vedeu 0.4.26 → 0.4.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/examples/material_colours_app.rb +5 -3
- data/examples/panel_app.rb +61 -0
- data/lib/vedeu/bindings.rb +10 -0
- data/lib/vedeu/cursor/cursor.rb +6 -0
- data/lib/vedeu/cursor/move.rb +20 -14
- data/lib/vedeu/dsl/interface.rb +56 -0
- data/lib/vedeu/models/escape_char.rb +7 -7
- data/lib/vedeu/models/interface.rb +14 -17
- data/lib/vedeu/models/panel.rb +17 -0
- data/lib/vedeu/models/stream.rb +1 -1
- data/lib/vedeu/output/border.rb +17 -37
- data/lib/vedeu/output/esc.rb +17 -16
- data/lib/vedeu/output/html_char.rb +18 -15
- data/lib/vedeu/output/refresh.rb +8 -2
- data/lib/vedeu/output/viewport.rb +3 -1
- data/lib/vedeu/repositories/repositories/cursors.rb +1 -1
- data/lib/vedeu/repositories/repositories/interfaces_repository.rb +8 -0
- data/lib/vedeu/repositories/repository.rb +9 -0
- data/lib/vedeu/storage/store.rb +1 -0
- data/lib/vedeu/support/terminal.rb +7 -0
- data/lib/vedeu/support/visibility.rb +15 -4
- data/test/lib/vedeu/buffers/buffer_test.rb +1 -0
- data/test/lib/vedeu/dsl/components/border_test.rb +1 -0
- data/test/lib/vedeu/dsl/interface_test.rb +35 -5
- data/test/lib/vedeu/models/escape_char_test.rb +7 -2
- data/test/lib/vedeu/models/focus_test.rb +6 -11
- data/test/lib/vedeu/models/interface_test.rb +12 -9
- data/test/lib/vedeu/output/border_test.rb +3 -0
- data/test/lib/vedeu/output/esc_test.rb +4 -0
- data/test/lib/vedeu/repositories/repositories/interfaces_repositories_test.rb +19 -0
- data/test/lib/vedeu/repositories/repository_test.rb +34 -0
- data/test/lib/vedeu/storage/store_test.rb +4 -4
- data/test/lib/vedeu/support/terminal_test.rb +22 -13
- data/test/test_helper.rb +6 -6
- data/vedeu.gemspec +4 -4
- metadata +10 -8
data/lib/vedeu/output/esc.rb
CHANGED
|
@@ -77,22 +77,23 @@ module Vedeu
|
|
|
77
77
|
# @return [Hash<Symbol => String>]
|
|
78
78
|
def actions
|
|
79
79
|
{
|
|
80
|
-
hide_cursor:
|
|
81
|
-
show_cursor:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
80
|
+
hide_cursor: "\e[?25l",
|
|
81
|
+
show_cursor: "\e[?25h",
|
|
82
|
+
cursor_position: "\e[6n",
|
|
83
|
+
bg_reset: "\e[49m",
|
|
84
|
+
blink: "\e[5m",
|
|
85
|
+
blink_off: "\e[25m",
|
|
86
|
+
bold: "\e[1m",
|
|
87
|
+
bold_off: "\e[22m",
|
|
88
|
+
border_on: "\e(0",
|
|
89
|
+
border_off: "\e(B",
|
|
90
|
+
dim: "\e[2m",
|
|
91
|
+
fg_reset: "\e[39m",
|
|
92
|
+
negative: "\e[7m",
|
|
93
|
+
positive: "\e[27m",
|
|
94
|
+
reset: "\e[0m",
|
|
95
|
+
underline: "\e[4m",
|
|
96
|
+
underline_off: "\e[24m",
|
|
96
97
|
}
|
|
97
98
|
end
|
|
98
99
|
|
|
@@ -85,28 +85,31 @@ module Vedeu
|
|
|
85
85
|
|
|
86
86
|
# @return [String]
|
|
87
87
|
def colour_bg
|
|
88
|
-
|
|
89
|
-
char.background.to_html
|
|
90
|
-
|
|
91
|
-
elsif defined_value?(char.parent_background.to_html)
|
|
92
|
-
char.parent_background.to_html
|
|
93
|
-
|
|
94
|
-
else
|
|
95
|
-
'#000'
|
|
96
|
-
|
|
97
|
-
end
|
|
88
|
+
colour(char, 'background', '#000')
|
|
98
89
|
end
|
|
99
90
|
|
|
100
91
|
# @return [String]
|
|
101
92
|
def colour_fg
|
|
102
|
-
|
|
103
|
-
|
|
93
|
+
colour(char, 'foreground', '#222')
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# @param char []
|
|
97
|
+
# @param type [String]
|
|
98
|
+
# @param default [String]
|
|
99
|
+
# @return [String]
|
|
100
|
+
def colour(char, type, default)
|
|
101
|
+
parent_type = ('parent_' + type).to_sym
|
|
102
|
+
type_to_html = char.send(type).send(:to_html)
|
|
103
|
+
parent_type_to_html = char.send(parent_type).send(:to_html)
|
|
104
|
+
|
|
105
|
+
if defined_value?(type_to_html)
|
|
106
|
+
type_to_html
|
|
104
107
|
|
|
105
|
-
elsif defined_value?(
|
|
106
|
-
|
|
108
|
+
elsif defined_value?(parent_type_to_html)
|
|
109
|
+
parent_type_to_html
|
|
107
110
|
|
|
108
111
|
else
|
|
109
|
-
|
|
112
|
+
default
|
|
110
113
|
|
|
111
114
|
end
|
|
112
115
|
end
|
data/lib/vedeu/output/refresh.rb
CHANGED
|
@@ -13,7 +13,7 @@ module Vedeu
|
|
|
13
13
|
message = 'Refreshing all interfaces'
|
|
14
14
|
|
|
15
15
|
Vedeu::Timer.for(:info, message) do
|
|
16
|
-
Vedeu.interfaces.
|
|
16
|
+
Vedeu.interfaces.zindexed.each { |model| by_name(model.name) }
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
@@ -33,7 +33,13 @@ module Vedeu
|
|
|
33
33
|
message = "Refreshing group: '#{group_name}'"
|
|
34
34
|
|
|
35
35
|
Vedeu::Timer.for(:info, message) do
|
|
36
|
-
Vedeu.groups.find!(group_name).members.each
|
|
36
|
+
Vedeu.groups.find!(group_name).members.each do |name|
|
|
37
|
+
Vedeu.interfaces.by_name(name)
|
|
38
|
+
end.sort do |a, b|
|
|
39
|
+
a.zindex <=> b.zindex
|
|
40
|
+
end.each do |name|
|
|
41
|
+
by_name(name)
|
|
42
|
+
end
|
|
37
43
|
end
|
|
38
44
|
end
|
|
39
45
|
|
|
@@ -54,12 +54,14 @@ module Vedeu
|
|
|
54
54
|
|
|
55
55
|
Vedeu::Timer.for(:output, "Rendering: #{name}") do
|
|
56
56
|
out = []
|
|
57
|
+
|
|
57
58
|
show[0...height].each_with_index do |line, iy|
|
|
58
59
|
line[0...width].each_with_index do |column, ix|
|
|
59
|
-
column.position = [by + iy, bx + ix]
|
|
60
|
+
column.position = Vedeu::Position[by + iy, bx + ix]
|
|
60
61
|
out << column
|
|
61
62
|
end
|
|
62
63
|
end
|
|
64
|
+
|
|
63
65
|
out
|
|
64
66
|
end
|
|
65
67
|
end
|
|
@@ -20,6 +20,14 @@ module Vedeu
|
|
|
20
20
|
null Vedeu::Null::Interface
|
|
21
21
|
# real Vedeu::Interface
|
|
22
22
|
|
|
23
|
+
# Returns the interfaces in zindex order.
|
|
24
|
+
#
|
|
25
|
+
# @return [Array<Vedeu::Interface>]
|
|
26
|
+
# @see Vedeu::DSL::Interface#zindex
|
|
27
|
+
def zindexed
|
|
28
|
+
all.sort { |a, b| a.zindex <=> b.zindex }
|
|
29
|
+
end
|
|
30
|
+
|
|
23
31
|
end # InterfacesRepository
|
|
24
32
|
|
|
25
33
|
end # Vedeu
|
|
@@ -39,6 +39,15 @@ module Vedeu
|
|
|
39
39
|
self.class
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
+
# @return [Array<void>] An array containing each stored model.
|
|
43
|
+
def all
|
|
44
|
+
return [] if empty?
|
|
45
|
+
return storage.values if storage.is_a?(Hash)
|
|
46
|
+
return storage.to_a if storage.is_a?(Set)
|
|
47
|
+
|
|
48
|
+
storage
|
|
49
|
+
end
|
|
50
|
+
|
|
42
51
|
# @param name [String] The name of the stored model.
|
|
43
52
|
# @return [void]
|
|
44
53
|
def by_name(name)
|
data/lib/vedeu/storage/store.rb
CHANGED
|
@@ -175,6 +175,13 @@ module Vedeu
|
|
|
175
175
|
@mode ||= Vedeu::Configuration.terminal_mode
|
|
176
176
|
end
|
|
177
177
|
|
|
178
|
+
# Returns the position of the cursor.
|
|
179
|
+
#
|
|
180
|
+
# @return [Vedeu::Position]
|
|
181
|
+
def cursor
|
|
182
|
+
# Vedeu.trigger(:_cursor_position_)
|
|
183
|
+
end
|
|
184
|
+
|
|
178
185
|
# Returns a coordinate tuple of the format [y, x], where `y` is the row/line
|
|
179
186
|
# and `x` is the column/character.
|
|
180
187
|
#
|
|
@@ -37,8 +37,13 @@ module Vedeu
|
|
|
37
37
|
|
|
38
38
|
# @return [void]
|
|
39
39
|
def show
|
|
40
|
-
model.visible
|
|
41
|
-
|
|
40
|
+
if model.visible?
|
|
41
|
+
model
|
|
42
|
+
|
|
43
|
+
else
|
|
44
|
+
model.visible = true
|
|
45
|
+
model.store
|
|
46
|
+
end
|
|
42
47
|
end
|
|
43
48
|
|
|
44
49
|
# @return [Symbol]
|
|
@@ -54,8 +59,14 @@ module Vedeu
|
|
|
54
59
|
|
|
55
60
|
# @return [void]
|
|
56
61
|
def hide
|
|
57
|
-
model.visible
|
|
58
|
-
|
|
62
|
+
if model.visible?
|
|
63
|
+
model.visible = false
|
|
64
|
+
model.store
|
|
65
|
+
|
|
66
|
+
else
|
|
67
|
+
model
|
|
68
|
+
|
|
69
|
+
end
|
|
59
70
|
end
|
|
60
71
|
|
|
61
72
|
# @return [void]
|
|
@@ -16,11 +16,7 @@ module Vedeu
|
|
|
16
16
|
let(:client) {}
|
|
17
17
|
|
|
18
18
|
before { Vedeu.interfaces.reset }
|
|
19
|
-
|
|
20
|
-
describe 'alias methods' do
|
|
21
|
-
it { instance.must_respond_to(:keys) }
|
|
22
|
-
it { instance.must_respond_to(:line) }
|
|
23
|
-
end
|
|
19
|
+
after { Vedeu.interfaces.reset }
|
|
24
20
|
|
|
25
21
|
describe '#initialize' do
|
|
26
22
|
it { instance.must_be_instance_of(described) }
|
|
@@ -68,6 +64,13 @@ module Vedeu
|
|
|
68
64
|
it { subject.must_be_instance_of(Vedeu::Border) }
|
|
69
65
|
end
|
|
70
66
|
|
|
67
|
+
describe '#button' do
|
|
68
|
+
let(:label) { 'No' }
|
|
69
|
+
let(:_value) { false }
|
|
70
|
+
|
|
71
|
+
subject { instance.button(label, _value) }
|
|
72
|
+
end
|
|
73
|
+
|
|
71
74
|
describe '#cursor' do
|
|
72
75
|
let(:_value) {}
|
|
73
76
|
|
|
@@ -244,6 +247,7 @@ module Vedeu
|
|
|
244
247
|
}
|
|
245
248
|
|
|
246
249
|
it { subject.must_be_instance_of(Vedeu::Keymap) }
|
|
250
|
+
it { instance.must_respond_to(:keys) }
|
|
247
251
|
end
|
|
248
252
|
|
|
249
253
|
describe '#lines' do
|
|
@@ -260,6 +264,8 @@ module Vedeu
|
|
|
260
264
|
|
|
261
265
|
it { proc { subject }.must_raise(InvalidSyntax) }
|
|
262
266
|
end
|
|
267
|
+
|
|
268
|
+
it { instance.must_respond_to(:line) }
|
|
263
269
|
end
|
|
264
270
|
|
|
265
271
|
describe '#name' do
|
|
@@ -268,7 +274,18 @@ module Vedeu
|
|
|
268
274
|
it { subject; model.name.must_equal('nickel') }
|
|
269
275
|
end
|
|
270
276
|
|
|
277
|
+
describe '#no_cursor!' do
|
|
278
|
+
subject { instance.no_cursor! }
|
|
279
|
+
|
|
280
|
+
it {
|
|
281
|
+
subject
|
|
282
|
+
Vedeu.cursors.find('actinium').visible?.must_equal(false)
|
|
283
|
+
}
|
|
284
|
+
end
|
|
285
|
+
|
|
271
286
|
describe '#show!' do
|
|
287
|
+
after { Vedeu.interfaces.reset }
|
|
288
|
+
|
|
272
289
|
subject {
|
|
273
290
|
Vedeu.interface 'xenon' do
|
|
274
291
|
show!
|
|
@@ -279,6 +296,8 @@ module Vedeu
|
|
|
279
296
|
end
|
|
280
297
|
|
|
281
298
|
describe '#hide!' do
|
|
299
|
+
after { Vedeu.interfaces.reset }
|
|
300
|
+
|
|
282
301
|
subject {
|
|
283
302
|
Vedeu.interface 'xenon' do
|
|
284
303
|
hide!
|
|
@@ -295,6 +314,17 @@ module Vedeu
|
|
|
295
314
|
it { instance.visible(:show).must_equal(true) }
|
|
296
315
|
end
|
|
297
316
|
|
|
317
|
+
describe '#zindex' do
|
|
318
|
+
let(:_value) { 1 }
|
|
319
|
+
|
|
320
|
+
subject { instance.zindex(_value) }
|
|
321
|
+
|
|
322
|
+
it { subject.must_equal(1) }
|
|
323
|
+
|
|
324
|
+
it { instance.must_respond_to(:z_index) }
|
|
325
|
+
it { instance.must_respond_to(:z) }
|
|
326
|
+
end
|
|
327
|
+
|
|
298
328
|
end # Interface
|
|
299
329
|
|
|
300
330
|
end # DSL
|
|
@@ -29,6 +29,8 @@ module Vedeu
|
|
|
29
29
|
|
|
30
30
|
it { subject.must_equal(false) }
|
|
31
31
|
end
|
|
32
|
+
|
|
33
|
+
it { instance.must_respond_to(:==) }
|
|
32
34
|
end
|
|
33
35
|
|
|
34
36
|
describe '#inspect' do
|
|
@@ -47,8 +49,11 @@ module Vedeu
|
|
|
47
49
|
it { instance.style.must_equal('') }
|
|
48
50
|
end
|
|
49
51
|
|
|
50
|
-
describe '#
|
|
51
|
-
it { instance.
|
|
52
|
+
describe '#value' do
|
|
53
|
+
it { instance.value.must_be_instance_of(String) }
|
|
54
|
+
|
|
55
|
+
it { instance.must_respond_to(:to_s) }
|
|
56
|
+
it { instance.must_respond_to(:to_str) }
|
|
52
57
|
end
|
|
53
58
|
|
|
54
59
|
end # EscapeChar
|
|
@@ -13,14 +13,15 @@ module Vedeu
|
|
|
13
13
|
Vedeu.interface('lead') {}
|
|
14
14
|
Vedeu.interface('bismuth') {}
|
|
15
15
|
end
|
|
16
|
+
after { Vedeu.interfaces.reset }
|
|
16
17
|
|
|
17
18
|
describe '#add' do
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
end
|
|
19
|
+
before do
|
|
20
|
+
Focus.reset
|
|
21
|
+
Vedeu.interfaces.reset
|
|
22
|
+
end
|
|
23
23
|
|
|
24
|
+
context 'adds an interface to storage' do
|
|
24
25
|
it {
|
|
25
26
|
Focus.add('thallium').must_equal(['thallium'])
|
|
26
27
|
}
|
|
@@ -28,8 +29,6 @@ module Vedeu
|
|
|
28
29
|
|
|
29
30
|
context 'does not add it again if already exists' do
|
|
30
31
|
before do
|
|
31
|
-
Focus.reset
|
|
32
|
-
Vedeu.interfaces.reset
|
|
33
32
|
Vedeu.interface('thallium') {}
|
|
34
33
|
end
|
|
35
34
|
|
|
@@ -49,8 +48,6 @@ module Vedeu
|
|
|
49
48
|
|
|
50
49
|
context 'adds the interface to storage focussed' do
|
|
51
50
|
before do
|
|
52
|
-
Focus.reset
|
|
53
|
-
Vedeu.interfaces.reset
|
|
54
51
|
Vedeu.interface('thallium') {}
|
|
55
52
|
end
|
|
56
53
|
|
|
@@ -63,8 +60,6 @@ module Vedeu
|
|
|
63
60
|
|
|
64
61
|
context 'adds the interface to storage unfocussed' do
|
|
65
62
|
before do
|
|
66
|
-
Focus.reset
|
|
67
|
-
Vedeu.interfaces.reset
|
|
68
63
|
Vedeu.interface('thallium') {}
|
|
69
64
|
end
|
|
70
65
|
|
|
@@ -8,15 +8,16 @@ module Vedeu
|
|
|
8
8
|
let(:instance) { described.new(attributes) }
|
|
9
9
|
let(:attributes) {
|
|
10
10
|
{
|
|
11
|
-
client:
|
|
12
|
-
colour:
|
|
13
|
-
delay:
|
|
14
|
-
group:
|
|
15
|
-
lines:
|
|
16
|
-
name:
|
|
17
|
-
parent:
|
|
18
|
-
style:
|
|
11
|
+
client: client,
|
|
12
|
+
colour: colour,
|
|
13
|
+
delay: delay,
|
|
14
|
+
group: group,
|
|
15
|
+
lines: lines,
|
|
16
|
+
name: _name,
|
|
17
|
+
parent: parent,
|
|
18
|
+
style: style,
|
|
19
19
|
visible: visible,
|
|
20
|
+
zindex: zindex,
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
let(:client) {}
|
|
@@ -29,6 +30,7 @@ module Vedeu
|
|
|
29
30
|
let(:repository) { Vedeu.interfaces }
|
|
30
31
|
let(:style) {}
|
|
31
32
|
let(:visible) { true }
|
|
33
|
+
let(:zindex) { 1 }
|
|
32
34
|
|
|
33
35
|
describe '#initialize' do
|
|
34
36
|
subject { instance }
|
|
@@ -42,6 +44,7 @@ module Vedeu
|
|
|
42
44
|
it { subject.instance_variable_get('@parent').must_equal(parent) }
|
|
43
45
|
it { subject.instance_variable_get('@repository').must_equal(repository) }
|
|
44
46
|
it { subject.instance_variable_get('@visible').must_equal(visible) }
|
|
47
|
+
it { subject.instance_variable_get('@zindex').must_equal(zindex) }
|
|
45
48
|
end
|
|
46
49
|
|
|
47
50
|
describe '#lines?' do
|
|
@@ -91,7 +94,7 @@ module Vedeu
|
|
|
91
94
|
it { subject.must_be_instance_of(Array) }
|
|
92
95
|
|
|
93
96
|
context 'when the interface is visible' do
|
|
94
|
-
it { subject.must_equal([
|
|
97
|
+
it { subject.must_equal([:clear, :border, :view]) }
|
|
95
98
|
end
|
|
96
99
|
|
|
97
100
|
context 'when the interface is not visible' do
|