vedeu 0.6.71 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/docs/api.md +1 -1
  3. data/lib/vedeu/all.rb +1 -0
  4. data/lib/vedeu/borders/border.rb +66 -55
  5. data/lib/vedeu/borders/caption.rb +10 -20
  6. data/lib/vedeu/borders/dsl.rb +57 -13
  7. data/lib/vedeu/borders/refresh.rb +123 -64
  8. data/lib/vedeu/borders/set_attribute.rb +1 -3
  9. data/lib/vedeu/borders/title.rb +68 -25
  10. data/lib/vedeu/cells/all.rb +23 -0
  11. data/lib/vedeu/cells/border.rb +72 -0
  12. data/lib/vedeu/cells/borders/all.rb +18 -0
  13. data/lib/vedeu/cells/borders/bottom_horizontal.rb +28 -0
  14. data/lib/vedeu/cells/borders/bottom_left.rb +34 -0
  15. data/lib/vedeu/cells/borders/bottom_right.rb +34 -0
  16. data/lib/vedeu/cells/borders/horizontal.rb +28 -0
  17. data/lib/vedeu/cells/borders/left_vertical.rb +28 -0
  18. data/lib/vedeu/cells/borders/right_vertical.rb +28 -0
  19. data/lib/vedeu/cells/borders/top_horizontal.rb +28 -0
  20. data/lib/vedeu/cells/borders/top_left.rb +34 -0
  21. data/lib/vedeu/cells/borders/top_right.rb +34 -0
  22. data/lib/vedeu/cells/borders/vertical.rb +28 -0
  23. data/lib/vedeu/cells/char.rb +24 -0
  24. data/lib/vedeu/cells/clear.rb +29 -0
  25. data/lib/vedeu/cells/empty.rb +78 -0
  26. data/lib/vedeu/cells/escape.rb +24 -0
  27. data/lib/vedeu/cells/html.rb +19 -0
  28. data/lib/vedeu/cells/json.rb +19 -0
  29. data/lib/vedeu/colours/colour.rb +6 -6
  30. data/lib/vedeu/common.rb +9 -0
  31. data/lib/vedeu/cursors/move.rb +2 -3
  32. data/lib/vedeu/editor/insert.rb +1 -1
  33. data/lib/vedeu/editor/item.rb +2 -3
  34. data/lib/vedeu/input/mouse.rb +1 -1
  35. data/lib/vedeu/interfaces/clear.rb +3 -4
  36. data/lib/vedeu/output/compressor.rb +1 -0
  37. data/lib/vedeu/presentation/colour.rb +3 -0
  38. data/lib/vedeu/repositories/defaults.rb +10 -1
  39. data/lib/vedeu/templating/decoder.rb +1 -1
  40. data/lib/vedeu/templating/encoder.rb +1 -1
  41. data/lib/vedeu/templating/template.rb +2 -2
  42. data/lib/vedeu/templating/view_template.rb +1 -1
  43. data/lib/vedeu/terminal/terminal.rb +9 -0
  44. data/lib/vedeu/version.rb +1 -1
  45. data/lib/vedeu/views/html_char.rb +1 -1
  46. data/test/lib/vedeu/application/application_controller_test.rb +2 -2
  47. data/test/lib/vedeu/application/controller_test.rb +4 -4
  48. data/test/lib/vedeu/borders/border_test.rb +10 -2
  49. data/test/lib/vedeu/borders/caption_test.rb +29 -13
  50. data/test/lib/vedeu/borders/dsl_test.rb +44 -25
  51. data/test/lib/vedeu/borders/refresh_test.rb +2 -2
  52. data/test/lib/vedeu/borders/title_test.rb +17 -15
  53. data/test/lib/vedeu/buffers/buffer_test.rb +8 -8
  54. data/test/lib/vedeu/buffers/refresh_test.rb +10 -10
  55. data/test/lib/vedeu/buffers/terminal_test.rb +6 -6
  56. data/test/lib/vedeu/cells/border_test.rb +72 -0
  57. data/test/lib/vedeu/cells/borders/bottom_horizontal_test.rb +22 -0
  58. data/test/lib/vedeu/cells/borders/bottom_left_test.rb +36 -0
  59. data/test/lib/vedeu/cells/borders/bottom_right_test.rb +36 -0
  60. data/test/lib/vedeu/cells/borders/horizontal_test.rb +22 -0
  61. data/test/lib/vedeu/cells/borders/left_vertical_test.rb +22 -0
  62. data/test/lib/vedeu/cells/borders/right_vertical_test.rb +22 -0
  63. data/test/lib/vedeu/cells/borders/top_horizontal_test.rb +22 -0
  64. data/test/lib/vedeu/cells/borders/top_left_test.rb +36 -0
  65. data/test/lib/vedeu/cells/borders/top_right_test.rb +36 -0
  66. data/test/lib/vedeu/cells/borders/vertical_test.rb +22 -0
  67. data/test/lib/vedeu/cells/char_test.rb +22 -0
  68. data/test/lib/vedeu/cells/clear_test.rb +34 -0
  69. data/test/lib/vedeu/cells/empty_test.rb +55 -0
  70. data/test/lib/vedeu/cells/escape_test.rb +13 -0
  71. data/test/lib/vedeu/cells/html_test.rb +13 -0
  72. data/test/lib/vedeu/cells/json_test.rb +13 -0
  73. data/test/lib/vedeu/colours/colour_test.rb +2 -6
  74. data/test/lib/vedeu/colours/translator_test.rb +4 -4
  75. data/test/lib/vedeu/common_test.rb +10 -0
  76. data/test/lib/vedeu/configuration/api_test.rb +24 -24
  77. data/test/lib/vedeu/cursors/cursor_test.rb +4 -4
  78. data/test/lib/vedeu/cursors/dsl_test.rb +16 -16
  79. data/test/lib/vedeu/cursors/reposition_test.rb +2 -2
  80. data/test/lib/vedeu/cursors/repository_test.rb +2 -2
  81. data/test/lib/vedeu/distributed/client_test.rb +2 -2
  82. data/test/lib/vedeu/distributed/server_test.rb +8 -8
  83. data/test/lib/vedeu/distributed/subprocess_test.rb +2 -2
  84. data/test/lib/vedeu/distributed/test_application_test.rb +2 -2
  85. data/test/lib/vedeu/dsl/line_test.rb +2 -2
  86. data/test/lib/vedeu/dsl/presentation_test.rb +4 -4
  87. data/test/lib/vedeu/editor/cursor_test.rb +2 -2
  88. data/test/lib/vedeu/editor/document_test.rb +4 -4
  89. data/test/lib/vedeu/editor/editor_test.rb +20 -20
  90. data/test/lib/vedeu/events/aliases_test.rb +2 -2
  91. data/test/lib/vedeu/events/repository_test.rb +2 -2
  92. data/test/lib/vedeu/geometries/area/area_test.rb +2 -2
  93. data/test/lib/vedeu/geometries/geometry_test.rb +2 -2
  94. data/test/lib/vedeu/geometries/move_test.rb +2 -2
  95. data/test/lib/vedeu/geometries/position_test.rb +2 -2
  96. data/test/lib/vedeu/groups/clear_test.rb +2 -2
  97. data/test/lib/vedeu/groups/group_test.rb +4 -4
  98. data/test/lib/vedeu/groups/refresh_test.rb +2 -2
  99. data/test/lib/vedeu/input/capture_test.rb +42 -40
  100. data/test/lib/vedeu/input/mouse_test.rb +13 -11
  101. data/test/lib/vedeu/input/read_test.rb +10 -10
  102. data/test/lib/vedeu/interfaces/clear_test.rb +15 -6
  103. data/test/lib/vedeu/interfaces/dsl_test.rb +14 -14
  104. data/test/lib/vedeu/interfaces/interface_test.rb +12 -9
  105. data/test/lib/vedeu/logging/debug_test.rb +2 -2
  106. data/test/lib/vedeu/logging/lockless_log_device_test.rb +2 -2
  107. data/test/lib/vedeu/logging/log_test.rb +4 -4
  108. data/test/lib/vedeu/logging/mono_logger_test.rb +8 -8
  109. data/test/lib/vedeu/logging/timer_test.rb +2 -2
  110. data/test/lib/vedeu/menus/menu_test.rb +4 -4
  111. data/test/lib/vedeu/models/cell_test.rb +2 -2
  112. data/test/lib/vedeu/models/focus_test.rb +6 -6
  113. data/test/lib/vedeu/models/toggleable_test.rb +10 -10
  114. data/test/lib/vedeu/null/generic_test.rb +2 -2
  115. data/test/lib/vedeu/output/output_test.rb +8 -8
  116. data/test/lib/vedeu/output/refresh_test.rb +2 -2
  117. data/test/lib/vedeu/output/viewport_test.rb +2 -2
  118. data/test/lib/vedeu/plugins/plugin_test.rb +4 -4
  119. data/test/lib/vedeu/presentation/background_test.rb +2 -2
  120. data/test/lib/vedeu/presentation/foreground_test.rb +2 -2
  121. data/test/lib/vedeu/presentation/style_test.rb +2 -2
  122. data/test/lib/vedeu/renderers/all_test.rb +2 -2
  123. data/test/lib/vedeu/renderers/file_test.rb +6 -6
  124. data/test/lib/vedeu/renderers/terminal_test.rb +2 -2
  125. data/test/lib/vedeu/repositories/collection_test.rb +2 -2
  126. data/test/lib/vedeu/repositories/defaults_test.rb +35 -0
  127. data/test/lib/vedeu/repositories/registerable_test.rb +2 -2
  128. data/test/lib/vedeu/runtime/bootstrap_test.rb +2 -2
  129. data/test/lib/vedeu/runtime/flags_test.rb +2 -2
  130. data/test/lib/vedeu/runtime/launcher_test.rb +4 -4
  131. data/test/lib/vedeu/runtime/main_loop_test.rb +2 -2
  132. data/test/lib/vedeu/runtime/router_test.rb +12 -12
  133. data/test/lib/vedeu/terminal/mode_test.rb +4 -4
  134. data/test/lib/vedeu/terminal/terminal_test.rb +19 -9
  135. data/test/lib/vedeu/views/char_test.rb +2 -2
  136. data/test/lib/vedeu/views/composition_test.rb +2 -2
  137. data/test/lib/vedeu/views/line_test.rb +2 -2
  138. data/test/lib/vedeu/views/stream_test.rb +2 -2
  139. data/test/lib/vedeu/views/view_test.rb +4 -4
  140. data/vedeu.gemspec +1 -1
  141. metadata +57 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6f85cb55a50d53c490a1a1f8f0bb3adbf38035d
4
- data.tar.gz: 98154c75cbe858bb6ec6810f8a9887ebca55ffbb
3
+ metadata.gz: 3bb700b808027ae0199e3f275aa59204c356e2c4
4
+ data.tar.gz: 269a2f124899846454acefe97fe50a95dc28ef8d
5
5
  SHA512:
6
- metadata.gz: 23e2508ccb6cac4af70ef49caa6cd8be4c13cb71233f3b121a78979fbda7956a4e0efa79c7b518558bb3054d11a6cb9c69b6bfe263afa4bdd1a9ed9941b9e5ce
7
- data.tar.gz: ee5c80b253f55995582811f1f579ce8c2a408be5adb5ec699d1ddd87ae36f3a13dce1c4a4616a3831a1336758b0cf69555b8274fde96a2ca5d4ab6f0e36d4a3b
6
+ metadata.gz: 79c2059ccd86e0afdf0b4998bb4528ff5a9d0cdf9266583db8b8ae976f7a04c2079e3f362cf503f42e6193f32cbcd95a96edefe47ed9bb5f4fd051b76ad7bf8a
7
+ data.tar.gz: fc2a6a223a6e9a8b098d02b0c74f08d07d56a3ee0cef6870229ba87f1756d7075e393cd3eb8a409159afc3b8249ce64a1c298e997458000097a385cd033c40e1
data/docs/api.md CHANGED
@@ -175,7 +175,7 @@ Repository method. Access registered background colours.
175
175
 
176
176
  ### Vedeu.border
177
177
 
178
- @todo Add more documentation.
178
+ See {Vedeu::Borders::DSL.border}
179
179
 
180
180
  ### Vedeu.borders
181
181
 
data/lib/vedeu/all.rb CHANGED
@@ -16,6 +16,7 @@ require 'vedeu/renderers/all'
16
16
  require 'vedeu/esc/all'
17
17
  require 'vedeu/null/all'
18
18
  require 'vedeu/views/all'
19
+ require 'vedeu/cells/all'
19
20
  require 'vedeu/models/all'
20
21
  require 'vedeu/application/all'
21
22
  require 'vedeu/cursors/all'
@@ -21,16 +21,6 @@ module Vedeu
21
21
  include Vedeu::Repositories::Model
22
22
  include Vedeu::Presentation
23
23
 
24
- def_delegators :geometry,
25
- :bx,
26
- :bxn,
27
- :by,
28
- :byn,
29
- :x,
30
- :xn,
31
- :y,
32
- :yn
33
-
34
24
  # @!attribute [rw] bottom_left
35
25
  # @return [String] The character to be used for the bottom left
36
26
  # border if enabled.
@@ -41,6 +31,11 @@ module Vedeu
41
31
  # border if enabled.
42
32
  attr_accessor :bottom_right
43
33
 
34
+ # @!attribute [rw] bottom_horizontal
35
+ # @return [String] The character to be used for the bottom
36
+ # horizontal border if enabled.
37
+ attr_accessor :bottom_horizontal
38
+
44
39
  # @!attribute [rw] caption
45
40
  # @return [String] An optional caption for when the bottom
46
41
  # border is to be shown.
@@ -90,11 +85,26 @@ module Vedeu
90
85
  # border if enabled.
91
86
  attr_accessor :top_right
92
87
 
88
+ # @!attribute [rw] top_horizontal
89
+ # @return [String] The character to be used for the top
90
+ # horizontal border if enabled.
91
+ attr_accessor :top_horizontal
92
+
93
93
  # @!attribute [rw] vertical
94
94
  # @return [String] The character to be used for the vertical
95
95
  # side border.
96
96
  attr_accessor :vertical
97
97
 
98
+ # @!attribute [rw] left_vertical
99
+ # @return [String] The character to be used for the left
100
+ # vertical side border.
101
+ attr_accessor :left_vertical
102
+
103
+ # @!attribute [rw] right_vertical
104
+ # @return [String] The character to be used for the right
105
+ # vertical side border.
106
+ attr_accessor :right_vertical
107
+
98
108
  # @!attribute [r] name
99
109
  # @return [String|Symbol] Associates the border with the
100
110
  # same-named interface/view.
@@ -157,25 +167,29 @@ module Vedeu
157
167
  # Vedeu::Borders::Repository|Vedeu::Presentation::Style>]
158
168
  def attributes
159
169
  {
160
- bottom_left: @bottom_left,
161
- bottom_right: @bottom_right,
162
- caption: @caption,
163
- client: @client,
164
- colour: @colour,
165
- enabled: @enabled,
166
- horizontal: @horizontal,
167
- name: @name,
168
- parent: @parent,
169
- repository: @repository,
170
- show_bottom: @show_bottom,
171
- show_left: @show_left,
172
- show_right: @show_right,
173
- show_top: @show_top,
174
- style: @style,
175
- title: @title,
176
- top_left: @top_left,
177
- top_right: @top_right,
178
- vertical: @vertical,
170
+ bottom_horizontal: @bottom_horizontal,
171
+ bottom_left: @bottom_left,
172
+ bottom_right: @bottom_right,
173
+ caption: @caption,
174
+ client: @client,
175
+ colour: @colour,
176
+ enabled: @enabled,
177
+ horizontal: @horizontal,
178
+ left_vertical: @left_vertical,
179
+ name: @name,
180
+ parent: @parent,
181
+ repository: @repository,
182
+ right_vertical: @right_vertical,
183
+ show_bottom: @show_bottom,
184
+ show_left: @show_left,
185
+ show_right: @show_right,
186
+ show_top: @show_top,
187
+ style: @style,
188
+ title: @title,
189
+ top_horizontal: @top_horizontal,
190
+ top_left: @top_left,
191
+ top_right: @top_right,
192
+ vertical: @vertical,
179
193
  }
180
194
  end
181
195
 
@@ -193,13 +207,6 @@ module Vedeu
193
207
 
194
208
  private
195
209
 
196
- # Returns the geometry for the interface.
197
- #
198
- # @return (see Vedeu::Geometries::Repository#by_name)
199
- def geometry
200
- Vedeu.geometries.by_name(name)
201
- end
202
-
203
210
  # The default values for a new instance of this class.
204
211
  #
205
212
  # @return [Hash<Symbol => Boolean|Hash|NilClass|String|Symbol|
@@ -207,25 +214,29 @@ module Vedeu
207
214
  # @see Vedeu::EscapeSequences::Borders
208
215
  def defaults
209
216
  {
210
- bottom_left: Vedeu::EscapeSequences::Borders.bottom_left,
211
- bottom_right: Vedeu::EscapeSequences::Borders.bottom_right,
212
- caption: '',
213
- client: nil,
214
- colour: nil,
215
- enabled: false,
216
- horizontal: Vedeu::EscapeSequences::Borders.horizontal,
217
- name: '',
218
- parent: nil,
219
- repository: Vedeu.borders,
220
- show_bottom: true,
221
- show_left: true,
222
- show_right: true,
223
- show_top: true,
224
- style: nil,
225
- title: '',
226
- top_left: Vedeu::EscapeSequences::Borders.top_left,
227
- top_right: Vedeu::EscapeSequences::Borders.top_right,
228
- vertical: Vedeu::EscapeSequences::Borders.vertical,
217
+ bottom_horizontal: nil,
218
+ bottom_left: nil,
219
+ bottom_right: nil,
220
+ caption: '',
221
+ client: nil,
222
+ colour: nil,
223
+ enabled: false,
224
+ horizontal: Vedeu::EscapeSequences::Borders.horizontal,
225
+ left_vertical: nil,
226
+ name: '',
227
+ parent: nil,
228
+ repository: Vedeu.borders,
229
+ right_vertical: nil,
230
+ show_bottom: true,
231
+ show_left: true,
232
+ show_right: true,
233
+ show_top: true,
234
+ style: nil,
235
+ title: '',
236
+ top_horizontal: nil,
237
+ top_left: nil,
238
+ top_right: nil,
239
+ vertical: Vedeu::EscapeSequences::Borders.vertical,
229
240
  }
230
241
  end
231
242
 
@@ -6,33 +6,23 @@ module Vedeu
6
6
  # the caption is longer than the interface is wide, and pad with a
7
7
  # space either side.
8
8
  #
9
+ # The caption is displayed within the bottom border of the
10
+ # interface/view.
11
+ #
9
12
  # @api private
10
13
  #
11
- class Caption < Title
12
-
13
- # Overwrite the border from
14
- # {Vedeu::Borders::Border#build_horizontal} on the bottom border
15
- # to include the caption if given.
16
- #
17
- # @return [Array<Vedeu::Views::Char>]
18
- def render
19
- return chars if empty?
20
-
21
- caption_index = 0
22
- chars.each_with_index do |char, index|
23
- next if index <= start_index || index > (width - 2)
24
-
25
- char.border = nil
26
- char.value = characters[caption_index]
27
- caption_index += 1
28
- end
29
- end
14
+ class Caption < Vedeu::Borders::Title
30
15
 
31
16
  private
32
17
 
33
18
  # @return [Fixnum]
34
19
  def start_index
35
- (width - size) - 2
20
+ (width - size) - 1
21
+ end
22
+
23
+ # @return [Fixnum]
24
+ def y
25
+ @_y ||= geometry.yn
36
26
  end
37
27
 
38
28
  end # Caption
@@ -19,9 +19,12 @@ module Vedeu
19
19
  # @param name [String|Symbol] The name of the interface or view
20
20
  # to which this border belongs.
21
21
  # @param block [Proc]
22
- # @raise [Vedeu::Error::RequiresBlock]
22
+ # @raise [Vedeu::Error::MissingRequired|
23
+ # Vedeu::Error::RequiresBlock] When a name or block
24
+ # respectively are not given.
23
25
  # @return [Vedeu::Borders::Border]
24
26
  def self.border(name, &block)
27
+ fail Vedeu::Error::MissingRequired unless name
25
28
  fail Vedeu::Error::RequiresBlock unless block_given?
26
29
 
27
30
  Vedeu::Borders::Border.build(enabled: true, name: name, &block).store
@@ -37,9 +40,13 @@ module Vedeu
37
40
  #
38
41
  # @param char [String] Character to be used as the bottom left
39
42
  # border character.
43
+ # @param options [Hash<Symbol => Hash<Symbol => String>|String|
44
+ # Symbol]
45
+ # @option options colour [Hash<Symbol => String>]
46
+ # @option options style [String|Symbol]
40
47
  # @return [String]
41
- def bottom_left(char)
42
- model.bottom_left = char
48
+ def bottom_left(char, options = {})
49
+ model.bottom_left = Vedeu::Cells::BottomLeft.new(attrs(char, options))
43
50
  end
44
51
  alias_method :bottom_left=, :bottom_left
45
52
 
@@ -53,9 +60,13 @@ module Vedeu
53
60
  #
54
61
  # @param char [String] Character to be used as the bottom right
55
62
  # border character.
63
+ # @param options [Hash<Symbol => Hash<Symbol => String>|String|
64
+ # Symbol]
65
+ # @option options colour [Hash<Symbol => String>]
66
+ # @option options style [String|Symbol]
56
67
  # @return [String]
57
- def bottom_right(char)
58
- model.bottom_right = char
68
+ def bottom_right(char, options = {})
69
+ model.bottom_right = Vedeu::Cells::BottomRight.new(attrs(char, options))
59
70
  end
60
71
  alias_method :bottom_right=, :bottom_right
61
72
 
@@ -109,9 +120,13 @@ module Vedeu
109
120
  #
110
121
  # @param char [String] Character to be used as the horizontal
111
122
  # border character.
123
+ # @param options [Hash<Symbol => Hash<Symbol => String>|String|
124
+ # Symbol]
125
+ # @option options colour [Hash<Symbol => String>]
126
+ # @option options style [String|Symbol]
112
127
  # @return [String]
113
- def horizontal(char)
114
- model.horizontal = char
128
+ def horizontal(char, options = {})
129
+ model.horizontal = Vedeu::Cells::Horizontal.new(attrs(char, options))
115
130
  end
116
131
  alias_method :horizontal=, :horizontal
117
132
 
@@ -305,9 +320,13 @@ module Vedeu
305
320
  #
306
321
  # @param char [String] Character to be used as the top left
307
322
  # border character.
323
+ # @param options [Hash<Symbol => Hash<Symbol => String>|String|
324
+ # Symbol]
325
+ # @option options colour [Hash<Symbol => String>]
326
+ # @option options style [String|Symbol]
308
327
  # @return [String]
309
- def top_left(char)
310
- model.top_left = char
328
+ def top_left(char, options = {})
329
+ model.top_left = Vedeu::Cells::TopLeft.new(attrs(char, options))
311
330
  end
312
331
  alias_method :top_left=, :top_left
313
332
 
@@ -321,9 +340,13 @@ module Vedeu
321
340
  #
322
341
  # @param char [String] Character to be used as the top right
323
342
  # border character.
343
+ # @param options [Hash<Symbol => Hash<Symbol => String>|String|
344
+ # Symbol]
345
+ # @option options colour [Hash<Symbol => String>]
346
+ # @option options style [String|Symbol]
324
347
  # @return [String]
325
- def top_right(char)
326
- model.top_right = char
348
+ def top_right(char, options = {})
349
+ model.top_right = Vedeu::Cells::TopRight.new(attrs(char, options))
327
350
  end
328
351
  alias_method :top_right=, :top_right
329
352
 
@@ -337,12 +360,33 @@ module Vedeu
337
360
  #
338
361
  # @param char [String] Character to be used as the vertical
339
362
  # border character.
363
+ # @param options [Hash<Symbol => Hash<Symbol => String>|String|
364
+ # Symbol]
365
+ # @option options colour [Hash<Symbol => String>]
366
+ # @option options style [String|Symbol]
340
367
  # @return [String]
341
- def vertical(char)
342
- model.vertical = char
368
+ def vertical(char, options = {})
369
+ model.vertical = Vedeu::Cells::Vertical.new(attrs(char, options))
343
370
  end
344
371
  alias_method :vertical=, :vertical
345
372
 
373
+ private
374
+
375
+ # @return [Hash<Symbol => void>]
376
+ def attrs(value, options)
377
+ default_options.merge!(value: value).merge!(options)
378
+ end
379
+
380
+ # @return [Hash<Symbol => NilClass|String|Symbol>]
381
+ def default_options
382
+ {
383
+ colour: model.colour,
384
+ name: model.name,
385
+ style: model.style,
386
+ value: nil,
387
+ }
388
+ end
389
+
346
390
  end # Border
347
391
 
348
392
  end # DSL
@@ -15,6 +15,7 @@ module Vedeu
15
15
  :bottom?,
16
16
  :bottom_left,
17
17
  :bottom_right,
18
+ :bottom_horizontal,
18
19
  :caption,
19
20
  :colour,
20
21
  :enabled?,
@@ -26,7 +27,10 @@ module Vedeu
26
27
  :top?,
27
28
  :top_left,
28
29
  :top_right,
29
- :vertical
30
+ :top_horizontal,
31
+ :vertical,
32
+ :left_vertical,
33
+ :right_vertical
30
34
 
31
35
  def_delegators :geometry,
32
36
  :bordered_height,
@@ -79,6 +83,15 @@ module Vedeu
79
83
 
80
84
  private
81
85
 
86
+ # @return [Hash<Symbol => void>]
87
+ def attributes
88
+ {
89
+ colour: colour,
90
+ name: name,
91
+ style: style,
92
+ }
93
+ end
94
+
82
95
  # Returns the border for the interface.
83
96
  #
84
97
  # @return (see Vedeu::Borders::Repository#by_name)
@@ -89,69 +102,48 @@ module Vedeu
89
102
  # @return [Array<Array<Vedeu::Views::Char>>]
90
103
  def output
91
104
  Vedeu.timer("Drawing border: '#{name}'".freeze) do
92
- out = [top, bottom]
93
-
94
- bordered_height.times { |y| out << [left(y), right(y)] }
95
-
96
- out.flatten
105
+ [top, left, right, bottom].flatten
97
106
  end
98
107
  end
99
108
 
100
- # @param value [String]
101
- # @param type [Symbol|NilClass]
102
- # @param iy [Fixnum]
103
- # @param ix [Fixnum]
104
- # @return [Vedeu::Views::Char]
105
- def build(value, type = :border, iy = 0, ix = 0)
106
- Vedeu::Views::Char.new(value: value,
107
- parent: interface,
108
- colour: colour,
109
- name: name,
110
- style: style,
111
- position: [iy, ix],
112
- border: type)
113
- end
114
-
115
109
  # Creates the bottom left border character.
116
110
  #
117
- # @return [Vedeu::Views::Char]
111
+ # @return [NilClass|Vedeu::Cells::Border|Vedeu::Views::Char]
118
112
  def build_bottom_left
119
- build(bottom_left, :bottom_left, yn, x) if left?
113
+ return nil unless left?
114
+ return bottom_left if bottom_left
115
+
116
+ Vedeu::Cells::BottomLeft.new(attributes)
120
117
  end
121
118
 
122
119
  # Creates the bottom right border character.
123
120
  #
124
- # @return [Vedeu::Views::Char]
121
+ # @return [NilClass|Vedeu::Cells::Border|Vedeu::Views::Char]
125
122
  def build_bottom_right
126
- build(bottom_right, :bottom_right, yn, xn) if right?
127
- end
123
+ return nil unless right?
124
+ return bottom_right if bottom_right
128
125
 
129
- # Creates a top border character.
130
- #
131
- # @return [Array<Vedeu::Views::Char>]
132
- def build_top
133
- build_horizontal(:top_horizontal, y)
134
- end
135
-
136
- # Creates a bottom border character.
137
- #
138
- # @return [Array<Vedeu::Views::Char>]
139
- def build_bottom
140
- build_horizontal(:bottom_horizontal, yn)
126
+ Vedeu::Cells::BottomRight.new(attributes)
141
127
  end
142
128
 
143
129
  # Creates the top left border character.
144
130
  #
145
- # @return [Vedeu::Views::Char]
131
+ # @return [NilClass|Vedeu::Cells::Border|Vedeu::Views::Char]
146
132
  def build_top_left
147
- build(top_left, :top_left, y, x) if left?
133
+ return nil unless left?
134
+ return top_left if top_left
135
+
136
+ Vedeu::Cells::TopLeft.new(attributes)
148
137
  end
149
138
 
150
139
  # Creates the top right border character.
151
140
  #
152
- # @return [Vedeu::Views::Char]
141
+ # @return [NilClass|Vedeu::Cells::Border|Vedeu::Views::Char]
153
142
  def build_top_right
154
- build(top_right, :top_right, y, xn) if right?
143
+ return nil unless right?
144
+ return top_right if top_right
145
+
146
+ Vedeu::Cells::TopRight.new(attributes)
155
147
  end
156
148
 
157
149
  # Renders the bottom border for the interface.
@@ -175,16 +167,6 @@ module Vedeu
175
167
  Vedeu.geometries.by_name(name)
176
168
  end
177
169
 
178
- # @param position [Symbol] Either :top_horizontal, or
179
- # :bottom_horizontal.
180
- # @param y_coordinate [Fixnum] The value of either y or yn.
181
- # @return [Array<Vedeu::Views::Char>]
182
- def build_horizontal(position, y_coordinate)
183
- Array.new(bordered_width) do |ix|
184
- build(horizontal, position, y_coordinate, (bx + ix))
185
- end
186
- end
187
-
188
170
  # Returns the interface by name.
189
171
  #
190
172
  # @note
@@ -198,22 +180,28 @@ module Vedeu
198
180
 
199
181
  # Renders the left border for the interface.
200
182
  #
201
- # @param iy [Fixnum]
202
- # @return [String]
203
- def left(iy = 0)
183
+ # @return [Array<void>]
184
+ def left
204
185
  return [] unless left?
205
186
 
206
- build(vertical, :left_vertical, (by + iy), x)
187
+ build_collection(bordered_height) do |iy|
188
+ cell = left_vertical_cell.dup
189
+ cell.position = [by + iy, x]
190
+ cell
191
+ end
207
192
  end
208
193
 
209
194
  # Renders the right border for the interface.
210
195
  #
211
- # @param iy [Fixnum]
212
- # @return [String]
213
- def right(iy = 0)
196
+ # @return [Array<void>]
197
+ def right
214
198
  return [] unless right?
215
199
 
216
- build(vertical, :right_vertical, (by + iy), xn)
200
+ build_collection(bordered_height) do |iy|
201
+ cell = right_vertical_cell.dup
202
+ cell.position = [by + iy, xn]
203
+ cell
204
+ end
217
205
  end
218
206
 
219
207
  # Renders the top border for the interface.
@@ -235,9 +223,20 @@ module Vedeu
235
223
  # @return [Array<Vedeu::Views::Char>]
236
224
  # @see [Vedeu::Borders::Caption#render]
237
225
  def captionbar
238
- return nil unless caption
226
+ return build_bottom unless present?(caption)
239
227
 
240
- @_caption ||= Vedeu::Borders::Caption.render(caption, build_bottom)
228
+ Vedeu::Borders::Caption.render(name, caption, build_bottom)
229
+ end
230
+
231
+ # Creates a bottom border character.
232
+ #
233
+ # @return [Array<Vedeu::Views::Char>]
234
+ def build_bottom
235
+ build_collection(bordered_width) do |ix|
236
+ cell = bottom_horizontal_cell.dup
237
+ cell.position = [yn, bx + ix]
238
+ cell
239
+ end
241
240
  end
242
241
 
243
242
  # An optional title for when the top border is to be shown.
@@ -245,9 +244,69 @@ module Vedeu
245
244
  # @return [Array<Vedeu::Views::Char>]
246
245
  # @see [Vedeu::Borders::Title#render]
247
246
  def titlebar
248
- return nil unless title
247
+ return build_top unless present?(title)
248
+
249
+ Vedeu::Borders::Title.render(name, title, build_top)
250
+ end
251
+
252
+ # Creates a top border character.
253
+ #
254
+ # @return [Array<Vedeu::Views::Char>]
255
+ def build_top
256
+ build_collection(bordered_width) do |ix|
257
+ cell = top_horizontal_cell.dup
258
+ cell.position = [y, bx + ix]
259
+ cell
260
+ end
261
+ end
262
+
263
+ # Return the client application configured left vertical cell
264
+ # character, or the default if not set.
265
+ #
266
+ # @return [Vedeu::Cells::LeftVertical]
267
+ def left_vertical_cell
268
+ return left_vertical if left_vertical
249
269
 
250
- @_title ||= Vedeu::Borders::Title.render(title, build_top)
270
+ Vedeu::Cells::LeftVertical.new(attributes)
271
+ end
272
+
273
+ # Return the client application configured right vertical cell
274
+ # character, or the default if not set.
275
+ #
276
+ # @return [Vedeu::Cells::RightVertical]
277
+ def right_vertical_cell
278
+ return right_vertical if right_vertical
279
+
280
+ Vedeu::Cells::RightVertical.new(attributes)
281
+ end
282
+
283
+ # Return the client application configured top horizontal cell
284
+ # character, or the default if not set.
285
+ #
286
+ # @return [Vedeu::Cells::TopHorizontal]
287
+ def top_horizontal_cell
288
+ return top_horizontal if top_horizontal
289
+
290
+ Vedeu::Cells::TopHorizontal.new(attributes)
291
+ end
292
+
293
+ # Return the client application configured bottom horizontal
294
+ # cell character, or the default if not set.
295
+ #
296
+ # @return [Vedeu::Cells::BottomHorizontal]
297
+ def bottom_horizontal_cell
298
+ return bottom_horizontal if bottom_horizontal
299
+
300
+ Vedeu::Cells::BottomHorizontal.new(attributes)
301
+ end
302
+
303
+ # Build a collection with the given size of objects given within
304
+ # the block.
305
+ #
306
+ # @param size [Fixnum]
307
+ # @return [Array<void>]
308
+ def build_collection(size)
309
+ Array.new(size) { |e| yield(e) }
251
310
  end
252
311
 
253
312
  end # Refresh