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,6 +1,29 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
describe Application do
|
5
|
-
|
6
|
-
|
6
|
+
|
7
|
+
describe '.start' do
|
8
|
+
it { skip }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '.restart' do
|
12
|
+
it { skip }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '.stop' do
|
16
|
+
it { skip }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#initialize' do
|
20
|
+
it { skip }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#start' do
|
24
|
+
it { skip }
|
25
|
+
end
|
26
|
+
|
27
|
+
end # Application
|
28
|
+
|
29
|
+
end # Vedeu
|
@@ -1,6 +1,41 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
describe Launcher do
|
5
|
-
|
6
|
-
|
6
|
+
before do
|
7
|
+
Configuration.stubs(:configure)
|
8
|
+
Application.stubs(:start)
|
9
|
+
Kernel.stubs(:exit)
|
10
|
+
Kernel.stubs(:puts)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '.execute' do
|
14
|
+
it { skip }
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#initialize' do
|
18
|
+
it 'returns an instance of itself' do
|
19
|
+
Launcher.new.must_be_instance_of(Launcher)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#execute!' do
|
24
|
+
it 'returns 0 for successful execution' do
|
25
|
+
Launcher.new.execute!.must_equal(0)
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'when execution causes an uncaught exception' do
|
29
|
+
before { Application.stubs(:start).raises(StandardError) }
|
30
|
+
|
31
|
+
it 'returns 1 for unsuccessful execution' do
|
32
|
+
skip 'This test is incorrect and fails.'
|
33
|
+
|
34
|
+
Launcher.new.execute!.must_equal(1)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end # Launcher
|
40
|
+
|
41
|
+
end # Vedeu
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
describe Background do
|
6
|
+
|
5
7
|
describe '.escape_sequence' do
|
6
8
|
describe 'when the colour is empty' do
|
7
9
|
it 'returns an empty String' do
|
@@ -79,5 +81,7 @@ module Vedeu
|
|
79
81
|
end
|
80
82
|
end
|
81
83
|
end
|
82
|
-
|
83
|
-
end
|
84
|
+
|
85
|
+
end # Background
|
86
|
+
|
87
|
+
end # Vedeu
|
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
describe Char do
|
5
|
-
|
6
|
+
|
7
|
+
let(:char) { Char.new(attributes) }
|
6
8
|
let(:attributes) {
|
7
9
|
{
|
8
10
|
colour: { foreground: '#ffff00', background: '#0000ff' },
|
@@ -21,20 +23,20 @@ module Vedeu
|
|
21
23
|
|
22
24
|
describe '#initialize' do
|
23
25
|
it 'returns a new instance of Char' do
|
24
|
-
|
26
|
+
char.must_be_instance_of(Char)
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
28
30
|
describe '#to_s' do
|
29
31
|
it 'returns a String' do
|
30
|
-
|
32
|
+
char.to_s.must_be_instance_of(String)
|
31
33
|
end
|
32
34
|
|
33
35
|
it 'returns the escape sequences and content' do
|
34
36
|
# - char colours and style as set in Stream#chars.
|
35
37
|
# - the value.
|
36
38
|
# - the colours and style of the line which the Char belongs to.
|
37
|
-
|
39
|
+
char.to_s.must_equal(
|
38
40
|
"\e[38;2;255;255;0m\e[48;2;0;0;255m" \
|
39
41
|
"a" \
|
40
42
|
"\e[38;2;0;255;0m\e[48;2;255;0;255m"
|
@@ -42,5 +44,6 @@ module Vedeu
|
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
45
|
-
end
|
46
|
-
|
47
|
+
end # Char
|
48
|
+
|
49
|
+
end # Vedeu
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
describe Colour do
|
6
|
+
|
5
7
|
describe '#initialize' do
|
6
8
|
it 'returns an instance of itself' do
|
7
9
|
attributes = {}
|
@@ -58,5 +60,7 @@ module Vedeu
|
|
58
60
|
Colour.new.to_s.must_equal('')
|
59
61
|
end
|
60
62
|
end
|
61
|
-
|
62
|
-
end
|
63
|
+
|
64
|
+
end # Colour
|
65
|
+
|
66
|
+
end # Vedeu
|
@@ -1,13 +1,15 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
describe Cursor do
|
6
|
+
|
5
7
|
let(:attributes) {
|
6
8
|
{
|
7
|
-
name:
|
8
|
-
state:
|
9
|
-
x:
|
10
|
-
y:
|
9
|
+
name: 'silver',
|
10
|
+
state: :show,
|
11
|
+
x: 19,
|
12
|
+
y: 8
|
11
13
|
}
|
12
14
|
}
|
13
15
|
|
@@ -96,16 +98,6 @@ module Vedeu
|
|
96
98
|
end
|
97
99
|
end
|
98
100
|
|
99
|
-
describe '#visible?' do
|
100
|
-
it 'returns false when the cursor is not visible' do
|
101
|
-
Cursor.new({ state: :hide }).visible?.must_equal(false)
|
102
|
-
end
|
103
|
-
|
104
|
-
it 'returns true when the cursor is visible' do
|
105
|
-
Cursor.new({ state: :show }).visible?.must_equal(true)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
101
|
describe '#show' do
|
110
102
|
it 'sets the state attribute to :show' do
|
111
103
|
cursor = Cursor.new(attributes)
|
@@ -127,10 +119,27 @@ module Vedeu
|
|
127
119
|
cursor.attributes.must_equal(
|
128
120
|
{ name: 'silver', state: :hide, x: 19, y: 8 }
|
129
121
|
)
|
122
|
+
cursor.to_s.must_equal("\e[8;19H\e[?25l")
|
130
123
|
end
|
131
124
|
end
|
132
125
|
|
133
126
|
describe '#to_s' do
|
127
|
+
context 'when the cursor state is :show' do
|
128
|
+
it 'returns an escape sequence for showing the cursor (and position)' do
|
129
|
+
cursor = Cursor.new(attributes)
|
130
|
+
cursor.show
|
131
|
+
cursor.to_s.must_equal("\e[8;19H\e[?25h")
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
context 'when the cursor state is :hide' do
|
136
|
+
it 'returns an escape sequence for hiding the cursor (and position)' do
|
137
|
+
cursor = Cursor.new(attributes)
|
138
|
+
cursor.hide
|
139
|
+
cursor.to_s.must_equal("\e[8;19H\e[?25l")
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
134
143
|
it 'returns the escape sequence to position and set the visibility of ' \
|
135
144
|
'the cursor' do
|
136
145
|
Cursor.new(attributes).to_s.must_equal("\e[8;19H\e[?25h")
|
@@ -143,5 +152,7 @@ module Vedeu
|
|
143
152
|
end.must_equal("\e[8;19H\e[?25h\e[8;19H\e[?25h")
|
144
153
|
end
|
145
154
|
end
|
146
|
-
|
147
|
-
end
|
155
|
+
|
156
|
+
end # Cursor
|
157
|
+
|
158
|
+
end # Vedeu
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
describe Foreground do
|
6
|
+
|
5
7
|
describe '.escape_sequence' do
|
6
8
|
describe 'when the colour is empty' do
|
7
9
|
it 'returns an empty String' do
|
@@ -79,5 +81,7 @@ module Vedeu
|
|
79
81
|
end
|
80
82
|
end
|
81
83
|
end
|
82
|
-
|
83
|
-
end
|
84
|
+
|
85
|
+
end # Foreground
|
86
|
+
|
87
|
+
end # Vedeu
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
describe Geometry do
|
6
|
+
|
5
7
|
describe '#initialize' do
|
6
8
|
it 'returns an instance of itself' do
|
7
9
|
attributes = {}
|
@@ -273,5 +275,7 @@ module Vedeu
|
|
273
275
|
)
|
274
276
|
end
|
275
277
|
end
|
276
|
-
|
277
|
-
end
|
278
|
+
|
279
|
+
end # Geometry
|
280
|
+
|
281
|
+
end # Vedeu
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
describe Interface do
|
5
6
|
let(:interface) { Vedeu.use('#initialize') }
|
6
7
|
|
@@ -26,6 +27,7 @@ module Vedeu
|
|
26
27
|
it 'returns the value' do
|
27
28
|
interface.attributes.must_equal(
|
28
29
|
{
|
30
|
+
cursor: :hide,
|
29
31
|
name: '#initialize',
|
30
32
|
group: 'my_group',
|
31
33
|
lines: [],
|
@@ -103,5 +105,6 @@ module Vedeu
|
|
103
105
|
end
|
104
106
|
end
|
105
107
|
|
106
|
-
end
|
107
|
-
|
108
|
+
end # Interface
|
109
|
+
|
110
|
+
end # Vedeu
|
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
describe Keymap do
|
5
6
|
|
6
7
|
describe '.define' do
|
7
|
-
it '' do
|
8
|
-
|
8
|
+
it 'returns an instance of Keymap' do
|
9
|
+
Keymap.define.must_be_instance_of(Keymap)
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
@@ -21,5 +22,6 @@ module Vedeu
|
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
24
|
-
end
|
25
|
-
|
25
|
+
end # Keymap
|
26
|
+
|
27
|
+
end # Vedeu
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
describe Line do
|
5
6
|
let(:line) { Line.new(attributes) }
|
6
7
|
let(:attributes) {
|
@@ -120,5 +121,7 @@ module Vedeu
|
|
120
121
|
Line.new.some_missing_method(:test).must_equal(nil)
|
121
122
|
end
|
122
123
|
end
|
123
|
-
|
124
|
-
end
|
124
|
+
|
125
|
+
end # Line
|
126
|
+
|
127
|
+
end # Vedeu
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
+
|
4
5
|
describe Offset do
|
5
6
|
let(:offset) { Offset.new(attributes) }
|
6
7
|
let(:attributes) { {} }
|
@@ -14,8 +15,10 @@ module Vedeu
|
|
14
15
|
end
|
15
16
|
|
16
17
|
describe '#attributes' do
|
18
|
+
let(:attributes) { { name: 'roentgenium', y: 5, x: 12 } }
|
19
|
+
|
17
20
|
it 'returns the attributes' do
|
18
|
-
|
21
|
+
offset.attributes.must_equal(attributes)
|
19
22
|
end
|
20
23
|
end
|
21
24
|
|
@@ -117,5 +120,6 @@ module Vedeu
|
|
117
120
|
end
|
118
121
|
end
|
119
122
|
|
120
|
-
end
|
121
|
-
|
123
|
+
end # Offset
|
124
|
+
|
125
|
+
end # Vedeu
|