vedeu 0.6.69 → 0.6.70
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 +4 -0
- data/lib/vedeu/all.rb +5 -7
- data/lib/vedeu/borders/all.rb +1 -0
- data/lib/vedeu/borders/repository.rb +2 -6
- data/lib/vedeu/borders/set_attribute.rb +71 -0
- data/lib/vedeu/buffers/buffer.rb +6 -1
- data/lib/vedeu/buffers/refresh.rb +6 -1
- data/lib/vedeu/common.rb +2 -1
- data/lib/vedeu/configuration/configuration.rb +1 -1
- data/lib/vedeu/cursors/all.rb +1 -0
- data/lib/vedeu/cursors/cursor.rb +8 -27
- data/lib/vedeu/cursors/move.rb +69 -0
- data/lib/vedeu/cursors/repository.rb +1 -1
- data/lib/vedeu/dsl/all.rb +2 -0
- data/lib/vedeu/dsl/composition.rb +6 -1
- data/lib/vedeu/dsl/lines.rb +21 -0
- data/lib/vedeu/dsl/streams.rb +21 -0
- data/lib/vedeu/groups/clear.rb +6 -1
- data/lib/vedeu/groups/refresh.rb +6 -1
- data/lib/vedeu/input/capture.rb +6 -1
- data/lib/vedeu/interfaces/clear.rb +6 -1
- data/lib/vedeu/interfaces/interface.rb +20 -8
- data/lib/vedeu/models/all.rb +1 -0
- data/lib/vedeu/models/focus.rb +19 -14
- data/lib/vedeu/models/page.rb +5 -0
- data/lib/vedeu/models/row.rb +5 -0
- data/lib/vedeu/models/toggleable.rb +6 -1
- data/lib/vedeu/null/all.rb +0 -1
- data/lib/vedeu/output/all.rb +0 -2
- data/lib/vedeu/output/compressor.rb +2 -1
- data/lib/vedeu/output/wordwrap.rb +6 -1
- data/lib/vedeu/output/write.rb +2 -0
- data/lib/vedeu/presentation/all.rb +17 -0
- data/lib/vedeu/presentation/background.rb +47 -0
- data/lib/vedeu/presentation/colour.rb +42 -0
- data/lib/vedeu/presentation/foreground.rb +47 -0
- data/lib/vedeu/{output/presentation → presentation}/presentation.rb +0 -0
- data/lib/vedeu/{output/presentation → presentation}/style.rb +0 -0
- data/lib/vedeu/presentation/styles.rb +45 -0
- data/lib/vedeu/{output/renderers → renderers}/all.rb +5 -5
- data/lib/vedeu/{output/renderers → renderers}/file.rb +0 -0
- data/lib/vedeu/{output/renderers → renderers}/html.rb +0 -0
- data/lib/vedeu/{output/renderers → renderers}/json.rb +0 -0
- data/lib/vedeu/{output/renderers → renderers}/options.rb +5 -1
- data/lib/vedeu/{output → renderers}/templates/html_renderer.vedeu +0 -0
- data/lib/vedeu/{output/renderers → renderers}/terminal.rb +1 -1
- data/lib/vedeu/repositories/all.rb +1 -0
- data/lib/vedeu/repositories/parent.rb +32 -0
- data/lib/vedeu/repositories/repositories.rb +1 -0
- data/lib/vedeu/runtime/flags.rb +2 -0
- data/lib/vedeu/templating/view_template.rb +6 -1
- data/lib/vedeu/version.rb +1 -1
- data/lib/vedeu/views/all.rb +20 -0
- data/lib/vedeu/{models/views → views}/char.rb +33 -21
- data/lib/vedeu/views/chars.rb +15 -0
- data/lib/vedeu/{models/views → views}/composition.rb +0 -0
- data/lib/vedeu/{models/views → views}/html_char.rb +0 -0
- data/lib/vedeu/{models/views → views}/line.rb +17 -21
- data/lib/vedeu/views/lines.rb +15 -0
- data/lib/vedeu/{models/views → views}/stream.rb +16 -20
- data/lib/vedeu/views/streams.rb +15 -0
- data/lib/vedeu/{models/views → views}/view.rb +28 -17
- data/lib/vedeu/views/view_collection.rb +15 -0
- data/lib/vedeu.rb +2 -0
- data/test/lib/vedeu/borders/set_attribute_test.rb +62 -0
- data/test/lib/vedeu/common_test.rb +6 -0
- data/test/lib/vedeu/cursors/cursor_test.rb +0 -8
- data/test/lib/vedeu/cursors/move_test.rb +73 -0
- data/test/lib/vedeu/cursors/repository_test.rb +3 -1
- data/test/lib/vedeu/dsl/lines_test.rb +12 -0
- data/test/lib/vedeu/dsl/streams_test.rb +13 -0
- data/test/lib/vedeu/events/aliases_test.rb +4 -4
- data/test/lib/vedeu/groups/refresh_test.rb +0 -6
- data/test/lib/vedeu/input/store_test.rb +2 -2
- data/test/lib/vedeu/interfaces/interface_test.rb +6 -1
- data/test/lib/vedeu/models/focus_test.rb +25 -10
- data/test/lib/vedeu/models/page_test.rb +6 -0
- data/test/lib/vedeu/models/row_test.rb +12 -0
- data/test/lib/vedeu/presentation/background_test.rb +72 -0
- data/test/lib/vedeu/presentation/colour_test.rb +67 -0
- data/test/lib/vedeu/presentation/foreground_test.rb +73 -0
- data/test/lib/vedeu/{output/presentation → presentation}/presentation_test.rb +0 -0
- data/test/lib/vedeu/{output/presentation → presentation}/style_test.rb +0 -0
- data/test/lib/vedeu/{output/presentation → presentation}/styles_test.rb +7 -9
- data/test/lib/vedeu/{output/renderers → renderers}/all_test.rb +3 -2
- data/test/lib/vedeu/{output/renderers → renderers}/file_test.rb +0 -0
- data/test/lib/vedeu/{output/renderers → renderers}/html_test.rb +2 -1
- data/test/lib/vedeu/{output/renderers → renderers}/json_test.rb +1 -0
- data/test/lib/vedeu/{output/renderers → renderers}/options_test.rb +10 -6
- data/test/lib/vedeu/{output/renderers → renderers}/terminal_test.rb +0 -0
- data/test/lib/vedeu/repositories/repositories_test.rb +1 -0
- data/test/lib/vedeu/runtime/flags_test.rb +2 -0
- data/test/lib/vedeu/templating/helpers_test.rb +15 -6
- data/test/lib/vedeu/{models/views → views}/char_test.rb +0 -0
- data/test/lib/vedeu/{models/views → views}/composition_test.rb +0 -0
- data/test/lib/vedeu/{models/views → views}/html_char_test.rb +0 -0
- data/test/lib/vedeu/{models/views → views}/line_test.rb +6 -1
- data/test/lib/vedeu/views/lines_test.rb +13 -0
- data/test/lib/vedeu/{models/views → views}/stream_test.rb +6 -1
- data/test/lib/vedeu/views/streams_test.rb +13 -0
- data/test/lib/vedeu/views/view_collection_test.rb +13 -0
- data/test/lib/vedeu/{models/views → views}/view_test.rb +6 -1
- data/test/support/examples/material_colours_app.rb +1 -1
- data/test/support/helpers/presentation_colour_test_class.rb +29 -0
- data/test/test_helper.rb +4 -0
- metadata +84 -56
- data/lib/vedeu/models/views/all.rb +0 -16
- data/lib/vedeu/null/view.rb +0 -26
- data/lib/vedeu/output/presentation/all.rb +0 -15
- data/lib/vedeu/output/presentation/colour.rb +0 -100
- data/lib/vedeu/output/presentation/styles.rb +0 -42
- data/test/lib/vedeu/null/view_test.rb +0 -31
- data/test/lib/vedeu/output/presentation/colour_test.rb +0 -172
data/lib/vedeu/models/focus.rb
CHANGED
@@ -69,13 +69,14 @@ module Vedeu
|
|
69
69
|
# @example
|
70
70
|
# Vedeu.focus
|
71
71
|
#
|
72
|
-
# @return [String]
|
72
|
+
# @return [NilClass|String|Symbol]
|
73
73
|
def current
|
74
|
-
return
|
74
|
+
return nil if storage.empty?
|
75
75
|
|
76
|
-
|
76
|
+
storage[0]
|
77
77
|
end
|
78
78
|
alias_method :focus, :current
|
79
|
+
alias_method :name, :current
|
79
80
|
|
80
81
|
# Returns a boolean indicating whether the named interface is
|
81
82
|
# focussed.
|
@@ -90,6 +91,14 @@ module Vedeu
|
|
90
91
|
end
|
91
92
|
alias_method :focussed?, :current?
|
92
93
|
|
94
|
+
# Returns a boolean indicating whether there are interfaces
|
95
|
+
# registered.
|
96
|
+
#
|
97
|
+
# @return [Boolean]
|
98
|
+
def focus?
|
99
|
+
!storage.empty?
|
100
|
+
end
|
101
|
+
|
93
102
|
# Put the next interface relative to the current interfaces in
|
94
103
|
# focus.
|
95
104
|
#
|
@@ -97,7 +106,7 @@ module Vedeu
|
|
97
106
|
# Vedeu.trigger(:_focus_next_)
|
98
107
|
# Vedeu.focus_next
|
99
108
|
#
|
100
|
-
# @return [String]
|
109
|
+
# @return [String|Symbol]
|
101
110
|
def next_item
|
102
111
|
storage.rotate!
|
103
112
|
|
@@ -108,7 +117,7 @@ module Vedeu
|
|
108
117
|
# Put the next visible interface relative to the current
|
109
118
|
# interfaces in focus.
|
110
119
|
#
|
111
|
-
# @return [String]
|
120
|
+
# @return [String|Symbol]
|
112
121
|
def next_visible_item
|
113
122
|
return update unless visible_items?
|
114
123
|
|
@@ -128,7 +137,7 @@ module Vedeu
|
|
128
137
|
# Vedeu.trigger(:_focus_prev_)
|
129
138
|
# Vedeu.focus_previous
|
130
139
|
#
|
131
|
-
# @return [String]
|
140
|
+
# @return [String|Symbol]
|
132
141
|
def prev_item
|
133
142
|
storage.rotate!(-1)
|
134
143
|
|
@@ -140,7 +149,7 @@ module Vedeu
|
|
140
149
|
# Put the previous visible interface relative to the current
|
141
150
|
# interfaces in focus.
|
142
151
|
#
|
143
|
-
# @return [String]
|
152
|
+
# @return [String|Symbol]
|
144
153
|
def prev_visible_item
|
145
154
|
return update unless visible_items?
|
146
155
|
|
@@ -196,13 +205,6 @@ module Vedeu
|
|
196
205
|
Vedeu.interfaces.by_name(current)
|
197
206
|
end
|
198
207
|
|
199
|
-
# @raise [Vedeu::Error::Fatal]
|
200
|
-
def no_interfaces_registered!
|
201
|
-
fail Vedeu::Error::Fatal,
|
202
|
-
'No interfaces or views have been registered, therefore the ' \
|
203
|
-
'focus table is empty.'.freeze
|
204
|
-
end
|
205
|
-
|
206
208
|
# @raise [Vedeu::Error::ModelNotFound]
|
207
209
|
def not_registered!
|
208
210
|
fail Vedeu::Error::ModelNotFound,
|
@@ -244,6 +246,8 @@ module Vedeu
|
|
244
246
|
|
245
247
|
# @!method focus
|
246
248
|
# @see Vedeu::Models::Focus#focus
|
249
|
+
# @!method focus?
|
250
|
+
# @see Vedeu::Models::Focus#focus?
|
247
251
|
# @!method focus_by_name
|
248
252
|
# @see Vedeu::Models::Focus#focus_by_name
|
249
253
|
# @!method focussed?
|
@@ -254,6 +258,7 @@ module Vedeu
|
|
254
258
|
# @see Vedeu::Models::Focus#focus_previous
|
255
259
|
def_delegators Vedeu::Models::Focus,
|
256
260
|
:focus,
|
261
|
+
:focus?,
|
257
262
|
:focus_by_name,
|
258
263
|
:focussed?,
|
259
264
|
:focus_next,
|
data/lib/vedeu/models/page.rb
CHANGED
data/lib/vedeu/models/row.rb
CHANGED
@@ -134,7 +134,12 @@ module Vedeu
|
|
134
134
|
# @param name [String|Symbol]
|
135
135
|
# @return [Boolean]
|
136
136
|
def cursor_visible?(name)
|
137
|
-
|
137
|
+
buffer(name).cursor_visible?
|
138
|
+
end
|
139
|
+
|
140
|
+
# @return [Vedeu::Buffers::Buffer]
|
141
|
+
def buffer(name)
|
142
|
+
Vedeu.buffers.by_name(name)
|
138
143
|
end
|
139
144
|
|
140
145
|
end # ClassMethods
|
data/lib/vedeu/null/all.rb
CHANGED
data/lib/vedeu/output/all.rb
CHANGED
@@ -12,7 +12,5 @@ require 'vedeu/output/text'
|
|
12
12
|
require 'vedeu/output/output'
|
13
13
|
require 'vedeu/output/viewport'
|
14
14
|
require 'vedeu/output/wordwrap'
|
15
|
-
require 'vedeu/output/presentation/all'
|
16
15
|
require 'vedeu/output/refresh'
|
17
|
-
require 'vedeu/output/renderers/all'
|
18
16
|
require 'vedeu/output/write'
|
@@ -12,6 +12,7 @@ module Vedeu
|
|
12
12
|
class Compressor
|
13
13
|
|
14
14
|
include Vedeu::Common
|
15
|
+
include Vedeu::Renderers::Options
|
15
16
|
|
16
17
|
# @param (see #initialize)
|
17
18
|
# @return [String]
|
@@ -37,7 +38,7 @@ module Vedeu
|
|
37
38
|
# - Takes approximately ~25ms for 2100 chars. (2015-07-25)
|
38
39
|
# @return [String]
|
39
40
|
def render
|
40
|
-
return cached if
|
41
|
+
return cached if compress?
|
41
42
|
|
42
43
|
uncompress
|
43
44
|
end
|
@@ -137,6 +137,11 @@ module Vedeu
|
|
137
137
|
options[:ellipsis]
|
138
138
|
end
|
139
139
|
|
140
|
+
# @return [Vedeu::Geometries::Geometry]
|
141
|
+
def geometry
|
142
|
+
Vedeu.geometry.by_name(name)
|
143
|
+
end
|
144
|
+
|
140
145
|
# Returns the word wrapping mode. One of :default, :prune or
|
141
146
|
# :wrap;
|
142
147
|
#
|
@@ -174,7 +179,7 @@ module Vedeu
|
|
174
179
|
# @return [Fixnum]
|
175
180
|
def width
|
176
181
|
return options[:width] if present?(options[:width])
|
177
|
-
return
|
182
|
+
return geometry.width if registered?
|
178
183
|
|
179
184
|
fail Vedeu::Error::MissingRequired,
|
180
185
|
'The text provided cannot be wrapped or pruned because a :width ' \
|
data/lib/vedeu/output/write.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# This module allows the sharing of presentation concerns between
|
4
|
+
# the models: Interface, View, Line and Stream.
|
5
|
+
#
|
6
|
+
module Presentation
|
7
|
+
|
8
|
+
end # Presentation
|
9
|
+
|
10
|
+
end # Vedeu
|
11
|
+
|
12
|
+
require 'vedeu/presentation/background'
|
13
|
+
require 'vedeu/presentation/foreground'
|
14
|
+
require 'vedeu/presentation/colour'
|
15
|
+
require 'vedeu/presentation/styles'
|
16
|
+
require 'vedeu/presentation/style'
|
17
|
+
require 'vedeu/presentation/presentation'
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
module Presentation
|
4
|
+
|
5
|
+
module Colour
|
6
|
+
|
7
|
+
module Background
|
8
|
+
|
9
|
+
include Vedeu::Repositories::Parent
|
10
|
+
|
11
|
+
# When the background colour for the model exists, return it,
|
12
|
+
# otherwise returns the parent background colour, or an empty
|
13
|
+
# Vedeu::Colours::Background.
|
14
|
+
#
|
15
|
+
# @return [Vedeu::Colours::Background]
|
16
|
+
def background
|
17
|
+
@background ||= if colour && present?(colour.background)
|
18
|
+
colour.background
|
19
|
+
|
20
|
+
elsif self.is_a?(Vedeu::Views::Char) && name
|
21
|
+
interface.colour.background
|
22
|
+
|
23
|
+
elsif parent && present?(parent.background)
|
24
|
+
parent.background
|
25
|
+
|
26
|
+
else
|
27
|
+
Vedeu::Colours::Background.new
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Allows the setting of the background colour by coercing the
|
33
|
+
# given value into a Vedeu::Colours::Background colour.
|
34
|
+
#
|
35
|
+
# @return [Vedeu::Colours::Background]
|
36
|
+
def background=(value)
|
37
|
+
@background = colour.background = value
|
38
|
+
@_colour = @colour = colour
|
39
|
+
end
|
40
|
+
|
41
|
+
end # Background
|
42
|
+
|
43
|
+
end # Colour
|
44
|
+
|
45
|
+
end # Presentation
|
46
|
+
|
47
|
+
end # Vedeu
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
module Presentation
|
4
|
+
|
5
|
+
# Provides colour related presentation behaviour.
|
6
|
+
#
|
7
|
+
module Colour
|
8
|
+
|
9
|
+
include Vedeu::Repositories::Parent
|
10
|
+
include Vedeu::Presentation::Colour::Background
|
11
|
+
include Vedeu::Presentation::Colour::Foreground
|
12
|
+
|
13
|
+
# @return [Vedeu::Colours::Colour]
|
14
|
+
def colour
|
15
|
+
@_colour ||= if @colour
|
16
|
+
Vedeu::Colours::Colour.coerce(@colour)
|
17
|
+
|
18
|
+
elsif self.is_a?(Vedeu::Views::Char) && name
|
19
|
+
Vedeu::Colours::Colour.coerce(interface.colour)
|
20
|
+
|
21
|
+
elsif parent && present?(parent.colour)
|
22
|
+
Vedeu::Colours::Colour.coerce(parent.colour)
|
23
|
+
|
24
|
+
else
|
25
|
+
Vedeu::Colours::Colour.new
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Allows the setting of the model's colour by coercing the given
|
31
|
+
# value into a Vedeu::Colours::Colour.
|
32
|
+
#
|
33
|
+
# @return [Vedeu::Colours::Colour]
|
34
|
+
def colour=(value)
|
35
|
+
@_colour = @colour = Vedeu::Colours::Colour.coerce(value)
|
36
|
+
end
|
37
|
+
|
38
|
+
end # Colour
|
39
|
+
|
40
|
+
end # Presentation
|
41
|
+
|
42
|
+
end # Vedeu
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
module Presentation
|
4
|
+
|
5
|
+
module Colour
|
6
|
+
|
7
|
+
module Foreground
|
8
|
+
|
9
|
+
include Vedeu::Repositories::Parent
|
10
|
+
|
11
|
+
# When the foreground colour for the model exists, return it,
|
12
|
+
# otherwise returns the parent foreground colour, or an empty
|
13
|
+
# Vedeu::Colours::Foreground.
|
14
|
+
#
|
15
|
+
# @return [Vedeu::Colours::Foreground]
|
16
|
+
def foreground
|
17
|
+
@foreground ||= if colour && present?(colour.foreground)
|
18
|
+
colour.foreground
|
19
|
+
|
20
|
+
elsif self.is_a?(Vedeu::Views::Char) && name
|
21
|
+
interface.colour.foreground
|
22
|
+
|
23
|
+
elsif parent && present?(parent.foreground)
|
24
|
+
parent.foreground
|
25
|
+
|
26
|
+
else
|
27
|
+
Vedeu::Colours::Foreground.new
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Allows the setting of the foreground colour by coercing the
|
33
|
+
# given value into a Vedeu::Colours::Foreground colour.
|
34
|
+
#
|
35
|
+
# @return [Vedeu::Colours::Foreground]
|
36
|
+
def foreground=(value)
|
37
|
+
@foreground = colour.foreground = value
|
38
|
+
@_colour = @colour = colour
|
39
|
+
end
|
40
|
+
|
41
|
+
end # Foreground
|
42
|
+
|
43
|
+
end # Colour
|
44
|
+
|
45
|
+
end # Presentation
|
46
|
+
|
47
|
+
end # Vedeu
|
File without changes
|
File without changes
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
module Presentation
|
4
|
+
|
5
|
+
# Provides style related presentation behaviour.
|
6
|
+
#
|
7
|
+
module Styles
|
8
|
+
|
9
|
+
include Vedeu::Common
|
10
|
+
include Vedeu::Repositories::Parent
|
11
|
+
|
12
|
+
# When the style for the model exists, return it, otherwise
|
13
|
+
# returns the parent style, or an empty
|
14
|
+
# {Vedeu::Presentation::Style}.
|
15
|
+
#
|
16
|
+
# @return [Vedeu::Presentation::Style]
|
17
|
+
def style
|
18
|
+
@_style ||= if @style
|
19
|
+
Vedeu::Presentation::Style.coerce(@style)
|
20
|
+
|
21
|
+
elsif self.is_a?(Vedeu::Views::Char) && name
|
22
|
+
Vedeu::Presentation::Style.coerce(interface.style)
|
23
|
+
|
24
|
+
elsif parent && present?(parent.style)
|
25
|
+
Vedeu::Presentation::Style.coerce(parent.style)
|
26
|
+
|
27
|
+
else
|
28
|
+
Vedeu::Presentation::Style.new
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Allows the setting of the style by coercing the given value
|
34
|
+
# into a {Vedeu::Presentation::Style}.
|
35
|
+
#
|
36
|
+
# @return [Vedeu::Presentation::Style]
|
37
|
+
def style=(value)
|
38
|
+
@_style = @style = Vedeu::Presentation::Style.coerce(value)
|
39
|
+
end
|
40
|
+
|
41
|
+
end # Style
|
42
|
+
|
43
|
+
end # Presentation
|
44
|
+
|
45
|
+
end # Vedeu
|
@@ -140,8 +140,8 @@ module Vedeu
|
|
140
140
|
|
141
141
|
end # Vedeu
|
142
142
|
|
143
|
-
require 'vedeu/
|
144
|
-
require 'vedeu/
|
145
|
-
require 'vedeu/
|
146
|
-
require 'vedeu/
|
147
|
-
require 'vedeu/
|
143
|
+
require 'vedeu/renderers/options'
|
144
|
+
require 'vedeu/renderers/file'
|
145
|
+
require 'vedeu/renderers/html'
|
146
|
+
require 'vedeu/renderers/json'
|
147
|
+
require 'vedeu/renderers/terminal'
|
File without changes
|
File without changes
|
File without changes
|
@@ -12,8 +12,12 @@ module Vedeu
|
|
12
12
|
# @return [Hash<Symbol => void>]
|
13
13
|
attr_writer :options
|
14
14
|
|
15
|
+
# Returns a boolean indicating whether the content should be
|
16
|
+
# compressed if compression is available.
|
17
|
+
#
|
18
|
+
# @return [Boolean]
|
15
19
|
def compress?
|
16
|
-
options[:compression] || false
|
20
|
+
options[:compression] || Vedeu::Configuration.compression? || false
|
17
21
|
end
|
18
22
|
|
19
23
|
private
|
File without changes
|
@@ -13,6 +13,7 @@ require 'vedeu/repositories/collection'
|
|
13
13
|
require 'vedeu/repositories/defaults'
|
14
14
|
require 'vedeu/repositories/repositories'
|
15
15
|
require 'vedeu/repositories/model'
|
16
|
+
require 'vedeu/repositories/parent'
|
16
17
|
require 'vedeu/repositories/store'
|
17
18
|
require 'vedeu/repositories/registerable'
|
18
19
|
require 'vedeu/repositories/repository'
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
module Repositories
|
4
|
+
|
5
|
+
# When included into a class, provides the mechanism to retrieve
|
6
|
+
# the parent object for the class if available.
|
7
|
+
#
|
8
|
+
module Parent
|
9
|
+
|
10
|
+
include Vedeu::Common
|
11
|
+
|
12
|
+
# @return [NilClass|void]
|
13
|
+
def parent
|
14
|
+
@_parent ||= present?(@parent) ? @parent : nil
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [NilClass|String|Symbol]
|
18
|
+
def name
|
19
|
+
@_name ||= if present?(@name)
|
20
|
+
@name
|
21
|
+
|
22
|
+
elsif parent && present?(parent.name)
|
23
|
+
parent.name
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end # Parent
|
29
|
+
|
30
|
+
end # Repositories
|
31
|
+
|
32
|
+
end # Vedeu
|
data/lib/vedeu/runtime/flags.rb
CHANGED
@@ -76,10 +76,15 @@ module Vedeu
|
|
76
76
|
#
|
77
77
|
# @return (see Vedeu::Interfaces::Repository#by_name)
|
78
78
|
def interface
|
79
|
-
Vedeu.interfaces.by_name(
|
79
|
+
Vedeu.interfaces.by_name(name)
|
80
80
|
end
|
81
81
|
alias_method :interface?, :interface
|
82
82
|
|
83
|
+
# @return [String|Symbol]
|
84
|
+
def name
|
85
|
+
options[:name]
|
86
|
+
end
|
87
|
+
|
83
88
|
# Returns the stream directives for the line.
|
84
89
|
#
|
85
90
|
# @param line [String]
|
data/lib/vedeu/version.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# View related models.
|
4
|
+
#
|
5
|
+
module Views
|
6
|
+
|
7
|
+
end # Views
|
8
|
+
|
9
|
+
end # Vedeu
|
10
|
+
|
11
|
+
require 'vedeu/views/chars'
|
12
|
+
require 'vedeu/views/char'
|
13
|
+
require 'vedeu/views/html_char'
|
14
|
+
require 'vedeu/views/streams'
|
15
|
+
require 'vedeu/views/stream'
|
16
|
+
require 'vedeu/views/lines'
|
17
|
+
require 'vedeu/views/line'
|
18
|
+
require 'vedeu/views/view_collection'
|
19
|
+
require 'vedeu/views/view'
|
20
|
+
require 'vedeu/views/composition'
|
@@ -2,14 +2,6 @@ module Vedeu
|
|
2
2
|
|
3
3
|
module Views
|
4
4
|
|
5
|
-
# A collection of {Vedeu::Views::Char} instances.
|
6
|
-
#
|
7
|
-
# @api private
|
8
|
-
#
|
9
|
-
class Chars < Vedeu::Repositories::Collection
|
10
|
-
|
11
|
-
end # Chars
|
12
|
-
|
13
5
|
# A Char represents a single character of the terminal. It is a
|
14
6
|
# container for the a single character in a
|
15
7
|
# {Vedeu::Views::Stream}.
|
@@ -20,12 +12,9 @@ module Vedeu
|
|
20
12
|
class Char
|
21
13
|
|
22
14
|
include Comparable
|
15
|
+
include Vedeu::Repositories::Parent
|
23
16
|
include Vedeu::Presentation
|
24
17
|
|
25
|
-
# @!attribute [r] attributes
|
26
|
-
# @return [Hash]
|
27
|
-
attr_reader :attributes
|
28
|
-
|
29
18
|
# @!attribute [rw] border
|
30
19
|
# @return [NilClass|Symbol]
|
31
20
|
attr_accessor :border
|
@@ -56,11 +45,22 @@ module Vedeu
|
|
56
45
|
# @option attributes value [String]
|
57
46
|
# @return [Vedeu::Views::Char]
|
58
47
|
def initialize(attributes = {})
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
48
|
+
defaults.merge!(attributes).each do |key, value|
|
49
|
+
instance_variable_set("@#{key}", value)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# @return [Hash<Symbol => void>]
|
54
|
+
def attributes
|
55
|
+
{
|
56
|
+
border: @border,
|
57
|
+
# colour: colour,
|
58
|
+
name: @name,
|
59
|
+
parent: @parent,
|
60
|
+
position: position,
|
61
|
+
style: @style,
|
62
|
+
value: value,
|
63
|
+
}
|
64
64
|
end
|
65
65
|
|
66
66
|
# @return [Boolean]
|
@@ -96,16 +96,15 @@ module Vedeu
|
|
96
96
|
|
97
97
|
# @return [Vedeu::Geometries::Position]
|
98
98
|
def position
|
99
|
-
@
|
99
|
+
@_position ||= Vedeu::Geometries::Position.coerce(@position)
|
100
100
|
end
|
101
101
|
|
102
102
|
# Sets the position of the Vedeu::Views::Char.
|
103
103
|
#
|
104
|
-
# @param value [Vedeu::Geometries::Position]
|
104
|
+
# @param value [Array<void>|Hash<void>|Vedeu::Geometries::Position]
|
105
105
|
# @return [Vedeu::Geometries::Position]
|
106
106
|
def position=(value)
|
107
|
-
@
|
108
|
-
.coerce(value)
|
107
|
+
@_position = @position = Vedeu::Geometries::Position.coerce(value)
|
109
108
|
end
|
110
109
|
|
111
110
|
# @return [String]
|
@@ -166,6 +165,19 @@ module Vedeu
|
|
166
165
|
}
|
167
166
|
end
|
168
167
|
|
168
|
+
# @return [Hash<Symbol => void>]
|
169
|
+
def defaults
|
170
|
+
{
|
171
|
+
border: nil,
|
172
|
+
colour: nil,
|
173
|
+
name: nil,
|
174
|
+
parent: nil,
|
175
|
+
position: nil,
|
176
|
+
style: nil,
|
177
|
+
value: '',
|
178
|
+
}
|
179
|
+
end
|
180
|
+
|
169
181
|
# @return [Hash<Symbol => String>]
|
170
182
|
def parent_to_hash
|
171
183
|
return {} unless parent
|