vedeu 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/Rakefile +6 -0
  4. data/bin/vedeu_drb_client +8 -3
  5. data/bin/vedeu_drb_server +113 -0
  6. data/bin/vedeu_test +1 -1
  7. data/docs/events.md +0 -127
  8. data/examples/borders_app.rb +17 -7
  9. data/examples/configuration_app.rb +1 -1
  10. data/examples/cursor_app.rb +4 -2
  11. data/examples/drb_app.rb +113 -0
  12. data/examples/focus_app.rb +1 -1
  13. data/examples/geometry_app.rb +1 -1
  14. data/examples/hello_world.rb +1 -1
  15. data/examples/lines_app.rb +1 -1
  16. data/features/start_stop.feature +1 -1
  17. data/inch.yml +5 -0
  18. data/lib/vedeu/all.rb +2 -0
  19. data/lib/vedeu/api.rb +1 -0
  20. data/lib/vedeu/application.rb +17 -36
  21. data/lib/vedeu/bindings.rb +134 -27
  22. data/lib/vedeu/buffers/display_buffer.rb +1 -4
  23. data/lib/vedeu/configuration/api.rb +15 -14
  24. data/lib/vedeu/configuration/cli.rb +17 -16
  25. data/lib/vedeu/configuration/configuration.rb +3 -1
  26. data/lib/vedeu/cursor/cursor.rb +6 -8
  27. data/lib/vedeu/cursor/move_cursor.rb +1 -0
  28. data/lib/vedeu/cursor/toggle_cursor.rb +1 -0
  29. data/lib/vedeu/debug.rb +23 -0
  30. data/lib/vedeu/distributed/all.rb +1 -1
  31. data/lib/vedeu/distributed/client.rb +55 -13
  32. data/lib/vedeu/distributed/server.rb +207 -0
  33. data/lib/vedeu/distributed/subprocess.rb +22 -21
  34. data/lib/vedeu/distributed/templates/default_application.vedeu +3 -1
  35. data/lib/vedeu/distributed/test_application.rb +2 -1
  36. data/lib/vedeu/distributed/uri.rb +1 -0
  37. data/lib/vedeu/dsl/all.rb +4 -2
  38. data/lib/vedeu/dsl/components/border.rb +11 -10
  39. data/lib/vedeu/dsl/components/geometry.rb +1 -0
  40. data/lib/vedeu/dsl/components/keymap.rb +1 -0
  41. data/lib/vedeu/dsl/components/menu.rb +1 -0
  42. data/lib/vedeu/dsl/interface.rb +1 -0
  43. data/lib/vedeu/dsl/line.rb +3 -1
  44. data/lib/vedeu/dsl/shared/colour.rb +1 -0
  45. data/lib/vedeu/dsl/shared/style.rb +1 -0
  46. data/lib/vedeu/dsl/shared/text.rb +2 -0
  47. data/lib/vedeu/dsl/shared/use.rb +3 -0
  48. data/lib/vedeu/dsl/stream.rb +3 -1
  49. data/lib/vedeu/dsl/view.rb +1 -0
  50. data/lib/vedeu/events/event.rb +9 -6
  51. data/lib/vedeu/events/trigger.rb +18 -7
  52. data/lib/vedeu/exceptions.rb +4 -1
  53. data/lib/vedeu/input/input.rb +1 -0
  54. data/lib/vedeu/input/key.rb +0 -1
  55. data/lib/vedeu/input/keymap.rb +5 -3
  56. data/lib/vedeu/input/keys.rb +1 -0
  57. data/lib/vedeu/input/mapper.rb +1 -0
  58. data/lib/vedeu/launcher.rb +35 -12
  59. data/lib/vedeu/main_loop.rb +53 -0
  60. data/lib/vedeu/models/collection.rb +11 -3
  61. data/lib/vedeu/models/focus.rb +3 -3
  62. data/lib/vedeu/models/geometry.rb +8 -16
  63. data/lib/vedeu/models/group.rb +1 -0
  64. data/lib/vedeu/models/menu.rb +2 -1
  65. data/lib/vedeu/models/model.rb +7 -1
  66. data/lib/vedeu/models/view/char.rb +52 -44
  67. data/lib/vedeu/models/view/chars.rb +1 -0
  68. data/lib/vedeu/models/view/composition.rb +2 -1
  69. data/lib/vedeu/models/view/interface.rb +5 -3
  70. data/lib/vedeu/models/view/interfaces.rb +1 -0
  71. data/lib/vedeu/models/view/line.rb +2 -1
  72. data/lib/vedeu/models/view/stream.rb +2 -1
  73. data/lib/vedeu/models/view/streams.rb +1 -0
  74. data/lib/vedeu/output/all.rb +4 -0
  75. data/lib/vedeu/output/border.rb +75 -206
  76. data/lib/vedeu/output/compositor.rb +1 -0
  77. data/lib/vedeu/output/html_char.rb +119 -0
  78. data/lib/vedeu/output/html_renderer.rb +89 -0
  79. data/lib/vedeu/output/output.rb +48 -44
  80. data/lib/vedeu/output/position_index.rb +12 -1
  81. data/lib/vedeu/output/renderer.rb +28 -0
  82. data/lib/vedeu/output/viewport.rb +14 -14
  83. data/lib/vedeu/output/virtual_buffer.rb +56 -0
  84. data/lib/vedeu/output/virtual_terminal.rb +42 -34
  85. data/lib/vedeu/output/wordwrap.rb +3 -0
  86. data/lib/vedeu/output/writer.rb +13 -1
  87. data/lib/vedeu/presentation/background.rb +1 -0
  88. data/lib/vedeu/presentation/colour.rb +8 -7
  89. data/lib/vedeu/presentation/foreground.rb +1 -0
  90. data/lib/vedeu/presentation/presentation.rb +43 -7
  91. data/lib/vedeu/presentation/translator.rb +12 -0
  92. data/lib/vedeu/repositories/repository.rb +8 -8
  93. data/lib/vedeu/support/bounding_area.rb +2 -0
  94. data/lib/vedeu/support/coercions.rb +2 -1
  95. data/lib/vedeu/support/common.rb +1 -0
  96. data/lib/vedeu/support/console.rb +17 -23
  97. data/lib/vedeu/support/content_geometry.rb +2 -0
  98. data/lib/vedeu/support/coordinate.rb +1 -0
  99. data/lib/vedeu/support/esc.rb +58 -29
  100. data/lib/vedeu/support/grid.rb +1 -0
  101. data/lib/vedeu/support/limit.rb +9 -0
  102. data/lib/vedeu/support/log.rb +31 -9
  103. data/lib/vedeu/support/node.rb +8 -18
  104. data/lib/vedeu/support/position.rb +13 -34
  105. data/lib/vedeu/support/position_validator.rb +3 -0
  106. data/lib/vedeu/support/read.rb +1 -0
  107. data/lib/vedeu/support/refresh.rb +3 -2
  108. data/lib/vedeu/support/terminal.rb +11 -5
  109. data/lib/vedeu/support/trace.rb +16 -1
  110. data/lib/vedeu/support/visible.rb +2 -0
  111. data/lib/vedeu/support/write.rb +1 -0
  112. data/lib/vedeu/traps.rb +1 -0
  113. data/lib/vedeu.rb +2 -0
  114. data/test/integration/distributed_test.rb +10 -8
  115. data/test/lib/vedeu/api_test.rb +3 -7
  116. data/test/lib/vedeu/application_test.rb +2 -5
  117. data/test/lib/vedeu/configuration/api_test.rb +12 -0
  118. data/test/lib/vedeu/cursor/cursor_test.rb +2 -0
  119. data/test/lib/vedeu/distributed/client_test.rb +17 -7
  120. data/test/lib/vedeu/distributed/server_test.rb +56 -0
  121. data/test/lib/vedeu/distributed/test_application_test.rb +7 -3
  122. data/test/lib/vedeu/dsl/components/border_test.rb +10 -2
  123. data/test/lib/vedeu/dsl/interface_test.rb +6 -0
  124. data/test/lib/vedeu/dsl/line_test.rb +19 -0
  125. data/test/lib/vedeu/dsl/shared/colour_test.rb +4 -26
  126. data/test/lib/vedeu/dsl/shared/text_test.rb +8 -1
  127. data/test/lib/vedeu/dsl/stream_test.rb +13 -1
  128. data/test/lib/vedeu/input/input_test.rb +1 -1
  129. data/test/lib/vedeu/input/key_test.rb +3 -16
  130. data/test/lib/vedeu/launcher_test.rb +11 -1
  131. data/test/lib/vedeu/main_loop_test.rb +41 -0
  132. data/test/lib/vedeu/models/geometry_test.rb +15 -34
  133. data/test/lib/vedeu/models/view/char_test.rb +44 -45
  134. data/test/lib/vedeu/models/view/interface_test.rb +6 -0
  135. data/test/lib/vedeu/models/view/line_test.rb +1 -1
  136. data/test/lib/vedeu/models/view/stream_test.rb +1 -1
  137. data/test/lib/vedeu/output/border_test.rb +6 -5
  138. data/test/lib/vedeu/output/compositor_test.rb +2 -20
  139. data/test/lib/vedeu/output/html_char_test.rb +85 -0
  140. data/test/lib/vedeu/output/html_renderer_test.rb +37 -0
  141. data/test/lib/vedeu/output/position_index_test.rb +2 -10
  142. data/test/lib/vedeu/output/renderer_test.rb +24 -0
  143. data/test/lib/vedeu/output/virtual_buffer_test.rb +53 -0
  144. data/test/lib/vedeu/output/virtual_terminal_test.rb +32 -2
  145. data/test/lib/vedeu/presentation/background_test.rb +41 -1
  146. data/test/lib/vedeu/presentation/colour_test.rb +10 -6
  147. data/test/lib/vedeu/presentation/foreground_test.rb +46 -6
  148. data/test/lib/vedeu/presentation/presentation_test.rb +44 -1
  149. data/test/lib/vedeu/presentation/translator_test.rb +34 -0
  150. data/test/lib/vedeu/repositories/repository_test.rb +1 -1
  151. data/test/lib/vedeu/support/bounding_area_test.rb +4 -12
  152. data/test/lib/vedeu/support/console_test.rb +9 -50
  153. data/test/lib/vedeu/support/esc_test.rb +7 -7
  154. data/test/lib/vedeu/support/position_test.rb +42 -0
  155. data/test/lib/vedeu/support/terminal_test.rb +5 -20
  156. data/test/lib/vedeu/support/write_test.rb +42 -18
  157. data/test/support/helpers/all.rb +0 -1
  158. data/test/support/helpers/repository_test_module.rb +1 -0
  159. data/test/test_helper.rb +5 -2
  160. data/vedeu.gemspec +7 -5
  161. metadata +60 -14
  162. data/lib/vedeu/distributed/application.rb +0 -91
  163. data/test/lib/vedeu/distributed/application_test.rb +0 -24
  164. data/test/support/helpers/presentation.rb +0 -16
@@ -3,29 +3,29 @@ module Vedeu
3
3
  # Orchestrates the running of the main application loop.
4
4
  #
5
5
  # @api private
6
+ #
6
7
  class Application
7
8
 
8
9
  class << self
9
10
 
10
- # @return []
11
+ # @return [void]
11
12
  def start(configuration)
12
13
  new(configuration).start
13
14
  end
14
15
  alias_method :restart, :start
15
16
 
16
17
  # Stops the application!
17
- # - The `:cleanup` event is triggered. Vedeu does not handle this event;
18
- # the client application may treat this event as Vedeu signalling that it
19
- # is about to terminate. Client applications are encouraged to use this
20
- # event to close any open buffers, save files, empty trash, etc.
18
+ # - The `:_cleanup_` event is triggered, which in turn triggers the client
19
+ # event `:cleanup`; the client application may treat this event as Vedeu
20
+ # signalling that it is about to terminate. Client applications are
21
+ # encouraged to use this event to close any open buffers, save files,
22
+ # empty trash, etc.
21
23
  #
22
- # @raise [StopIteration] Will cause {#start} to exit its loop and
23
- # terminate the application.
24
- # @return [StopIteration]
24
+ # @return [void]
25
25
  def stop
26
- Vedeu.trigger(:cleanup)
26
+ Vedeu.trigger(:_cleanup_)
27
27
 
28
- fail StopIteration
28
+ Vedeu::MainLoop.stop!
29
29
  end
30
30
 
31
31
  end # Application eigenclass
@@ -49,7 +49,7 @@ module Vedeu
49
49
  #
50
50
  # @return [Array] The last output sent to the terminal.
51
51
  def start
52
- distributed_start
52
+ Vedeu.trigger(:_drb_start_)
53
53
 
54
54
  output = Terminal.open do
55
55
  Terminal.set_cursor_mode
@@ -59,7 +59,7 @@ module Vedeu
59
59
  runner { main_sequence }
60
60
  end
61
61
 
62
- distributed_stop
62
+ Vedeu.trigger(:_drb_stop_, 'via Vedeu::Application#start')
63
63
 
64
64
  output
65
65
  end
@@ -71,7 +71,7 @@ module Vedeu
71
71
  # Runs the application loop either once, or forever (exceptions and signals
72
72
  # permitting).
73
73
  #
74
- # @return []
74
+ # @return [void]
75
75
  def runner
76
76
  if configuration.once?
77
77
  yield
@@ -89,7 +89,7 @@ module Vedeu
89
89
  # and 'do something useful'. When the client application has finished, it
90
90
  # should trigger the `:_exit_` event.
91
91
  #
92
- # @return []
92
+ # @return [void]
93
93
  def main_sequence
94
94
  if configuration.interactive?
95
95
  Input.capture(Terminal)
@@ -104,38 +104,19 @@ module Vedeu
104
104
  # uncaught exception occurs or when either the `:_mode_switch_` or `:_exit_`
105
105
  # event is triggered.
106
106
  #
107
- # @return []
107
+ # @return [void]
108
108
  def run_many
109
- loop do
110
- Vedeu.trigger(:_tick_)
111
- yield
112
-
113
- end
109
+ MainLoop.start! { yield }
114
110
 
115
111
  rescue ModeSwitch
116
112
  Terminal.switch_mode!
117
113
 
118
- distributed_stop
114
+ Vedeu.trigger(:_drb_restart_)
119
115
 
120
116
  Application.restart
121
117
 
122
118
  end
123
119
 
124
- # @return []
125
- def distributed_start
126
- distributed.start if configuration.drb?
127
- end
128
-
129
- # @return []
130
- def distributed_stop
131
- distributed.stop if configuration.drb?
132
- end
133
-
134
- # @return [Vedeu::Distributed::Application]
135
- def distributed
136
- @distributed ||= Vedeu::Distributed::Application.new(configuration)
137
- end
138
-
139
120
  # :nocov:
140
121
 
141
122
  end # Application
@@ -17,41 +17,111 @@ module Vedeu
17
17
  # underscore, it's probably used by Vedeu internally.
18
18
  #
19
19
  # :nocov:
20
+ #
20
21
  module Bindings
21
22
 
22
- # System events needed by Vedeu to run.
23
- Vedeu.bind(:_clear_) { Vedeu::Terminal.clear }
23
+ # Clears the whole terminal space.
24
+ Vedeu.bind(:_clear_) { Vedeu::Terminal.clear }
25
+
26
+ # Vedeu triggers this event when `:_exit_` is triggered. You can hook into
27
+ # this to perform a special action before the application terminates. Saving
28
+ # the user's work, session or preferences might be popular here.
29
+ Vedeu.bind(:_cleanup_) do
30
+ Vedeu.trigger(:_drb_stop_, 'via :cleanup')
31
+ Vedeu.trigger(:cleanup)
32
+ end
33
+
34
+ Vedeu.bind(:_drb_input_) do |data|
35
+ Vedeu.log(type: :drb, message: 'Sending input')
36
+ Vedeu.trigger(:_keypress_, data)
37
+ end
38
+
39
+ Vedeu.bind(:_drb_retrieve_output_) do
40
+ Vedeu.log(type: :drb, message: 'Retrieving output')
41
+ Vedeu::VirtualBuffer.retrieve
42
+ end
43
+
44
+ Vedeu.bind(:_drb_store_output_) do |data|
45
+ Vedeu.log(type: :drb, message: 'Storing output')
46
+ Vedeu::VirtualBuffer.store(Vedeu::Terminal.virtual.output(data))
47
+ end
48
+
49
+ Vedeu.bind(:_drb_restart_) do
50
+ Vedeu.log(type: :drb, message: 'Attempting to restart')
51
+ Vedeu::Distributed::Server.restart
52
+ end
53
+
54
+ Vedeu.bind(:_drb_start_) do
55
+ Vedeu.log(type: :drb, message: 'Attempting to start')
56
+ Vedeu::Distributed::Server.start
57
+ end
58
+
59
+ Vedeu.bind(:_drb_status_) do
60
+ Vedeu.log(type: :drb, message: 'Fetching status')
61
+ Vedeu::Distributed::Server.status
62
+ end
63
+
64
+ Vedeu.bind(:_drb_stop_) do |message|
65
+ Vedeu.log(type: :drb, message: "Attempting to stop (#{message})")
66
+ Vedeu::Distributed::Server.stop
67
+ end
68
+
69
+ # When triggered, Vedeu will trigger a `:cleanup` event which you can define
70
+ # (to save files, etc) and attempt to exit.
24
71
  Vedeu.bind(:_exit_) { Vedeu::Application.stop }
72
+
73
+ # Vedeu triggers this event when it is ready to enter the main loop. Client
74
+ # applications can listen for this event and perform some action(s), like
75
+ # render the first screen, interface or make a sound. When Vedeu triggers
76
+ # this event, the :_refresh_ event is also triggered automatically.
25
77
  Vedeu.bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
26
- Vedeu.bind(:_keypress_) { |key| Vedeu.keypress(key) }
27
- Vedeu.bind(:_log_) { |msg| Vedeu.log(msg) }
28
- Vedeu.bind(:_mode_switch_) { fail ModeSwitch }
29
- Vedeu.bind(:_resize_, { delay: 0.25 }) { Vedeu.resize }
30
-
31
- # System events which when called will update the cursor visibility
32
- # accordingly for the interface in focus, or the named interface. Also
33
- # includes events to move the cursor in the direction specified; these will
34
- # update the cursor position according to the interface in focus.
78
+
79
+ # Triggering this event will cause the triggering of the `:key` event; which
80
+ # you should define to 'do things'. If the `escape` key is pressed, then
81
+ # `key` is triggered with the argument `:escape`, also an internal event
82
+ # `_mode_switch_` is triggered.
83
+ Vedeu.bind(:_keypress_) { |key| Vedeu.keypress(key) }
84
+
85
+ # When triggered with a message will cause Vedeu to log the message if
86
+ # logging is enabled in the configuration.
87
+ Vedeu.bind(:_log_) { |msg| Vedeu.log(type: :debug, message: msg) }
88
+
89
+ # When triggered (after the user presses `escape`), Vedeu switches from a
90
+ # "raw mode" terminal to a "cooked mode" terminal. The idea here being that
91
+ # the raw mode is for single keypress actions, whilst cooked mode allows the
92
+ # user to enter more elaborate commands- such as commands with arguments.
93
+ Vedeu.bind(:_mode_switch_) { fail ModeSwitch }
94
+
95
+ # When triggered will cause Vedeu to trigger the `:_clear_` and `:_refresh_`
96
+ # events. Please see those events for their behaviour.
97
+ Vedeu.bind(:_resize_, { delay: 0.25 }) { Vedeu.resize }
98
+
99
+ # Hide the cursor of the interface currently in focus.
35
100
  Vedeu.bind(:_cursor_hide_) do
36
101
  ToggleCursor.hide(Vedeu.cursor)
37
102
  end
38
103
 
104
+ # Show the cursor of the interface currently in focus.
39
105
  Vedeu.bind(:_cursor_show_) do
40
106
  ToggleCursor.show(Vedeu.cursor)
41
107
  end
42
108
 
109
+ # Hide the cursor of the named interface.
43
110
  Vedeu.bind(:_cursor_hide_by_name_) do |name|
44
111
  named = Vedeu.cursors.by_name(name)
45
112
 
46
113
  ToggleCursor.hide(named)
47
114
  end
48
115
 
116
+ # Show the cursor of the named interface.
49
117
  Vedeu.bind(:_cursor_show_by_name_) do |name|
50
118
  named = Vedeu.cursors.by_name(name)
51
119
 
52
120
  ToggleCursor.show(named)
53
121
  end
54
122
 
123
+ # Move the cursor down one character in the interface currently in focus.
124
+ # Will not exceed the border or boundary of the interface.
55
125
  Vedeu.bind(:_cursor_down_) do
56
126
  interface = Vedeu.interfaces.current
57
127
 
@@ -60,6 +130,8 @@ module Vedeu
60
130
  Refresh.by_focus
61
131
  end
62
132
 
133
+ # Move the cursor left one character in the interface currently in focus.
134
+ # Will not exceed the border or boundary of the interface.
63
135
  Vedeu.bind(:_cursor_left_) do
64
136
  interface = Vedeu.interfaces.current
65
137
 
@@ -68,6 +140,8 @@ module Vedeu
68
140
  Refresh.by_focus
69
141
  end
70
142
 
143
+ # Move the cursor right one character in the interface currently in focus.
144
+ # Will not exceed the border or boundary of the interface.
71
145
  Vedeu.bind(:_cursor_right_) do
72
146
  interface = Vedeu.interfaces.current
73
147
 
@@ -76,6 +150,8 @@ module Vedeu
76
150
  Refresh.by_focus
77
151
  end
78
152
 
153
+ # Move the cursor up one character in the interface currently in focus.
154
+ # Will not exceed the border or boundary of the interface.
79
155
  Vedeu.bind(:_cursor_up_) do
80
156
  interface = Vedeu.interfaces.current
81
157
 
@@ -84,6 +160,8 @@ module Vedeu
84
160
  Refresh.by_focus
85
161
  end
86
162
 
163
+ # Moves the cursor to the top left position of the interface currently in
164
+ # focus; respecting a border if present.
87
165
  Vedeu.bind(:_cursor_origin_) do
88
166
  interface = Vedeu.interfaces.current
89
167
 
@@ -92,27 +170,56 @@ module Vedeu
92
170
  Refresh.by_focus
93
171
  end
94
172
 
95
- # System events which when called will change which interface is currently
96
- # focussed. When the interface is brought into focus, its cursor position
97
- # and visibility is restored.
173
+ # When triggered with an interface name will focus that interface and
174
+ # restore the cursor position and visibility.
98
175
  Vedeu.bind(:_focus_by_name_) { |name| Vedeu.focus_by_name(name) }
99
- Vedeu.bind(:_focus_next_) { Vedeu.focus_next }
100
- Vedeu.bind(:_focus_prev_) { Vedeu.focus_previous }
101
176
 
102
- # System events which when called with the appropriate menu name will
103
- # update the menu accordingly.
104
- Vedeu.bind(:_menu_bottom_) { |name| Vedeu.menus.find(name).bottom_item }
105
- Vedeu.bind(:_menu_current_) { |name| Vedeu.menus.find(name).current_item }
177
+ # When triggered will focus the next interface and restore the cursor
178
+ # position and visibility.
179
+ Vedeu.bind(:_focus_next_) { Vedeu.focus_next }
180
+
181
+ # When triggered will focus the previous interface and restore the cursor
182
+ # position and visibility.
183
+ Vedeu.bind(:_focus_prev_) { Vedeu.focus_previous }
184
+
185
+ # Requires target menu name as argument. Makes the last menu item the
186
+ # current menu item.
187
+ Vedeu.bind(:_menu_bottom_) { |name| Vedeu.menus.find(name).bottom_item }
188
+
189
+ # Requires target menu name as argument. Returns the current menu item.
190
+ Vedeu.bind(:_menu_current_) { |name| Vedeu.menus.find(name).current_item }
191
+
192
+ # Requires target menu name as argument. Deselects all menu items.
106
193
  Vedeu.bind(:_menu_deselect_) { |name| Vedeu.menus.find(name).deselect_item }
107
- Vedeu.bind(:_menu_items_) { |name| Vedeu.menus.find(name).items }
108
- Vedeu.bind(:_menu_next_) { |name| Vedeu.menus.find(name).next_item }
109
- Vedeu.bind(:_menu_prev_) { |name| Vedeu.menus.find(name).prev_item }
194
+
195
+ # Requires target menu name as argument. Returns all the menu items with
196
+ # respective `current` or `selected` boolean indicators.
197
+ Vedeu.bind(:_menu_items_) { |name| Vedeu.menus.find(name).items }
198
+
199
+ # Requires target menu name as argument. Makes the next menu item the
200
+ # current menu item, until it reaches the last item.
201
+ Vedeu.bind(:_menu_next_) { |name| Vedeu.menus.find(name).next_item }
202
+
203
+ # Requires target menu name as argument. Makes the previous menu item the
204
+ # current menu item, until it reaches the first item.
205
+ Vedeu.bind(:_menu_prev_) { |name| Vedeu.menus.find(name).prev_item }
206
+
207
+ # Requires target menu name as argument. Returns the selected menu item.
110
208
  Vedeu.bind(:_menu_selected_) { |name| Vedeu.menus.find(name).selected_item }
111
- Vedeu.bind(:_menu_select_) { |name| Vedeu.menus.find(name).select_item }
112
- Vedeu.bind(:_menu_top_) { |name| Vedeu.menus.find(name).top_item }
113
- Vedeu.bind(:_menu_view_) { |name| Vedeu.menus.find(name).view }
114
209
 
115
- # System event to refresh all registered interfaces.
210
+ # Requires target menu name as argument. Makes the current menu item also
211
+ # the selected menu item.
212
+ Vedeu.bind(:_menu_select_) { |name| Vedeu.menus.find(name).select_item }
213
+
214
+ # Requires target menu name as argument. Makes the first menu item the
215
+ # current menu item.
216
+ Vedeu.bind(:_menu_top_) { |name| Vedeu.menus.find(name).top_item }
217
+
218
+ # Requires target menu name as argument. Returns a subset of the menu items;
219
+ # starting at the current item to the last item.
220
+ Vedeu.bind(:_menu_view_) { |name| Vedeu.menus.find(name).view }
221
+
222
+ # Triggering this event will cause all interfaces to refresh.
116
223
  Vedeu.bind(:_refresh_) { Vedeu::Refresh.all }
117
224
 
118
225
  end # Bindings
@@ -24,6 +24,7 @@ module Vedeu
24
24
  # Store the view if it has a name. This view will be shown next time the
25
25
  # refresh event is triggered for the interface.
26
26
  #
27
+ # @raise [InvalidSyntax] The name is not defined.
27
28
  # @return [Interface]
28
29
  def store_deferred
29
30
  unless defined_value?(name)
@@ -44,13 +45,9 @@ module Vedeu
44
45
  # @return [Interface]
45
46
  def store_new_buffer
46
47
  if Vedeu.buffers.registered?(name)
47
- Vedeu.log("Updating buffer: '#{name}'")
48
-
49
48
  Vedeu.buffers.find(name).add(self)
50
49
 
51
50
  else
52
- Vedeu.log("Registering buffer: '#{name}'")
53
-
54
51
  Buffer.new(name, self).store
55
52
 
56
53
  end
@@ -8,6 +8,7 @@ module Vedeu
8
8
  # options used by Vedeu to affect certain behaviours.
9
9
  #
10
10
  # @api private
11
+ #
11
12
  class API
12
13
 
13
14
  include Vedeu::Common
@@ -64,7 +65,7 @@ module Vedeu
64
65
  # @param value [Boolean]
65
66
  # @return [Boolean]
66
67
  def interactive!(value = true)
67
- Vedeu.log("Configuration::API interactive: #{value}")
68
+ Vedeu.log(type: :info, message: "Configuration::API interactive: #{value}")
68
69
 
69
70
  options[:interactive] = value
70
71
  end
@@ -81,7 +82,7 @@ module Vedeu
81
82
  # @param value [Boolean]
82
83
  # @return [Boolean]
83
84
  def standalone!(value = true)
84
- Vedeu.log("Configuration::API interactive: #{!value}")
85
+ Vedeu.log(type: :info, message: "Configuration::API interactive: #{!value}")
85
86
 
86
87
  options[:interactive] = !value
87
88
  end
@@ -99,7 +100,7 @@ module Vedeu
99
100
  # @param value [Boolean]
100
101
  # @return [Boolean]
101
102
  def run_once!(value = true)
102
- Vedeu.log("Configuration::API once: #{value}")
103
+ Vedeu.log(type: :info, message: "Configuration::API once: #{value}")
103
104
 
104
105
  options[:once] = value
105
106
  end
@@ -115,7 +116,7 @@ module Vedeu
115
116
  # @param value [Boolean]
116
117
  # @return [Boolean]
117
118
  def drb!(value = true)
118
- Vedeu.log("Configuration::API drb: #{value}")
119
+ Vedeu.log(type: :info, message: "Configuration::API drb: #{value}")
119
120
 
120
121
  options[:drb] = value
121
122
  end
@@ -182,7 +183,7 @@ module Vedeu
182
183
  #
183
184
  # @return [Boolean]
184
185
  def cooked!
185
- Vedeu.log("Configuration::API terminal_mode: :cooked")
186
+ Vedeu.log(type: :info, message: "Configuration::API terminal_mode: :cooked")
186
187
 
187
188
  options[:terminal_mode] = :cooked
188
189
  end
@@ -197,7 +198,7 @@ module Vedeu
197
198
  #
198
199
  # @return [Boolean]
199
200
  def raw!
200
- Vedeu.log("Configuration::API terminal_mode: :raw")
201
+ Vedeu.log(type: :info, message: "Configuration::API terminal_mode: :raw")
201
202
 
202
203
  options[:terminal_mode] = :raw
203
204
  end
@@ -221,12 +222,12 @@ module Vedeu
221
222
  # @return [Boolean]
222
223
  def debug!(value = true)
223
224
  if options.key?(:trace) && options[:trace] != false
224
- Vedeu.log("Configuration::API debug: true")
225
+ Vedeu.log(type: :info, message: "Configuration::API debug: true")
225
226
 
226
227
  options[:debug] = true
227
228
 
228
229
  else
229
- Vedeu.log("Configuration::API debug: #{value}")
230
+ Vedeu.log(type: :info, message: "Configuration::API debug: #{value}")
230
231
 
231
232
  options[:debug] = value
232
233
 
@@ -252,7 +253,7 @@ module Vedeu
252
253
  def trace!(value = true)
253
254
  options[:debug] = true if value === true
254
255
 
255
- Vedeu.log("Configuration::API trace: #{value}")
256
+ Vedeu.log(type: :info, message: "Configuration::API trace: #{value}")
256
257
 
257
258
  options[:trace] = value
258
259
  end
@@ -273,7 +274,7 @@ module Vedeu
273
274
  fail InvalidSyntax, '`colour_mode` must be `8`, `16`, `256`, ' \
274
275
  '`16777216`.' unless valid_colour_mode?(value)
275
276
 
276
- Vedeu.log("Configuration::API colour_mode: #{value}")
277
+ Vedeu.log(type: :info, message: "Configuration::API colour_mode: #{value}")
277
278
 
278
279
  options[:colour_mode] = value
279
280
  end
@@ -346,7 +347,7 @@ module Vedeu
346
347
  def exit_key(value)
347
348
  return invalid_key('exit_key') unless valid_key?(value)
348
349
 
349
- Vedeu.log("Configuration::API exit_key: #{value}")
350
+ Vedeu.log(type: :info, message: "Configuration::API exit_key: #{value}")
350
351
 
351
352
  system_keys[:exit] = value
352
353
  end
@@ -368,7 +369,7 @@ module Vedeu
368
369
  def focus_next_key(value)
369
370
  return invalid_key('exit_key') unless valid_key?(value)
370
371
 
371
- Vedeu.log("Configuration::API focus_next: #{value}")
372
+ Vedeu.log(type: :info, message: "Configuration::API focus_next: #{value}")
372
373
 
373
374
  system_keys[:focus_next] = value
374
375
  end
@@ -390,7 +391,7 @@ module Vedeu
390
391
  def focus_prev_key(value)
391
392
  return invalid_key('exit_key') unless valid_key?(value)
392
393
 
393
- Vedeu.log("Configuration::API focus_prev: #{value}")
394
+ Vedeu.log(type: :info, message: "Configuration::API focus_prev: #{value}")
394
395
 
395
396
  system_keys[:focus_prev] = value
396
397
  end
@@ -412,7 +413,7 @@ module Vedeu
412
413
  def mode_switch_key(value)
413
414
  return invalid_key('exit_key') unless valid_key?(value)
414
415
 
415
- Vedeu.log("Configuration::API mode_switch: #{value}")
416
+ Vedeu.log(type: :info, message: "Configuration::API mode_switch: #{value}")
416
417
 
417
418
  system_keys[:mode_switch] = value
418
419
  end
@@ -8,6 +8,7 @@ module Vedeu
8
8
  # OptionParser into options used by Vedeu to affect certain behaviours.
9
9
  #
10
10
  # @api private
11
+ #
11
12
  class CLI
12
13
 
13
14
  # Configure Vedeu via command-line arguments. Options set here via
@@ -39,7 +40,7 @@ module Vedeu
39
40
 
40
41
  opts.on('-i', '--interactive',
41
42
  'Run the application in interactive mode (default).') do
42
- Vedeu.log("Configuration::CLI interactive: true")
43
+ Vedeu.log(type: :info, message: "Configuration::CLI interactive: true")
43
44
 
44
45
  options[:interactive] = true
45
46
  end
@@ -47,46 +48,46 @@ module Vedeu
47
48
  opts.on('-I', '--noninteractive', '--standalone',
48
49
  'Run the application non-interactively; i.e. not requiring ' \
49
50
  'intervention from the user.') do
50
- Vedeu.log("Configuration::CLI interactive: false")
51
+ Vedeu.log(type: :info, message: "Configuration::CLI interactive: false")
51
52
 
52
53
  options[:interactive] = false
53
54
  end
54
55
 
55
56
  opts.on('-1', '--run-once',
56
57
  'Run the application loop once.') do
57
- Vedeu.log("Configuration::CLI once: true")
58
+ Vedeu.log(type: :info, message: "Configuration::CLI once: true")
58
59
 
59
60
  options[:once] = true
60
61
  end
61
62
 
62
63
  opts.on('-n', '--run-many',
63
64
  'Run the application loop continuously (default).') do
64
- Vedeu.log("Configuration::CLI once: false")
65
+ Vedeu.log(type: :info, message: "Configuration::CLI once: false")
65
66
 
66
67
  options[:once] = false
67
68
  end
68
69
 
69
70
  opts.on('-c', '--cooked', 'Run application in cooked mode.') do
70
- Vedeu.log("Configuration::CLI terminal_mode: :cooked")
71
+ Vedeu.log(type: :info, message: "Configuration::CLI terminal_mode: :cooked")
71
72
 
72
73
  options[:terminal_mode] = :cooked
73
74
  end
74
75
 
75
76
  opts.on('-r', '--raw', 'Run application in raw mode (default).') do
76
- Vedeu.log("Configuration::CLI terminal_mode: :raw")
77
+ Vedeu.log(type: :info, message: "Configuration::CLI terminal_mode: :raw")
77
78
 
78
79
  options[:terminal_mode] = :raw
79
80
  end
80
81
 
81
82
  opts.on('-d', '--debug', 'Run application with debugging on.') do
82
- Vedeu.log("Configuration::CLI debug: true")
83
+ Vedeu.log(type: :info, message: "Configuration::CLI debug: true")
83
84
 
84
85
  options[:debug] = true
85
86
  end
86
87
 
87
88
  opts.on('-D', '--trace', 'Run application with debugging on with ' \
88
89
  'method and event tracing (noisy!).') do
89
- Vedeu.log("Configuration::CLI trace: true")
90
+ Vedeu.log(type: :info, message: "Configuration::CLI trace: true")
90
91
 
91
92
  options[:debug] = true
92
93
  options[:trace] = true
@@ -96,12 +97,12 @@ module Vedeu
96
97
  'Run application in either `8`, `16`, `256` or `16777216` ' \
97
98
  'colour mode.') do |colours|
98
99
  if [8, 16, 256, 16777216].include?(colours)
99
- Vedeu.log("Configuration::CLI colour_mode: #{colours}")
100
+ Vedeu.log(type: :info, message: "Configuration::CLI colour_mode: #{colours}")
100
101
 
101
102
  options[:colour_mode] = colours
102
103
 
103
104
  else
104
- Vedeu.log("Configuration::CLI colour_mode: 8 (defaulted)")
105
+ Vedeu.log(type: :info, message: "Configuration::CLI colour_mode: 8 (defaulted)")
105
106
 
106
107
  options[:colour_mode] = 8
107
108
 
@@ -110,40 +111,40 @@ module Vedeu
110
111
 
111
112
  opts.on('-l', '--log [FILENAME]', String,
112
113
  'Specify the path for the log file.') do |filename|
113
- Vedeu.log("Configuration::CLI log: #{filename}")
114
+ Vedeu.log(type: :info, message: "Configuration::CLI log: #{filename}")
114
115
 
115
116
  options[:log] = filename
116
117
  end
117
118
 
118
119
  opts.on('--drb', 'Run application with DRb on.') do
119
- Vedeu.log("Configuration::CLI drb: true")
120
+ Vedeu.log(type: :info, message: "Configuration::CLI drb: true")
120
121
 
121
122
  options[:drb] = true
122
123
  end
123
124
 
124
125
  opts.on('--drb-host', 'Set the hostname/IP for the DRb server.') do |hostname|
125
- Vedeu.log("Configuration::CLI drb_host: #{hostname}")
126
+ Vedeu.log(type: :info, message: "Configuration::CLI drb_host: #{hostname}")
126
127
 
127
128
  #options[:drb] = true
128
129
  options[:drb_host] = hostname
129
130
  end
130
131
 
131
132
  opts.on('--drb-port', 'Set the port for the DRb server.') do |port|
132
- Vedeu.log("Configuration::CLI drb_port: #{port}")
133
+ Vedeu.log(type: :info, message: "Configuration::CLI drb_port: #{port}")
133
134
 
134
135
  #options[:drb] = true
135
136
  options[:drb_port] = port
136
137
  end
137
138
 
138
139
  opts.on('--drb-height', 'Set the height for fake terminal of the DRb server.') do |height|
139
- Vedeu.log("Configuration::CLI drb_height: #{height}")
140
+ Vedeu.log(type: :info, message: "Configuration::CLI drb_height: #{height}")
140
141
 
141
142
  #options[:drb] = true
142
143
  options[:drb_height] = height
143
144
  end
144
145
 
145
146
  opts.on('--drb-width', 'Set the width for fake terminal of the DRb server.') do |width|
146
- Vedeu.log("Configuration::CLI drb_width: #{width}")
147
+ Vedeu.log(type: :info, message: "Configuration::CLI drb_width: #{width}")
147
148
 
148
149
  #options[:drb] = true
149
150
  options[:drb_width] = width
@@ -6,6 +6,7 @@ require 'vedeu/configuration/cli'
6
6
  module Vedeu
7
7
 
8
8
  # Namespace for the API configuration and CLI configuration classes.
9
+ #
9
10
  module Config
10
11
  end
11
12
 
@@ -18,6 +19,7 @@ module Vedeu
18
19
  # arguments provided.
19
20
  #
20
21
  # @api private
22
+ #
21
23
  class Configuration
22
24
 
23
25
  include Singleton
@@ -185,7 +187,7 @@ module Vedeu
185
187
  end
186
188
 
187
189
  # @param value []
188
- # @return []
190
+ # @return [void]
189
191
  def options=(value)
190
192
  instance.options = value
191
193
  end