vedeu 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/LICENSE.txt +5 -0
- data/bin/vedeu +3 -1
- data/docs/api.md +2 -0
- data/examples/cursor_app/cursor_app.rb +22 -7
- data/examples/hello_world.rb +42 -0
- data/lib/vedeu.rb +5 -5
- data/lib/vedeu/api/api.rb +16 -33
- data/lib/vedeu/api/helpers.rb +86 -0
- data/lib/vedeu/api/interface.rb +60 -17
- data/lib/vedeu/api/keymap.rb +5 -0
- data/lib/vedeu/api/line.rb +52 -34
- data/lib/vedeu/api/menu.rb +1 -1
- data/lib/vedeu/api/stream.rb +0 -34
- data/lib/vedeu/configuration/api.rb +10 -10
- data/lib/vedeu/configuration/cli.rb +1 -1
- data/lib/vedeu/launcher.rb +21 -6
- data/lib/vedeu/models/background.rb +1 -1
- data/lib/vedeu/models/composition.rb +1 -1
- data/lib/vedeu/models/cursor.rb +25 -35
- data/lib/vedeu/models/foreground.rb +1 -1
- data/lib/vedeu/models/geometry.rb +216 -6
- data/lib/vedeu/models/interface.rb +14 -16
- data/lib/vedeu/models/keymap.rb +38 -6
- data/lib/vedeu/models/line.rb +1 -1
- data/lib/vedeu/models/stream.rb +1 -1
- data/lib/vedeu/output/compositor.rb +1 -1
- data/lib/vedeu/output/render.rb +1 -5
- data/lib/vedeu/output/viewport.rb +37 -2
- data/lib/vedeu/repositories/buffers.rb +21 -27
- data/lib/vedeu/repositories/cursors.rb +3 -15
- data/lib/vedeu/repositories/focus.rb +2 -6
- data/lib/vedeu/repositories/groups.rb +1 -1
- data/lib/vedeu/repositories/interfaces.rb +1 -1
- data/lib/vedeu/repositories/keymaps.rb +26 -22
- data/lib/vedeu/repositories/menus.rb +1 -1
- data/lib/vedeu/repositories/offsets.rb +30 -12
- data/lib/vedeu/repositories/positional.rb +23 -0
- data/lib/vedeu/support/colour_translator.rb +1 -16
- data/lib/vedeu/support/esc.rb +23 -28
- data/lib/vedeu/support/event.rb +6 -14
- data/lib/vedeu/{output → support}/refresh.rb +0 -0
- data/lib/vedeu/support/registrar.rb +6 -14
- data/lib/vedeu/support/repository.rb +3 -2
- data/lib/vedeu/support/terminal.rb +9 -13
- data/lib/vedeu/support/trace.rb +2 -3
- data/test/integration/cursors_test.rb +9 -0
- data/test/integration/views/basic_view_test.rb +19 -0
- data/test/lib/vedeu/api/api_test.rb +28 -5
- data/test/lib/vedeu/api/composition_test.rb +7 -3
- data/test/lib/vedeu/api/defined_test.rb +9 -3
- data/test/lib/vedeu/api/helpers_test.rb +39 -5
- data/test/lib/vedeu/api/interface_test.rb +88 -8
- data/test/lib/vedeu/api/keymap_test.rb +5 -3
- data/test/lib/vedeu/api/line_test.rb +9 -3
- data/test/lib/vedeu/api/menu_test.rb +11 -7
- data/test/lib/vedeu/api/stream_test.rb +9 -31
- data/test/lib/vedeu/application_test.rb +25 -2
- data/test/lib/vedeu/configuration/api_test.rb +5 -3
- data/test/lib/vedeu/configuration/cli_test.rb +5 -3
- data/test/lib/vedeu/configuration/configuration_test.rb +5 -2
- data/test/lib/vedeu/input/input_test.rb +5 -2
- data/test/lib/vedeu/launcher_test.rb +37 -2
- data/test/lib/vedeu/models/background_test.rb +6 -2
- data/test/lib/vedeu/models/char_test.rb +9 -6
- data/test/lib/vedeu/models/colour_test.rb +6 -2
- data/test/lib/vedeu/models/composition_test.rb +4 -2
- data/test/lib/vedeu/models/cursor_test.rb +27 -16
- data/test/lib/vedeu/models/foreground_test.rb +6 -2
- data/test/lib/vedeu/models/geometry_test.rb +6 -2
- data/test/lib/vedeu/models/interface_test.rb +5 -2
- data/test/lib/vedeu/models/keymap_test.rb +6 -4
- data/test/lib/vedeu/models/line_test.rb +5 -2
- data/test/lib/vedeu/models/offset_test.rb +7 -3
- data/test/lib/vedeu/models/stream_test.rb +4 -2
- data/test/lib/vedeu/models/style_test.rb +5 -2
- data/test/lib/vedeu/output/clear_test.rb +6 -2
- data/test/lib/vedeu/output/compositor_test.rb +8 -4
- data/test/lib/vedeu/output/render_test.rb +9 -6
- data/test/lib/vedeu/output/view_test.rb +7 -3
- data/test/lib/vedeu/output/viewport_test.rb +42 -9
- data/test/lib/vedeu/repositories/buffers_test.rb +52 -12
- data/test/lib/vedeu/repositories/cursors_test.rb +4 -26
- data/test/lib/vedeu/repositories/events_test.rb +6 -2
- data/test/lib/vedeu/repositories/focus_test.rb +5 -2
- data/test/lib/vedeu/repositories/groups_test.rb +5 -2
- data/test/lib/vedeu/repositories/interfaces_test.rb +4 -2
- data/test/lib/vedeu/repositories/keymaps_test.rb +8 -2
- data/test/lib/vedeu/repositories/menus_test.rb +3 -2
- data/test/lib/vedeu/repositories/offsets_test.rb +26 -19
- data/test/lib/vedeu/repositories/positional_test.rb +50 -0
- data/test/lib/vedeu/support/coercions_test.rb +7 -3
- data/test/lib/vedeu/support/colour_translator_test.rb +6 -2
- data/test/lib/vedeu/support/common_test.rb +5 -3
- data/test/lib/vedeu/support/esc_test.rb +6 -2
- data/test/lib/vedeu/support/event_test.rb +6 -2
- data/test/lib/vedeu/support/grid_test.rb +9 -3
- data/test/lib/vedeu/support/keymap_validator_test.rb +5 -2
- data/test/lib/vedeu/support/log_test.rb +4 -2
- data/test/lib/vedeu/support/menu_test.rb +10 -2
- data/test/lib/vedeu/support/position_test.rb +10 -2
- data/test/lib/vedeu/support/presentation_test.rb +6 -3
- data/test/lib/vedeu/{output → support}/refresh_test.rb +6 -2
- data/test/lib/vedeu/support/registrar_test.rb +2 -2
- data/test/lib/vedeu/support/repository_test.rb +4 -3
- data/test/lib/vedeu/support/terminal_test.rb +6 -2
- data/test/lib/vedeu/support/trace_test.rb +17 -2
- data/test/lib/vedeu_test.rb +1 -1
- data/vedeu.gemspec +2 -2
- metadata +13 -13
- data/lib/vedeu/output/area.rb +0 -284
- data/lib/vedeu/support/move.rb +0 -50
- data/test/lib/vedeu/output/area_test.rb +0 -242
- data/test/lib/vedeu/support/move_test.rb +0 -35
data/lib/vedeu/api/keymap.rb
CHANGED
@@ -58,10 +58,15 @@ module Vedeu
|
|
58
58
|
# key('s') { :something }
|
59
59
|
# ...
|
60
60
|
#
|
61
|
+
# keys do
|
62
|
+
# interfaces('main', 'other')
|
63
|
+
# ...
|
64
|
+
#
|
61
65
|
# @return [Array]
|
62
66
|
def interface(*name_or_names)
|
63
67
|
attributes[:interfaces] = name_or_names
|
64
68
|
end
|
69
|
+
alias_method :interfaces, :interface
|
65
70
|
|
66
71
|
end # Keymap
|
67
72
|
|
data/lib/vedeu/api/line.rb
CHANGED
@@ -4,11 +4,63 @@ module Vedeu
|
|
4
4
|
|
5
5
|
# Provides methods to be used to define views.
|
6
6
|
#
|
7
|
+
# @example
|
8
|
+
# line do
|
9
|
+
#
|
10
|
+
# background '#ffffff'
|
11
|
+
#
|
12
|
+
# colour background: '#222222', foreground: '#ff0000'
|
13
|
+
#
|
14
|
+
# foreground '#000000'
|
15
|
+
#
|
16
|
+
# stream do
|
17
|
+
# # see {API::Stream} for directives
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# style 'normal' # or a collection: ['bold', 'underline']
|
21
|
+
#
|
22
|
+
# text 'Some text...'
|
23
|
+
#
|
24
|
+
#
|
7
25
|
# @api public
|
8
26
|
class Line < Vedeu::Line
|
9
27
|
|
10
28
|
include Helpers
|
11
29
|
|
30
|
+
# @param value [String]
|
31
|
+
# @param block [Proc]
|
32
|
+
#
|
33
|
+
# @example
|
34
|
+
# ...
|
35
|
+
# line do
|
36
|
+
# background '#0022ff' do
|
37
|
+
# ... other stream directives ...
|
38
|
+
#
|
39
|
+
# @return [Array]
|
40
|
+
def background(value = '', &block)
|
41
|
+
stream = API::Stream.build({ colour: { background: value },
|
42
|
+
parent: self.view_attributes }, &block)
|
43
|
+
|
44
|
+
attributes[:streams] << stream
|
45
|
+
end
|
46
|
+
|
47
|
+
# @param value [String]
|
48
|
+
# @param block [Proc]
|
49
|
+
#
|
50
|
+
# @example
|
51
|
+
# ...
|
52
|
+
# line do
|
53
|
+
# foreground '#00ff00' do
|
54
|
+
# ... other stream directives ...
|
55
|
+
#
|
56
|
+
# @return [Array]
|
57
|
+
def foreground(value = '', &block)
|
58
|
+
stream = API::Stream.build({ colour: { foreground: value },
|
59
|
+
parent: self.view_attributes }, &block)
|
60
|
+
|
61
|
+
attributes[:streams] << stream
|
62
|
+
end
|
63
|
+
|
12
64
|
# Define a stream (a subset of a line).
|
13
65
|
#
|
14
66
|
# @param block [Proc] Block contains directives relating to API::Stream.
|
@@ -48,40 +100,6 @@ module Vedeu
|
|
48
100
|
attributes[:streams] << { text: value }
|
49
101
|
end
|
50
102
|
|
51
|
-
# @param value [String]
|
52
|
-
# @param block [Proc]
|
53
|
-
#
|
54
|
-
# @example
|
55
|
-
# ...
|
56
|
-
# line do
|
57
|
-
# foreground '#00ff00' do
|
58
|
-
# ... other stream directives ...
|
59
|
-
#
|
60
|
-
# @return [Array]
|
61
|
-
def foreground(value = '', &block)
|
62
|
-
stream = API::Stream.build({ colour: { foreground: value },
|
63
|
-
parent: self.view_attributes }, &block)
|
64
|
-
|
65
|
-
attributes[:streams] << stream
|
66
|
-
end
|
67
|
-
|
68
|
-
# @param value [String]
|
69
|
-
# @param block [Proc]
|
70
|
-
#
|
71
|
-
# @example
|
72
|
-
# ...
|
73
|
-
# line do
|
74
|
-
# background '#0022ff' do
|
75
|
-
# ... other stream directives ...
|
76
|
-
#
|
77
|
-
# @return [Array]
|
78
|
-
def background(value = '', &block)
|
79
|
-
stream = API::Stream.build({ colour: { background: value },
|
80
|
-
parent: self.view_attributes }, &block)
|
81
|
-
|
82
|
-
attributes[:streams] << stream
|
83
|
-
end
|
84
|
-
|
85
103
|
end # Line
|
86
104
|
|
87
105
|
end # API
|
data/lib/vedeu/api/menu.rb
CHANGED
@@ -97,7 +97,7 @@ module Vedeu
|
|
97
97
|
# @param block [Proc] The optional block provided to the method.
|
98
98
|
# @return []
|
99
99
|
def method_missing(method, *args, &block)
|
100
|
-
Vedeu.log("API::Menu#method_missing '#{method
|
100
|
+
Vedeu.log("API::Menu#method_missing '#{method}' (args: #{args.inspect})")
|
101
101
|
|
102
102
|
@self_before_instance_eval.send(method, *args, &block) if @self_before_instance_eval
|
103
103
|
end
|
data/lib/vedeu/api/stream.rb
CHANGED
@@ -34,40 +34,6 @@ module Vedeu
|
|
34
34
|
attributes[:align] = value.to_sym
|
35
35
|
end
|
36
36
|
|
37
|
-
# Specify the background colour for a stream.
|
38
|
-
#
|
39
|
-
# @param value [String]
|
40
|
-
#
|
41
|
-
# @example
|
42
|
-
# ...
|
43
|
-
# stream do
|
44
|
-
# background '#0022ff'
|
45
|
-
# ... other stream directives ...
|
46
|
-
#
|
47
|
-
# @return [Hash]
|
48
|
-
def background(value = '')
|
49
|
-
fail InvalidSyntax, '`background` requires a value.' unless defined_value?(value)
|
50
|
-
|
51
|
-
attributes[:colour].merge!({ background: value })
|
52
|
-
end
|
53
|
-
|
54
|
-
# Specify the foreground colour for a stream.
|
55
|
-
#
|
56
|
-
# @param value [String]
|
57
|
-
#
|
58
|
-
# @example
|
59
|
-
# ...
|
60
|
-
# stream do
|
61
|
-
# foreground '#0022ff'
|
62
|
-
# ... other stream directives ...
|
63
|
-
#
|
64
|
-
# @return [Hash]
|
65
|
-
def foreground(value = '')
|
66
|
-
fail InvalidSyntax, '`foreground` requires a value.' unless defined_value?(value)
|
67
|
-
|
68
|
-
attributes[:colour].merge!({ foreground: value })
|
69
|
-
end
|
70
|
-
|
71
37
|
# Syntactic sugar used with {#align} to left align content.
|
72
38
|
#
|
73
39
|
# @return [Symbol]
|
@@ -60,7 +60,7 @@ module Vedeu
|
|
60
60
|
# @param value [Boolean]
|
61
61
|
# @return [Boolean]
|
62
62
|
def interactive!(value = true)
|
63
|
-
Vedeu.log("Configuration::API interactive: #{value
|
63
|
+
Vedeu.log("Configuration::API interactive: #{value}")
|
64
64
|
|
65
65
|
options[:interactive] = value
|
66
66
|
end
|
@@ -77,7 +77,7 @@ module Vedeu
|
|
77
77
|
# @param value [Boolean]
|
78
78
|
# @return [Boolean]
|
79
79
|
def standalone!(value = true)
|
80
|
-
Vedeu.log("Configuration::API interactive: #{!value
|
80
|
+
Vedeu.log("Configuration::API interactive: #{!value}")
|
81
81
|
|
82
82
|
options[:interactive] = !value
|
83
83
|
end
|
@@ -95,7 +95,7 @@ module Vedeu
|
|
95
95
|
# @param value [Boolean]
|
96
96
|
# @return [Boolean]
|
97
97
|
def run_once!(value = true)
|
98
|
-
Vedeu.log("Configuration::API once: #{value
|
98
|
+
Vedeu.log("Configuration::API once: #{value}")
|
99
99
|
|
100
100
|
options[:once] = value
|
101
101
|
end
|
@@ -154,7 +154,7 @@ module Vedeu
|
|
154
154
|
options[:debug] = true
|
155
155
|
|
156
156
|
else
|
157
|
-
Vedeu.log("Configuration::API debug: #{value
|
157
|
+
Vedeu.log("Configuration::API debug: #{value}")
|
158
158
|
|
159
159
|
options[:debug] = value
|
160
160
|
|
@@ -180,7 +180,7 @@ module Vedeu
|
|
180
180
|
def trace!(value = true)
|
181
181
|
options[:debug] = true if value === true
|
182
182
|
|
183
|
-
Vedeu.log("Configuration::API trace: #{value
|
183
|
+
Vedeu.log("Configuration::API trace: #{value}")
|
184
184
|
|
185
185
|
options[:trace] = value
|
186
186
|
end
|
@@ -201,7 +201,7 @@ module Vedeu
|
|
201
201
|
fail InvalidSyntax, '`colour_mode` must be `8`, `16`, `256`, ' \
|
202
202
|
'`16777216`.' unless valid_colour_mode?(value)
|
203
203
|
|
204
|
-
Vedeu.log("Configuration::API colour_mode: #{value
|
204
|
+
Vedeu.log("Configuration::API colour_mode: #{value}")
|
205
205
|
|
206
206
|
options[:colour_mode] = value
|
207
207
|
end
|
@@ -222,7 +222,7 @@ module Vedeu
|
|
222
222
|
def exit_key(value)
|
223
223
|
return invalid_key('exit_key') unless valid_key?(value)
|
224
224
|
|
225
|
-
Vedeu.log("Configuration::API exit_key: #{value
|
225
|
+
Vedeu.log("Configuration::API exit_key: #{value}")
|
226
226
|
|
227
227
|
system_key_options[:exit] = value
|
228
228
|
end
|
@@ -244,7 +244,7 @@ module Vedeu
|
|
244
244
|
def focus_next_key(value)
|
245
245
|
return invalid_key('exit_key') unless valid_key?(value)
|
246
246
|
|
247
|
-
Vedeu.log("Configuration::API focus_next: #{value
|
247
|
+
Vedeu.log("Configuration::API focus_next: #{value}")
|
248
248
|
|
249
249
|
system_key_options[:focus_next] = value
|
250
250
|
end
|
@@ -266,7 +266,7 @@ module Vedeu
|
|
266
266
|
def focus_prev_key(value)
|
267
267
|
return invalid_key('exit_key') unless valid_key?(value)
|
268
268
|
|
269
|
-
Vedeu.log("Configuration::API focus_prev: #{value
|
269
|
+
Vedeu.log("Configuration::API focus_prev: #{value}")
|
270
270
|
|
271
271
|
system_key_options[:focus_prev] = value
|
272
272
|
end
|
@@ -288,7 +288,7 @@ module Vedeu
|
|
288
288
|
def mode_switch_key(value)
|
289
289
|
return invalid_key('exit_key') unless valid_key?(value)
|
290
290
|
|
291
|
-
Vedeu.log("Configuration::API mode_switch: #{value
|
291
|
+
Vedeu.log("Configuration::API mode_switch: #{value}")
|
292
292
|
|
293
293
|
system_key_options[:mode_switch] = value
|
294
294
|
end
|
@@ -93,7 +93,7 @@ module Vedeu
|
|
93
93
|
'Run application in either `8`, `16`, `256` or `16777216` ' \
|
94
94
|
'colour mode.') do |colours|
|
95
95
|
if [8, 16, 256, 16777216].include?(colours)
|
96
|
-
Vedeu.log("Configuration::CLI colour_mode: #{colours
|
96
|
+
Vedeu.log("Configuration::CLI colour_mode: #{colours}")
|
97
97
|
|
98
98
|
options[:colour_mode] = colours
|
99
99
|
|
data/lib/vedeu/launcher.rb
CHANGED
@@ -8,16 +8,32 @@ module Vedeu
|
|
8
8
|
# @api public
|
9
9
|
class Launcher
|
10
10
|
|
11
|
+
attr_reader :exit_code
|
12
|
+
|
13
|
+
# @see Vedeu::Launcher#initialize
|
14
|
+
def self.execute!(argv = [],
|
15
|
+
stdin = STDIN,
|
16
|
+
stdout = STDOUT,
|
17
|
+
stderr = STDERR,
|
18
|
+
kernel = Kernel)
|
19
|
+
new(argv,
|
20
|
+
stdin = STDIN,
|
21
|
+
stdout = STDOUT,
|
22
|
+
stderr = STDERR,
|
23
|
+
kernel = Kernel).execute!
|
24
|
+
end
|
25
|
+
|
11
26
|
# @param argv [Array]
|
12
27
|
# @param stdin []
|
13
28
|
# @param stdout []
|
14
29
|
# @param stderr []
|
15
30
|
# @param kernel []
|
16
31
|
# @return [Launcher]
|
17
|
-
def initialize(argv
|
18
|
-
|
19
|
-
|
20
|
-
|
32
|
+
def initialize(argv = [],
|
33
|
+
stdin = STDIN,
|
34
|
+
stdout = STDOUT,
|
35
|
+
stderr = STDERR,
|
36
|
+
kernel = Kernel)
|
21
37
|
@argv = argv
|
22
38
|
@stdin = stdin
|
23
39
|
@stdout = stdout
|
@@ -43,8 +59,7 @@ module Vedeu
|
|
43
59
|
Vedeu.log("Exiting gracefully.")
|
44
60
|
|
45
61
|
$stdin, $stdout, $stderr = STDIN, STDOUT, STDERR
|
46
|
-
@kernel.exit(
|
47
|
-
|
62
|
+
@kernel.exit(exit_code)
|
48
63
|
end
|
49
64
|
|
50
65
|
private
|
@@ -62,7 +62,7 @@ module Vedeu
|
|
62
62
|
# @param block [Proc] The optional block provided to the method.
|
63
63
|
# @return []
|
64
64
|
def method_missing(method, *args, &block)
|
65
|
-
Vedeu.log("Composition#method_missing '#{method
|
65
|
+
Vedeu.log("Composition#method_missing '#{method}' (args: #{args.inspect})")
|
66
66
|
|
67
67
|
@self_before_instance_eval.send(method, *args, &block) if @self_before_instance_eval
|
68
68
|
end
|
data/lib/vedeu/models/cursor.rb
CHANGED
@@ -19,17 +19,17 @@ module Vedeu
|
|
19
19
|
# belongs to.
|
20
20
|
# @option attributes :state [Symbol] The visibility of the cursor, either
|
21
21
|
# +:hide+ or +:show+.
|
22
|
-
# @option attributes :x [Fixnum]
|
23
|
-
# @option attributes :y [Fixnum]
|
22
|
+
# @option attributes :x [Fixnum] The terminal x coordinate for the cursor.
|
23
|
+
# @option attributes :y [Fixnum] The terminal y coordinate for the cursor.
|
24
24
|
#
|
25
25
|
# @return [Cursor]
|
26
26
|
def initialize(attributes = {})
|
27
27
|
@attributes = defaults.merge!(attributes)
|
28
28
|
|
29
|
-
@name
|
30
|
-
@state
|
31
|
-
@x
|
32
|
-
@y
|
29
|
+
@name = @attributes[:name]
|
30
|
+
@state = @attributes[:state]
|
31
|
+
@x = @attributes[:x]
|
32
|
+
@y = @attributes[:y]
|
33
33
|
end
|
34
34
|
|
35
35
|
# Returns an attribute hash for the current position and visibility of the
|
@@ -38,19 +38,23 @@ module Vedeu
|
|
38
38
|
# @return [Hash]
|
39
39
|
def attributes
|
40
40
|
{
|
41
|
-
name:
|
42
|
-
state:
|
43
|
-
x:
|
44
|
-
y:
|
41
|
+
name: name,
|
42
|
+
state: state,
|
43
|
+
x: x,
|
44
|
+
y: y,
|
45
45
|
}
|
46
46
|
end
|
47
47
|
alias_method :refresh, :attributes
|
48
48
|
|
49
49
|
# Returns the x coordinate (column/character) of the cursor. Attempts to
|
50
|
-
# sensibly reposition the cursor if it is currently outside the interface
|
50
|
+
# sensibly reposition the cursor if it is currently outside the interface,
|
51
|
+
# or outside the visible area of the terminal.
|
51
52
|
#
|
52
53
|
# @return [Fixnum]
|
53
54
|
def x
|
55
|
+
@x = 1 if @x <= 1
|
56
|
+
@x = Terminal.width if @x >= Terminal.width
|
57
|
+
|
54
58
|
if @x <= left
|
55
59
|
@x = left
|
56
60
|
|
@@ -64,10 +68,14 @@ module Vedeu
|
|
64
68
|
end
|
65
69
|
|
66
70
|
# Returns the y coordinate (row/line) of the cursor. Attempts to sensibly
|
67
|
-
# reposition the cursor if it is currently outside the interface
|
71
|
+
# reposition the cursor if it is currently outside the interface, or outside
|
72
|
+
# the visible area of the terminal.
|
68
73
|
#
|
69
74
|
# @return [Fixnum]
|
70
75
|
def y
|
76
|
+
@y = 1 if @y <= 1
|
77
|
+
@y = Terminal.height if @y >= Terminal.height
|
78
|
+
|
71
79
|
if @y <= top
|
72
80
|
@y = top
|
73
81
|
|
@@ -114,17 +122,6 @@ module Vedeu
|
|
114
122
|
end
|
115
123
|
end
|
116
124
|
|
117
|
-
# Return a boolean indicating the visibility of the cursor, invisible if
|
118
|
-
# the state is not defined.
|
119
|
-
#
|
120
|
-
# @return [Boolean]
|
121
|
-
def visible?
|
122
|
-
return false unless states.include?(state)
|
123
|
-
return false if state == :hide
|
124
|
-
|
125
|
-
true
|
126
|
-
end
|
127
|
-
|
128
125
|
private
|
129
126
|
|
130
127
|
# Returns the escape sequence to position the cursor and set its visibility.
|
@@ -145,7 +142,7 @@ module Vedeu
|
|
145
142
|
#
|
146
143
|
# @return [String]
|
147
144
|
def visibility
|
148
|
-
return Esc.string('show_cursor') if
|
145
|
+
return Esc.string('show_cursor') if state == :show
|
149
146
|
|
150
147
|
Esc.string('hide_cursor')
|
151
148
|
end
|
@@ -162,22 +159,15 @@ module Vedeu
|
|
162
159
|
@interface ||= Interfaces.build(name)
|
163
160
|
end
|
164
161
|
|
165
|
-
# The valid visibility states for the cursor.
|
166
|
-
#
|
167
|
-
# @return [Array]
|
168
|
-
def states
|
169
|
-
[:show, :hide]
|
170
|
-
end
|
171
|
-
|
172
162
|
# The default values for a new instance of Cursor.
|
173
163
|
#
|
174
164
|
# @return [Hash]
|
175
165
|
def defaults
|
176
166
|
{
|
177
|
-
name:
|
178
|
-
state:
|
179
|
-
x:
|
180
|
-
y:
|
167
|
+
name: '',
|
168
|
+
state: :hide,
|
169
|
+
x: 1,
|
170
|
+
y: 1,
|
181
171
|
}
|
182
172
|
end
|
183
173
|
|