vedeu 0.4.18 → 0.4.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/Rakefile +1 -0
  4. data/bin/vedeu_drb_server +0 -1
  5. data/bin/vedeu_test +0 -1
  6. data/config/rubocop_enabled.yml +1 -1
  7. data/examples/borders_app.rb +0 -1
  8. data/examples/colours_app.rb +0 -1
  9. data/examples/cursor_app.rb +0 -1
  10. data/examples/drb_app.rb +0 -1
  11. data/examples/geometry_app.rb +0 -1
  12. data/examples/hello_world.rb +0 -1
  13. data/examples/lines_app.rb +0 -1
  14. data/examples/material_colours_app.rb +0 -1
  15. data/examples/typed_commands/typed_commands_app.rb +0 -1
  16. data/examples/view_templates_app/view_templates_app.rb +0 -1
  17. data/lib/vedeu/api.rb +2 -1
  18. data/lib/vedeu/application.rb +3 -2
  19. data/lib/vedeu/bindings.rb +3 -5
  20. data/lib/vedeu/buffers/buffer.rb +8 -11
  21. data/lib/vedeu/buffers/display_buffer.rb +0 -2
  22. data/lib/vedeu/configuration/api.rb +1 -4
  23. data/lib/vedeu/configuration/cli.rb +153 -74
  24. data/lib/vedeu/configuration/configuration.rb +1 -2
  25. data/lib/vedeu/cursor/cursor.rb +0 -4
  26. data/lib/vedeu/cursor/move.rb +3 -6
  27. data/lib/vedeu/cursor/refresh_cursor.rb +12 -2
  28. data/lib/vedeu/distributed/client.rb +3 -2
  29. data/lib/vedeu/distributed/server.rb +4 -3
  30. data/lib/vedeu/distributed/subprocess.rb +3 -4
  31. data/lib/vedeu/distributed/test_application.rb +0 -1
  32. data/lib/vedeu/distributed/uri.rb +0 -1
  33. data/lib/vedeu/dsl/components/border.rb +3 -4
  34. data/lib/vedeu/dsl/components/geometry.rb +1 -5
  35. data/lib/vedeu/dsl/components/keymap.rb +1 -3
  36. data/lib/vedeu/dsl/components/menu.rb +1 -2
  37. data/lib/vedeu/dsl/composition.rb +3 -4
  38. data/lib/vedeu/dsl/group.rb +1 -4
  39. data/lib/vedeu/dsl/interface.rb +3 -10
  40. data/lib/vedeu/dsl/line.rb +3 -4
  41. data/lib/vedeu/dsl/shared/text.rb +0 -3
  42. data/lib/vedeu/dsl/stream.rb +3 -4
  43. data/lib/vedeu/dsl/view.rb +0 -3
  44. data/lib/vedeu/events/event.rb +3 -3
  45. data/lib/vedeu/events/trigger.rb +3 -2
  46. data/lib/vedeu/geometry/area.rb +0 -1
  47. data/lib/vedeu/geometry/canvas.rb +0 -1
  48. data/lib/vedeu/geometry/coordinate.rb +6 -7
  49. data/lib/vedeu/geometry/dimension.rb +3 -2
  50. data/lib/vedeu/geometry/geometry.rb +0 -6
  51. data/lib/vedeu/geometry/grid.rb +3 -2
  52. data/lib/vedeu/geometry/index_position.rb +0 -1
  53. data/lib/vedeu/geometry/position.rb +0 -1
  54. data/lib/vedeu/geometry/position_index.rb +0 -1
  55. data/lib/vedeu/geometry/position_validator.rb +6 -68
  56. data/lib/vedeu/input/all.rb +0 -2
  57. data/lib/vedeu/input/input.rb +3 -2
  58. data/lib/vedeu/input/key.rb +0 -1
  59. data/lib/vedeu/input/keymap.rb +4 -7
  60. data/lib/vedeu/input/mapper.rb +3 -2
  61. data/lib/vedeu/launcher.rb +3 -2
  62. data/lib/vedeu/main_loop.rb +1 -1
  63. data/lib/vedeu/models/cell.rb +0 -1
  64. data/lib/vedeu/models/char.rb +0 -1
  65. data/lib/vedeu/models/composition.rb +1 -7
  66. data/lib/vedeu/models/group.rb +0 -3
  67. data/lib/vedeu/models/interface.rb +0 -3
  68. data/lib/vedeu/models/line.rb +0 -4
  69. data/lib/vedeu/models/menu.rb +5 -8
  70. data/lib/vedeu/models/stream.rb +0 -4
  71. data/lib/vedeu/null/all.rb +11 -0
  72. data/lib/vedeu/null/border.rb +3 -1
  73. data/lib/vedeu/null/buffer.rb +0 -1
  74. data/lib/vedeu/null/generic.rb +4 -1
  75. data/lib/vedeu/null/geometry.rb +0 -1
  76. data/lib/vedeu/null/interface.rb +36 -7
  77. data/lib/vedeu/output/background.rb +0 -1
  78. data/lib/vedeu/output/border.rb +1 -6
  79. data/lib/vedeu/output/clear.rb +3 -2
  80. data/lib/vedeu/output/colour.rb +6 -18
  81. data/lib/vedeu/output/compressor.rb +5 -2
  82. data/lib/vedeu/output/esc.rb +4 -1
  83. data/lib/vedeu/output/foreground.rb +0 -5
  84. data/lib/vedeu/output/html_char.rb +3 -2
  85. data/lib/vedeu/output/output.rb +1 -5
  86. data/lib/vedeu/output/refresh.rb +1 -1
  87. data/lib/vedeu/output/renderers/all.rb +0 -1
  88. data/lib/vedeu/output/renderers/escape_sequence.rb +3 -2
  89. data/lib/vedeu/output/renderers/file.rb +85 -80
  90. data/lib/vedeu/output/renderers/html.rb +77 -72
  91. data/lib/vedeu/output/renderers/json.rb +45 -42
  92. data/lib/vedeu/output/renderers/null.rb +11 -8
  93. data/lib/vedeu/output/renderers/terminal.rb +41 -36
  94. data/lib/vedeu/output/renderers/text.rb +41 -36
  95. data/lib/vedeu/output/style.rb +0 -3
  96. data/lib/vedeu/output/text.rb +3 -2
  97. data/lib/vedeu/output/viewport.rb +3 -2
  98. data/lib/vedeu/output/virtual_terminal.rb +0 -1
  99. data/lib/vedeu/output/wordwrap.rb +3 -2
  100. data/lib/vedeu/repositories/all.rb +7 -6
  101. data/lib/vedeu/repositories/collection.rb +0 -1
  102. data/lib/vedeu/repositories/collections/chars.rb +0 -1
  103. data/lib/vedeu/repositories/collections/events.rb +0 -1
  104. data/lib/vedeu/repositories/collections/interfaces.rb +0 -1
  105. data/lib/vedeu/repositories/collections/keys.rb +0 -1
  106. data/lib/vedeu/repositories/collections/lines.rb +0 -1
  107. data/lib/vedeu/repositories/collections/streams.rb +0 -1
  108. data/lib/vedeu/repositories/model.rb +0 -1
  109. data/lib/vedeu/repositories/registerable.rb +29 -0
  110. data/lib/vedeu/repositories/repositories/background_colours.rb +0 -1
  111. data/lib/vedeu/repositories/repositories/borders.rb +2 -13
  112. data/lib/vedeu/repositories/repositories/buffers.rb +2 -13
  113. data/lib/vedeu/repositories/repositories/colours.rb +0 -1
  114. data/lib/vedeu/repositories/repositories/cursors.rb +1 -2
  115. data/lib/vedeu/repositories/repositories/events_repository.rb +0 -1
  116. data/lib/vedeu/repositories/repositories/foreground_colours.rb +0 -1
  117. data/lib/vedeu/repositories/repositories/geometries.rb +2 -13
  118. data/lib/vedeu/repositories/repositories/groups.rb +1 -2
  119. data/lib/vedeu/repositories/repositories/interfaces_repository.rb +2 -14
  120. data/lib/vedeu/repositories/repositories/keymaps.rb +1 -2
  121. data/lib/vedeu/repositories/repositories/menus.rb +1 -2
  122. data/lib/vedeu/repositories/repository.rb +14 -5
  123. data/lib/vedeu/storage/all.rb +0 -1
  124. data/lib/vedeu/storage/associative_store.rb +0 -1
  125. data/lib/vedeu/storage/conveyor_store.rb +0 -1
  126. data/lib/vedeu/storage/fifo_store.rb +0 -1
  127. data/lib/vedeu/support/log.rb +0 -3
  128. data/lib/vedeu/support/options.rb +3 -2
  129. data/lib/vedeu/support/template.rb +3 -4
  130. data/lib/vedeu/support/terminal.rb +0 -2
  131. data/lib/vedeu/support/trace.rb +6 -7
  132. data/lib/vedeu/support/visibility.rb +1 -2
  133. data/lib/vedeu.rb +3 -5
  134. data/test/lib/vedeu/buffers/buffer_test.rb +48 -13
  135. data/test/lib/vedeu/configuration/cli_test.rb +5 -4
  136. data/test/lib/vedeu/cursor/refresh_cursor_test.rb +37 -15
  137. data/test/lib/vedeu/distributed/subprocess_test.rb +1 -0
  138. data/test/lib/vedeu/dsl/shared/use_test.rb +1 -6
  139. data/test/lib/vedeu/main_loop_test.rb +11 -0
  140. data/test/lib/vedeu/null/interface_test.rb +27 -0
  141. data/test/lib/vedeu/output/output_test.rb +17 -10
  142. data/test/lib/vedeu/output/presentation_test.rb +35 -7
  143. data/test/lib/vedeu/output/renderers/escape_sequence_test.rb +50 -0
  144. data/test/lib/vedeu/output/renderers/file_test.rb +34 -30
  145. data/test/lib/vedeu/output/renderers/html_test.rb +61 -57
  146. data/test/lib/vedeu/output/renderers/json_test.rb +40 -36
  147. data/test/lib/vedeu/output/renderers/null_test.rb +12 -8
  148. data/test/lib/vedeu/output/renderers/terminal_test.rb +17 -13
  149. data/test/lib/vedeu/output/renderers/text_test.rb +17 -13
  150. data/test/lib/vedeu/repositories/model_test.rb +1 -1
  151. data/test/lib/vedeu/repositories/registerable_test.rb +28 -0
  152. data/test/lib/vedeu/storage/associative_store_test.rb +7 -0
  153. data/test/lib/vedeu/storage/conveyor_store_test.rb +7 -0
  154. data/test/lib/vedeu/storage/fifo_store_test.rb +7 -0
  155. data/test/support/helpers/model_test_class.rb +6 -2
  156. data/test/test_helper.rb +2 -0
  157. data/vedeu.gemspec +3 -2
  158. metadata +23 -6
  159. data/test/lib/vedeu/output/renderers/escape_sequence_renderer_test.rb +0 -46
@@ -3,7 +3,6 @@ module Vedeu
3
3
  module Distributed
4
4
 
5
5
  # A class for the server side of the DRb server/client relationship.
6
- #
7
6
  class Server
8
7
 
9
8
  $SAFE = 1 # disable `eval` and related calls on strings passed
@@ -158,15 +157,17 @@ module Vedeu
158
157
 
159
158
  end
160
159
  rescue NoMethodError # raised when #join is called on NilClass.
161
- # ...
160
+ Vedeu.log(type: :debug, message: 'Attempted to #join on DRb.thread.')
162
161
  end
163
162
 
164
- private
163
+ protected
165
164
 
166
165
  # @!attribute [r] configuration
167
166
  # @return [Configuration]
168
167
  attr_reader :configuration
169
168
 
169
+ private
170
+
170
171
  # @return [Boolean]
171
172
  def drb?
172
173
  Vedeu::Configuration.drb?
@@ -1,10 +1,7 @@
1
- require 'vedeu/distributed/test_application'
2
-
3
1
  module Vedeu
4
2
 
5
3
  # @example
6
4
  # Vedeu::TestApplication.build
7
- #
8
5
  class Subprocess
9
6
 
10
7
  # @param (see #initialize)
@@ -45,7 +42,7 @@ module Vedeu
45
42
  file_unlink
46
43
  end
47
44
 
48
- private
45
+ protected
49
46
 
50
47
  # @!attribute [r] application
51
48
  # @return [Vedeu::TestApplication]
@@ -55,6 +52,8 @@ module Vedeu
55
52
  # @return [Fixnum]
56
53
  attr_accessor :pid
57
54
 
55
+ private
56
+
58
57
  # @return [String]
59
58
  def command
60
59
  "ruby #{file_path}"
@@ -13,7 +13,6 @@ module Vedeu
13
13
  # app.menus = ''
14
14
  # app.views = ''
15
15
  # end
16
- #
17
16
  class TestApplication
18
17
 
19
18
  # @!attribute [rw] borders
@@ -4,7 +4,6 @@ module Vedeu
4
4
 
5
5
  # Value class which provides the host and port for the DRb server and
6
6
  # client.
7
- #
8
7
  class Uri
9
8
 
10
9
  # @!attribute [r] host
@@ -1,5 +1,5 @@
1
- require 'vedeu/output/border'
2
- require 'vedeu/dsl/shared/all'
1
+ require 'vedeu/dsl/shared/presentation'
2
+ require 'vedeu/dsl/shared/use'
3
3
 
4
4
  module Vedeu
5
5
 
@@ -26,7 +26,6 @@ module Vedeu
26
26
  # # ...or standalone; referencing the target interface or view.
27
27
  # Vedeu.border 'some_interface' do
28
28
  # # ...
29
- #
30
29
  class Border
31
30
 
32
31
  include Vedeu::DSL
@@ -303,7 +302,7 @@ module Vedeu
303
302
  model.vertical = char
304
303
  end
305
304
 
306
- private
305
+ protected
307
306
 
308
307
  # @!attribute [r] client
309
308
  # @return [Object]
@@ -1,12 +1,8 @@
1
- require 'vedeu/geometry/geometry'
2
- require 'vedeu/dsl/shared/all'
3
-
4
1
  module Vedeu
5
2
 
6
3
  module DSL
7
4
 
8
5
  # Provide DSL methods for configuring the geometry of an interface.
9
- #
10
6
  class Geometry
11
7
 
12
8
  include Vedeu::DSL
@@ -187,7 +183,7 @@ module Vedeu
187
183
  model.yn = value
188
184
  end
189
185
 
190
- private
186
+ protected
191
187
 
192
188
  # @!attribute [r] client
193
189
  # @return [Object]
@@ -1,5 +1,4 @@
1
1
  require 'vedeu/support/common'
2
- require 'vedeu/input/key'
3
2
 
4
3
  module Vedeu
5
4
 
@@ -8,7 +7,6 @@ module Vedeu
8
7
  # Provides methods to be used to define keypress mapped to actions.
9
8
  #
10
9
  # @api public
11
- #
12
10
  class Keymap
13
11
 
14
12
  include Vedeu::Common
@@ -123,7 +121,7 @@ module Vedeu
123
121
  model.name = value
124
122
  end
125
123
 
126
- private
124
+ protected
127
125
 
128
126
  # @!attribute [r] client
129
127
  # @return [Object]
@@ -6,7 +6,6 @@ module Vedeu
6
6
  # events to drive them.
7
7
  #
8
8
  # @api public
9
- #
10
9
  class Menu
11
10
 
12
11
  include Vedeu::DSL
@@ -73,7 +72,7 @@ module Vedeu
73
72
  model.name = value
74
73
  end
75
74
 
76
- private
75
+ protected
77
76
 
78
77
  # @!attribute [r] client
79
78
  # @return [Object]
@@ -1,11 +1,8 @@
1
- require 'vedeu/models/interface'
2
-
3
1
  module Vedeu
4
2
 
5
3
  module DSL
6
4
 
7
5
  # DSL for creating collections of interfaces.
8
- #
9
6
  class Composition
10
7
 
11
8
  include Vedeu::DSL
@@ -74,7 +71,7 @@ module Vedeu
74
71
  model.add(new_model)
75
72
  end
76
73
 
77
- private
74
+ protected
78
75
 
79
76
  # @!attribute [r] client
80
77
  # @return [Object]
@@ -84,6 +81,8 @@ module Vedeu
84
81
  # @return [Composition]
85
82
  attr_reader :model
86
83
 
84
+ private
85
+
87
86
  # @param name [String]
88
87
  # @param lines [Vedeu::Lines]
89
88
  # @return [Hash]
@@ -1,11 +1,8 @@
1
- require 'vedeu/models/group'
2
-
3
1
  module Vedeu
4
2
 
5
3
  module DSL
6
4
 
7
5
  # DSL for adding interfaces to a group.
8
- #
9
6
  class Group
10
7
 
11
8
  include Vedeu::DSL
@@ -58,7 +55,7 @@ module Vedeu
58
55
  model.add(interface_name)
59
56
  end
60
57
 
61
- private
58
+ protected
62
59
 
63
60
  # @!attribute [r] client
64
61
  # @return [Object]
@@ -1,17 +1,8 @@
1
- require 'vedeu/cursor/cursor'
2
- require 'vedeu/models/focus'
3
- require 'vedeu/geometry/geometry'
4
- require 'vedeu/models/group'
5
- require 'vedeu/models/line'
6
- require 'vedeu/output/border'
7
- require 'vedeu/support/common'
8
-
9
1
  module Vedeu
10
2
 
11
3
  module DSL
12
4
 
13
5
  # DSL for creating interfaces.
14
- #
15
6
  class Interface
16
7
 
17
8
  include Vedeu::Common
@@ -247,7 +238,7 @@ module Vedeu
247
238
  model.visible = boolean
248
239
  end
249
240
 
250
- private
241
+ protected
251
242
 
252
243
  # @!attribute [r] client
253
244
  # @return [Object]
@@ -257,6 +248,8 @@ module Vedeu
257
248
  # @return [Interface]
258
249
  attr_reader :model
259
250
 
251
+ private
252
+
260
253
  # @return [Hash]
261
254
  def attributes
262
255
  {
@@ -1,5 +1,3 @@
1
- require 'vedeu/dsl/shared/all'
2
-
3
1
  module Vedeu
4
2
 
5
3
  module DSL
@@ -34,7 +32,6 @@ module Vedeu
34
32
  # end
35
33
  #
36
34
  # @api public
37
- #
38
35
  class Line
39
36
 
40
37
  include Vedeu::DSL
@@ -107,7 +104,7 @@ module Vedeu
107
104
  end
108
105
  alias_method :stream, :streams
109
106
 
110
- private
107
+ protected
111
108
 
112
109
  # @!attribute [r] client
113
110
  # @return [Object]
@@ -117,6 +114,8 @@ module Vedeu
117
114
  # @return [Line]
118
115
  attr_reader :model
119
116
 
117
+ private
118
+
120
119
  # @return [Hash]
121
120
  def attributes
122
121
  {
@@ -1,6 +1,3 @@
1
- require 'vedeu/output/text'
2
- require 'vedeu/models/all'
3
-
4
1
  module Vedeu
5
2
 
6
3
  module DSL
@@ -1,5 +1,3 @@
1
- require 'vedeu/dsl/shared/all'
2
-
3
1
  module Vedeu
4
2
 
5
3
  module DSL
@@ -7,7 +5,6 @@ module Vedeu
7
5
  # Provides methods to be used to define views.
8
6
  #
9
7
  # @api public
10
- #
11
8
  class Stream
12
9
 
13
10
  include Vedeu::DSL
@@ -33,7 +30,7 @@ module Vedeu
33
30
  model.add(model.class.build(attributes, &block))
34
31
  end
35
32
 
36
- private
33
+ protected
37
34
 
38
35
  # @!attribute [r] client
39
36
  # @return [Object]
@@ -43,6 +40,8 @@ module Vedeu
43
40
  # @return [Stream]
44
41
  attr_reader :model
45
42
 
43
+ private
44
+
46
45
  # @return [Hash]
47
46
  def attributes
48
47
  {
@@ -1,5 +1,3 @@
1
- require 'vedeu/models/composition'
2
-
3
1
  module Vedeu
4
2
 
5
3
  module DSL
@@ -7,7 +5,6 @@ module Vedeu
7
5
  # DSL for creating views.
8
6
  #
9
7
  # @api public
10
- #
11
8
  class View
12
9
 
13
10
  class << self
@@ -1,4 +1,3 @@
1
- require 'vedeu/repositories/all'
2
1
  require 'vedeu/events/trigger'
3
2
 
4
3
  module Vedeu
@@ -30,7 +29,6 @@ module Vedeu
30
29
  # # Not all events you define will have arguments; like methods.
31
30
  # :do_stuff
32
31
  # end
33
- #
34
32
  class Event
35
33
 
36
34
  include Vedeu::Model
@@ -150,7 +148,7 @@ module Vedeu
150
148
  return execute(*args) if throttling? && throttle_expired?
151
149
  end
152
150
 
153
- private
151
+ protected
154
152
 
155
153
  # @!attribute [r] closure
156
154
  # @return [String]
@@ -172,6 +170,8 @@ module Vedeu
172
170
  # @return [String]
173
171
  attr_accessor :now
174
172
 
173
+ private
174
+
175
175
  # Execute the code stored in the event closure.
176
176
  #
177
177
  # @param args [void]
@@ -7,7 +7,6 @@ module Vedeu
7
7
  #
8
8
  # @example
9
9
  # Vedeu.trigger(:my_event, :oxidize, 'nitrogen')
10
- #
11
10
  class Trigger
12
11
 
13
12
  # @param name [Symbol] The name of the event you wish to trigger. The event
@@ -41,7 +40,7 @@ module Vedeu
41
40
  end
42
41
  end
43
42
 
44
- private
43
+ protected
45
44
 
46
45
  # @!attribute [r] name
47
46
  # @return [Symbol]
@@ -55,6 +54,8 @@ module Vedeu
55
54
  # @return [Vedeu::Repository]
56
55
  attr_reader :repository
57
56
 
57
+ private
58
+
58
59
  # @return [Array<void>|void]
59
60
  def results
60
61
  @results ||= registered_events.map { |event| event.trigger(*args) }
@@ -1,7 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # Define an area from dimensions or points.
4
- #
5
4
  class Area
6
5
 
7
6
  # @!attribute [r] y
@@ -2,7 +2,6 @@ module Vedeu
2
2
 
3
3
  # The size of the terminal is a limitation. Defining a canvas means we have
4
4
  # more space to 'do stuff'.
5
- #
6
5
  class Canvas
7
6
 
8
7
  include Singleton
@@ -1,7 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # Crudely corrects out of range values.
4
- #
5
4
  class Coordinate
6
5
 
7
6
  # @!attribute [r] height
@@ -118,6 +117,12 @@ module Vedeu
118
117
  end
119
118
  end
120
119
 
120
+ protected
121
+
122
+ # @!attribute [r] name
123
+ # @return [String]
124
+ attr_reader :name
125
+
121
126
  private
122
127
 
123
128
  # Returns the maximum y index for an area.
@@ -194,12 +199,6 @@ module Vedeu
194
199
  (y...yn).to_a
195
200
  end
196
201
 
197
- private
198
-
199
- # @!attribute [r] name
200
- # @return [String]
201
- attr_reader :name
202
-
203
202
  end # Coordinate
204
203
 
205
204
  end # Vedeu
@@ -1,7 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # A Dimension is either the height or width of an entity.
4
- #
5
4
  class Dimension
6
5
 
7
6
  # @param (see #initialize)
@@ -42,7 +41,7 @@ module Vedeu
42
41
  dimension
43
42
  end
44
43
 
45
- private
44
+ protected
46
45
 
47
46
  # @!attribute [r] d
48
47
  # @return [Fixnum|NilClass]
@@ -60,6 +59,8 @@ module Vedeu
60
59
  # @return [Fixnum|NilClass]
61
60
  attr_reader :default
62
61
 
62
+ private
63
+
63
64
  # @return [Array<Fixnum>]
64
65
  def dimension
65
66
  @dimension ||= if centred? && length?
@@ -1,10 +1,5 @@
1
- require 'vedeu/dsl/components/all'
2
1
  require 'vedeu/repositories/model'
3
2
 
4
- require 'vedeu/geometry/area'
5
- require 'vedeu/geometry/dimension'
6
- require 'vedeu/support/terminal'
7
-
8
3
  module Vedeu
9
4
 
10
5
  # @todo Consider storing the Terminal size at the time of first creation,
@@ -26,7 +21,6 @@ module Vedeu
26
21
  # | bottom | # bottom: yn
27
22
  # yn +--------------+ # south: yn + 1
28
23
  # south
29
- #
30
24
  class Geometry
31
25
 
32
26
  extend Forwardable
@@ -23,7 +23,6 @@ module Vedeu
23
23
 
24
24
  # Divides horizontal terminal space into 12 equal columns, discarding
25
25
  # the remainder.
26
- #
27
26
  class Grid
28
27
 
29
28
  # @see (#initialize)
@@ -49,12 +48,14 @@ module Vedeu
49
48
  column * value
50
49
  end
51
50
 
52
- private
51
+ protected
53
52
 
54
53
  # @!attribute [r] value
55
54
  # @return [Fixnum]
56
55
  attr_reader :value
57
56
 
57
+ private
58
+
58
59
  # Returns the width of a single column in characters.
59
60
  #
60
61
  # @return [Fixnum]
@@ -4,7 +4,6 @@ module Vedeu
4
4
  #
5
5
  # When the optional offset `oy` and `ox` params are given, the they are used
6
6
  # for the starting position.
7
- #
8
7
  class IndexPosition
9
8
 
10
9
  # @param (see #initialize)
@@ -1,7 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # Change coordinates into an escape sequence to set the cursor position.
4
- #
5
4
  class Position
6
5
 
7
6
  # @!attribute [r] y
@@ -1,7 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # Converts a position into an index for the terminal.
4
- #
5
4
  class PositionIndex
6
5
 
7
6
  # Convenience constructor for Vedeu::Position.
@@ -1,33 +1,17 @@
1
- require 'vedeu/support/terminal'
2
-
3
1
  module Vedeu
4
2
 
5
3
  # Validates that the provided coordinates are within the terminal and
6
4
  # interface's geometry (with or without a border).
7
- #
8
5
  class PositionValidator
9
6
 
10
7
  extend Forwardable
11
8
 
12
- def_delegators :terminal,
13
- :tx,
14
- :ty,
15
- :txn,
16
- :tyn
17
-
18
9
  def_delegators :border,
19
- :enabled?,
20
10
  :bx,
21
11
  :bxn,
22
12
  :by,
23
13
  :byn
24
14
 
25
- def_delegators :geometry,
26
- :left,
27
- :right,
28
- :top,
29
- :bottom
30
-
31
15
  # @!attribute [rw] x
32
16
  # @return [Fixnum]
33
17
  attr_accessor :x
@@ -58,73 +42,27 @@ module Vedeu
58
42
  #
59
43
  # @return [PositionValidator]
60
44
  def validate
61
- terminal_validation
62
- interface_validation
63
- border_validation if enabled?
45
+ @x = bx if x < bx
46
+ @x = bxn if x > bxn
47
+ @y = by if y < by
48
+ @y = byn if y > byn
64
49
 
65
50
  self
66
51
  end
67
52
 
68
- private
53
+ protected
69
54
 
70
55
  # @!attribute [r] name
71
56
  # @return [String]
72
57
  attr_reader :name
73
58
 
74
- # @return [Vedeu::Terminal]
75
- def terminal
76
- Vedeu::Terminal
77
- end
78
-
79
- # Validate the x and y coordinates are within the dimensions of the
80
- # terminal.
81
- #
82
- # @return [PositionValidator]
83
- def terminal_validation
84
- @x = tx if x < tx
85
- @x = txn if x > txn
86
- @y = ty if y < ty
87
- @y = tyn if y > tyn
88
-
89
- self
90
- end
91
-
92
- # Validate the x and y coordinates are within the dimensions of the
93
- # interface.
94
- #
95
- # @return [PositionValidator]
96
- def interface_validation
97
- @x = left if x < left
98
- @x = right if x > right
99
- @y = top if y < top
100
- @y = bottom if y > bottom
101
-
102
- self
103
- end
104
-
105
- # Validate the x and y coordinates are within the dimensions of an interface
106
- # with a border.
107
- #
108
- # @return [PositionValidator]
109
- def border_validation
110
- @x = bx if x < bx
111
- @x = bxn if x > bxn
112
- @y = by if y < by
113
- @y = byn if y > byn
114
-
115
- self
116
- end
59
+ private
117
60
 
118
61
  # @return (see Vedeu::Borders#by_name)
119
62
  def border
120
63
  @border ||= Vedeu.borders.by_name(name)
121
64
  end
122
65
 
123
- # @return (see Vedeu::Geometries#by_name)
124
- def geometry
125
- @geometry ||= Vedeu.geometries.by_name(name)
126
- end
127
-
128
66
  end # PositionValidator
129
67
 
130
68
  end # Vedeu
@@ -1,5 +1,3 @@
1
- require 'vedeu/repositories/all'
2
-
3
1
  require_relative 'mapper'
4
2
  require_relative 'key'
5
3
  require_relative 'input'
@@ -2,7 +2,6 @@ module Vedeu
2
2
 
3
3
  # Captures input from the user via {Vedeu::Terminal#input} and translates
4
4
  # special characters into symbols.
5
- #
6
5
  class Input
7
6
 
8
7
  # Instantiate Input and capture keypress(es).
@@ -36,12 +35,14 @@ module Vedeu
36
35
  end
37
36
  end
38
37
 
39
- private
38
+ protected
40
39
 
41
40
  # @!attribute [r] reader
42
41
  # @return [IO]
43
42
  attr_reader :reader
44
43
 
44
+ private
45
+
45
46
  # Returns the input from the terminal.
46
47
  #
47
48
  # @return [String]
@@ -1,7 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # A single keypress or combination of keypresses bound to a specific action.
4
- #
5
4
  class Key
6
5
 
7
6
  # @!attribute [r] input