vedeu 0.8.10 → 0.8.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +0 -1
- data/docs/api.md +1 -1
- data/docs/dsl/by_method/add_command.md +1 -0
- data/docs/dsl/by_method/add_keypress.md +1 -0
- data/docs/dsl/by_method/all_commands.md +1 -0
- data/docs/dsl/by_method/all_keypresses.md +1 -0
- data/docs/dsl/by_method/background_colours.md +1 -0
- data/docs/dsl/by_method/bind.md +1 -0
- data/docs/dsl/by_method/bind_alias.md +1 -0
- data/docs/dsl/by_method/borders.md +1 -0
- data/docs/dsl/by_method/bottom.md +1 -0
- data/docs/dsl/by_method/bottom_horizontal.md +1 -0
- data/docs/dsl/by_method/bottom_left.md +1 -0
- data/docs/dsl/by_method/bottom_right.md +1 -0
- data/docs/dsl/by_method/bound.md +1 -0
- data/docs/dsl/by_method/buffer_update.md +4 -1
- data/docs/dsl/by_method/buffer_write.md +5 -1
- data/docs/dsl/by_method/buffers.md +1 -0
- data/docs/dsl/by_method/caption.md +1 -0
- data/docs/dsl/by_method/clear.md +1 -0
- data/docs/dsl/by_method/clear_by_group.md +1 -0
- data/docs/dsl/by_method/clear_by_name.md +1 -0
- data/docs/dsl/by_method/clear_content_by_name.md +1 -0
- data/docs/dsl/by_method/configuration.md +1 -0
- data/docs/dsl/by_method/configure.md +1 -0
- data/docs/dsl/by_method/cursor.md +1 -0
- data/docs/dsl/by_method/cursors.md +1 -0
- data/docs/dsl/by_method/debug.md +1 -0
- data/docs/dsl/by_method/direct_write.md +6 -1
- data/docs/dsl/by_method/disable.md +1 -0
- data/docs/dsl/by_method/documents.md +1 -0
- data/docs/dsl/by_method/drb_restart.md +1 -0
- data/docs/dsl/by_method/drb_start.md +1 -0
- data/docs/dsl/by_method/drb_status.md +1 -0
- data/docs/dsl/by_method/drb_stop.md +1 -0
- data/docs/dsl/by_method/enable.md +1 -0
- data/docs/dsl/by_method/esc.md +50 -0
- data/docs/dsl/by_method/events.md +1 -0
- data/docs/dsl/by_method/exit.md +1 -0
- data/docs/dsl/by_method/focus.md +1 -0
- data/docs/dsl/by_method/focus_by_name.md +1 -0
- data/docs/dsl/by_method/focus_next.md +1 -0
- data/docs/dsl/by_method/focus_previous.md +1 -0
- data/docs/dsl/by_method/focussed.md +1 -0
- data/docs/dsl/by_method/foreground_colours.md +1 -0
- data/docs/dsl/by_method/geometries.md +1 -0
- data/docs/dsl/by_method/geometry.md +1 -0
- data/docs/dsl/by_method/goto.md +1 -0
- data/docs/dsl/by_method/group.md +1 -0
- data/docs/dsl/by_method/groups.md +1 -0
- data/docs/dsl/by_method/height.md +1 -0
- data/docs/dsl/by_method/hide_cursor.md +1 -0
- data/docs/dsl/by_method/hide_group.md +1 -0
- data/docs/dsl/by_method/hide_interface.md +1 -0
- data/docs/dsl/by_method/horizontal.md +1 -0
- data/docs/dsl/by_method/interface.md +1 -0
- data/docs/dsl/by_method/interfaces.md +1 -0
- data/docs/dsl/by_method/keymap.md +1 -0
- data/docs/dsl/by_method/keymaps.md +1 -0
- data/docs/dsl/by_method/keypress.md +2 -0
- data/docs/dsl/by_method/last_command.md +1 -0
- data/docs/dsl/by_method/last_keypress.md +1 -0
- data/docs/dsl/by_method/left.md +1 -0
- data/docs/dsl/by_method/left_vertical.md +1 -0
- data/docs/dsl/by_method/log.md +1 -0
- data/docs/dsl/by_method/log_stderr.md +1 -0
- data/docs/dsl/by_method/log_stdout.md +1 -0
- data/docs/dsl/by_method/log_timestamp.md +1 -0
- data/docs/dsl/by_method/menu.md +1 -0
- data/docs/dsl/by_method/menus.md +1 -0
- data/docs/dsl/by_method/profile.md +1 -0
- data/docs/dsl/by_method/ready.md +1 -0
- data/docs/dsl/by_method/refresh.md +1 -0
- data/docs/dsl/by_method/render_output.md +5 -1
- data/docs/dsl/by_method/renderer.md +1 -0
- data/docs/dsl/by_method/renderers.md +1 -0
- data/docs/dsl/by_method/resize.md +1 -0
- data/docs/dsl/by_method/right.md +1 -0
- data/docs/dsl/by_method/right_vertical.md +1 -0
- data/docs/dsl/by_method/show_cursor.md +1 -0
- data/docs/dsl/by_method/show_group.md +1 -0
- data/docs/dsl/by_method/show_interface.md +1 -0
- data/docs/dsl/by_method/timer.md +1 -0
- data/docs/dsl/by_method/title.md +1 -0
- data/docs/dsl/by_method/toggle_cursor.md +1 -0
- data/docs/dsl/by_method/toggle_group.md +1 -0
- data/docs/dsl/by_method/toggle_interface.md +1 -0
- data/docs/dsl/by_method/top.md +1 -0
- data/docs/dsl/by_method/top_horizontal.md +1 -0
- data/docs/dsl/by_method/top_left.md +1 -0
- data/docs/dsl/by_method/top_right.md +1 -0
- data/docs/dsl/by_method/trigger.md +1 -0
- data/docs/dsl/by_method/unbind.md +1 -0
- data/docs/dsl/by_method/unbind_alias.md +1 -0
- data/docs/dsl/by_method/vertical.md +1 -0
- data/docs/dsl/by_method/width.md +1 -0
- data/docs/dsl/by_method/write.md +1 -0
- data/docs/dsl_elements.md +107 -100
- data/examples/dsl_alignment.rb +1 -1
- data/examples/dsl_colours.rb +1 -1
- data/examples/dsl_editor.rb +1 -1
- data/examples/dsl_horizontal_alignment.rb +1 -1
- data/examples/dsl_vertical_alignment.rb +1 -1
- data/examples/views/misc_view.rb +1 -1
- data/lib/vedeu/application/application_controller.rb +2 -0
- data/lib/vedeu/application/application_view.rb +2 -0
- data/lib/vedeu/borders/dsl.rb +1 -0
- data/lib/vedeu/borders/repository.rb +1 -0
- data/lib/vedeu/buffers/empty.rb +1 -0
- data/lib/vedeu/buffers/repository.rb +1 -0
- data/lib/vedeu/buffers/terminal.rb +3 -1
- data/lib/vedeu/cells/border.rb +0 -5
- data/lib/vedeu/cells/char.rb +0 -5
- data/lib/vedeu/cells/clear.rb +0 -5
- data/lib/vedeu/cells/cursor.rb +0 -5
- data/lib/vedeu/cells/empty.rb +0 -5
- data/lib/vedeu/cells/escape.rb +0 -5
- data/lib/vedeu/cells/support/html.rb +2 -0
- data/lib/vedeu/colours/backgrounds.rb +1 -0
- data/lib/vedeu/colours/foregrounds.rb +1 -0
- data/lib/vedeu/common.rb +0 -9
- data/lib/vedeu/configuration/configuration.rb +5 -0
- data/lib/vedeu/cursors/cursor.rb +3 -0
- data/lib/vedeu/cursors/repository.rb +2 -0
- data/lib/vedeu/distributed/server.rb +4 -0
- data/lib/vedeu/dsl/helpers/attributes.rb +4 -0
- data/lib/vedeu/dsl/views.rb +3 -0
- data/lib/vedeu/editor/repository.rb +1 -0
- data/lib/vedeu/esc/background.rb +2 -0
- data/lib/vedeu/esc/foreground.rb +2 -0
- data/lib/vedeu/events/aliases.rb +2 -0
- data/lib/vedeu/events/all.rb +1 -1
- data/lib/vedeu/events/event.rb +4 -1
- data/lib/vedeu/events/{collection.rb → events.rb} +3 -2
- data/lib/vedeu/events/repository.rb +4 -1
- data/lib/vedeu/events/trigger.rb +3 -0
- data/lib/vedeu/geometries/dsl/dsl.rb +1 -0
- data/lib/vedeu/geometries/repository.rb +1 -0
- data/lib/vedeu/groups/clear.rb +1 -0
- data/lib/vedeu/groups/dsl.rb +1 -0
- data/lib/vedeu/groups/group.rb +3 -0
- data/lib/vedeu/groups/repository.rb +1 -0
- data/lib/vedeu/input/capture.rb +1 -1
- data/lib/vedeu/input/dsl.rb +1 -0
- data/lib/vedeu/input/mapper.rb +1 -0
- data/lib/vedeu/input/read.rb +1 -0
- data/lib/vedeu/input/repository.rb +1 -0
- data/lib/vedeu/input/store.rb +6 -0
- data/lib/vedeu/interfaces/clear.rb +3 -1
- data/lib/vedeu/interfaces/dsl.rb +1 -0
- data/lib/vedeu/interfaces/interface.rb +3 -0
- data/lib/vedeu/interfaces/repository.rb +1 -0
- data/lib/vedeu/logging/clock_time.rb +1 -0
- data/lib/vedeu/logging/debug.rb +2 -0
- data/lib/vedeu/logging/log.rb +4 -0
- data/lib/vedeu/logging/timer.rb +1 -0
- data/lib/vedeu/menus/menu.rb +1 -0
- data/lib/vedeu/menus/repository.rb +1 -0
- data/lib/vedeu/models/focus.rb +6 -0
- data/lib/vedeu/output/all.rb +1 -0
- data/lib/vedeu/output/compressor.rb +17 -104
- data/lib/vedeu/output/compressor_cache.rb +43 -20
- data/lib/vedeu/output/compressors/all.rb +26 -0
- data/lib/vedeu/output/compressors/character.rb +105 -0
- data/lib/vedeu/output/compressors/simple.rb +67 -0
- data/lib/vedeu/output/output.rb +30 -24
- data/lib/vedeu/output/write.rb +1 -0
- data/lib/vedeu/renderers/all.rb +1 -0
- data/lib/vedeu/renderers/options.rb +1 -1
- data/lib/vedeu/renderers/terminal.rb +8 -7
- data/lib/vedeu/repositories/storage.rb +2 -0
- data/lib/vedeu/runtime/application.rb +15 -2
- data/lib/vedeu/runtime/flags.rb +4 -0
- data/lib/vedeu/runtime/router.rb +1 -0
- data/lib/vedeu/sentence.rb +2 -0
- data/lib/vedeu/support/point.rb +2 -0
- data/lib/vedeu/terminal/terminal.rb +1 -0
- data/lib/vedeu/version.rb +1 -1
- data/lib/vedeu/views/all.rb +2 -0
- data/lib/vedeu/views/composition.rb +5 -1
- data/lib/vedeu/views/line.rb +2 -0
- data/lib/vedeu/views/stream.rb +2 -0
- data/lib/vedeu/views/view.rb +3 -1
- data/test/lib/vedeu/cells/border_test.rb +0 -6
- data/test/lib/vedeu/cells/char_test.rb +0 -6
- data/test/lib/vedeu/cells/clear_test.rb +0 -6
- data/test/lib/vedeu/cells/cursor_test.rb +0 -4
- data/test/lib/vedeu/cells/empty_test.rb +0 -6
- data/test/lib/vedeu/cells/escape_test.rb +0 -4
- data/test/lib/vedeu/common_test.rb +0 -10
- data/test/lib/vedeu/events/{collection_test.rb → events_test.rb} +3 -3
- data/test/lib/vedeu/events/repository_test.rb +1 -1
- data/test/lib/vedeu/output/compressor_cache_test.rb +87 -63
- data/test/lib/vedeu/output/compressor_test.rb +31 -8
- data/test/lib/vedeu/output/compressors/character_test.rb +40 -0
- data/test/lib/vedeu/output/compressors/simple_test.rb +42 -0
- data/test/lib/vedeu/repositories/storage_test.rb +2 -0
- data/test/lib/vedeu/sentence_test.rb +2 -0
- data/test/lib/vedeu/support/point_test.rb +2 -0
- data/test/support/coverage.rb +2 -0
- data/test/support/examples/drb_app.rb +2 -0
- data/test/support/examples/focus_app.rb +2 -0
- data/test/support/examples/hello_world.rb +2 -0
- data/test/support/examples/material_colours_app.rb +7 -4
- data/test/support/examples/view_templates_app/view_templates_app.rb +2 -0
- data/test/support/ttyrec.rb +2 -0
- data/test/support/who.rb +2 -0
- metadata +13 -5
@@ -6,6 +6,8 @@ module Vedeu
|
|
6
6
|
|
7
7
|
# Allows the storing of events.
|
8
8
|
#
|
9
|
+
# @api private
|
10
|
+
#
|
9
11
|
class Repository < Vedeu::Repositories::Repository
|
10
12
|
|
11
13
|
singleton_class.send(:alias_method, :events, :repository)
|
@@ -19,7 +21,7 @@ module Vedeu
|
|
19
21
|
#
|
20
22
|
# @return [Vedeu::Events::Repository]
|
21
23
|
def reset!
|
22
|
-
@events = new(Vedeu::Events::
|
24
|
+
@events = new(Vedeu::Events::Events)
|
23
25
|
end
|
24
26
|
alias reset reset!
|
25
27
|
|
@@ -34,6 +36,7 @@ module Vedeu
|
|
34
36
|
# @example
|
35
37
|
# Vedeu.events
|
36
38
|
#
|
39
|
+
# @api public
|
37
40
|
# @!method events
|
38
41
|
# @return [Vedeu::Events::Repository]
|
39
42
|
def_delegators Vedeu::Events::Repository,
|
data/lib/vedeu/events/trigger.rb
CHANGED
@@ -9,6 +9,8 @@ module Vedeu
|
|
9
9
|
# events are registered for a name, then the result of each event
|
10
10
|
# will be returned as part of a collection.
|
11
11
|
#
|
12
|
+
# @api private
|
13
|
+
#
|
12
14
|
class Trigger
|
13
15
|
|
14
16
|
# Trigger an event by name.
|
@@ -88,6 +90,7 @@ module Vedeu
|
|
88
90
|
|
89
91
|
end # Events
|
90
92
|
|
93
|
+
# @api public
|
91
94
|
# @!method trigger
|
92
95
|
# @see Vedeu::Events::Trigger.trigger
|
93
96
|
def_delegators Vedeu::Events::Trigger,
|
data/lib/vedeu/groups/clear.rb
CHANGED
data/lib/vedeu/groups/dsl.rb
CHANGED
data/lib/vedeu/groups/group.rb
CHANGED
@@ -179,10 +179,13 @@ module Vedeu
|
|
179
179
|
|
180
180
|
end # Groups
|
181
181
|
|
182
|
+
# @api public
|
182
183
|
# @!method hide_group
|
183
184
|
# @see Vedeu::Toggleable::SingletonMethods#hide
|
185
|
+
# @api public
|
184
186
|
# @!method show_group
|
185
187
|
# @see Vedeu::Toggleable::SingletonMethods#show
|
188
|
+
# @api public
|
186
189
|
# @!method toggle_group
|
187
190
|
# @see Vedeu::Toggleable::SingletonMethods#toggle
|
188
191
|
def_delegators Vedeu::Groups::Group,
|
data/lib/vedeu/input/capture.rb
CHANGED
data/lib/vedeu/input/dsl.rb
CHANGED
data/lib/vedeu/input/mapper.rb
CHANGED
data/lib/vedeu/input/read.rb
CHANGED
data/lib/vedeu/input/store.rb
CHANGED
@@ -63,16 +63,22 @@ module Vedeu
|
|
63
63
|
|
64
64
|
end # Input
|
65
65
|
|
66
|
+
# @api public
|
66
67
|
# @!method add_command
|
67
68
|
# @see Vedeu::Input::Store.add_command
|
69
|
+
# @api public
|
68
70
|
# @!method add_keypress
|
69
71
|
# @see Vedeu::Input::Store.add_keypress
|
72
|
+
# @api public
|
70
73
|
# @!method all_commands
|
71
74
|
# @see Vedeu::Input::Store.all_commands
|
75
|
+
# @api public
|
72
76
|
# @!method all_keypresses
|
73
77
|
# @see Vedeu::Input::Store.all_keypresses
|
78
|
+
# @api public
|
74
79
|
# @!method last_command
|
75
80
|
# @see Vedeu::Input::Store.last_command
|
81
|
+
# @api public
|
76
82
|
# @!method last_keypress
|
77
83
|
# @see Vedeu::Input::Store.last_keypress
|
78
84
|
def_delegators Vedeu::Input::Store,
|
@@ -67,7 +67,7 @@ module Vedeu
|
|
67
67
|
if direct?
|
68
68
|
Vedeu.direct_write(optimised_output)
|
69
69
|
|
70
|
-
Vedeu
|
70
|
+
Vedeu.buffer_update(output)
|
71
71
|
|
72
72
|
else
|
73
73
|
Vedeu.render_output(output)
|
@@ -227,8 +227,10 @@ module Vedeu
|
|
227
227
|
|
228
228
|
end # Interfaces
|
229
229
|
|
230
|
+
# @api public
|
230
231
|
# @!method clear_by_name
|
231
232
|
# @see Vedeu::Interfaces::Clear.clear_by_name
|
233
|
+
# @api public
|
232
234
|
# @!method clear_content_by_name
|
233
235
|
# @see Vedeu::Interfaces.Clear.clear_content_by_name
|
234
236
|
def_delegators Vedeu::Interfaces::Clear,
|
data/lib/vedeu/interfaces/dsl.rb
CHANGED
@@ -169,10 +169,13 @@ module Vedeu
|
|
169
169
|
|
170
170
|
end # Interfaces
|
171
171
|
|
172
|
+
# @api public
|
172
173
|
# @!method hide_interface
|
173
174
|
# @see Vedeu::Toggleable::SingletonMethods#hide
|
175
|
+
# @api public
|
174
176
|
# @!method show_interface
|
175
177
|
# @see Vedeu::Toggleable::SingletonMethods#show
|
178
|
+
# @api public
|
176
179
|
# @!method toggle_interface
|
177
180
|
# @see Vedeu::Toggleable::SingletonMethods#toggle
|
178
181
|
def_delegators Vedeu::Interfaces::Interface,
|
data/lib/vedeu/logging/debug.rb
CHANGED
@@ -117,12 +117,14 @@ module Vedeu
|
|
117
117
|
end # Logging
|
118
118
|
|
119
119
|
# {include:file:docs/dsl/by_method/profile.md}
|
120
|
+
# @api public
|
120
121
|
# @!method profile
|
121
122
|
# @return [Vedeu::Logging::Debug]
|
122
123
|
def_delegators Vedeu::Logging::Debug,
|
123
124
|
:profile
|
124
125
|
|
125
126
|
# {include:file:docs/dsl/by_method/debug.md}
|
127
|
+
# @api public
|
126
128
|
# @!method debug
|
127
129
|
# @return [void]
|
128
130
|
def_delegators Vedeu::Logging::Debug,
|
data/lib/vedeu/logging/log.rb
CHANGED
@@ -166,12 +166,16 @@ module Vedeu
|
|
166
166
|
|
167
167
|
end # Logging
|
168
168
|
|
169
|
+
# @api public
|
169
170
|
# @!method log
|
170
171
|
# @see Vedeu::Logging::Log.log
|
172
|
+
# @api public
|
171
173
|
# @!method log_stdout
|
172
174
|
# @see Vedeu::Logging::Log.log_stdout
|
175
|
+
# @api public
|
173
176
|
# @!method log_stderr
|
174
177
|
# @see Vedeu::Logging::Log.log_stderr
|
178
|
+
# @api public
|
175
179
|
# @!method log_timestamp
|
176
180
|
# @see Vedeu::Logging::Log.log_timestamp
|
177
181
|
def_delegators Vedeu::Logging::Log,
|
data/lib/vedeu/logging/timer.rb
CHANGED
data/lib/vedeu/menus/menu.rb
CHANGED
data/lib/vedeu/models/focus.rb
CHANGED
@@ -246,16 +246,22 @@ module Vedeu
|
|
246
246
|
|
247
247
|
end # Models
|
248
248
|
|
249
|
+
# @api public
|
249
250
|
# @!method focus
|
250
251
|
# @see Vedeu::Models::Focus#focus
|
252
|
+
# @api public
|
251
253
|
# @!method focus?
|
252
254
|
# @see Vedeu::Models::Focus#focus?
|
255
|
+
# @api public
|
253
256
|
# @!method focus_by_name
|
254
257
|
# @see Vedeu::Models::Focus#focus_by_name
|
258
|
+
# @api public
|
255
259
|
# @!method focussed?
|
256
260
|
# @see Vedeu::Models::Focus#focussed?
|
261
|
+
# @api public
|
257
262
|
# @!method focus_next
|
258
263
|
# @see Vedeu::Models::Focus#focus_next
|
264
|
+
# @api public
|
259
265
|
# @!method focus_previous
|
260
266
|
# @see Vedeu::Models::Focus#focus_previous
|
261
267
|
def_delegators Vedeu::Models::Focus,
|
data/lib/vedeu/output/all.rb
CHANGED
@@ -31,18 +31,17 @@ module Vedeu
|
|
31
31
|
def initialize(output, options = {})
|
32
32
|
@output = output
|
33
33
|
@options = options
|
34
|
-
@colour = ''
|
35
|
-
@style = ''
|
36
34
|
end
|
37
35
|
|
38
36
|
# @note
|
39
37
|
# - Takes approximately ~6ms for 2100 chars. (2015-11-25)
|
40
38
|
# - Takes approximately ~25ms for 2100 chars. (2015-07-25)
|
41
39
|
# @return [String]
|
40
|
+
# @return [Array<void>|String]
|
42
41
|
def render
|
43
|
-
return
|
42
|
+
return [] unless output?
|
44
43
|
|
45
|
-
|
44
|
+
Vedeu::Output::CompressorCache.cache(content, compression?)
|
46
45
|
end
|
47
46
|
|
48
47
|
protected
|
@@ -53,114 +52,28 @@ module Vedeu
|
|
53
52
|
|
54
53
|
private
|
55
54
|
|
55
|
+
# Returns the output with all of the empty cells removed to make
|
56
|
+
# compression faster.
|
57
|
+
#
|
56
58
|
# @return [Array]
|
57
59
|
def content
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
else
|
62
|
-
[]
|
63
|
-
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
# @return [Array<void>|String]
|
68
|
-
def cached
|
69
|
-
cached_original = Vedeu::Output::CompressorCache.read(:original)
|
70
|
-
cached_compressed = Vedeu::Output::CompressorCache.read(:compressed)
|
71
|
-
|
72
|
-
if content.size == cached_original.size && content == cached_original
|
73
|
-
cached_compressed
|
74
|
-
|
75
|
-
else
|
76
|
-
Vedeu::Output::CompressorCache.write(:original, content)
|
77
|
-
Vedeu::Output::CompressorCache.write(:compressed, compress)
|
78
|
-
compress
|
79
|
-
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
# @return [String]
|
84
|
-
def compress
|
85
|
-
message = "Compression for #{content.size} objects"
|
86
|
-
|
87
|
-
@same = ''
|
88
|
-
@compress ||= Vedeu.timer(message) do
|
89
|
-
out = content.map do |cell|
|
90
|
-
rendered = [
|
91
|
-
# position_for(cell),
|
92
|
-
cell.position.to_s,
|
93
|
-
colour_for(cell),
|
94
|
-
style_for(cell),
|
95
|
-
cell.value,
|
96
|
-
].join
|
97
|
-
|
98
|
-
if @same == rendered
|
99
|
-
next
|
100
|
-
|
101
|
-
else
|
102
|
-
@same = rendered
|
103
|
-
@same
|
104
|
-
|
105
|
-
end
|
106
|
-
end.join
|
107
|
-
|
60
|
+
output.content.reject do |cell|
|
61
|
+
cell.class == Vedeu::Cells::Empty
|
62
|
+
end.tap do |cells|
|
108
63
|
Vedeu.log(type: :compress,
|
109
|
-
message: "
|
110
|
-
|
111
|
-
out
|
64
|
+
message: "Orignal size: #{content_size} / " \
|
65
|
+
"New size: #{cells.size}")
|
112
66
|
end
|
113
67
|
end
|
114
68
|
|
115
|
-
# @return [
|
116
|
-
def
|
117
|
-
|
118
|
-
|
119
|
-
Vedeu.log(type: :compress,
|
120
|
-
message: "No compression: #{content.size} objects -> " \
|
121
|
-
"#{out.size} characters")
|
122
|
-
|
123
|
-
out
|
124
|
-
end
|
125
|
-
|
126
|
-
# Compress by not repeatedly sending a position when only the x
|
127
|
-
# coordinate has changed; i.e. we are on the same line, just
|
128
|
-
# advancing a character.
|
129
|
-
#
|
130
|
-
# @param char [Vedeu::Cells::Char]
|
131
|
-
# @return [String]
|
132
|
-
def position_for(char)
|
133
|
-
return '' unless char.position
|
134
|
-
return '' if char.position.y == @y
|
135
|
-
|
136
|
-
@y = char.position.y
|
137
|
-
char.position.to_s
|
69
|
+
# @return [Fixnum]
|
70
|
+
def content_size
|
71
|
+
output.content.size
|
138
72
|
end
|
139
73
|
|
140
|
-
#
|
141
|
-
|
142
|
-
|
143
|
-
#
|
144
|
-
# @param char [Vedeu::Cells::Char]
|
145
|
-
# @return [String]
|
146
|
-
def colour_for(char)
|
147
|
-
return '' if char.colour == @colour
|
148
|
-
|
149
|
-
@colour = char.colour
|
150
|
-
@colour.to_s
|
151
|
-
end
|
152
|
-
|
153
|
-
# Compress by not repeatedly sending the same style(s) for each
|
154
|
-
# character which has the same style(s) as the last character
|
155
|
-
# output.
|
156
|
-
#
|
157
|
-
# @param char [Vedeu::Cells::Char]
|
158
|
-
# @return [String]
|
159
|
-
def style_for(char)
|
160
|
-
return '' if char.style == @style
|
161
|
-
|
162
|
-
@style = char.style
|
163
|
-
@style.to_s
|
74
|
+
# @return [Boolean]
|
75
|
+
def output?
|
76
|
+
present?(output)
|
164
77
|
end
|
165
78
|
|
166
79
|
end # Compressor
|
@@ -16,41 +16,64 @@ module Vedeu
|
|
16
16
|
extend self
|
17
17
|
extend Vedeu::Repositories::Storage
|
18
18
|
|
19
|
-
# @param
|
20
|
-
# @return [
|
21
|
-
def
|
22
|
-
|
19
|
+
# @param content [Array<void>]
|
20
|
+
# @return [String]
|
21
|
+
def cache(content, compression = false)
|
22
|
+
write(content, compression) unless empty?(content) || cached?(content)
|
23
|
+
|
24
|
+
compression ? read(:compress) : read(:uncompress)
|
23
25
|
end
|
24
26
|
|
25
|
-
|
26
|
-
# @param value [Array|NilClass]
|
27
|
-
# @return [Hash<Symbol => Array<void>>]
|
28
|
-
def write(key, value)
|
29
|
-
return storage if invalid_key?(key) || invalid_value?(value)
|
27
|
+
private
|
30
28
|
|
31
|
-
|
29
|
+
# @param content [Array<void>]
|
30
|
+
# @return [Boolean]
|
31
|
+
def cached?(content)
|
32
|
+
content.size == read(:original).size && content == read(:original)
|
32
33
|
end
|
33
34
|
|
34
|
-
|
35
|
+
# @param content [Array<void>]
|
36
|
+
# @return [String]
|
37
|
+
def compress(content)
|
38
|
+
Vedeu::Output::Compressors::Character.with(content)
|
39
|
+
end
|
35
40
|
|
36
|
-
# @
|
41
|
+
# @param content [Array<void>]
|
42
|
+
# @return [Boolean]
|
43
|
+
def empty?(content)
|
44
|
+
content.nil? || content.empty?
|
45
|
+
end
|
46
|
+
|
47
|
+
# @return [Hash<Symbol => Array<void>, String>]
|
37
48
|
def in_memory
|
38
49
|
{
|
39
|
-
|
50
|
+
compress: '',
|
40
51
|
original: [],
|
52
|
+
uncompress: '',
|
41
53
|
}
|
42
54
|
end
|
43
55
|
|
44
56
|
# @param key [NilClass|Symbol]
|
45
|
-
# @return [
|
46
|
-
def
|
47
|
-
|
57
|
+
# @return [Array<void>]
|
58
|
+
def read(key)
|
59
|
+
storage.fetch(key, [])
|
48
60
|
end
|
49
61
|
|
50
|
-
# @param
|
51
|
-
# @return [
|
52
|
-
def
|
53
|
-
|
62
|
+
# @param content [Array<void>]
|
63
|
+
# @return [String]
|
64
|
+
def uncompress(content)
|
65
|
+
Vedeu::Output::Compressors::Simple.with(content)
|
66
|
+
end
|
67
|
+
|
68
|
+
# @param content [Array<void>]
|
69
|
+
# @param compression [Boolean]
|
70
|
+
# @return [Hash<Symbol => Array<void>>]
|
71
|
+
def write(content, compression = false)
|
72
|
+
storage[:original] = content
|
73
|
+
|
74
|
+
storage[:uncompress] = uncompress(content)
|
75
|
+
|
76
|
+
storage[:compress] = compress(content)
|
54
77
|
end
|
55
78
|
|
56
79
|
end # CompressorCache
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Output
|
6
|
+
|
7
|
+
# Provides different mechanisms to compress content. Compressing
|
8
|
+
# content is performed to:
|
9
|
+
#
|
10
|
+
# 1) Reduce the amount of data sent to the renderer with each
|
11
|
+
# refresh or render.
|
12
|
+
# 2) Reduce the time spent converting a terminal buffer into data
|
13
|
+
# suitable to send to the renderer.
|
14
|
+
#
|
15
|
+
# @api private
|
16
|
+
#
|
17
|
+
module Compressors
|
18
|
+
|
19
|
+
end # Compressors
|
20
|
+
|
21
|
+
end # Output
|
22
|
+
|
23
|
+
end # Vedeu
|
24
|
+
|
25
|
+
require 'vedeu/output/compressors/simple'
|
26
|
+
require 'vedeu/output/compressors/character'
|