vedeu 0.6.71 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/api.md +1 -1
- data/lib/vedeu/all.rb +1 -0
- data/lib/vedeu/borders/border.rb +66 -55
- data/lib/vedeu/borders/caption.rb +10 -20
- data/lib/vedeu/borders/dsl.rb +57 -13
- data/lib/vedeu/borders/refresh.rb +123 -64
- data/lib/vedeu/borders/set_attribute.rb +1 -3
- data/lib/vedeu/borders/title.rb +68 -25
- data/lib/vedeu/cells/all.rb +23 -0
- data/lib/vedeu/cells/border.rb +72 -0
- data/lib/vedeu/cells/borders/all.rb +18 -0
- data/lib/vedeu/cells/borders/bottom_horizontal.rb +28 -0
- data/lib/vedeu/cells/borders/bottom_left.rb +34 -0
- data/lib/vedeu/cells/borders/bottom_right.rb +34 -0
- data/lib/vedeu/cells/borders/horizontal.rb +28 -0
- data/lib/vedeu/cells/borders/left_vertical.rb +28 -0
- data/lib/vedeu/cells/borders/right_vertical.rb +28 -0
- data/lib/vedeu/cells/borders/top_horizontal.rb +28 -0
- data/lib/vedeu/cells/borders/top_left.rb +34 -0
- data/lib/vedeu/cells/borders/top_right.rb +34 -0
- data/lib/vedeu/cells/borders/vertical.rb +28 -0
- data/lib/vedeu/cells/char.rb +24 -0
- data/lib/vedeu/cells/clear.rb +29 -0
- data/lib/vedeu/cells/empty.rb +78 -0
- data/lib/vedeu/cells/escape.rb +24 -0
- data/lib/vedeu/cells/html.rb +19 -0
- data/lib/vedeu/cells/json.rb +19 -0
- data/lib/vedeu/colours/colour.rb +6 -6
- data/lib/vedeu/common.rb +9 -0
- data/lib/vedeu/cursors/move.rb +2 -3
- data/lib/vedeu/editor/insert.rb +1 -1
- data/lib/vedeu/editor/item.rb +2 -3
- data/lib/vedeu/input/mouse.rb +1 -1
- data/lib/vedeu/interfaces/clear.rb +3 -4
- data/lib/vedeu/output/compressor.rb +1 -0
- data/lib/vedeu/presentation/colour.rb +3 -0
- data/lib/vedeu/repositories/defaults.rb +10 -1
- data/lib/vedeu/templating/decoder.rb +1 -1
- data/lib/vedeu/templating/encoder.rb +1 -1
- data/lib/vedeu/templating/template.rb +2 -2
- data/lib/vedeu/templating/view_template.rb +1 -1
- data/lib/vedeu/terminal/terminal.rb +9 -0
- data/lib/vedeu/version.rb +1 -1
- data/lib/vedeu/views/html_char.rb +1 -1
- data/test/lib/vedeu/application/application_controller_test.rb +2 -2
- data/test/lib/vedeu/application/controller_test.rb +4 -4
- data/test/lib/vedeu/borders/border_test.rb +10 -2
- data/test/lib/vedeu/borders/caption_test.rb +29 -13
- data/test/lib/vedeu/borders/dsl_test.rb +44 -25
- data/test/lib/vedeu/borders/refresh_test.rb +2 -2
- data/test/lib/vedeu/borders/title_test.rb +17 -15
- data/test/lib/vedeu/buffers/buffer_test.rb +8 -8
- data/test/lib/vedeu/buffers/refresh_test.rb +10 -10
- data/test/lib/vedeu/buffers/terminal_test.rb +6 -6
- data/test/lib/vedeu/cells/border_test.rb +72 -0
- data/test/lib/vedeu/cells/borders/bottom_horizontal_test.rb +22 -0
- data/test/lib/vedeu/cells/borders/bottom_left_test.rb +36 -0
- data/test/lib/vedeu/cells/borders/bottom_right_test.rb +36 -0
- data/test/lib/vedeu/cells/borders/horizontal_test.rb +22 -0
- data/test/lib/vedeu/cells/borders/left_vertical_test.rb +22 -0
- data/test/lib/vedeu/cells/borders/right_vertical_test.rb +22 -0
- data/test/lib/vedeu/cells/borders/top_horizontal_test.rb +22 -0
- data/test/lib/vedeu/cells/borders/top_left_test.rb +36 -0
- data/test/lib/vedeu/cells/borders/top_right_test.rb +36 -0
- data/test/lib/vedeu/cells/borders/vertical_test.rb +22 -0
- data/test/lib/vedeu/cells/char_test.rb +22 -0
- data/test/lib/vedeu/cells/clear_test.rb +34 -0
- data/test/lib/vedeu/cells/empty_test.rb +55 -0
- data/test/lib/vedeu/cells/escape_test.rb +13 -0
- data/test/lib/vedeu/cells/html_test.rb +13 -0
- data/test/lib/vedeu/cells/json_test.rb +13 -0
- data/test/lib/vedeu/colours/colour_test.rb +2 -6
- data/test/lib/vedeu/colours/translator_test.rb +4 -4
- data/test/lib/vedeu/common_test.rb +10 -0
- data/test/lib/vedeu/configuration/api_test.rb +24 -24
- data/test/lib/vedeu/cursors/cursor_test.rb +4 -4
- data/test/lib/vedeu/cursors/dsl_test.rb +16 -16
- data/test/lib/vedeu/cursors/reposition_test.rb +2 -2
- data/test/lib/vedeu/cursors/repository_test.rb +2 -2
- data/test/lib/vedeu/distributed/client_test.rb +2 -2
- data/test/lib/vedeu/distributed/server_test.rb +8 -8
- data/test/lib/vedeu/distributed/subprocess_test.rb +2 -2
- data/test/lib/vedeu/distributed/test_application_test.rb +2 -2
- data/test/lib/vedeu/dsl/line_test.rb +2 -2
- data/test/lib/vedeu/dsl/presentation_test.rb +4 -4
- data/test/lib/vedeu/editor/cursor_test.rb +2 -2
- data/test/lib/vedeu/editor/document_test.rb +4 -4
- data/test/lib/vedeu/editor/editor_test.rb +20 -20
- data/test/lib/vedeu/events/aliases_test.rb +2 -2
- data/test/lib/vedeu/events/repository_test.rb +2 -2
- data/test/lib/vedeu/geometries/area/area_test.rb +2 -2
- data/test/lib/vedeu/geometries/geometry_test.rb +2 -2
- data/test/lib/vedeu/geometries/move_test.rb +2 -2
- data/test/lib/vedeu/geometries/position_test.rb +2 -2
- data/test/lib/vedeu/groups/clear_test.rb +2 -2
- data/test/lib/vedeu/groups/group_test.rb +4 -4
- data/test/lib/vedeu/groups/refresh_test.rb +2 -2
- data/test/lib/vedeu/input/capture_test.rb +42 -40
- data/test/lib/vedeu/input/mouse_test.rb +13 -11
- data/test/lib/vedeu/input/read_test.rb +10 -10
- data/test/lib/vedeu/interfaces/clear_test.rb +15 -6
- data/test/lib/vedeu/interfaces/dsl_test.rb +14 -14
- data/test/lib/vedeu/interfaces/interface_test.rb +12 -9
- data/test/lib/vedeu/logging/debug_test.rb +2 -2
- data/test/lib/vedeu/logging/lockless_log_device_test.rb +2 -2
- data/test/lib/vedeu/logging/log_test.rb +4 -4
- data/test/lib/vedeu/logging/mono_logger_test.rb +8 -8
- data/test/lib/vedeu/logging/timer_test.rb +2 -2
- data/test/lib/vedeu/menus/menu_test.rb +4 -4
- data/test/lib/vedeu/models/cell_test.rb +2 -2
- data/test/lib/vedeu/models/focus_test.rb +6 -6
- data/test/lib/vedeu/models/toggleable_test.rb +10 -10
- data/test/lib/vedeu/null/generic_test.rb +2 -2
- data/test/lib/vedeu/output/output_test.rb +8 -8
- data/test/lib/vedeu/output/refresh_test.rb +2 -2
- data/test/lib/vedeu/output/viewport_test.rb +2 -2
- data/test/lib/vedeu/plugins/plugin_test.rb +4 -4
- data/test/lib/vedeu/presentation/background_test.rb +2 -2
- data/test/lib/vedeu/presentation/foreground_test.rb +2 -2
- data/test/lib/vedeu/presentation/style_test.rb +2 -2
- data/test/lib/vedeu/renderers/all_test.rb +2 -2
- data/test/lib/vedeu/renderers/file_test.rb +6 -6
- data/test/lib/vedeu/renderers/terminal_test.rb +2 -2
- data/test/lib/vedeu/repositories/collection_test.rb +2 -2
- data/test/lib/vedeu/repositories/defaults_test.rb +35 -0
- data/test/lib/vedeu/repositories/registerable_test.rb +2 -2
- data/test/lib/vedeu/runtime/bootstrap_test.rb +2 -2
- data/test/lib/vedeu/runtime/flags_test.rb +2 -2
- data/test/lib/vedeu/runtime/launcher_test.rb +4 -4
- data/test/lib/vedeu/runtime/main_loop_test.rb +2 -2
- data/test/lib/vedeu/runtime/router_test.rb +12 -12
- data/test/lib/vedeu/terminal/mode_test.rb +4 -4
- data/test/lib/vedeu/terminal/terminal_test.rb +19 -9
- data/test/lib/vedeu/views/char_test.rb +2 -2
- data/test/lib/vedeu/views/composition_test.rb +2 -2
- data/test/lib/vedeu/views/line_test.rb +2 -2
- data/test/lib/vedeu/views/stream_test.rb +2 -2
- data/test/lib/vedeu/views/view_test.rb +4 -4
- data/vedeu.gemspec +1 -1
- metadata +57 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bb700b808027ae0199e3f275aa59204c356e2c4
|
4
|
+
data.tar.gz: 269a2f124899846454acefe97fe50a95dc28ef8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79c2059ccd86e0afdf0b4998bb4528ff5a9d0cdf9266583db8b8ae976f7a04c2079e3f362cf503f42e6193f32cbcd95a96edefe47ed9bb5f4fd051b76ad7bf8a
|
7
|
+
data.tar.gz: fc2a6a223a6e9a8b098d02b0c74f08d07d56a3ee0cef6870229ba87f1756d7075e393cd3eb8a409159afc3b8249ce64a1c298e997458000097a385cd033c40e1
|
data/docs/api.md
CHANGED
data/lib/vedeu/all.rb
CHANGED
data/lib/vedeu/borders/border.rb
CHANGED
@@ -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
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
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
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
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) -
|
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
|
data/lib/vedeu/borders/dsl.rb
CHANGED
@@ -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::
|
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
|
-
:
|
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
|
-
|
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
|
-
|
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
|
-
|
127
|
-
|
123
|
+
return nil unless right?
|
124
|
+
return bottom_right if bottom_right
|
128
125
|
|
129
|
-
|
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
|
-
|
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
|
-
|
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
|
-
# @
|
202
|
-
|
203
|
-
def left(iy = 0)
|
183
|
+
# @return [Array<void>]
|
184
|
+
def left
|
204
185
|
return [] unless left?
|
205
186
|
|
206
|
-
|
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
|
-
# @
|
212
|
-
|
213
|
-
def right(iy = 0)
|
196
|
+
# @return [Array<void>]
|
197
|
+
def right
|
214
198
|
return [] unless right?
|
215
199
|
|
216
|
-
|
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
|
226
|
+
return build_bottom unless present?(caption)
|
239
227
|
|
240
|
-
|
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
|
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
|
-
|
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
|