vedeu 0.2.1 → 0.2.2

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.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/README.md +1 -2
  4. data/Rakefile +5 -5
  5. data/bin/vedeu +8 -4
  6. data/docs/api.md +3 -1
  7. data/docs/events.md +43 -29
  8. data/docs/getting_started.md +2 -0
  9. data/examples/cursor_app/cursor_app.rb +85 -0
  10. data/examples/lines_app/lines_app.rb +60 -0
  11. data/lib/vedeu.rb +9 -3
  12. data/lib/vedeu/api/api.rb +28 -7
  13. data/lib/vedeu/api/composition.rb +2 -0
  14. data/lib/vedeu/api/helpers.rb +2 -0
  15. data/lib/vedeu/api/interface.rb +2 -20
  16. data/lib/vedeu/api/keymap.rb +2 -0
  17. data/lib/vedeu/api/line.rb +2 -0
  18. data/lib/vedeu/api/menu.rb +3 -1
  19. data/lib/vedeu/api/stream.rb +25 -2
  20. data/lib/vedeu/application.rb +4 -4
  21. data/lib/vedeu/configuration/api.rb +327 -0
  22. data/lib/vedeu/configuration/cli.rb +110 -0
  23. data/lib/vedeu/{configuration.rb → configuration/configuration.rb} +49 -99
  24. data/lib/vedeu/launcher.rb +0 -1
  25. data/lib/vedeu/models/attributes/colour_translator.rb +2 -2
  26. data/lib/vedeu/models/colour.rb +0 -1
  27. data/lib/vedeu/models/composition.rb +2 -8
  28. data/lib/vedeu/models/cursor.rb +261 -0
  29. data/lib/vedeu/models/geometry.rb +11 -19
  30. data/lib/vedeu/models/interface.rb +2 -12
  31. data/lib/vedeu/models/keymap.rb +2 -0
  32. data/lib/vedeu/models/line.rb +2 -0
  33. data/lib/vedeu/models/stream.rb +2 -0
  34. data/lib/vedeu/models/style.rb +2 -0
  35. data/lib/vedeu/output/clear.rb +0 -1
  36. data/lib/vedeu/output/compositor.rb +0 -1
  37. data/lib/vedeu/output/refresh.rb +3 -0
  38. data/lib/vedeu/output/render.rb +12 -6
  39. data/lib/vedeu/output/view.rb +1 -0
  40. data/lib/vedeu/repositories/cursors.rb +98 -0
  41. data/lib/vedeu/repositories/events.rb +0 -1
  42. data/lib/vedeu/repositories/focus.rb +18 -0
  43. data/lib/vedeu/repositories/menus.rb +4 -4
  44. data/lib/vedeu/support/common.rb +2 -1
  45. data/lib/vedeu/support/event.rb +1 -10
  46. data/lib/vedeu/support/grid.rb +1 -2
  47. data/lib/vedeu/{repositories → support}/keymap_validator.rb +5 -4
  48. data/lib/vedeu/support/log.rb +3 -0
  49. data/lib/vedeu/support/menu.rb +4 -1
  50. data/lib/vedeu/support/registrar.rb +2 -1
  51. data/test/integration/defining_interfaces_test.rb +0 -1
  52. data/test/integration/views/basic_view_test.rb +741 -739
  53. data/test/lib/vedeu/api/api_test.rb +14 -3
  54. data/test/lib/vedeu/api/helpers_test.rb +3 -3
  55. data/test/lib/vedeu/api/interface_test.rb +17 -70
  56. data/test/lib/vedeu/api/keymap_test.rb +2 -0
  57. data/test/lib/vedeu/api/line_test.rb +4 -4
  58. data/test/lib/vedeu/api/menu_test.rb +6 -5
  59. data/test/lib/vedeu/api/stream_test.rb +18 -0
  60. data/test/lib/vedeu/configuration/api_test.rb +248 -0
  61. data/test/lib/vedeu/configuration/cli_test.rb +88 -0
  62. data/test/lib/vedeu/configuration/configuration_test.rb +67 -0
  63. data/test/lib/vedeu/input/input_test.rb +2 -2
  64. data/test/lib/vedeu/models/attributes/background_test.rb +3 -3
  65. data/test/lib/vedeu/models/attributes/foreground_test.rb +3 -3
  66. data/test/lib/vedeu/models/composition_test.rb +0 -222
  67. data/test/lib/vedeu/models/cursor_test.rb +164 -0
  68. data/test/lib/vedeu/models/interface_test.rb +0 -11
  69. data/test/lib/vedeu/output/compositor_test.rb +2 -4
  70. data/test/lib/vedeu/output/render_test.rb +4 -41
  71. data/test/lib/vedeu/repositories/cursors_test.rb +13 -0
  72. data/test/lib/vedeu/repositories/focus_test.rb +14 -4
  73. data/test/lib/vedeu/repositories/menus_test.rb +36 -29
  74. data/test/lib/vedeu/{repositories → support}/keymap_validator_test.rb +0 -0
  75. data/test/lib/vedeu/support/menu_test.rb +3 -3
  76. data/test/lib/vedeu/support/registrar_test.rb +6 -0
  77. data/test/lib/vedeu/support/terminal_test.rb +2 -2
  78. data/test/test_helper.rb +1 -1
  79. data/vedeu.gemspec +1 -1
  80. metadata +23 -14
  81. data/elements.txt +0 -118
  82. data/lib/vedeu/support/cursor.rb +0 -96
  83. data/test/lib/vedeu/configuration_test.rb +0 -154
  84. data/test/lib/vedeu/support/cursor_test.rb +0 -79
  85. data/test/support/model_test_data.json +0 -437
@@ -3,6 +3,7 @@ require 'time'
3
3
 
4
4
  module Vedeu
5
5
  # :nocov:
6
+ # @api private
6
7
  class MonoLogger < Logger
7
8
  # Create a trappable Logger instance.
8
9
  #
@@ -86,6 +87,8 @@ module Vedeu
86
87
 
87
88
  # Provides the ability to Log anything to the Vedeu log file which is
88
89
  # hard-coded to reside in `$HOME/.vedeu/vedeu.log`.
90
+ #
91
+ # @api private
89
92
  class Log
90
93
 
91
94
  # @return [TrueClass]
@@ -3,14 +3,17 @@ module Vedeu
3
3
  # Converts the collection passed into a list of menu items which can be
4
4
  # navigated using the instance methods or events provided.
5
5
  #
6
+ # @api private
6
7
  class Menu
7
8
 
8
9
  # Returns a new instance of Menu.
9
10
  #
10
11
  # @param collection [Array]
12
+ # @param name [String]
11
13
  # @return [Menu]
12
- def initialize(collection)
14
+ def initialize(collection, name = '')
13
15
  @collection = collection
16
+ @name = name
14
17
  @current = 0
15
18
  @selected = nil
16
19
  end
@@ -30,6 +30,8 @@ module Vedeu
30
30
 
31
31
  Vedeu::Interfaces.add(attributes)
32
32
 
33
+ Vedeu::Cursors.add(attributes)
34
+
33
35
  Vedeu::Groups.add(attributes)
34
36
 
35
37
  Vedeu::Focus.add(attributes)
@@ -39,7 +41,6 @@ module Vedeu
39
41
 
40
42
  private
41
43
 
42
- # Client application defined settings for interfaces etc.
43
44
  attr_reader :attributes
44
45
 
45
46
  # At present, validates that attributes has a `:name` key that is not nil or
@@ -9,7 +9,6 @@ class MyFirstApplication
9
9
  width 40
10
10
  height 4
11
11
  centred false
12
- cursor true
13
12
  delay 0.25
14
13
  group 'elements'
15
14
  end
@@ -1,767 +1,769 @@
1
- # require 'test_helper'
1
+ require 'test_helper'
2
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
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
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
16
+ it 'builds a basic view' do
17
+ Vedeu.view 'testing_view' do
18
+ line do
19
+ text 'All text declarations within a line '
20
+ text 'are treated as one line.'
21
+ end
22
+ end.must_equal(
23
+ { interfaces: [{
24
+ name: 'testing_view',
25
+ group: '',
26
+ colour: {},
27
+ style: '',
28
+ geometry: {},
29
+ delay: 0.0,
30
+ parent: {},
31
+ lines: [
32
+ {
33
+ parent: {colour: {}, style: ''},
34
+ colour: {},
35
+ style: [],
36
+ streams: [
37
+ {
38
+ text: 'All text declarations within a line '
39
+ }, {
40
+ text: 'are treated as one line.'
41
+ }
42
+ ]
43
+ }
44
+ ]
45
+ }] }
46
+ )
47
+ end
48
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
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
+ delay: 0.0,
62
+ parent: {},
63
+ lines: [
64
+ {
65
+ parent: {colour: {}, style: ''},
66
+ colour: {},
67
+ style: [],
68
+ streams: [{ text: '1. Line without colours.' }]
69
+ }
70
+ ]
71
+ }] }
72
+ )
73
+ end
74
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
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
+ delay: 0.0,
89
+ parent: {},
90
+ lines: [
91
+ {
92
+ parent: {colour: {}, style: ''},
93
+ colour: { background: '#ff0000', foreground: '#ffff00' },
94
+ style: [],
95
+ streams: [{ text: '2. Line with colours.' }]
96
+ }
97
+ ]
98
+ }] }
99
+ )
100
+ end
101
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
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
+ delay: 0.0,
116
+ parent: {},
117
+ lines: [
118
+ {
119
+ parent: {colour: {}, style: ''},
120
+ colour: { background: '#005700', foreground: '#a7ff00' },
121
+ style: [],
122
+ streams: [{ text: '3. Line with explicit colour declaration.' }]
123
+ }
124
+ ]
125
+ }] }
126
+ )
127
+ end
128
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
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
+ delay: 0.0,
144
+ parent: {},
145
+ lines: [
146
+ {
147
+ parent: {colour: {}, style: ''},
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: {colour: {}, style: []},
157
+ }]
158
+ }
159
+ ]
160
+ }] }
161
+ )
162
+ end
163
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
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
+ delay: 0.0,
179
+ parent: {},
180
+ lines: [
181
+ {
182
+ parent: {colour: {}, style: ''},
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: {colour: {}, style: []},
192
+ }]
193
+ }
194
+ ]
195
+ }] }
196
+ )
197
+ end
198
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
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
+ delay: 0.0,
213
+ parent: {},
214
+ lines: [
215
+ {
216
+ parent: {colour: {}, style: ''},
217
+ colour: {},
218
+ style: ['normal'],
219
+ streams: [{
220
+ text: '1. Line with a normal style.'
221
+ }]
222
+ }
223
+ ]
224
+ }] }
225
+ )
226
+ end
227
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
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
+ delay: 0.0,
242
+ parent: {},
243
+ lines: [
244
+ {
245
+ parent: {colour: {}, style: ''},
246
+ colour: {},
247
+ style: ['underline'],
248
+ streams: [{
249
+ text: '2. Line with an underline style.'
250
+ }]
251
+ }
252
+ ]
253
+ }] }
254
+ )
255
+ end
256
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
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
+ delay: 0.0,
272
+ parent: {},
273
+ lines: [
274
+ {
275
+ parent: {colour: {}, style: ''},
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
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
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
+ delay: 0.0,
307
+ parent: {},
308
+ lines: [
309
+ {
310
+ parent: {colour: {}, style: ''},
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
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
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
+ delay: 0.0,
342
+ parent: {},
343
+ lines: [
344
+ {
345
+ parent: {colour: {}, style: ''},
346
+ colour: {},
347
+ style: [],
348
+ streams: [
349
+ {
350
+ parent: {colour: {}, style: []},
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
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
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
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
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
+ delay: 0.0,
385
+ parent: {},
386
+ lines: [
387
+ {
388
+ parent: {colour: {}, style: ''},
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: {colour: {}, style: []},
399
+ }, {
400
+ colour: {},
401
+ style: [],
402
+ text: ' on the same line- note the space.',
403
+ width: nil,
404
+ align: :left,
405
+ parent: {colour: {}, style: []},
406
+ }
407
+ ]
408
+ }
409
+ ]
410
+ }] }
411
+ )
412
+ end
413
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
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
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
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
+ delay: 0.0,
434
+ parent: {},
435
+ lines: [
436
+ {
437
+ parent: {colour: {}, style: ''},
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: {colour: {}, style: []},
448
+ }, {
449
+ colour: {
450
+ foreground: '#ff0000',
451
+ background: '#00ff00'
452
+ },
453
+ style: [],
454
+ text: ' colours too.',
455
+ width: nil,
456
+ align: :left,
457
+ parent: {colour: {}, style: []},
458
+ }
459
+ ]
460
+ }
461
+ ]
462
+ }] }
463
+ )
464
+ end
465
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
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
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
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
+ delay: 0.0,
486
+ parent: {},
487
+ lines: [
488
+ {
489
+ parent: {colour: {}, style: ''},
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: {colour: {}, style: []},
500
+ }, {
501
+ colour: {},
502
+ style: ['underline'],
503
+ text: ' styles too.',
504
+ width: nil,
505
+ align: :left,
506
+ parent: {colour: {}, style: []},
507
+ }
508
+ ]
509
+ }
510
+ ]
511
+ }] }
512
+ )
513
+ end
514
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
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
+ delay: 0.0,
531
+ parent: {},
532
+ lines: [{
533
+ parent: {colour: {}, style: ''},
534
+ colour: {},
535
+ style: [],
536
+ streams: [{
537
+ parent: {colour: {}, style: []},
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
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
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
+ delay: 0.0,
566
+ parent: {},
567
+ lines: [{
568
+ parent: {colour: {}, style: ''},
569
+ colour: {},
570
+ style: [],
571
+ streams: [{
572
+ parent: {colour: {}, style: []},
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
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
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
+ delay: 0.0,
601
+ parent: {},
602
+ lines: [{
603
+ parent: {colour: {}, style: ''},
604
+ colour: {},
605
+ style: [],
606
+ streams: [{
607
+ parent: {colour: {}, style: []},
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
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
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
+ delay: 0.0,
636
+ parent: {},
637
+ lines: [{
638
+ parent: {colour: {}, style: ''},
639
+ colour: {},
640
+ style: [],
641
+ streams: [{
642
+ parent: {colour: {}, style: []},
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
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"
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
659
 
660
- # foreground('#ffff00') { text "\u{25BC}" }
661
- # text " Next"
660
+ foreground('#ffff00') { text "\u{25BC}" }
661
+ text " Next"
662
662
 
663
- # foreground('#ffff00') { text "\u{21B2}" }
664
- # text " Select"
663
+ foreground('#ffff00') { text "\u{21B2}" }
664
+ text " Select"
665
665
 
666
- # foreground('#ffff00') { text "\u{2395}" }
667
- # text " Pause"
666
+ foreground('#ffff00') { text "\u{2395}" }
667
+ text " Pause"
668
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
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
+ delay: 0.0,
680
+ parent: {},
681
+ lines: [
682
+ {
683
+ parent: {colour: {}, style: ''},
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: {colour: {}, style: []},
696
+ }, {
697
+ text: " Prev",
698
+ }, {
699
+ colour: {
700
+ foreground: '#ffff00'
701
+ },
702
+ style: [],
703
+ text: "▼",
704
+ width: nil,
705
+ align: :left,
706
+ parent: {colour: {}, style: []},
707
+ }, {
708
+ text: " Next",
709
+ }, {
710
+ colour: {
711
+ foreground: '#ffff00'
712
+ },
713
+ style: [],
714
+ text: "↲",
715
+ width: nil,
716
+ align: :left,
717
+ parent: {colour: {}, style: []},
718
+ }, {
719
+ text: " Select",
720
+ }, {
721
+ colour: {
722
+ foreground: '#ffff00'
723
+ },
724
+ style: [],
725
+ text: "⎕",
726
+ width: nil,
727
+ align: :left,
728
+ parent: {colour: {}, style: []},
729
+ }, {
730
+ text: " Pause",
731
+ }, {
732
+ colour: {
733
+ foreground: '#ffff00'
734
+ },
735
+ style: [],
736
+ text: "Q",
737
+ width: nil,
738
+ align: :left,
739
+ parent: {colour: {}, style: []},
740
+ }, {
741
+ text: " Quit",
742
+ }
743
+ ]
744
+ }
745
+ ]
746
+ }] }
747
+ )
748
+ end
749
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
750
+ it 'allows inline values for line' do
751
+ Vedeu.interface 'helium' do
752
+ # ...
753
+ end
754
+
755
+ attributes = Vedeu.view 'helium' do
756
+ line 'A headline, if you will.'
757
+ line # with a spacer line
758
+ line 'This is a line of text...'
759
+ line do
760
+ text '...we can mix and match...'
761
+ end
762
+ line '...to our hearts content.'
763
+ end
764
+ attributes[:interfaces].first[:lines].size.must_equal(5)
765
+ end
766
+ end
767
+ end
768
+ end
769
+ end