vedeu 0.4.18 → 0.4.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9465a952ab6e8149c69de234c8e51c5e6f09a2a2
4
- data.tar.gz: 6eb60784e45eea477870787e5a5ced902dc5f1c9
3
+ metadata.gz: dab76c44fae79844ccc5b6321392ee99a09c23d0
4
+ data.tar.gz: 43162ef0fdcf20ba49b09957d32316379e3e0583
5
5
  SHA512:
6
- metadata.gz: 48866fecffced7581f359ed1fb6107aedfa746d1035dd0c26443920b158f090ab45199c0d4cdcb84c4cea5d9aefdcc3210895e9cb86bc6d53e033b71692f646d
7
- data.tar.gz: 1774d54f66bf61ff8639891c5ec3572740f9ae8f8be1d7019b9a603315720f17ccf61f92b534fc2c78c4f1a8e80577221bf98e944745966d3753feefb59f0d39
6
+ metadata.gz: a9774a3562701e47aaacc997d01dd157ce021c46b688adda4f56b4cdffb323c918189bc1038b0af46031aa858825449b865eb77b37b41d482aa106e6120f406e
7
+ data.tar.gz: 222d43c099bf843b27b616536b10b0cc316c6c0cb9bb09e06606ffd00362aa2ee02eb79f84cd09c4ac437d94270df33ec88a1fd4e328d0a6d22e8f9259b104a2
data/.rubocop.yml CHANGED
@@ -650,7 +650,7 @@ Metrics/ParameterLists:
650
650
  CountKeywordArgs: true
651
651
 
652
652
  Metrics/PerceivedComplexity:
653
- Max: 10
653
+ Max: 12
654
654
 
655
655
  ##################### Lint ##################################
656
656
 
data/Rakefile CHANGED
@@ -15,6 +15,7 @@ Rake::TestTask.new(:test) do |t|
15
15
  t.libs.push 'test'
16
16
  t.pattern = 'test/**/*_test.rb'
17
17
  t.verbose = false
18
+ t.warning = false # set to true for Ruby warnings (ruby -w)
18
19
  end
19
20
 
20
21
  YARD::Rake::YardocTask.new(:yard) do |t|
data/bin/vedeu_drb_server CHANGED
@@ -6,7 +6,6 @@ $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
6
6
  require 'vedeu'
7
7
 
8
8
  # A simple test application for Vedeu.
9
- #
10
9
  class VedeuTestApplication
11
10
 
12
11
  Vedeu.configure do
data/bin/vedeu_test CHANGED
@@ -6,7 +6,6 @@ $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
6
6
  require 'vedeu'
7
7
 
8
8
  # A simple test application for Vedeu.
9
- #
10
9
  class VedeuTestApp
11
10
 
12
11
  def self.start(argv = ARGV)
@@ -161,7 +161,7 @@ Style/DeprecatedHashMethods:
161
161
 
162
162
  Style/Documentation:
163
163
  Description: 'Document classes and non-namespace modules.'
164
- Enabled: true
164
+ Enabled: false
165
165
 
166
166
  Style/DotPosition:
167
167
  Description: 'Checks the position of the dot in multi-line method calls.'
@@ -6,7 +6,6 @@ $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
6
6
  require 'vedeu'
7
7
 
8
8
  # An example application to demonstrate borders.
9
- #
10
9
  class VedeuBordersApp
11
10
 
12
11
  include Vedeu
@@ -6,7 +6,6 @@ $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
6
6
  require 'vedeu'
7
7
 
8
8
  # An example application to demonstrate colours.
9
- #
10
9
  class VedeuColoursApp
11
10
 
12
11
  include Vedeu
@@ -7,7 +7,6 @@ require 'vedeu'
7
7
 
8
8
  # An example application to demonstrate cursors; their movement and effect on
9
9
  # the viewport of the interface in focus.
10
- #
11
10
  class VedeuCursorApp
12
11
 
13
12
  include Vedeu
data/examples/drb_app.rb CHANGED
@@ -6,7 +6,6 @@ $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
6
6
  require 'vedeu'
7
7
 
8
8
  # An example application to demonstrate the DRb server.
9
- #
10
9
  class VedeuTestApplication
11
10
 
12
11
  Vedeu.configure do
@@ -6,7 +6,6 @@ $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
6
6
  require 'vedeu'
7
7
 
8
8
  # An example application to demonstrate geometry.
9
- #
10
9
  class VedeuGeometryApp
11
10
 
12
11
  include Vedeu
@@ -9,7 +9,6 @@ trap('INT') { exit! }
9
9
  require 'vedeu'
10
10
 
11
11
  # An example application to demonstrate 'Hello World'.
12
- #
13
12
  class HelloWorldApp
14
13
 
15
14
  include Vedeu
@@ -6,7 +6,6 @@ $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
6
6
  require 'vedeu'
7
7
 
8
8
  # An example application to demonstrate interface lines.
9
- #
10
9
  class VedeuLinesApp
11
10
 
12
11
  include Vedeu
@@ -6,7 +6,6 @@ $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
6
6
  require 'vedeu'
7
7
 
8
8
  # An example application to demonstrate colours.
9
- #
10
9
  class VedeuMaterialColoursApp
11
10
 
12
11
  include Vedeu
@@ -7,7 +7,6 @@ require 'vedeu'
7
7
 
8
8
  # A simple example application to test the input of commands. This will test
9
9
  # the functionality of 'cooked' mode.
10
- #
11
10
  class VedeuTypedCommands
12
11
 
13
12
  include Vedeu
@@ -6,7 +6,6 @@ $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
6
6
  require 'vedeu'
7
7
 
8
8
  # An example application to demonstrate templates.
9
- #
10
9
  class VedeuViewTemplateApp
11
10
 
12
11
  include Vedeu
data/lib/vedeu/api.rb CHANGED
@@ -33,7 +33,8 @@ module Vedeu
33
33
  module API
34
34
 
35
35
  extend Forwardable
36
- extend self
36
+
37
+ module_function
37
38
 
38
39
  # @!method borders
39
40
  # @see Vedeu::Borders.borders
@@ -1,7 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # Orchestrates the running of the main application loop.
4
- #
5
4
  class Application
6
5
 
7
6
  # @param (see #initialize)
@@ -64,12 +63,14 @@ module Vedeu
64
63
  output
65
64
  end
66
65
 
67
- private
66
+ protected
68
67
 
69
68
  # @!attribute [r] configuration
70
69
  # @return [Configuration]
71
70
  attr_reader :configuration
72
71
 
72
+ private
73
+
73
74
  # Runs the application loop either once, or forever (exceptions and signals
74
75
  # permitting).
75
76
  #
@@ -1,5 +1,3 @@
1
- require 'vedeu/events/event'
2
-
3
1
  module Vedeu
4
2
 
5
3
  # Creates system events which when called provide a variety of core functions
@@ -171,9 +169,9 @@ module Vedeu
171
169
  # Clears the whole terminal space, or the named interface area to be cleared
172
170
  # if given.
173
171
  Vedeu.bind(:_clear_) do |name|
174
- if name && Vedeu.interfaces.registered?(name)
175
- Vedeu::Clear.clear(Vedeu.interfaces.find(name), clear_border: true,
176
- use_terminal_colours: true)
172
+ if name
173
+ Vedeu::Clear.clear(Vedeu.interfaces.by_name(name),
174
+ clear_border: true, use_terminal_colours: true)
177
175
 
178
176
  else
179
177
  Vedeu::Terminal.virtual.clear if Vedeu::Configuration.drb?
@@ -1,10 +1,7 @@
1
- require 'vedeu/repositories/model'
2
-
3
1
  module Vedeu
4
2
 
5
3
  # The Buffer object represents the states of display for an interface. The
6
4
  # states are 'front', 'back' and 'previous'.
7
- #
8
5
  class Buffer
9
6
 
10
7
  include Vedeu::Model
@@ -76,10 +73,10 @@ module Vedeu
76
73
 
77
74
  # @return [void]
78
75
  def hide
79
- if visible?
80
- Vedeu::Visibility.hide(interface)
81
- clear
82
- end
76
+ return nil unless visible?
77
+
78
+ Vedeu::Visibility.hide(interface)
79
+ clear
83
80
  end
84
81
 
85
82
  # Return the content for this buffer.
@@ -103,10 +100,10 @@ module Vedeu
103
100
 
104
101
  # @return [void]
105
102
  def show
106
- unless visible?
107
- Vedeu::Visibility.show(interface)
108
- render
109
- end
103
+ return nil if visible?
104
+
105
+ Vedeu::Visibility.show(interface)
106
+ render
110
107
  end
111
108
 
112
109
  private
@@ -1,5 +1,3 @@
1
- require 'vedeu/repositories/all'
2
-
3
1
  module Vedeu
4
2
 
5
3
  # This module is included in Vedeu::Interface to provide means to store client
@@ -1,12 +1,9 @@
1
- require 'vedeu/support/common'
2
-
3
1
  module Vedeu
4
2
 
5
3
  module Config
6
4
 
7
5
  # The Configuration::API class parses client application configuration into
8
6
  # options used by Vedeu to affect certain behaviours.
9
- #
10
7
  class API
11
8
 
12
9
  include Vedeu::Common
@@ -225,7 +222,7 @@ module Vedeu
225
222
  # @param value [Boolean]
226
223
  # @return [Boolean]
227
224
  def trace!(value = true)
228
- options[:debug] = true if value === true
225
+ options[:debug] = true if value
229
226
  options[:trace] = value
230
227
  end
231
228
  alias_method :trace, :trace!
@@ -4,7 +4,6 @@ module Vedeu
4
4
 
5
5
  # The Configuration::CLI class parses command-line arguments using
6
6
  # OptionParser into options used by Vedeu to affect certain behaviours.
7
- #
8
7
  class CLI
9
8
 
10
9
  # @param (see #initialize)
@@ -28,107 +27,187 @@ module Vedeu
28
27
  #
29
28
  # @return [Hash]
30
29
  def configuration
31
- parser = OptionParser.new do |opts|
32
- opts.banner = "Usage: #{$PROGRAM_NAME} [options]"
30
+ setup!
33
31
 
34
- opts.on('-i', '--interactive',
35
- 'Run the application in interactive mode (default).') do
36
- options[:interactive] = true
37
- end
32
+ parser.parse!(args)
38
33
 
39
- opts.on('-I', '--noninteractive', '--standalone',
40
- 'Run the application non-interactively; ' \
41
- 'i.e. not requiring intervention from the user.') do
42
- options[:interactive] = false
43
- end
34
+ Vedeu::Config.log(Esc.blue { '[cli]' }, options)
35
+ end
44
36
 
45
- opts.on('-1', '--run-once',
46
- 'Run the application loop once.') do
47
- options[:once] = true
48
- end
37
+ protected
49
38
 
50
- opts.on('-n', '--run-many',
51
- 'Run the application loop continuously (default).') do
52
- options[:once] = false
53
- end
39
+ # @!attribute [r] args
40
+ # @return [Array<String>]
41
+ attr_reader :args
54
42
 
55
- opts.on('-c', '--cooked', 'Run application in cooked mode.') do
56
- options[:terminal_mode] = :cooked
57
- end
43
+ # @!attribute [r] options
44
+ # @return [Hash]
45
+ attr_reader :options
58
46
 
59
- opts.on('-r', '--raw', 'Run application in raw mode (default).') do
60
- options[:terminal_mode] = :raw
61
- end
47
+ private
62
48
 
63
- opts.on('-d', '--debug', 'Run application with debugging on.') do
64
- options[:debug] = true
65
- end
49
+ # @return [void]
50
+ def setup!
51
+ ([:banner] + allowed_options).each { |opt| send(opt) }
52
+ end
66
53
 
67
- opts.on('-D', '--trace', 'Run application with debugging on with ' \
68
- 'method and event tracing (noisy!).') do
69
- options[:debug] = true
70
- options[:trace] = true
71
- end
54
+ # @return [OptionParser]
55
+ def parser
56
+ @parser ||= OptionParser.new
57
+ end
72
58
 
73
- opts.on('-C', '--colour-mode [COLOURS]', Integer,
59
+ # @return [Array<Symbol>]
60
+ def allowed_options
61
+ [
62
+ :colour_mode,
63
+ :cooked,
64
+ :debug,
65
+ :drb,
66
+ :drb_height,
67
+ :drb_host,
68
+ :drb_port,
69
+ :drb_width,
70
+ :interactive,
71
+ :log,
72
+ :raw,
73
+ :run_many,
74
+ :run_once,
75
+ :standalone,
76
+ :trace,
77
+ ]
78
+ end
79
+
80
+ # @return [String]
81
+ def banner
82
+ parser.banner = "Usage: #{$PROGRAM_NAME} [options]"
83
+ end
84
+
85
+ # @return [OptionParser]
86
+ def colour_mode
87
+ parser.on('-C', '--colour-mode [COLOURS]', Integer,
74
88
  'Run application in either `8`, `16`, `256` or `16777216` ' \
75
89
  'colour mode.') do |colours|
76
- if [8, 16, 256, 16_777_216].include?(colours)
77
- options[:colour_mode] = colours
90
+ if [8, 16, 256, 16_777_216].include?(colours)
91
+ options[:colour_mode] = colours
78
92
 
79
- else
80
- options[:colour_mode] = 8
93
+ else
94
+ options[:colour_mode] = 8
81
95
 
82
- end
83
- end
84
-
85
- opts.on('-l', '--log [FILENAME]', String,
86
- 'Specify the path for the log file.') do |filename|
87
- options[:log] = filename
88
96
  end
97
+ end
98
+ end
89
99
 
90
- opts.on('--drb', 'Run application with DRb on.') do
91
- options[:drb] = true
92
- end
100
+ # @return [OptionParser]
101
+ def cooked
102
+ parser.on('-c', '--cooked', 'Run application in cooked mode.') do
103
+ options[:terminal_mode] = :cooked
104
+ end
105
+ end
93
106
 
94
- opts.on('--drb-host',
95
- 'Set the hostname/IP for the DRb server.') do |hostname|
96
- # options[:drb] = true
97
- options[:drb_host] = hostname
98
- end
107
+ # @return [OptionParser]
108
+ def debug
109
+ parser.on('-d', '--debug', 'Run application with debugging on.') do
110
+ options[:debug] = true
111
+ end
112
+ end
99
113
 
100
- opts.on('--drb-port', 'Set the port for the DRb server.') do |port|
101
- # options[:drb] = true
102
- options[:drb_port] = port
103
- end
114
+ # @return [OptionParser]
115
+ def drb
116
+ parser.on('--drb', 'Run application with DRb on.') do
117
+ options[:drb] = true
118
+ end
119
+ end
104
120
 
105
- opts.on('--drb-height',
121
+ # @return [OptionParser]
122
+ def drb_height
123
+ parser.on('--drb-height',
106
124
  'Set the height for fake terminal.') do |height|
107
- # options[:drb] = true
108
- options[:drb_height] = height
109
- end
125
+ # options[:drb] = true
126
+ options[:drb_height] = height
127
+ end
128
+ end
129
+
130
+ # @return [OptionParser]
131
+ def drb_host
132
+ parser.on('--drb-host',
133
+ 'Set the hostname/IP for the DRb server.') do |hostname|
134
+ # options[:drb] = true
135
+ options[:drb_host] = hostname
136
+ end
137
+ end
138
+
139
+ # @return [OptionParser]
140
+ def drb_port
141
+ parser.on('--drb-port', 'Set the port for the DRb server.') do |port|
142
+ # options[:drb] = true
143
+ options[:drb_port] = port
144
+ end
145
+ end
110
146
 
111
- opts.on('--drb-width',
147
+ # @return [OptionParser]
148
+ def drb_width
149
+ parser.on('--drb-width',
112
150
  'Set the width for fake terminal.') do |width|
113
- # options[:drb] = true
114
- options[:drb_width] = width
115
- end
151
+ # options[:drb] = true
152
+ options[:drb_width] = width
116
153
  end
154
+ end
117
155
 
118
- parser.parse!(args)
156
+ # @return [OptionParser]
157
+ def interactive
158
+ parser.on('-i', '--interactive',
159
+ 'Run the application in interactive mode (default).') do
160
+ options[:interactive] = true
161
+ end
162
+ end
119
163
 
120
- Vedeu::Config.log(Esc.blue { '[cli]' }, options)
164
+ # @return [OptionParser]
165
+ def log
166
+ parser.on('-l', '--log [FILENAME]', String,
167
+ 'Specify the path for the log file.') do |filename|
168
+ options[:log] = filename
169
+ end
121
170
  end
122
171
 
123
- private
172
+ # @return [OptionParser]
173
+ def raw
174
+ parser.on('-r', '--raw', 'Run application in raw mode (default).') do
175
+ options[:terminal_mode] = :raw
176
+ end
177
+ end
124
178
 
125
- # @!attribute [r] args
126
- # @return [Array<String>]
127
- attr_reader :args
179
+ # @return [OptionParser]
180
+ def run_many
181
+ parser.on('-n', '--run-many',
182
+ 'Run the application loop continuously (default).') do
183
+ options[:once] = false
184
+ end
185
+ end
128
186
 
129
- # @!attribute [r] options
130
- # @return [Hash]
131
- attr_reader :options
187
+ # @return [OptionParser]
188
+ def run_once
189
+ parser.on('-1', '--run-once', 'Run the application loop once.') do
190
+ options[:once] = true
191
+ end
192
+ end
193
+
194
+ # @return [OptionParser]
195
+ def standalone
196
+ parser.on('-I', '--noninteractive', '--standalone',
197
+ 'Run the application non-interactively; ' \
198
+ 'i.e. not requiring intervention from the user.') do
199
+ options[:interactive] = false
200
+ end
201
+ end
202
+
203
+ # @return [OptionParser]
204
+ def trace
205
+ parser.on('-D', '--trace', 'Run application with debugging on with ' \
206
+ 'method and event tracing (noisy!).') do
207
+ options[:debug] = true
208
+ options[:trace] = true
209
+ end
210
+ end
132
211
 
133
212
  end # CLI
134
213
 
@@ -1,10 +1,9 @@
1
1
  module Vedeu
2
2
 
3
3
  # Namespace for the API configuration and CLI configuration classes.
4
- #
5
4
  module Config
6
5
 
7
- extend self
6
+ module_function
8
7
 
9
8
  # Custom log for configuration.
10
9
  #
@@ -1,11 +1,7 @@
1
- require 'vedeu/cursor/all'
2
- require 'vedeu/geometry/position'
3
-
4
1
  module Vedeu
5
2
 
6
3
  # Each interface has its own Cursor which maintains the position and
7
4
  # visibility of the cursor within that interface.
8
- #
9
5
  class Cursor
10
6
 
11
7
  extend Forwardable
@@ -1,7 +1,3 @@
1
- require 'vedeu/cursor/cursor'
2
- require 'vedeu/geometry/coordinate'
3
- require 'vedeu/geometry/position_validator'
4
-
5
1
  module Vedeu
6
2
 
7
3
  # Adjusts the position of the cursor. To use this class, call the appropriate
@@ -32,7 +28,6 @@ module Vedeu
32
28
  # The cursor will not exceed the border or boundary of the interface.
33
29
  # The cursor will move freely within the bounds of the interface,
34
30
  # irrespective of content.
35
- #
36
31
  class Move
37
32
 
38
33
  extend Forwardable
@@ -122,7 +117,7 @@ module Vedeu
122
117
  cursor
123
118
  end
124
119
 
125
- private
120
+ protected
126
121
 
127
122
  # @!attribute [r] dx
128
123
  # @return [Fixnum]
@@ -136,6 +131,8 @@ module Vedeu
136
131
  # @return [String]
137
132
  attr_reader :name
138
133
 
134
+ private
135
+
139
136
  # @return [Hash<Symbol => Fixnum, String>]
140
137
  def attributes
141
138
  cursor.attributes
@@ -2,7 +2,6 @@ module Vedeu
2
2
 
3
3
  # Handle the refreshing (redrawing) of a cursor, without redrawing the whole
4
4
  # interface; unless the cursor's offset has caused the view to change.
5
- #
6
5
  class RefreshCursor
7
6
 
8
7
  extend Forwardable
@@ -37,12 +36,14 @@ module Vedeu
37
36
  Vedeu::Terminal.output(new_cursor.to_s)
38
37
  end
39
38
 
40
- private
39
+ protected
41
40
 
42
41
  # @!attribute [r] name
43
42
  # @return [String]
44
43
  attr_reader :name
45
44
 
45
+ private
46
+
46
47
  # @return [Boolean]
47
48
  def refresh_view?
48
49
  new_cursor.ox >= width || new_cursor.oy >= height
@@ -71,6 +72,15 @@ module Vedeu
71
72
  @cursor ||= Vedeu.cursors.by_name(name)
72
73
  end
73
74
 
75
+ # Fetch the border by name.
76
+ #
77
+ # @note
78
+ # Vedeu::Border is used in this way because if there is not a border
79
+ # defined, it will fallback to a Vedeu::Null::Border which uses
80
+ # Vedeu::Geometry to determine it's dimensions based on the name also.
81
+ # When a Vedeu::Geometry cannot be found, this falls back to a
82
+ # Vedeu::Null::Geometry which uses the current terminal's dimensions.
83
+ #
74
84
  # @return (see Vedeu::Borders#by_name)
75
85
  def border
76
86
  @border ||= Vedeu.borders.by_name(name)
@@ -8,7 +8,6 @@ module Vedeu
8
8
  # client = Vedeu::Distributed::Client.connect("druby://localhost:21420")
9
9
  # client.input('a')
10
10
  # client.output # => 'some content...'
11
- #
12
11
  class Client
13
12
 
14
13
  # @param (see #initialize)
@@ -84,12 +83,14 @@ module Vedeu
84
83
  :shutdown
85
84
  end
86
85
 
87
- private
86
+ protected
88
87
 
89
88
  # @!attribute [r] uri
90
89
  # @return [String]
91
90
  attr_reader :uri
92
91
 
92
+ private
93
+
93
94
  # @return [void]
94
95
  def server
95
96
  @server ||= DRbObject.new_with_uri(uri)