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
@@ -40,7 +40,7 @@ module Vedeu
40
40
  # Register an event by name with optional delay (throttling) which when
41
41
  # triggered will execute the code contained within the passed block.
42
42
  #
43
- # @param name [Symbol] The name of the event which will be triggered later.
43
+ # @param name [Symbol] The name of the event to be triggered later.
44
44
  # @param options [Hash] The options to register the event with.
45
45
  # @option options :delay [Fixnum|Float] Limits the execution of the
46
46
  # triggered event to only execute when first triggered, with subsequent
@@ -49,8 +49,8 @@ module Vedeu
49
49
  # triggered event to only execute once the debounce has expired.
50
50
  # Subsequent triggers before debounce expiry are ignored.
51
51
  # @param block [Proc] The event to be executed when triggered. This block
52
- # could be a method call, or the triggering of another event, or sequence
53
- # of either/both.
52
+ # could be a method call, or the triggering of another event, or
53
+ # sequence of either/both.
54
54
  #
55
55
  # @example
56
56
  # Vedeu.bind :my_event do |some, args|
@@ -218,7 +218,7 @@ module Vedeu
218
218
  def debouncing?
219
219
  set_time
220
220
 
221
- set_deadline unless has_deadline?
221
+ set_deadline unless deadline?
222
222
 
223
223
  options[:debounce] > 0
224
224
  end
@@ -259,7 +259,7 @@ module Vedeu
259
259
  # Returns a boolean indicating if this event has a deadline.
260
260
  #
261
261
  # @return [Boolean]
262
- def has_deadline?
262
+ def deadline?
263
263
  @deadline > 0
264
264
  end
265
265
 
@@ -1,16 +1,11 @@
1
- require 'vedeu/geometry/area'
2
- require 'vedeu/geometry/canvas'
3
- require 'vedeu/geometry/centre'
4
- require 'vedeu/geometry/content'
5
- require 'vedeu/geometry/coordinate'
6
- require 'vedeu/geometry/dimension'
7
- require 'vedeu/geometry/geometry'
8
- require 'vedeu/geometry/grid'
9
- require 'vedeu/geometry/index_position'
10
- require 'vedeu/geometry/limit'
11
- require 'vedeu/geometry/position_index'
12
- require 'vedeu/geometry/position'
13
- require 'vedeu/geometry/position_validator'
14
-
15
- module Vedeu
16
- end # Vedeu
1
+ require_relative 'area'
2
+ require_relative 'canvas'
3
+ require_relative 'coordinate'
4
+ require_relative 'dimension'
5
+ require_relative 'geometry'
6
+ require_relative 'grid'
7
+ require_relative 'index_position'
8
+ require_relative 'null_geometry'
9
+ require_relative 'position_index'
10
+ require_relative 'position'
11
+ require_relative 'position_validator'
@@ -58,11 +58,8 @@ module Vedeu
58
58
  # @param other [Vedeu::Area]
59
59
  # @return [Boolean]
60
60
  def eql?(other)
61
- self.class == other.class &&
62
- y == other.y &&
63
- yn == other.yn &&
64
- x == other.x &&
65
- xn == other.xn
61
+ self.class == other.class && y == other.y && yn == other.yn &&
62
+ x == other.x && xn == other.xn
66
63
  end
67
64
  alias_method :==, :eql?
68
65
 
@@ -1,5 +1,3 @@
1
- require 'singleton'
2
-
3
1
  module Vedeu
4
2
 
5
3
  # The size of the terminal is a limitation. Defining a canvas means we have
@@ -9,6 +7,18 @@ module Vedeu
9
7
 
10
8
  include Singleton
11
9
 
10
+ # @!attribute [r] yn
11
+ # @return [Fixnum]
12
+ attr_reader :yn
13
+ alias_method :bottom, :yn
14
+ alias_method :height, :yn
15
+
16
+ # @!attribute [r] xn
17
+ # @return [Fixnum]
18
+ attr_reader :xn
19
+ alias_method :right, :xn
20
+ alias_method :width, :xn
21
+
12
22
  # @return [Vedeu::Canvas]
13
23
  def self.canvas
14
24
  instance
@@ -64,26 +74,12 @@ module Vedeu
64
74
  end
65
75
  alias_method :top, :y
66
76
 
67
- # @return [Fixnum]
68
- def yn
69
- @yn
70
- end
71
- alias_method :bottom, :yn
72
- alias_method :height, :yn
73
-
74
77
  # @return [Fixnum]
75
78
  def x
76
79
  1
77
80
  end
78
81
  alias_method :left, :x
79
82
 
80
- # @return [Fixnum]
81
- def xn
82
- @xn
83
- end
84
- alias_method :right, :xn
85
- alias_method :width, :xn
86
-
87
83
  end # Canvas
88
84
 
89
85
  end # Vedeu
@@ -45,50 +45,51 @@ module Vedeu
45
45
  private
46
46
 
47
47
  # @!attribute [r] d
48
- # @return [Fixnum]
48
+ # @return [Fixnum|NilClass]
49
49
  attr_reader :d
50
50
 
51
51
  # @!attribute [r] dn
52
- # @return [Fixnum]
52
+ # @return [Fixnum|NilClass]
53
53
  attr_reader :dn
54
54
 
55
55
  # @!attribute [r] d_dn
56
- # @return [Fixnum]
56
+ # @return [Fixnum|NilClass]
57
57
  attr_reader :d_dn
58
58
 
59
59
  # @!attribute [r] default
60
- # @return [Fixnum]
60
+ # @return [Fixnum|NilClass]
61
61
  attr_reader :default
62
62
 
63
63
  # @return [Array<Fixnum>]
64
64
  def dimension
65
65
  @dimension ||= if centred? && length?
66
- [(default / 2) - (length / 2), (default / 2) + (length / 2)]
66
+ [(default / 2) - (length / 2),
67
+ (default / 2) + (length / 2)]
67
68
 
68
- elsif d && dn
69
- [d, dn]
69
+ elsif d && dn
70
+ [d, dn]
70
71
 
71
- elsif d && d_dn
72
- [d, (d + d_dn)]
72
+ elsif d && d_dn
73
+ [d, ((d + d_dn) - 1)]
73
74
 
74
- elsif d_dn
75
- [1, d_dn]
75
+ elsif d_dn
76
+ [1, d_dn]
76
77
 
77
- elsif d
78
- [d, default]
78
+ elsif d
79
+ [d, default]
79
80
 
80
- elsif dn
81
- [1, dn]
81
+ elsif dn
82
+ [1, dn]
82
83
 
83
- else
84
- [1, default]
84
+ else
85
+ [1, default]
85
86
 
86
- end
87
+ end
87
88
  end
88
89
 
89
90
  # @return [Boolean]
90
91
  def length?
91
- !!(default) && !!(length)
92
+ default && length
92
93
  end
93
94
 
94
95
  # @return [Fixnum|NilClass]
@@ -102,9 +103,6 @@ module Vedeu
102
103
  elsif default
103
104
  default
104
105
 
105
- else
106
- nil
107
-
108
106
  end
109
107
  end
110
108
 
@@ -33,24 +33,24 @@ module Vedeu
33
33
  include Vedeu::Model
34
34
 
35
35
  def_delegators :area,
36
- :north,
37
- :east,
38
- :south,
39
- :west,
40
- :top,
41
- :right,
42
- :bottom,
43
- :left,
44
- :y,
45
- :xn,
46
- :yn,
47
- :x,
48
- :height,
49
- :width,
50
- :top_left,
51
- :top_right,
52
- :bottom_left,
53
- :bottom_right
36
+ :north,
37
+ :east,
38
+ :south,
39
+ :west,
40
+ :top,
41
+ :right,
42
+ :bottom,
43
+ :left,
44
+ :y,
45
+ :xn,
46
+ :yn,
47
+ :x,
48
+ :height,
49
+ :width,
50
+ :top_left,
51
+ :top_right,
52
+ :bottom_left,
53
+ :bottom_right
54
54
 
55
55
  # @!attribute [rw] centred
56
56
  # @return [Boolean]
@@ -122,22 +122,20 @@ module Vedeu
122
122
 
123
123
  # @return [Array<Fixnum>]
124
124
  def x_xn
125
- @x_xn ||= Vedeu::Dimension.pair({ d: _x,
126
- dn: _xn,
127
- d_dn: @width,
128
- default: Vedeu::Terminal.width,
129
- options: { centred: centred }
130
- })
125
+ @x_xn ||= Vedeu::Dimension.pair(d: _x,
126
+ dn: _xn,
127
+ d_dn: @width,
128
+ default: Vedeu::Terminal.width,
129
+ options: { centred: centred })
131
130
  end
132
131
 
133
132
  # @return [Array<Fixnum>]
134
133
  def y_yn
135
- @y_yn ||= Vedeu::Dimension.pair({ d: _y,
136
- dn: _yn,
137
- d_dn: @height,
138
- default: Vedeu::Terminal.height,
139
- options: { centred: centred }
140
- })
134
+ @y_yn ||= Vedeu::Dimension.pair(d: _y,
135
+ dn: _yn,
136
+ d_dn: @height,
137
+ default: Vedeu::Terminal.height,
138
+ options: { centred: centred })
141
139
  end
142
140
 
143
141
  # Returns the row/line start position for the interface.
@@ -44,7 +44,7 @@ module Vedeu
44
44
  # @return [Fixnum|OutOfRange]
45
45
  def columns
46
46
  fail OutOfRange,
47
- 'Valid value between 1 and 12 inclusive.' if out_of_range?
47
+ 'Valid value between 1 and 12 inclusive.' if out_of_range?
48
48
 
49
49
  column * value
50
50
  end
@@ -51,6 +51,13 @@ module Vedeu
51
51
  Vedeu::Position.new(y, x)
52
52
  end
53
53
 
54
+ # @param other [Vedeu::IndexPosition]
55
+ # @return [Boolean]
56
+ def eql?(other)
57
+ self.class == other.class && (x == other.x && y == other.y)
58
+ end
59
+ alias_method :==, :eql?
60
+
54
61
  # @return [Fixnum]
55
62
  def y
56
63
  (iy <= 0) ? oy : (iy + oy)
@@ -0,0 +1,61 @@
1
+ module Vedeu
2
+
3
+ # Provides geometry for interfaces that do not have geometry defined.
4
+ #
5
+ class NullGeometry
6
+
7
+ extend Forwardable
8
+
9
+ def_delegators :area,
10
+ :north,
11
+ :east,
12
+ :south,
13
+ :west,
14
+ :top,
15
+ :right,
16
+ :bottom,
17
+ :left,
18
+ :y,
19
+ :xn,
20
+ :yn,
21
+ :x,
22
+ :height,
23
+ :width,
24
+ :top_left,
25
+ :top_right,
26
+ :bottom_left,
27
+ :bottom_right
28
+
29
+ # @return [Vedeu::NullGeometry]
30
+ def initialize; end
31
+
32
+ # @return [FalseClass]
33
+ def centred
34
+ false
35
+ end
36
+
37
+ # @return [Vedeu::NullGeometry]
38
+ def store
39
+ self
40
+ end
41
+
42
+ private
43
+
44
+ # @return [Vedeu::Area]
45
+ def area
46
+ @area ||= Vedeu::Area.from_dimensions(y_yn: y_yn, x_xn: x_xn)
47
+ end
48
+
49
+ # @return [Array<Fixnum>]
50
+ def x_xn
51
+ @x_xn ||= Vedeu::Dimension.pair(default: Vedeu::Terminal.width)
52
+ end
53
+
54
+ # @return [Array<Fixnum>]
55
+ def y_yn
56
+ @y_yn ||= Vedeu::Dimension.pair(default: Vedeu::Terminal.height)
57
+ end
58
+
59
+ end # NullGeometry
60
+
61
+ end # Vedeu
@@ -32,9 +32,6 @@ module Vedeu
32
32
  elsif value.is_a?(Hash)
33
33
  new(value.fetch(:y, 1), value.fetch(:x, 1))
34
34
 
35
- else
36
- # not sure how to proceed
37
-
38
35
  end
39
36
  end
40
37
 
@@ -35,6 +35,13 @@ module Vedeu
35
35
  [y, x]
36
36
  end
37
37
 
38
+ # @param other [Vedeu::PositionIndex]
39
+ # @return [Boolean]
40
+ def eql?(other)
41
+ self.class == other.class && (x == other.x && y == other.y)
42
+ end
43
+ alias_method :==, :eql?
44
+
38
45
  # @return [Vedeu::Position]
39
46
  def to_position
40
47
  Vedeu::Position.new(y, x)
@@ -3,34 +3,30 @@ require 'vedeu/support/terminal'
3
3
  module Vedeu
4
4
 
5
5
  # Validates that the provided coordinates are within the terminal and
6
- # interface (with or without a border).
6
+ # interface's geometry (with or without a border).
7
7
  #
8
8
  class PositionValidator
9
9
 
10
10
  extend Forwardable
11
11
 
12
- def_delegators Vedeu::Terminal,
13
- :tx,
14
- :ty,
15
- :txn,
16
- :tyn
17
-
18
- def_delegators :interface,
19
- :border?,
20
- :border,
21
- :geometry
12
+ def_delegators :terminal,
13
+ :tx,
14
+ :ty,
15
+ :txn,
16
+ :tyn
22
17
 
23
18
  def_delegators :border,
24
- :left?,
25
- :right?,
26
- :top?,
27
- :bottom?
19
+ :enabled?,
20
+ :left?,
21
+ :right?,
22
+ :top?,
23
+ :bottom?
28
24
 
29
25
  def_delegators :geometry,
30
- :left,
31
- :right,
32
- :top,
33
- :bottom
26
+ :left,
27
+ :right,
28
+ :top,
29
+ :bottom
34
30
 
35
31
  # @!attribute [rw] x
36
32
  # @return [Fixnum]
@@ -41,36 +37,41 @@ module Vedeu
41
37
  attr_accessor :y
42
38
 
43
39
  # @param (see #initialize)
44
- def self.validate(interface, x, y)
45
- new(interface, x, y).validate
40
+ def self.validate(name, x, y)
41
+ new(name, x, y).validate
46
42
  end
47
43
 
48
44
  # Returns a new instance of Vedeu::PositionValidator.
49
45
  #
50
- # @param interface [Interface]
46
+ # @param name [String]
51
47
  # @param x [Fixnum]
52
48
  # @param y [Fixnum]
53
49
  # @return [PositionValidator]
54
- def initialize(interface, x, y)
55
- @interface = interface
56
- @x = x
57
- @y = y
50
+ def initialize(name, x, y)
51
+ @name = name
52
+ @x = x
53
+ @y = y
58
54
  end
59
55
 
60
56
  # @return [PositionValidator]
61
57
  def validate
62
58
  terminal_validation
63
59
  interface_validation
64
- border_validation if border?
60
+ border_validation if enabled?
65
61
 
66
62
  self
67
63
  end
68
64
 
69
65
  private
70
66
 
71
- # @!attribute [r] interface
72
- # @return [Vedeu::Interface]
73
- attr_reader :interface
67
+ # @!attribute [r] name
68
+ # @return [String]
69
+ attr_reader :name
70
+
71
+ # @return [Vedeu::Terminal]
72
+ def terminal
73
+ Vedeu::Terminal
74
+ end
74
75
 
75
76
  # Validate the x and y coordinates are within the dimensions of the
76
77
  # terminal.
@@ -103,14 +104,24 @@ module Vedeu
103
104
  #
104
105
  # @return [PositionValidator]
105
106
  def border_validation
106
- @x = left + 1 if left? && x < (left + 1)
107
- @x = right - 2 if right? && x > (right - 1)
108
- @y = top + 1 if top? && y < (top + 1)
107
+ @x = left + 1 if left? && x < (left + 1)
108
+ @x = right - 2 if right? && x > (right - 1)
109
+ @y = top + 1 if top? && y < (top + 1)
109
110
  @y = bottom - 2 if bottom? && y > (bottom - 1)
110
111
 
111
112
  self
112
113
  end
113
114
 
115
+ # @return [Vedeu::Border|Vedeu::NullBorder|NilClass]
116
+ def border
117
+ @border ||= Vedeu.borders.by_name(name)
118
+ end
119
+
120
+ # @return [Vedeu::Geometry|Vedeu::NullGeometry]
121
+ def geometry
122
+ @geometry ||= Vedeu.geometries.by_name(name)
123
+ end
124
+
114
125
  end # PositionValidator
115
126
 
116
127
  end # Vedeu
@@ -1,8 +1,9 @@
1
1
  require 'vedeu/repositories/all'
2
- require 'vedeu/input/mapper'
3
- require 'vedeu/input/key'
4
- require 'vedeu/input/input'
5
- require 'vedeu/input/keymap'
2
+
3
+ require_relative 'mapper'
4
+ require_relative 'key'
5
+ require_relative 'input'
6
+ require_relative 'keymap'
6
7
 
7
8
  module Vedeu
8
9
 
@@ -1,4 +1,3 @@
1
- require 'vedeu/exceptions'
2
1
  require 'vedeu/repositories/all'
3
2
  require 'vedeu/dsl/components/all'
4
3
  require 'vedeu/input/key'
@@ -60,9 +60,7 @@ module Vedeu
60
60
  #
61
61
  # @return [Boolean]
62
62
  def valid?
63
- return false unless key
64
-
65
- return false if key_defined? || global_key? || system_key?
63
+ return false if !key || key_defined? || global_key? || system_key?
66
64
 
67
65
  true
68
66
  end
@@ -20,11 +20,7 @@ module Vedeu
20
20
  stdout = STDOUT,
21
21
  stderr = STDERR,
22
22
  kernel = Kernel)
23
- new(argv,
24
- stdin = STDIN,
25
- stdout = STDOUT,
26
- stderr = STDERR,
27
- kernel = Kernel).debug_execute!
23
+ new(argv, stdin, stdout, stderr, kernel).debug_execute!
28
24
  end
29
25
 
30
26
  # Returns a new instance of Vedeu::Launcher.
@@ -72,7 +68,6 @@ module Vedeu
72
68
  rescue StandardError => uncaught_exception
73
69
  puts uncaught_exception.message
74
70
  puts uncaught_exception.backtrace.join("\n") if configuration.debug?
75
-
76
71
  end
77
72
 
78
73
  private
@@ -85,13 +80,17 @@ module Vedeu
85
80
  #
86
81
  # @return [void]
87
82
  def terminate!
88
- Vedeu.log(type: :info, message: "Exiting gracefully.")
83
+ Vedeu.log(type: :info, message: 'Exiting gracefully.')
89
84
 
90
85
  $stdin, $stdout, $stderr = STDIN, STDOUT, STDERR
91
86
 
92
87
  @kernel.exit(exit_code)
93
88
  end
94
89
 
90
+ # Use the arguments passed on the command-line along with those defined by
91
+ # the client application and Vedeu's defaults to configure the client
92
+ # application.
93
+ #
95
94
  # @return [Vedeu::Configuration]
96
95
  def configuration
97
96
  Vedeu::Configuration.configure(argv)
@@ -21,13 +21,12 @@ module Vedeu
21
21
  @started = true
22
22
  @loop = true
23
23
 
24
- while(@loop) do
24
+ while @loop
25
25
  yield
26
26
 
27
27
  safe_exit_point!
28
28
  end
29
29
  rescue VedeuInterrupt
30
-
31
30
  end
32
31
  # :nocov:
33
32
 
@@ -1,5 +1,6 @@
1
1
  require 'vedeu/repositories/all'
2
2
 
3
+ require_relative 'null'
3
4
  require_relative 'cell'
4
5
  require_relative 'char'
5
6
  require_relative 'stream'
@@ -30,7 +30,8 @@ module Vedeu
30
30
 
31
31
  # Returns a new instance of Vedeu::Cell.
32
32
  #
33
- # @param attributes [Hash<Symbol => Array<Symbol|String>, Fixnum, String, Symbol]
33
+ # @param attributes [Hash<Symbol => Array<Symbol|String>,
34
+ # Fixnum, String, Symbol]
34
35
  # @option attributes background [NilClass|String]
35
36
  # @option attributes foreground [NilClass|String]
36
37
  # @option attributes style [NilClass|Array<Symbol|String>|Symbol|String]
@@ -50,13 +51,9 @@ module Vedeu
50
51
  # @param other [Vedeu::Cell]
51
52
  # @return [Boolean]
52
53
  def eql?(other)
53
- self.class == other.class &&
54
- background == other.background &&
55
- foreground == other.foreground &&
56
- style == other.style &&
57
- value == other.value &&
58
- x == other.x &&
59
- y == other.y
54
+ self.class == other.class && background == other.background &&
55
+ foreground == other.foreground && style == other.style &&
56
+ value == other.value && x == other.x && y == other.y
60
57
  end
61
58
  alias_method :==, :eql?
62
59