vedeu 0.6.9 → 0.6.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/lib/vedeu/all.rb +3 -3
- data/lib/vedeu/api/external.rb +194 -0
- data/lib/vedeu/api/internal.rb +173 -0
- data/lib/vedeu/application/controller.rb +3 -2
- data/lib/vedeu/bindings/application.rb +1 -1
- data/lib/vedeu/bindings/drb.rb +2 -3
- data/lib/vedeu/bindings/movement.rb +1 -1
- data/lib/vedeu/buffers/all.rb +0 -2
- data/lib/vedeu/colours/translator.rb +2 -1
- data/lib/vedeu/common.rb +4 -2
- data/lib/vedeu/configuration/api.rb +1 -1
- data/lib/vedeu/configuration/cli.rb +1 -1
- data/lib/vedeu/cursors/repository.rb +1 -1
- data/lib/vedeu/editor/insert.rb +12 -13
- data/lib/vedeu/geometry/position.rb +1 -1
- data/lib/vedeu/models/cell.rb +35 -21
- data/lib/vedeu/models/escape.rb +18 -1
- data/lib/vedeu/models/page.rb +20 -10
- data/lib/vedeu/models/row.rb +18 -8
- data/lib/vedeu/models/views/char.rb +9 -7
- data/lib/vedeu/models/views/view.rb +1 -1
- data/lib/vedeu/output/compressor.rb +22 -14
- data/lib/vedeu/output/output.rb +1 -10
- data/lib/vedeu/output/renderers/escape_sequence.rb +8 -4
- data/lib/vedeu/output/renderers/file.rb +7 -23
- data/lib/vedeu/output/renderers/html.rb +47 -26
- data/lib/vedeu/output/renderers/json.rb +11 -16
- data/lib/vedeu/output/renderers/null.rb +1 -1
- data/lib/vedeu/output/renderers/renderer_options.rb +2 -1
- data/lib/vedeu/output/renderers/terminal.rb +7 -15
- data/lib/vedeu/output/renderers/text.rb +1 -1
- data/lib/vedeu/output/viewport.rb +154 -143
- data/lib/vedeu/repositories/collection.rb +2 -2
- data/lib/vedeu/repositories/model.rb +25 -26
- data/lib/vedeu/repositories/registerable.rb +9 -8
- data/lib/vedeu/repositories/repository.rb +21 -16
- data/lib/vedeu/repositories/store.rb +6 -4
- data/lib/vedeu/runtime/bootstrap.rb +7 -5
- data/lib/vedeu/runtime/main_loop.rb +2 -0
- data/lib/vedeu/runtime/router.rb +155 -149
- data/lib/vedeu/templating/decoder.rb +8 -5
- data/lib/vedeu/templating/encoder.rb +6 -4
- data/lib/vedeu/templating/template.rb +2 -2
- data/lib/vedeu/templating/view_template.rb +8 -7
- data/lib/vedeu/terminal/buffer.rb +132 -0
- data/lib/vedeu/terminal/terminal.rb +0 -5
- data/lib/vedeu/version.rb +1 -1
- data/lib/vedeu.rb +2 -2
- data/out_ +50 -0
- data/test/lib/vedeu/api/external_test.rb +62 -0
- data/test/lib/vedeu/{internal_api_test.rb → api/internal_test.rb} +6 -2
- data/test/lib/vedeu/application/controller_test.rb +3 -3
- data/test/lib/vedeu/bindings/application_test.rb +2 -2
- data/test/lib/vedeu/models/cell_test.rb +48 -17
- data/test/lib/vedeu/models/escape_test.rb +29 -7
- data/test/lib/vedeu/models/page_test.rb +70 -50
- data/test/lib/vedeu/models/row_test.rb +40 -20
- data/test/lib/vedeu/output/compressor_test.rb +12 -12
- data/test/lib/vedeu/output/output_test.rb +17 -23
- data/test/lib/vedeu/output/renderers/escape_sequence_test.rb +15 -11
- data/test/lib/vedeu/output/renderers/html_test.rb +66 -68
- data/test/lib/vedeu/output/renderers/json_test.rb +36 -83
- data/test/lib/vedeu/output/renderers/terminal_test.rb +22 -2
- data/test/lib/vedeu/output/viewport_test.rb +201 -197
- data/test/lib/vedeu/runtime/router_test.rb +144 -140
- data/test/lib/vedeu/terminal/buffer_test.rb +307 -0
- data/test/support/examples/material_colours_app.rb +2 -2
- data/test/support/templates/html_renderer.vedeu +24 -0
- metadata +14 -17
- data/lib/vedeu/api.rb +0 -190
- data/lib/vedeu/buffers/virtual_buffer.rb +0 -136
- data/lib/vedeu/buffers/virtual_buffers.rb +0 -77
- data/lib/vedeu/internal_api.rb +0 -173
- data/lib/vedeu/terminal/content.rb +0 -88
- data/test/lib/vedeu/api_test.rb +0 -58
- data/test/lib/vedeu/buffers/virtual_buffer_test.rb +0 -148
- data/test/lib/vedeu/buffers/virtual_buffers_test.rb +0 -73
- data/test/lib/vedeu/terminal/content_test.rb +0 -108
@@ -2,169 +2,111 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
5
|
+
module Output
|
6
|
+
|
7
|
+
describe Viewport do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Output::Viewport }
|
10
|
+
let(:instance) { described.new(view) }
|
11
|
+
let(:view) {
|
12
|
+
Vedeu::Views::View.build(name: 'lithium', style: nil) do
|
13
|
+
lines do
|
14
|
+
line 'barium'
|
15
|
+
line 'carbon'
|
16
|
+
line 'helium'
|
17
|
+
line 'iodine'
|
18
|
+
line 'nickel'
|
19
|
+
line 'osmium'
|
20
|
+
end
|
18
21
|
end
|
22
|
+
}
|
23
|
+
let(:visible) { true }
|
24
|
+
let(:interface) {
|
25
|
+
Vedeu::Models::Interface.new(style: nil, visible: visible)
|
26
|
+
}
|
27
|
+
let(:geometry) { Vedeu::Geometry::Geometry.new(height: 3, width: 3) }
|
28
|
+
|
29
|
+
before do
|
30
|
+
Vedeu.interfaces.stubs(:by_name).returns(interface)
|
31
|
+
Vedeu.geometries.stubs(:by_name).returns(geometry)
|
19
32
|
end
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
let(:geometry) { Vedeu::Geometry::Geometry.new(height: 3, width: 3) }
|
26
|
-
|
27
|
-
before do
|
28
|
-
Vedeu.interfaces.stubs(:by_name).returns(interface)
|
29
|
-
Vedeu.geometries.stubs(:by_name).returns(geometry)
|
30
|
-
end
|
31
|
-
after { Vedeu.interfaces.reset }
|
32
|
-
|
33
|
-
describe '#initialize' do
|
34
|
-
it { instance.must_be_instance_of(described) }
|
35
|
-
it { instance.instance_variable_get('@view').must_equal(view) }
|
36
|
-
end
|
37
|
-
|
38
|
-
describe '.render' do
|
39
|
-
subject { described.render(view) }
|
40
|
-
|
41
|
-
context 'when the interface is visible' do
|
42
|
-
# @todo Add more tests.
|
43
|
-
# it { skip }
|
33
|
+
after { Vedeu.interfaces.reset }
|
34
|
+
|
35
|
+
describe '#initialize' do
|
36
|
+
it { instance.must_be_instance_of(described) }
|
37
|
+
it { instance.instance_variable_get('@view').must_equal(view) }
|
44
38
|
end
|
45
39
|
|
46
|
-
|
47
|
-
|
40
|
+
describe '.render' do
|
41
|
+
subject { described.render(view) }
|
48
42
|
|
49
|
-
|
43
|
+
context 'when the interface is visible' do
|
44
|
+
# @todo Add more tests.
|
45
|
+
# it { skip }
|
46
|
+
end
|
50
47
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
ox: ox,
|
59
|
-
oy: oy,
|
60
|
-
visible: true,
|
61
|
-
x: x,
|
62
|
-
y: y) }
|
63
|
-
let(:lines) { [] }
|
64
|
-
let(:ox) { 0 }
|
65
|
-
let(:oy) { 0 }
|
66
|
-
let(:x) { 1 }
|
67
|
-
let(:y) { 1 }
|
68
|
-
|
69
|
-
subject { instance.render }
|
70
|
-
|
71
|
-
it { subject.must_be_instance_of(Array) }
|
72
|
-
|
73
|
-
context 'when there is no content' do
|
74
|
-
before { view.stubs(:lines).returns([]) }
|
75
|
-
|
76
|
-
it { subject.must_equal([]) }
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe '#to_s' do
|
81
|
-
let(:cursor) {
|
82
|
-
Vedeu::Cursors::Cursor.new(name: 'lithium',
|
83
|
-
ox: ox,
|
84
|
-
oy: oy,
|
85
|
-
visible: true,
|
86
|
-
x: x,
|
87
|
-
y: y) }
|
88
|
-
let(:lines) { [] }
|
89
|
-
let(:ox) { 0 }
|
90
|
-
let(:oy) { 0 }
|
91
|
-
let(:x) { 1 }
|
92
|
-
let(:y) { 1 }
|
93
|
-
|
94
|
-
subject { instance.to_s }
|
95
|
-
|
96
|
-
it { subject.must_be_instance_of(String) }
|
97
|
-
|
98
|
-
context 'when there is no content' do
|
99
|
-
before { view.stubs(:lines).returns([]) }
|
100
|
-
|
101
|
-
it { subject.must_equal('') }
|
48
|
+
context 'when the interface is not visible' do
|
49
|
+
let(:visible) { false }
|
50
|
+
|
51
|
+
it { subject.must_be_instance_of(Array) }
|
52
|
+
|
53
|
+
it { subject.must_equal([]) }
|
54
|
+
end
|
102
55
|
end
|
103
56
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
57
|
+
describe '#render' do
|
58
|
+
let(:cursor) {
|
59
|
+
Vedeu::Cursors::Cursor.new(name: 'lithium',
|
60
|
+
ox: ox,
|
61
|
+
oy: oy,
|
62
|
+
visible: true,
|
63
|
+
x: x,
|
64
|
+
y: y) }
|
65
|
+
let(:lines) { [] }
|
66
|
+
let(:ox) { 0 }
|
67
|
+
let(:oy) { 0 }
|
68
|
+
let(:x) { 1 }
|
69
|
+
let(:y) { 1 }
|
70
|
+
|
71
|
+
subject { instance.render }
|
72
|
+
|
73
|
+
it { subject.must_be_instance_of(Array) }
|
74
|
+
|
75
|
+
context 'when there is no content' do
|
76
|
+
before { view.stubs(:lines).returns([]) }
|
77
|
+
|
78
|
+
it { subject.must_equal([]) }
|
122
79
|
end
|
80
|
+
end
|
123
81
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
82
|
+
describe '#to_s' do
|
83
|
+
let(:cursor) {
|
84
|
+
Vedeu::Cursors::Cursor.new(name: 'lithium',
|
85
|
+
ox: ox,
|
86
|
+
oy: oy,
|
87
|
+
visible: true,
|
88
|
+
x: x,
|
89
|
+
y: y) }
|
90
|
+
let(:lines) { [] }
|
91
|
+
let(:ox) { 0 }
|
92
|
+
let(:oy) { 0 }
|
93
|
+
let(:x) { 1 }
|
94
|
+
let(:y) { 1 }
|
128
95
|
|
129
|
-
|
130
|
-
subject.must_equal(
|
131
|
-
"\e[1;1H\e[39m\e[49mb\n" \
|
132
|
-
"\e[1;2H\e[39m\e[49ma\n" \
|
133
|
-
"\e[1;3H\e[39m\e[49mr\n" \
|
134
|
-
"\e[2;1H\e[39m\e[49mc\n" \
|
135
|
-
"\e[2;2H\e[39m\e[49ma\n" \
|
136
|
-
"\e[2;3H\e[39m\e[49mr\n" \
|
137
|
-
"\e[3;1H\e[39m\e[49mh\n" \
|
138
|
-
"\e[3;2H\e[39m\e[49me\n" \
|
139
|
-
"\e[3;3H\e[39m\e[49ml"
|
140
|
-
)
|
141
|
-
end
|
142
|
-
end
|
96
|
+
subject { instance.to_s }
|
143
97
|
|
144
|
-
|
145
|
-
let(:ox) { 3 }
|
146
|
-
let(:oy) { 3 }
|
98
|
+
it { subject.must_be_instance_of(String) }
|
147
99
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
"\e[1;3H\e[39m\e[49mr\n" \
|
153
|
-
"\e[2;1H\e[39m\e[49mc\n" \
|
154
|
-
"\e[2;2H\e[39m\e[49ma\n" \
|
155
|
-
"\e[2;3H\e[39m\e[49mr\n" \
|
156
|
-
"\e[3;1H\e[39m\e[49mh\n" \
|
157
|
-
"\e[3;2H\e[39m\e[49me\n" \
|
158
|
-
"\e[3;3H\e[39m\e[49ml"
|
159
|
-
)
|
160
|
-
end
|
161
|
-
end
|
100
|
+
context 'when there is no content' do
|
101
|
+
before { view.stubs(:lines).returns([]) }
|
102
|
+
|
103
|
+
it { subject.must_equal('') }
|
162
104
|
end
|
163
105
|
|
164
|
-
context 'when
|
165
|
-
context '
|
166
|
-
let(:ox) {
|
167
|
-
let(:oy) {
|
106
|
+
context 'when there is content' do
|
107
|
+
context 'when the cursor y position is outside the viewable area' do
|
108
|
+
let(:ox) { -4 }
|
109
|
+
let(:oy) { -4 }
|
168
110
|
|
169
111
|
it 'scrolls the content the correct position' do
|
170
112
|
subject.must_equal(
|
@@ -181,68 +123,130 @@ module Vedeu
|
|
181
123
|
end
|
182
124
|
end
|
183
125
|
|
184
|
-
context '
|
185
|
-
|
186
|
-
|
126
|
+
context 'when the cursor y position is inside the viewable area' do
|
127
|
+
context 'when there is not enough content to fill the height' do
|
128
|
+
let(:ox) { 3 }
|
129
|
+
let(:oy) { 7 }
|
130
|
+
|
131
|
+
it 'renders the visible content' do
|
132
|
+
subject.must_equal(
|
133
|
+
"\e[1;1H\e[39m\e[49mb\n" \
|
134
|
+
"\e[1;2H\e[39m\e[49ma\n" \
|
135
|
+
"\e[1;3H\e[39m\e[49mr\n" \
|
136
|
+
"\e[2;1H\e[39m\e[49mc\n" \
|
137
|
+
"\e[2;2H\e[39m\e[49ma\n" \
|
138
|
+
"\e[2;3H\e[39m\e[49mr\n" \
|
139
|
+
"\e[3;1H\e[39m\e[49mh\n" \
|
140
|
+
"\e[3;2H\e[39m\e[49me\n" \
|
141
|
+
"\e[3;3H\e[39m\e[49ml"
|
142
|
+
)
|
143
|
+
end
|
144
|
+
end
|
187
145
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
146
|
+
context 'when there is more content than the height' do
|
147
|
+
let(:ox) { 3 }
|
148
|
+
let(:oy) { 3 }
|
149
|
+
|
150
|
+
it 'is cropped to show only that which fits' do
|
151
|
+
subject.must_equal(
|
152
|
+
"\e[1;1H\e[39m\e[49mb\n" \
|
153
|
+
"\e[1;2H\e[39m\e[49ma\n" \
|
154
|
+
"\e[1;3H\e[39m\e[49mr\n" \
|
155
|
+
"\e[2;1H\e[39m\e[49mc\n" \
|
156
|
+
"\e[2;2H\e[39m\e[49ma\n" \
|
157
|
+
"\e[2;3H\e[39m\e[49mr\n" \
|
158
|
+
"\e[3;1H\e[39m\e[49mh\n" \
|
159
|
+
"\e[3;2H\e[39m\e[49me\n" \
|
160
|
+
"\e[3;3H\e[39m\e[49ml"
|
161
|
+
)
|
162
|
+
end
|
200
163
|
end
|
201
164
|
end
|
202
|
-
end
|
203
165
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
166
|
+
context 'when the cursor x position is outside the viewable area' do
|
167
|
+
context 'but inside the content' do
|
168
|
+
let(:ox) { 6 }
|
169
|
+
let(:oy) { 6 }
|
170
|
+
|
171
|
+
it 'scrolls the content the correct position' do
|
172
|
+
subject.must_equal(
|
173
|
+
"\e[1;1H\e[39m\e[49mb\n" \
|
174
|
+
"\e[1;2H\e[39m\e[49ma\n" \
|
175
|
+
"\e[1;3H\e[39m\e[49mr\n" \
|
176
|
+
"\e[2;1H\e[39m\e[49mc\n" \
|
177
|
+
"\e[2;2H\e[39m\e[49ma\n" \
|
178
|
+
"\e[2;3H\e[39m\e[49mr\n" \
|
179
|
+
"\e[3;1H\e[39m\e[49mh\n" \
|
180
|
+
"\e[3;2H\e[39m\e[49me\n" \
|
181
|
+
"\e[3;3H\e[39m\e[49ml"
|
182
|
+
)
|
183
|
+
end
|
184
|
+
end
|
208
185
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
186
|
+
context 'and outside the content' do
|
187
|
+
let(:ox) { 7 }
|
188
|
+
let(:oy) { 7 }
|
189
|
+
|
190
|
+
it 'scrolls the content the correct position' do
|
191
|
+
subject.must_equal(
|
192
|
+
"\e[1;1H\e[39m\e[49mb\n" \
|
193
|
+
"\e[1;2H\e[39m\e[49ma\n" \
|
194
|
+
"\e[1;3H\e[39m\e[49mr\n" \
|
195
|
+
"\e[2;1H\e[39m\e[49mc\n" \
|
196
|
+
"\e[2;2H\e[39m\e[49ma\n" \
|
197
|
+
"\e[2;3H\e[39m\e[49mr\n" \
|
198
|
+
"\e[3;1H\e[39m\e[49mh\n" \
|
199
|
+
"\e[3;2H\e[39m\e[49me\n" \
|
200
|
+
"\e[3;3H\e[39m\e[49ml"
|
201
|
+
)
|
202
|
+
end
|
221
203
|
end
|
222
204
|
end
|
223
205
|
|
224
|
-
context 'when
|
225
|
-
|
226
|
-
|
206
|
+
context 'when the cursor x position is inside the viewable area' do
|
207
|
+
context 'when there is not enough content to fill the width' do
|
208
|
+
let(:ox) { 7 }
|
209
|
+
let(:oy) { 3 }
|
210
|
+
|
211
|
+
it 'renders the visible content' do
|
212
|
+
subject.must_equal(
|
213
|
+
"\e[1;1H\e[39m\e[49mb\n" \
|
214
|
+
"\e[1;2H\e[39m\e[49ma\n" \
|
215
|
+
"\e[1;3H\e[39m\e[49mr\n" \
|
216
|
+
"\e[2;1H\e[39m\e[49mc\n" \
|
217
|
+
"\e[2;2H\e[39m\e[49ma\n" \
|
218
|
+
"\e[2;3H\e[39m\e[49mr\n" \
|
219
|
+
"\e[3;1H\e[39m\e[49mh\n" \
|
220
|
+
"\e[3;2H\e[39m\e[49me\n" \
|
221
|
+
"\e[3;3H\e[39m\e[49ml"
|
222
|
+
)
|
223
|
+
end
|
224
|
+
end
|
227
225
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
226
|
+
context 'when there is more content than the width' do
|
227
|
+
let(:ox) { 3 }
|
228
|
+
let(:oy) { 3 }
|
229
|
+
|
230
|
+
it 'is cropped to show only that which fits' do
|
231
|
+
subject.must_equal(
|
232
|
+
"\e[1;1H\e[39m\e[49mb\n" \
|
233
|
+
"\e[1;2H\e[39m\e[49ma\n" \
|
234
|
+
"\e[1;3H\e[39m\e[49mr\n" \
|
235
|
+
"\e[2;1H\e[39m\e[49mc\n" \
|
236
|
+
"\e[2;2H\e[39m\e[49ma\n" \
|
237
|
+
"\e[2;3H\e[39m\e[49mr\n" \
|
238
|
+
"\e[3;1H\e[39m\e[49mh\n" \
|
239
|
+
"\e[3;2H\e[39m\e[49me\n" \
|
240
|
+
"\e[3;3H\e[39m\e[49ml"
|
241
|
+
)
|
242
|
+
end
|
240
243
|
end
|
241
244
|
end
|
242
245
|
end
|
243
246
|
end
|
244
|
-
end
|
245
247
|
|
246
|
-
|
248
|
+
end # Viewport
|
249
|
+
|
250
|
+
end # Output
|
247
251
|
|
248
252
|
end # Vedeu
|