vedeu 0.6.20 → 0.6.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -1
  3. data/README.md +4 -0
  4. data/Rakefile +13 -0
  5. data/bin/vedeu_drb_server +6 -6
  6. data/docs/api.md +14 -0
  7. data/docs/dsl.md +12 -12
  8. data/docs/events/document.md +4 -2
  9. data/docs/events/drb.md +4 -0
  10. data/docs/events/focus.md +2 -0
  11. data/docs/events/menu.md +2 -0
  12. data/docs/events/movement.md +7 -5
  13. data/docs/events/refresh.md +2 -0
  14. data/docs/events/system.md +5 -0
  15. data/docs/events/view.md +2 -0
  16. data/docs/events/visibility.md +2 -0
  17. data/lib/vedeu.rb +0 -23
  18. data/lib/vedeu/all.rb +2 -4
  19. data/lib/vedeu/application/application_view.rb +1 -1
  20. data/lib/vedeu/borders/all.rb +3 -3
  21. data/lib/vedeu/borders/border.rb +2 -2
  22. data/lib/vedeu/borders/dsl.rb +21 -27
  23. data/lib/vedeu/borders/null.rb +2 -15
  24. data/lib/vedeu/borders/render.rb +1 -1
  25. data/lib/vedeu/borders/repository.rb +9 -0
  26. data/lib/vedeu/buffers/buffer.rb +2 -2
  27. data/lib/vedeu/buffers/null.rb +1 -31
  28. data/lib/vedeu/buffers/refresh.rb +8 -8
  29. data/lib/vedeu/buffers/repository.rb +9 -0
  30. data/lib/vedeu/colours/backgrounds.rb +9 -0
  31. data/lib/vedeu/colours/colour.rb +1 -1
  32. data/lib/vedeu/colours/foregrounds.rb +9 -0
  33. data/lib/vedeu/common.rb +22 -13
  34. data/lib/vedeu/configuration/configuration.rb +6 -0
  35. data/lib/vedeu/cursors/cursor.rb +13 -8
  36. data/lib/vedeu/cursors/refresh.rb +2 -2
  37. data/lib/vedeu/cursors/repository.rb +18 -1
  38. data/lib/vedeu/distributed/server.rb +23 -0
  39. data/lib/vedeu/distributed/templates/default_borders.vedeu +1 -1
  40. data/lib/vedeu/distributed/templates/default_geometries.vedeu +1 -1
  41. data/lib/vedeu/distributed/templates/default_interfaces.vedeu +1 -1
  42. data/lib/vedeu/distributed/templates/default_keymaps.vedeu +1 -1
  43. data/lib/vedeu/distributed/templates/default_menus.vedeu +1 -1
  44. data/lib/vedeu/distributed/templates/default_views.vedeu +1 -1
  45. data/lib/vedeu/dsl/composition.rb +7 -17
  46. data/lib/vedeu/dsl/dsl.rb +12 -0
  47. data/lib/vedeu/dsl/interface.rb +32 -33
  48. data/lib/vedeu/dsl/keymap.rb +13 -19
  49. data/lib/vedeu/dsl/line.rb +3 -13
  50. data/lib/vedeu/dsl/shared.rb +5 -5
  51. data/lib/vedeu/dsl/stream.rb +0 -10
  52. data/lib/vedeu/dsl/use.rb +6 -6
  53. data/lib/vedeu/dsl/view.rb +17 -19
  54. data/lib/vedeu/editor/cursor.rb +32 -10
  55. data/lib/vedeu/editor/document.rb +33 -35
  56. data/lib/vedeu/editor/editor.rb +3 -4
  57. data/lib/vedeu/editor/insert.rb +1 -1
  58. data/lib/vedeu/editor/line.rb +1 -8
  59. data/lib/vedeu/editor/lines.rb +1 -1
  60. data/lib/vedeu/editor/repository.rb +9 -0
  61. data/lib/vedeu/esc/esc.rb +2 -1
  62. data/lib/vedeu/events/aliases.rb +8 -1
  63. data/lib/vedeu/events/event.rb +8 -0
  64. data/lib/vedeu/events/repository.rb +9 -0
  65. data/lib/vedeu/events/trigger.rb +9 -5
  66. data/lib/vedeu/geometry/coordinate.rb +2 -2
  67. data/lib/vedeu/geometry/dsl.rb +32 -38
  68. data/lib/vedeu/geometry/generic_coordinate.rb +1 -1
  69. data/lib/vedeu/geometry/geometry.rb +3 -3
  70. data/lib/vedeu/geometry/null.rb +2 -24
  71. data/lib/vedeu/geometry/repository.rb +9 -0
  72. data/lib/vedeu/groups/clear.rb +7 -3
  73. data/lib/vedeu/groups/dsl.rb +29 -35
  74. data/lib/vedeu/groups/group.rb +28 -4
  75. data/lib/vedeu/groups/refresh.rb +3 -2
  76. data/lib/vedeu/groups/repository.rb +9 -0
  77. data/lib/vedeu/input/capture.rb +1 -1
  78. data/lib/vedeu/input/keymap.rb +2 -1
  79. data/lib/vedeu/input/keymaps.rb +9 -0
  80. data/lib/vedeu/input/mapper.rb +4 -0
  81. data/lib/vedeu/input/translator.rb +1 -1
  82. data/lib/vedeu/logging/debug.rb +13 -0
  83. data/lib/vedeu/logging/log.rb +8 -0
  84. data/lib/vedeu/logging/timer.rb +13 -0
  85. data/lib/vedeu/menus/dsl.rb +8 -18
  86. data/lib/vedeu/menus/menu.rb +8 -4
  87. data/lib/vedeu/menus/null.rb +1 -1
  88. data/lib/vedeu/menus/repository.rb +9 -0
  89. data/lib/vedeu/models/cell.rb +5 -0
  90. data/lib/vedeu/models/escape.rb +5 -0
  91. data/lib/vedeu/models/focus.rb +20 -5
  92. data/lib/vedeu/models/interface.rb +10 -1
  93. data/lib/vedeu/models/interfaces.rb +9 -0
  94. data/lib/vedeu/models/toggleable.rb +19 -4
  95. data/lib/vedeu/models/views/char.rb +6 -1
  96. data/lib/vedeu/models/views/html_char.rb +1 -4
  97. data/lib/vedeu/models/views/line.rb +1 -1
  98. data/lib/vedeu/models/views/view.rb +1 -1
  99. data/lib/vedeu/null/generic.rb +14 -2
  100. data/lib/vedeu/null/interface.rb +1 -1
  101. data/lib/vedeu/null/view.rb +1 -1
  102. data/lib/vedeu/output/clear/interface.rb +5 -1
  103. data/lib/vedeu/output/compressor.rb +8 -4
  104. data/lib/vedeu/output/direct.rb +4 -4
  105. data/lib/vedeu/output/presentation/all.rb +15 -0
  106. data/lib/vedeu/output/presentation/presentation.rb +0 -7
  107. data/lib/vedeu/output/refresh/refresh.rb +1 -3
  108. data/lib/vedeu/output/renderers/all.rb +10 -0
  109. data/lib/vedeu/output/renderers/terminal.rb +1 -3
  110. data/lib/vedeu/repositories/collection.rb +3 -3
  111. data/lib/vedeu/repositories/model.rb +1 -1
  112. data/lib/vedeu/repositories/repository.rb +8 -8
  113. data/lib/vedeu/repositories/store.rb +3 -2
  114. data/lib/vedeu/runtime/application.rb +4 -0
  115. data/lib/vedeu/runtime/bootstrap.rb +1 -1
  116. data/lib/vedeu/runtime/flags.rb +7 -0
  117. data/lib/vedeu/runtime/main_loop.rb +2 -0
  118. data/lib/vedeu/runtime/router.rb +4 -0
  119. data/lib/vedeu/templating/decoder.rb +1 -1
  120. data/lib/vedeu/templating/encoder.rb +1 -1
  121. data/lib/vedeu/templating/helpers.rb +2 -0
  122. data/lib/vedeu/templating/template.rb +1 -1
  123. data/lib/vedeu/terminal/buffer.rb +7 -0
  124. data/lib/vedeu/terminal/terminal.rb +8 -0
  125. data/lib/vedeu/version.rb +1 -1
  126. data/test/lib/vedeu/borders/dsl_test.rb +0 -6
  127. data/test/lib/vedeu/borders/null_test.rb +0 -12
  128. data/test/lib/vedeu/buffers/null_test.rb +0 -37
  129. data/test/lib/vedeu/common_test.rb +33 -0
  130. data/test/lib/vedeu/cursors/cursor_test.rb +1 -1
  131. data/test/lib/vedeu/dsl/composition_test.rb +0 -6
  132. data/test/lib/vedeu/dsl/dsl_test.rb +1 -0
  133. data/test/lib/vedeu/dsl/interface_test.rb +0 -6
  134. data/test/lib/vedeu/dsl/keymap_test.rb +0 -5
  135. data/test/lib/vedeu/dsl/line_test.rb +0 -7
  136. data/test/lib/vedeu/dsl/stream_test.rb +0 -7
  137. data/test/lib/vedeu/editor/cursor_test.rb +23 -8
  138. data/test/lib/vedeu/editor/document_test.rb +27 -23
  139. data/test/lib/vedeu/editor/line_test.rb +0 -30
  140. data/test/lib/vedeu/geometry/dsl_test.rb +0 -5
  141. data/test/lib/vedeu/geometry/null_test.rb +0 -30
  142. data/test/lib/vedeu/groups/dsl_test.rb +0 -6
  143. data/test/lib/vedeu/groups/group_test.rb +15 -7
  144. data/test/lib/vedeu/menus/dsl_test.rb +0 -5
  145. data/test/lib/vedeu/models/cell_test.rb +4 -0
  146. data/test/lib/vedeu/models/escape_test.rb +4 -0
  147. data/test/lib/vedeu/models/views/char_test.rb +4 -0
  148. data/test/lib/vedeu/null/generic_test.rb +13 -0
  149. data/test/lib/vedeu/terminal/buffer_test.rb +3 -2
  150. data/test/lib/vedeu_test.rb +81 -3
  151. data/test/support/examples/borders_app.rb +1 -3
  152. data/test/support/examples/drb_app.rb +1 -3
  153. data/test/support/examples/editor_app.rb +2 -4
  154. data/test/support/examples/focus_app.rb +1 -3
  155. data/test/support/examples/hello_world.rb +1 -6
  156. data/test/support/examples/material_colours_app.rb +1 -3
  157. data/test/support/examples/view_templates_app/view_templates_app.rb +1 -3
  158. data/test/support/helpers/model_test_class.rb +1 -5
  159. data/test/support/who.rb +29 -0
  160. data/test/test_helper.rb +0 -1
  161. metadata +5 -17
  162. data/lib/vedeu/api/all.rb +0 -15
  163. data/lib/vedeu/api/external.rb +0 -194
  164. data/lib/vedeu/api/internal.rb +0 -177
  165. data/test/lib/vedeu/api/external_test.rb +0 -74
  166. data/test/lib/vedeu/api/internal_test.rb +0 -33
  167. data/test/support/examples/typed_commands/command.erb +0 -1
  168. data/test/support/examples/typed_commands/output.erb +0 -1
  169. data/test/support/examples/typed_commands/status.erb +0 -1
  170. data/test/support/examples/typed_commands/typed_commands_app.rb +0 -94
@@ -17,7 +17,7 @@ module Vedeu
17
17
  # assumed to be global, meaning its action will happen
18
18
  # regardless of the interface in focus.
19
19
  #
20
- # Vedeu.keymap 'some_interface' do
20
+ # Vedeu.keymap :my_interface do
21
21
  # key('s') { Vedeu.trigger(:save) }
22
22
  # key('h', :left) { Vedeu.trigger(:left) }
23
23
  # key('j', :down) { Vedeu.trigger(:down) }
@@ -29,13 +29,13 @@ module Vedeu
29
29
  #
30
30
  # # or...
31
31
  #
32
- # Vedeu.keys 'some_interface' do
32
+ # Vedeu.keys :my_interface do
33
33
  # # ... some code
34
34
  # end
35
35
  #
36
36
  # # or...
37
37
  #
38
- # Vedeu.interface 'some_interface' do
38
+ # Vedeu.interface :my_interface do
39
39
  # keymap do
40
40
  # # ... some code
41
41
  # end # or...
@@ -45,8 +45,8 @@ module Vedeu
45
45
  # end
46
46
  # end
47
47
  #
48
- # @param name [String] The name of the interface which this
49
- # keymap relates to.
48
+ # @param name [String|Symbol] The name of the interface which
49
+ # this keymap relates to.
50
50
  # @param block [Proc]
51
51
  # @raise [Vedeu::Error::RequiresBlock]
52
52
  # @return [Vedeu::Input::Keymap]
@@ -58,16 +58,6 @@ module Vedeu
58
58
  Vedeu::Input::Keymap.build(name: name, &block).store
59
59
  end
60
60
 
61
- # Returns an instance of DSL::Keymap.
62
- #
63
- # @param model [Vedeu::Input::Keymap]
64
- # @param client [Object]
65
- # @return [Vedeu::DSL::Keymap]
66
- def initialize(model, client = nil)
67
- @model = model
68
- @client = client
69
- end
70
-
71
61
  # Define keypress(es) to perform an action.
72
62
  #
73
63
  # @param values [Array<String>|Array<Symbol>|String|Symbol]
@@ -104,16 +94,16 @@ module Vedeu
104
94
  # To only allow certain keys to work with specific interfaces,
105
95
  # use the same name as the interface.
106
96
  #
107
- # When the name '_global_' is used, all keys in the keymap block
97
+ # When the name :_global_ is used, all keys in the keymap block
108
98
  # will be available to all interfaces. Once a key has been
109
- # defined in the '_global_' keymap, it cannot be used for a
99
+ # defined in the :_global_ keymap, it cannot be used for a
110
100
  # specific interface.
111
101
  #
112
102
  # Vedeu.keymap do
113
- # name 'some_interface'
103
+ # name :some_interface
114
104
  # end
115
105
  #
116
- # @param value [String]
106
+ # @param value [String|Symbol]
117
107
  # @return [String]
118
108
  def name(value)
119
109
  model.name = value
@@ -124,4 +114,8 @@ module Vedeu
124
114
 
125
115
  end # DSL
126
116
 
117
+ # @!method keymap
118
+ # @see Vedeu::DSL::Keymap.keymap
119
+ def_delegators Vedeu::DSL::Keymap, :keymap
120
+
127
121
  end # Vedeu
@@ -5,7 +5,7 @@ module Vedeu
5
5
  # Provides methods to be used to define views.
6
6
  #
7
7
  # Vedeu.renders do
8
- # view 'my_interface' do
8
+ # view :my_interface do
9
9
  # lines do
10
10
  # background '#000000'
11
11
  # foreground '#ffffff'
@@ -36,20 +36,10 @@ module Vedeu
36
36
  include Vedeu::DSL::Presentation
37
37
  include Vedeu::DSL::Text
38
38
 
39
- # Returns an instance of DSL::Line.
40
- #
41
- # @param model [Vedeu::Views::Line]
42
- # @param client [Object]
43
- # @return [Vedeu::DSL::Line]
44
- def initialize(model, client = nil)
45
- @model = model
46
- @client = client
47
- end
48
-
49
39
  # Specify a single line in a view.
50
40
  #
51
41
  # Vedeu.renders do
52
- # view 'my_interface' do
42
+ # view :my_interface do
53
43
  # line 'some text...'
54
44
  # # ... some code
55
45
  #
@@ -85,7 +75,7 @@ module Vedeu
85
75
  # required block.
86
76
  #
87
77
  # Vedeu.renders do
88
- # view 'my_interface' do
78
+ # view :my_interface do
89
79
  # line do
90
80
  # streams do
91
81
  # # ... some code
@@ -10,14 +10,14 @@ module Vedeu
10
10
  # Allows the setting of a border for the interface.
11
11
  #
12
12
  # @example
13
- # Vedeu.interface 'my_interface' do
13
+ # Vedeu.interface :my_interface do
14
14
  # border do
15
15
  # # ... see Vedeu::Borders::DSL for DSL methods for
16
16
  # # borders.
17
17
  # end
18
18
  # end
19
19
  #
20
- # @param name [String] The name of the interface; this is
20
+ # @param name [String|Symbol] The name of the interface; this is
21
21
  # already provided when we define the interface or view,
22
22
  # setting it here is just mirroring functionality of
23
23
  # {Vedeu::Borders::DSL.border}.
@@ -39,7 +39,7 @@ module Vedeu
39
39
  # Applies the default border to the interface.
40
40
  #
41
41
  # @example
42
- # Vedeu.interface 'my_interface' do
42
+ # Vedeu.interface :my_interface do
43
43
  # border!
44
44
  #
45
45
  # # ... some code
@@ -55,14 +55,14 @@ module Vedeu
55
55
  # Define the geometry for an interface.
56
56
  #
57
57
  # @example
58
- # Vedeu.interface 'my_interface' do
58
+ # Vedeu.interface :my_interface do
59
59
  # geometry do
60
60
  # # ... see Vedeu::Geometry::DSL for DSL methods for
61
61
  # # geometries.
62
62
  # end
63
63
  # end
64
64
  #
65
- # @param name [String] The name of the interface; this is
65
+ # @param name [String|Symbol] The name of the interface; this is
66
66
  # already provided when we define the interface or view,
67
67
  # setting it here is just mirroring functionality of
68
68
  # {Vedeu::Geometry::DSL.geometry}.
@@ -10,16 +10,6 @@ module Vedeu
10
10
  include Vedeu::DSL::Presentation
11
11
  include Vedeu::DSL::Text
12
12
 
13
- # Returns an instance of Vedeu::DSL::Stream.
14
- #
15
- # @param model [Vedeu::Views::Stream]
16
- # @param client [Object]
17
- # @return [Vedeu::DSL::Stream]
18
- def initialize(model, client = nil)
19
- @model = model
20
- @client = client
21
- end
22
-
23
13
  # @param block [Proc]
24
14
  # @raise [Vedeu::Error::RequiresBlock]
25
15
  # @return [void]
data/lib/vedeu/dsl/use.rb CHANGED
@@ -14,10 +14,10 @@ module Vedeu
14
14
  # Border, Geometry and Interface.
15
15
  #
16
16
  # @example
17
- # # Here the character used for 'my_border' is used in
18
- # # 'my_other_border'.
19
- # Vedeu.border 'my_other_border' do
20
- # top_right use('my_border').top_right
17
+ # # Here the character used for :my_border is used in
18
+ # # :my_other_border.
19
+ # Vedeu.border :my_other_border do
20
+ # top_right use(:my_border).top_right
21
21
  # end
22
22
  #
23
23
  # @note
@@ -27,8 +27,8 @@ module Vedeu
27
27
  # exception may be raised, or the request for an attribute
28
28
  # may raise a NoMethodError exception.
29
29
  #
30
- # @param name [String] The name of the model with the value you
31
- # wish to use.
30
+ # @param name [String|Symbol] The name of the model with the
31
+ # value you wish to use.
32
32
  # @raise
33
33
  # [Vedeu::Error::ModelNotFound|Vedeu::Error::NoMethodError]
34
34
  # The model or attribute cannot be found.
@@ -15,7 +15,7 @@ module Vedeu
15
15
  # you use these examples, ensure your terminal is at least 70
16
16
  # characters in width and 5 lines in height.)
17
17
  #
18
- # Vedeu.interface 'main' do
18
+ # Vedeu.interface :main do
19
19
  # geometry do
20
20
  # centred!
21
21
  # height 4
@@ -23,7 +23,7 @@ module Vedeu
23
23
  # end
24
24
  # end
25
25
  #
26
- # Vedeu.interface 'title' do
26
+ # Vedeu.interface :title do
27
27
  # geometry do
28
28
  # height 1
29
29
  # width 50
@@ -100,7 +100,7 @@ module Vedeu
100
100
  # triggered when needed.
101
101
  #
102
102
  # Vedeu.renders do
103
- # view 'some_interface' do
103
+ # view :some_interface do
104
104
  # line do
105
105
  # stream do
106
106
  # left 'Title goes here', width: 35
@@ -110,7 +110,7 @@ module Vedeu
110
110
  # end
111
111
  # end
112
112
  # end
113
- # view 'other_interface' do
113
+ # view :other_interface do
114
114
  # lines do
115
115
  # line 'This is content for the main interface.'
116
116
  # line ''
@@ -123,7 +123,7 @@ module Vedeu
123
123
  # # or...
124
124
  #
125
125
  # Vedeu.render do
126
- # view 'my_interface' do
126
+ # view :my_interface do
127
127
  # # ... some code
128
128
  # end
129
129
  # end
@@ -153,7 +153,7 @@ module Vedeu
153
153
  # here will be rendered to {Vedeu::Terminal#output}.
154
154
  #
155
155
  # Vedeu.views do
156
- # view 'some_interface' do
156
+ # view :some_interface do
157
157
  # line do
158
158
  # stream do
159
159
  # left 'Title goes here', width: 35
@@ -163,7 +163,7 @@ module Vedeu
163
163
  # end
164
164
  # end
165
165
  # end
166
- # view 'other_interface' do
166
+ # view :other_interface do
167
167
  # lines do
168
168
  # line 'This is content for the main interface.'
169
169
  # line ''
@@ -220,28 +220,18 @@ module Vedeu
220
220
 
221
221
  end # Eigenclass
222
222
 
223
- # Returns an instance of Vedeu::DSL::View.
224
- #
225
- # @param model [Vedeu::DSL::View]
226
- # @param client [Object]
227
- # @return [Vedeu::DSL::View]
228
- def initialize(model, client = nil)
229
- @model = model
230
- @client = client
231
- end
232
-
233
223
  # Specify multiple lines in a view.
234
224
  #
235
225
  # @param block [Proc]
236
226
  #
237
227
  # @example
238
- # Vedeu.view 'my_interface' do
228
+ # Vedeu.view :my_interface do
239
229
  # lines do
240
230
  # # ... see {Vedeu::DSL::Line} and {Vedeu::DSL::Stream}
241
231
  # end
242
232
  # end
243
233
  #
244
- # Vedeu.view 'my_interface' do
234
+ # Vedeu.view :my_interface do
245
235
  # line do
246
236
  # # ... see {Vedeu::DSL::Line} and {Vedeu::DSL::Stream}
247
237
  # end
@@ -260,4 +250,12 @@ module Vedeu
260
250
 
261
251
  end # DSL
262
252
 
253
+ # @!method render
254
+ # @see Vedeu::DSL::View.render
255
+ # @!method renders
256
+ # @see Vedeu::DSL::View.renders
257
+ # @!method views
258
+ # @see Vedeu::DSL::View.views
259
+ def_delegators Vedeu::DSL::View, :renders, :render, :views
260
+
263
261
  end # Vedeu
@@ -23,6 +23,10 @@ module Vedeu
23
23
  # @return [Fixnum]
24
24
  attr_accessor :byn
25
25
 
26
+ # @!attribute [r] name
27
+ # @return [String|Symbol]
28
+ attr_reader :name
29
+
26
30
  # @!attribute [rw] ox
27
31
  # @return [Fixnum]
28
32
  attr_accessor :ox
@@ -49,6 +53,7 @@ module Vedeu
49
53
  # @option attributes bx [Fixnum]
50
54
  # @option attributes byn [Fixnum]
51
55
  # @option attributes bxn [Fixnum]
56
+ # @option attributes name [String|Symbol]
52
57
  # @option attributes oy [Fixnum]
53
58
  # @option attributes ox [Fixnum]
54
59
  # @return [Vedeu::Editor::Cursor]
@@ -87,6 +92,22 @@ module Vedeu
87
92
  self
88
93
  end
89
94
 
95
+ # Overwrite the cursor of the same name. This ensure that on
96
+ # refresh the cursor stays in the correct position for the
97
+ # document being edited.
98
+ #
99
+ # @return [Vedeu::Editor::Cursor]
100
+ def store
101
+ Vedeu::Cursors::Cursor.store(name: name,
102
+ x: real_x,
103
+ y: real_y,
104
+ ox: 0,
105
+ oy: 0,
106
+ visible: true)
107
+
108
+ self
109
+ end
110
+
90
111
  # Move the virtual cursor to the origin (0, 0).
91
112
  #
92
113
  # @return [Vedeu::Editor::Cursor]
@@ -108,8 +129,8 @@ module Vedeu
108
129
  self
109
130
  end
110
131
 
111
- # Return the escape sequence for setting the cursor position and
112
- # show the cursor.
132
+ # Return the escape sequence as a string for setting the cursor
133
+ # position and show the cursor.
113
134
  #
114
135
  # @return [String]
115
136
  def to_s
@@ -149,14 +170,15 @@ module Vedeu
149
170
  # @return [Hash<Symbol => Fixnum|NilClass>]
150
171
  def defaults
151
172
  {
152
- y: 0,
153
- x: 0,
154
- by: nil,
155
- bx: nil,
156
- byn: nil,
157
- bxn: nil,
158
- ox: 0,
159
- oy: 0,
173
+ y: 0,
174
+ x: 0,
175
+ by: nil,
176
+ bx: nil,
177
+ byn: nil,
178
+ bxn: nil,
179
+ name: '',
180
+ ox: 0,
181
+ oy: 0,
160
182
  }
161
183
  end
162
184
 
@@ -24,6 +24,10 @@ module Vedeu
24
24
  :x,
25
25
  :y
26
26
 
27
+ def_delegators :interface,
28
+ :colour,
29
+ :style
30
+
27
31
  # @!attribute [r] attributes
28
32
  # @return [Hash]
29
33
  attr_reader :attributes
@@ -33,14 +37,14 @@ module Vedeu
33
37
  attr_accessor :data
34
38
 
35
39
  # @!attribute [rw] name
36
- # @return [String]
40
+ # @return [String|Symbol]
37
41
  attr_accessor :name
38
42
 
39
43
  # Returns a new instance of Vedeu::Editor::Document.
40
44
  #
41
45
  # @param attributes [Hash]
42
46
  # @option attributes data [String]
43
- # @option attributes name [String]
47
+ # @option attributes name [String|Symbol]
44
48
  # @option attributes repository
45
49
  # [Vedeu::Repositories::Repository]
46
50
  # @return [Vedeu::Editor::Document]
@@ -54,7 +58,7 @@ module Vedeu
54
58
  #
55
59
  # @return [void]
56
60
  def clear
57
- Vedeu::Output::Direct.write(value: clear_output, x: bx, y: by)
61
+ Vedeu.trigger(:_clear_view_, name)
58
62
  end
59
63
 
60
64
  # Deletes the character from the line where the cursor is
@@ -76,8 +80,6 @@ module Vedeu
76
80
  @lines = lines.delete_line(y)
77
81
 
78
82
  up
79
-
80
- refresh
81
83
  end
82
84
 
83
85
  # Move the virtual cursor down.
@@ -116,8 +118,6 @@ module Vedeu
116
118
  @lines = lines.insert_character(character, y, x)
117
119
 
118
120
  right
119
-
120
- refresh
121
121
  end
122
122
 
123
123
  # Insert an empty line.
@@ -163,7 +163,7 @@ module Vedeu
163
163
  def render
164
164
  clear
165
165
 
166
- Vedeu::Output::Direct.write(value: output, x: bx, y: by)
166
+ Vedeu::Output::Output.render(output)
167
167
  end
168
168
 
169
169
  # Reset the document to the empty state.
@@ -217,24 +217,14 @@ module Vedeu
217
217
  @border ||= Vedeu.borders.by_name(name)
218
218
  end
219
219
 
220
- # Return the data needed to clear the area which the document is
221
- # using.
222
- #
223
- # @return [String]
224
- def clear_output
225
- clear_output = ''
226
-
227
- (by..byn).each do |row|
228
- clear_output << "\e[#{row};#{bx}H" + (' ' * width)
229
- end
230
-
231
- # reset cursor to top left of document
232
- clear_output << "\e[#{by};#{bx}H"
220
+ # @return [Vedeu::Models::Interface]
221
+ def interface
222
+ @interface ||= Vedeu.interfaces.by_name(name)
233
223
  end
234
224
 
235
225
  # Returns the default options/attributes for this class.
236
226
  #
237
- # @return [Hash]
227
+ # @return [Hash<Symbol => void|Symbol]
238
228
  def defaults
239
229
  {
240
230
  data: Vedeu::Editor::Lines.new([Vedeu::Editor::Line.new]),
@@ -247,16 +237,23 @@ module Vedeu
247
237
  #
248
238
  # @return [String]
249
239
  def output
250
- output = ''
240
+ out = []
241
+
242
+ visible_lines.each_with_index do |line, y_index|
243
+ line.chars.each_with_index do |char, x_index|
244
+ position = [(by + y_index), (bx + x_index)]
251
245
 
252
- visible.each_with_index do |line, y_index|
253
- output << Vedeu::Geometry::Position.new((by + y_index), bx).to_s
254
- output << line.to_s
246
+ out << Vedeu::Views::Char.new(value: char,
247
+ parent: interface,
248
+ position: position)
249
+ end
255
250
  end
256
251
 
257
- output << cursor.to_s
252
+ out << border.render
253
+
254
+ cursor.store
258
255
 
259
- output
256
+ out.flatten
260
257
  end
261
258
 
262
259
  # Return a virtual cursor to track the cursor position within
@@ -264,19 +261,20 @@ module Vedeu
264
261
  #
265
262
  # @return [Vedeu::Editor::Cursor]
266
263
  def cursor
267
- @cursor ||= Vedeu::Editor::Cursor.new(y: 0,
268
- x: 0,
269
- by: by,
270
- bx: bx,
271
- byn: byn,
272
- bxn: bxn)
264
+ @cursor ||= Vedeu::Editor::Cursor.new(y: 0,
265
+ x: 0,
266
+ by: by,
267
+ bx: bx,
268
+ byn: byn,
269
+ bxn: bxn,
270
+ name: name)
273
271
  end
274
272
 
275
273
  # Return only the visible lines for the document based on the
276
274
  # current virtual cursor position.
277
275
  #
278
276
  # @return [Vedeu::Editor::Lines]
279
- def visible
277
+ def visible_lines
280
278
  Vedeu::Editor::Cropper.new(lines: lines,
281
279
  height: height,
282
280
  width: width,