vedeu 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/docs/api.md +2 -0
  3. data/docs/events.md +0 -4
  4. data/examples/cursor_app/cursor_app.rb +56 -44
  5. data/lib/vedeu/api/api.rb +4 -6
  6. data/lib/vedeu/api/composition.rb +3 -7
  7. data/lib/vedeu/api/interface.rb +2 -3
  8. data/lib/vedeu/api/menu.rb +5 -3
  9. data/lib/vedeu/api/stream.rb +34 -0
  10. data/lib/vedeu/application.rb +4 -7
  11. data/lib/vedeu/configuration/api.rb +0 -5
  12. data/lib/vedeu/configuration/cli.rb +0 -1
  13. data/lib/vedeu/configuration/configuration.rb +0 -12
  14. data/lib/vedeu/input/input.rb +0 -3
  15. data/lib/vedeu/launcher.rb +0 -1
  16. data/lib/vedeu/models/{attributes/background.rb → background.rb} +0 -4
  17. data/lib/vedeu/models/char.rb +43 -0
  18. data/lib/vedeu/models/colour.rb +0 -1
  19. data/lib/vedeu/models/composition.rb +4 -3
  20. data/lib/vedeu/models/cursor.rb +70 -146
  21. data/lib/vedeu/models/{attributes/foreground.rb → foreground.rb} +0 -4
  22. data/lib/vedeu/models/geometry.rb +19 -20
  23. data/lib/vedeu/models/interface.rb +36 -5
  24. data/lib/vedeu/models/keymap.rb +7 -4
  25. data/lib/vedeu/models/line.rb +31 -11
  26. data/lib/vedeu/models/offset.rb +84 -0
  27. data/lib/vedeu/models/stream.rb +37 -13
  28. data/lib/vedeu/models/style.rb +0 -1
  29. data/lib/vedeu/output/area.rb +284 -0
  30. data/lib/vedeu/output/clear.rb +2 -4
  31. data/lib/vedeu/output/compositor.rb +0 -4
  32. data/lib/vedeu/output/refresh.rb +1 -2
  33. data/lib/vedeu/output/render.rb +12 -163
  34. data/lib/vedeu/output/view.rb +0 -2
  35. data/lib/vedeu/output/viewport.rb +132 -0
  36. data/lib/vedeu/repositories/buffers.rb +11 -22
  37. data/lib/vedeu/repositories/cursors.rb +20 -47
  38. data/lib/vedeu/repositories/events.rb +2 -1
  39. data/lib/vedeu/repositories/focus.rb +16 -16
  40. data/lib/vedeu/repositories/groups.rb +1 -4
  41. data/lib/vedeu/repositories/interfaces.rb +10 -3
  42. data/lib/vedeu/repositories/keymaps.rb +0 -3
  43. data/lib/vedeu/repositories/menus.rb +0 -2
  44. data/lib/vedeu/repositories/offsets.rb +47 -0
  45. data/lib/vedeu/{models/attributes → support}/coercions.rb +0 -0
  46. data/lib/vedeu/{models/attributes → support}/colour_translator.rb +0 -16
  47. data/lib/vedeu/support/esc.rb +0 -22
  48. data/lib/vedeu/support/event.rb +1 -17
  49. data/lib/vedeu/support/exceptions.rb +0 -3
  50. data/lib/vedeu/support/grid.rb +0 -3
  51. data/lib/vedeu/support/log.rb +13 -14
  52. data/lib/vedeu/support/move.rb +50 -0
  53. data/lib/vedeu/support/position.rb +17 -9
  54. data/lib/vedeu/{models/attributes → support}/presentation.rb +1 -4
  55. data/lib/vedeu/support/registrar.rb +2 -2
  56. data/lib/vedeu/support/repository.rb +23 -2
  57. data/lib/vedeu/support/terminal.rb +0 -2
  58. data/lib/vedeu/support/trace.rb +0 -11
  59. data/lib/vedeu.rb +11 -5
  60. data/test/lib/vedeu/api/api_test.rb +14 -5
  61. data/test/lib/vedeu/api/composition_test.rb +9 -26
  62. data/test/lib/vedeu/api/keymap_test.rb +1 -1
  63. data/test/lib/vedeu/api/menu_test.rb +6 -0
  64. data/test/lib/vedeu/api/stream_test.rb +32 -0
  65. data/test/lib/vedeu/models/{attributes/background_test.rb → background_test.rb} +0 -0
  66. data/test/lib/vedeu/models/char_test.rb +46 -0
  67. data/test/lib/vedeu/models/composition_test.rb +7 -0
  68. data/test/lib/vedeu/models/cursor_test.rb +63 -80
  69. data/test/lib/vedeu/models/{attributes/foreground_test.rb → foreground_test.rb} +0 -0
  70. data/test/lib/vedeu/models/geometry_test.rb +8 -10
  71. data/test/lib/vedeu/models/interface_test.rb +26 -21
  72. data/test/lib/vedeu/models/keymap_test.rb +6 -0
  73. data/test/lib/vedeu/models/line_test.rb +82 -3
  74. data/test/lib/vedeu/models/offset_test.rb +121 -0
  75. data/test/lib/vedeu/models/stream_test.rb +107 -8
  76. data/test/lib/vedeu/output/area_test.rb +242 -0
  77. data/test/lib/vedeu/output/compositor_test.rb +12 -3
  78. data/test/lib/vedeu/output/render_test.rb +34 -39
  79. data/test/lib/vedeu/output/viewport_test.rb +36 -0
  80. data/test/lib/vedeu/repositories/cursors_test.rb +32 -9
  81. data/test/lib/vedeu/repositories/focus_test.rb +8 -0
  82. data/test/lib/vedeu/repositories/offsets_test.rb +32 -0
  83. data/test/lib/vedeu/{models/attributes → support}/coercions_test.rb +0 -0
  84. data/test/lib/vedeu/{models/attributes → support}/colour_translator_test.rb +0 -0
  85. data/test/lib/vedeu/support/move_test.rb +35 -0
  86. data/test/lib/vedeu/{models/attributes → support}/presentation_test.rb +0 -0
  87. data/test/lib/vedeu/support/registrar_test.rb +6 -0
  88. data/test/lib/vedeu_test.rb +5 -0
  89. data/vedeu.gemspec +1 -1
  90. metadata +37 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53b812fdf424dda850a0a008b824cb388a2329cb
4
- data.tar.gz: 85d3208b47291886ed7dad1913fe29bb7806b2b8
3
+ metadata.gz: 5ab3b3e107a170520a384cb15529a6cb087b6aae
4
+ data.tar.gz: 96170b0362f0584f7ce527290cf3068bb2fe26bf
5
5
  SHA512:
6
- metadata.gz: 6d2e44aebbefa2314e55ba466f262d9417ed6380872746d23f2b9e9fe940c70f9fbbc741ec756e1069211c54498d8da09de57702076814bf014f717bdb7908a5
7
- data.tar.gz: 4cc8fd2986658da91d8d4b10d48da4514e9eaf588c11dc4941b2173471e85ccaf1adea8e5d19453f1f65532c5395e6234f5ffcca656743b7a9609e86dfb35adb
6
+ metadata.gz: 08584d6388fbac9ee09e678a22362aaff1028cbd547b3583dad82c67ae8cfb790989066412bc9de4ca0ff800127f7c5fd7a3f36281ee7329c0c04e6eec1ff574
7
+ data.tar.gz: 96a95d7eca4e92b3794eb96e3183fb75b908e74ea77aff7f561051ee37aac9ec2dd057e128c27e4acec3815c0c3bf0079cf4c8fc6fe312b59845cf639730a9a5
data/docs/api.md CHANGED
@@ -85,7 +85,9 @@ Note: Nesting indicates where an API method is allowed/supposed to be used.
85
85
  - foreground
86
86
  - stream
87
87
  - align
88
+ - background
88
89
  - colour
90
+ - foreground
89
91
  - style
90
92
  - text
91
93
  - width
data/docs/events.md CHANGED
@@ -43,10 +43,6 @@ Hides the cursor for the focussed interface.
43
43
 
44
44
  Shows the cursor for the focussed interface.
45
45
 
46
- ### `:_cursor_refresh_`
47
-
48
- Refreshes the cursor for the focussed interface.
49
-
50
46
  ### `:_exit_`
51
47
 
52
48
  When triggered, Vedeu will trigger a `:_cleanup_` event which you can define (to save files, etc) and attempt to exit.
@@ -17,34 +17,15 @@ class VedeuCursorApp
17
17
  centred true
18
18
  colour foreground: '#ff0000', background: '#000000'
19
19
  height 4
20
- width 12
20
+ width 15
21
21
  end
22
22
 
23
- interface 'krypton' do
24
- centred false
25
- colour foreground: '#ffff00', background: '#000000'
26
- height 4
27
- width 12
28
- y { use('iron').south }
29
- x { use('iron').east(1) }
30
- end
31
-
32
- interface 'francium' do
33
- centred false
34
- colour foreground: '#ff00ff', background: '#000000'
35
- height 4
36
- width 12
37
- y { use('iron').north(5) }
38
- x { use('iron').west(13) }
39
- end
40
-
41
- interface 'argon' do
42
- centred false
43
- colour foreground: '#00ff00', background: '#000000'
44
- height 4
45
- width 12
46
- y { use('iron').south }
47
- x { use('iron').west(13) }
23
+ interface 'gold' do
24
+ colour foreground: '#00ff00', background: '#001100'
25
+ height 4
26
+ width 15
27
+ x use('iron').left
28
+ y use('iron').south
48
29
  end
49
30
 
50
31
  keys do
@@ -54,26 +35,57 @@ class VedeuCursorApp
54
35
  key(:left) { trigger(:_cursor_left_) }
55
36
  end
56
37
 
38
+ focus('iron')
39
+
57
40
  render do
58
41
  view 'iron' do
59
- line 'shift+tab to'
60
- line 'move to the'
61
- line 'previous one'
62
- end
63
- view 'francium' do
64
- line 'Press tab to'
65
- line 'move to next'
66
- line 'interface or'
67
- end
68
- view 'krypton' do
69
- line 'Position is'
70
- line 'remembered'
71
- line 'between'
72
- line 'interfaces.'
73
- end
74
- view 'argon' do
75
- line 'To exit this'
76
- line 'just press Q'
42
+ line do
43
+ stream do
44
+ text 'A 23456789 '
45
+ end
46
+ stream do
47
+ background '#550000'
48
+ foreground '#ffff00'
49
+ text 'hydrogen'
50
+ end
51
+ stream do
52
+ text ' helium'
53
+ end
54
+ end
55
+ line 'B 23456789 lithium beryllium boron nitrogen'
56
+ line do
57
+ stream do
58
+ text 'C 23456789'
59
+ end
60
+ stream do
61
+ text ' carbon oxygen '
62
+ end
63
+ stream do
64
+ background '#aadd00'
65
+ foreground '#000000'
66
+ text 'fluorine'
67
+ end
68
+ end
69
+ line 'D 23456789'
70
+ line
71
+ line 'E 23456789 neon sodium'
72
+ line do
73
+ stream do
74
+ text 'F 23456789 magnesium '
75
+ end
76
+ stream do
77
+ foreground '#00aaff'
78
+ text 'aluminium'
79
+ end
80
+ end
81
+ line 'G 23456789 silicon'
82
+ line do
83
+ stream do
84
+ background '#550000'
85
+ foreground '#ff00ff'
86
+ text 'H 234'
87
+ end
88
+ end
77
89
  end
78
90
  end
79
91
 
data/lib/vedeu/api/api.rb CHANGED
@@ -214,7 +214,10 @@ module Vedeu
214
214
  # view 'my_interface' do
215
215
  # ...
216
216
  #
217
- # @return [Array]
217
+ # @raise [InvalidSyntax] When the required block is not given.
218
+ # @return [Array] A collection of strings, each defining containing the
219
+ # escape sequences and content. This data has already been sent to the
220
+ # terminal to be output.
218
221
  def render(&block)
219
222
  API::Composition.render(&block)
220
223
  end
@@ -223,19 +226,14 @@ module Vedeu
223
226
  # and attempt to redraw the current interface with varying degrees of
224
227
  # success. Can also be used to simulate a terminal resize.
225
228
  #
226
- # @api private
227
229
  # @return [TrueClass]
228
- # :nocov:
229
230
  def resize
230
231
  trigger(:_clear_)
231
232
 
232
233
  trigger(:_refresh_)
233
234
 
234
- trigger(:_cursor_refresh_)
235
-
236
235
  true
237
236
  end
238
- # :nocov:
239
237
 
240
238
  # Trigger a registered or system event by name with arguments. If the
241
239
  # event stored returns a value, that is returned.
@@ -7,13 +7,9 @@ module Vedeu
7
7
  # @api public
8
8
  class Composition < Vedeu::Composition
9
9
 
10
- # Directly write a view buffer to the terminal.
11
- #
12
10
  # @param block [Proc]
13
- # @raise [InvalidSyntax] When the required block is not given.
14
- # @return [Array] A collection of strings, each defining containing the
15
- # escape sequences and content. This data has already been sent to the
16
- # terminal to be output.
11
+ # @return [Array]
12
+ # @see Vedeu::API#render
17
13
  def self.render(&block)
18
14
  fail InvalidSyntax, '`render` requires a block.' unless block_given?
19
15
 
@@ -28,7 +24,7 @@ module Vedeu
28
24
 
29
25
  # @param name [String]
30
26
  # @param block [Proc]
31
- # @return []
27
+ # @return [Hash]
32
28
  # @see Vedeu::API#view
33
29
  def view(name, &block)
34
30
  attributes[:interfaces] << API::Interface
@@ -193,7 +193,6 @@ module Vedeu
193
193
 
194
194
  # Returns the out of bounds error message for the given named attribute.
195
195
  #
196
- # @api private
197
196
  # @param name [String]
198
197
  # @return [String]
199
198
  def out_of_bounds(name)
@@ -203,7 +202,7 @@ module Vedeu
203
202
 
204
203
  # Checks the value is within the terminal's confines.
205
204
  #
206
- # @api private
205
+ # @param value [Fixnum]
207
206
  # @return [Boolean]
208
207
  def y_out_of_bounds?(value)
209
208
  value < 1 || value > Terminal.height
@@ -211,7 +210,7 @@ module Vedeu
211
210
 
212
211
  # Checks the value is within the terminal's confines.
213
212
  #
214
- # @api private
213
+ # @param value [Fixnum]
215
214
  # @return [Boolean]
216
215
  def x_out_of_bounds?(value)
217
216
  value < 1 || value > Terminal.width
@@ -83,7 +83,6 @@ module Vedeu
83
83
 
84
84
  # The default values for a new instance of Menu.
85
85
  #
86
- # @api private
87
86
  # @return [Hash]
88
87
  def defaults
89
88
  {
@@ -92,12 +91,15 @@ module Vedeu
92
91
  }
93
92
  end
94
93
 
95
- # @api private
94
+ # @param method [Symbol] The name of the method sought.
95
+ # @param args [Array] The arguments which the method was to be invoked
96
+ # with.
97
+ # @param block [Proc] The optional block provided to the method.
96
98
  # @return []
97
99
  def method_missing(method, *args, &block)
98
100
  Vedeu.log("API::Menu#method_missing '#{method.to_s}' (args: #{args.inspect})")
99
101
 
100
- @self_before_instance_eval.send(method, *args, &block)
102
+ @self_before_instance_eval.send(method, *args, &block) if @self_before_instance_eval
101
103
  end
102
104
 
103
105
  end # Menu
@@ -34,6 +34,40 @@ module Vedeu
34
34
  attributes[:align] = value.to_sym
35
35
  end
36
36
 
37
+ # Specify the background colour for a stream.
38
+ #
39
+ # @param value [String]
40
+ #
41
+ # @example
42
+ # ...
43
+ # stream do
44
+ # background '#0022ff'
45
+ # ... other stream directives ...
46
+ #
47
+ # @return [Hash]
48
+ def background(value = '')
49
+ fail InvalidSyntax, '`background` requires a value.' unless defined_value?(value)
50
+
51
+ attributes[:colour].merge!({ background: value })
52
+ end
53
+
54
+ # Specify the foreground colour for a stream.
55
+ #
56
+ # @param value [String]
57
+ #
58
+ # @example
59
+ # ...
60
+ # stream do
61
+ # foreground '#0022ff'
62
+ # ... other stream directives ...
63
+ #
64
+ # @return [Hash]
65
+ def foreground(value = '')
66
+ fail InvalidSyntax, '`foreground` requires a value.' unless defined_value?(value)
67
+
68
+ attributes[:colour].merge!({ foreground: value })
69
+ end
70
+
37
71
  # Syntactic sugar used with {#align} to left align content.
38
72
  #
39
73
  # @return [Symbol]
@@ -4,7 +4,7 @@ module Vedeu
4
4
  #
5
5
  # @api private
6
6
  class Application
7
- # :nocov:
7
+
8
8
  class << self
9
9
 
10
10
  # @return []
@@ -19,7 +19,6 @@ module Vedeu
19
19
  # is about to terminate. Client applications are encouraged to use this
20
20
  # event to close any open buffers, save files, empty trash, etc.
21
21
  #
22
- # @api private
23
22
  # @raise [StopIteration] Will cause {#start} to exit its loop and
24
23
  # terminate the application.
25
24
  # @return [StopIteration]
@@ -28,7 +27,8 @@ module Vedeu
28
27
 
29
28
  fail StopIteration
30
29
  end
31
- end
30
+
31
+ end # self
32
32
 
33
33
  # @return [Application]
34
34
  def initialize; end
@@ -60,7 +60,6 @@ module Vedeu
60
60
  # Runs the application loop either once, or forever (exceptions and signals
61
61
  # permitting).
62
62
  #
63
- # @api private
64
63
  # @return []
65
64
  def runner
66
65
  if Configuration.once?
@@ -79,7 +78,6 @@ module Vedeu
79
78
  # and 'do something useful'. When the client application has finished, it
80
79
  # should trigger the `:_exit_` event.
81
80
  #
82
- # @api private
83
81
  # @return []
84
82
  def main_sequence
85
83
  if Configuration.interactive?
@@ -95,7 +93,6 @@ module Vedeu
95
93
  # uncaught exception occurs or when either the `:_mode_switch_` or `:_exit_`
96
94
  # event is triggered.
97
95
  #
98
- # @api private
99
96
  # @return []
100
97
  def run_many
101
98
  loop { yield }
@@ -108,5 +105,5 @@ module Vedeu
108
105
  end
109
106
 
110
107
  end # Application
111
- # :nocov:
108
+
112
109
  end # Vedeu
@@ -298,7 +298,6 @@ module Vedeu
298
298
  # Returns the options set via the configuration API DSL or an empty Hash
299
299
  # if none were set.
300
300
  #
301
- # @api private
302
301
  # @return [Hash]
303
302
  def options
304
303
  @_options ||= {}
@@ -307,7 +306,6 @@ module Vedeu
307
306
  # Returns the system keys set via the configuration API DSL or an empty
308
307
  # hash if none were redefined.
309
308
  #
310
- # @api private
311
309
  # @return [Hash]
312
310
  def system_key_options
313
311
  @_system_key_options ||= Configuration.default_system_keys
@@ -315,7 +313,6 @@ module Vedeu
315
313
 
316
314
  # Checks that the value provided to {#colour_mode} is valid.
317
315
  #
318
- # @api private
319
316
  # @param value [Fixnum]
320
317
  # @return [Boolean]
321
318
  def valid_colour_mode?(value)
@@ -326,7 +323,6 @@ module Vedeu
326
323
  # {#focus_prev_key} and {#mode_switch_key} is valid. Must be a Symbol or a
327
324
  # non-empty String.
328
325
  #
329
- # @api private
330
326
  # @param value [String|Symbol]
331
327
  # @return [Boolean]
332
328
  def valid_key?(value)
@@ -340,7 +336,6 @@ module Vedeu
340
336
  # Raises an exception on behalf of the calling method to report that the
341
337
  # value provided is not valid.
342
338
  #
343
- # @api private
344
339
  # @param system_key [String] The calling method wishing to raise an
345
340
  # exception.
346
341
  # @raise [InvalidSyntax] When the system_key parameter is not a String or
@@ -117,7 +117,6 @@ module Vedeu
117
117
  # Returns the options set via command-line arguments parsed by
118
118
  # OptionParser, or an empty Hash if none were set or parsed.
119
119
  #
120
- # @api private
121
120
  # @return [Hash]
122
121
  def options
123
122
  @_options ||= {}
@@ -98,7 +98,6 @@ module Vedeu
98
98
 
99
99
  # Vedeu's default system keys. Use {#system_keys}.
100
100
  #
101
- # @api private
102
101
  # @return [Hash]
103
102
  def default_system_keys
104
103
  {
@@ -113,7 +112,6 @@ module Vedeu
113
112
 
114
113
  # Returns all the options current configured.
115
114
  #
116
- # @api private
117
115
  # @return [Hash]
118
116
  def options
119
117
  @options ||= defaults
@@ -122,7 +120,6 @@ module Vedeu
122
120
  # The Vedeu default options, which of course are influenced by environment
123
121
  # variables also.
124
122
  #
125
- # @api private
126
123
  # @return [Hash]
127
124
  def defaults
128
125
  {
@@ -139,9 +136,7 @@ module Vedeu
139
136
  # Attempt to determine the terminal colour mode via environment variables,
140
137
  # or be optimistic and settle for 256 colours.
141
138
  #
142
- # @api private
143
139
  # @return [Fixnum]
144
- # :nocov:
145
140
  def detect_colour_mode
146
141
  return 16777216 if ENV['VEDEU_TESTMODE']
147
142
 
@@ -164,13 +159,10 @@ module Vedeu
164
159
 
165
160
  end
166
161
  end
167
- # :nocov:
168
162
 
169
163
  # Determine the debug mode via an environment variable.
170
164
  #
171
- # @api private
172
165
  # @return [Boolean]
173
- # :nocov:
174
166
  def detect_debug_mode
175
167
  return false if ENV['VEDEU_TESTMODE']
176
168
 
@@ -178,13 +170,10 @@ module Vedeu
178
170
 
179
171
  false
180
172
  end
181
- # :nocov:
182
173
 
183
174
  # Determine the trace mode via an environment variable.
184
175
  #
185
- # @api private
186
176
  # @return [Boolean]
187
- # :nocov:
188
177
  def detect_trace_mode
189
178
  return false if ENV['VEDEU_TESTMODE']
190
179
 
@@ -192,7 +181,6 @@ module Vedeu
192
181
 
193
182
  false
194
183
  end
195
- # :nocov:
196
184
 
197
185
  end # Configuration
198
186
 
@@ -23,13 +23,11 @@ module Vedeu
23
23
 
24
24
  private
25
25
 
26
- # @api private
27
26
  # @return [String]
28
27
  def input
29
28
  @_input ||= Terminal.input
30
29
  end
31
30
 
32
- # @api private
33
31
  # @return [String|Symbol]
34
32
  def keypress
35
33
  key = input
@@ -40,7 +38,6 @@ module Vedeu
40
38
  # Translates (if possible) entered escape sequences into symbols
41
39
  # representing the key which was pressed.
42
40
  #
43
- # @api private
44
41
  # @return [Hash]
45
42
  def specials
46
43
  {
@@ -8,7 +8,6 @@ module Vedeu
8
8
  # @api public
9
9
  class Launcher
10
10
 
11
- # :nocov:
12
11
  # @param argv [Array]
13
12
  # @param stdin []
14
13
  # @param stdout []
@@ -13,19 +13,16 @@ module Vedeu
13
13
  # Valid names are: `:black`, `:red`, `:green`, `:yellow`, `:blue`,
14
14
  # `:magenta`, `:cyan`, `:white` and `:default`.
15
15
  #
16
- # @api private
17
16
  # @return [String]
18
17
  def named
19
18
  ["\e[", background_codes[colour], 'm'].join
20
19
  end
21
20
 
22
- # @api private
23
21
  # @return [String]
24
22
  def numbered
25
23
  ["\e[48;5;", css_to_numbered, 'm'].join
26
24
  end
27
25
 
28
- # @api private
29
26
  # @return [String]
30
27
  def rgb
31
28
  if Configuration.colour_mode == 16777216
@@ -40,7 +37,6 @@ module Vedeu
40
37
  # Produces the background named colour escape sequence hash from the
41
38
  # foreground escape sequence hash.
42
39
  #
43
- # @api private
44
40
  # @return [Hash]
45
41
  def background_codes
46
42
  codes.inject({}){ |h, (k, v)| h.merge(k => v + 10) }
@@ -0,0 +1,43 @@
1
+ module Vedeu
2
+
3
+ # A Char represents a single character of the terminal. It is a container for
4
+ # the a single character in a {Vedeu::Stream}.
5
+ #
6
+ # @note The parent of a Char is a Line.
7
+ # @todo Colour and style is not being correctly reset. (GL 2014-10-19)
8
+ #
9
+ # @api private
10
+ class Char
11
+
12
+ include Presentation
13
+
14
+ attr_reader :attributes, :parent, :value
15
+ alias_method :data, :value
16
+
17
+ # Returns a new instance of Char.
18
+ #
19
+ # @param attributes [Hash]
20
+ # @return [Char]
21
+ def initialize(attributes = {})
22
+ @attributes = defaults.merge!(attributes)
23
+ @parent = @attributes[:parent]
24
+ @value = @attributes[:value]
25
+ end
26
+
27
+ private
28
+
29
+ # The default values for a new instance of Char.
30
+ #
31
+ # @return [Hash]
32
+ def defaults
33
+ {
34
+ colour: {},
35
+ parent: nil,
36
+ style: [],
37
+ value: '',
38
+ }
39
+ end
40
+
41
+ end # Char
42
+
43
+ end # Vedeu
@@ -41,7 +41,6 @@ module Vedeu
41
41
 
42
42
  private
43
43
 
44
- # @api private
45
44
  # @return [Hash]
46
45
  def defaults
47
46
  {
@@ -50,7 +50,6 @@ module Vedeu
50
50
 
51
51
  # The default values for a new instance of Composition.
52
52
  #
53
- # @api private
54
53
  # @return [Hash]
55
54
  def defaults
56
55
  {
@@ -58,12 +57,14 @@ module Vedeu
58
57
  }
59
58
  end
60
59
 
61
- # @api private
60
+ # @param method [Symbol] The name of the method sought.
61
+ # @param args [Array] The arguments which the method was to be invoked with.
62
+ # @param block [Proc] The optional block provided to the method.
62
63
  # @return []
63
64
  def method_missing(method, *args, &block)
64
65
  Vedeu.log("Composition#method_missing '#{method.to_s}' (args: #{args.inspect})")
65
66
 
66
- @self_before_instance_eval.send(method, *args, &block)
67
+ @self_before_instance_eval.send(method, *args, &block) if @self_before_instance_eval
67
68
  end
68
69
 
69
70
  end # Composition