vedeu 0.4.52 → 0.4.53

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/docs/events.md +15 -5
  3. data/lib/vedeu/application/application_view.rb +0 -4
  4. data/lib/vedeu/bindings/all.rb +22 -1
  5. data/lib/vedeu/bindings/drb.rb +89 -13
  6. data/lib/vedeu/bindings/menus.rb +123 -13
  7. data/lib/vedeu/bindings/movement.rb +147 -26
  8. data/lib/vedeu/bindings/system.rb +284 -0
  9. data/lib/vedeu/bindings/visibility.rb +117 -13
  10. data/lib/vedeu/dsl/all.rb +2 -1
  11. data/lib/vedeu/output/compressor.rb +2 -0
  12. data/lib/vedeu/output/refresh.rb +20 -5
  13. data/lib/vedeu/output/refresh_group.rb +6 -1
  14. data/lib/vedeu/output/render_border.rb +1 -1
  15. data/lib/vedeu/output/renderers/all.rb +1 -0
  16. data/lib/vedeu/output/renderers/escape_sequence.rb +2 -16
  17. data/lib/vedeu/output/renderers/null.rb +2 -16
  18. data/lib/vedeu/output/renderers/renderer_options.rb +26 -0
  19. data/lib/vedeu/output/renderers/terminal.rb +2 -14
  20. data/lib/vedeu/output/renderers/text.rb +2 -16
  21. data/lib/vedeu/repositories/all.rb +23 -1
  22. data/lib/vedeu/version.rb +1 -1
  23. data/test/lib/vedeu/bindings/system_test.rb +44 -0
  24. data/test/lib/vedeu/output/refresh_group_test.rb +10 -2
  25. data/test/lib/vedeu/output/refresh_test.rb +6 -23
  26. data/test/lib/vedeu/output/renderers/renderer_options_test.rb +12 -0
  27. data/test/lib/vedeu/templating/preprocessor_test.rb +11 -10
  28. metadata +8 -10
  29. data/docs/events/drb.md +0 -49
  30. data/docs/events/main.md +0 -109
  31. data/docs/events/menus.md +0 -72
  32. data/docs/events/movement.md +0 -105
  33. data/docs/events/visibility.md +0 -61
  34. data/lib/vedeu/bindings/bindings.rb +0 -86
  35. data/test/lib/vedeu/bindings/bindings_test.rb +0 -40
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2cd921c8f76dab6e9fb3b972420e1bc86dcfb33c
4
- data.tar.gz: f01800caf43bfcc0a9a50ae8825f3c96acd257ae
3
+ metadata.gz: af96b5d6c566e54996cf3c560a60650c5aec5492
4
+ data.tar.gz: 29d0ba76490206ea43cfb3d24a17a6f81fb9ff8f
5
5
  SHA512:
6
- metadata.gz: 33e373ad6fddc14a6ecbdf27645890dc4598b542b258b6a0f1d623fdf129c1afb10e1ba8056ba7aed4fb2d734687b8ab2539c5dd588f3e78e7a18779d1f9d708
7
- data.tar.gz: 647940089d7ade5c1ef030898561eb542e08265b8d4c7975712780fcdc4fe7a44afa954f5a5d8830fb02db9bf57a134c02857f50847f7d121b215ac13f9a653b
6
+ metadata.gz: f9f76c20306185777104a808a6f23a3b3c6199e6712207c7246e8758cbd2be8a456d132bfb0a2c3afce79285d3d2b8661ee8a60d592137ec21149f5cfea71edd
7
+ data.tar.gz: a7e80e7662f4c59de7ede8cea19b2feeb847a544a583d6de92888cda507794a2c96de1e8b6af19fb6e1f74dab04876f47a5c95aa77a4890729110d10ec2a9d20
data/docs/events.md CHANGED
@@ -2,12 +2,22 @@
2
2
 
3
3
  # Vedeu Events
4
4
 
5
- {include:file:docs/events/main.md}
5
+ ## System Events
6
6
 
7
- {include:file:docs/events/drb.md}
7
+ See {Vedeu::Bindings::System}
8
8
 
9
- {include:file:docs/events/menus.md}
9
+ ## DRB Events
10
10
 
11
- {include:file:docs/events/movement.md}
11
+ See {Vedeu::Bindings::DRB}
12
12
 
13
- {include:file:docs/events/visibility.md}
13
+ ## Menu Events
14
+
15
+ See {Vedeu::Bindings::Menus}
16
+
17
+ ## Movement Events
18
+
19
+ See {Vedeu::Bindings::Movement}
20
+
21
+ ## Visibility Events
22
+
23
+ See {Vedeu::Bindings::Visibility}
@@ -32,10 +32,6 @@ module Vedeu
32
32
  # @return [void]
33
33
  attr_reader :args
34
34
 
35
- # # @!attribute [r] template
36
- # # @return [void]
37
- # attr_reader :template
38
-
39
35
  private
40
36
 
41
37
  # Provides the path to the template file using the base_path configuration
@@ -2,4 +2,25 @@ require_relative 'visibility'
2
2
  require_relative 'movement'
3
3
  require_relative 'menus'
4
4
  require_relative 'drb'
5
- require_relative 'bindings'
5
+ require_relative 'system'
6
+
7
+ module Vedeu
8
+
9
+ module Bindings
10
+
11
+ # Setup events for running Vedeu. This method is called by Vedeu.
12
+ #
13
+ # @return [void]
14
+ def self.setup!
15
+ Vedeu::Bindings::Visibility.setup!
16
+ Vedeu::Bindings::Movement.setup!
17
+ Vedeu::Bindings::Menus.setup!
18
+ Vedeu::Bindings::DRB.setup!
19
+ Vedeu::Bindings::System.setup!
20
+ end
21
+
22
+ end # Bindings
23
+
24
+ end # Vedeu
25
+
26
+ Vedeu::Bindings.setup!
@@ -5,30 +5,106 @@ module Vedeu
5
5
  # System events relating to the DRb server implementation.
6
6
  #
7
7
  # @api public
8
- # {include:file:docs/events/drb.md}
9
8
  # :nocov:
10
9
  module DRB
11
10
 
12
- Vedeu.bind(:_drb_input_) do |data, type|
13
- Vedeu.log(type: :drb, message: "Sending input (#{type})")
11
+ extend self
14
12
 
15
- case type
16
- when :command then Vedeu.trigger(:_command_, data)
17
- else Vedeu.trigger(:_keypress_, data)
13
+ # Setup events relating to the DRb server. This method is called by Vedeu.
14
+ #
15
+ # @return [void]
16
+ def setup!
17
+ drb_input!
18
+ drb_retrieve_output!
19
+ drb_store_output!
20
+ drb_restart!
21
+ drb_start!
22
+ drb_status!
23
+ drb_stop!
24
+ end
25
+
26
+ private
27
+
28
+ # Triggering this event will send input to the running application as long
29
+ # as it has the DRb server running.
30
+ #
31
+ # @example
32
+ # Vedeu.trigger(:_drb_input_, data, type)
33
+ #
34
+ # @return [void]
35
+ def drb_input!
36
+ Vedeu.bind(:_drb_input_) do |data, type|
37
+ Vedeu.log(type: :drb, message: "Sending input (#{type})")
38
+
39
+ case type
40
+ when :command then Vedeu.trigger(:_command_, data)
41
+ else Vedeu.trigger(:_keypress_, data)
42
+ end
18
43
  end
19
44
  end
20
45
 
46
+ # @example
47
+ # Vedeu.trigger(:_drb_retrieve_output_)
48
+ #
21
49
  # @todo This event queries Vedeu. Events should only be commands.
22
- Vedeu.bind(:_drb_retrieve_output_) { Vedeu::VirtualBuffer.retrieve }
50
+ #
51
+ # @return [void]
52
+ def drb_retrieve_output!
53
+ Vedeu.bind(:_drb_retrieve_output_) { Vedeu::VirtualBuffer.retrieve }
54
+ end
23
55
 
24
- Vedeu.bind(:_drb_store_output_) do |data|
25
- Vedeu::VirtualBuffer.store(Vedeu::Terminal.virtual.output(data))
56
+ # Triggering this event with 'data' will push data into the running
57
+ # application's virtual buffer.
58
+ #
59
+ # @example
60
+ # Vedeu.trigger(:_drb_store_output_, data)
61
+ #
62
+ # @return [void]
63
+ def drb_store_output!
64
+ Vedeu.bind(:_drb_store_output_) do |data|
65
+ Vedeu::VirtualBuffer.store(Vedeu::Terminal.virtual.output(data))
66
+ end
26
67
  end
27
68
 
28
- Vedeu.bind(:_drb_restart_) { Vedeu::Distributed::Server.restart }
29
- Vedeu.bind(:_drb_start_) { Vedeu::Distributed::Server.start }
30
- Vedeu.bind(:_drb_status_) { Vedeu::Distributed::Server.status }
31
- Vedeu.bind(:_drb_stop_) { Vedeu::Distributed::Server.stop }
69
+ # Use the DRb server to request the client application to restart.
70
+ #
71
+ # @example
72
+ # Vedeu.trigger(:_drb_restart_)
73
+ #
74
+ # @return [void]
75
+ def drb_restart!
76
+ Vedeu.bind(:_drb_restart_) { Vedeu::Distributed::Server.restart }
77
+ end
78
+
79
+ # Use the DRb server to request the client application to start.
80
+ #
81
+ # @example
82
+ # Vedeu.trigger(:_drb_start_)
83
+ #
84
+ # @return [void]
85
+ def drb_start!
86
+ Vedeu.bind(:_drb_start_) { Vedeu::Distributed::Server.start }
87
+ end
88
+
89
+ # Use the DRb server to request the status of the client application.
90
+ #
91
+ # @example
92
+ # Vedeu.trigger(:_drb_status_)
93
+ #
94
+ # @return [void]
95
+ def drb_status!
96
+ Vedeu.bind(:_drb_status_) { Vedeu::Distributed::Server.status }
97
+ end
98
+
99
+ # Use the DRb server to request the client application to stop.
100
+ #
101
+ # @example
102
+ # Vedeu.trigger(:_drb_stop_)
103
+ #
104
+ # @return [void]
105
+ def drb_stop!
106
+ Vedeu.bind(:_drb_stop_) { Vedeu::Distributed::Server.stop }
107
+ end
32
108
 
33
109
  end # DRB
34
110
  # :nocov:
@@ -6,28 +6,138 @@ module Vedeu
6
6
  # argument.
7
7
  #
8
8
  # @api public
9
- # {include:file:docs/events/menus.md}
10
9
  # :nocov:
11
10
  module Menus
12
11
 
13
- Vedeu.bind(:_menu_bottom_) { |name| Vedeu.menus.find(name).bottom_item }
14
- Vedeu.bind(:_menu_current_) { |name| Vedeu.menus.find(name).current_item }
12
+ extend self
15
13
 
16
- Vedeu.bind(:_menu_deselect_) do |name|
17
- Vedeu.menus.find(name).deselect_item
14
+ # Setup events relating to menus. This method is called by Vedeu.
15
+ #
16
+ # @return [void]
17
+ def setup!
18
+ menu_bottom!
19
+ menu_current!
20
+ menu_deselect!
21
+ menu_items!
22
+ menu_next!
23
+ menu_prev!
24
+ menu_selected!
25
+ menu_select!
26
+ menu_top!
27
+ menu_view!
18
28
  end
19
29
 
20
- Vedeu.bind(:_menu_items_) { |name| Vedeu.menus.find(name).items }
21
- Vedeu.bind(:_menu_next_) { |name| Vedeu.menus.find(name).next_item }
22
- Vedeu.bind(:_menu_prev_) { |name| Vedeu.menus.find(name).prev_item }
30
+ private
23
31
 
24
- Vedeu.bind(:_menu_selected_) do |name|
25
- Vedeu.menus.find(name).selected_item
32
+ # Makes the last menu item the current menu item.
33
+ #
34
+ # @example
35
+ # Vedeu.trigger(:_menu_bottom_, name)
36
+ #
37
+ # @return [void]
38
+ def menu_bottom!
39
+ Vedeu.bind(:_menu_bottom_) { |name| Vedeu.menus.find(name).bottom_item }
26
40
  end
27
41
 
28
- Vedeu.bind(:_menu_select_) { |name| Vedeu.menus.find(name).select_item }
29
- Vedeu.bind(:_menu_top_) { |name| Vedeu.menus.find(name).top_item }
30
- Vedeu.bind(:_menu_view_) { |name| Vedeu.menus.find(name).view }
42
+ # Returns the current menu item.
43
+ #
44
+ # @example
45
+ # Vedeu.trigger(:_menu_current_, name)
46
+ #
47
+ # @return [void]
48
+ def menu_current!
49
+ Vedeu.bind(:_menu_current_) do |name|
50
+ Vedeu.menus.find(name).current_item
51
+ end
52
+ end
53
+
54
+ # Deselects all menu items.
55
+ #
56
+ # @example
57
+ # Vedeu.trigger(:_menu_deselect_, name)
58
+ #
59
+ # @return [void]
60
+ def menu_deselect!
61
+ Vedeu.bind(:_menu_deselect_) do |name|
62
+ Vedeu.menus.find(name).deselect_item
63
+ end
64
+ end
65
+
66
+ # Returns all the menu items with respective `current` or `selected`
67
+ # boolean indicators.
68
+ #
69
+ # @example
70
+ # Vedeu.trigger(:_menu_items_, name)
71
+ #
72
+ # @return [void]
73
+ def menu_items!
74
+ Vedeu.bind(:_menu_items_) { |name| Vedeu.menus.find(name).items }
75
+ end
76
+
77
+ # Makes the next menu item the current menu item, until it reaches the
78
+ # last item.
79
+ #
80
+ # @example
81
+ # Vedeu.trigger(:_menu_next_, name)
82
+ #
83
+ # @return [void]
84
+ def menu_next!
85
+ Vedeu.bind(:_menu_next_) { |name| Vedeu.menus.find(name).next_item }
86
+ end
87
+
88
+ # Makes the previous menu item the current menu item, until it reaches the
89
+ # first item.
90
+ #
91
+ # @example
92
+ # Vedeu.trigger(:_menu_prev_, name)
93
+ #
94
+ # @return [void]
95
+ def menu_prev!
96
+ Vedeu.bind(:_menu_prev_) { |name| Vedeu.menus.find(name).prev_item }
97
+ end
98
+
99
+ # Returns the selected menu item.
100
+ #
101
+ # @example
102
+ # Vedeu.trigger(:_menu_selected_, name)
103
+ #
104
+ # @return [void]
105
+ def menu_selected!
106
+ Vedeu.bind(:_menu_selected_) do |name|
107
+ Vedeu.menus.find(name).selected_item
108
+ end
109
+ end
110
+
111
+ # Makes the current menu item also the selected menu item.
112
+ #
113
+ # @example
114
+ # Vedeu.trigger(:_menu_select_, name)
115
+ #
116
+ # @return [void]
117
+ def menu_select!
118
+ Vedeu.bind(:_menu_select_) { |name| Vedeu.menus.find(name).select_item }
119
+ end
120
+
121
+ # Makes the first menu item the current menu item.
122
+ #
123
+ # @example
124
+ # Vedeu.trigger(:_menu_top_, name)
125
+ #
126
+ # @return [void]
127
+ def menu_top!
128
+ Vedeu.bind(:_menu_top_) { |name| Vedeu.menus.find(name).top_item }
129
+ end
130
+
131
+ # Returns a subset of the menu items; starting at the current item to the
132
+ # last item.
133
+ #
134
+ # @example
135
+ # Vedeu.trigger(:_menu_view_, name)
136
+ #
137
+ # @return [void]
138
+ def menu_view!
139
+ Vedeu.bind(:_menu_view_) { |name| Vedeu.menus.find(name).view }
140
+ end
31
141
 
32
142
  end # Menus
33
143
  # :nocov:
@@ -5,57 +5,178 @@ module Vedeu
5
5
  # System events relating to movement of cursors or interfaces.
6
6
  #
7
7
  # @api public
8
- # {include:file:docs/events/movement.md}
9
8
  # :nocov:
10
9
  module Movement
11
10
 
12
- Vedeu.bind(:_cursor_down_) do |name|
13
- Vedeu::Move.by_name(Vedeu::Cursor, :down, name)
11
+ extend self
12
+
13
+ # Setup events relating to movement. This method is called by Vedeu.
14
+ #
15
+ # @return [void]
16
+ def setup!
17
+ cursor_down!
18
+ cursor_left!
19
+ cursor_origin!
20
+ cursor_position!
21
+ cursor_reposition!
22
+ cursor_right!
23
+ cursor_up!
24
+ geometry_down!
25
+ geometry_left!
26
+ geometry_right!
27
+ geometry_up!
14
28
  end
15
29
 
16
- Vedeu.bind(:_cursor_left_) do |name|
17
- Vedeu::Move.by_name(Vedeu::Cursor, :left, name)
30
+ private
31
+
32
+ # Move the cursor down by one character.
33
+ #
34
+ # @example
35
+ # Vedeu.trigger(:_cursor_down_, name)
36
+ #
37
+ # @return [void]
38
+ # @see Vedeu::Move
39
+ def cursor_down!
40
+ Vedeu.bind(:_cursor_down_) do |name|
41
+ Vedeu::Move.by_name(Vedeu::Cursor, :down, name)
42
+ end
18
43
  end
19
44
 
20
- Vedeu.bind(:_cursor_origin_) do |name|
21
- Vedeu::Move.by_name(Vedeu::Cursor, :origin, name)
45
+ # Move the cursor left by one character.
46
+ #
47
+ # @example
48
+ # Vedeu.trigger(:_cursor_left_, name)
49
+ #
50
+ # @return [void]
51
+ # @see Vedeu::Move
52
+ def cursor_left!
53
+ Vedeu.bind(:_cursor_left_) do |name|
54
+ Vedeu::Move.by_name(Vedeu::Cursor, :left, name)
55
+ end
22
56
  end
23
57
 
24
- # @todo This event queries Vedeu. Events should only be commands.
25
- Vedeu.bind(:_cursor_position_) do |name|
26
- Vedeu.cursors.by_name(name).position
58
+ # This event moves the cursor to the interface origin; the top left corner
59
+ # of the named interface.
60
+ #
61
+ # @example
62
+ # Vedeu.trigger(:_cursor_origin_, name)
63
+ # Vedeu.trigger(:_cursor_reset_, name)
64
+ #
65
+ # @return [void]
66
+ # @see Vedeu::Move
67
+ def cursor_origin!
68
+ Vedeu.bind(:_cursor_origin_) do |name|
69
+ Vedeu::Move.by_name(Vedeu::Cursor, :origin, name)
70
+ end
71
+ Vedeu.bind(:_cursor_reset_) do |name|
72
+ Vedeu.trigger(:_cursor_origin_, name)
73
+ end
27
74
  end
28
75
 
29
- Vedeu.bind(:_cursor_reposition_) do |name, y, x|
30
- Vedeu::Reposition.to(Vedeu::Cursor, name, y, x)
76
+ # When triggered will return the current position of the cursor.
77
+ #
78
+ # @example
79
+ # Vedeu.trigger(:_cursor_position_, name)
80
+ #
81
+ # @todo This event queries Vedeu. Events should only be commands.
82
+ #
83
+ # @return [void]
84
+ # @see Vedeu::Move
85
+ def cursor_position!
86
+ Vedeu.bind(:_cursor_position_) do |name|
87
+ Vedeu.cursors.by_name(name).position
88
+ end
31
89
  end
32
90
 
33
- Vedeu.bind(:_cursor_reset_) do |name|
34
- Vedeu.trigger(:_cursor_origin_, name)
91
+ # Moves the cursor to a relative position inside the interface.
92
+ #
93
+ # @example
94
+ # Vedeu.trigger(:_cursor_reposition_, name, y, x)
95
+ #
96
+ # @return [void]
97
+ # @see Vedeu::Move
98
+ def cursor_reposition!
99
+ Vedeu.bind(:_cursor_reposition_) do |name, y, x|
100
+ Vedeu::Reposition.to(Vedeu::Cursor, name, y, x)
101
+ end
35
102
  end
36
103
 
37
- Vedeu.bind(:_cursor_right_) do |name|
38
- Vedeu::Move.by_name(Vedeu::Cursor, :right, name)
104
+ # Move the cursor right by one character.
105
+ #
106
+ # @example
107
+ # Vedeu.trigger(:_cursor_right_, name)
108
+ #
109
+ # @return [void]
110
+ # @see Vedeu::Move
111
+ def cursor_right!
112
+ Vedeu.bind(:_cursor_right_) do |name|
113
+ Vedeu::Move.by_name(Vedeu::Cursor, :right, name)
114
+ end
39
115
  end
40
116
 
41
- Vedeu.bind(:_cursor_up_) do |name|
42
- Vedeu::Move.by_name(Vedeu::Cursor, :up, name)
117
+ # Move the cursor up by one character.
118
+ #
119
+ # @example
120
+ # Vedeu.trigger(:_cursor_up, name)
121
+ #
122
+ # @return [void]
123
+ # @see Vedeu::Move
124
+ def cursor_up!
125
+ Vedeu.bind(:_cursor_up_) do |name|
126
+ Vedeu::Move.by_name(Vedeu::Cursor, :up, name)
127
+ end
43
128
  end
44
129
 
45
- Vedeu.bind(:_geometry_down_) do |name|
46
- Vedeu::Move.by_name(Vedeu::Geometry, :down, name)
130
+ # Move the geometry down by one character.
131
+ #
132
+ # @example
133
+ # Vedeu.trigger(:_geometry_down_, name)
134
+ #
135
+ # @return [void]
136
+ # @see Vedeu::Move
137
+ def geometry_down!
138
+ Vedeu.bind(:_geometry_down_) do |name|
139
+ Vedeu::Move.by_name(Vedeu::Geometry, :down, name)
140
+ end
47
141
  end
48
142
 
49
- Vedeu.bind(:_geometry_left_) do |name|
50
- Vedeu::Move.by_name(Vedeu::Geometry, :left, name)
143
+ # Move the geometry left by one character.
144
+ #
145
+ # @example
146
+ # Vedeu.trigger(:_geometry_left_, name)
147
+ #
148
+ # @return [void]
149
+ # @see Vedeu::Move
150
+ def geometry_left!
151
+ Vedeu.bind(:_geometry_left_) do |name|
152
+ Vedeu::Move.by_name(Vedeu::Geometry, :left, name)
153
+ end
51
154
  end
52
155
 
53
- Vedeu.bind(:_geometry_right_) do |name|
54
- Vedeu::Move.by_name(Vedeu::Geometry, :right, name)
156
+ # Move the geometry right by one character.
157
+ #
158
+ # @example
159
+ # Vedeu.trigger(:_geometry_right_, name)
160
+ #
161
+ # @return [void]
162
+ # @see Vedeu::Move
163
+ def geometry_right!
164
+ Vedeu.bind(:_geometry_right_) do |name|
165
+ Vedeu::Move.by_name(Vedeu::Geometry, :right, name)
166
+ end
55
167
  end
56
168
 
57
- Vedeu.bind(:_geometry_up_) do |name|
58
- Vedeu::Move.by_name(Vedeu::Geometry, :up, name)
169
+ # Move the geometry up by one character.
170
+ #
171
+ # @example
172
+ # Vedeu.trigger(:_geometry_up_, name)
173
+ #
174
+ # @return [void]
175
+ # @see Vedeu::Move
176
+ def geometry_up!
177
+ Vedeu.bind(:_geometry_up_) do |name|
178
+ Vedeu::Move.by_name(Vedeu::Geometry, :up, name)
179
+ end
59
180
  end
60
181
 
61
182
  end # Movement