vedeu 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/LICENSE.txt +5 -0
- data/bin/vedeu +3 -1
- data/docs/api.md +2 -0
- data/examples/cursor_app/cursor_app.rb +22 -7
- data/examples/hello_world.rb +42 -0
- data/lib/vedeu.rb +5 -5
- data/lib/vedeu/api/api.rb +16 -33
- data/lib/vedeu/api/helpers.rb +86 -0
- data/lib/vedeu/api/interface.rb +60 -17
- data/lib/vedeu/api/keymap.rb +5 -0
- data/lib/vedeu/api/line.rb +52 -34
- data/lib/vedeu/api/menu.rb +1 -1
- data/lib/vedeu/api/stream.rb +0 -34
- data/lib/vedeu/configuration/api.rb +10 -10
- data/lib/vedeu/configuration/cli.rb +1 -1
- data/lib/vedeu/launcher.rb +21 -6
- data/lib/vedeu/models/background.rb +1 -1
- data/lib/vedeu/models/composition.rb +1 -1
- data/lib/vedeu/models/cursor.rb +25 -35
- data/lib/vedeu/models/foreground.rb +1 -1
- data/lib/vedeu/models/geometry.rb +216 -6
- data/lib/vedeu/models/interface.rb +14 -16
- data/lib/vedeu/models/keymap.rb +38 -6
- data/lib/vedeu/models/line.rb +1 -1
- data/lib/vedeu/models/stream.rb +1 -1
- data/lib/vedeu/output/compositor.rb +1 -1
- data/lib/vedeu/output/render.rb +1 -5
- data/lib/vedeu/output/viewport.rb +37 -2
- data/lib/vedeu/repositories/buffers.rb +21 -27
- data/lib/vedeu/repositories/cursors.rb +3 -15
- data/lib/vedeu/repositories/focus.rb +2 -6
- data/lib/vedeu/repositories/groups.rb +1 -1
- data/lib/vedeu/repositories/interfaces.rb +1 -1
- data/lib/vedeu/repositories/keymaps.rb +26 -22
- data/lib/vedeu/repositories/menus.rb +1 -1
- data/lib/vedeu/repositories/offsets.rb +30 -12
- data/lib/vedeu/repositories/positional.rb +23 -0
- data/lib/vedeu/support/colour_translator.rb +1 -16
- data/lib/vedeu/support/esc.rb +23 -28
- data/lib/vedeu/support/event.rb +6 -14
- data/lib/vedeu/{output → support}/refresh.rb +0 -0
- data/lib/vedeu/support/registrar.rb +6 -14
- data/lib/vedeu/support/repository.rb +3 -2
- data/lib/vedeu/support/terminal.rb +9 -13
- data/lib/vedeu/support/trace.rb +2 -3
- data/test/integration/cursors_test.rb +9 -0
- data/test/integration/views/basic_view_test.rb +19 -0
- data/test/lib/vedeu/api/api_test.rb +28 -5
- data/test/lib/vedeu/api/composition_test.rb +7 -3
- data/test/lib/vedeu/api/defined_test.rb +9 -3
- data/test/lib/vedeu/api/helpers_test.rb +39 -5
- data/test/lib/vedeu/api/interface_test.rb +88 -8
- data/test/lib/vedeu/api/keymap_test.rb +5 -3
- data/test/lib/vedeu/api/line_test.rb +9 -3
- data/test/lib/vedeu/api/menu_test.rb +11 -7
- data/test/lib/vedeu/api/stream_test.rb +9 -31
- data/test/lib/vedeu/application_test.rb +25 -2
- data/test/lib/vedeu/configuration/api_test.rb +5 -3
- data/test/lib/vedeu/configuration/cli_test.rb +5 -3
- data/test/lib/vedeu/configuration/configuration_test.rb +5 -2
- data/test/lib/vedeu/input/input_test.rb +5 -2
- data/test/lib/vedeu/launcher_test.rb +37 -2
- data/test/lib/vedeu/models/background_test.rb +6 -2
- data/test/lib/vedeu/models/char_test.rb +9 -6
- data/test/lib/vedeu/models/colour_test.rb +6 -2
- data/test/lib/vedeu/models/composition_test.rb +4 -2
- data/test/lib/vedeu/models/cursor_test.rb +27 -16
- data/test/lib/vedeu/models/foreground_test.rb +6 -2
- data/test/lib/vedeu/models/geometry_test.rb +6 -2
- data/test/lib/vedeu/models/interface_test.rb +5 -2
- data/test/lib/vedeu/models/keymap_test.rb +6 -4
- data/test/lib/vedeu/models/line_test.rb +5 -2
- data/test/lib/vedeu/models/offset_test.rb +7 -3
- data/test/lib/vedeu/models/stream_test.rb +4 -2
- data/test/lib/vedeu/models/style_test.rb +5 -2
- data/test/lib/vedeu/output/clear_test.rb +6 -2
- data/test/lib/vedeu/output/compositor_test.rb +8 -4
- data/test/lib/vedeu/output/render_test.rb +9 -6
- data/test/lib/vedeu/output/view_test.rb +7 -3
- data/test/lib/vedeu/output/viewport_test.rb +42 -9
- data/test/lib/vedeu/repositories/buffers_test.rb +52 -12
- data/test/lib/vedeu/repositories/cursors_test.rb +4 -26
- data/test/lib/vedeu/repositories/events_test.rb +6 -2
- data/test/lib/vedeu/repositories/focus_test.rb +5 -2
- data/test/lib/vedeu/repositories/groups_test.rb +5 -2
- data/test/lib/vedeu/repositories/interfaces_test.rb +4 -2
- data/test/lib/vedeu/repositories/keymaps_test.rb +8 -2
- data/test/lib/vedeu/repositories/menus_test.rb +3 -2
- data/test/lib/vedeu/repositories/offsets_test.rb +26 -19
- data/test/lib/vedeu/repositories/positional_test.rb +50 -0
- data/test/lib/vedeu/support/coercions_test.rb +7 -3
- data/test/lib/vedeu/support/colour_translator_test.rb +6 -2
- data/test/lib/vedeu/support/common_test.rb +5 -3
- data/test/lib/vedeu/support/esc_test.rb +6 -2
- data/test/lib/vedeu/support/event_test.rb +6 -2
- data/test/lib/vedeu/support/grid_test.rb +9 -3
- data/test/lib/vedeu/support/keymap_validator_test.rb +5 -2
- data/test/lib/vedeu/support/log_test.rb +4 -2
- data/test/lib/vedeu/support/menu_test.rb +10 -2
- data/test/lib/vedeu/support/position_test.rb +10 -2
- data/test/lib/vedeu/support/presentation_test.rb +6 -3
- data/test/lib/vedeu/{output → support}/refresh_test.rb +6 -2
- data/test/lib/vedeu/support/registrar_test.rb +2 -2
- data/test/lib/vedeu/support/repository_test.rb +4 -3
- data/test/lib/vedeu/support/terminal_test.rb +6 -2
- data/test/lib/vedeu/support/trace_test.rb +17 -2
- data/test/lib/vedeu_test.rb +1 -1
- data/vedeu.gemspec +2 -2
- metadata +13 -13
- data/lib/vedeu/output/area.rb +0 -284
- data/lib/vedeu/support/move.rb +0 -50
- data/test/lib/vedeu/output/area_test.rb +0 -242
- data/test/lib/vedeu/support/move_test.rb +0 -35
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
describe Compositor do
|
6
|
+
|
5
7
|
before do
|
6
8
|
Interfaces.reset
|
7
9
|
Terminal.console.stubs(:print)
|
@@ -27,7 +29,7 @@ module Vedeu
|
|
27
29
|
"\e[1;1H \e[1;1H" \
|
28
30
|
"\e[2;1H \e[2;1H" \
|
29
31
|
"\e[3;1H \e[3;1H" \
|
30
|
-
"\e[1;1H\e[?
|
32
|
+
"\e[1;1H\e[?25l"
|
31
33
|
])
|
32
34
|
end
|
33
35
|
end
|
@@ -62,10 +64,12 @@ module Vedeu
|
|
62
64
|
"\e[1;1Hargon" \
|
63
65
|
"\e[2;1Hboron" \
|
64
66
|
"\e[3;1Hradon" \
|
65
|
-
"\e[1;1H\e[?
|
67
|
+
"\e[1;1H\e[?25l"
|
66
68
|
])
|
67
69
|
end
|
68
70
|
end
|
69
71
|
end
|
70
|
-
|
71
|
-
end
|
72
|
+
|
73
|
+
end # Compositor
|
74
|
+
|
75
|
+
end # Vedeu
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
describe Render do
|
6
|
+
|
5
7
|
before do
|
6
8
|
Buffers.reset
|
7
9
|
Cursors.reset
|
@@ -37,7 +39,7 @@ module Vedeu
|
|
37
39
|
"\e[1;1Hthis is the first" \
|
38
40
|
"\e[2;1Hthis is the second and it is lon" \
|
39
41
|
"\e[3;1Hthis is the third, it is even lo" \
|
40
|
-
"\e[1;1H\e[?
|
42
|
+
"\e[1;1H\e[?25l"
|
41
43
|
)
|
42
44
|
end
|
43
45
|
|
@@ -55,7 +57,7 @@ module Vedeu
|
|
55
57
|
"\e[1;1H \e[1;1H" \
|
56
58
|
"\e[2;1H \e[2;1H" \
|
57
59
|
"\e[3;1H \e[3;1H" \
|
58
|
-
"\e[1;1H\e[?
|
60
|
+
"\e[1;1H\e[?25l"
|
59
61
|
)
|
60
62
|
end
|
61
63
|
|
@@ -89,7 +91,7 @@ module Vedeu
|
|
89
91
|
"\e[1;1Hthis is the first" \
|
90
92
|
"\e[2;1H" \
|
91
93
|
"\e[3;1Hthis is the third, it is even lo" \
|
92
|
-
"\e[1;1H\e[?
|
94
|
+
"\e[1;1H\e[?25l"
|
93
95
|
)
|
94
96
|
end
|
95
97
|
|
@@ -139,7 +141,8 @@ module Vedeu
|
|
139
141
|
)
|
140
142
|
end
|
141
143
|
end
|
142
|
-
|
143
144
|
end
|
144
|
-
|
145
|
-
end
|
145
|
+
|
146
|
+
end # Render
|
147
|
+
|
148
|
+
end # Vedeu
|
@@ -1,17 +1,21 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
class ViewTest < View
|
5
6
|
def render
|
6
7
|
{ interfaces: [] }
|
7
8
|
end
|
8
|
-
end
|
9
|
+
end # ViewTest
|
9
10
|
|
10
11
|
describe View do
|
12
|
+
|
11
13
|
describe '.render' do
|
12
14
|
it 'returns' do
|
13
15
|
ViewTest.render.must_equal([])
|
14
16
|
end
|
15
17
|
end
|
16
|
-
|
17
|
-
end
|
18
|
+
|
19
|
+
end # View
|
20
|
+
|
21
|
+
end # Vedeu
|
@@ -12,25 +12,58 @@ module Vedeu
|
|
12
12
|
height: 2,
|
13
13
|
},
|
14
14
|
lines: [
|
15
|
-
{
|
15
|
+
{
|
16
16
|
streams: [{
|
17
|
-
text: 'Something interesting ',
|
17
|
+
text: 'Something interesting ',
|
18
18
|
},{
|
19
|
-
text: 'on this line ',
|
19
|
+
text: 'on this line ',
|
20
20
|
},{
|
21
|
-
text: 'would be cool, eh?'
|
21
|
+
text: 'would be cool, eh?'
|
22
22
|
}]
|
23
|
-
}, {
|
23
|
+
}, {
|
24
24
|
streams: [{
|
25
|
-
text: 'Maybe a lyric, a little ditty ',
|
25
|
+
text: 'Maybe a lyric, a little ditty ',
|
26
26
|
},{
|
27
|
-
text: 'to help you unwind.',
|
27
|
+
text: 'to help you unwind.',
|
28
28
|
}]
|
29
29
|
}
|
30
30
|
]
|
31
31
|
})
|
32
32
|
}
|
33
33
|
|
34
|
-
|
34
|
+
describe '#initialize' do
|
35
|
+
it 'returns an instance of itself' do
|
36
|
+
Viewport.new(interface).must_be_instance_of(Viewport)
|
37
|
+
end
|
38
|
+
end
|
35
39
|
|
36
|
-
|
40
|
+
describe '.show' do
|
41
|
+
it 'returns an Array' do
|
42
|
+
Viewport.show(interface).must_be_instance_of(Array)
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when there is no content' do
|
46
|
+
before { interface.stubs(:content).returns([]) }
|
47
|
+
|
48
|
+
it 'returns an empty collection' do
|
49
|
+
Viewport.show(interface).must_equal([])
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'when there is content, it returns only the visible content ' \
|
54
|
+
'determined by the geometry of the interface and the current ' \
|
55
|
+
'offset stored' do
|
56
|
+
it 'returns a collection of lines, each a collection of characters' do
|
57
|
+
Viewport.show(interface).must_equal(
|
58
|
+
[
|
59
|
+
['S', 'o', 'm', 'e', 't', 'h', 'i', 'n', 'g', ' ', 'i', 'n', 't', 'e', 'r', 'e', 's', 't', 'i', 'n', 'g', ' ', 'o', 'n', ' ', 't', 'h', 'i', 's', ' '],
|
60
|
+
['M', 'a', 'y', 'b', 'e', ' ', 'a', ' ', 'l', 'y', 'r', 'i', 'c', ',', ' ', 'a', ' ', 'l', 'i', 't', 't', 'l', 'e', ' ', 'd', 'i', 't', 't', 'y', ' ']
|
61
|
+
]
|
62
|
+
)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end # Viewport
|
68
|
+
|
69
|
+
end # Vedeu
|
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
describe Buffers do
|
5
6
|
|
6
|
-
|
7
|
-
before { Buffers.reset }
|
7
|
+
before { Buffers.reset }
|
8
8
|
|
9
|
+
describe '.add' do
|
9
10
|
it 'returns the name of the buffer added to storage' do
|
10
11
|
Buffers.add({ name: 'molybdenum' }).must_equal('molybdenum')
|
11
12
|
end
|
@@ -18,32 +19,71 @@ module Vedeu
|
|
18
19
|
|
19
20
|
context 'when the buffer is already registered' do
|
20
21
|
it 'retrieves the buffer in storage, and adds the attributes to the ' \
|
21
|
-
|
22
|
+
'back buffer, preserving the front which may already have content' do
|
22
23
|
skip
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
27
|
context 'when the buffer was not registered' do
|
27
28
|
it 'stores a new buffer by name, and adds the attributes to the back ' \
|
28
|
-
|
29
|
+
'buffer' do
|
29
30
|
skip
|
30
31
|
end
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
35
|
+
describe '.back' do
|
36
|
+
context 'when the buffer does not exist' do
|
37
|
+
it 'raises an exception' do
|
38
|
+
proc { Buffers.back('actinium') }.must_raise(BufferNotFound)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when the buffer exists' do
|
43
|
+
before { Buffers.add({ name: 'mercury' }) }
|
44
|
+
|
45
|
+
it 'returns a Hash' do
|
46
|
+
Buffers.back('mercury').must_be_instance_of(Hash)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'returns the stored attributes' do
|
50
|
+
Buffers.back('mercury').must_equal({ name: 'mercury' })
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '.front' do
|
56
|
+
context 'when the buffer does not exist' do
|
57
|
+
it 'raises an exception' do
|
58
|
+
proc { Buffers.front('mercury') }.must_raise(BufferNotFound)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'when the buffer exists but there is no content' do
|
63
|
+
before { Buffers.add({ name: 'actinium' }) }
|
64
|
+
|
65
|
+
it 'returns a NilClass' do
|
66
|
+
Buffers.front('actinium').must_be_instance_of(NilClass)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
34
71
|
describe '.latest' do
|
35
|
-
context 'when the buffer does not exist
|
36
|
-
it '' do
|
37
|
-
|
72
|
+
context 'when the buffer does not exist' do
|
73
|
+
it 'raises an exception' do
|
74
|
+
proc { Buffers.front('nobelium') }.must_raise(BufferNotFound)
|
38
75
|
end
|
39
76
|
end
|
40
77
|
|
41
|
-
context 'when the buffer
|
42
|
-
|
43
|
-
|
78
|
+
context 'when the buffer exists and there is content' do
|
79
|
+
before { Buffers.add({ name: 'nobelium' }) }
|
80
|
+
|
81
|
+
it 'returns the stored attributes' do
|
82
|
+
Buffers.latest('nobelium').must_equal({ name: 'nobelium' })
|
44
83
|
end
|
45
84
|
end
|
46
85
|
end
|
47
86
|
|
48
|
-
end
|
49
|
-
|
87
|
+
end # Buffers
|
88
|
+
|
89
|
+
end # Vedeu
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
describe Cursors do
|
5
6
|
|
6
7
|
before do
|
@@ -8,30 +9,6 @@ module Vedeu
|
|
8
9
|
Registrar.record({ name: 'chromium' })
|
9
10
|
end
|
10
11
|
|
11
|
-
describe '#add' do
|
12
|
-
let(:attributes) { { name: 'chromium' } }
|
13
|
-
|
14
|
-
it 'returns a new Cursor after registering' do
|
15
|
-
Cursors.add(attributes).must_be_instance_of(Cursor)
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'returns a new Cursor after updating' do
|
19
|
-
Cursors.update(attributes).must_be_instance_of(Cursor)
|
20
|
-
end
|
21
|
-
|
22
|
-
context 'when the attributes do not have the :name key' do
|
23
|
-
let(:attributes) { { no_name_key: 'some_value' } }
|
24
|
-
|
25
|
-
it 'raises an exception' do
|
26
|
-
proc { Cursors.update(attributes) }.must_raise(MissingRequired)
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'raises an exception' do
|
30
|
-
proc { Cursors.add(attributes) }.must_raise(MissingRequired)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
12
|
describe '#hide' do
|
36
13
|
it 'sets the state attribute of the Cursor to :hide' do
|
37
14
|
cursor = Cursors.hide
|
@@ -46,5 +23,6 @@ module Vedeu
|
|
46
23
|
end
|
47
24
|
end
|
48
25
|
|
49
|
-
end
|
50
|
-
|
26
|
+
end # Cursors
|
27
|
+
|
28
|
+
end # Vedeu
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
describe Events do
|
6
|
+
|
5
7
|
describe '#add' do
|
6
8
|
it 'adds the event' do
|
7
9
|
Events.add(:sulphur) { proc { |x| x } }
|
@@ -37,5 +39,7 @@ module Vedeu
|
|
37
39
|
Events.use(:_not_found_).must_be_empty
|
38
40
|
end
|
39
41
|
end
|
40
|
-
|
41
|
-
end
|
42
|
+
|
43
|
+
end # Events
|
44
|
+
|
45
|
+
end # Vedeu
|