vedeu 0.2.2 → 0.2.3
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/api.md +1 -1
- data/docs/events.md +11 -8
- data/lib/vedeu/api/api.rb +19 -43
- data/lib/vedeu/api/composition.rb +13 -8
- data/lib/vedeu/api/defined.rb +14 -4
- data/lib/vedeu/api/helpers.rb +8 -5
- data/lib/vedeu/api/interface.rb +15 -21
- data/lib/vedeu/api/keymap.rb +11 -5
- data/lib/vedeu/api/line.rb +6 -7
- data/lib/vedeu/api/menu.rb +9 -17
- data/lib/vedeu/api/stream.rb +8 -6
- data/lib/vedeu/application.rb +14 -12
- data/lib/vedeu/configuration/api.rb +33 -3
- data/lib/vedeu/configuration/cli.rb +23 -3
- data/lib/vedeu/configuration/configuration.rb +3 -2
- data/lib/vedeu/input/input.rb +6 -2
- data/lib/vedeu/launcher.rb +5 -2
- data/lib/vedeu/models/attributes/background.rb +3 -2
- data/lib/vedeu/models/attributes/coercions.rb +3 -2
- data/lib/vedeu/models/attributes/colour_translator.rb +11 -4
- data/lib/vedeu/models/attributes/foreground.rb +3 -2
- data/lib/vedeu/models/attributes/presentation.rb +3 -2
- data/lib/vedeu/models/colour.rb +3 -2
- data/lib/vedeu/models/composition.rb +5 -2
- data/lib/vedeu/models/cursor.rb +3 -2
- data/lib/vedeu/models/geometry.rb +48 -6
- data/lib/vedeu/models/interface.rb +12 -2
- data/lib/vedeu/models/keymap.rb +4 -2
- data/lib/vedeu/models/line.rb +5 -2
- data/lib/vedeu/models/stream.rb +12 -2
- data/lib/vedeu/models/style.rb +3 -2
- data/lib/vedeu/output/clear.rb +5 -2
- data/lib/vedeu/output/compositor.rb +4 -2
- data/lib/vedeu/output/refresh.rb +4 -6
- data/lib/vedeu/output/render.rb +17 -14
- data/lib/vedeu/output/view.rb +5 -2
- data/lib/vedeu/repositories/buffers.rb +16 -47
- data/lib/vedeu/repositories/cursors.rb +26 -28
- data/lib/vedeu/repositories/events.rb +33 -48
- data/lib/vedeu/repositories/focus.rb +24 -20
- data/lib/vedeu/repositories/groups.rb +17 -52
- data/lib/vedeu/repositories/interfaces.rb +21 -42
- data/lib/vedeu/repositories/keymaps.rb +9 -57
- data/lib/vedeu/repositories/menus.rb +15 -55
- data/lib/vedeu/support/common.rb +2 -2
- data/lib/vedeu/support/esc.rb +35 -2
- data/lib/vedeu/support/event.rb +7 -8
- data/lib/vedeu/support/exceptions.rb +47 -0
- data/lib/vedeu/support/grid.rb +11 -4
- data/lib/vedeu/support/keymap_validator.rb +9 -14
- data/lib/vedeu/support/log.rb +13 -3
- data/lib/vedeu/support/menu.rb +3 -2
- data/lib/vedeu/support/position.rb +3 -2
- data/lib/vedeu/support/registrar.rb +2 -23
- data/lib/vedeu/support/repository.rb +77 -0
- data/lib/vedeu/support/terminal.rb +12 -2
- data/lib/vedeu/support/trace.rb +127 -20
- data/lib/vedeu.rb +11 -46
- data/test/lib/vedeu/api/api_test.rb +14 -18
- data/test/lib/vedeu/api/defined_test.rb +16 -6
- data/test/lib/vedeu/api/interface_test.rb +5 -20
- data/test/lib/vedeu/api/menu_test.rb +1 -1
- data/test/lib/vedeu/models/geometry_test.rb +41 -0
- data/test/lib/vedeu/models/interface_test.rb +14 -0
- data/test/lib/vedeu/repositories/buffers_test.rb +6 -32
- data/test/lib/vedeu/repositories/cursors_test.rb +14 -0
- data/test/lib/vedeu/repositories/events_test.rb +18 -47
- data/test/lib/vedeu/repositories/focus_test.rb +18 -5
- data/test/lib/vedeu/repositories/groups_test.rb +3 -62
- data/test/lib/vedeu/repositories/interfaces_test.rb +13 -49
- data/test/lib/vedeu/repositories/keymaps_test.rb +0 -23
- data/test/lib/vedeu/repositories/menus_test.rb +3 -62
- data/test/lib/vedeu/support/esc_test.rb +24 -0
- data/test/lib/vedeu/support/keymap_validator_test.rb +19 -38
- data/test/lib/vedeu/support/repository_test.rb +70 -0
- data/test/test_helper.rb +2 -0
- data/vedeu.gemspec +3 -3
- metadata +10 -6
data/lib/vedeu/api/stream.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
module Vedeu
|
2
|
+
|
2
3
|
module API
|
3
4
|
|
4
5
|
# Provides methods to be used to define views.
|
@@ -11,7 +12,6 @@ module Vedeu
|
|
11
12
|
# Specify the alignment of the stream within the line. Useful in
|
12
13
|
# combination with {#width} to provide simple formatting effects.
|
13
14
|
#
|
14
|
-
# @api public
|
15
15
|
# @param value [Symbol] `:left`, `:centre` and `right` are valid values
|
16
16
|
# and will align accordingly. If not value is specified, the stream will
|
17
17
|
# left align.
|
@@ -22,6 +22,8 @@ module Vedeu
|
|
22
22
|
# align :right
|
23
23
|
# ...
|
24
24
|
#
|
25
|
+
# @raise [InvalidSyntax] When the value parameter is not one of +:left+,
|
26
|
+
# +:right+ or +:centre+.
|
25
27
|
# @return [Symbol]
|
26
28
|
def align(value)
|
27
29
|
unless [:left, :right, :centre].include?(value.to_sym)
|
@@ -55,7 +57,6 @@ module Vedeu
|
|
55
57
|
|
56
58
|
# Add textual data to the stream via this method.
|
57
59
|
#
|
58
|
-
# @api public
|
59
60
|
# @param value [String] The text to be added to the stream. If the length
|
60
61
|
# of the text is greater than the interface's width, it will be
|
61
62
|
# truncated and ellipsized.
|
@@ -75,7 +76,6 @@ module Vedeu
|
|
75
76
|
# stream. Useful in combination with #align to provide simple formatting
|
76
77
|
# effects.
|
77
78
|
#
|
78
|
-
# @api public
|
79
79
|
# @param value [Fixnum] The width in characters.
|
80
80
|
#
|
81
81
|
# @example
|
@@ -89,6 +89,8 @@ module Vedeu
|
|
89
89
|
attributes[:width] = value
|
90
90
|
end
|
91
91
|
|
92
|
-
end
|
93
|
-
|
94
|
-
end
|
92
|
+
end # Stream
|
93
|
+
|
94
|
+
end # API
|
95
|
+
|
96
|
+
end # Vedeu
|
data/lib/vedeu/application.rb
CHANGED
@@ -18,11 +18,11 @@ module Vedeu
|
|
18
18
|
# the client application may treat this event as Vedeu signalling that it
|
19
19
|
# is about to terminate. Client applications are encouraged to use this
|
20
20
|
# event to close any open buffers, save files, empty trash, etc.
|
21
|
-
# - A StopIteration exception is raised which will cause {#start} to exit
|
22
|
-
# its looop and terminate the application.
|
23
21
|
#
|
24
22
|
# @api private
|
25
|
-
# @
|
23
|
+
# @raise [StopIteration] Will cause {#start} to exit its loop and
|
24
|
+
# terminate the application.
|
25
|
+
# @return [StopIteration]
|
26
26
|
def stop
|
27
27
|
Vedeu.trigger(:_cleanup_)
|
28
28
|
|
@@ -73,10 +73,11 @@ module Vedeu
|
|
73
73
|
end
|
74
74
|
|
75
75
|
# For an interactive application we capture input, (usually from the user),
|
76
|
-
# and continue the main loop.
|
77
|
-
#
|
78
|
-
#
|
79
|
-
#
|
76
|
+
# and continue the main loop. If the client application does not require
|
77
|
+
# user input then Vedeu triggers the `:_standalone_` event for each run of
|
78
|
+
# the main loop. The client application is expected to respond to this event
|
79
|
+
# and 'do something useful'. When the client application has finished, it
|
80
|
+
# should trigger the `:_exit_` event.
|
80
81
|
#
|
81
82
|
# @api private
|
82
83
|
# @return []
|
@@ -85,13 +86,14 @@ module Vedeu
|
|
85
86
|
Input.capture
|
86
87
|
|
87
88
|
else
|
88
|
-
|
89
|
+
Vedeu.trigger(:_standalone_)
|
89
90
|
|
90
91
|
end
|
91
92
|
end
|
92
93
|
|
93
|
-
# Runs the application in a continuous loop. This loop is stopped
|
94
|
-
#
|
94
|
+
# Runs the application in a continuous loop. This loop is stopped when an
|
95
|
+
# uncaught exception occurs or when either the `:_mode_switch_` or `:_exit_`
|
96
|
+
# event is triggered.
|
95
97
|
#
|
96
98
|
# @api private
|
97
99
|
# @return []
|
@@ -105,6 +107,6 @@ module Vedeu
|
|
105
107
|
|
106
108
|
end
|
107
109
|
|
108
|
-
end
|
110
|
+
end # Application
|
109
111
|
# :nocov:
|
110
|
-
end
|
112
|
+
end # Vedeu
|
@@ -60,6 +60,8 @@ module Vedeu
|
|
60
60
|
# @param value [Boolean]
|
61
61
|
# @return [Boolean]
|
62
62
|
def interactive!(value = true)
|
63
|
+
Vedeu.log("Configuration::API interactive: #{value.to_s}")
|
64
|
+
|
63
65
|
options[:interactive] = value
|
64
66
|
end
|
65
67
|
alias_method :interactive, :interactive!
|
@@ -75,6 +77,8 @@ module Vedeu
|
|
75
77
|
# @param value [Boolean]
|
76
78
|
# @return [Boolean]
|
77
79
|
def standalone!(value = true)
|
80
|
+
Vedeu.log("Configuration::API interactive: #{!value.to_s}")
|
81
|
+
|
78
82
|
options[:interactive] = !value
|
79
83
|
end
|
80
84
|
alias_method :standalone, :standalone!
|
@@ -91,6 +95,8 @@ module Vedeu
|
|
91
95
|
# @param value [Boolean]
|
92
96
|
# @return [Boolean]
|
93
97
|
def run_once!(value = true)
|
98
|
+
Vedeu.log("Configuration::API once: #{value.to_s}")
|
99
|
+
|
94
100
|
options[:once] = value
|
95
101
|
end
|
96
102
|
alias_method :run_once, :run_once!
|
@@ -104,6 +110,8 @@ module Vedeu
|
|
104
110
|
#
|
105
111
|
# @return [Boolean]
|
106
112
|
def cooked!
|
113
|
+
Vedeu.log("Configuration::API terminal_mode: :cooked")
|
114
|
+
|
107
115
|
options[:terminal_mode] = :cooked
|
108
116
|
end
|
109
117
|
alias_method :cooked, :cooked!
|
@@ -117,6 +125,8 @@ module Vedeu
|
|
117
125
|
#
|
118
126
|
# @return [Boolean]
|
119
127
|
def raw!
|
128
|
+
Vedeu.log("Configuration::API terminal_mode: :raw")
|
129
|
+
|
120
130
|
options[:terminal_mode] = :raw
|
121
131
|
end
|
122
132
|
alias_method :raw, :raw!
|
@@ -139,9 +149,13 @@ module Vedeu
|
|
139
149
|
# @return [Boolean]
|
140
150
|
def debug!(value = true)
|
141
151
|
if options.key?(:trace) && options[:trace] != false
|
152
|
+
Vedeu.log("Configuration::API debug: true")
|
153
|
+
|
142
154
|
options[:debug] = true
|
143
155
|
|
144
156
|
else
|
157
|
+
Vedeu.log("Configuration::API debug: #{value.to_s}")
|
158
|
+
|
145
159
|
options[:debug] = value
|
146
160
|
|
147
161
|
end
|
@@ -166,6 +180,8 @@ module Vedeu
|
|
166
180
|
def trace!(value = true)
|
167
181
|
options[:debug] = true if value === true
|
168
182
|
|
183
|
+
Vedeu.log("Configuration::API trace: #{value.to_s}")
|
184
|
+
|
169
185
|
options[:trace] = value
|
170
186
|
end
|
171
187
|
alias_method :trace, :trace!
|
@@ -178,11 +194,15 @@ module Vedeu
|
|
178
194
|
# ...
|
179
195
|
#
|
180
196
|
# @param value [Fixnum]
|
197
|
+
# @raise [InvalidSyntax] When the value parameter is not one of +8+, +16+,
|
198
|
+
# +256+ or +16777216+.
|
181
199
|
# @return [Boolean]
|
182
200
|
def colour_mode(value = nil)
|
183
201
|
fail InvalidSyntax, '`colour_mode` must be `8`, `16`, `256`, ' \
|
184
202
|
'`16777216`.' unless valid_colour_mode?(value)
|
185
203
|
|
204
|
+
Vedeu.log("Configuration::API colour_mode: #{value.to_s}")
|
205
|
+
|
186
206
|
options[:colour_mode] = value
|
187
207
|
end
|
188
208
|
|
@@ -202,6 +222,8 @@ module Vedeu
|
|
202
222
|
def exit_key(value)
|
203
223
|
return invalid_key('exit_key') unless valid_key?(value)
|
204
224
|
|
225
|
+
Vedeu.log("Configuration::API exit_key: #{value.to_s}")
|
226
|
+
|
205
227
|
system_key_options[:exit] = value
|
206
228
|
end
|
207
229
|
|
@@ -222,6 +244,8 @@ module Vedeu
|
|
222
244
|
def focus_next_key(value)
|
223
245
|
return invalid_key('exit_key') unless valid_key?(value)
|
224
246
|
|
247
|
+
Vedeu.log("Configuration::API focus_next: #{value.to_s}")
|
248
|
+
|
225
249
|
system_key_options[:focus_next] = value
|
226
250
|
end
|
227
251
|
|
@@ -242,6 +266,8 @@ module Vedeu
|
|
242
266
|
def focus_prev_key(value)
|
243
267
|
return invalid_key('exit_key') unless valid_key?(value)
|
244
268
|
|
269
|
+
Vedeu.log("Configuration::API focus_prev: #{value.to_s}")
|
270
|
+
|
245
271
|
system_key_options[:focus_prev] = value
|
246
272
|
end
|
247
273
|
|
@@ -262,6 +288,8 @@ module Vedeu
|
|
262
288
|
def mode_switch_key(value)
|
263
289
|
return invalid_key('exit_key') unless valid_key?(value)
|
264
290
|
|
291
|
+
Vedeu.log("Configuration::API mode_switch: #{value.to_s}")
|
292
|
+
|
265
293
|
system_key_options[:mode_switch] = value
|
266
294
|
end
|
267
295
|
|
@@ -315,13 +343,15 @@ module Vedeu
|
|
315
343
|
# @api private
|
316
344
|
# @param system_key [String] The calling method wishing to raise an
|
317
345
|
# exception.
|
346
|
+
# @raise [InvalidSyntax] When the system_key parameter is not a String or
|
347
|
+
# Symbol.
|
318
348
|
# @return [InvalidSyntax]
|
319
349
|
def invalid_key(system_key)
|
320
350
|
fail InvalidSyntax, "`#{system_key}` must be a String or a Symbol."
|
321
351
|
end
|
322
352
|
|
323
|
-
end
|
353
|
+
end # API
|
324
354
|
|
325
|
-
end
|
355
|
+
end # Configuration
|
326
356
|
|
327
|
-
end
|
357
|
+
end # Vedeu
|
@@ -36,39 +36,55 @@ module Vedeu
|
|
36
36
|
|
37
37
|
opts.on('-i', '--interactive',
|
38
38
|
'Run the application in interactive mode (default).') do
|
39
|
+
Vedeu.log("Configuration::CLI interactive: true")
|
40
|
+
|
39
41
|
options[:interactive] = true
|
40
42
|
end
|
41
43
|
|
42
44
|
opts.on('-I', '--noninteractive', '--standalone',
|
43
45
|
'Run the application non-interactively; i.e. not requiring ' \
|
44
46
|
'intervention from the user.') do
|
47
|
+
Vedeu.log("Configuration::CLI interactive: false")
|
48
|
+
|
45
49
|
options[:interactive] = false
|
46
50
|
end
|
47
51
|
|
48
52
|
opts.on('-1', '--run-once',
|
49
53
|
'Run the application loop once.') do
|
54
|
+
Vedeu.log("Configuration::CLI once: true")
|
55
|
+
|
50
56
|
options[:once] = true
|
51
57
|
end
|
52
58
|
|
53
59
|
opts.on('-n', '--run-many',
|
54
60
|
'Run the application loop continuously (default).') do
|
61
|
+
Vedeu.log("Configuration::CLI once: false")
|
62
|
+
|
55
63
|
options[:once] = false
|
56
64
|
end
|
57
65
|
|
58
66
|
opts.on('-c', '--cooked', 'Run application in cooked mode.') do
|
67
|
+
Vedeu.log("Configuration::CLI terminal_mode: :cooked")
|
68
|
+
|
59
69
|
options[:terminal_mode] = :cooked
|
60
70
|
end
|
61
71
|
|
62
72
|
opts.on('-r', '--raw', 'Run application in raw mode (default).') do
|
73
|
+
Vedeu.log("Configuration::CLI terminal_mode: :raw")
|
74
|
+
|
63
75
|
options[:terminal_mode] = :raw
|
64
76
|
end
|
65
77
|
|
66
78
|
opts.on('-d', '--debug', 'Run application with debugging on.') do
|
79
|
+
Vedeu.log("Configuration::CLI debug: true")
|
80
|
+
|
67
81
|
options[:debug] = true
|
68
82
|
end
|
69
83
|
|
70
84
|
opts.on('-D', '--trace', 'Run application with debugging on with ' \
|
71
85
|
'method and event tracing (noisy!).') do
|
86
|
+
Vedeu.log("Configuration::CLI trace: true")
|
87
|
+
|
72
88
|
options[:debug] = true
|
73
89
|
options[:trace] = true
|
74
90
|
end
|
@@ -77,9 +93,13 @@ module Vedeu
|
|
77
93
|
'Run application in either `8`, `16`, `256` or `16777216` ' \
|
78
94
|
'colour mode.') do |colours|
|
79
95
|
if [8, 16, 256, 16777216].include?(colours)
|
96
|
+
Vedeu.log("Configuration::CLI colour_mode: #{colours.to_s}")
|
97
|
+
|
80
98
|
options[:colour_mode] = colours
|
81
99
|
|
82
100
|
else
|
101
|
+
Vedeu.log("Configuration::CLI colour_mode: 8 (defaulted)")
|
102
|
+
|
83
103
|
options[:colour_mode] = 8
|
84
104
|
|
85
105
|
end
|
@@ -103,8 +123,8 @@ module Vedeu
|
|
103
123
|
@_options ||= {}
|
104
124
|
end
|
105
125
|
|
106
|
-
end
|
126
|
+
end # CLI
|
107
127
|
|
108
|
-
end
|
128
|
+
end # Configuration
|
109
129
|
|
110
|
-
end
|
130
|
+
end # Vedeu
|
data/lib/vedeu/input/input.rb
CHANGED
@@ -37,6 +37,9 @@ module Vedeu
|
|
37
37
|
specials.fetch(key, key)
|
38
38
|
end
|
39
39
|
|
40
|
+
# Translates (if possible) entered escape sequences into symbols
|
41
|
+
# representing the key which was pressed.
|
42
|
+
#
|
40
43
|
# @api private
|
41
44
|
# @return [Hash]
|
42
45
|
def specials
|
@@ -73,5 +76,6 @@ module Vedeu
|
|
73
76
|
}
|
74
77
|
end
|
75
78
|
|
76
|
-
end
|
77
|
-
|
79
|
+
end # Input
|
80
|
+
|
81
|
+
end # Vedeu
|
data/lib/vedeu/launcher.rb
CHANGED
@@ -41,6 +41,8 @@ module Vedeu
|
|
41
41
|
puts uncaught_exception.backtrace.join("\n")
|
42
42
|
|
43
43
|
ensure
|
44
|
+
Vedeu.log("Exiting gracefully.")
|
45
|
+
|
44
46
|
$stdin, $stdout, $stderr = STDIN, STDOUT, STDERR
|
45
47
|
@kernel.exit(@exit_code)
|
46
48
|
|
@@ -50,5 +52,6 @@ module Vedeu
|
|
50
52
|
|
51
53
|
attr_reader :argv
|
52
54
|
|
53
|
-
end
|
54
|
-
|
55
|
+
end # Launcher
|
56
|
+
|
57
|
+
end # Vedeu
|
@@ -76,6 +76,8 @@ module Vedeu
|
|
76
76
|
end
|
77
77
|
|
78
78
|
# @api private
|
79
|
+
# @raise [NotImplemented] Subclasses of this class must implement this
|
80
|
+
# method.
|
79
81
|
# @return [Exception]
|
80
82
|
def named
|
81
83
|
fail NotImplemented, 'Subclasses implement this.'
|
@@ -94,7 +96,9 @@ module Vedeu
|
|
94
96
|
end
|
95
97
|
|
96
98
|
# @api private
|
97
|
-
# @
|
99
|
+
# @raise [NotImplemented] Subclasses of this class must implement this
|
100
|
+
# method.
|
101
|
+
# @return [NotImplemented]
|
98
102
|
def numbered
|
99
103
|
fail NotImplemented, 'Subclasses implement this.'
|
100
104
|
end
|
@@ -112,7 +116,9 @@ module Vedeu
|
|
112
116
|
end
|
113
117
|
|
114
118
|
# @api private
|
115
|
-
# @
|
119
|
+
# @raise [NotImplemented] Subclasses of this class must implement this
|
120
|
+
# method.
|
121
|
+
# @return [NotImplemented]
|
116
122
|
def rgb
|
117
123
|
fail NotImplemented, 'Subclasses implement this.'
|
118
124
|
end
|
@@ -179,5 +185,6 @@ module Vedeu
|
|
179
185
|
}
|
180
186
|
end
|
181
187
|
|
182
|
-
end
|
183
|
-
|
188
|
+
end # ColourTranslator
|
189
|
+
|
190
|
+
end # Vedeu
|
data/lib/vedeu/models/colour.rb
CHANGED
@@ -61,8 +61,11 @@ module Vedeu
|
|
61
61
|
# @api private
|
62
62
|
# @return []
|
63
63
|
def method_missing(method, *args, &block)
|
64
|
+
Vedeu.log("Composition#method_missing '#{method.to_s}' (args: #{args.inspect})")
|
65
|
+
|
64
66
|
@self_before_instance_eval.send(method, *args, &block)
|
65
67
|
end
|
66
68
|
|
67
|
-
end
|
68
|
-
|
69
|
+
end # Composition
|
70
|
+
|
71
|
+
end # Vedeu
|
data/lib/vedeu/models/cursor.rb
CHANGED
@@ -162,6 +162,9 @@ module Vedeu
|
|
162
162
|
# Returns the bottom coordinate of the interface, a fixed or dynamic value
|
163
163
|
# depending on the value of {#top}.
|
164
164
|
#
|
165
|
+
# @todo I think `height` should be `viewport_height` because the terminal
|
166
|
+
# may have resized, and viewport_height will properly handle this.
|
167
|
+
#
|
165
168
|
# @return [Fixnum]
|
166
169
|
def bottom
|
167
170
|
top + height
|
@@ -185,6 +188,9 @@ module Vedeu
|
|
185
188
|
# Returns the right coordinate of the interface, a fixed or dynamic value
|
186
189
|
# depending on the value of {#left}.
|
187
190
|
#
|
191
|
+
# @todo I think `width` should be `viewport_width` because the terminal may
|
192
|
+
# have resized, and viewport_width will properly handle this.
|
193
|
+
#
|
188
194
|
# @return [Fixnum]
|
189
195
|
def right
|
190
196
|
left + width
|
@@ -205,22 +211,57 @@ module Vedeu
|
|
205
211
|
right + value
|
206
212
|
end
|
207
213
|
|
208
|
-
private
|
209
|
-
|
210
214
|
# Provides a virtual y position within the interface's dimensions.
|
211
215
|
#
|
216
|
+
# @example
|
217
|
+
# # top = 3
|
218
|
+
# # bottom = 6
|
219
|
+
# # virtual_y # => [3, 4, 5]
|
220
|
+
#
|
212
221
|
# @return [Array]
|
213
222
|
def virtual_y
|
214
|
-
(top
|
223
|
+
(top...bottom).to_a
|
215
224
|
end
|
216
225
|
|
217
226
|
# Provides a virtual x position within the interface's dimensions.
|
218
227
|
#
|
228
|
+
# @example
|
229
|
+
# # left = 9
|
230
|
+
# # right = 13
|
231
|
+
# # virtual_x # => [9, 10, 11, 12]
|
232
|
+
#
|
219
233
|
# @return [Array]
|
220
234
|
def virtual_x
|
221
|
-
(left
|
235
|
+
(left...right).to_a
|
222
236
|
end
|
223
237
|
|
238
|
+
# Provides all the geometry in a convenient hash.
|
239
|
+
#
|
240
|
+
# @return [Hash]
|
241
|
+
def to_h
|
242
|
+
{
|
243
|
+
centred: centred,
|
244
|
+
height: height,
|
245
|
+
width: width,
|
246
|
+
x: x,
|
247
|
+
y: y,
|
248
|
+
viewport_height: viewport_height,
|
249
|
+
viewport_width: viewport_width,
|
250
|
+
top: top,
|
251
|
+
right: right,
|
252
|
+
bottom: bottom,
|
253
|
+
left: left,
|
254
|
+
north: north,
|
255
|
+
east: east,
|
256
|
+
south: south,
|
257
|
+
west: west,
|
258
|
+
virtual_x: virtual_x,
|
259
|
+
virtual_y: virtual_y,
|
260
|
+
}
|
261
|
+
end
|
262
|
+
|
263
|
+
private
|
264
|
+
|
224
265
|
# The default geometry of an interface- full screen.
|
225
266
|
#
|
226
267
|
# @return [Hash]
|
@@ -234,5 +275,6 @@ module Vedeu
|
|
234
275
|
}
|
235
276
|
end
|
236
277
|
|
237
|
-
end
|
238
|
-
|
278
|
+
end # Geometry
|
279
|
+
|
280
|
+
end # Vedeu
|
@@ -67,6 +67,13 @@ module Vedeu
|
|
67
67
|
self
|
68
68
|
end
|
69
69
|
|
70
|
+
# Returns a boolean indicating whether this interface is currently in focus.
|
71
|
+
#
|
72
|
+
# @return [Boolean]
|
73
|
+
def in_focus?
|
74
|
+
Focus.current?(name)
|
75
|
+
end
|
76
|
+
|
70
77
|
# Returns a collection of lines associated with this interface.
|
71
78
|
#
|
72
79
|
# @return [Array]
|
@@ -103,8 +110,11 @@ module Vedeu
|
|
103
110
|
# @api private
|
104
111
|
# @return []
|
105
112
|
def method_missing(method, *args, &block)
|
113
|
+
Vedeu.log("Interface#method_missing '#{method.to_s}' (args: #{args.inspect})")
|
114
|
+
|
106
115
|
@self_before_instance_eval.send(method, *args, &block)
|
107
116
|
end
|
108
117
|
|
109
|
-
end
|
110
|
-
|
118
|
+
end # Interface
|
119
|
+
|
120
|
+
end # Vedeu
|
data/lib/vedeu/models/keymap.rb
CHANGED
@@ -60,9 +60,11 @@ module Vedeu
|
|
60
60
|
# @api private
|
61
61
|
# @return []
|
62
62
|
def method_missing(method, *args, &block)
|
63
|
+
Vedeu.log("Keymap#method_missing '#{method.to_s}' (args: #{args.inspect})")
|
64
|
+
|
63
65
|
@self_before_instance_eval.send(method, *args, &block)
|
64
66
|
end
|
65
67
|
|
66
|
-
end
|
68
|
+
end # Keymap
|
67
69
|
|
68
|
-
end
|
70
|
+
end # Vedeu
|
data/lib/vedeu/models/line.rb
CHANGED
@@ -70,8 +70,11 @@ module Vedeu
|
|
70
70
|
# @api private
|
71
71
|
# @return []
|
72
72
|
def method_missing(method, *args, &block)
|
73
|
+
Vedeu.log("Line#method_missing '#{method.to_s}' (args: #{args.inspect})")
|
74
|
+
|
73
75
|
@self_before_instance_eval.send(method, *args, &block)
|
74
76
|
end
|
75
77
|
|
76
|
-
end
|
77
|
-
|
78
|
+
end # Line
|
79
|
+
|
80
|
+
end # Vedeu
|
data/lib/vedeu/models/stream.rb
CHANGED
@@ -40,6 +40,13 @@ module Vedeu
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
# Returns the content of this stream.
|
44
|
+
#
|
45
|
+
# @return [String]
|
46
|
+
def content
|
47
|
+
data
|
48
|
+
end
|
49
|
+
|
43
50
|
private
|
44
51
|
|
45
52
|
# Returns the text aligned if a width was set, otherwise just the text.
|
@@ -89,8 +96,11 @@ module Vedeu
|
|
89
96
|
# @api private
|
90
97
|
# @return []
|
91
98
|
def method_missing(method, *args, &block)
|
99
|
+
Vedeu.log("Stream#method_missing '#{method.to_s}' (args: #{args.inspect})")
|
100
|
+
|
92
101
|
@self_before_instance_eval.send(method, *args, &block)
|
93
102
|
end
|
94
103
|
|
95
|
-
end
|
96
|
-
|
104
|
+
end # Stream
|
105
|
+
|
106
|
+
end # Vedeu
|
data/lib/vedeu/models/style.rb
CHANGED
data/lib/vedeu/output/clear.rb
CHANGED
@@ -29,6 +29,8 @@ module Vedeu
|
|
29
29
|
#
|
30
30
|
# @return [String]
|
31
31
|
def clear
|
32
|
+
Vedeu.log("Clearing view: '#{interface.name}'")
|
33
|
+
|
32
34
|
rows.inject([colours]) do |line, index|
|
33
35
|
line << interface.origin(index) { ' ' * interface.viewport_width }
|
34
36
|
end.join
|
@@ -50,5 +52,6 @@ module Vedeu
|
|
50
52
|
interface.viewport_height.times
|
51
53
|
end
|
52
54
|
|
53
|
-
end
|
54
|
-
|
55
|
+
end # Clear
|
56
|
+
|
57
|
+
end # Vedeu
|