vedeu 0.4.52 → 0.4.53
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.
- checksums.yaml +4 -4
- data/docs/events.md +15 -5
- data/lib/vedeu/application/application_view.rb +0 -4
- data/lib/vedeu/bindings/all.rb +22 -1
- data/lib/vedeu/bindings/drb.rb +89 -13
- data/lib/vedeu/bindings/menus.rb +123 -13
- data/lib/vedeu/bindings/movement.rb +147 -26
- data/lib/vedeu/bindings/system.rb +284 -0
- data/lib/vedeu/bindings/visibility.rb +117 -13
- data/lib/vedeu/dsl/all.rb +2 -1
- data/lib/vedeu/output/compressor.rb +2 -0
- data/lib/vedeu/output/refresh.rb +20 -5
- data/lib/vedeu/output/refresh_group.rb +6 -1
- data/lib/vedeu/output/render_border.rb +1 -1
- data/lib/vedeu/output/renderers/all.rb +1 -0
- data/lib/vedeu/output/renderers/escape_sequence.rb +2 -16
- data/lib/vedeu/output/renderers/null.rb +2 -16
- data/lib/vedeu/output/renderers/renderer_options.rb +26 -0
- data/lib/vedeu/output/renderers/terminal.rb +2 -14
- data/lib/vedeu/output/renderers/text.rb +2 -16
- data/lib/vedeu/repositories/all.rb +23 -1
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/bindings/system_test.rb +44 -0
- data/test/lib/vedeu/output/refresh_group_test.rb +10 -2
- data/test/lib/vedeu/output/refresh_test.rb +6 -23
- data/test/lib/vedeu/output/renderers/renderer_options_test.rb +12 -0
- data/test/lib/vedeu/templating/preprocessor_test.rb +11 -10
- metadata +8 -10
- data/docs/events/drb.md +0 -49
- data/docs/events/main.md +0 -109
- data/docs/events/menus.md +0 -72
- data/docs/events/movement.md +0 -105
- data/docs/events/visibility.md +0 -61
- data/lib/vedeu/bindings/bindings.rb +0 -86
- data/test/lib/vedeu/bindings/bindings_test.rb +0 -40
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
module Vedeu
|
|
2
|
+
|
|
3
|
+
module Bindings
|
|
4
|
+
|
|
5
|
+
# Creates system events which when called provide a variety of core
|
|
6
|
+
# functions and behaviours. They are soft-namespaced using underscores.
|
|
7
|
+
#
|
|
8
|
+
# @note
|
|
9
|
+
# Unbinding any of these events is likely to cause problems, so I would
|
|
10
|
+
# advise leaving them alone. A safe rule: if the name starts with an
|
|
11
|
+
# underscore, it's probably used by Vedeu internally.
|
|
12
|
+
#
|
|
13
|
+
# @api public
|
|
14
|
+
# :nocov:
|
|
15
|
+
module System
|
|
16
|
+
|
|
17
|
+
extend self
|
|
18
|
+
|
|
19
|
+
# Setup events relating to running Vedeu. This method is called by Vedeu.
|
|
20
|
+
#
|
|
21
|
+
# @return [void]
|
|
22
|
+
def setup!
|
|
23
|
+
cleanup!
|
|
24
|
+
clear!
|
|
25
|
+
clear_group!
|
|
26
|
+
command!
|
|
27
|
+
exit!
|
|
28
|
+
focus_next!
|
|
29
|
+
focus_prev!
|
|
30
|
+
focus_by_name!
|
|
31
|
+
initialize!
|
|
32
|
+
keypress!
|
|
33
|
+
log!
|
|
34
|
+
maximise!
|
|
35
|
+
mode_switch!
|
|
36
|
+
refresh!
|
|
37
|
+
refresh_cursor!
|
|
38
|
+
refresh_group!
|
|
39
|
+
resize!
|
|
40
|
+
unmaximise!
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
private
|
|
44
|
+
|
|
45
|
+
# Vedeu triggers this event when `:_exit_` is triggered. You can hook
|
|
46
|
+
# into this to perform a special action before the application
|
|
47
|
+
# terminates. Saving the user's work, session or preferences might be
|
|
48
|
+
# popular here.
|
|
49
|
+
#
|
|
50
|
+
# @example
|
|
51
|
+
# Vedeu.trigger(:_exit_)
|
|
52
|
+
#
|
|
53
|
+
# @return [void]
|
|
54
|
+
def cleanup!
|
|
55
|
+
Vedeu.bind(:_cleanup_) do
|
|
56
|
+
Vedeu.trigger(:_drb_stop_)
|
|
57
|
+
Vedeu.trigger(:cleanup)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Clears the whole terminal space, or the named interface area to be
|
|
62
|
+
# cleared if given.
|
|
63
|
+
#
|
|
64
|
+
# @example
|
|
65
|
+
# Vedeu.trigger(:_clear_)
|
|
66
|
+
# Vedeu.clear_by_name(name)
|
|
67
|
+
#
|
|
68
|
+
# @return [void]
|
|
69
|
+
def clear!
|
|
70
|
+
Vedeu.bind(:_clear_) do |name|
|
|
71
|
+
if name
|
|
72
|
+
Vedeu::Clear::NamedInterface.render(name)
|
|
73
|
+
|
|
74
|
+
else
|
|
75
|
+
Vedeu::Terminal.clear
|
|
76
|
+
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Clears the spaces occupied by the interfaces belonging to the named
|
|
82
|
+
# group.
|
|
83
|
+
#
|
|
84
|
+
# @example
|
|
85
|
+
# Vedeu.trigger(:_clear_group_, name)
|
|
86
|
+
# Vedeu.clear_by_group(name)
|
|
87
|
+
#
|
|
88
|
+
# @return [void]
|
|
89
|
+
def clear_group!
|
|
90
|
+
Vedeu.bind(:_clear_group_) do |name|
|
|
91
|
+
Vedeu::Clear::NamedGroup.render(name)
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Will cause the triggering of the `:command` event; which you should
|
|
96
|
+
# define to 'do things'
|
|
97
|
+
#
|
|
98
|
+
# @example
|
|
99
|
+
# Vedeu.trigger(:_command_, command)
|
|
100
|
+
#
|
|
101
|
+
# @return [void]
|
|
102
|
+
def command!
|
|
103
|
+
Vedeu.bind(:_command_) { |command| Vedeu.trigger(:command, command) }
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# When triggered, Vedeu will trigger a `:cleanup` event which you can
|
|
107
|
+
# define (to save files, etc) and attempt to exit.
|
|
108
|
+
#
|
|
109
|
+
# @example
|
|
110
|
+
# Vedeu.trigger(:_exit_)
|
|
111
|
+
# Vedeu.exit
|
|
112
|
+
#
|
|
113
|
+
# @return [void]
|
|
114
|
+
def exit!
|
|
115
|
+
Vedeu.bind(:_exit_) { Vedeu::Application.stop }
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# When triggered with an interface name will focus that interface and
|
|
119
|
+
# restore the cursor position and visibility.
|
|
120
|
+
#
|
|
121
|
+
# @example
|
|
122
|
+
# Vedeu.trigger(:_focus_by_name_, name)
|
|
123
|
+
#
|
|
124
|
+
# @return [void]
|
|
125
|
+
def focus_by_name!
|
|
126
|
+
Vedeu.bind(:_focus_by_name_) { |name| Vedeu.focus_by_name(name) }
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# When triggered will focus the next interface and restore the cursor
|
|
130
|
+
# position and visibility.
|
|
131
|
+
#
|
|
132
|
+
# @example
|
|
133
|
+
# Vedeu.trigger(:_focus_next_)
|
|
134
|
+
#
|
|
135
|
+
# @return [void]
|
|
136
|
+
def focus_next!
|
|
137
|
+
Vedeu.bind(:_focus_next_) { Vedeu.focus_next }
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# When triggered will focus the previous interface and restore the cursor
|
|
141
|
+
# position and visibility.
|
|
142
|
+
#
|
|
143
|
+
# @example
|
|
144
|
+
# Vedeu.trigger(:_focus_prev_)
|
|
145
|
+
#
|
|
146
|
+
# @return [void]
|
|
147
|
+
def focus_prev!
|
|
148
|
+
Vedeu.bind(:_focus_prev_) { Vedeu.focus_previous }
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# Vedeu triggers this event when it is ready to enter the main loop.
|
|
152
|
+
# Client applications can listen for this event and perform some
|
|
153
|
+
# action(s), like render the first screen, interface or make a sound.
|
|
154
|
+
# When Vedeu triggers this event, the :_refresh_ event is also triggered
|
|
155
|
+
# automatically.
|
|
156
|
+
#
|
|
157
|
+
# @return [void]
|
|
158
|
+
def initialize!
|
|
159
|
+
Vedeu.bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Will cause the triggering of the `:key` event; which you should define
|
|
163
|
+
# to 'do things'. If the `escape` key is pressed, then `key` is triggered
|
|
164
|
+
# with the argument `:escape`, also an internal event `_mode_switch_` is
|
|
165
|
+
# triggered. Vedeu recognises most key presses and some 'extended'
|
|
166
|
+
# keypress (eg. Ctrl+J), a list of supported keypresses can be found here:
|
|
167
|
+
# {Vedeu::Input#specials} and {Vedeu::Input#f_keys}.
|
|
168
|
+
#
|
|
169
|
+
# @example
|
|
170
|
+
# Vedeu.trigger(:_keypress_, key)
|
|
171
|
+
#
|
|
172
|
+
# @return [void]
|
|
173
|
+
def keypress!
|
|
174
|
+
Vedeu.bind(:_keypress_) { |key| Vedeu.keypress(key) }
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
# When triggered with a message will cause Vedeu to log the message if
|
|
178
|
+
# logging is enabled in the configuration.
|
|
179
|
+
#
|
|
180
|
+
# @example
|
|
181
|
+
# Vedeu.trigger(:_log_, message)
|
|
182
|
+
#
|
|
183
|
+
# @return [void]
|
|
184
|
+
def log!
|
|
185
|
+
Vedeu.bind(:_log_) { |msg| Vedeu.log(type: :debug, message: msg) }
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
# Maximising an interface.
|
|
189
|
+
#
|
|
190
|
+
# @example
|
|
191
|
+
# Vedeu.trigger(:_maximise_, name)
|
|
192
|
+
#
|
|
193
|
+
# @return [void]
|
|
194
|
+
# @see Vedeu::Geometry#maximise
|
|
195
|
+
def maximise!
|
|
196
|
+
Vedeu.bind(:_maximise_) do |name|
|
|
197
|
+
Vedeu.geometries.by_name(name).maximise
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
# When triggered (after the user presses `escape`), Vedeu switches from a
|
|
202
|
+
# "raw mode" terminal to a "cooked mode" terminal. The idea here being
|
|
203
|
+
# that the raw mode is for single keypress actions, whilst cooked mode
|
|
204
|
+
# allows the user to enter more elaborate commands- such as commands with
|
|
205
|
+
# arguments.
|
|
206
|
+
#
|
|
207
|
+
# @example
|
|
208
|
+
# Vedeu.trigger(:_mode_switch_)
|
|
209
|
+
#
|
|
210
|
+
# @return [void]
|
|
211
|
+
def mode_switch!
|
|
212
|
+
Vedeu.bind(:_mode_switch_) { fail ModeSwitch }
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
# Will cause the named interface to refresh, or if a name is not given,
|
|
216
|
+
# will refresh all interfaces.
|
|
217
|
+
#
|
|
218
|
+
# @note: Hidden interfaces will be still refreshed in memory but not
|
|
219
|
+
# shown.
|
|
220
|
+
#
|
|
221
|
+
# @example
|
|
222
|
+
# Vedeu.trigger(:_refresh_)
|
|
223
|
+
# Vedeu.trigger(:_refresh_, name)
|
|
224
|
+
#
|
|
225
|
+
# @return [void]
|
|
226
|
+
def refresh!
|
|
227
|
+
Vedeu.bind(:_refresh_) do |name|
|
|
228
|
+
name ? Vedeu::Refresh.by_name(name) : Vedeu::Refresh.all
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
# Will cause the named cursor to refresh, or the cursor of the interface
|
|
233
|
+
# which is currently in focus.
|
|
234
|
+
#
|
|
235
|
+
# @example
|
|
236
|
+
# Vedeu.trigger(:_refresh_cursor_, name)
|
|
237
|
+
#
|
|
238
|
+
# @return [void]
|
|
239
|
+
def refresh_cursor!
|
|
240
|
+
Vedeu.bind(:_refresh_cursor_) do |name|
|
|
241
|
+
Vedeu::RefreshCursor.render(name)
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
# Will cause all interfaces in the named group to refresh.
|
|
246
|
+
#
|
|
247
|
+
# @example
|
|
248
|
+
# Vedeu.trigger(:_refresh_group_, name)
|
|
249
|
+
#
|
|
250
|
+
# @return [void]
|
|
251
|
+
def refresh_group!
|
|
252
|
+
Vedeu.bind(:_refresh_group_) { |name| Vedeu::Refresh.by_group(name) }
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
# When triggered will cause Vedeu to trigger the `:_clear_` and
|
|
256
|
+
# `:_refresh_` events. Please see those events for their behaviour.
|
|
257
|
+
#
|
|
258
|
+
# @example
|
|
259
|
+
# Vedeu.trigger(:_resize_)
|
|
260
|
+
#
|
|
261
|
+
# @return [void]
|
|
262
|
+
def resize!
|
|
263
|
+
Vedeu.bind(:_resize_, delay: 0.15) { Vedeu.resize }
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
# Unmaximising an interface.
|
|
267
|
+
#
|
|
268
|
+
# @example
|
|
269
|
+
# Vedeu.trigger(:_unmaximise_, name)
|
|
270
|
+
#
|
|
271
|
+
# @return [void]
|
|
272
|
+
# @see Vedeu::Geometry#unmaximise
|
|
273
|
+
def unmaximise!
|
|
274
|
+
Vedeu.bind(:_unmaximise_) do |name|
|
|
275
|
+
Vedeu.geometries.by_name(name).unmaximise
|
|
276
|
+
end
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
end # System
|
|
280
|
+
|
|
281
|
+
end # Bindings
|
|
282
|
+
# :nocov:
|
|
283
|
+
|
|
284
|
+
end # Vedeu
|
|
@@ -5,25 +5,129 @@ module Vedeu
|
|
|
5
5
|
# System events relating to the visibility of cursors or interfaces.
|
|
6
6
|
#
|
|
7
7
|
# @api public
|
|
8
|
-
# {include:file:docs/events/visibility.md}
|
|
9
8
|
# :nocov:
|
|
10
9
|
module Visibility
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
Vedeu.bind(:_cursor_hide_) { |name| Vedeu.trigger(:_hide_cursor_, name) }
|
|
14
|
-
Vedeu.bind(:_show_cursor_) { |name| Vedeu::Visibility.show_cursor(name) }
|
|
15
|
-
Vedeu.bind(:_cursor_show_) { |name| Vedeu.trigger(:_show_cursor_, name) }
|
|
11
|
+
extend self
|
|
16
12
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
# Setup events relating to visibility. This method is called by Vedeu.
|
|
14
|
+
#
|
|
15
|
+
# @return [void]
|
|
16
|
+
def setup!
|
|
17
|
+
hide_cursor!
|
|
18
|
+
hide_group!
|
|
19
|
+
hide_interface!
|
|
20
|
+
show_cursor!
|
|
21
|
+
show_group!
|
|
22
|
+
show_interface!
|
|
23
|
+
toggle_interface!
|
|
21
24
|
end
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
# Hide the cursor of the named interface or if a name is not given, the
|
|
29
|
+
# interface currently in focus.
|
|
30
|
+
#
|
|
31
|
+
# @example
|
|
32
|
+
# Vedeu.trigger(:_hide_cursor_, name)
|
|
33
|
+
# Vedeu.trigger(:_cursor_hide_, name)
|
|
34
|
+
# Vedeu.hide_cursor(name)
|
|
35
|
+
#
|
|
36
|
+
# @return [void]
|
|
37
|
+
def hide_cursor!
|
|
38
|
+
Vedeu.bind(:_hide_cursor_) do |name|
|
|
39
|
+
Vedeu::Visibility.hide_cursor(name)
|
|
40
|
+
end
|
|
41
|
+
Vedeu.bind(:_cursor_hide_) do |name|
|
|
42
|
+
Vedeu.trigger(:_hide_cursor_, name)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Will hide all of the interfaces belonging to the named group. Useful for
|
|
47
|
+
# hiding part of that which is currently displaying in the terminal.
|
|
48
|
+
|
|
49
|
+
# This may be rarely used, since the action of showing a group will
|
|
50
|
+
# effectively clear the terminal and show the new group.
|
|
51
|
+
#
|
|
52
|
+
# @example
|
|
53
|
+
# Vedeu.trigger(:_hide_group_, group_name)
|
|
54
|
+
#
|
|
55
|
+
# @return [void]
|
|
56
|
+
def hide_group!
|
|
57
|
+
Vedeu.bind(:_hide_group_) do |name|
|
|
58
|
+
Vedeu.trigger(:_clear_group_, name)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Hiding an interface.
|
|
63
|
+
#
|
|
64
|
+
# @example
|
|
65
|
+
# Vedeu.trigger(:_hide_interface_, name)
|
|
66
|
+
#
|
|
67
|
+
# @return [void]
|
|
68
|
+
# @see Vedeu::Buffer#hide
|
|
69
|
+
def hide_interface!
|
|
70
|
+
Vedeu.bind(:_hide_interface_) do |name|
|
|
71
|
+
Vedeu.buffers.by_name(name).hide
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Show the cursor of the named interface or if a name is not given, the
|
|
76
|
+
# interface currently in focus.
|
|
77
|
+
#
|
|
78
|
+
# @example
|
|
79
|
+
# Vedeu.trigger(:_show_cursor_, name)
|
|
80
|
+
# Vedeu.trigger(:_cursor_show_, name)
|
|
81
|
+
# Vedeu.show_cursor(name)
|
|
82
|
+
#
|
|
83
|
+
# @return [void]
|
|
84
|
+
def show_cursor!
|
|
85
|
+
Vedeu.bind(:_show_cursor_) do |name|
|
|
86
|
+
Vedeu::Visibility.show_cursor(name)
|
|
87
|
+
end
|
|
88
|
+
Vedeu.bind(:_cursor_show_) do |name|
|
|
89
|
+
Vedeu.trigger(:_show_cursor_, name)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Will clear the terminal and then show all of the interfaces belonging to
|
|
94
|
+
# the named group.
|
|
95
|
+
#
|
|
96
|
+
# @example
|
|
97
|
+
# Vedeu.trigger(:_show_group_, group_name)
|
|
98
|
+
#
|
|
99
|
+
# @return [void]
|
|
100
|
+
def show_group!
|
|
101
|
+
Vedeu.bind(:_show_group_) do |name|
|
|
102
|
+
Vedeu.trigger(:_clear_)
|
|
103
|
+
Vedeu.trigger(:_refresh_group_, name)
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Showing an interface.
|
|
108
|
+
#
|
|
109
|
+
# @example
|
|
110
|
+
# Vedeu.trigger(:_show_interface_, name)
|
|
111
|
+
#
|
|
112
|
+
# @return [void]
|
|
113
|
+
# @see Vedeu::Buffer#show
|
|
114
|
+
def show_interface!
|
|
115
|
+
Vedeu.bind(:_show_interface_) do |name|
|
|
116
|
+
Vedeu.buffers.by_name(name).show
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# Toggling an interface.
|
|
121
|
+
#
|
|
122
|
+
# @example
|
|
123
|
+
# Vedeu.trigger(:_toggle_interface_, name)
|
|
124
|
+
#
|
|
125
|
+
# @return [void]
|
|
126
|
+
# @see Vedeu::Buffer#toggle
|
|
127
|
+
def toggle_interface!
|
|
128
|
+
Vedeu.bind(:_toggle_interface_) do |name|
|
|
129
|
+
Vedeu.buffers.by_name(name).toggle
|
|
130
|
+
end
|
|
27
131
|
end
|
|
28
132
|
|
|
29
133
|
end # Visibility
|
data/lib/vedeu/dsl/all.rb
CHANGED
|
@@ -31,7 +31,8 @@ module Vedeu
|
|
|
31
31
|
# @param block [Proc] The optional block provided to the method.
|
|
32
32
|
# @return [void]
|
|
33
33
|
def method_missing(method, *args, &block)
|
|
34
|
-
Vedeu.log(type:
|
|
34
|
+
Vedeu.log(type: :debug,
|
|
35
|
+
message: "!!!method_missing '#{method}' (#{client.inspect})")
|
|
35
36
|
|
|
36
37
|
client.send(method, *args, &block) if client
|
|
37
38
|
end
|
|
@@ -43,6 +43,7 @@ module Vedeu
|
|
|
43
43
|
|
|
44
44
|
private
|
|
45
45
|
|
|
46
|
+
# @return [String]
|
|
46
47
|
def compress
|
|
47
48
|
out = ''
|
|
48
49
|
Array(output).flatten.each do |char|
|
|
@@ -54,6 +55,7 @@ module Vedeu
|
|
|
54
55
|
out
|
|
55
56
|
end
|
|
56
57
|
|
|
58
|
+
# @return [String]
|
|
57
59
|
def uncompress
|
|
58
60
|
out = ''
|
|
59
61
|
Array(output).flatten.each do |char|
|