vedeu 0.4.13 → 0.4.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -1
- data/.travis.yml +2 -1
- data/Guardfile +6 -5
- data/README.md +3 -30
- data/Rakefile +5 -5
- data/bin/vedeu_drb_client +1 -1
- data/bin/vedeu_drb_server +91 -89
- data/bin/vedeu_test +4 -0
- data/config/rubocop_enabled.yml +5 -10
- data/examples/borders_app.rb +2 -1
- data/examples/colours_app.rb +13 -8
- data/examples/configuration_app.rb +3 -2
- data/examples/cursor_app.rb +16 -11
- data/examples/drb_app.rb +88 -89
- data/examples/focus_app.rb +31 -32
- data/examples/geometry_app.rb +2 -1
- data/examples/hello_world.rb +2 -1
- data/examples/lines_app.rb +2 -1
- data/examples/material_colours_app.rb +126 -0
- data/examples/typed_commands/typed_commands_app.rb +5 -1
- data/examples/view_templates_app/view_templates_app.rb +6 -3
- data/lib/vedeu/all.rb +1 -1
- data/lib/vedeu/api.rb +18 -10
- data/lib/vedeu/application.rb +0 -1
- data/lib/vedeu/bindings.rb +77 -16
- data/lib/vedeu/buffers/all.rb +2 -5
- data/lib/vedeu/buffers/buffer.rb +69 -25
- data/lib/vedeu/buffers/display_buffer.rb +3 -7
- data/lib/vedeu/configuration/all.rb +3 -6
- data/lib/vedeu/configuration/api.rb +28 -4
- data/lib/vedeu/configuration/cli.rb +9 -9
- data/lib/vedeu/configuration/configuration.rb +11 -7
- data/lib/vedeu/cursor/all.rb +3 -6
- data/lib/vedeu/cursor/cursor.rb +22 -14
- data/lib/vedeu/cursor/move.rb +32 -22
- data/lib/vedeu/cursor/refresh_cursor.rb +1 -1
- data/lib/vedeu/debug.rb +2 -1
- data/lib/vedeu/distributed/client.rb +1 -7
- data/lib/vedeu/distributed/server.rb +0 -4
- data/lib/vedeu/distributed/subprocess.rb +1 -1
- data/lib/vedeu/distributed/templates/default_configuration.vedeu +1 -1
- data/lib/vedeu/distributed/test_application.rb +3 -5
- data/lib/vedeu/distributed/uri.rb +2 -2
- data/lib/vedeu/dsl/all.rb +6 -6
- data/lib/vedeu/dsl/components/all.rb +0 -3
- data/lib/vedeu/dsl/components/border.rb +20 -12
- data/lib/vedeu/dsl/components/geometry.rb +68 -3
- data/lib/vedeu/dsl/components/keymap.rb +1 -2
- data/lib/vedeu/dsl/composition.rb +8 -1
- data/lib/vedeu/dsl/interface.rb +61 -11
- data/lib/vedeu/dsl/line.rb +12 -12
- data/lib/vedeu/dsl/shared/all.rb +4 -7
- data/lib/vedeu/dsl/shared/colour.rb +2 -2
- data/lib/vedeu/dsl/shared/text.rb +2 -35
- data/lib/vedeu/dsl/shared/use.rb +2 -2
- data/lib/vedeu/dsl/view.rb +4 -4
- data/lib/vedeu/events/all.rb +3 -5
- data/lib/vedeu/events/event.rb +5 -5
- data/lib/vedeu/geometry/all.rb +11 -16
- data/lib/vedeu/geometry/area.rb +2 -5
- data/lib/vedeu/geometry/canvas.rb +12 -16
- data/lib/vedeu/geometry/dimension.rb +20 -22
- data/lib/vedeu/geometry/geometry.rb +28 -30
- data/lib/vedeu/geometry/grid.rb +1 -1
- data/lib/vedeu/geometry/index_position.rb +7 -0
- data/lib/vedeu/geometry/null_geometry.rb +61 -0
- data/lib/vedeu/geometry/position.rb +0 -3
- data/lib/vedeu/geometry/position_index.rb +7 -0
- data/lib/vedeu/geometry/position_validator.rb +44 -33
- data/lib/vedeu/input/all.rb +5 -4
- data/lib/vedeu/input/keymap.rb +0 -1
- data/lib/vedeu/input/mapper.rb +1 -3
- data/lib/vedeu/launcher.rb +6 -7
- data/lib/vedeu/main_loop.rb +1 -2
- data/lib/vedeu/models/all.rb +1 -0
- data/lib/vedeu/models/cell.rb +5 -8
- data/lib/vedeu/models/char.rb +50 -15
- data/lib/vedeu/models/composition.rb +8 -1
- data/lib/vedeu/models/focus.rb +4 -4
- data/lib/vedeu/models/group.rb +3 -3
- data/lib/vedeu/models/interface.rb +62 -46
- data/lib/vedeu/models/line.rb +1 -1
- data/lib/vedeu/models/null.rb +48 -0
- data/lib/vedeu/models/stream.rb +5 -5
- data/lib/vedeu/output/all.rb +20 -30
- data/lib/vedeu/output/border.rb +93 -40
- data/lib/vedeu/output/clear.rb +100 -15
- data/lib/vedeu/output/colour.rb +56 -12
- data/lib/vedeu/output/compressor.rb +59 -0
- data/lib/vedeu/output/html_char.rb +4 -2
- data/lib/vedeu/output/null_border.rb +16 -4
- data/lib/vedeu/output/output.rb +13 -21
- data/lib/vedeu/output/presentation.rb +28 -23
- data/lib/vedeu/output/refresh.rb +2 -2
- data/lib/vedeu/output/renderers/all.rb +80 -3
- data/lib/vedeu/output/renderers/file_renderer.rb +38 -2
- data/lib/vedeu/output/renderers/html_renderer.rb +6 -4
- data/lib/vedeu/output/renderers/json_renderer.rb +52 -0
- data/lib/vedeu/output/renderers/null_renderer.rb +14 -0
- data/lib/vedeu/output/renderers/terminal_renderer.rb +2 -12
- data/lib/vedeu/output/style.rb +33 -3
- data/lib/vedeu/output/text.rb +98 -1
- data/lib/vedeu/output/translator.rb +30 -7
- data/lib/vedeu/output/viewport.rb +43 -79
- data/lib/vedeu/output/wordwrap.rb +4 -4
- data/lib/vedeu/repositories/all.rb +22 -179
- data/lib/vedeu/repositories/collection.rb +11 -13
- data/lib/vedeu/repositories/collections/all.rb +8 -0
- data/lib/vedeu/repositories/collections/chars.rb +9 -0
- data/lib/vedeu/repositories/collections/events.rb +9 -0
- data/lib/vedeu/repositories/collections/interfaces.rb +9 -0
- data/lib/vedeu/repositories/collections/keys.rb +9 -0
- data/lib/vedeu/repositories/collections/lines.rb +9 -0
- data/lib/vedeu/repositories/collections/streams.rb +9 -0
- data/lib/vedeu/repositories/model.rb +7 -2
- data/lib/vedeu/repositories/repositories/all.rb +14 -0
- data/lib/vedeu/repositories/repositories/background_colours.rb +14 -0
- data/lib/vedeu/repositories/repositories/borders.rb +38 -0
- data/lib/vedeu/repositories/repositories/buffers.rb +36 -0
- data/lib/vedeu/repositories/repositories/colours.rb +63 -0
- data/lib/vedeu/repositories/repositories/cursors.rb +29 -0
- data/lib/vedeu/repositories/repositories/events_repository.rb +24 -0
- data/lib/vedeu/repositories/repositories/foreground_colours.rb +14 -0
- data/lib/vedeu/repositories/repositories/geometries.rb +37 -0
- data/lib/vedeu/repositories/repositories/groups.rb +24 -0
- data/lib/vedeu/repositories/repositories/interfaces_repository.rb +24 -0
- data/lib/vedeu/repositories/repositories/keymaps.rb +24 -0
- data/lib/vedeu/repositories/repositories/menus.rb +24 -0
- data/lib/vedeu/repositories/repository.rb +29 -47
- data/lib/vedeu/storage/all.rb +6 -0
- data/lib/vedeu/storage/associative_store.rb +47 -0
- data/lib/vedeu/storage/conveyor_store.rb +69 -0
- data/lib/vedeu/storage/fifo_store.rb +37 -0
- data/lib/vedeu/storage/store.rb +58 -0
- data/lib/vedeu/support/all.rb +5 -10
- data/lib/vedeu/support/common.rb +0 -8
- data/lib/vedeu/support/log.rb +13 -24
- data/lib/vedeu/support/template.rb +4 -1
- data/lib/vedeu/support/terminal.rb +10 -10
- data/lib/vedeu/support/trace.rb +15 -88
- data/lib/vedeu/support/visibility.rb +73 -0
- data/lib/vedeu.rb +37 -0
- data/test/lib/vedeu/api_test.rb +7 -3
- data/test/lib/vedeu/application_test.rb +9 -3
- data/test/lib/vedeu/bindings_test.rb +21 -0
- data/test/lib/vedeu/buffers/buffer_test.rb +110 -134
- data/test/lib/vedeu/buffers/display_buffer_test.rb +8 -0
- data/test/lib/vedeu/configuration/api_test.rb +5 -1
- data/test/lib/vedeu/configuration/configuration_test.rb +4 -6
- data/test/lib/vedeu/cursor/cursor_test.rb +25 -17
- data/test/lib/vedeu/cursor/move_test.rb +7 -7
- data/test/lib/vedeu/distributed/client_test.rb +1 -1
- data/test/lib/vedeu/distributed/subprocess_test.rb +3 -1
- data/test/lib/vedeu/distributed/uri_test.rb +5 -5
- data/test/lib/vedeu/dsl/components/geometry_test.rb +43 -0
- data/test/lib/vedeu/dsl/components/keymap_test.rb +1 -1
- data/test/lib/vedeu/dsl/composition_test.rb +6 -5
- data/test/lib/vedeu/dsl/interface_test.rb +81 -16
- data/test/lib/vedeu/dsl/shared/colour_test.rb +4 -4
- data/test/lib/vedeu/dsl/shared/text_test.rb +87 -9
- data/test/lib/vedeu/dsl/stream_test.rb +1 -1
- data/test/lib/vedeu/events/event_test.rb +3 -1
- data/test/lib/vedeu/events/trigger_test.rb +8 -4
- data/test/lib/vedeu/geometry/dimension_test.rb +1 -1
- data/test/lib/vedeu/geometry/geometry_test.rb +5 -3
- data/test/lib/vedeu/geometry/index_position_test.rb +30 -7
- data/test/lib/vedeu/geometry/null_geometry_test.rb +57 -0
- data/test/lib/vedeu/geometry/position_index_test.rb +14 -0
- data/test/lib/vedeu/geometry/position_validator_test.rb +17 -3
- data/test/lib/vedeu/input/keymap_test.rb +3 -1
- data/test/lib/vedeu/input/mapper_test.rb +8 -4
- data/test/lib/vedeu/launcher_test.rb +1 -1
- data/test/lib/vedeu/models/cell_test.rb +10 -8
- data/test/lib/vedeu/models/char_test.rb +52 -28
- data/test/lib/vedeu/models/composition_test.rb +26 -4
- data/test/lib/vedeu/models/group_test.rb +11 -5
- data/test/lib/vedeu/models/interface_test.rb +32 -19
- data/test/lib/vedeu/models/line_test.rb +21 -25
- data/test/lib/vedeu/models/menu_test.rb +10 -6
- data/test/lib/vedeu/models/null_test.rb +66 -0
- data/test/lib/vedeu/models/stream_test.rb +13 -10
- data/test/lib/vedeu/output/border_test.rb +29 -8
- data/test/lib/vedeu/output/clear_test.rb +23 -4
- data/test/lib/vedeu/output/colour_test.rb +20 -4
- data/test/lib/vedeu/output/compressor_test.rb +43 -0
- data/test/lib/vedeu/output/html_char_test.rb +29 -17
- data/test/lib/vedeu/output/null_border_test.rb +2 -1
- data/test/lib/vedeu/output/output_test.rb +20 -30
- data/test/lib/vedeu/output/presentation_test.rb +39 -16
- data/test/lib/vedeu/output/refresh_test.rb +14 -10
- data/test/lib/vedeu/output/renderers/all_test.rb +96 -0
- data/test/lib/vedeu/output/renderers/file_renderer_test.rb +1 -1
- data/test/lib/vedeu/output/renderers/html_renderer_test.rb +13 -9
- data/test/lib/vedeu/output/renderers/json_renderer_test.rb +52 -0
- data/test/lib/vedeu/output/renderers/null_renderer_test.rb +19 -0
- data/test/lib/vedeu/output/style_test.rb +41 -1
- data/test/lib/vedeu/output/text_test.rb +61 -10
- data/test/lib/vedeu/output/translator_test.rb +14 -0
- data/test/lib/vedeu/output/viewport_test.rb +22 -3
- data/test/lib/vedeu/output/virtual_terminal_test.rb +3 -3
- data/test/lib/vedeu/output/wordwrap_test.rb +58 -45
- data/test/lib/vedeu/repositories/collections/chars_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/events_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/interfaces_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/keys_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/lines_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/streams_test.rb +16 -0
- data/test/lib/vedeu/repositories/repositories/background_colours_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/borders_test.rb +51 -0
- data/test/lib/vedeu/repositories/repositories/buffers_test.rb +52 -0
- data/test/lib/vedeu/repositories/repositories/colours_test.rb +16 -0
- data/test/lib/vedeu/repositories/repositories/cursors_test.rb +39 -0
- data/test/lib/vedeu/repositories/repositories/events_repository_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/foreground_colours_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/geometries_test.rb +42 -0
- data/test/lib/vedeu/repositories/repositories/groups_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/interfaces_repositories_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/keymaps_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/menus_test.rb +17 -0
- data/test/lib/vedeu/repositories/repository_test.rb +16 -36
- data/test/lib/vedeu/storage/associative_store_test.rb +69 -0
- data/test/lib/vedeu/storage/conveyor_store_test.rb +135 -0
- data/test/lib/vedeu/storage/fifo_store_test.rb +47 -0
- data/test/lib/vedeu/storage/store_test.rb +123 -0
- data/test/lib/vedeu/support/common_test.rb +0 -9
- data/test/lib/vedeu/support/terminal_test.rb +78 -55
- data/test/lib/vedeu/support/visibility_test.rb +80 -0
- data/test/test_helper.rb +13 -11
- data/vedeu.gemspec +4 -3
- metadata +92 -32
- data/lib/vedeu/cursor/toggle.rb +0 -55
- data/lib/vedeu/exceptions.rb +0 -37
- data/lib/vedeu/geometry/centre.rb +0 -85
- data/lib/vedeu/geometry/content.rb +0 -70
- data/lib/vedeu/geometry/limit.rb +0 -58
- data/lib/vedeu/output/compositor.rb +0 -62
- data/lib/vedeu/repositories/collections.rb +0 -41
- data/lib/vedeu/support/coercions.rb +0 -60
- data/lib/vedeu/support/sentence.rb +0 -91
- data/lib/vedeu/support/visible.rb +0 -90
- data/test/lib/vedeu/cursor/toggle_test.rb +0 -63
- data/test/lib/vedeu/geometry/centre_test.rb +0 -58
- data/test/lib/vedeu/geometry/content_test.rb +0 -98
- data/test/lib/vedeu/geometry/limit_test.rb +0 -30
- data/test/lib/vedeu/output/compositor_test.rb +0 -48
- data/test/lib/vedeu/repositories/all_test.rb +0 -135
- data/test/lib/vedeu/repositories/collections_test.rb +0 -71
- data/test/lib/vedeu/support/coercions_test.rb +0 -84
- data/test/lib/vedeu/support/sentence_test.rb +0 -56
- data/test/lib/vedeu/support/visible_test.rb +0 -161
@@ -11,23 +11,31 @@ module Vedeu
|
|
11
11
|
extend Forwardable
|
12
12
|
|
13
13
|
def_delegators :interface,
|
14
|
-
:geometry,
|
15
14
|
:lines,
|
16
15
|
:lines?,
|
17
|
-
:
|
16
|
+
:name,
|
17
|
+
:visible?
|
18
|
+
|
19
|
+
def_delegators :border,
|
20
|
+
:bx,
|
21
|
+
:by,
|
22
|
+
:height,
|
23
|
+
:width
|
18
24
|
|
19
25
|
def_delegators :cursor,
|
20
26
|
:ox,
|
21
27
|
:oy
|
22
28
|
|
23
|
-
def_delegators :geometry,
|
24
|
-
:height,
|
25
|
-
:width
|
26
|
-
|
27
29
|
# @param interface [Vedeu::Interface]
|
28
30
|
# @return [Array<Array<Vedeu::Char>>]
|
29
31
|
def self.render(interface)
|
30
|
-
|
32
|
+
if interface.visible?
|
33
|
+
new(interface).render
|
34
|
+
|
35
|
+
else
|
36
|
+
[]
|
37
|
+
|
38
|
+
end
|
31
39
|
end
|
32
40
|
|
33
41
|
# Returns an instance of Vedeu::Viewport.
|
@@ -43,20 +51,17 @@ module Vedeu
|
|
43
51
|
#
|
44
52
|
# @return [Array<Array<String>>]
|
45
53
|
def render
|
46
|
-
|
54
|
+
return [] unless visible?
|
47
55
|
|
48
|
-
|
56
|
+
Vedeu.log(type: :output, message: "Rendering: '#{name}'")
|
49
57
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
interface.border.by,
|
55
|
-
interface.border.bx]
|
58
|
+
out = []
|
59
|
+
show[0...height].each_with_index do |line, iy|
|
60
|
+
line[0...width].each_with_index do |column, ix|
|
61
|
+
column.position = IndexPosition[iy, ix, by, bx]
|
56
62
|
out << column
|
57
63
|
end
|
58
64
|
end
|
59
|
-
|
60
65
|
out
|
61
66
|
end
|
62
67
|
|
@@ -97,7 +102,7 @@ module Vedeu
|
|
97
102
|
#
|
98
103
|
# @return [Range]
|
99
104
|
def rows
|
100
|
-
top..(top + (height - 1))
|
105
|
+
top..(top + (geometry.height - 1))
|
101
106
|
end
|
102
107
|
|
103
108
|
# Using the current cursor's x position, return a range of visible columns.
|
@@ -110,87 +115,46 @@ module Vedeu
|
|
110
115
|
#
|
111
116
|
# @return [Range]
|
112
117
|
def columns
|
113
|
-
left..(left + (width - 1))
|
118
|
+
left..(left + (geometry.width - 1))
|
114
119
|
end
|
115
120
|
|
116
|
-
# Returns the offset for the content
|
121
|
+
# Returns the offset for the content (the number of columns to change the
|
122
|
+
# viewport by on the x axis) determined by the offset (the cursor's x
|
123
|
+
# offset position).
|
117
124
|
#
|
118
125
|
# @return [Fixnum]
|
119
126
|
def left
|
120
|
-
@left ||=
|
127
|
+
@left ||= (ox >= width && ((ox - width) > 0)) ? ox - width : 0
|
121
128
|
end
|
122
129
|
|
123
|
-
# Returns the offset for the content
|
130
|
+
# Returns the offset for the content (the number of rows to change the
|
131
|
+
# viewport by on the y axis) determined by the offset (the cursor's y offset
|
132
|
+
# position.
|
124
133
|
#
|
125
134
|
# @return [Fixnum]
|
126
135
|
def top
|
127
|
-
@top ||=
|
128
|
-
end
|
129
|
-
|
130
|
-
# Returns a boolean indicating whether the x offset is greater than or equal
|
131
|
-
# to the bordered width.
|
132
|
-
#
|
133
|
-
# @return [Boolean]
|
134
|
-
def reposition_x?
|
135
|
-
ox >= bordered_width
|
136
|
+
@top ||= (oy >= height && ((oy - height) > 0)) ? oy - height : 0
|
136
137
|
end
|
137
138
|
|
138
|
-
#
|
139
|
-
# to the bordered height.
|
140
|
-
#
|
141
|
-
# @return [Boolean]
|
142
|
-
def reposition_y?
|
143
|
-
oy >= bordered_height
|
144
|
-
end
|
145
|
-
|
146
|
-
# Returns the number of columns to change the viewport by on the x axis,
|
147
|
-
# determined by the position of the x offset.
|
148
|
-
#
|
149
|
-
# @return [Fixnum]
|
150
|
-
def reposition_x
|
151
|
-
((ox - bordered_width) <= 0) ? 0 : (ox - bordered_width)
|
152
|
-
end
|
153
|
-
|
154
|
-
# Returns the number of rows to change the viewport by on the y axis,
|
155
|
-
# determined by the position of the y offset.
|
156
|
-
#
|
157
|
-
# @return [Fixnum]
|
158
|
-
def reposition_y
|
159
|
-
((oy - bordered_height) <= 0) ? 0 : (oy - bordered_height)
|
160
|
-
end
|
161
|
-
|
162
|
-
# When the viewport has a border, we need to account for that in our
|
163
|
-
# redrawing.
|
164
|
-
#
|
165
|
-
# @return [Fixnum]
|
166
|
-
def bordered_width
|
167
|
-
return border.width if border?
|
168
|
-
|
169
|
-
width
|
170
|
-
end
|
171
|
-
|
172
|
-
# When the viewport has a border, we need to account for that in our
|
173
|
-
# redrawing.
|
139
|
+
# Return the border associated with the interface we are drawing.
|
174
140
|
#
|
175
|
-
# @return [
|
176
|
-
def
|
177
|
-
|
178
|
-
|
179
|
-
height
|
141
|
+
# @return [Vedeu::Border|Vedeu::NullBorder]
|
142
|
+
def border
|
143
|
+
@border ||= Vedeu.borders.by_name(name)
|
180
144
|
end
|
181
145
|
|
182
|
-
#
|
146
|
+
# Fetch the cursor associated with the interface we are drawing.
|
183
147
|
#
|
184
|
-
# @return [Vedeu::
|
185
|
-
def
|
186
|
-
@
|
148
|
+
# @return [Vedeu::Cursor]
|
149
|
+
def cursor
|
150
|
+
@cursor ||= Vedeu.cursors.by_name(name)
|
187
151
|
end
|
188
152
|
|
189
|
-
#
|
153
|
+
# Return the geometry associated with the interface we are drawing.
|
190
154
|
#
|
191
|
-
# @return [
|
192
|
-
def
|
193
|
-
Vedeu.
|
155
|
+
# @return [Vedeu::Geometry|Vedeu::NullGeometry]
|
156
|
+
def geometry
|
157
|
+
@geometry || Vedeu.geometries.by_name(name)
|
194
158
|
end
|
195
159
|
|
196
160
|
end # Viewport
|
@@ -15,7 +15,7 @@ module Vedeu
|
|
15
15
|
# @param options [Hash]
|
16
16
|
# @option options ellipsis [String] For when using mode `:prune`.
|
17
17
|
# @option options mode [Symbol] One of :default, :prune, :wrap
|
18
|
-
# @option options width [Fixnum] The width
|
18
|
+
# @option options width [Fixnum] The width to prune or wrap to.
|
19
19
|
# @return [Vedeu::Wordwrap]
|
20
20
|
def initialize(text, options = {})
|
21
21
|
@text = text
|
@@ -24,7 +24,7 @@ module Vedeu
|
|
24
24
|
|
25
25
|
# @return [Vedeu::Lines]
|
26
26
|
def content
|
27
|
-
case
|
27
|
+
case mode
|
28
28
|
when :prune then to_line_objects(prune)
|
29
29
|
when :wrap then to_line_objects(wrap)
|
30
30
|
else
|
@@ -63,7 +63,7 @@ module Vedeu
|
|
63
63
|
|
64
64
|
if (line_length += word_length) >= width
|
65
65
|
line_length = word_length
|
66
|
-
processed
|
66
|
+
processed << reformatted
|
67
67
|
reformatted = []
|
68
68
|
end
|
69
69
|
|
@@ -92,7 +92,7 @@ module Vedeu
|
|
92
92
|
# @return [Vedeu::Lines]
|
93
93
|
def to_line_objects(text_as_lines)
|
94
94
|
line_objects = Array(text_as_lines).map do |text_line|
|
95
|
-
stream = Vedeu::Stream.new(
|
95
|
+
stream = Vedeu::Stream.new(value: text_line)
|
96
96
|
line = Vedeu::Line.new
|
97
97
|
stream.parent = line
|
98
98
|
line.add(stream)
|
@@ -1,196 +1,39 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
require_relative 'collection'
|
2
|
+
require_relative 'collections/all'
|
3
|
+
require_relative 'model'
|
4
|
+
require_relative 'repositories/all'
|
5
|
+
require_relative 'repository'
|
5
6
|
|
6
7
|
module Vedeu
|
7
8
|
|
8
|
-
#
|
9
|
-
# instance.
|
9
|
+
# Provides all registered repositories.
|
10
10
|
#
|
11
|
-
|
11
|
+
module Repositories
|
12
12
|
|
13
|
-
|
14
|
-
def self.borders
|
15
|
-
@borders ||= Vedeu::Borders.new(Vedeu::Border)
|
16
|
-
end
|
17
|
-
|
18
|
-
end # Borders
|
19
|
-
|
20
|
-
# Allows the storing of view buffers.
|
21
|
-
#
|
22
|
-
class Buffers < Repository
|
23
|
-
|
24
|
-
# @return [Vedeu::Buffers]
|
25
|
-
def self.buffers
|
26
|
-
@buffers ||= Vedeu::Buffers.new(Vedeu::Buffer)
|
27
|
-
end
|
28
|
-
|
29
|
-
end # Buffers
|
30
|
-
|
31
|
-
# Allows the storing of HTML/CSS colours and their respective escape
|
32
|
-
# sequences.
|
33
|
-
#
|
34
|
-
class Colours
|
13
|
+
extend self
|
35
14
|
|
36
|
-
#
|
37
|
-
# @return [
|
38
|
-
|
39
|
-
|
40
|
-
# Returns a new instance of Vedeu::Colours.
|
41
|
-
#
|
42
|
-
# @return [Vedeu::Colours]
|
43
|
-
def initialize
|
44
|
-
@storage = {}
|
45
|
-
end
|
46
|
-
|
47
|
-
# Registers a colour with respective escape sequence.
|
48
|
-
#
|
49
|
-
# @return [String]
|
50
|
-
def register(colour, escape_sequence)
|
51
|
-
storage.store(colour, escape_sequence)
|
15
|
+
# @param klass [Class]
|
16
|
+
# @return [Set]
|
17
|
+
def register(klass)
|
18
|
+
storage.add(klass)
|
52
19
|
end
|
53
20
|
|
54
|
-
#
|
55
|
-
#
|
56
|
-
# @return [Boolean]
|
57
|
-
def registered?(colour)
|
58
|
-
storage.key?(colour)
|
59
|
-
end
|
60
|
-
|
61
|
-
# Removes all stored colours.
|
62
|
-
#
|
63
|
-
# @return [Hash]
|
21
|
+
# @return [TrueClass]
|
64
22
|
def reset!
|
65
|
-
storage.
|
66
|
-
end
|
67
|
-
|
68
|
-
# Retrieves a registered colour.
|
69
|
-
#
|
70
|
-
# @return [String]
|
71
|
-
def retrieve(colour)
|
72
|
-
storage.fetch(colour, '')
|
73
|
-
end
|
74
|
-
|
75
|
-
# Retrieves a registered colour, or registers the colour with its respective
|
76
|
-
# escape sequence.
|
77
|
-
#
|
78
|
-
# @return [String]
|
79
|
-
def retrieve_or_register(colour, escape_sequence)
|
80
|
-
if registered?(colour)
|
81
|
-
retrieve(colour)
|
82
|
-
|
83
|
-
else
|
84
|
-
register(colour, escape_sequence)
|
85
|
-
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
end # Colours
|
90
|
-
|
91
|
-
# Store background colour escape sequences by HTML/CSS code.
|
92
|
-
#
|
93
|
-
class BackgroundColours < Colours
|
94
|
-
|
95
|
-
# @return [Vedeu::BackgroundColours]
|
96
|
-
def self.background_colours
|
97
|
-
@background_colours ||= new
|
98
|
-
end
|
99
|
-
|
100
|
-
end # BackgroundColours
|
101
|
-
|
102
|
-
# Store foreground colour escape sequences by HTML/CSS code.
|
103
|
-
#
|
104
|
-
class ForegroundColours < Colours
|
23
|
+
storage.map(&:repository).map { |repository| repository.send(:reset) }
|
105
24
|
|
106
|
-
|
107
|
-
def self.foreground_colours
|
108
|
-
@foreground_colours ||= new
|
25
|
+
true
|
109
26
|
end
|
110
27
|
|
111
|
-
|
28
|
+
private
|
112
29
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
def self.cursors
|
119
|
-
@cursors ||= Vedeu::Cursors.new(Vedeu::Cursor)
|
120
|
-
end
|
121
|
-
|
122
|
-
# @return [Vedeu::Cursor]
|
123
|
-
def self.cursor
|
124
|
-
cursors.current
|
125
|
-
end
|
126
|
-
|
127
|
-
end # Cursors
|
128
|
-
|
129
|
-
# Allows the storing of events.
|
130
|
-
#
|
131
|
-
class EventsRepository < Repository
|
132
|
-
|
133
|
-
# @return [Vedeu::EventsRepository]
|
134
|
-
def self.events
|
135
|
-
@events ||= Vedeu::EventsRepository.new(Vedeu::Events)
|
136
|
-
end
|
137
|
-
|
138
|
-
end # EventsRepository
|
139
|
-
|
140
|
-
# Allows the storing of interface/view geometry independent of the interface
|
141
|
-
# instance.
|
142
|
-
#
|
143
|
-
class Geometries < Repository
|
144
|
-
|
145
|
-
# @return [Vedeu::Geometries]
|
146
|
-
def self.geometries
|
147
|
-
@geometries ||= Vedeu::Geometries.new(Vedeu::Geometry)
|
148
|
-
end
|
149
|
-
|
150
|
-
end # Geometries
|
151
|
-
|
152
|
-
# Allows the storing of view groups.
|
153
|
-
#
|
154
|
-
class Groups < Repository
|
155
|
-
|
156
|
-
# @return [Vedeu::Groups]
|
157
|
-
def self.groups
|
158
|
-
@groups ||= Vedeu::Groups.new(Vedeu::Group)
|
159
|
-
end
|
160
|
-
|
161
|
-
end # Groups
|
162
|
-
|
163
|
-
# Allows the storing of interfaces and views.
|
164
|
-
#
|
165
|
-
class InterfacesRepository < Repository
|
166
|
-
|
167
|
-
# @return [Vedeu::InterfacesRepository]
|
168
|
-
def self.interfaces
|
169
|
-
@interfaces ||= Vedeu::InterfacesRepository.new(Vedeu::Interface)
|
170
|
-
end
|
171
|
-
|
172
|
-
end # InterfacesRepository
|
173
|
-
|
174
|
-
# Allows the storing of keymaps.
|
175
|
-
#
|
176
|
-
class Keymaps < Repository
|
177
|
-
|
178
|
-
# @return [Vedeu::Keymaps]
|
179
|
-
def self.keymaps
|
180
|
-
@keymaps ||= Vedeu::Keymaps.new(Vedeu::Keymap)
|
181
|
-
end
|
182
|
-
|
183
|
-
end # Keymaps
|
184
|
-
|
185
|
-
# Allows the storing of menus by name.
|
186
|
-
#
|
187
|
-
class Menus < Repository
|
188
|
-
|
189
|
-
# @return [Vedeu::Menus]
|
190
|
-
def self.menus
|
191
|
-
@menus ||= Vedeu::Menus.new(Vedeu::Menu)
|
30
|
+
# Access to the storage for this repository.
|
31
|
+
#
|
32
|
+
# @return [Array]
|
33
|
+
def storage
|
34
|
+
@storage ||= Set.new
|
192
35
|
end
|
193
36
|
|
194
|
-
end
|
37
|
+
end
|
195
38
|
|
196
39
|
end # Vedeu
|
@@ -7,6 +7,11 @@ module Vedeu
|
|
7
7
|
|
8
8
|
include Enumerable
|
9
9
|
|
10
|
+
# @!attribute [r] collection
|
11
|
+
# @return [Array|Vedeu::Collection]
|
12
|
+
attr_reader :collection
|
13
|
+
alias_method :all, :collection
|
14
|
+
|
10
15
|
# @!attribute [rw] parent
|
11
16
|
# @return [Fixnum]
|
12
17
|
attr_accessor :parent
|
@@ -20,7 +25,7 @@ module Vedeu
|
|
20
25
|
# @param name [String|NilClass]
|
21
26
|
# @return [Vedeu::Collection]
|
22
27
|
def self.coerce(collection = [], parent = nil, name = nil)
|
23
|
-
if collection.
|
28
|
+
if collection.is_a?(Vedeu::Collection)
|
24
29
|
collection
|
25
30
|
|
26
31
|
else
|
@@ -46,7 +51,7 @@ module Vedeu
|
|
46
51
|
# @param value [Fixnum]
|
47
52
|
# @return [void]
|
48
53
|
def [](value)
|
49
|
-
|
54
|
+
collection[value]
|
50
55
|
end
|
51
56
|
|
52
57
|
# Adds an entry to the collection.
|
@@ -58,40 +63,33 @@ module Vedeu
|
|
58
63
|
end
|
59
64
|
alias_method :<<, :add
|
60
65
|
|
61
|
-
# Returns the whole collection.
|
62
|
-
#
|
63
|
-
# @return [Array]
|
64
|
-
def all
|
65
|
-
@collection
|
66
|
-
end
|
67
|
-
|
68
66
|
# Provides iteration over the collection.
|
69
67
|
#
|
70
68
|
# @param block [Proc]
|
71
69
|
# @return [Enumerator]
|
72
70
|
def each(&block)
|
73
|
-
|
71
|
+
collection.each(&block)
|
74
72
|
end
|
75
73
|
|
76
74
|
# Returns a boolean indicating whether the collection is empty.
|
77
75
|
#
|
78
76
|
# @return [Boolean]
|
79
77
|
def empty?
|
80
|
-
|
78
|
+
collection.empty?
|
81
79
|
end
|
82
80
|
|
83
81
|
# Returns the size of the collection.
|
84
82
|
#
|
85
83
|
# @return [Fixnum]
|
86
84
|
def size
|
87
|
-
|
85
|
+
collection.size
|
88
86
|
end
|
89
87
|
|
90
88
|
# Returns the collection as a String.
|
91
89
|
#
|
92
90
|
# @return [String]
|
93
91
|
def to_s
|
94
|
-
|
92
|
+
collection.map(&:to_s).join
|
95
93
|
end
|
96
94
|
|
97
95
|
end # Collection
|
@@ -5,9 +5,9 @@ module Vedeu
|
|
5
5
|
#
|
6
6
|
module Model
|
7
7
|
|
8
|
-
# @!attribute [
|
8
|
+
# @!attribute [rw] repository
|
9
9
|
# @return [Vedeu::Repository]
|
10
|
-
|
10
|
+
attr_accessor :repository
|
11
11
|
|
12
12
|
# When {Vedeu::Model} is included in a class, the methods within this module
|
13
13
|
# are included as class methods on that class.
|
@@ -40,6 +40,11 @@ module Vedeu
|
|
40
40
|
alias_method :member, :child
|
41
41
|
alias_method :collection, :child
|
42
42
|
|
43
|
+
def repository(klass, as:)
|
44
|
+
self.repository = as
|
45
|
+
klass.register(as, self)
|
46
|
+
end
|
47
|
+
|
43
48
|
private
|
44
49
|
|
45
50
|
# The default values for a new instance of this class.
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'vedeu/repositories/repository'
|
2
|
+
|
3
|
+
require_relative 'colours'
|
4
|
+
require_relative 'background_colours'
|
5
|
+
require_relative 'foreground_colours'
|
6
|
+
require_relative 'borders'
|
7
|
+
require_relative 'buffers'
|
8
|
+
require_relative 'cursors'
|
9
|
+
require_relative 'events_repository'
|
10
|
+
require_relative 'geometries'
|
11
|
+
require_relative 'groups'
|
12
|
+
require_relative 'interfaces_repository'
|
13
|
+
require_relative 'keymaps'
|
14
|
+
require_relative 'menus'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# Store background colour escape sequences by HTML/CSS code.
|
4
|
+
#
|
5
|
+
class BackgroundColours < Colours
|
6
|
+
|
7
|
+
# @return [Vedeu::BackgroundColours]
|
8
|
+
def self.background_colours
|
9
|
+
@background_colours ||= new
|
10
|
+
end
|
11
|
+
|
12
|
+
end # BackgroundColours
|
13
|
+
|
14
|
+
end # Vedeu
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# Allows the storing of interface/view borders independent of the interface
|
4
|
+
# instance.
|
5
|
+
#
|
6
|
+
class Borders < Repository
|
7
|
+
|
8
|
+
# @return [Vedeu::Borders]
|
9
|
+
def self.borders
|
10
|
+
@borders ||= reset! # Vedeu::Borders.new(Vedeu::Border)
|
11
|
+
end
|
12
|
+
|
13
|
+
# @return [Vedeu::Borders]
|
14
|
+
def self.repository
|
15
|
+
Vedeu.borders
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [Vedeu::Borders]
|
19
|
+
def self.reset!
|
20
|
+
@borders = Vedeu::Borders.register_repository(Vedeu::Border)
|
21
|
+
end
|
22
|
+
|
23
|
+
# @param name [String] The name of the stored border.
|
24
|
+
# @return [Vedeu::Border|Vedeu::NullBorder|NilClass]
|
25
|
+
def by_name(name)
|
26
|
+
if registered?(name)
|
27
|
+
find(name)
|
28
|
+
|
29
|
+
elsif Vedeu.interfaces.registered?(name)
|
30
|
+
interface = Vedeu.interfaces.find(name)
|
31
|
+
Vedeu::NullBorder.new(interface)
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end # Borders
|
37
|
+
|
38
|
+
end # Vedeu
|