vedeu 0.8.10 → 0.8.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (209) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +0 -1
  3. data/docs/api.md +1 -1
  4. data/docs/dsl/by_method/add_command.md +1 -0
  5. data/docs/dsl/by_method/add_keypress.md +1 -0
  6. data/docs/dsl/by_method/all_commands.md +1 -0
  7. data/docs/dsl/by_method/all_keypresses.md +1 -0
  8. data/docs/dsl/by_method/background_colours.md +1 -0
  9. data/docs/dsl/by_method/bind.md +1 -0
  10. data/docs/dsl/by_method/bind_alias.md +1 -0
  11. data/docs/dsl/by_method/borders.md +1 -0
  12. data/docs/dsl/by_method/bottom.md +1 -0
  13. data/docs/dsl/by_method/bottom_horizontal.md +1 -0
  14. data/docs/dsl/by_method/bottom_left.md +1 -0
  15. data/docs/dsl/by_method/bottom_right.md +1 -0
  16. data/docs/dsl/by_method/bound.md +1 -0
  17. data/docs/dsl/by_method/buffer_update.md +4 -1
  18. data/docs/dsl/by_method/buffer_write.md +5 -1
  19. data/docs/dsl/by_method/buffers.md +1 -0
  20. data/docs/dsl/by_method/caption.md +1 -0
  21. data/docs/dsl/by_method/clear.md +1 -0
  22. data/docs/dsl/by_method/clear_by_group.md +1 -0
  23. data/docs/dsl/by_method/clear_by_name.md +1 -0
  24. data/docs/dsl/by_method/clear_content_by_name.md +1 -0
  25. data/docs/dsl/by_method/configuration.md +1 -0
  26. data/docs/dsl/by_method/configure.md +1 -0
  27. data/docs/dsl/by_method/cursor.md +1 -0
  28. data/docs/dsl/by_method/cursors.md +1 -0
  29. data/docs/dsl/by_method/debug.md +1 -0
  30. data/docs/dsl/by_method/direct_write.md +6 -1
  31. data/docs/dsl/by_method/disable.md +1 -0
  32. data/docs/dsl/by_method/documents.md +1 -0
  33. data/docs/dsl/by_method/drb_restart.md +1 -0
  34. data/docs/dsl/by_method/drb_start.md +1 -0
  35. data/docs/dsl/by_method/drb_status.md +1 -0
  36. data/docs/dsl/by_method/drb_stop.md +1 -0
  37. data/docs/dsl/by_method/enable.md +1 -0
  38. data/docs/dsl/by_method/esc.md +50 -0
  39. data/docs/dsl/by_method/events.md +1 -0
  40. data/docs/dsl/by_method/exit.md +1 -0
  41. data/docs/dsl/by_method/focus.md +1 -0
  42. data/docs/dsl/by_method/focus_by_name.md +1 -0
  43. data/docs/dsl/by_method/focus_next.md +1 -0
  44. data/docs/dsl/by_method/focus_previous.md +1 -0
  45. data/docs/dsl/by_method/focussed.md +1 -0
  46. data/docs/dsl/by_method/foreground_colours.md +1 -0
  47. data/docs/dsl/by_method/geometries.md +1 -0
  48. data/docs/dsl/by_method/geometry.md +1 -0
  49. data/docs/dsl/by_method/goto.md +1 -0
  50. data/docs/dsl/by_method/group.md +1 -0
  51. data/docs/dsl/by_method/groups.md +1 -0
  52. data/docs/dsl/by_method/height.md +1 -0
  53. data/docs/dsl/by_method/hide_cursor.md +1 -0
  54. data/docs/dsl/by_method/hide_group.md +1 -0
  55. data/docs/dsl/by_method/hide_interface.md +1 -0
  56. data/docs/dsl/by_method/horizontal.md +1 -0
  57. data/docs/dsl/by_method/interface.md +1 -0
  58. data/docs/dsl/by_method/interfaces.md +1 -0
  59. data/docs/dsl/by_method/keymap.md +1 -0
  60. data/docs/dsl/by_method/keymaps.md +1 -0
  61. data/docs/dsl/by_method/keypress.md +2 -0
  62. data/docs/dsl/by_method/last_command.md +1 -0
  63. data/docs/dsl/by_method/last_keypress.md +1 -0
  64. data/docs/dsl/by_method/left.md +1 -0
  65. data/docs/dsl/by_method/left_vertical.md +1 -0
  66. data/docs/dsl/by_method/log.md +1 -0
  67. data/docs/dsl/by_method/log_stderr.md +1 -0
  68. data/docs/dsl/by_method/log_stdout.md +1 -0
  69. data/docs/dsl/by_method/log_timestamp.md +1 -0
  70. data/docs/dsl/by_method/menu.md +1 -0
  71. data/docs/dsl/by_method/menus.md +1 -0
  72. data/docs/dsl/by_method/profile.md +1 -0
  73. data/docs/dsl/by_method/ready.md +1 -0
  74. data/docs/dsl/by_method/refresh.md +1 -0
  75. data/docs/dsl/by_method/render_output.md +5 -1
  76. data/docs/dsl/by_method/renderer.md +1 -0
  77. data/docs/dsl/by_method/renderers.md +1 -0
  78. data/docs/dsl/by_method/resize.md +1 -0
  79. data/docs/dsl/by_method/right.md +1 -0
  80. data/docs/dsl/by_method/right_vertical.md +1 -0
  81. data/docs/dsl/by_method/show_cursor.md +1 -0
  82. data/docs/dsl/by_method/show_group.md +1 -0
  83. data/docs/dsl/by_method/show_interface.md +1 -0
  84. data/docs/dsl/by_method/timer.md +1 -0
  85. data/docs/dsl/by_method/title.md +1 -0
  86. data/docs/dsl/by_method/toggle_cursor.md +1 -0
  87. data/docs/dsl/by_method/toggle_group.md +1 -0
  88. data/docs/dsl/by_method/toggle_interface.md +1 -0
  89. data/docs/dsl/by_method/top.md +1 -0
  90. data/docs/dsl/by_method/top_horizontal.md +1 -0
  91. data/docs/dsl/by_method/top_left.md +1 -0
  92. data/docs/dsl/by_method/top_right.md +1 -0
  93. data/docs/dsl/by_method/trigger.md +1 -0
  94. data/docs/dsl/by_method/unbind.md +1 -0
  95. data/docs/dsl/by_method/unbind_alias.md +1 -0
  96. data/docs/dsl/by_method/vertical.md +1 -0
  97. data/docs/dsl/by_method/width.md +1 -0
  98. data/docs/dsl/by_method/write.md +1 -0
  99. data/docs/dsl_elements.md +107 -100
  100. data/examples/dsl_alignment.rb +1 -1
  101. data/examples/dsl_colours.rb +1 -1
  102. data/examples/dsl_editor.rb +1 -1
  103. data/examples/dsl_horizontal_alignment.rb +1 -1
  104. data/examples/dsl_vertical_alignment.rb +1 -1
  105. data/examples/views/misc_view.rb +1 -1
  106. data/lib/vedeu/application/application_controller.rb +2 -0
  107. data/lib/vedeu/application/application_view.rb +2 -0
  108. data/lib/vedeu/borders/dsl.rb +1 -0
  109. data/lib/vedeu/borders/repository.rb +1 -0
  110. data/lib/vedeu/buffers/empty.rb +1 -0
  111. data/lib/vedeu/buffers/repository.rb +1 -0
  112. data/lib/vedeu/buffers/terminal.rb +3 -1
  113. data/lib/vedeu/cells/border.rb +0 -5
  114. data/lib/vedeu/cells/char.rb +0 -5
  115. data/lib/vedeu/cells/clear.rb +0 -5
  116. data/lib/vedeu/cells/cursor.rb +0 -5
  117. data/lib/vedeu/cells/empty.rb +0 -5
  118. data/lib/vedeu/cells/escape.rb +0 -5
  119. data/lib/vedeu/cells/support/html.rb +2 -0
  120. data/lib/vedeu/colours/backgrounds.rb +1 -0
  121. data/lib/vedeu/colours/foregrounds.rb +1 -0
  122. data/lib/vedeu/common.rb +0 -9
  123. data/lib/vedeu/configuration/configuration.rb +5 -0
  124. data/lib/vedeu/cursors/cursor.rb +3 -0
  125. data/lib/vedeu/cursors/repository.rb +2 -0
  126. data/lib/vedeu/distributed/server.rb +4 -0
  127. data/lib/vedeu/dsl/helpers/attributes.rb +4 -0
  128. data/lib/vedeu/dsl/views.rb +3 -0
  129. data/lib/vedeu/editor/repository.rb +1 -0
  130. data/lib/vedeu/esc/background.rb +2 -0
  131. data/lib/vedeu/esc/foreground.rb +2 -0
  132. data/lib/vedeu/events/aliases.rb +2 -0
  133. data/lib/vedeu/events/all.rb +1 -1
  134. data/lib/vedeu/events/event.rb +4 -1
  135. data/lib/vedeu/events/{collection.rb → events.rb} +3 -2
  136. data/lib/vedeu/events/repository.rb +4 -1
  137. data/lib/vedeu/events/trigger.rb +3 -0
  138. data/lib/vedeu/geometries/dsl/dsl.rb +1 -0
  139. data/lib/vedeu/geometries/repository.rb +1 -0
  140. data/lib/vedeu/groups/clear.rb +1 -0
  141. data/lib/vedeu/groups/dsl.rb +1 -0
  142. data/lib/vedeu/groups/group.rb +3 -0
  143. data/lib/vedeu/groups/repository.rb +1 -0
  144. data/lib/vedeu/input/capture.rb +1 -1
  145. data/lib/vedeu/input/dsl.rb +1 -0
  146. data/lib/vedeu/input/mapper.rb +1 -0
  147. data/lib/vedeu/input/read.rb +1 -0
  148. data/lib/vedeu/input/repository.rb +1 -0
  149. data/lib/vedeu/input/store.rb +6 -0
  150. data/lib/vedeu/interfaces/clear.rb +3 -1
  151. data/lib/vedeu/interfaces/dsl.rb +1 -0
  152. data/lib/vedeu/interfaces/interface.rb +3 -0
  153. data/lib/vedeu/interfaces/repository.rb +1 -0
  154. data/lib/vedeu/logging/clock_time.rb +1 -0
  155. data/lib/vedeu/logging/debug.rb +2 -0
  156. data/lib/vedeu/logging/log.rb +4 -0
  157. data/lib/vedeu/logging/timer.rb +1 -0
  158. data/lib/vedeu/menus/menu.rb +1 -0
  159. data/lib/vedeu/menus/repository.rb +1 -0
  160. data/lib/vedeu/models/focus.rb +6 -0
  161. data/lib/vedeu/output/all.rb +1 -0
  162. data/lib/vedeu/output/compressor.rb +17 -104
  163. data/lib/vedeu/output/compressor_cache.rb +43 -20
  164. data/lib/vedeu/output/compressors/all.rb +26 -0
  165. data/lib/vedeu/output/compressors/character.rb +105 -0
  166. data/lib/vedeu/output/compressors/simple.rb +67 -0
  167. data/lib/vedeu/output/output.rb +30 -24
  168. data/lib/vedeu/output/write.rb +1 -0
  169. data/lib/vedeu/renderers/all.rb +1 -0
  170. data/lib/vedeu/renderers/options.rb +1 -1
  171. data/lib/vedeu/renderers/terminal.rb +8 -7
  172. data/lib/vedeu/repositories/storage.rb +2 -0
  173. data/lib/vedeu/runtime/application.rb +15 -2
  174. data/lib/vedeu/runtime/flags.rb +4 -0
  175. data/lib/vedeu/runtime/router.rb +1 -0
  176. data/lib/vedeu/sentence.rb +2 -0
  177. data/lib/vedeu/support/point.rb +2 -0
  178. data/lib/vedeu/terminal/terminal.rb +1 -0
  179. data/lib/vedeu/version.rb +1 -1
  180. data/lib/vedeu/views/all.rb +2 -0
  181. data/lib/vedeu/views/composition.rb +5 -1
  182. data/lib/vedeu/views/line.rb +2 -0
  183. data/lib/vedeu/views/stream.rb +2 -0
  184. data/lib/vedeu/views/view.rb +3 -1
  185. data/test/lib/vedeu/cells/border_test.rb +0 -6
  186. data/test/lib/vedeu/cells/char_test.rb +0 -6
  187. data/test/lib/vedeu/cells/clear_test.rb +0 -6
  188. data/test/lib/vedeu/cells/cursor_test.rb +0 -4
  189. data/test/lib/vedeu/cells/empty_test.rb +0 -6
  190. data/test/lib/vedeu/cells/escape_test.rb +0 -4
  191. data/test/lib/vedeu/common_test.rb +0 -10
  192. data/test/lib/vedeu/events/{collection_test.rb → events_test.rb} +3 -3
  193. data/test/lib/vedeu/events/repository_test.rb +1 -1
  194. data/test/lib/vedeu/output/compressor_cache_test.rb +87 -63
  195. data/test/lib/vedeu/output/compressor_test.rb +31 -8
  196. data/test/lib/vedeu/output/compressors/character_test.rb +40 -0
  197. data/test/lib/vedeu/output/compressors/simple_test.rb +42 -0
  198. data/test/lib/vedeu/repositories/storage_test.rb +2 -0
  199. data/test/lib/vedeu/sentence_test.rb +2 -0
  200. data/test/lib/vedeu/support/point_test.rb +2 -0
  201. data/test/support/coverage.rb +2 -0
  202. data/test/support/examples/drb_app.rb +2 -0
  203. data/test/support/examples/focus_app.rb +2 -0
  204. data/test/support/examples/hello_world.rb +2 -0
  205. data/test/support/examples/material_colours_app.rb +7 -4
  206. data/test/support/examples/view_templates_app/view_templates_app.rb +2 -0
  207. data/test/support/ttyrec.rb +2 -0
  208. data/test/support/who.rb +2 -0
  209. 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::Collection)
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,
@@ -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,
@@ -411,6 +411,7 @@ module Vedeu
411
411
 
412
412
  end # Geometries
413
413
 
414
+ # @api public
414
415
  # @!method geometry
415
416
  # @see Vedeu::Geometries::DSL.geometry
416
417
  def_delegators Vedeu::Geometries::DSL,
@@ -23,6 +23,7 @@ module Vedeu
23
23
  # @example
24
24
  # Vedeu.geometries
25
25
  #
26
+ # @api public
26
27
  # @!method geometries
27
28
  # @return [Vedeu::Geometries::Repository]
28
29
  def_delegators Vedeu::Geometries::Repository,
@@ -61,6 +61,7 @@ module Vedeu
61
61
 
62
62
  end # Groups
63
63
 
64
+ # @api public
64
65
  # @!method clear_by_group
65
66
  # @see Vedeu::Groups::Clear.render
66
67
  def_delegators Vedeu::Groups::Clear,
@@ -95,6 +95,7 @@ module Vedeu
95
95
 
96
96
  end # Groups
97
97
 
98
+ # @api public
98
99
  # @!method group
99
100
  # @see Vedeu::Groups::DSL.group
100
101
  def_delegators Vedeu::Groups::DSL,
@@ -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,
@@ -28,6 +28,7 @@ module Vedeu
28
28
  # @example
29
29
  # Vedeu.groups
30
30
  #
31
+ # @api public
31
32
  # @!method groups
32
33
  # @return [Vedeu::Groups::Repository]
33
34
  def_delegators Vedeu::Groups::Repository,
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Vedeu
4
4
 
5
- # \e
5
+ # Produces ASCII character 27 which is ESC
6
6
  ESCAPE_KEY_CODE = 27
7
7
 
8
8
  module Input
@@ -106,6 +106,7 @@ module Vedeu
106
106
 
107
107
  end # Input
108
108
 
109
+ # @api public
109
110
  # @!method keymap
110
111
  # @see Vedeu::Input::DSL.keymap
111
112
  def_delegators Vedeu::Input::DSL,
@@ -166,6 +166,7 @@ module Vedeu
166
166
 
167
167
  end # Input
168
168
 
169
+ # @api public
169
170
  # @!method keypress
170
171
  # @see Vedeu::Input::Mapper.keypress
171
172
  def_delegators Vedeu::Input::Mapper,
@@ -137,6 +137,7 @@ module Vedeu
137
137
 
138
138
  end # Input
139
139
 
140
+ # @api public
140
141
  # @!method read
141
142
  # @see Vedeu::Input::Read#read
142
143
  def_delegators Vedeu::Input::Read,
@@ -21,6 +21,7 @@ module Vedeu
21
21
  # @example
22
22
  # Vedeu.keymaps
23
23
  #
24
+ # @api public
24
25
  # @!method keymaps
25
26
  # @return [Vedeu::Input::Repository]
26
27
  def_delegators Vedeu::Input::Repository,
@@ -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::Buffers::Terminal.update(output)
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,
@@ -328,6 +328,7 @@ module Vedeu
328
328
 
329
329
  end # Interfaces
330
330
 
331
+ # @api public
331
332
  # @!method interface
332
333
  # @see Vedeu::Interfaces::DSL.interface
333
334
  def_delegators Vedeu::Interfaces::DSL,
@@ -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,
@@ -39,6 +39,7 @@ module Vedeu
39
39
  # @example
40
40
  # Vedeu.interfaces
41
41
  #
42
+ # @api public
42
43
  # @!method interfaces
43
44
  # @return [Vedeu::Interfaces::Repository]
44
45
  def_delegators Vedeu::Interfaces::Repository,
@@ -27,6 +27,7 @@ module Vedeu
27
27
 
28
28
  end # Logging
29
29
 
30
+ # @api public
30
31
  # @!method clock_time
31
32
  # {include:file:docs/dsl/by_method/clock_time.md}
32
33
  def_delegators Vedeu::Logging::ClockTime,
@@ -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,
@@ -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,
@@ -86,6 +86,7 @@ module Vedeu
86
86
  end # Logging
87
87
 
88
88
  # {include:file:docs/dsl/by_method/timer.md}
89
+ # @api public
89
90
  # @!method timer
90
91
  # @see Vedeu::Logging::Timer.timer
91
92
  def_delegators Vedeu::Logging::Timer,
@@ -211,6 +211,7 @@ module Vedeu
211
211
 
212
212
  end # Menus
213
213
 
214
+ # @api public
214
215
  # @!method menu
215
216
  # @see Vedeu::Menus::DSL.menu
216
217
  def_delegators Vedeu::Menus::DSL,
@@ -22,6 +22,7 @@ module Vedeu
22
22
  # @example
23
23
  # Vedeu.menus
24
24
  #
25
+ # @api public
25
26
  # @!method menus
26
27
  # @return [Vedeu::Menus::Repository]
27
28
  def_delegators Vedeu::Menus::Repository,
@@ -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,
@@ -11,6 +11,7 @@ module Vedeu
11
11
 
12
12
  end # Vedeu
13
13
 
14
+ require 'vedeu/output/compressors/all'
14
15
  require 'vedeu/output/compressor_cache'
15
16
  require 'vedeu/output/compressor'
16
17
  require 'vedeu/output/output'
@@ -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 cached if compression?
42
+ return [] unless output?
44
43
 
45
- uncompress
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
- @content ||= if present?(output)
59
- output.content.reject(&:cell?)
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: "#{message} -> #{out.size} characters")
110
-
111
- out
64
+ message: "Orignal size: #{content_size} / " \
65
+ "New size: #{cells.size}")
112
66
  end
113
67
  end
114
68
 
115
- # @return [String]
116
- def uncompress
117
- out = content.map(&:to_s).join
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
- # Compress by not repeatedly sending the same colours for each
141
- # character which has the same colours as the last character
142
- # output.
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 key [NilClass|Symbol]
20
- # @return [Array<void>]
21
- def read(key)
22
- storage.fetch(key, [])
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
- # @param key [NilClass|Symbol]
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
- storage.merge!(key => value)
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
- private
35
+ # @param content [Array<void>]
36
+ # @return [String]
37
+ def compress(content)
38
+ Vedeu::Output::Compressors::Character.with(content)
39
+ end
35
40
 
36
- # @return [Hash<Symbol => Array<void>>]
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
- compressed: '',
50
+ compress: '',
40
51
  original: [],
52
+ uncompress: '',
41
53
  }
42
54
  end
43
55
 
44
56
  # @param key [NilClass|Symbol]
45
- # @return [Boolean]
46
- def invalid_key?(key)
47
- key.nil? || !in_memory.keys.include?(key)
57
+ # @return [Array<void>]
58
+ def read(key)
59
+ storage.fetch(key, [])
48
60
  end
49
61
 
50
- # @param value [Array|NilClass]
51
- # @return [Boolean]
52
- def invalid_value?(value)
53
- value.nil? || value.empty?
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'