vedeu 0.1.18 → 0.1.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +5 -0
- data/Dockerfile +40 -0
- data/README.md +7 -30
- data/docs/api.md +79 -0
- data/docs/events.md +121 -0
- data/lib/vedeu.rb +61 -18
- data/lib/vedeu/api/api.rb +73 -53
- data/lib/vedeu/api/composition.rb +4 -1
- data/lib/vedeu/api/defined.rb +35 -0
- data/lib/vedeu/api/helpers.rb +20 -15
- data/lib/vedeu/api/interface.rb +17 -12
- data/lib/vedeu/api/line.rb +20 -12
- data/lib/vedeu/api/stream.rb +3 -0
- data/lib/vedeu/application.rb +34 -1
- data/lib/vedeu/configuration.rb +15 -3
- data/lib/vedeu/input/input.rb +77 -0
- data/lib/vedeu/launcher.rb +7 -0
- data/lib/vedeu/models/attributes/background.rb +15 -2
- data/lib/vedeu/models/attributes/coercions.rb +18 -3
- data/lib/vedeu/models/attributes/colour_translator.rb +23 -17
- data/lib/vedeu/models/attributes/foreground.rb +10 -2
- data/lib/vedeu/models/attributes/presentation.rb +62 -0
- data/lib/vedeu/models/colour.rb +7 -3
- data/lib/vedeu/models/composition.rb +17 -19
- data/lib/vedeu/models/geometry.rb +13 -5
- data/lib/vedeu/models/interface.rb +35 -19
- data/lib/vedeu/models/line.rb +24 -8
- data/lib/vedeu/models/stream.rb +13 -7
- data/lib/vedeu/models/style.rb +17 -7
- data/lib/vedeu/{support → output}/clear.rb +14 -0
- data/lib/vedeu/output/compositor.rb +77 -0
- data/lib/vedeu/output/refresh.rb +129 -0
- data/lib/vedeu/{support → output}/render.rb +49 -13
- data/lib/vedeu/{support → output}/view.rb +15 -8
- data/lib/vedeu/repositories/buffers.rb +181 -0
- data/lib/vedeu/{support → repositories}/events.rb +16 -6
- data/lib/vedeu/repositories/focus.rb +109 -0
- data/lib/vedeu/repositories/groups.rb +76 -0
- data/lib/vedeu/repositories/interfaces.rb +74 -0
- data/lib/vedeu/support/common.rb +20 -0
- data/lib/vedeu/support/cursor.rb +77 -0
- data/lib/vedeu/support/esc.rb +181 -46
- data/lib/vedeu/support/event.rb +22 -4
- data/lib/vedeu/support/grid.rb +10 -3
- data/lib/vedeu/support/log.rb +14 -1
- data/lib/vedeu/support/menu.rb +51 -12
- data/lib/vedeu/support/position.rb +9 -0
- data/lib/vedeu/support/terminal.rb +49 -15
- data/lib/vedeu/support/trace.rb +11 -4
- data/test/integration/defining_interfaces_test.rb +27 -0
- data/test/integration/views/basic_view_test.rb +767 -0
- data/test/lib/vedeu/api/api_test.rb +32 -37
- data/test/lib/vedeu/api/composition_test.rb +23 -61
- data/test/lib/vedeu/api/defined_test.rb +49 -0
- data/test/lib/vedeu/api/helpers_test.rb +91 -0
- data/test/lib/vedeu/api/interface_test.rb +136 -688
- data/test/lib/vedeu/api/line_test.rb +28 -32
- data/test/lib/vedeu/application_test.rb +6 -0
- data/test/lib/vedeu/configuration_test.rb +8 -4
- data/test/lib/vedeu/{support → input}/input_test.rb +9 -0
- data/test/lib/vedeu/launcher_test.rb +6 -0
- data/test/lib/vedeu/models/attributes/{coercer_test.rb → coercions_test.rb} +11 -10
- data/test/lib/vedeu/models/attributes/colour_translator_test.rb +13 -0
- data/test/lib/vedeu/models/attributes/presentation_test.rb +30 -0
- data/test/lib/vedeu/models/colour_test.rb +8 -0
- data/test/lib/vedeu/models/composition_test.rb +208 -200
- data/test/lib/vedeu/models/geometry_test.rb +39 -0
- data/test/lib/vedeu/models/interface_test.rb +11 -1
- data/test/lib/vedeu/models/line_test.rb +8 -1
- data/test/lib/vedeu/models/stream_test.rb +35 -0
- data/test/lib/vedeu/models/style_test.rb +8 -0
- data/test/lib/vedeu/{support → output}/clear_test.rb +1 -1
- data/test/lib/vedeu/output/compositor_test.rb +64 -0
- data/test/lib/vedeu/output/refresh_test.rb +48 -0
- data/test/lib/vedeu/{support → output}/render_test.rb +36 -0
- data/test/lib/vedeu/{support → output}/view_test.rb +0 -0
- data/test/lib/vedeu/repositories/buffers_test.rb +48 -0
- data/test/lib/vedeu/{support → repositories}/events_test.rb +0 -0
- data/test/lib/vedeu/repositories/focus_test.rb +74 -0
- data/test/lib/vedeu/repositories/groups_test.rb +66 -0
- data/test/lib/vedeu/repositories/interfaces_test.rb +6 -0
- data/test/lib/vedeu/support/common_test.rb +6 -0
- data/test/lib/vedeu/support/cursor_test.rb +79 -0
- data/test/lib/vedeu/support/log_test.rb +6 -0
- data/test/lib/vedeu/support/terminal_test.rb +6 -28
- data/test/lib/vedeu/support/trace_test.rb +6 -0
- data/test/test_helper.rb +37 -0
- data/vedeu.gemspec +1 -1
- metadata +65 -33
- data/bin/log +0 -13
- data/lib/vedeu/support/buffer.rb +0 -69
- data/lib/vedeu/support/buffers.rb +0 -106
- data/lib/vedeu/support/focus.rb +0 -83
- data/lib/vedeu/support/groups.rb +0 -61
- data/lib/vedeu/support/input.rb +0 -67
- data/test/lib/vedeu/support/buffer_test.rb +0 -83
- data/test/lib/vedeu/support/buffers_test.rb +0 -15
- data/test/lib/vedeu/support/focus_test.rb +0 -114
- data/test/lib/vedeu/support/groups_test.rb +0 -65
data/lib/vedeu/support/trace.rb
CHANGED
@@ -1,4 +1,11 @@
|
|
1
1
|
module Vedeu
|
2
|
+
|
3
|
+
# This class currently provides the means to trace each method call which
|
4
|
+
# occurs inside Vedeu. This is very useful (to me!) for debugging. Running
|
5
|
+
# this will make your application less responsive, and the tests
|
6
|
+
# excruciatingly slow to run.
|
7
|
+
#
|
8
|
+
# @api private
|
2
9
|
class Trace
|
3
10
|
|
4
11
|
# :nocov:
|
@@ -18,7 +25,7 @@ module Vedeu
|
|
18
25
|
def trace
|
19
26
|
set_trace_func proc { |event, file, line, id, binding, classname|
|
20
27
|
if event == watched && classname.to_s.match(klass)
|
21
|
-
Vedeu.log(sprintf(" %s %-35s #%s", event, classname, id))
|
28
|
+
Vedeu.log(sprintf(" %s %-35s #%s", event, classname, id), true)
|
22
29
|
# binding.eval('local_variables').each do |var|
|
23
30
|
# print("#{var.to_s} = #{binding.local_variable_get(var).inspect}\n")
|
24
31
|
# end
|
@@ -29,13 +36,13 @@ module Vedeu
|
|
29
36
|
private
|
30
37
|
|
31
38
|
# @api private
|
32
|
-
# @return []
|
39
|
+
# @return [String]
|
33
40
|
def watched
|
34
41
|
options[:event]
|
35
42
|
end
|
36
43
|
|
37
44
|
# @api private
|
38
|
-
# @return []
|
45
|
+
# @return [Regexp]
|
39
46
|
def klass
|
40
47
|
options[:klass]
|
41
48
|
end
|
@@ -51,7 +58,7 @@ module Vedeu
|
|
51
58
|
def defaults
|
52
59
|
{
|
53
60
|
event: 'call',
|
54
|
-
klass: /^Vedeu
|
61
|
+
klass: /^Vedeu::.*/
|
55
62
|
}
|
56
63
|
end
|
57
64
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class MyFirstApplication
|
4
|
+
include Vedeu
|
5
|
+
|
6
|
+
interface 'hydrogen' do
|
7
|
+
x 2
|
8
|
+
y 2
|
9
|
+
width 40
|
10
|
+
height 4
|
11
|
+
centred false
|
12
|
+
cursor true
|
13
|
+
delay 0.25
|
14
|
+
group 'elements'
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize; end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'Define an interface' do
|
21
|
+
it 'defines an interface' do
|
22
|
+
skip
|
23
|
+
MyFirstApplication.new
|
24
|
+
|
25
|
+
Vedeu.defined.interfaces.must_equal(['hydrogen'])
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,767 @@
|
|
1
|
+
# require 'test_helper'
|
2
|
+
|
3
|
+
# module Vedeu
|
4
|
+
# module API
|
5
|
+
# describe Interface do
|
6
|
+
# describe '#build' do
|
7
|
+
# before do
|
8
|
+
# @interface = Vedeu.interface('testing_view') do
|
9
|
+
# x 1
|
10
|
+
# y 1
|
11
|
+
# colour foreground: '#ffffff', background: '#000000'
|
12
|
+
# centred false
|
13
|
+
# end
|
14
|
+
# end
|
15
|
+
|
16
|
+
# it 'builds a basic view' do
|
17
|
+
# Vedeu.view 'testing_view' do
|
18
|
+
# line do
|
19
|
+
# text '1. A line of text.'
|
20
|
+
# text '2. Another line of text.'
|
21
|
+
# end
|
22
|
+
# end.must_equal(
|
23
|
+
# { interfaces: [{
|
24
|
+
# name: 'testing_view',
|
25
|
+
# group: '',
|
26
|
+
# colour: {},
|
27
|
+
# style: '',
|
28
|
+
# geometry: {},
|
29
|
+
# cursor: true,
|
30
|
+
# delay: 0.0,
|
31
|
+
# lines: [
|
32
|
+
# {
|
33
|
+
# parent: @interface.view_attributes,
|
34
|
+
# colour: {},
|
35
|
+
# style: [],
|
36
|
+
# streams: [
|
37
|
+
# {
|
38
|
+
# text: '1. A line of text.'
|
39
|
+
# }, {
|
40
|
+
# text: '2. Another line of text.'
|
41
|
+
# }
|
42
|
+
# ]
|
43
|
+
# }
|
44
|
+
# ]
|
45
|
+
# }] }
|
46
|
+
# )
|
47
|
+
# end
|
48
|
+
|
49
|
+
# it 'handles coloured lines' do
|
50
|
+
# Vedeu.view 'testing_view' do
|
51
|
+
# line do
|
52
|
+
# text '1. Line without colours.'
|
53
|
+
# end
|
54
|
+
# end.must_equal(
|
55
|
+
# { interfaces: [{
|
56
|
+
# name: 'testing_view',
|
57
|
+
# group: '',
|
58
|
+
# colour: {},
|
59
|
+
# style: '',
|
60
|
+
# geometry: {},
|
61
|
+
# cursor: true,
|
62
|
+
# delay: 0.0,
|
63
|
+
# lines: [
|
64
|
+
# {
|
65
|
+
# parent: nil,
|
66
|
+
# colour: {},
|
67
|
+
# style: [],
|
68
|
+
# streams: [{ text: '1. Line without colours.' }]
|
69
|
+
# }
|
70
|
+
# ]
|
71
|
+
# }] }
|
72
|
+
# )
|
73
|
+
# end
|
74
|
+
|
75
|
+
# it 'handles coloured lines' do
|
76
|
+
# Vedeu.view 'testing_view' do
|
77
|
+
# line do
|
78
|
+
# colour background: '#ff0000', foreground: '#ffff00'
|
79
|
+
# text '2. Line with colours.'
|
80
|
+
# end
|
81
|
+
# end.must_equal(
|
82
|
+
# { interfaces: [{
|
83
|
+
# name: 'testing_view',
|
84
|
+
# group: '',
|
85
|
+
# colour: {},
|
86
|
+
# style: '',
|
87
|
+
# geometry: {},
|
88
|
+
# cursor: true,
|
89
|
+
# delay: 0.0,
|
90
|
+
# lines: [
|
91
|
+
# {
|
92
|
+
# parent: nil,
|
93
|
+
# colour: { background: '#ff0000', foreground: '#ffff00' },
|
94
|
+
# style: [],
|
95
|
+
# streams: [{ text: '2. Line with colours.' }]
|
96
|
+
# }
|
97
|
+
# ]
|
98
|
+
# }] }
|
99
|
+
# )
|
100
|
+
# end
|
101
|
+
|
102
|
+
# it 'handles coloured lines' do
|
103
|
+
# Vedeu.view 'testing_view' do
|
104
|
+
# line do
|
105
|
+
# colour foreground: '#a7ff00', background: '#005700'
|
106
|
+
# text '3. Line with explicit colour declaration.'
|
107
|
+
# end
|
108
|
+
# end.must_equal(
|
109
|
+
# { interfaces: [{
|
110
|
+
# name: 'testing_view',
|
111
|
+
# group: '',
|
112
|
+
# colour: {},
|
113
|
+
# style: '',
|
114
|
+
# geometry: {},
|
115
|
+
# cursor: true,
|
116
|
+
# delay: 0.0,
|
117
|
+
# lines: [
|
118
|
+
# {
|
119
|
+
# parent: nil,
|
120
|
+
# colour: { background: '#005700', foreground: '#a7ff00' },
|
121
|
+
# style: [],
|
122
|
+
# streams: [{ text: '3. Line with explicit colour declaration.' }]
|
123
|
+
# }
|
124
|
+
# ]
|
125
|
+
# }] }
|
126
|
+
# )
|
127
|
+
# end
|
128
|
+
|
129
|
+
# it 'handles coloured lines' do
|
130
|
+
# Vedeu.view 'testing_view' do
|
131
|
+
# line do # actually uses streams
|
132
|
+
# foreground '#ff00ff' do
|
133
|
+
# text '4. Line with only foreground set.'
|
134
|
+
# end
|
135
|
+
# end
|
136
|
+
# end.must_equal(
|
137
|
+
# { interfaces: [{
|
138
|
+
# name: 'testing_view',
|
139
|
+
# group: '',
|
140
|
+
# colour: {},
|
141
|
+
# style: '',
|
142
|
+
# geometry: {},
|
143
|
+
# cursor: true,
|
144
|
+
# delay: 0.0,
|
145
|
+
# lines: [
|
146
|
+
# {
|
147
|
+
# parent: nil,
|
148
|
+
# colour: {},
|
149
|
+
# style: [],
|
150
|
+
# streams: [{
|
151
|
+
# colour: { foreground: '#ff00ff' },
|
152
|
+
# style: [],
|
153
|
+
# text: '4. Line with only foreground set.',
|
154
|
+
# width: nil,
|
155
|
+
# align: :left,
|
156
|
+
# parent: nil,
|
157
|
+
# }]
|
158
|
+
# }
|
159
|
+
# ]
|
160
|
+
# }] }
|
161
|
+
# )
|
162
|
+
# end
|
163
|
+
|
164
|
+
# it 'handles coloured lines' do
|
165
|
+
# Vedeu.view 'testing_view' do
|
166
|
+
# line do # actually uses streams
|
167
|
+
# background '#00ff00' do
|
168
|
+
# text '5. Line with only background set.'
|
169
|
+
# end
|
170
|
+
# end
|
171
|
+
# end.must_equal(
|
172
|
+
# { interfaces: [{
|
173
|
+
# name: 'testing_view',
|
174
|
+
# group: '',
|
175
|
+
# colour: {},
|
176
|
+
# style: '',
|
177
|
+
# geometry: {},
|
178
|
+
# cursor: true,
|
179
|
+
# delay: 0.0,
|
180
|
+
# lines: [
|
181
|
+
# {
|
182
|
+
# parent: nil,
|
183
|
+
# colour: {},
|
184
|
+
# style: [],
|
185
|
+
# streams: [{
|
186
|
+
# colour: { background: '#00ff00' },
|
187
|
+
# style: [],
|
188
|
+
# text: '5. Line with only background set.',
|
189
|
+
# width: nil,
|
190
|
+
# align: :left,
|
191
|
+
# parent: nil,
|
192
|
+
# }]
|
193
|
+
# }
|
194
|
+
# ]
|
195
|
+
# }] }
|
196
|
+
# )
|
197
|
+
# end
|
198
|
+
|
199
|
+
# it 'handles styles' do
|
200
|
+
# Vedeu.view 'testing_view' do
|
201
|
+
# line do
|
202
|
+
# style 'normal'
|
203
|
+
# text '1. Line with a normal style.'
|
204
|
+
# end
|
205
|
+
# end.must_equal(
|
206
|
+
# { interfaces: [{
|
207
|
+
# name: 'testing_view',
|
208
|
+
# group: '',
|
209
|
+
# colour: {},
|
210
|
+
# style: '',
|
211
|
+
# geometry: {},
|
212
|
+
# cursor: true,
|
213
|
+
# delay: 0.0,
|
214
|
+
# lines: [
|
215
|
+
# {
|
216
|
+
# parent: nil,
|
217
|
+
# colour: {},
|
218
|
+
# style: ['normal'],
|
219
|
+
# streams: [{
|
220
|
+
# text: '1. Line with a normal style.'
|
221
|
+
# }]
|
222
|
+
# }
|
223
|
+
# ]
|
224
|
+
# }] }
|
225
|
+
# )
|
226
|
+
# end
|
227
|
+
|
228
|
+
# it 'handles styles' do
|
229
|
+
# Vedeu.view 'testing_view' do
|
230
|
+
# line do
|
231
|
+
# style 'underline'
|
232
|
+
# text '2. Line with an underline style.'
|
233
|
+
# end
|
234
|
+
# end.must_equal(
|
235
|
+
# { interfaces: [{
|
236
|
+
# name: 'testing_view',
|
237
|
+
# group: '',
|
238
|
+
# colour: {},
|
239
|
+
# style: '',
|
240
|
+
# geometry: {},
|
241
|
+
# cursor: true,
|
242
|
+
# delay: 0.0,
|
243
|
+
# lines: [
|
244
|
+
# {
|
245
|
+
# parent: nil,
|
246
|
+
# colour: {},
|
247
|
+
# style: ['underline'],
|
248
|
+
# streams: [{
|
249
|
+
# text: '2. Line with an underline style.'
|
250
|
+
# }]
|
251
|
+
# }
|
252
|
+
# ]
|
253
|
+
# }] }
|
254
|
+
# )
|
255
|
+
# end
|
256
|
+
|
257
|
+
# it 'handles styles' do
|
258
|
+
# Vedeu.view 'testing_view' do
|
259
|
+
# line do # actually uses streams
|
260
|
+
# style 'normal' do
|
261
|
+
# text '3. Line with a normal style.'
|
262
|
+
# end
|
263
|
+
# end
|
264
|
+
# end.must_equal(
|
265
|
+
# { interfaces: [{
|
266
|
+
# name: 'testing_view',
|
267
|
+
# group: '',
|
268
|
+
# colour: {},
|
269
|
+
# style: '',
|
270
|
+
# geometry: {},
|
271
|
+
# cursor: true,
|
272
|
+
# delay: 0.0,
|
273
|
+
# lines: [
|
274
|
+
# {
|
275
|
+
# parent: nil,
|
276
|
+
# colour: {},
|
277
|
+
# style: [],
|
278
|
+
# streams: [{
|
279
|
+
# colour: {},
|
280
|
+
# style: ['normal'],
|
281
|
+
# text: '3. Line with a normal style.',
|
282
|
+
# width: nil,
|
283
|
+
# align: :left,
|
284
|
+
# parent: nil,
|
285
|
+
# }]
|
286
|
+
# }
|
287
|
+
# ]
|
288
|
+
# }] }
|
289
|
+
# )
|
290
|
+
# end
|
291
|
+
|
292
|
+
# it 'handles styles' do
|
293
|
+
# Vedeu.view 'testing_view' do
|
294
|
+
# line do # actually uses streams
|
295
|
+
# style 'underline' do
|
296
|
+
# text '4. Line with an underlined style.'
|
297
|
+
# end
|
298
|
+
# end
|
299
|
+
# end.must_equal(
|
300
|
+
# { interfaces: [{
|
301
|
+
# name: 'testing_view',
|
302
|
+
# group: '',
|
303
|
+
# colour: {},
|
304
|
+
# style: '',
|
305
|
+
# geometry: {},
|
306
|
+
# cursor: true,
|
307
|
+
# delay: 0.0,
|
308
|
+
# lines: [
|
309
|
+
# {
|
310
|
+
# parent: nil,
|
311
|
+
# colour: {},
|
312
|
+
# style: [],
|
313
|
+
# streams: [{
|
314
|
+
# colour: {},
|
315
|
+
# style: ['underline'],
|
316
|
+
# text: '4. Line with an underlined style.',
|
317
|
+
# width: nil,
|
318
|
+
# align: :left,
|
319
|
+
# parent: nil,
|
320
|
+
# }]
|
321
|
+
# }
|
322
|
+
# ]
|
323
|
+
# }] }
|
324
|
+
# )
|
325
|
+
# end
|
326
|
+
|
327
|
+
# it 'handles streams, which means sub-line colours and styles' do
|
328
|
+
# Vedeu.view 'testing_view' do
|
329
|
+
# line do
|
330
|
+
# stream do
|
331
|
+
# text 'A stream of text.'
|
332
|
+
# end
|
333
|
+
# end
|
334
|
+
# end.must_equal(
|
335
|
+
# { interfaces: [{
|
336
|
+
# name: 'testing_view',
|
337
|
+
# group: '',
|
338
|
+
# colour: {},
|
339
|
+
# style: '',
|
340
|
+
# geometry: {},
|
341
|
+
# cursor: true,
|
342
|
+
# delay: 0.0,
|
343
|
+
# lines: [
|
344
|
+
# {
|
345
|
+
# parent: nil,
|
346
|
+
# colour: {},
|
347
|
+
# style: [],
|
348
|
+
# streams: [
|
349
|
+
# {
|
350
|
+
# parent: nil,
|
351
|
+
# colour: {},
|
352
|
+
# style: [],
|
353
|
+
# text: 'A stream of text.',
|
354
|
+
# width: nil,
|
355
|
+
# align: :left
|
356
|
+
# }
|
357
|
+
# ]
|
358
|
+
# }
|
359
|
+
# ]
|
360
|
+
# }] }
|
361
|
+
# )
|
362
|
+
# end
|
363
|
+
|
364
|
+
# it 'handles streams, which means sub-line colours and styles' do
|
365
|
+
# Vedeu.view 'testing_view' do
|
366
|
+
# line do
|
367
|
+
# stream do # Stream is an 'explicit declaration'.
|
368
|
+
# # We don't need it unless we want to add colours and styles.
|
369
|
+
# # See below.
|
370
|
+
# text '1. Two streams of text, these will be'
|
371
|
+
# end
|
372
|
+
|
373
|
+
# stream do
|
374
|
+
# text ' on the same line- note the space.'
|
375
|
+
# end
|
376
|
+
# end
|
377
|
+
# end.must_equal(
|
378
|
+
# { interfaces: [{
|
379
|
+
# name: 'testing_view',
|
380
|
+
# group: '',
|
381
|
+
# colour: {},
|
382
|
+
# style: '',
|
383
|
+
# geometry: {},
|
384
|
+
# cursor: true,
|
385
|
+
# delay: 0.0,
|
386
|
+
# lines: [
|
387
|
+
# {
|
388
|
+
# parent: nil,
|
389
|
+
# colour: {},
|
390
|
+
# style: [],
|
391
|
+
# streams: [
|
392
|
+
# {
|
393
|
+
# colour: {},
|
394
|
+
# style: [],
|
395
|
+
# text: '1. Two streams of text, these will be',
|
396
|
+
# width: nil,
|
397
|
+
# align: :left,
|
398
|
+
# parent: nil,
|
399
|
+
# }, {
|
400
|
+
# colour: {},
|
401
|
+
# style: [],
|
402
|
+
# text: ' on the same line- note the space.',
|
403
|
+
# width: nil,
|
404
|
+
# align: :left,
|
405
|
+
# parent: nil,
|
406
|
+
# }
|
407
|
+
# ]
|
408
|
+
# }
|
409
|
+
# ]
|
410
|
+
# }] }
|
411
|
+
# )
|
412
|
+
# end
|
413
|
+
|
414
|
+
# it 'handles streams, which means sub-line colours and styles' do
|
415
|
+
# Vedeu.view 'testing_view' do
|
416
|
+
# line do
|
417
|
+
# stream do
|
418
|
+
# text '2. Streams can have'
|
419
|
+
# end
|
420
|
+
|
421
|
+
# stream do
|
422
|
+
# colour foreground: '#ff0000', background: '#00ff00'
|
423
|
+
# text ' colours too.'
|
424
|
+
# end
|
425
|
+
# end
|
426
|
+
# end.must_equal(
|
427
|
+
# { interfaces: [{
|
428
|
+
# name: 'testing_view',
|
429
|
+
# group: '',
|
430
|
+
# colour: {},
|
431
|
+
# style: '',
|
432
|
+
# geometry: {},
|
433
|
+
# cursor: true,
|
434
|
+
# delay: 0.0,
|
435
|
+
# lines: [
|
436
|
+
# {
|
437
|
+
# parent: nil,
|
438
|
+
# colour: {},
|
439
|
+
# style: [],
|
440
|
+
# streams: [
|
441
|
+
# {
|
442
|
+
# colour: {},
|
443
|
+
# style: [],
|
444
|
+
# text: '2. Streams can have',
|
445
|
+
# width: nil,
|
446
|
+
# align: :left,
|
447
|
+
# parent: nil,
|
448
|
+
# }, {
|
449
|
+
# colour: {
|
450
|
+
# foreground: '#ff0000',
|
451
|
+
# background: '#00ff00'
|
452
|
+
# },
|
453
|
+
# style: [],
|
454
|
+
# text: ' colours too.',
|
455
|
+
# width: nil,
|
456
|
+
# align: :left,
|
457
|
+
# parent: nil,
|
458
|
+
# }
|
459
|
+
# ]
|
460
|
+
# }
|
461
|
+
# ]
|
462
|
+
# }] }
|
463
|
+
# )
|
464
|
+
# end
|
465
|
+
|
466
|
+
# it 'handles streams, which means sub-line colours and styles' do
|
467
|
+
# Vedeu.view 'testing_view' do
|
468
|
+
# line do
|
469
|
+
# stream do
|
470
|
+
# text '3. Streams can have'
|
471
|
+
# end
|
472
|
+
|
473
|
+
# stream do
|
474
|
+
# style 'underline'
|
475
|
+
# text ' styles too.'
|
476
|
+
# end
|
477
|
+
# end
|
478
|
+
# end.must_equal(
|
479
|
+
# { interfaces: [{
|
480
|
+
# name: 'testing_view',
|
481
|
+
# group: '',
|
482
|
+
# colour: {},
|
483
|
+
# style: '',
|
484
|
+
# geometry: {},
|
485
|
+
# cursor: true,
|
486
|
+
# delay: 0.0,
|
487
|
+
# lines: [
|
488
|
+
# {
|
489
|
+
# parent: nil,
|
490
|
+
# colour: {},
|
491
|
+
# style: [],
|
492
|
+
# streams: [
|
493
|
+
# {
|
494
|
+
# colour: {},
|
495
|
+
# style: [],
|
496
|
+
# text: '3. Streams can have',
|
497
|
+
# width: nil,
|
498
|
+
# align: :left,
|
499
|
+
# parent: nil,
|
500
|
+
# }, {
|
501
|
+
# colour: {},
|
502
|
+
# style: ['underline'],
|
503
|
+
# text: ' styles too.',
|
504
|
+
# width: nil,
|
505
|
+
# align: :left,
|
506
|
+
# parent: nil,
|
507
|
+
# }
|
508
|
+
# ]
|
509
|
+
# }
|
510
|
+
# ]
|
511
|
+
# }] }
|
512
|
+
# )
|
513
|
+
# end
|
514
|
+
|
515
|
+
# it 'handles alignment' do
|
516
|
+
# Vedeu.view 'testing_view' do
|
517
|
+
# line do
|
518
|
+
# stream do
|
519
|
+
# width 80
|
520
|
+
# text 'This is aligned left, and padded with spaces.'
|
521
|
+
# end
|
522
|
+
# end
|
523
|
+
# end.must_equal(
|
524
|
+
# { interfaces: [{
|
525
|
+
# name: 'testing_view',
|
526
|
+
# group: '',
|
527
|
+
# colour: {},
|
528
|
+
# style: '',
|
529
|
+
# geometry: {},
|
530
|
+
# cursor: true,
|
531
|
+
# delay: 0.0,
|
532
|
+
# lines: [{
|
533
|
+
# parent: nil,
|
534
|
+
# colour: {},
|
535
|
+
# style: [],
|
536
|
+
# streams: [{
|
537
|
+
# parent: nil,
|
538
|
+
# align: :left,
|
539
|
+
# colour: {},
|
540
|
+
# style: [],
|
541
|
+
# width: 80,
|
542
|
+
# text: 'This is aligned left, and padded with spaces.'
|
543
|
+
# }]
|
544
|
+
# }]
|
545
|
+
# }] }
|
546
|
+
# )
|
547
|
+
# end
|
548
|
+
|
549
|
+
# it 'handles alignment' do
|
550
|
+
# Vedeu.view 'testing_view' do
|
551
|
+
# line do
|
552
|
+
# stream do
|
553
|
+
# width 80
|
554
|
+
# align :left # explicit
|
555
|
+
# text 'This is aligned left, and padded with spaces.'
|
556
|
+
# end
|
557
|
+
# end
|
558
|
+
# end.must_equal(
|
559
|
+
# { interfaces: [{
|
560
|
+
# name: 'testing_view',
|
561
|
+
# group: '',
|
562
|
+
# colour: {},
|
563
|
+
# style: '',
|
564
|
+
# geometry: {},
|
565
|
+
# cursor: true,
|
566
|
+
# delay: 0.0,
|
567
|
+
# lines: [{
|
568
|
+
# parent: nil,
|
569
|
+
# colour: {},
|
570
|
+
# style: [],
|
571
|
+
# streams: [{
|
572
|
+
# parent: nil,
|
573
|
+
# colour: {},
|
574
|
+
# style: [],
|
575
|
+
# width: 80,
|
576
|
+
# align: :left,
|
577
|
+
# text: 'This is aligned left, and padded with spaces.'
|
578
|
+
# }]
|
579
|
+
# }]
|
580
|
+
# }] }
|
581
|
+
# )
|
582
|
+
# end
|
583
|
+
|
584
|
+
# it 'handles alignment' do
|
585
|
+
# Vedeu.view 'testing_view' do
|
586
|
+
# line do
|
587
|
+
# stream do
|
588
|
+
# width 80
|
589
|
+
# align :centre
|
590
|
+
# text 'This is aligned centrally, and padded with spaces.'
|
591
|
+
# end
|
592
|
+
# end
|
593
|
+
# end.must_equal(
|
594
|
+
# { interfaces: [{
|
595
|
+
# name: 'testing_view',
|
596
|
+
# group: '',
|
597
|
+
# colour: {},
|
598
|
+
# style: '',
|
599
|
+
# geometry: {},
|
600
|
+
# cursor: true,
|
601
|
+
# delay: 0.0,
|
602
|
+
# lines: [{
|
603
|
+
# parent: nil,
|
604
|
+
# colour: {},
|
605
|
+
# style: [],
|
606
|
+
# streams: [{
|
607
|
+
# parent: nil,
|
608
|
+
# colour: {},
|
609
|
+
# style: [],
|
610
|
+
# width: 80,
|
611
|
+
# align: :centre,
|
612
|
+
# text: 'This is aligned centrally, and padded with spaces.'
|
613
|
+
# }]
|
614
|
+
# }]
|
615
|
+
# }] }
|
616
|
+
# )
|
617
|
+
# end
|
618
|
+
|
619
|
+
# it 'handles alignment' do
|
620
|
+
# Vedeu.view 'testing_view' do
|
621
|
+
# line do
|
622
|
+
# stream do
|
623
|
+
# width 80
|
624
|
+
# align :right
|
625
|
+
# text 'This is aligned right, and padded with spaces.'
|
626
|
+
# end
|
627
|
+
# end
|
628
|
+
# end.must_equal(
|
629
|
+
# { interfaces: [{
|
630
|
+
# name: 'testing_view',
|
631
|
+
# group: '',
|
632
|
+
# colour: {},
|
633
|
+
# style: '',
|
634
|
+
# geometry: {},
|
635
|
+
# cursor: true,
|
636
|
+
# delay: 0.0,
|
637
|
+
# lines: [{
|
638
|
+
# parent: nil,
|
639
|
+
# colour: {},
|
640
|
+
# style: [],
|
641
|
+
# streams: [{
|
642
|
+
# parent: nil,
|
643
|
+
# colour: {},
|
644
|
+
# style: [],
|
645
|
+
# width: 80,
|
646
|
+
# align: :right,
|
647
|
+
# text: 'This is aligned right, and padded with spaces.'
|
648
|
+
# }]
|
649
|
+
# }]
|
650
|
+
# }] }
|
651
|
+
# )
|
652
|
+
# end
|
653
|
+
|
654
|
+
# it 'handles multiple colour and text statements correctly' do
|
655
|
+
# Vedeu.view 'testing_view' do
|
656
|
+
# line do
|
657
|
+
# foreground('#ffff00') { text "\u{25B2}" }
|
658
|
+
# text " Prev"
|
659
|
+
|
660
|
+
# foreground('#ffff00') { text "\u{25BC}" }
|
661
|
+
# text " Next"
|
662
|
+
|
663
|
+
# foreground('#ffff00') { text "\u{21B2}" }
|
664
|
+
# text " Select"
|
665
|
+
|
666
|
+
# foreground('#ffff00') { text "\u{2395}" }
|
667
|
+
# text " Pause"
|
668
|
+
|
669
|
+
# foreground('#ffff00') { text "Q" }
|
670
|
+
# text " Quit"
|
671
|
+
# end
|
672
|
+
# end.must_equal(
|
673
|
+
# { interfaces: [{
|
674
|
+
# name: 'testing_view',
|
675
|
+
# group: '',
|
676
|
+
# colour: {},
|
677
|
+
# style: '',
|
678
|
+
# geometry: {},
|
679
|
+
# cursor: true,
|
680
|
+
# delay: 0.0,
|
681
|
+
# lines: [
|
682
|
+
# {
|
683
|
+
# parent: nil,
|
684
|
+
# colour: {},
|
685
|
+
# style: [],
|
686
|
+
# streams: [
|
687
|
+
# {
|
688
|
+
# colour: {
|
689
|
+
# foreground: "#ffff00"
|
690
|
+
# },
|
691
|
+
# style: [],
|
692
|
+
# text: "▲",
|
693
|
+
# width: nil,
|
694
|
+
# align: :left,
|
695
|
+
# parent: nil,
|
696
|
+
# }, {
|
697
|
+
# text: " Prev",
|
698
|
+
# }, {
|
699
|
+
# colour: {
|
700
|
+
# foreground: "#ffff00"
|
701
|
+
# },
|
702
|
+
# style: [],
|
703
|
+
# text: "▼",
|
704
|
+
# width: nil,
|
705
|
+
# align: :left,
|
706
|
+
# parent: nil,
|
707
|
+
# }, {
|
708
|
+
# text: " Next",
|
709
|
+
# }, {
|
710
|
+
# colour: {
|
711
|
+
# foreground: "#ffff00"
|
712
|
+
# },
|
713
|
+
# style: [],
|
714
|
+
# text: "↲",
|
715
|
+
# width: nil,
|
716
|
+
# align: :left,
|
717
|
+
# parent: nil,
|
718
|
+
# }, {
|
719
|
+
# text: " Select",
|
720
|
+
# }, {
|
721
|
+
# colour: {
|
722
|
+
# foreground: "#ffff00"
|
723
|
+
# },
|
724
|
+
# style: [],
|
725
|
+
# text: "⎕",
|
726
|
+
# width: nil,
|
727
|
+
# align: :left,
|
728
|
+
# parent: nil,
|
729
|
+
# }, {
|
730
|
+
# text: " Pause",
|
731
|
+
# }, {
|
732
|
+
# colour: {
|
733
|
+
# foreground: "#ffff00"
|
734
|
+
# },
|
735
|
+
# style: [],
|
736
|
+
# text: "Q",
|
737
|
+
# width: nil,
|
738
|
+
# align: :left,
|
739
|
+
# parent: nil,
|
740
|
+
# }, {
|
741
|
+
# text: " Quit",
|
742
|
+
# }
|
743
|
+
# ]
|
744
|
+
# }
|
745
|
+
# ]
|
746
|
+
# }] }
|
747
|
+
# )
|
748
|
+
# end
|
749
|
+
|
750
|
+
# it 'allows inline values for line' do
|
751
|
+
# Vedeu.interface 'helium' do
|
752
|
+
# end
|
753
|
+
# attributes = Vedeu.view 'helium' do
|
754
|
+
# line 'A headline, if you will.'
|
755
|
+
# line # with a spacer line
|
756
|
+
# line 'This is a line of text...'
|
757
|
+
# line do
|
758
|
+
# text '...we can mix and match...'
|
759
|
+
# end
|
760
|
+
# line '...to our hearts content.'
|
761
|
+
# end
|
762
|
+
# attributes[:interfaces].first[:lines].size.must_equal(5)
|
763
|
+
# end
|
764
|
+
# end
|
765
|
+
# end
|
766
|
+
# end
|
767
|
+
# end
|