vedeu 0.6.8 → 0.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +9 -0
- data/README.md +1 -1
- data/docs/api.md +60 -67
- data/docs/configuration.md +8 -5
- data/docs/events.md +31 -15
- data/docs/events/application.md +12 -0
- data/docs/events/document.md +57 -0
- data/docs/events/drb.md +43 -0
- data/docs/events/focus.md +24 -0
- data/docs/events/menu.md +57 -0
- data/docs/events/movement.md +57 -0
- data/docs/events/refresh.md +25 -0
- data/docs/events/system.md +90 -0
- data/docs/events/visibility.md +68 -0
- data/lib/vedeu.rb +2 -2
- data/lib/vedeu/all.rb +3 -2
- data/lib/vedeu/api.rb +18 -18
- data/lib/vedeu/application/controller.rb +1 -1
- data/lib/vedeu/application/helper.rb +1 -1
- data/lib/vedeu/application/view.rb +1 -1
- data/lib/vedeu/bindings/application.rb +1 -12
- data/lib/vedeu/bindings/bindings.rb +3 -1
- data/lib/vedeu/bindings/document.rb +9 -62
- data/lib/vedeu/bindings/drb.rb +12 -56
- data/lib/vedeu/bindings/focus.rb +3 -28
- data/lib/vedeu/bindings/menus.rb +10 -66
- data/lib/vedeu/bindings/movement.rb +4 -69
- data/lib/vedeu/bindings/refresh.rb +3 -33
- data/lib/vedeu/bindings/system.rb +14 -100
- data/lib/vedeu/bindings/visibility.rb +20 -71
- data/lib/vedeu/borders/all.rb +4 -3
- data/lib/vedeu/borders/border.rb +39 -33
- data/lib/vedeu/borders/dsl.rb +40 -33
- data/lib/vedeu/borders/null.rb +2 -2
- data/lib/vedeu/borders/render.rb +29 -24
- data/lib/vedeu/borders/repository.rb +2 -2
- data/lib/vedeu/buffers/all.rb +8 -7
- data/lib/vedeu/buffers/buffer.rb +47 -39
- data/lib/vedeu/buffers/null.rb +2 -2
- data/lib/vedeu/buffers/refresh.rb +4 -3
- data/lib/vedeu/buffers/virtual_buffer.rb +122 -118
- data/lib/vedeu/buffers/virtual_buffers.rb +62 -56
- data/lib/vedeu/colours/background.rb +2 -1
- data/lib/vedeu/colours/colour.rb +21 -19
- data/lib/vedeu/colours/foreground.rb +2 -1
- data/lib/vedeu/colours/repository.rb +6 -5
- data/lib/vedeu/colours/translator.rb +39 -35
- data/lib/vedeu/configuration/api.rb +59 -51
- data/lib/vedeu/configuration/cli.rb +9 -7
- data/lib/vedeu/configuration/configuration.rb +41 -32
- data/lib/vedeu/cursors/cursor.rb +1 -1
- data/lib/vedeu/cursors/refresh.rb +20 -16
- data/lib/vedeu/distributed/server.rb +8 -6
- data/lib/vedeu/distributed/subprocess.rb +90 -86
- data/lib/vedeu/distributed/uri.rb +4 -3
- data/lib/vedeu/dsl/composition.rb +2 -2
- data/lib/vedeu/dsl/group.rb +4 -4
- data/lib/vedeu/dsl/interface.rb +5 -5
- data/lib/vedeu/dsl/presentation.rb +2 -2
- data/lib/vedeu/dsl/text.rb +1 -1
- data/lib/vedeu/editor/cropper.rb +4 -4
- data/lib/vedeu/editor/cursor.rb +6 -4
- data/lib/vedeu/editor/document.rb +20 -18
- data/lib/vedeu/editor/editor.rb +2 -2
- data/lib/vedeu/editor/line.rb +10 -5
- data/lib/vedeu/editor/lines.rb +2 -2
- data/lib/vedeu/internal_api.rb +4 -4
- data/lib/vedeu/models/focus.rb +197 -191
- data/lib/vedeu/models/group.rb +171 -159
- data/lib/vedeu/models/groups.rb +14 -10
- data/lib/vedeu/models/interface.rb +116 -110
- data/lib/vedeu/models/interfaces.rb +24 -20
- data/lib/vedeu/models/toggleable.rb +4 -4
- data/lib/vedeu/models/views/char.rb +1 -1
- data/lib/vedeu/models/views/composition.rb +1 -1
- data/lib/vedeu/models/views/line.rb +1 -1
- data/lib/vedeu/models/views/stream.rb +1 -1
- data/lib/vedeu/models/views/view.rb +1 -1
- data/lib/vedeu/null/interface.rb +1 -1
- data/lib/vedeu/null/view.rb +1 -1
- data/lib/vedeu/output/clear/named_interface.rb +1 -1
- data/lib/vedeu/output/compressor.rb +78 -73
- data/lib/vedeu/output/direct.rb +61 -57
- data/lib/vedeu/output/output.rb +34 -29
- data/lib/vedeu/output/{presentation.rb → presentation/presentation.rb} +2 -1
- data/lib/vedeu/output/presentation/style.rb +64 -18
- data/lib/vedeu/output/presentation/styles.rb +39 -0
- data/lib/vedeu/output/renderers/html.rb +2 -2
- data/lib/vedeu/output/renderers/json.rb +2 -1
- data/lib/vedeu/output/renderers/terminal.rb +3 -3
- data/lib/vedeu/output/renderers/text.rb +3 -3
- data/lib/vedeu/output/text.rb +186 -180
- data/lib/vedeu/output/wordwrap.rb +142 -138
- data/lib/vedeu/refresh/refresh.rb +2 -2
- data/lib/vedeu/templating/helpers.rb +11 -6
- data/lib/vedeu/templating/view_template.rb +1 -1
- data/lib/vedeu/terminal/terminal.rb +2 -2
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/borders/render_test.rb +1 -1
- data/test/lib/vedeu/buffers/buffer_test.rb +16 -14
- data/test/lib/vedeu/buffers/virtual_buffer_test.rb +105 -101
- data/test/lib/vedeu/buffers/virtual_buffers_test.rb +43 -39
- data/test/lib/vedeu/colours/colour_test.rb +4 -4
- data/test/lib/vedeu/cursors/cursor_test.rb +2 -2
- data/test/lib/vedeu/cursors/repository_test.rb +3 -3
- data/test/lib/vedeu/distributed/subprocess_test.rb +33 -29
- data/test/lib/vedeu/dsl/group_test.rb +3 -3
- data/test/lib/vedeu/dsl/interface_test.rb +6 -5
- data/test/lib/vedeu/dsl/line_test.rb +4 -2
- data/test/lib/vedeu/dsl/presentation_test.rb +2 -2
- data/test/lib/vedeu/dsl/text_test.rb +8 -8
- data/test/lib/vedeu/editor/document_test.rb +10 -6
- data/test/lib/vedeu/input/keymap_test.rb +1 -10
- data/test/lib/vedeu/models/focus_test.rb +177 -170
- data/test/lib/vedeu/models/group_test.rb +99 -95
- data/test/lib/vedeu/models/groups_test.rb +13 -9
- data/test/lib/vedeu/models/interface_test.rb +93 -87
- data/test/lib/vedeu/models/interfaces_test.rb +24 -20
- data/test/lib/vedeu/models/views/char_test.rb +2 -2
- data/test/lib/vedeu/models/views/line_test.rb +11 -7
- data/test/lib/vedeu/models/views/stream_test.rb +1 -1
- data/test/lib/vedeu/models/views/view_test.rb +1 -1
- data/test/lib/vedeu/output/clear/named_group_test.rb +1 -1
- data/test/lib/vedeu/output/clear/named_interface_test.rb +3 -1
- data/test/lib/vedeu/output/compressor_test.rb +126 -122
- data/test/lib/vedeu/output/direct_test.rb +49 -43
- data/test/lib/vedeu/output/output_test.rb +35 -31
- data/test/lib/vedeu/output/{presentation_test.rb → presentation/presentation_test.rb} +11 -7
- data/test/lib/vedeu/output/presentation/style_test.rb +88 -48
- data/test/lib/vedeu/output/presentation/styles_test.rb +84 -0
- data/test/lib/vedeu/output/text_test.rb +109 -105
- data/test/lib/vedeu/output/viewport_test.rb +3 -1
- data/test/lib/vedeu/output/wordwrap_test.rb +209 -205
- data/test/lib/vedeu/refresh/refresh_test.rb +3 -1
- data/test/lib/vedeu/templating/helpers_test.rb +6 -6
- data/test/lib/vedeu/templating/view_template_test.rb +1 -1
- metadata +17 -8
- data/lib/vedeu/output/style.rb +0 -76
- data/test/lib/vedeu/output/style_test.rb +0 -120
data/lib/vedeu/borders/dsl.rb
CHANGED
@@ -16,8 +16,8 @@ module Vedeu
|
|
16
16
|
# # ...
|
17
17
|
# end
|
18
18
|
#
|
19
|
-
# @param name [String] The name of the interface or view to
|
20
|
-
# border belongs.
|
19
|
+
# @param name [String] The name of the interface or view to
|
20
|
+
# which this border belongs.
|
21
21
|
# @param block [Proc]
|
22
22
|
# @raise [Vedeu::Error::InvalidSyntax]
|
23
23
|
# The required block was not given.
|
@@ -38,32 +38,32 @@ module Vedeu
|
|
38
38
|
@client = client
|
39
39
|
end
|
40
40
|
|
41
|
-
# Set the character to be used to draw the bottom left corner of
|
42
|
-
# border.
|
41
|
+
# Set the character to be used to draw the bottom left corner of
|
42
|
+
# the border.
|
43
43
|
#
|
44
44
|
# Vedeu.border 'border_demo' do
|
45
45
|
# bottom_left '+'
|
46
46
|
# # ... some code
|
47
47
|
# end
|
48
48
|
#
|
49
|
-
# @param char [String] Character to be used as the bottom left
|
50
|
-
# character.
|
49
|
+
# @param char [String] Character to be used as the bottom left
|
50
|
+
# border character.
|
51
51
|
# @return [String]
|
52
52
|
def bottom_left(char)
|
53
53
|
model.bottom_left = char
|
54
54
|
end
|
55
55
|
alias_method :bottom_left=, :bottom_left
|
56
56
|
|
57
|
-
# Set the character to be used to draw the bottom right corner
|
58
|
-
# border.
|
57
|
+
# Set the character to be used to draw the bottom right corner
|
58
|
+
# of the border.
|
59
59
|
#
|
60
60
|
# Vedeu.border 'border_demo' do
|
61
61
|
# bottom_right '+'
|
62
62
|
# # ... some code
|
63
63
|
# end
|
64
64
|
#
|
65
|
-
# @param char [String] Character to be used as the bottom right
|
66
|
-
# character.
|
65
|
+
# @param char [String] Character to be used as the bottom right
|
66
|
+
# border character.
|
67
67
|
# @return [String]
|
68
68
|
def bottom_right(char)
|
69
69
|
model.bottom_right = char
|
@@ -90,7 +90,8 @@ module Vedeu
|
|
90
90
|
end
|
91
91
|
|
92
92
|
# Enable the border:
|
93
|
-
# (Borders are enabled by default when defined for an
|
93
|
+
# (Borders are enabled by default when defined for an
|
94
|
+
# interface).
|
94
95
|
#
|
95
96
|
# Vedeu.border 'border_demo' do
|
96
97
|
# enable!
|
@@ -109,15 +110,16 @@ module Vedeu
|
|
109
110
|
model.enabled
|
110
111
|
end
|
111
112
|
|
112
|
-
# Set the character to be used to draw a horizontal part of the
|
113
|
+
# Set the character to be used to draw a horizontal part of the
|
114
|
+
# border.
|
113
115
|
#
|
114
116
|
# Vedeu.border 'border_demo' do
|
115
117
|
# horizontal '-'
|
116
118
|
# # ... some code
|
117
119
|
# end
|
118
120
|
#
|
119
|
-
# @param char [String] Character to be used as the horizontal
|
120
|
-
# character.
|
121
|
+
# @param char [String] Character to be used as the horizontal
|
122
|
+
# border character.
|
121
123
|
# @return [String]
|
122
124
|
def horizontal(char)
|
123
125
|
model.horizontal = char
|
@@ -134,8 +136,8 @@ module Vedeu
|
|
134
136
|
# # ... some code
|
135
137
|
# end
|
136
138
|
#
|
137
|
-
# @param value [Boolean] All values evaluate as true except nil
|
138
|
-
#
|
139
|
+
# @param value [Boolean] All values evaluate as true except nil
|
140
|
+
# and false.
|
139
141
|
# @return [Boolean]
|
140
142
|
def bottom(value)
|
141
143
|
boolean = value ? true : false
|
@@ -169,8 +171,8 @@ module Vedeu
|
|
169
171
|
# # ... some code
|
170
172
|
# end
|
171
173
|
#
|
172
|
-
# @param value [Boolean] All values evaluate as true except nil
|
173
|
-
# false.
|
174
|
+
# @param value [Boolean] All values evaluate as true except nil
|
175
|
+
# and false.
|
174
176
|
# @return [Boolean]
|
175
177
|
def left(value)
|
176
178
|
boolean = value ? true : false
|
@@ -204,8 +206,8 @@ module Vedeu
|
|
204
206
|
# # ... some code
|
205
207
|
# end
|
206
208
|
#
|
207
|
-
# @param value [Boolean] All values evaluate as true except nil
|
208
|
-
# false.
|
209
|
+
# @param value [Boolean] All values evaluate as true except nil
|
210
|
+
# and false.
|
209
211
|
# @return [Boolean]
|
210
212
|
def right(value)
|
211
213
|
boolean = value ? true : false
|
@@ -229,7 +231,8 @@ module Vedeu
|
|
229
231
|
right(true)
|
230
232
|
end
|
231
233
|
|
232
|
-
# If you have you are showing a top border, you could add a
|
234
|
+
# If you have you are showing a top border, you could add a
|
235
|
+
# title.
|
233
236
|
#
|
234
237
|
# Vedeu.border 'border_demo' do
|
235
238
|
# title 'My Cool Title'
|
@@ -247,7 +250,8 @@ module Vedeu
|
|
247
250
|
end
|
248
251
|
alias_method :title=, :title
|
249
252
|
|
250
|
-
# If you have you are showing a bottom border, you could add a
|
253
|
+
# If you have you are showing a bottom border, you could add a
|
254
|
+
# caption.
|
251
255
|
#
|
252
256
|
# Vedeu.border 'border_demo' do
|
253
257
|
# caption 'My Cool Caption'
|
@@ -275,8 +279,8 @@ module Vedeu
|
|
275
279
|
# # ... some code
|
276
280
|
# end
|
277
281
|
#
|
278
|
-
# @param value [Boolean] All values evaluate as true except nil
|
279
|
-
# false.
|
282
|
+
# @param value [Boolean] All values evaluate as true except nil
|
283
|
+
# and false.
|
280
284
|
# @return [Boolean]
|
281
285
|
def top(value)
|
282
286
|
boolean = value ? true : false
|
@@ -300,45 +304,48 @@ module Vedeu
|
|
300
304
|
top(true)
|
301
305
|
end
|
302
306
|
|
303
|
-
# Set the character to be used to draw the top left corner of
|
307
|
+
# Set the character to be used to draw the top left corner of
|
308
|
+
# the border.
|
304
309
|
#
|
305
310
|
# Vedeu.border 'border_demo' do
|
306
311
|
# top_left '+'
|
307
312
|
# # ... some code
|
308
313
|
# end
|
309
314
|
#
|
310
|
-
# @param char [String] Character to be used as the top left
|
311
|
-
# character.
|
315
|
+
# @param char [String] Character to be used as the top left
|
316
|
+
# border character.
|
312
317
|
# @return [String]
|
313
318
|
def top_left(char)
|
314
319
|
model.top_left = char
|
315
320
|
end
|
316
321
|
alias_method :top_left=, :top_left
|
317
322
|
|
318
|
-
# Set the character to be used to draw the top right corner of
|
323
|
+
# Set the character to be used to draw the top right corner of
|
324
|
+
# the border.
|
319
325
|
#
|
320
326
|
# Vedeu.border 'border_demo' do
|
321
327
|
# top_right '+'
|
322
328
|
# # ... some code
|
323
329
|
# end
|
324
330
|
#
|
325
|
-
# @param char [String] Character to be used as the top right
|
326
|
-
# character.
|
331
|
+
# @param char [String] Character to be used as the top right
|
332
|
+
# border character.
|
327
333
|
# @return [String]
|
328
334
|
def top_right(char)
|
329
335
|
model.top_right = char
|
330
336
|
end
|
331
337
|
alias_method :top_right=, :top_right
|
332
338
|
|
333
|
-
# Set the character to be used to draw a vertical part of the
|
339
|
+
# Set the character to be used to draw a vertical part of the
|
340
|
+
# border.
|
334
341
|
#
|
335
342
|
# Vedeu.border 'border_demo' do
|
336
343
|
# vertical '|'
|
337
344
|
# # ... some code
|
338
345
|
# end
|
339
346
|
#
|
340
|
-
# @param char [String] Character to be used as the vertical
|
341
|
-
# character.
|
347
|
+
# @param char [String] Character to be used as the vertical
|
348
|
+
# border character.
|
342
349
|
# @return [String]
|
343
350
|
def vertical(char)
|
344
351
|
model.vertical = char
|
data/lib/vedeu/borders/null.rb
CHANGED
data/lib/vedeu/borders/render.rb
CHANGED
@@ -133,9 +133,9 @@ module Vedeu
|
|
133
133
|
# Renders the bottom border for the interface.
|
134
134
|
#
|
135
135
|
# @note
|
136
|
-
# If a caption has been specified, then the bottom border will
|
137
|
-
# this caption unless the size of the interface is
|
138
|
-
# padded caption length.
|
136
|
+
# If a caption has been specified, then the bottom border will
|
137
|
+
# include this caption unless the size of the interface is
|
138
|
+
# smaller than the padded caption length.
|
139
139
|
#
|
140
140
|
# @return [String]
|
141
141
|
def bottom
|
@@ -149,7 +149,8 @@ module Vedeu
|
|
149
149
|
Vedeu.geometries.by_name(name)
|
150
150
|
end
|
151
151
|
|
152
|
-
# @param position [Symbol] Either :top_horizontal, or
|
152
|
+
# @param position [Symbol] Either :top_horizontal, or
|
153
|
+
# :bottom_horizontal.
|
153
154
|
# @param y_coordinate [Fixnum] The value of either y or yn.
|
154
155
|
# @return [Array<Vedeu::Views::Char>]
|
155
156
|
def build_horizontal(position, y_coordinate)
|
@@ -160,7 +161,7 @@ module Vedeu
|
|
160
161
|
|
161
162
|
# The parent of a border is always an interface.
|
162
163
|
#
|
163
|
-
# @return [Vedeu::Interface]
|
164
|
+
# @return [Vedeu::Models::Interface]
|
164
165
|
def interface
|
165
166
|
@interface ||= Vedeu.interfaces.by_name(name)
|
166
167
|
end
|
@@ -189,9 +190,9 @@ module Vedeu
|
|
189
190
|
# Renders the top border for the interface.
|
190
191
|
#
|
191
192
|
# @note
|
192
|
-
# If a title has been specified, then the top border will
|
193
|
-
# title unless the size of the interface is
|
194
|
-
# title length.
|
193
|
+
# If a title has been specified, then the top border will
|
194
|
+
# include this title unless the size of the interface is
|
195
|
+
# smaller than the padded title length.
|
195
196
|
#
|
196
197
|
# @return [String]
|
197
198
|
def top
|
@@ -200,8 +201,8 @@ module Vedeu
|
|
200
201
|
[build_top_left, titlebar, build_top_right].compact
|
201
202
|
end
|
202
203
|
|
203
|
-
# Overwrite the border from {#build_horizontal} on the bottom
|
204
|
-
# include the caption if given.
|
204
|
+
# Overwrite the border from {#build_horizontal} on the bottom
|
205
|
+
# border to include the caption if given.
|
205
206
|
#
|
206
207
|
# @return [Array<Vedeu::Views::Char>]
|
207
208
|
def captionbar
|
@@ -219,8 +220,8 @@ module Vedeu
|
|
219
220
|
end
|
220
221
|
end
|
221
222
|
|
222
|
-
# Overwrite the border from {#build_horizontal} on the top
|
223
|
-
# include the title if given.
|
223
|
+
# Overwrite the border from {#build_horizontal} on the top
|
224
|
+
# border to include the title if given.
|
224
225
|
#
|
225
226
|
# @return [Array<Vedeu::Views::Char>]
|
226
227
|
def titlebar
|
@@ -234,30 +235,32 @@ module Vedeu
|
|
234
235
|
end
|
235
236
|
end
|
236
237
|
|
237
|
-
# Return boolean indicating whether this border has a non-empty
|
238
|
+
# Return boolean indicating whether this border has a non-empty
|
239
|
+
# title.
|
238
240
|
#
|
239
241
|
# @return [Boolean]
|
240
242
|
def title?
|
241
243
|
present?(title)
|
242
244
|
end
|
243
245
|
|
244
|
-
# Return boolean indicating whether this border has a non-empty
|
246
|
+
# Return boolean indicating whether this border has a non-empty
|
247
|
+
# caption.
|
245
248
|
#
|
246
249
|
# @return [Boolean]
|
247
250
|
def caption?
|
248
251
|
present?(caption)
|
249
252
|
end
|
250
253
|
|
251
|
-
# Return boolean indicating whether the title fits within the
|
252
|
-
# top border.
|
254
|
+
# Return boolean indicating whether the title fits within the
|
255
|
+
# width of the top border.
|
253
256
|
#
|
254
257
|
# @return [Boolean]
|
255
258
|
def title_fits?
|
256
259
|
width > title_characters.size
|
257
260
|
end
|
258
261
|
|
259
|
-
# Return boolean indicating whether the caption fits within the
|
260
|
-
# the bottom border.
|
262
|
+
# Return boolean indicating whether the caption fits within the
|
263
|
+
# width of the bottom border.
|
261
264
|
#
|
262
265
|
# @return [Boolean]
|
263
266
|
def caption_fits?
|
@@ -306,9 +309,10 @@ module Vedeu
|
|
306
309
|
truncated_caption.center(truncated_caption.size + 2)
|
307
310
|
end
|
308
311
|
|
309
|
-
# Truncates the title to the width of the interface, minus
|
310
|
-
# needed to ensure there is at least a single
|
311
|
-
# border and a whitespace on either side
|
312
|
+
# Truncates the title to the width of the interface, minus
|
313
|
+
# characters needed to ensure there is at least a single
|
314
|
+
# character of horizontal border and a whitespace on either side
|
315
|
+
# of the title.
|
312
316
|
#
|
313
317
|
# @example
|
314
318
|
# title = 'Truncated!'
|
@@ -323,9 +327,10 @@ module Vedeu
|
|
323
327
|
title.chomp.slice(0..(width - 5))
|
324
328
|
end
|
325
329
|
|
326
|
-
# Truncates the caption to the width of the interface, minus
|
327
|
-
# needed to ensure there is at least a single
|
328
|
-
# border and a whitespace on either
|
330
|
+
# Truncates the caption to the width of the interface, minus
|
331
|
+
# characters needed to ensure there is at least a single
|
332
|
+
# character of horizontal border and a whitespace on either
|
333
|
+
# side of the caption.
|
329
334
|
#
|
330
335
|
# @example
|
331
336
|
# caption = 'Truncated!'
|
data/lib/vedeu/buffers/all.rb
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
# The Buffer object represents the states of display for an
|
4
|
-
# states are 'front', 'back' and 'previous'.
|
3
|
+
# The Buffer object represents the states of display for an
|
4
|
+
# interface. The states are 'front', 'back' and 'previous'.
|
5
5
|
#
|
6
6
|
# [Back] -> [Front] -> [Previous]
|
7
7
|
#
|
8
|
-
# The content on the screen, or last output will always be the
|
9
|
-
# buffer. Content due to be displayed on next refresh will
|
10
|
-
# 'Back' buffer when available, otherwise from the
|
11
|
-
# When new content is copied to the 'Front'
|
12
|
-
# buffer is also copied to the
|
8
|
+
# The content on the screen, or last output will always be the
|
9
|
+
# 'Front' buffer. Content due to be displayed on next refresh will
|
10
|
+
# come from the 'Back' buffer when available, otherwise from the
|
11
|
+
# current 'Front' buffer. When new content is copied to the 'Front'
|
12
|
+
# buffer, the current 'Front' buffer is also copied to the
|
13
|
+
# 'Previous' buffer.
|
13
14
|
#
|
14
15
|
module Buffers
|
15
16
|
|
data/lib/vedeu/buffers/buffer.rb
CHANGED
@@ -2,28 +2,29 @@ module Vedeu
|
|
2
2
|
|
3
3
|
module Buffers
|
4
4
|
|
5
|
-
# Used by Vedeu internally to manage the buffers of each interface
|
5
|
+
# Used by Vedeu internally to manage the buffers of each interface
|
6
|
+
# defined.
|
6
7
|
#
|
7
8
|
class Buffer
|
8
9
|
|
9
10
|
include Vedeu::Model
|
10
11
|
|
11
|
-
# The next buffer to be displayed; contains the content which
|
12
|
-
# shown on next refresh.
|
12
|
+
# The next buffer to be displayed; contains the content which
|
13
|
+
# will be shown on next refresh.
|
13
14
|
#
|
14
15
|
# @!attribute [rw] back
|
15
16
|
# @return [Vedeu::Views::View]
|
16
17
|
attr_accessor :back
|
17
18
|
|
18
|
-
# The currently displayed buffer, contains the content which was
|
19
|
-
# output.
|
19
|
+
# The currently displayed buffer, contains the content which was
|
20
|
+
# last output.
|
20
21
|
#
|
21
22
|
# @!attribute [rw] front
|
22
23
|
# @return [Vedeu::Views::View]
|
23
24
|
attr_accessor :front
|
24
25
|
|
25
|
-
# The previous buffer which was displayed; contains the content
|
26
|
-
# shown before 'front'.
|
26
|
+
# The previous buffer which was displayed; contains the content
|
27
|
+
# that was shown before 'front'.
|
27
28
|
#
|
28
29
|
# @!attribute [rw] previous
|
29
30
|
# @return [Vedeu::Views::View]
|
@@ -33,11 +34,11 @@ module Vedeu
|
|
33
34
|
# @return [String]
|
34
35
|
attr_reader :name
|
35
36
|
|
36
|
-
# Return a new instance of Buffer. Generally a Buffer is
|
37
|
-
# only a 'name' and 'back' parameter.
|
37
|
+
# Return a new instance of Buffer. Generally a Buffer is
|
38
|
+
# initialized with only a 'name' and 'back' parameter.
|
38
39
|
#
|
39
|
-
# @option attributes name [String] The name of the interface for
|
40
|
-
# buffer belongs.
|
40
|
+
# @option attributes name [String] The name of the interface for
|
41
|
+
# which the buffer belongs.
|
41
42
|
# @option attributes back [Vedeu::Views::View]
|
42
43
|
# @option attributes front [Vedeu::Views::View]
|
43
44
|
# @option attributes previous [Vedeu::Views::View]
|
@@ -51,8 +52,9 @@ module Vedeu
|
|
51
52
|
end
|
52
53
|
end
|
53
54
|
|
54
|
-
# Add the content to the back buffer, then update the
|
55
|
-
# Returns boolean indicating that the repository was
|
55
|
+
# Add the content to the back buffer, then update the
|
56
|
+
# repository. Returns boolean indicating that the repository was
|
57
|
+
# updated.
|
56
58
|
#
|
57
59
|
# @param content [Vedeu::Views::View]
|
58
60
|
# @return [Boolean]
|
@@ -64,7 +66,8 @@ module Vedeu
|
|
64
66
|
true
|
65
67
|
end
|
66
68
|
|
67
|
-
# Return a boolean indicating content presence on the buffer
|
69
|
+
# Return a boolean indicating content presence on the buffer
|
70
|
+
# type.
|
68
71
|
#
|
69
72
|
# @return [Boolean] Whether the buffer targetted has content.
|
70
73
|
def back?
|
@@ -77,10 +80,11 @@ module Vedeu
|
|
77
80
|
#
|
78
81
|
# @return [Array<Array<Vedeu::Views::Char>>]
|
79
82
|
def clear
|
80
|
-
Vedeu::Output.render(Vedeu::Clear::NamedInterface.render(name))
|
83
|
+
Vedeu::Output::Output.render(Vedeu::Clear::NamedInterface.render(name))
|
81
84
|
end
|
82
85
|
|
83
|
-
# Return a boolean indicating content presence on the buffer
|
86
|
+
# Return a boolean indicating content presence on the buffer
|
87
|
+
# type.
|
84
88
|
#
|
85
89
|
# @return [Boolean] Whether the buffer targetted has content.
|
86
90
|
def front?
|
@@ -89,7 +93,8 @@ module Vedeu
|
|
89
93
|
true
|
90
94
|
end
|
91
95
|
|
92
|
-
# Return a boolean indicating content presence on the buffer
|
96
|
+
# Return a boolean indicating content presence on the buffer
|
97
|
+
# type.
|
93
98
|
#
|
94
99
|
# @return [Boolean] Whether the buffer targetted has content.
|
95
100
|
def previous?
|
@@ -104,31 +109,33 @@ module Vedeu
|
|
104
109
|
# Vedeu.trigger(:_hide_interface_, name)
|
105
110
|
# Vedeu.hide_interface(name)
|
106
111
|
#
|
107
|
-
# Will hide the named interface. If the interface is currently
|
108
|
-
# will be cleared- rendered blank. To show the
|
109
|
-
# ':_show_interface_' event should be triggered.
|
110
|
-
# ':_hide_group_' event to which this named
|
111
|
-
# hide the interface.
|
112
|
+
# Will hide the named interface. If the interface is currently
|
113
|
+
# visible, it will be cleared- rendered blank. To show the
|
114
|
+
# interface, the ':_show_interface_' event should be triggered.
|
115
|
+
# Triggering the ':_hide_group_' event to which this named
|
116
|
+
# interface belongs will also hide the interface.
|
112
117
|
#
|
113
118
|
# @return [Array<Array<Array<Vedeu::Views::Char>>>]
|
114
119
|
def hide
|
115
|
-
Vedeu::Output.render(clear)
|
120
|
+
Vedeu::Output::Output.render(clear)
|
116
121
|
end
|
117
122
|
|
118
123
|
# Return the content for this buffer.
|
119
124
|
#
|
120
|
-
# - If we have new content (i.e. content on 'back') to be shown,
|
121
|
-
# clear the area occupied by the previous content,
|
122
|
-
# for the new content, and then finally
|
123
|
-
#
|
124
|
-
#
|
125
|
-
#
|
126
|
-
#
|
127
|
-
#
|
125
|
+
# - If we have new content (i.e. content on 'back') to be shown,
|
126
|
+
# we first clear the area occupied by the previous content,
|
127
|
+
# then clear the area for the new content, and then finally
|
128
|
+
# render the new content.
|
129
|
+
# - If there is no new content (i.e. 'back' is empty), check the
|
130
|
+
# 'front' buffer and display that.
|
131
|
+
# - If there is no new content, and the front buffer is empty,
|
132
|
+
# display the 'previous' buffer.
|
133
|
+
# - If the 'previous' buffer is empty, return an empty
|
134
|
+
# collection.
|
128
135
|
#
|
129
136
|
# @return [Array<Array<Array<Vedeu::Views::Char>>>]
|
130
137
|
def render
|
131
|
-
Vedeu::Output.render(buffer)
|
138
|
+
Vedeu::Output::Output.render(buffer)
|
132
139
|
end
|
133
140
|
|
134
141
|
# Show this buffer.
|
@@ -137,15 +144,15 @@ module Vedeu
|
|
137
144
|
# Vedeu.trigger(:_show_interface_, name)
|
138
145
|
# Vedeu.show_interface(name)
|
139
146
|
#
|
140
|
-
# Will show the named interface. If the interface is currently
|
141
|
-
# it will be shown- rendered with its latest content.
|
142
|
-
# interface, the ':_hide_interface_' event should be
|
143
|
-
# the ':_show_group_' event to which this
|
144
|
-
# also show the interface.
|
147
|
+
# Will show the named interface. If the interface is currently
|
148
|
+
# invisible, it will be shown- rendered with its latest content.
|
149
|
+
# To hide the interface, the ':_hide_interface_' event should be
|
150
|
+
# triggered. Triggering the ':_show_group_' event to which this
|
151
|
+
# named interface belongs will also show the interface.
|
145
152
|
#
|
146
153
|
# @return [Array<Array<Array<Vedeu::Views::Char>>>]
|
147
154
|
def show
|
148
|
-
Vedeu::Output.render(buffer)
|
155
|
+
Vedeu::Output::Output.render(buffer)
|
149
156
|
end
|
150
157
|
|
151
158
|
private
|
@@ -181,7 +188,8 @@ module Vedeu
|
|
181
188
|
}
|
182
189
|
end
|
183
190
|
|
184
|
-
# Return a boolean indicating content was swapped between
|
191
|
+
# Return a boolean indicating content was swapped between
|
192
|
+
# buffers.
|
185
193
|
#
|
186
194
|
# @return [Boolean]
|
187
195
|
def swap
|