vedeu 0.8.4 → 0.8.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/TODO.md +4 -0
- data/docs/dsl.md +1 -11
- data/docs/dsl/by_method/geometry/align.md +1 -0
- data/docs/dsl/by_method/geometry/align_bottom.md +40 -0
- data/docs/dsl/by_method/geometry/align_centre.md +40 -0
- data/docs/dsl/by_method/geometry/align_left.md +40 -0
- data/docs/dsl/by_method/geometry/align_middle.md +40 -0
- data/docs/dsl/by_method/geometry/align_right.md +40 -0
- data/docs/dsl/by_method/geometry/align_top.md +40 -0
- data/docs/dsl/by_method/geometry/columns.md +1 -0
- data/docs/dsl/by_method/geometry/height.md +0 -0
- data/docs/dsl/by_method/geometry/horizontal_alignment.md +1 -0
- data/docs/dsl/by_method/geometry/rows.md +1 -0
- data/docs/dsl/by_method/geometry/vertical_alignment.md +1 -0
- data/docs/dsl/by_method/geometry/width.md +0 -0
- data/docs/dsl/by_method/geometry/x.md +1 -0
- data/docs/dsl/by_method/geometry/xn.md +1 -0
- data/docs/dsl/by_method/geometry/y.md +1 -0
- data/docs/dsl/by_method/geometry/yn.md +1 -0
- data/docs/dsl/by_method/render.md +5 -1
- data/docs/dsl/by_method/renders.md +31 -1
- data/docs/dsl/by_method/view.md +26 -0
- data/docs/dsl/by_method/view/stream.md +18 -0
- data/docs/dsl/by_method/views.md +32 -1
- data/docs/events/by_name/set_border_caption.md +2 -4
- data/docs/events/by_name/set_border_title.md +2 -4
- data/examples/views/empty_template.rb +0 -4
- data/examples/views/full_screen.rb +30 -5
- data/examples/views/misc_view.rb +464 -0
- data/examples/views/wordwrap.rb +72 -0
- data/examples/views/wordwrap.txt +8 -0
- data/integrations/dsl_app_021.rb +127 -0
- data/integrations/dsl_app_022.rb +133 -0
- data/integrations/expected/342_streams.out +1 -1
- data/integrations/expected/dsl_app_001.out +1 -1
- data/integrations/expected/dsl_app_002.out +1 -1
- data/integrations/expected/dsl_app_003.out +1 -1
- data/integrations/expected/dsl_app_004.out +1 -1
- data/integrations/expected/dsl_app_005.out +1 -1
- data/integrations/expected/dsl_app_006.out +1 -1
- data/integrations/expected/dsl_app_007.out +1 -1
- data/integrations/expected/dsl_app_008.out +1 -1
- data/integrations/expected/dsl_app_009.out +1 -1
- data/integrations/expected/dsl_app_010.out +1 -1
- data/integrations/expected/dsl_app_011.out +1 -1
- data/integrations/expected/dsl_app_012.out +1 -1
- data/integrations/expected/dsl_app_013.out +1 -1
- data/integrations/expected/dsl_app_014.out +1 -1
- data/integrations/expected/dsl_app_015.out +1 -1
- data/integrations/expected/dsl_app_016.out +1 -1
- data/integrations/expected/dsl_app_021.out +1 -0
- data/integrations/expected/dsl_app_022.out +1 -0
- data/integrations/support/test_interface_021.rb +7 -0
- data/integrations/support/test_interface_022.rb +15 -0
- data/lib/vedeu/all.rb +4 -2
- data/lib/vedeu/borders/border.rb +22 -6
- data/lib/vedeu/borders/repository.rb +4 -8
- data/lib/vedeu/buffers/buffer.rb +9 -6
- data/lib/vedeu/buffers/empty.rb +26 -23
- data/lib/vedeu/buffers/view.rb +44 -41
- data/lib/vedeu/cells/cursor.rb +0 -2
- data/lib/vedeu/cells/empty.rb +0 -1
- data/lib/vedeu/cells/escape.rb +0 -2
- data/lib/vedeu/coercers/alignment.rb +58 -8
- data/lib/vedeu/coercers/horizontal_alignment.rb +13 -9
- data/lib/vedeu/coercers/vertical_alignment.rb +13 -8
- data/lib/vedeu/common.rb +1 -1
- data/lib/vedeu/configuration/configuration.rb +41 -3
- data/lib/vedeu/cursors/coordinate.rb +1 -3
- data/lib/vedeu/cursors/cursor.rb +2 -6
- data/lib/vedeu/dsl/all.rb +1 -2
- data/lib/vedeu/dsl/border.rb +6 -6
- data/lib/vedeu/dsl/elements.rb +2 -2
- data/lib/vedeu/dsl/geometry.rb +7 -7
- data/lib/vedeu/dsl/{string → helpers}/align.rb +0 -0
- data/lib/vedeu/dsl/helpers/all.rb +17 -0
- data/lib/vedeu/dsl/{attributes.rb → helpers/attributes.rb} +0 -0
- data/lib/vedeu/dsl/{string → helpers}/text.rb +0 -0
- data/lib/vedeu/dsl/{string → helpers}/truncate.rb +0 -0
- data/lib/vedeu/dsl/{string → helpers}/wordwrap.rb +0 -0
- data/lib/vedeu/dsl/view.rb +11 -19
- data/lib/vedeu/dsl/views.rb +16 -106
- data/lib/vedeu/geometries/all.rb +0 -1
- data/lib/vedeu/geometries/area/area.rb +6 -12
- data/lib/vedeu/geometries/area/dimension.rb +21 -44
- data/lib/vedeu/geometries/dsl/all.rb +0 -1
- data/lib/vedeu/geometries/dsl/dsl.rb +22 -31
- data/lib/vedeu/geometries/geometry.rb +6 -0
- data/lib/vedeu/geometries/position.rb +6 -3
- data/lib/vedeu/geometries/repository.rb +1 -1
- data/lib/vedeu/input/mouse.rb +1 -0
- data/lib/vedeu/logging/log.rb +3 -6
- data/lib/vedeu/menus/dsl.rb +4 -5
- data/lib/vedeu/output/compressor.rb +11 -1
- data/lib/vedeu/output/viewport.rb +59 -59
- data/lib/vedeu/presentation/all.rb +1 -2
- data/lib/vedeu/presentation/colour.rb +75 -3
- data/lib/vedeu/{geometries/positionable.rb → presentation/position.rb} +4 -4
- data/lib/vedeu/presentation/presentation.rb +1 -3
- data/lib/vedeu/presentation/styles.rb +16 -1
- data/lib/vedeu/repositories/all.rb +0 -1
- data/lib/vedeu/sentence.rb +91 -0
- data/lib/vedeu/support/point.rb +72 -0
- data/lib/vedeu/terminal/terminal.rb +11 -53
- data/lib/vedeu/version.rb +1 -1
- data/lib/vedeu/views/composition.rb +11 -1
- data/lib/vedeu/views/default_attributes.rb +2 -0
- data/lib/vedeu/views/line.rb +16 -1
- data/lib/vedeu/views/stream.rb +16 -1
- data/lib/vedeu/views/view.rb +25 -17
- data/test/lib/vedeu/borders/border_test.rb +20 -2
- data/test/lib/vedeu/buffers/buffer_test.rb +15 -2
- data/test/lib/vedeu/buffers/empty_test.rb +51 -18
- data/test/lib/vedeu/buffers/view_test.rb +2 -2
- data/test/lib/vedeu/coercers/alignment_test.rb +32 -0
- data/test/lib/vedeu/coercers/horizontal_alignment_test.rb +16 -0
- data/test/lib/vedeu/coercers/vertical_alignment_test.rb +16 -0
- data/test/lib/vedeu/cursors/cursor_test.rb +4 -4
- data/test/lib/vedeu/cursors/dsl_test.rb +35 -21
- data/test/lib/vedeu/dsl/elements_test.rb +94 -2
- data/test/lib/vedeu/dsl/{string → helpers}/align_test.rb +0 -0
- data/test/lib/vedeu/dsl/{attributes_test.rb → helpers/attributes_test.rb} +0 -0
- data/test/lib/vedeu/dsl/{string → helpers}/text_test.rb +0 -0
- data/test/lib/vedeu/dsl/{string → helpers}/truncate_test.rb +0 -0
- data/test/lib/vedeu/dsl/{string → helpers}/wordwrap_test.rb +0 -0
- data/test/lib/vedeu/dsl/view_test.rb +22 -4
- data/test/lib/vedeu/dsl/views_test.rb +8 -5
- data/test/lib/vedeu/geometries/dsl/dsl_test.rb +2 -159
- data/test/lib/vedeu/geometries/position_test.rb +118 -60
- data/test/lib/vedeu/input/mouse_test.rb +1 -6
- data/test/lib/vedeu/logging/log_test.rb +14 -3
- data/test/lib/vedeu/presentation/colour_test.rb +77 -0
- data/test/lib/vedeu/{geometries/positionable_test.rb → presentation/position_test.rb} +4 -4
- data/test/lib/vedeu/sentence_test.rb +49 -0
- data/test/lib/vedeu/support/point_test.rb +139 -0
- data/test/lib/vedeu/terminal/terminal_test.rb +3 -44
- data/test/lib/vedeu/views/composition_test.rb +24 -4
- data/test/lib/vedeu/views/default_attributes_test.rb +10 -2
- data/test/lib/vedeu/views/view_test.rb +8 -15
- data/test/support/examples/material_colours_app.rb +0 -6
- data/vedeu.gemspec +1 -1
- metadata +58 -38
- data/examples/views/lines_line_stream.rb +0 -95
- data/examples/views/lines_line_streams.rb +0 -75
- data/examples/views/lines_line_streams_stream.rb +0 -78
- data/examples/views/lines_line_streams_stream_stream.rb +0 -50
- data/examples/views/lines_streams.rb +0 -93
- data/lib/vedeu/dsl/string/all.rb +0 -16
- data/lib/vedeu/geometries/dsl/validator.rb +0 -62
- data/lib/vedeu/presentation/background.rb +0 -54
- data/lib/vedeu/presentation/foreground.rb +0 -54
- data/lib/vedeu/repositories/parent.rb +0 -34
- data/test/lib/vedeu/geometries/dsl/validator_test.rb +0 -85
- data/test/lib/vedeu/presentation/background_test.rb +0 -74
- data/test/lib/vedeu/presentation/foreground_test.rb +0 -75
@@ -10,17 +10,21 @@ module Vedeu
|
|
10
10
|
#
|
11
11
|
class HorizontalAlignment < Vedeu::Coercers::Alignment
|
12
12
|
|
13
|
+
# @raise (see Vedeu::Coercers::Alignment#validate)
|
14
|
+
# @return (see Vedeu::Coercers::Alignment#validate)
|
15
|
+
def validate
|
16
|
+
return coerce if valid_horizontal?
|
17
|
+
|
18
|
+
fail Vedeu::Error::InvalidSyntax,
|
19
|
+
'Missing or invalid horizontal alignment value. ' \
|
20
|
+
"Valid values are: #{to_sentence}"
|
21
|
+
end
|
22
|
+
|
13
23
|
private
|
14
24
|
|
15
|
-
# @return [
|
16
|
-
def
|
17
|
-
|
18
|
-
:centre,
|
19
|
-
:center,
|
20
|
-
:left,
|
21
|
-
:none,
|
22
|
-
:right,
|
23
|
-
]
|
25
|
+
# @return [String]
|
26
|
+
def to_sentence
|
27
|
+
Vedeu::Sentence.construct(horizontal_values)
|
24
28
|
end
|
25
29
|
|
26
30
|
end # HorizontalAlignment
|
@@ -10,16 +10,21 @@ module Vedeu
|
|
10
10
|
#
|
11
11
|
class VerticalAlignment < Vedeu::Coercers::Alignment
|
12
12
|
|
13
|
+
# @raise (see Vedeu::Coercers::Alignment#validate)
|
14
|
+
# @return (see Vedeu::Coercers::Alignment#validate)
|
15
|
+
def validate
|
16
|
+
return coerce if valid_vertical?
|
17
|
+
|
18
|
+
fail Vedeu::Error::InvalidSyntax,
|
19
|
+
'Missing or invalid vertical alignment value. ' \
|
20
|
+
"Valid values are: #{to_sentence}"
|
21
|
+
end
|
22
|
+
|
13
23
|
private
|
14
24
|
|
15
|
-
# @return [
|
16
|
-
def
|
17
|
-
|
18
|
-
:bottom,
|
19
|
-
:middle,
|
20
|
-
:none,
|
21
|
-
:top,
|
22
|
-
]
|
25
|
+
# @return [String]
|
26
|
+
def to_sentence
|
27
|
+
Vedeu::Sentence.construct(vertical_values)
|
23
28
|
end
|
24
29
|
|
25
30
|
end # VerticalAlignment
|
data/lib/vedeu/common.rb
CHANGED
@@ -133,9 +133,25 @@ module Vedeu
|
|
133
133
|
|
134
134
|
# Returns the client defined height for the terminal.
|
135
135
|
#
|
136
|
+
# {include:file:docs/dsl/by_method/height.md}
|
137
|
+
#
|
136
138
|
# @return [Fixnum]
|
137
139
|
def height
|
138
|
-
|
140
|
+
if drb?
|
141
|
+
drb_height
|
142
|
+
|
143
|
+
elsif height?
|
144
|
+
instance.options[:height]
|
145
|
+
|
146
|
+
else
|
147
|
+
Vedeu::Terminal.size[0]
|
148
|
+
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
# @return [Boolean]
|
153
|
+
def height?
|
154
|
+
instance.options[:height].is_a?(Fixnum)
|
139
155
|
end
|
140
156
|
|
141
157
|
# Returns whether the application is interactive (required user
|
@@ -257,9 +273,25 @@ module Vedeu
|
|
257
273
|
|
258
274
|
# Returns the client defined width for the terminal.
|
259
275
|
#
|
276
|
+
# {include:file:docs/dsl/by_method/width.md}
|
277
|
+
#
|
260
278
|
# @return [Fixnum]
|
261
279
|
def width
|
262
|
-
|
280
|
+
if drb?
|
281
|
+
drb_width
|
282
|
+
|
283
|
+
elsif width?
|
284
|
+
instance.options[:width]
|
285
|
+
|
286
|
+
else
|
287
|
+
Vedeu::Terminal.size[-1]
|
288
|
+
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
# @return [Boolean]
|
293
|
+
def width?
|
294
|
+
instance.options[:width].is_a?(Fixnum)
|
263
295
|
end
|
264
296
|
|
265
297
|
# @param value [void]
|
@@ -374,10 +406,16 @@ module Vedeu
|
|
374
406
|
# @see Vedeu::Configuration.configure
|
375
407
|
# @!method configuration
|
376
408
|
# @see Vedeu::Configuration.configuration
|
409
|
+
# @!method height
|
410
|
+
# @see Vedeu::Configuration.height
|
411
|
+
# @!method width
|
412
|
+
# @see Vedeu::Configuration.width
|
377
413
|
def_delegators Vedeu::Configuration,
|
378
414
|
:config,
|
379
415
|
:configure,
|
380
|
-
:configuration
|
416
|
+
:configuration,
|
417
|
+
:height,
|
418
|
+
:width
|
381
419
|
|
382
420
|
# Sets up a default configuration. Client applications calling using
|
383
421
|
# the `Vedeu.configure` API method will override these settings.
|
data/lib/vedeu/cursors/cursor.rb
CHANGED
@@ -244,16 +244,12 @@ module Vedeu
|
|
244
244
|
|
245
245
|
# @return [Fixnum] The column/character coordinate.
|
246
246
|
def x
|
247
|
-
@x = (@x
|
248
|
-
@x = (@x > bxn) ? bxn : @x
|
249
|
-
@x
|
247
|
+
@x = Vedeu::Point.coerce(value: @x, min: bx, max: bxn).value
|
250
248
|
end
|
251
249
|
|
252
250
|
# @return [Fixnum] The row/line coordinate.
|
253
251
|
def y
|
254
|
-
@y = (@y
|
255
|
-
@y = (@y > byn) ? byn : @y
|
256
|
-
@y
|
252
|
+
@y = Vedeu::Point.coerce(value: @y, min: by, max: byn).value
|
257
253
|
end
|
258
254
|
|
259
255
|
private
|
data/lib/vedeu/dsl/all.rb
CHANGED
@@ -10,11 +10,10 @@ module Vedeu
|
|
10
10
|
|
11
11
|
end # Vedeu
|
12
12
|
|
13
|
-
require 'vedeu/dsl/
|
13
|
+
require 'vedeu/dsl/helpers/all'
|
14
14
|
require 'vedeu/dsl/border'
|
15
15
|
require 'vedeu/dsl/cursors'
|
16
16
|
require 'vedeu/dsl/dsl'
|
17
|
-
require 'vedeu/dsl/attributes'
|
18
17
|
require 'vedeu/dsl/geometry'
|
19
18
|
require 'vedeu/dsl/use'
|
20
19
|
require 'vedeu/dsl/presentation'
|
data/lib/vedeu/dsl/border.rb
CHANGED
@@ -27,9 +27,9 @@ module Vedeu
|
|
27
27
|
# @param name [String|Symbol] The name of the interface or
|
28
28
|
# view to which this border belongs.
|
29
29
|
# @param block [Proc]
|
30
|
-
# @
|
31
|
-
#
|
32
|
-
#
|
30
|
+
# @macro raise_requires_block
|
31
|
+
# @raise [Vedeu::Error::MissingRequired] When a name is not
|
32
|
+
# given.
|
33
33
|
# @return [Vedeu::Borders::Border]
|
34
34
|
# @see Vedeu::Borders::DSL
|
35
35
|
def border(name, &block)
|
@@ -71,9 +71,9 @@ module Vedeu
|
|
71
71
|
# setting it here is just mirroring functionality of
|
72
72
|
# {Vedeu::DSL::Border::ClassMethods.border}.
|
73
73
|
# @param block [Proc]
|
74
|
-
# @
|
75
|
-
#
|
76
|
-
#
|
74
|
+
# @macro raise_requires_block
|
75
|
+
# @raise [Vedeu::Error::MissingRequired] When a name is not
|
76
|
+
# given.
|
77
77
|
# @return [Vedeu::Borders::Border]
|
78
78
|
# @see Vedeu::Borders::DSL
|
79
79
|
def border(name = nil, &block)
|
data/lib/vedeu/dsl/elements.rb
CHANGED
@@ -63,11 +63,11 @@ module Vedeu
|
|
63
63
|
# @macro raise_requires_block
|
64
64
|
# @raise [Vedeu::Error::Fatal]
|
65
65
|
# @return [void]
|
66
|
-
def lines(&block)
|
66
|
+
def lines(opts = {}, &block)
|
67
67
|
requires_block!(&block)
|
68
68
|
requires_model!
|
69
69
|
|
70
|
-
attrs = Vedeu::DSL::Attributes.build(self, model, nil,
|
70
|
+
attrs = Vedeu::DSL::Attributes.build(self, model, nil, opts, &block)
|
71
71
|
|
72
72
|
if view_model?
|
73
73
|
if model.lines?
|
data/lib/vedeu/dsl/geometry.rb
CHANGED
@@ -27,9 +27,9 @@ module Vedeu
|
|
27
27
|
# @param name [String|Symbol] The name of the interface or
|
28
28
|
# view to which this geometry belongs.
|
29
29
|
# @param block [Proc]
|
30
|
-
# @
|
31
|
-
#
|
32
|
-
#
|
30
|
+
# @macro raise_requires_block
|
31
|
+
# @raise [Vedeu::Error::MissingRequired] When a name is not
|
32
|
+
# given.
|
33
33
|
# @return [Vedeu::Geometries::Geometry]
|
34
34
|
# @see Vedeu::Geometries::DSL
|
35
35
|
def geometry(name = nil, &block)
|
@@ -80,11 +80,11 @@ module Vedeu
|
|
80
80
|
# @param name [String|Symbol] The name of the interface; this
|
81
81
|
# is already provided when we define the interface or view,
|
82
82
|
# setting it here is just mirroring functionality of
|
83
|
-
# {Vedeu::DSL::Geometry::ClassMethods
|
83
|
+
# {Vedeu::DSL::Geometry::ClassMethods#geometry}.
|
84
84
|
# @param block [Proc]
|
85
|
-
# @
|
86
|
-
#
|
87
|
-
#
|
85
|
+
# @macro raise_requires_block
|
86
|
+
# @raise [Vedeu::Error::MissingRequired] When a name is not
|
87
|
+
# given.
|
88
88
|
# @return [Vedeu::Geometries::Geometry]
|
89
89
|
# @see Vedeu::Geometries::DSL
|
90
90
|
def geometry(name = nil, &block)
|
File without changes
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
# Provides a mechanism to help configure and use Vedeu.
|
6
|
+
#
|
7
|
+
module DSL
|
8
|
+
|
9
|
+
end # DSL
|
10
|
+
|
11
|
+
end # Vedeu
|
12
|
+
|
13
|
+
require 'vedeu/dsl/helpers/attributes'
|
14
|
+
require 'vedeu/dsl/helpers/align'
|
15
|
+
require 'vedeu/dsl/helpers/truncate'
|
16
|
+
require 'vedeu/dsl/helpers/wordwrap'
|
17
|
+
require 'vedeu/dsl/helpers/text'
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/vedeu/dsl/view.rb
CHANGED
@@ -42,31 +42,22 @@ module Vedeu
|
|
42
42
|
#
|
43
43
|
class View
|
44
44
|
|
45
|
+
include Vedeu::Common
|
45
46
|
include Vedeu::DSL
|
46
47
|
|
47
|
-
#
|
48
|
-
#
|
49
|
-
# A view is just an Interface object.
|
50
|
-
#
|
51
|
-
# When a view already exists, we take its attributes and use
|
52
|
-
# them as the basis for the newly defined view. This way we
|
53
|
-
# don't need to specify everything again.
|
54
|
-
#
|
55
|
-
# @todo More documentation required.
|
48
|
+
# {include:file:docs/dsl/by_method/view.md}
|
56
49
|
# @param name [String|Symbol] The name of the interface you are
|
57
50
|
# targetting for this view.
|
58
51
|
# @param block [Proc] The directives you wish to send to this
|
59
|
-
#
|
60
|
-
#
|
61
|
-
# @example
|
62
|
-
# view :my_interface do
|
63
|
-
# # ...
|
64
|
-
# end
|
65
|
-
#
|
52
|
+
# view.
|
66
53
|
# @macro raise_requires_block
|
54
|
+
# @raise [Vedeu::Error::MissingRequired]
|
67
55
|
# @return [Vedeu::Views::Views<Vedeu::Views::View>]
|
68
|
-
|
56
|
+
# @todo More documentation required.
|
57
|
+
def view(name, &block)
|
69
58
|
fail Vedeu::Error::RequiresBlock unless block_given?
|
59
|
+
fail Vedeu::Error::MissingRequired,
|
60
|
+
'Cannot add view without a name.' unless present?(name)
|
70
61
|
|
71
62
|
new_model = Vedeu::Views::View.build(new_attributes(name), &block)
|
72
63
|
|
@@ -97,9 +88,10 @@ module Vedeu
|
|
97
88
|
def template_for(name, filename, object = nil, options = {})
|
98
89
|
fail Vedeu::Error::MissingRequired,
|
99
90
|
'Cannot render template without the name of the ' \
|
100
|
-
'view.' unless name
|
91
|
+
'view.' unless present?(name)
|
101
92
|
fail Vedeu::Error::MissingRequired,
|
102
|
-
'Cannot render template without a
|
93
|
+
'Cannot render template without a ' \
|
94
|
+
'filename.' unless present?(filename)
|
103
95
|
|
104
96
|
options.merge!(name: name)
|
105
97
|
|
data/lib/vedeu/dsl/views.rb
CHANGED
@@ -93,137 +93,47 @@ module Vedeu
|
|
93
93
|
|
94
94
|
class << self
|
95
95
|
|
96
|
-
include
|
97
|
-
|
98
|
-
# Directly write a view buffer to the terminal. Using this
|
99
|
-
# method means that the refresh event does not need to be
|
100
|
-
# triggered after creating the views, though can be later
|
101
|
-
# triggered when needed.
|
102
|
-
#
|
103
|
-
# Vedeu.renders do
|
104
|
-
# view :some_interface do
|
105
|
-
# line do
|
106
|
-
# stream do
|
107
|
-
# left 'Title goes here', width: 35
|
108
|
-
# end
|
109
|
-
# stream do
|
110
|
-
# right Time.now.strftime('%H:%m'), width: 7
|
111
|
-
# end
|
112
|
-
# end
|
113
|
-
# end
|
114
|
-
# view :other_interface do
|
115
|
-
# lines do
|
116
|
-
# line 'This is content for the main interface.'
|
117
|
-
# line ''
|
118
|
-
# line 'Pretty easy eh?'
|
119
|
-
# end
|
120
|
-
# end
|
121
|
-
# # ... some code
|
122
|
-
# end
|
123
|
-
#
|
124
|
-
# # or...
|
125
|
-
#
|
126
|
-
# Vedeu.render do
|
127
|
-
# view :my_interface do
|
128
|
-
# # ... some code
|
129
|
-
# end
|
130
|
-
# end
|
131
|
-
#
|
96
|
+
# {include:file:docs/dsl/by_method/renders.md}
|
132
97
|
# @param block [Proc] The directives you wish to send to
|
133
98
|
# render. Typically includes `view` with associated
|
134
99
|
# sub-directives.
|
135
100
|
# @macro raise_requires_block
|
136
|
-
# @return [
|
101
|
+
# @return [Vedeu::Views::Composition]
|
137
102
|
def renders(&block)
|
138
103
|
fail Vedeu::Error::RequiresBlock unless block_given?
|
139
104
|
|
140
|
-
|
105
|
+
composition(eval('self', block.binding), true, &block)
|
141
106
|
end
|
142
107
|
alias_method :render, :renders
|
143
108
|
|
144
|
-
#
|
145
|
-
#
|
146
|
-
# As you can see by comparing the examples above to these
|
147
|
-
# below, the immediate render simply wraps what is already
|
148
|
-
# here in the deferred view.
|
149
|
-
#
|
150
|
-
# The views declared within this block are stored in their
|
151
|
-
# respective interface back buffers until a refresh event
|
152
|
-
# occurs. When the refresh event is triggered, the back
|
153
|
-
# buffers are swapped into the front buffers and the content
|
154
|
-
# here will be rendered to {Vedeu::Terminal#output}.
|
155
|
-
#
|
156
|
-
# Vedeu.views do
|
157
|
-
# view :some_interface do
|
158
|
-
# line do
|
159
|
-
# stream do
|
160
|
-
# left 'Title goes here', width: 35
|
161
|
-
# end
|
162
|
-
# stream do
|
163
|
-
# right Time.now.strftime('%H:%m'), width: 7
|
164
|
-
# end
|
165
|
-
# end
|
166
|
-
# end
|
167
|
-
# view :other_interface do
|
168
|
-
# lines do
|
169
|
-
# line 'This is content for the main interface.'
|
170
|
-
# line ''
|
171
|
-
# line 'Pretty easy eh?'
|
172
|
-
# end
|
173
|
-
# end
|
174
|
-
# # ... some code
|
175
|
-
# end
|
176
|
-
#
|
109
|
+
# {include:file:docs/dsl/by_method/views.md}
|
177
110
|
# @param block [Proc] The directives you wish to send to
|
178
111
|
# render. Typically includes `view` with associated
|
179
112
|
# sub-directives.
|
180
113
|
# @macro raise_requires_block
|
181
|
-
# @return [
|
114
|
+
# @return [Vedeu::Views::Composition]
|
182
115
|
def views(&block)
|
183
116
|
fail Vedeu::Error::RequiresBlock unless block_given?
|
184
117
|
|
185
|
-
|
118
|
+
composition(eval('self', block.binding), false, &block)
|
186
119
|
end
|
187
120
|
|
188
121
|
private
|
189
122
|
|
190
|
-
# Returns the client object which called the DSL method.
|
191
|
-
#
|
192
|
-
# @param block [Proc]
|
193
|
-
# @return [Object]
|
194
|
-
def client(&block)
|
195
|
-
eval('self', block.binding)
|
196
|
-
end
|
197
|
-
|
198
123
|
# Creates a new Vedeu::Views::Composition which may contain
|
199
|
-
# one or more
|
124
|
+
# one or more view {Vedeu::Views::View} objects.
|
200
125
|
#
|
201
|
-
# @param client [Object]
|
202
|
-
# @param block [Proc]
|
203
|
-
# @return [Vedeu::Views::Composition]
|
204
|
-
def composition(client, &block)
|
205
|
-
attrs = { client: client, colour: Vedeu.config.colour }
|
206
|
-
|
207
|
-
Vedeu::Views::Composition.build(attrs, &block)
|
208
|
-
end
|
209
|
-
|
210
|
-
# Creates a new Vedeu::Views::Composition which may contain
|
211
|
-
# one or more views (Vedeu::Views::View objects).
|
212
|
-
#
|
213
|
-
# Stores each of the views defined in their respective buffers
|
214
|
-
# ready to be rendered on next refresh.
|
215
|
-
#
|
216
|
-
# @param method [Symbol] An instruction; `:store_immediate` or
|
217
|
-
# `:store_deferred` which determines whether the view will
|
218
|
-
# be shown immediately or later respectively.
|
219
126
|
# @param client [Object] The client class which called the DSL
|
220
127
|
# object.
|
221
|
-
# @param
|
222
|
-
# @
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
128
|
+
# @param refresh [Boolean]
|
129
|
+
# @param block [Proc] The directives you wish to send to
|
130
|
+
# render. Typically includes `view` with associated
|
131
|
+
# sub-directives.
|
132
|
+
# # @return [Vedeu::Views::Composition]
|
133
|
+
def composition(client, refresh = false, &block)
|
134
|
+
attrs = { client: client, colour: Vedeu.config.colour }
|
135
|
+
|
136
|
+
Vedeu::Views::Composition.build(attrs, &block).update_buffers(refresh)
|
227
137
|
end
|
228
138
|
|
229
139
|
end # Eigenclass
|