vedeu 0.4.13 → 0.4.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (251) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -1
  3. data/.travis.yml +2 -1
  4. data/Guardfile +6 -5
  5. data/README.md +3 -30
  6. data/Rakefile +5 -5
  7. data/bin/vedeu_drb_client +1 -1
  8. data/bin/vedeu_drb_server +91 -89
  9. data/bin/vedeu_test +4 -0
  10. data/config/rubocop_enabled.yml +5 -10
  11. data/examples/borders_app.rb +2 -1
  12. data/examples/colours_app.rb +13 -8
  13. data/examples/configuration_app.rb +3 -2
  14. data/examples/cursor_app.rb +16 -11
  15. data/examples/drb_app.rb +88 -89
  16. data/examples/focus_app.rb +31 -32
  17. data/examples/geometry_app.rb +2 -1
  18. data/examples/hello_world.rb +2 -1
  19. data/examples/lines_app.rb +2 -1
  20. data/examples/material_colours_app.rb +126 -0
  21. data/examples/typed_commands/typed_commands_app.rb +5 -1
  22. data/examples/view_templates_app/view_templates_app.rb +6 -3
  23. data/lib/vedeu/all.rb +1 -1
  24. data/lib/vedeu/api.rb +18 -10
  25. data/lib/vedeu/application.rb +0 -1
  26. data/lib/vedeu/bindings.rb +77 -16
  27. data/lib/vedeu/buffers/all.rb +2 -5
  28. data/lib/vedeu/buffers/buffer.rb +69 -25
  29. data/lib/vedeu/buffers/display_buffer.rb +3 -7
  30. data/lib/vedeu/configuration/all.rb +3 -6
  31. data/lib/vedeu/configuration/api.rb +28 -4
  32. data/lib/vedeu/configuration/cli.rb +9 -9
  33. data/lib/vedeu/configuration/configuration.rb +11 -7
  34. data/lib/vedeu/cursor/all.rb +3 -6
  35. data/lib/vedeu/cursor/cursor.rb +22 -14
  36. data/lib/vedeu/cursor/move.rb +32 -22
  37. data/lib/vedeu/cursor/refresh_cursor.rb +1 -1
  38. data/lib/vedeu/debug.rb +2 -1
  39. data/lib/vedeu/distributed/client.rb +1 -7
  40. data/lib/vedeu/distributed/server.rb +0 -4
  41. data/lib/vedeu/distributed/subprocess.rb +1 -1
  42. data/lib/vedeu/distributed/templates/default_configuration.vedeu +1 -1
  43. data/lib/vedeu/distributed/test_application.rb +3 -5
  44. data/lib/vedeu/distributed/uri.rb +2 -2
  45. data/lib/vedeu/dsl/all.rb +6 -6
  46. data/lib/vedeu/dsl/components/all.rb +0 -3
  47. data/lib/vedeu/dsl/components/border.rb +20 -12
  48. data/lib/vedeu/dsl/components/geometry.rb +68 -3
  49. data/lib/vedeu/dsl/components/keymap.rb +1 -2
  50. data/lib/vedeu/dsl/composition.rb +8 -1
  51. data/lib/vedeu/dsl/interface.rb +61 -11
  52. data/lib/vedeu/dsl/line.rb +12 -12
  53. data/lib/vedeu/dsl/shared/all.rb +4 -7
  54. data/lib/vedeu/dsl/shared/colour.rb +2 -2
  55. data/lib/vedeu/dsl/shared/text.rb +2 -35
  56. data/lib/vedeu/dsl/shared/use.rb +2 -2
  57. data/lib/vedeu/dsl/view.rb +4 -4
  58. data/lib/vedeu/events/all.rb +3 -5
  59. data/lib/vedeu/events/event.rb +5 -5
  60. data/lib/vedeu/geometry/all.rb +11 -16
  61. data/lib/vedeu/geometry/area.rb +2 -5
  62. data/lib/vedeu/geometry/canvas.rb +12 -16
  63. data/lib/vedeu/geometry/dimension.rb +20 -22
  64. data/lib/vedeu/geometry/geometry.rb +28 -30
  65. data/lib/vedeu/geometry/grid.rb +1 -1
  66. data/lib/vedeu/geometry/index_position.rb +7 -0
  67. data/lib/vedeu/geometry/null_geometry.rb +61 -0
  68. data/lib/vedeu/geometry/position.rb +0 -3
  69. data/lib/vedeu/geometry/position_index.rb +7 -0
  70. data/lib/vedeu/geometry/position_validator.rb +44 -33
  71. data/lib/vedeu/input/all.rb +5 -4
  72. data/lib/vedeu/input/keymap.rb +0 -1
  73. data/lib/vedeu/input/mapper.rb +1 -3
  74. data/lib/vedeu/launcher.rb +6 -7
  75. data/lib/vedeu/main_loop.rb +1 -2
  76. data/lib/vedeu/models/all.rb +1 -0
  77. data/lib/vedeu/models/cell.rb +5 -8
  78. data/lib/vedeu/models/char.rb +50 -15
  79. data/lib/vedeu/models/composition.rb +8 -1
  80. data/lib/vedeu/models/focus.rb +4 -4
  81. data/lib/vedeu/models/group.rb +3 -3
  82. data/lib/vedeu/models/interface.rb +62 -46
  83. data/lib/vedeu/models/line.rb +1 -1
  84. data/lib/vedeu/models/null.rb +48 -0
  85. data/lib/vedeu/models/stream.rb +5 -5
  86. data/lib/vedeu/output/all.rb +20 -30
  87. data/lib/vedeu/output/border.rb +93 -40
  88. data/lib/vedeu/output/clear.rb +100 -15
  89. data/lib/vedeu/output/colour.rb +56 -12
  90. data/lib/vedeu/output/compressor.rb +59 -0
  91. data/lib/vedeu/output/html_char.rb +4 -2
  92. data/lib/vedeu/output/null_border.rb +16 -4
  93. data/lib/vedeu/output/output.rb +13 -21
  94. data/lib/vedeu/output/presentation.rb +28 -23
  95. data/lib/vedeu/output/refresh.rb +2 -2
  96. data/lib/vedeu/output/renderers/all.rb +80 -3
  97. data/lib/vedeu/output/renderers/file_renderer.rb +38 -2
  98. data/lib/vedeu/output/renderers/html_renderer.rb +6 -4
  99. data/lib/vedeu/output/renderers/json_renderer.rb +52 -0
  100. data/lib/vedeu/output/renderers/null_renderer.rb +14 -0
  101. data/lib/vedeu/output/renderers/terminal_renderer.rb +2 -12
  102. data/lib/vedeu/output/style.rb +33 -3
  103. data/lib/vedeu/output/text.rb +98 -1
  104. data/lib/vedeu/output/translator.rb +30 -7
  105. data/lib/vedeu/output/viewport.rb +43 -79
  106. data/lib/vedeu/output/wordwrap.rb +4 -4
  107. data/lib/vedeu/repositories/all.rb +22 -179
  108. data/lib/vedeu/repositories/collection.rb +11 -13
  109. data/lib/vedeu/repositories/collections/all.rb +8 -0
  110. data/lib/vedeu/repositories/collections/chars.rb +9 -0
  111. data/lib/vedeu/repositories/collections/events.rb +9 -0
  112. data/lib/vedeu/repositories/collections/interfaces.rb +9 -0
  113. data/lib/vedeu/repositories/collections/keys.rb +9 -0
  114. data/lib/vedeu/repositories/collections/lines.rb +9 -0
  115. data/lib/vedeu/repositories/collections/streams.rb +9 -0
  116. data/lib/vedeu/repositories/model.rb +7 -2
  117. data/lib/vedeu/repositories/repositories/all.rb +14 -0
  118. data/lib/vedeu/repositories/repositories/background_colours.rb +14 -0
  119. data/lib/vedeu/repositories/repositories/borders.rb +38 -0
  120. data/lib/vedeu/repositories/repositories/buffers.rb +36 -0
  121. data/lib/vedeu/repositories/repositories/colours.rb +63 -0
  122. data/lib/vedeu/repositories/repositories/cursors.rb +29 -0
  123. data/lib/vedeu/repositories/repositories/events_repository.rb +24 -0
  124. data/lib/vedeu/repositories/repositories/foreground_colours.rb +14 -0
  125. data/lib/vedeu/repositories/repositories/geometries.rb +37 -0
  126. data/lib/vedeu/repositories/repositories/groups.rb +24 -0
  127. data/lib/vedeu/repositories/repositories/interfaces_repository.rb +24 -0
  128. data/lib/vedeu/repositories/repositories/keymaps.rb +24 -0
  129. data/lib/vedeu/repositories/repositories/menus.rb +24 -0
  130. data/lib/vedeu/repositories/repository.rb +29 -47
  131. data/lib/vedeu/storage/all.rb +6 -0
  132. data/lib/vedeu/storage/associative_store.rb +47 -0
  133. data/lib/vedeu/storage/conveyor_store.rb +69 -0
  134. data/lib/vedeu/storage/fifo_store.rb +37 -0
  135. data/lib/vedeu/storage/store.rb +58 -0
  136. data/lib/vedeu/support/all.rb +5 -10
  137. data/lib/vedeu/support/common.rb +0 -8
  138. data/lib/vedeu/support/log.rb +13 -24
  139. data/lib/vedeu/support/template.rb +4 -1
  140. data/lib/vedeu/support/terminal.rb +10 -10
  141. data/lib/vedeu/support/trace.rb +15 -88
  142. data/lib/vedeu/support/visibility.rb +73 -0
  143. data/lib/vedeu.rb +37 -0
  144. data/test/lib/vedeu/api_test.rb +7 -3
  145. data/test/lib/vedeu/application_test.rb +9 -3
  146. data/test/lib/vedeu/bindings_test.rb +21 -0
  147. data/test/lib/vedeu/buffers/buffer_test.rb +110 -134
  148. data/test/lib/vedeu/buffers/display_buffer_test.rb +8 -0
  149. data/test/lib/vedeu/configuration/api_test.rb +5 -1
  150. data/test/lib/vedeu/configuration/configuration_test.rb +4 -6
  151. data/test/lib/vedeu/cursor/cursor_test.rb +25 -17
  152. data/test/lib/vedeu/cursor/move_test.rb +7 -7
  153. data/test/lib/vedeu/distributed/client_test.rb +1 -1
  154. data/test/lib/vedeu/distributed/subprocess_test.rb +3 -1
  155. data/test/lib/vedeu/distributed/uri_test.rb +5 -5
  156. data/test/lib/vedeu/dsl/components/geometry_test.rb +43 -0
  157. data/test/lib/vedeu/dsl/components/keymap_test.rb +1 -1
  158. data/test/lib/vedeu/dsl/composition_test.rb +6 -5
  159. data/test/lib/vedeu/dsl/interface_test.rb +81 -16
  160. data/test/lib/vedeu/dsl/shared/colour_test.rb +4 -4
  161. data/test/lib/vedeu/dsl/shared/text_test.rb +87 -9
  162. data/test/lib/vedeu/dsl/stream_test.rb +1 -1
  163. data/test/lib/vedeu/events/event_test.rb +3 -1
  164. data/test/lib/vedeu/events/trigger_test.rb +8 -4
  165. data/test/lib/vedeu/geometry/dimension_test.rb +1 -1
  166. data/test/lib/vedeu/geometry/geometry_test.rb +5 -3
  167. data/test/lib/vedeu/geometry/index_position_test.rb +30 -7
  168. data/test/lib/vedeu/geometry/null_geometry_test.rb +57 -0
  169. data/test/lib/vedeu/geometry/position_index_test.rb +14 -0
  170. data/test/lib/vedeu/geometry/position_validator_test.rb +17 -3
  171. data/test/lib/vedeu/input/keymap_test.rb +3 -1
  172. data/test/lib/vedeu/input/mapper_test.rb +8 -4
  173. data/test/lib/vedeu/launcher_test.rb +1 -1
  174. data/test/lib/vedeu/models/cell_test.rb +10 -8
  175. data/test/lib/vedeu/models/char_test.rb +52 -28
  176. data/test/lib/vedeu/models/composition_test.rb +26 -4
  177. data/test/lib/vedeu/models/group_test.rb +11 -5
  178. data/test/lib/vedeu/models/interface_test.rb +32 -19
  179. data/test/lib/vedeu/models/line_test.rb +21 -25
  180. data/test/lib/vedeu/models/menu_test.rb +10 -6
  181. data/test/lib/vedeu/models/null_test.rb +66 -0
  182. data/test/lib/vedeu/models/stream_test.rb +13 -10
  183. data/test/lib/vedeu/output/border_test.rb +29 -8
  184. data/test/lib/vedeu/output/clear_test.rb +23 -4
  185. data/test/lib/vedeu/output/colour_test.rb +20 -4
  186. data/test/lib/vedeu/output/compressor_test.rb +43 -0
  187. data/test/lib/vedeu/output/html_char_test.rb +29 -17
  188. data/test/lib/vedeu/output/null_border_test.rb +2 -1
  189. data/test/lib/vedeu/output/output_test.rb +20 -30
  190. data/test/lib/vedeu/output/presentation_test.rb +39 -16
  191. data/test/lib/vedeu/output/refresh_test.rb +14 -10
  192. data/test/lib/vedeu/output/renderers/all_test.rb +96 -0
  193. data/test/lib/vedeu/output/renderers/file_renderer_test.rb +1 -1
  194. data/test/lib/vedeu/output/renderers/html_renderer_test.rb +13 -9
  195. data/test/lib/vedeu/output/renderers/json_renderer_test.rb +52 -0
  196. data/test/lib/vedeu/output/renderers/null_renderer_test.rb +19 -0
  197. data/test/lib/vedeu/output/style_test.rb +41 -1
  198. data/test/lib/vedeu/output/text_test.rb +61 -10
  199. data/test/lib/vedeu/output/translator_test.rb +14 -0
  200. data/test/lib/vedeu/output/viewport_test.rb +22 -3
  201. data/test/lib/vedeu/output/virtual_terminal_test.rb +3 -3
  202. data/test/lib/vedeu/output/wordwrap_test.rb +58 -45
  203. data/test/lib/vedeu/repositories/collections/chars_test.rb +16 -0
  204. data/test/lib/vedeu/repositories/collections/events_test.rb +16 -0
  205. data/test/lib/vedeu/repositories/collections/interfaces_test.rb +16 -0
  206. data/test/lib/vedeu/repositories/collections/keys_test.rb +16 -0
  207. data/test/lib/vedeu/repositories/collections/lines_test.rb +16 -0
  208. data/test/lib/vedeu/repositories/collections/streams_test.rb +16 -0
  209. data/test/lib/vedeu/repositories/repositories/background_colours_test.rb +17 -0
  210. data/test/lib/vedeu/repositories/repositories/borders_test.rb +51 -0
  211. data/test/lib/vedeu/repositories/repositories/buffers_test.rb +52 -0
  212. data/test/lib/vedeu/repositories/repositories/colours_test.rb +16 -0
  213. data/test/lib/vedeu/repositories/repositories/cursors_test.rb +39 -0
  214. data/test/lib/vedeu/repositories/repositories/events_repository_test.rb +17 -0
  215. data/test/lib/vedeu/repositories/repositories/foreground_colours_test.rb +17 -0
  216. data/test/lib/vedeu/repositories/repositories/geometries_test.rb +42 -0
  217. data/test/lib/vedeu/repositories/repositories/groups_test.rb +17 -0
  218. data/test/lib/vedeu/repositories/repositories/interfaces_repositories_test.rb +17 -0
  219. data/test/lib/vedeu/repositories/repositories/keymaps_test.rb +17 -0
  220. data/test/lib/vedeu/repositories/repositories/menus_test.rb +17 -0
  221. data/test/lib/vedeu/repositories/repository_test.rb +16 -36
  222. data/test/lib/vedeu/storage/associative_store_test.rb +69 -0
  223. data/test/lib/vedeu/storage/conveyor_store_test.rb +135 -0
  224. data/test/lib/vedeu/storage/fifo_store_test.rb +47 -0
  225. data/test/lib/vedeu/storage/store_test.rb +123 -0
  226. data/test/lib/vedeu/support/common_test.rb +0 -9
  227. data/test/lib/vedeu/support/terminal_test.rb +78 -55
  228. data/test/lib/vedeu/support/visibility_test.rb +80 -0
  229. data/test/test_helper.rb +13 -11
  230. data/vedeu.gemspec +4 -3
  231. metadata +92 -32
  232. data/lib/vedeu/cursor/toggle.rb +0 -55
  233. data/lib/vedeu/exceptions.rb +0 -37
  234. data/lib/vedeu/geometry/centre.rb +0 -85
  235. data/lib/vedeu/geometry/content.rb +0 -70
  236. data/lib/vedeu/geometry/limit.rb +0 -58
  237. data/lib/vedeu/output/compositor.rb +0 -62
  238. data/lib/vedeu/repositories/collections.rb +0 -41
  239. data/lib/vedeu/support/coercions.rb +0 -60
  240. data/lib/vedeu/support/sentence.rb +0 -91
  241. data/lib/vedeu/support/visible.rb +0 -90
  242. data/test/lib/vedeu/cursor/toggle_test.rb +0 -63
  243. data/test/lib/vedeu/geometry/centre_test.rb +0 -58
  244. data/test/lib/vedeu/geometry/content_test.rb +0 -98
  245. data/test/lib/vedeu/geometry/limit_test.rb +0 -30
  246. data/test/lib/vedeu/output/compositor_test.rb +0 -48
  247. data/test/lib/vedeu/repositories/all_test.rb +0 -135
  248. data/test/lib/vedeu/repositories/collections_test.rb +0 -71
  249. data/test/lib/vedeu/support/coercions_test.rb +0 -84
  250. data/test/lib/vedeu/support/sentence_test.rb +0 -56
  251. data/test/lib/vedeu/support/visible_test.rb +0 -161
data/lib/vedeu/debug.rb CHANGED
@@ -45,7 +45,8 @@ module Vedeu
45
45
  # - Creates a call graph report in HTML (separate files per thread)
46
46
  # RubyProf::GraphHtmlPrinter
47
47
 
48
- # - Creates a call graph report in GraphViz's DOT format which can be converted to an image
48
+ # - Creates a call graph report in GraphViz's DOT format which can be
49
+ # converted to an image
49
50
  # RubyProf::DotPrinter
50
51
 
51
52
  # - Creates a call tree report compatible with KCachegrind.
@@ -1,5 +1,3 @@
1
- require 'drb'
2
-
3
1
  module Vedeu
4
2
 
5
3
  module Distributed
@@ -39,7 +37,6 @@ module Vedeu
39
37
  puts 'Could not connect to DRb server, URI may be bad.'
40
38
 
41
39
  :drb_bad_uri
42
-
43
40
  end
44
41
 
45
42
  # Send input to the DRb server.
@@ -51,7 +48,6 @@ module Vedeu
51
48
 
52
49
  rescue DRb::DRbConnError
53
50
  drb_connection_error
54
-
55
51
  end
56
52
  alias_method :read, :input
57
53
 
@@ -63,7 +59,6 @@ module Vedeu
63
59
 
64
60
  rescue DRb::DRbConnError
65
61
  drb_connection_error
66
-
67
62
  end
68
63
  alias_method :write, :output
69
64
 
@@ -77,7 +72,7 @@ module Vedeu
77
72
  def shutdown
78
73
  server.shutdown
79
74
 
80
- Process.kill("KILL", server.pid)
75
+ Process.kill('KILL', server.pid)
81
76
 
82
77
  rescue DRb::DRbConnError
83
78
  drb_connection_error
@@ -87,7 +82,6 @@ module Vedeu
87
82
 
88
83
  ensure
89
84
  :shutdown
90
-
91
85
  end
92
86
 
93
87
  private
@@ -1,6 +1,3 @@
1
- require 'drb'
2
- require 'singleton'
3
-
4
1
  module Vedeu
5
2
 
6
3
  module Distributed
@@ -156,7 +153,6 @@ module Vedeu
156
153
  end
157
154
  rescue NoMethodError # raised when #join is called on NilClass.
158
155
  # ...
159
-
160
156
  end
161
157
 
162
158
  private
@@ -82,7 +82,7 @@ module Vedeu
82
82
 
83
83
  # @return [File]
84
84
  def file_open
85
- @file ||= File.new("/tmp/foo_#{timestamp}", "w", 0755)
85
+ @file ||= File.new("/tmp/foo_#{timestamp}", 'w', 0755)
86
86
  end
87
87
  alias_method :file, :file_open
88
88
 
@@ -1,5 +1,5 @@
1
1
  Vedeu.configure do
2
- colour_mode 16_777_216
2
+ colour_mode 256
3
3
  log '/tmp/vedeu_test_helper.log'
4
4
  debug!
5
5
  drb!
@@ -68,22 +68,20 @@ module Vedeu
68
68
  def initialize(attributes = {})
69
69
  @attributes = defaults.merge!(attributes)
70
70
 
71
- @attributes.each do |k, v|
72
- instance_variable_set("@#{k.to_s}", @attributes[k])
73
- end
71
+ @attributes.each { |k, _| instance_variable_set("@#{k}", @attributes[k]) }
74
72
  end
75
73
 
76
74
  # @param block [Proc]
77
75
  # @return [String]
78
76
  def build(&block)
79
- self.instance_eval(&block) if block_given?
77
+ instance_eval(&block) if block_given?
80
78
 
81
79
  Vedeu::Template.parse(self, template)
82
80
  end
83
81
 
84
82
  # @return [String]
85
83
  def lib_dir
86
- File.dirname(__FILE__) + "/../../../lib"
84
+ File.dirname(__FILE__) + '/../../../lib'
87
85
  end
88
86
 
89
87
  private
@@ -20,9 +20,9 @@ module Vedeu
20
20
  # @param host [String] Hostname or IP address.
21
21
  # @param port [Fixnum|String]
22
22
  # @return [Uri]
23
- def initialize(host = 'localhost', port = 21420)
23
+ def initialize(host = 'localhost', port = 21_420)
24
24
  @host = host || 'localhost'
25
- @port = port || 21420
25
+ @port = port || 21_420
26
26
  end
27
27
 
28
28
  # @example
data/lib/vedeu/dsl/all.rb CHANGED
@@ -1,12 +1,12 @@
1
1
  require 'vedeu/dsl/components/all'
2
2
  require 'vedeu/dsl/shared/all'
3
3
 
4
- require 'vedeu/dsl/composition'
5
- require 'vedeu/dsl/group'
6
- require 'vedeu/dsl/interface'
7
- require 'vedeu/dsl/line'
8
- require 'vedeu/dsl/stream'
9
- require 'vedeu/dsl/view'
4
+ require_relative 'composition'
5
+ require_relative 'group'
6
+ require_relative 'interface'
7
+ require_relative 'line'
8
+ require_relative 'stream'
9
+ require_relative 'view'
10
10
 
11
11
  module Vedeu
12
12
 
@@ -2,6 +2,3 @@ require_relative 'border'
2
2
  require_relative 'geometry'
3
3
  require_relative 'keymap'
4
4
  require_relative 'menu'
5
-
6
- module Vedeu
7
- end # Vedeu
@@ -117,11 +117,13 @@ module Vedeu
117
117
  # # ... or
118
118
  # show_bottom!
119
119
  #
120
- # @param boolean [Boolean] All values evaluate as true except nil and
120
+ # @param value [Boolean] All values evaluate as true except nil and
121
121
  # false.
122
122
  # @return [Boolean]
123
- def bottom(boolean)
124
- model.show_bottom = !!boolean
123
+ def bottom(value)
124
+ boolean = value ? true : false
125
+
126
+ model.show_bottom = boolean
125
127
  end
126
128
  alias_method :show_bottom, :bottom
127
129
 
@@ -147,11 +149,13 @@ module Vedeu
147
149
  # # ... or
148
150
  # show_left!
149
151
  #
150
- # @param boolean [Boolean] All values evaluate as true except nil and
152
+ # @param value [Boolean] All values evaluate as true except nil and
151
153
  # false.
152
154
  # @return [Boolean]
153
- def left(boolean)
154
- model.show_left = !!boolean
155
+ def left(value)
156
+ boolean = value ? true : false
157
+
158
+ model.show_left = boolean
155
159
  end
156
160
  alias_method :show_left, :left
157
161
 
@@ -177,11 +181,13 @@ module Vedeu
177
181
  # # ... or
178
182
  # show_right!
179
183
  #
180
- # @param boolean [Boolean] All values evaluate as true except nil and
184
+ # @param value [Boolean] All values evaluate as true except nil and
181
185
  # false.
182
186
  # @return [Boolean]
183
- def right(boolean)
184
- model.show_right = !!boolean
187
+ def right(value)
188
+ boolean = value ? true : false
189
+
190
+ model.show_right = boolean
185
191
  end
186
192
  alias_method :show_right, :right
187
193
 
@@ -225,11 +231,13 @@ module Vedeu
225
231
  # # ... or
226
232
  # show_top!
227
233
  #
228
- # @param boolean [Boolean] All values evaluate as true except nil and
234
+ # @param value [Boolean] All values evaluate as true except nil and
229
235
  # false.
230
236
  # @return [Boolean]
231
- def top(boolean)
232
- model.show_top = !!boolean
237
+ def top(value)
238
+ boolean = value ? true : false
239
+
240
+ model.show_top = boolean
233
241
  end
234
242
  alias_method :show_top, :top
235
243
 
@@ -56,7 +56,9 @@ module Vedeu
56
56
  #
57
57
  # @return [Boolean]
58
58
  def centred(value = true)
59
- model.centred = !!value
59
+ boolean = value ? true : false
60
+
61
+ model.centred = boolean
60
62
  end
61
63
  alias_method :centred!, :centred
62
64
 
@@ -76,6 +78,53 @@ module Vedeu
76
78
  model.height = value
77
79
  end
78
80
 
81
+ # Use the geometry of another interface as the basis for the geometry you
82
+ # are creating.
83
+ #
84
+ # @example
85
+ # geometry 'some_interface' do
86
+ # use 'other_interface' # will fetch the geometry of 'other_interface'
87
+ # # ...
88
+ #
89
+ # geometry 'other_interface' do
90
+ # centred!
91
+ # height 4
92
+ # # ...
93
+ #
94
+ # geometry 'some_interface' do
95
+ # use 'other_interface' # will fetch the geometry of 'other_interface'
96
+ # centred false
97
+ # # ...
98
+ #
99
+ # @note
100
+ # - When using 'use', the 'other_interface' (from the example) must
101
+ # already exist.
102
+ # - When using 'use', note that geometry defined before it's invocation
103
+ # will be overwritten by 'other_interface',
104
+ # - and geometry defined after will overwrite the inherited geometry.
105
+ # - Special geometry settings, like 'centred' also cause unexpected
106
+ # behaviour. If 'other_interface' was centred, then 'some_interface'
107
+ # will also be centred, to disable this, declare 'some_interface' to
108
+ # not be centred.
109
+ #
110
+ # @param name [String] The name of the interface you wish to use the
111
+ # geometry of.
112
+ # @raise [ModelNotFound] When the geometry to be used does not exist yet.
113
+ # @return [Vedeu::Geometry]
114
+ # def use(name)
115
+ # if Vedeu.geometries.registered?(name)
116
+ # other = Vedeu.geometries.find(name).dup
117
+ # other.name = name
118
+ # @model = other
119
+ # @model.store
120
+
121
+ # else
122
+ # fail ModelNotFound, "Cannot use the geometry of '#{name}', as it " \
123
+ # "is not yet defined."
124
+
125
+ # end
126
+ # end
127
+
79
128
  # Specify the number of characters/columns wide the interface will be.
80
129
  #
81
130
  # @param value [Fixnum]
@@ -122,12 +171,20 @@ module Vedeu
122
171
  # xn 37 # end at column 37.
123
172
  # # ...
124
173
  #
174
+ # geometry 'some_interface' do
175
+ # xn { use('other_interface').right } # if `other_interface` changes
176
+ # # ... # position, `some_interface`
177
+ # # will too.
178
+ #
125
179
  # @note
126
180
  # This value will override `width`.
127
181
  #
128
182
  # @param value [Fixnum]
183
+ # @param block [Proc]
129
184
  # @return [Fixnum]
130
- def xn(value)
185
+ def xn(value = 1, &block)
186
+ return model.xn = block if block_given?
187
+
131
188
  model.xn = value
132
189
  end
133
190
 
@@ -160,12 +217,20 @@ module Vedeu
160
217
  # yn 24 # end at row 24.
161
218
  # # ...
162
219
  #
220
+ # geometry 'some_interface' do
221
+ # yn { use('other_interface').bottom } # if `other_interface` changes
222
+ # # ... # position, `some_interface`
223
+ # # will too.
224
+ #
163
225
  # @note
164
226
  # This value will override `height`.
165
227
  #
166
228
  # @param value [Fixnum]
229
+ # @param block [Proc]
167
230
  # @return [Fixnum]
168
- def yn(value)
231
+ def yn(value = 1, &block)
232
+ return model.yn = block if block_given?
233
+
169
234
  model.yn = value
170
235
  end
171
236
 
@@ -1,4 +1,3 @@
1
- require 'vedeu/exceptions'
2
1
  require 'vedeu/support/common'
3
2
  require 'vedeu/input/key'
4
3
 
@@ -51,7 +50,7 @@ module Vedeu
51
50
  # @todo Try to remember why we need to pre-create the keymap in the
52
51
  # repository.
53
52
  def self.keymap(name, &block)
54
- Vedeu::Keymap.new({ name: name }).store
53
+ Vedeu::Keymap.new(name: name).store
55
54
 
56
55
  Vedeu::Keymap.build({ name: name }, &block).store
57
56
  end
@@ -69,7 +69,7 @@ module Vedeu
69
69
  content = Vedeu::Template.parse(object, filename)
70
70
  lines = Vedeu::Wordwrap.for(content, options)
71
71
 
72
- new_model = model.member.build(new_attributes(name).merge!({ lines: lines }))
72
+ new_model = model.member.build(template_attributes(name, lines))
73
73
 
74
74
  model.add(new_model)
75
75
  end
@@ -84,6 +84,13 @@ module Vedeu
84
84
  # @return [Composition]
85
85
  attr_reader :model
86
86
 
87
+ # @param name [String]
88
+ # @param lines [Vedeu::Lines]
89
+ # @return [Hash]
90
+ def template_attributes(name, lines)
91
+ new_attributes(name).merge!(lines: lines)
92
+ end
93
+
87
94
  # @param name [String] The name of the interface.
88
95
  # @return [Hash]
89
96
  def new_attributes(name)
@@ -33,14 +33,19 @@ module Vedeu
33
33
 
34
34
  # Allows the setting of a border for the interface.
35
35
  #
36
+ # @param name [String] The name of the interface; this is already provided
37
+ # when we define the interface or view, setting it here is just
38
+ # mirroring functionality of {Vedeu::DSL::Border.border}.
36
39
  # @param block [Proc]
37
40
  # @raise [InvalidSyntax] The required block was not given.
38
41
  # @return [Vedeu::Border]
39
- def border(&block)
42
+ def border(name = nil, &block)
40
43
  fail InvalidSyntax, 'block not given' unless block_given?
41
44
 
42
- border_attrs = attributes.merge!({ enabled: true,
43
- name: model.name })
45
+ model_name = name ? name : model.name
46
+
47
+ border_attrs = attributes.merge!(enabled: true,
48
+ name: model_name)
44
49
 
45
50
  Vedeu::Border.build(border_attrs, &block).store
46
51
  end
@@ -67,8 +72,7 @@ module Vedeu
67
72
  # # ...
68
73
  #
69
74
  # cursor false # => hide the cursor for this interface
70
- # cursor :hide # => both of these are equivalent to line above
71
- # cursor nil #
75
+ # cursor nil # => as above
72
76
  # # ...
73
77
  #
74
78
  # view 'my_interface' do
@@ -77,7 +81,9 @@ module Vedeu
77
81
  #
78
82
  # @return [Cursor]
79
83
  def cursor(value = true)
80
- Vedeu::Cursor.new({ name: model.name, state: value }).store
84
+ boolean = value ? true : false
85
+
86
+ Vedeu::Cursor.new(name: model.name, visible: boolean).store
81
87
  end
82
88
 
83
89
  # Set the cursor to visible for the interface.
@@ -115,20 +121,24 @@ module Vedeu
115
121
 
116
122
  # Define the geometry for an interface.
117
123
  #
118
- # @param block [Proc]
119
- #
120
124
  # @example
121
125
  # interface 'my_interface' do
122
126
  # geometry do
123
127
  # # ...
124
128
  #
129
+ # @param name [String] The name of the interface; this is already provided
130
+ # when we define the interface or view, setting it here is just
131
+ # mirroring functionality of {Vedeu::DSL::Geometry.geometry}.
132
+ # @param block [Proc]
125
133
  # @raise [InvalidSyntax] The required block was not given.
126
134
  # @return [Geometry]
127
135
  # @see Vedeu::DSL::Geometry
128
- def geometry(&block)
136
+ def geometry(name = nil, &block)
129
137
  fail InvalidSyntax, 'block not given' unless block_given?
130
138
 
131
- Vedeu::Geometry.build({ name: model.name }, &block).store
139
+ model_name = name ? name : model.name
140
+
141
+ Vedeu::Geometry.build({ name: model_name }, &block).store
132
142
  end
133
143
 
134
144
  # Specify a group for an interface. Interfaces of the same group can be
@@ -151,7 +161,7 @@ module Vedeu
151
161
  Vedeu.groups.find(name).add(model.name)
152
162
 
153
163
  else
154
- new_group = Vedeu::Group.new({ name: name })
164
+ new_group = Vedeu::Group.new(name: name)
155
165
  new_group.add(model.name)
156
166
 
157
167
  end
@@ -204,6 +214,46 @@ module Vedeu
204
214
  model.name = value
205
215
  end
206
216
 
217
+ # Set the interface to visible.
218
+ #
219
+ # @return [void]
220
+ def show!
221
+ visible(true)
222
+ end
223
+
224
+ # Set the interface to invisible.
225
+ #
226
+ # @return [void]
227
+ def hide!
228
+ visible(false)
229
+ end
230
+
231
+ # Set the visibility of the interface.
232
+ #
233
+ # @param value [Boolean] Any value other than nil or false will evaluate
234
+ # to true.
235
+ #
236
+ # @example
237
+ # interface 'my_interface' do
238
+ # visible true # => show the interface
239
+ # show! # => as above
240
+ # # ...
241
+ #
242
+ # visible false # => hide the interface
243
+ # hide! # => as above
244
+ # # ...
245
+ #
246
+ # view 'my_interface' do
247
+ # visible false
248
+ # # ...
249
+ #
250
+ # @return [void]
251
+ def visible(value = true)
252
+ boolean = value ? true : false
253
+
254
+ model.visible = boolean
255
+ end
256
+
207
257
  private
208
258
 
209
259
  # @!attribute [r] client
@@ -67,21 +67,21 @@ module Vedeu
67
67
  # @return [Vedeu::Lines]
68
68
  def line(value = '', &block)
69
69
  content = if block_given?
70
- Vedeu::Line.build({ client: client,
71
- parent: model.parent }, &block)
70
+ Vedeu::Line.build({ client: client,
71
+ parent: model.parent }, &block)
72
72
 
73
- elsif value
74
- stream = Vedeu::Stream.build({ client: client,
75
- parent: model,
76
- value: value })
77
- Vedeu::Line.build({ client: client,
78
- parent: model.parent,
79
- streams: [stream] })
73
+ elsif value
74
+ stream = Vedeu::Stream.build(client: client,
75
+ parent: model,
76
+ value: value)
77
+ Vedeu::Line.build(client: client,
78
+ parent: model.parent,
79
+ streams: [stream])
80
80
 
81
- else
82
- fail InvalidSyntax, 'block not given'
81
+ else
82
+ fail InvalidSyntax, 'block not given'
83
83
 
84
- end
84
+ end
85
85
 
86
86
  model.parent.add(content)
87
87
  end
@@ -1,7 +1,4 @@
1
- require 'vedeu/dsl/shared/text'
2
- require 'vedeu/dsl/shared/colour'
3
- require 'vedeu/dsl/shared/style'
4
- require 'vedeu/dsl/shared/use'
5
-
6
- module Vedeu
7
- end # Vedeu
1
+ require_relative 'colour'
2
+ require_relative 'style'
3
+ require_relative 'text'
4
+ require_relative 'use'
@@ -36,14 +36,14 @@ module Vedeu
36
36
  #
37
37
  # @return [String]
38
38
  def background(value = '')
39
- colour({ background: value })
39
+ colour(background: value)
40
40
  end
41
41
  alias_method :bg, :background
42
42
  alias_method :bgcolor, :background
43
43
 
44
44
  # @see Vedeu::DSL::Colour#background
45
45
  def foreground(value = '')
46
- colour({ foreground: value })
46
+ colour(foreground: value)
47
47
  end
48
48
  alias_method :fg, :foreground
49
49
  alias_method :fgcolor, :foreground
@@ -55,24 +55,9 @@ module Vedeu
55
55
  # than the specified width.
56
56
  # @return [String]
57
57
  def text(value = '', options = {})
58
- output = Vedeu::Text.with(value, options.merge!({ anchor: __callee__ }))
58
+ options.merge!(anchor: __callee__, model: model)
59
59
 
60
- content = if model.is_a?(Vedeu::Interface)
61
- stream = stream_builder({ value: output })
62
- Vedeu::Line.build({ streams: [stream], parent: model })
63
-
64
- elsif model.is_a?(Vedeu::Line)
65
- stream_builder({ value: output })
66
-
67
- elsif model.is_a?(Vedeu::Stream)
68
- stream_builder({ value: output, parent: model.parent })
69
-
70
- else
71
- # should never get here
72
-
73
- end
74
-
75
- model.add(content)
60
+ Vedeu::Text.add(value, options)
76
61
  end
77
62
  alias_method :align, :text
78
63
  alias_method :center, :text
@@ -80,24 +65,6 @@ module Vedeu
80
65
  alias_method :left, :text
81
66
  alias_method :right, :text
82
67
 
83
- private
84
-
85
- # @param attrs [Hash]
86
- # @return [Vedeu::Stream]
87
- def stream_builder(attrs)
88
- Vedeu::Stream.build(stream_attributes(attrs))
89
- end
90
-
91
- # @param attrs [Hash]
92
- # @return [Hash]
93
- def stream_attributes(attrs)
94
- {
95
- colour: model.colour,
96
- parent: model,
97
- style: model.style,
98
- }.merge!(attrs)
99
- end
100
-
101
68
  end # Text
102
69
 
103
70
  end # DSL
@@ -36,8 +36,8 @@ module Vedeu
36
36
  def use(value)
37
37
  if Vedeu.interfaces.registered?(value) == false
38
38
  fail ModelNotFound, "The properties of this interface (#{value}) " \
39
- "cannot be used, since the interface has not " \
40
- "been defined."
39
+ 'cannot be used, since the interface has not ' \
40
+ 'been defined.'
41
41
  end
42
42
 
43
43
  Vedeu.interfaces.find(value)
@@ -69,12 +69,12 @@ module Vedeu
69
69
  #
70
70
  # @note The views declared within this block are stored in their
71
71
  # respective interface back buffers until a refresh event occurs. When
72
- # the refresh event is triggered, the back buffers are swapped into the
73
- # front buffers and the content here will be rendered to
72
+ # the refresh event is triggered, the back buffers are swapped into
73
+ # the front buffers and the content here will be rendered to
74
74
  # {Vedeu::Terminal.output}.
75
75
  #
76
- # @param block [Proc] The directives you wish to send to render. Typically
77
- # includes `view` with associated sub-directives.
76
+ # @param block [Proc] The directives you wish to send to render.
77
+ # Typically includes `view` with associated sub-directives.
78
78
  #
79
79
  # @example
80
80
  # Vedeu.views do
@@ -1,6 +1,4 @@
1
- require 'vedeu/repositories/collections'
2
- require 'vedeu/events/event'
3
- require 'vedeu/events/trigger'
1
+ require 'vedeu/repositories/collections/all'
4
2
 
5
- module Vedeu
6
- end # Vedeu
3
+ require_relative 'event'
4
+ require_relative 'trigger'