vedeu 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/lib/vedeu/bindings/application.rb +1 -4
- data/lib/vedeu/bindings/movement.rb +40 -76
- data/lib/vedeu/colours/colour_translator.rb +2 -2
- data/lib/vedeu/cursor/cursor.rb +2 -9
- data/lib/vedeu/distributed/uri.rb +1 -1
- data/lib/vedeu/geometry/coordinate.rb +27 -49
- data/lib/vedeu/geometry/position.rb +1 -1
- data/lib/vedeu/log/log.rb +16 -4
- data/lib/vedeu/output/esc.rb +7 -7
- data/lib/vedeu/output/html_char.rb +5 -5
- data/lib/vedeu/output/presentation.rb +2 -2
- data/lib/vedeu/output/wordwrap.rb +1 -1
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/bindings/movement_test.rb +4 -1
- data/test/lib/vedeu/cursor/cursor_test.rb +17 -3
- data/test/lib/vedeu/cursor/move_test.rb +35 -49
- data/test/lib/vedeu/events/event_aliases_test.rb +2 -6
- data/test/lib/vedeu/geometry/geometry_test.rb +0 -2
- data/test/lib/vedeu/log/log_test.rb +1 -1
- data/test/lib/vedeu/models/interface_test.rb +6 -2
- data/test/lib/vedeu/runtime/application_test.rb +2 -0
- data/test/lib/vedeu/terminal_test.rb +2 -0
- data/test/test_helper.rb +0 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52f99e59a2bd4ab818933894f1954ab87447ca02
|
4
|
+
data.tar.gz: 137357a572a617e95530c6300beb880ec541f517
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d9db9d21a9bc04bda9b3039cef7aca59be615c0ac1ed1b0064855420e84a80cf58b978e533e8bb03319165a947a714129384751bef5f3729edcb11d6656d9be
|
7
|
+
data.tar.gz: 5e7aaaf8b00d308237e4a46886ef7b61bd1eac408cf091df3f65fbb605d8c2f2687cbd932aa514d1b8a87314ad978dec6fe890a0737d882f60d83cc427d488f0
|
data/.travis.yml
CHANGED
@@ -31,10 +31,7 @@ module Vedeu
|
|
31
31
|
Vedeu::Router.goto(controller, action, **args)
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
|
-
Vedeu.bind(:_action_) do |controller, action, **args|
|
36
|
-
Vedeu.trigger(:_goto_, controller, action, **args)
|
37
|
-
end
|
34
|
+
Vedeu.bind_alias(:_action_, :_goto_)
|
38
35
|
end
|
39
36
|
|
40
37
|
end # Application
|
@@ -13,45 +13,57 @@ module Vedeu
|
|
13
13
|
#
|
14
14
|
# @return [TrueClass]
|
15
15
|
def setup!
|
16
|
-
cursor_down!
|
17
|
-
cursor_left!
|
18
16
|
cursor_origin!
|
19
17
|
cursor_position!
|
20
18
|
cursor_reposition!
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
geometry_right!
|
26
|
-
geometry_up!
|
19
|
+
down!
|
20
|
+
left!
|
21
|
+
right!
|
22
|
+
up!
|
27
23
|
end
|
28
24
|
|
29
25
|
private
|
30
26
|
|
31
|
-
# Move the cursor down by one character.
|
27
|
+
# Move the cursor/view down by one character.
|
32
28
|
#
|
33
29
|
# @example
|
34
30
|
# Vedeu.trigger(:_cursor_down_, name)
|
31
|
+
# Vedeu.trigger(:_view_down_, name)
|
32
|
+
# Vedeu.trigger(:_geometry_down_, name)
|
35
33
|
#
|
36
34
|
# @return [TrueClass]
|
37
35
|
# @see Vedeu::Move
|
38
|
-
def
|
36
|
+
def down!
|
39
37
|
Vedeu.bind(:_cursor_down_) do |name|
|
40
38
|
Vedeu::Move.by_name(Vedeu::Cursor, :down, name)
|
41
39
|
end
|
40
|
+
|
41
|
+
Vedeu.bind(:_view_down_) do |name|
|
42
|
+
Vedeu::Move.by_name(Vedeu::Geometry, :down, name)
|
43
|
+
end
|
44
|
+
|
45
|
+
Vedeu.bind_alias(:_geometry_down_, :_view_down_)
|
42
46
|
end
|
43
47
|
|
44
|
-
# Move the cursor left by one character.
|
48
|
+
# Move the cursor/view left by one character.
|
45
49
|
#
|
46
50
|
# @example
|
47
51
|
# Vedeu.trigger(:_cursor_left_, name)
|
52
|
+
# Vedeu.trigger(:_view_left_, name)
|
53
|
+
# Vedeu.trigger(:_geometry_left_, name)
|
48
54
|
#
|
49
55
|
# @return [TrueClass]
|
50
56
|
# @see Vedeu::Move
|
51
|
-
def
|
57
|
+
def left!
|
52
58
|
Vedeu.bind(:_cursor_left_) do |name|
|
53
59
|
Vedeu::Move.by_name(Vedeu::Cursor, :left, name)
|
54
60
|
end
|
61
|
+
|
62
|
+
Vedeu.bind(:_view_left_) do |name|
|
63
|
+
Vedeu::Move.by_name(Vedeu::Geometry, :left, name)
|
64
|
+
end
|
65
|
+
|
66
|
+
Vedeu.bind_alias(:_geometry_left_, :_view_left_)
|
55
67
|
end
|
56
68
|
|
57
69
|
# This event moves the cursor to the interface origin; the top left corner
|
@@ -99,94 +111,46 @@ module Vedeu
|
|
99
111
|
end
|
100
112
|
end
|
101
113
|
|
102
|
-
# Move the cursor right by one character.
|
114
|
+
# Move the cursor/view right by one character.
|
103
115
|
#
|
104
116
|
# @example
|
105
117
|
# Vedeu.trigger(:_cursor_right_, name)
|
118
|
+
# Vedeu.trigger(:_view_right_, name)
|
119
|
+
# Vedeu.trigger(:_geometry_right_, name)
|
106
120
|
#
|
107
121
|
# @return [TrueClass]
|
108
122
|
# @see Vedeu::Move
|
109
|
-
def
|
123
|
+
def right!
|
110
124
|
Vedeu.bind(:_cursor_right_) do |name|
|
111
125
|
Vedeu::Move.by_name(Vedeu::Cursor, :right, name)
|
112
126
|
end
|
113
|
-
end
|
114
|
-
|
115
|
-
# Move the cursor up by one character.
|
116
|
-
#
|
117
|
-
# @example
|
118
|
-
# Vedeu.trigger(:_cursor_up, name)
|
119
|
-
#
|
120
|
-
# @return [TrueClass]
|
121
|
-
# @see Vedeu::Move
|
122
|
-
def cursor_up!
|
123
|
-
Vedeu.bind(:_cursor_up_) do |name|
|
124
|
-
Vedeu::Move.by_name(Vedeu::Cursor, :up, name)
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
# Move the geometry down by one character.
|
129
|
-
#
|
130
|
-
# @example
|
131
|
-
# Vedeu.trigger(:_geometry_down_, name)
|
132
|
-
# Vedeu.trigger(:_view_down_, name)
|
133
|
-
#
|
134
|
-
# @return [TrueClass]
|
135
|
-
# @see Vedeu::Move
|
136
|
-
def geometry_down!
|
137
|
-
Vedeu.bind(:_geometry_down_) do |name|
|
138
|
-
Vedeu::Move.by_name(Vedeu::Geometry, :down, name)
|
139
|
-
end
|
140
|
-
|
141
|
-
Vedeu.bind_alias(:_view_down_, :_geometry_down_)
|
142
|
-
end
|
143
|
-
|
144
|
-
# Move the geometry left by one character.
|
145
|
-
#
|
146
|
-
# @example
|
147
|
-
# Vedeu.trigger(:_geometry_left_, name)
|
148
|
-
# Vedeu.trigger(:_view_left_, name)
|
149
|
-
#
|
150
|
-
# @return [TrueClass]
|
151
|
-
# @see Vedeu::Move
|
152
|
-
def geometry_left!
|
153
|
-
Vedeu.bind(:_geometry_left_) do |name|
|
154
|
-
Vedeu::Move.by_name(Vedeu::Geometry, :left, name)
|
155
|
-
end
|
156
127
|
|
157
|
-
Vedeu.
|
158
|
-
end
|
159
|
-
|
160
|
-
# Move the geometry right by one character.
|
161
|
-
#
|
162
|
-
# @example
|
163
|
-
# Vedeu.trigger(:_geometry_right_, name)
|
164
|
-
# Vedeu.trigger(:_view_right_, name)
|
165
|
-
#
|
166
|
-
# @return [TrueClass]
|
167
|
-
# @see Vedeu::Move
|
168
|
-
def geometry_right!
|
169
|
-
Vedeu.bind(:_geometry_right_) do |name|
|
128
|
+
Vedeu.bind(:_view_right_) do |name|
|
170
129
|
Vedeu::Move.by_name(Vedeu::Geometry, :right, name)
|
171
130
|
end
|
172
131
|
|
173
|
-
Vedeu.bind_alias(:
|
132
|
+
Vedeu.bind_alias(:_geometry_right_, :_view_right_)
|
174
133
|
end
|
175
134
|
|
176
|
-
# Move the
|
135
|
+
# Move the cursor/view up by one character.
|
177
136
|
#
|
178
137
|
# @example
|
179
|
-
# Vedeu.trigger(:
|
138
|
+
# Vedeu.trigger(:_cursor_up, name)
|
180
139
|
# Vedeu.trigger(:_view_up_, name)
|
140
|
+
# Vedeu.trigger(:_geometry_up_, name)
|
181
141
|
#
|
182
142
|
# @return [TrueClass]
|
183
143
|
# @see Vedeu::Move
|
184
|
-
def
|
185
|
-
Vedeu.bind(:
|
144
|
+
def up!
|
145
|
+
Vedeu.bind(:_cursor_up_) do |name|
|
146
|
+
Vedeu::Move.by_name(Vedeu::Cursor, :up, name)
|
147
|
+
end
|
148
|
+
|
149
|
+
Vedeu.bind(:_view_up_) do |name|
|
186
150
|
Vedeu::Move.by_name(Vedeu::Geometry, :up, name)
|
187
151
|
end
|
188
152
|
|
189
|
-
Vedeu.bind_alias(:
|
153
|
+
Vedeu.bind_alias(:_geometry_up_, :_view_up_)
|
190
154
|
end
|
191
155
|
|
192
156
|
end # Movement
|
@@ -141,7 +141,7 @@ module Vedeu
|
|
141
141
|
#
|
142
142
|
# @return [String]
|
143
143
|
def named
|
144
|
-
|
144
|
+
"\e[#{named_codes}m"
|
145
145
|
end
|
146
146
|
|
147
147
|
# Returns a boolean indicating whether the colour provided is a valid named
|
@@ -164,7 +164,7 @@ module Vedeu
|
|
164
164
|
#
|
165
165
|
# @return [String]
|
166
166
|
def numbered
|
167
|
-
|
167
|
+
"#{numbered_prefix}#{css_to_numbered}m"
|
168
168
|
end
|
169
169
|
|
170
170
|
# Returns a boolean indicated whether the colour is a valid HTML/CSS colour.
|
data/lib/vedeu/cursor/cursor.rb
CHANGED
@@ -80,10 +80,10 @@ module Vedeu
|
|
80
80
|
# @return [String]
|
81
81
|
def to_s
|
82
82
|
if block_given?
|
83
|
-
|
83
|
+
"#{position}#{yield}#{position}#{visibility}"
|
84
84
|
|
85
85
|
else
|
86
|
-
|
86
|
+
"#{position}#{visibility}"
|
87
87
|
|
88
88
|
end
|
89
89
|
end
|
@@ -139,13 +139,6 @@ module Vedeu
|
|
139
139
|
}
|
140
140
|
end
|
141
141
|
|
142
|
-
# Returns the escape sequence to position the cursor and set its visibility.
|
143
|
-
#
|
144
|
-
# @return [String]
|
145
|
-
def sequence
|
146
|
-
[position, visibility].join
|
147
|
-
end
|
148
|
-
|
149
142
|
# Returns the escape sequence for setting the visibility of the cursor.
|
150
143
|
#
|
151
144
|
# @return [String]
|
@@ -75,18 +75,14 @@ module Vedeu
|
|
75
75
|
#
|
76
76
|
# @return [Fixnum]
|
77
77
|
def y_position
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
validate_y(value)
|
78
|
+
pos = case
|
79
|
+
when oy <= 0 then y
|
80
|
+
when oy > yn_index then yn
|
81
|
+
else
|
82
|
+
y_range[oy]
|
83
|
+
end
|
84
|
+
|
85
|
+
validate_y(pos)
|
90
86
|
end
|
91
87
|
|
92
88
|
# Returns the x coordinate for a given index.
|
@@ -100,18 +96,14 @@ module Vedeu
|
|
100
96
|
#
|
101
97
|
# @return [Fixnum]
|
102
98
|
def x_position
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
end
|
113
|
-
|
114
|
-
validate_x(value)
|
99
|
+
pos = case
|
100
|
+
when ox <= 0 then x
|
101
|
+
when ox > xn_index then xn
|
102
|
+
else
|
103
|
+
x_range[ox]
|
104
|
+
end
|
105
|
+
|
106
|
+
validate_x(pos)
|
115
107
|
end
|
116
108
|
|
117
109
|
protected
|
@@ -159,9 +151,13 @@ module Vedeu
|
|
159
151
|
#
|
160
152
|
# @return [Fixnum]
|
161
153
|
def yn_index
|
162
|
-
|
154
|
+
if height < 1
|
155
|
+
0
|
156
|
+
|
157
|
+
else
|
158
|
+
height - 1
|
163
159
|
|
164
|
-
|
160
|
+
end
|
165
161
|
end
|
166
162
|
|
167
163
|
# Returns the maximum x index for an area.
|
@@ -172,31 +168,13 @@ module Vedeu
|
|
172
168
|
#
|
173
169
|
# @return [Fixnum]
|
174
170
|
def xn_index
|
175
|
-
|
176
|
-
|
177
|
-
x_indices.last
|
178
|
-
end
|
171
|
+
if width < 1
|
172
|
+
0
|
179
173
|
|
180
|
-
|
181
|
-
|
182
|
-
# @example
|
183
|
-
# # height = 4
|
184
|
-
# y_indices # => [0, 1, 2, 3]
|
185
|
-
#
|
186
|
-
# @return [Array]
|
187
|
-
def y_indices
|
188
|
-
(0...height).to_a
|
189
|
-
end
|
174
|
+
else
|
175
|
+
width - 1
|
190
176
|
|
191
|
-
|
192
|
-
#
|
193
|
-
# @example
|
194
|
-
# # width = 10
|
195
|
-
# x_indices # => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
196
|
-
#
|
197
|
-
# @return [Array]
|
198
|
-
def x_indices
|
199
|
-
(0...width).to_a
|
177
|
+
end
|
200
178
|
end
|
201
179
|
|
202
180
|
# Returns an array with all coordinates from x to xn.
|
data/lib/vedeu/log/log.rb
CHANGED
@@ -95,7 +95,7 @@ module Vedeu
|
|
95
95
|
#
|
96
96
|
# @return [TrueClass]
|
97
97
|
def log(message:, force: false, type: :info)
|
98
|
-
output =
|
98
|
+
output = log_entry(type, message)
|
99
99
|
|
100
100
|
logger.debug(output) if enabled? || force
|
101
101
|
|
@@ -106,14 +106,14 @@ module Vedeu
|
|
106
106
|
#
|
107
107
|
# @return [TrueClass]
|
108
108
|
def log_stdout(type: :info, message:)
|
109
|
-
$stdout.puts
|
109
|
+
$stdout.puts log_entry(type, message)
|
110
110
|
end
|
111
111
|
|
112
112
|
# Write a message to STDERR.
|
113
113
|
#
|
114
114
|
# @return [TrueClass]
|
115
115
|
def log_stderr(type: :info, message:)
|
116
|
-
$stderr.puts
|
116
|
+
$stderr.puts log_entry(type, message)
|
117
117
|
end
|
118
118
|
|
119
119
|
private
|
@@ -135,7 +135,19 @@ module Vedeu
|
|
135
135
|
# combined.
|
136
136
|
# @return [String]
|
137
137
|
def formatted_message(message)
|
138
|
-
|
138
|
+
"#{timestamp}#{message}\n"
|
139
|
+
end
|
140
|
+
|
141
|
+
# Returns the message:
|
142
|
+
#
|
143
|
+
# [type] message
|
144
|
+
#
|
145
|
+
# @param type [Symbol] The type of log message.
|
146
|
+
# @param message [String] The message you wish to emit to the log file,
|
147
|
+
# useful for debugging.
|
148
|
+
# @return [String]
|
149
|
+
def log_entry(type, message)
|
150
|
+
"#{message_type(type)}#{message_body(type, message)}"
|
139
151
|
end
|
140
152
|
|
141
153
|
# Fetches the filename from the configuration.
|
data/lib/vedeu/output/esc.rb
CHANGED
@@ -42,39 +42,39 @@ module Vedeu
|
|
42
42
|
def border
|
43
43
|
return '' unless block_given?
|
44
44
|
|
45
|
-
|
45
|
+
"#{border_on}#{yield}#{border_off}"
|
46
46
|
end
|
47
47
|
|
48
48
|
private
|
49
49
|
|
50
50
|
# @return [String]
|
51
51
|
def clear
|
52
|
-
|
52
|
+
"#{colour_reset}\e[2J"
|
53
53
|
end
|
54
54
|
|
55
55
|
# @return [String]
|
56
56
|
def clear_line
|
57
|
-
|
57
|
+
"#{colour_reset}\e[2K"
|
58
58
|
end
|
59
59
|
|
60
60
|
# @return [String]
|
61
61
|
def colour_reset
|
62
|
-
|
62
|
+
"#{fg_reset}#{bg_reset}"
|
63
63
|
end
|
64
64
|
|
65
65
|
# @return [String]
|
66
66
|
def normal
|
67
|
-
|
67
|
+
"#{underline_off}#{bold_off}#{positive}"
|
68
68
|
end
|
69
69
|
|
70
70
|
# @return [String]
|
71
71
|
def screen_init
|
72
|
-
|
72
|
+
"#{reset}#{clear}#{hide_cursor}"
|
73
73
|
end
|
74
74
|
|
75
75
|
# @return [String]
|
76
76
|
def screen_exit
|
77
|
-
|
77
|
+
"#{show_cursor}#{colour_reset}#{reset}#{last_character_position}\n"
|
78
78
|
end
|
79
79
|
|
80
80
|
# @return [String]
|
@@ -30,7 +30,7 @@ module Vedeu
|
|
30
30
|
|
31
31
|
# @return [String]
|
32
32
|
def render
|
33
|
-
|
33
|
+
"#{start_tag}#{tag_style}>#{tag_value}#{end_tag}"
|
34
34
|
end
|
35
35
|
|
36
36
|
protected
|
@@ -66,10 +66,10 @@ module Vedeu
|
|
66
66
|
when :left_vertical then css('left')
|
67
67
|
when :right_vertical then css('right')
|
68
68
|
when :bottom_horizontal then css('bottom')
|
69
|
-
when :top_left then
|
70
|
-
when :top_right then
|
71
|
-
when :bottom_left then
|
72
|
-
when :bottom_right then
|
69
|
+
when :top_left then "#{css('top')}#{css('left')}"
|
70
|
+
when :top_right then "#{css('top')}#{css('right')}"
|
71
|
+
when :bottom_left then "#{css('bottom')}#{css('left')}"
|
72
|
+
when :bottom_right then "#{css('bottom')}#{css('right')}"
|
73
73
|
else
|
74
74
|
''
|
75
75
|
end
|
@@ -28,7 +28,7 @@ module Vedeu
|
|
28
28
|
#
|
29
29
|
# @return [String]
|
30
30
|
def render_colour
|
31
|
-
|
31
|
+
"#{colour}#{yield}"
|
32
32
|
end
|
33
33
|
|
34
34
|
# @return [String]
|
@@ -47,7 +47,7 @@ module Vedeu
|
|
47
47
|
#
|
48
48
|
# @return [String]
|
49
49
|
def render_style
|
50
|
-
|
50
|
+
"#{style}#{yield}"
|
51
51
|
end
|
52
52
|
|
53
53
|
end # Presentation
|
data/lib/vedeu/version.rb
CHANGED
@@ -15,11 +15,14 @@ module Vedeu
|
|
15
15
|
it { Vedeu.bound?(:_cursor_reset_).must_equal(true) }
|
16
16
|
it { Vedeu.bound?(:_cursor_right_).must_equal(true) }
|
17
17
|
it { Vedeu.bound?(:_cursor_up_).must_equal(true) }
|
18
|
-
|
19
18
|
it { Vedeu.bound?(:_geometry_down_).must_equal(true) }
|
20
19
|
it { Vedeu.bound?(:_geometry_left_).must_equal(true) }
|
21
20
|
it { Vedeu.bound?(:_geometry_right_).must_equal(true) }
|
22
21
|
it { Vedeu.bound?(:_geometry_up_).must_equal(true) }
|
22
|
+
it { Vedeu.bound?(:_view_down_).must_equal(true) }
|
23
|
+
it { Vedeu.bound?(:_view_left_).must_equal(true) }
|
24
|
+
it { Vedeu.bound?(:_view_right_).must_equal(true) }
|
25
|
+
it { Vedeu.bound?(:_view_up_).must_equal(true) }
|
23
26
|
end
|
24
27
|
|
25
28
|
end # Movement
|
@@ -53,10 +53,17 @@ module Vedeu
|
|
53
53
|
end
|
54
54
|
|
55
55
|
describe '#hide' do
|
56
|
+
let(:visible) { true }
|
57
|
+
let(:hide_cursor) { Vedeu::Escape.new(Vedeu::Esc.hide_cursor) }
|
58
|
+
|
59
|
+
before {
|
60
|
+
Vedeu::Output.stubs(:render).
|
61
|
+
with(hide_cursor).returns(hide_cursor)
|
62
|
+
}
|
63
|
+
|
56
64
|
subject { instance.hide }
|
57
65
|
|
58
66
|
it { subject.must_be_instance_of(Vedeu::Escape) }
|
59
|
-
it { subject.to_s.must_equal("\e[?25l") }
|
60
67
|
end
|
61
68
|
|
62
69
|
describe '#inspect' do
|
@@ -75,10 +82,17 @@ module Vedeu
|
|
75
82
|
end
|
76
83
|
|
77
84
|
describe '#show' do
|
85
|
+
let(:visible) { false }
|
86
|
+
let(:show_cursor) { Vedeu::Escape.new(Vedeu::Esc.show_cursor) }
|
87
|
+
|
88
|
+
before {
|
89
|
+
Vedeu::Output.stubs(:render).
|
90
|
+
with(show_cursor).returns(show_cursor)
|
91
|
+
}
|
92
|
+
|
78
93
|
subject { instance.show }
|
79
94
|
|
80
95
|
it { subject.must_be_instance_of(Vedeu::Escape) }
|
81
|
-
it { subject.to_s.must_equal("\e[?25h") }
|
82
96
|
end
|
83
97
|
|
84
98
|
describe '#to_s' do
|
@@ -113,7 +127,7 @@ module Vedeu
|
|
113
127
|
it 'returns the escape sequence to position and set the visibility ' \
|
114
128
|
'of the cursor and returns to that position after yielding the ' \
|
115
129
|
'block' do
|
116
|
-
subject.must_equal("\e[8;19H\e[
|
130
|
+
subject.must_equal("\e[8;19H\e[8;19H\e[?25h")
|
117
131
|
end
|
118
132
|
end
|
119
133
|
end
|
@@ -15,41 +15,29 @@ module Vedeu
|
|
15
15
|
let(:x) { 1 }
|
16
16
|
let(:y) { 1 }
|
17
17
|
|
18
|
+
let(:cursor) {
|
19
|
+
Vedeu::Cursor.new(name: _name, ox: ox, oy: oy, visible: true, x: x, y: y)
|
20
|
+
}
|
21
|
+
let(:new_cursor) {
|
22
|
+
Vedeu::Cursor.new
|
23
|
+
}
|
24
|
+
let(:border) {
|
25
|
+
Vedeu::Border.new(name: '_name', enabled: enabled)
|
26
|
+
}
|
27
|
+
let(:enabled) { true }
|
28
|
+
let(:geometry) {
|
29
|
+
Vedeu::Geometry.new(name: _name, x: 5, xn: 10, y: 5, yn: 10)
|
30
|
+
}
|
31
|
+
|
18
32
|
before {
|
19
|
-
Vedeu::Cursor.new(name: 'move_with_border',
|
20
|
-
ox: ox,
|
21
|
-
oy: oy,
|
22
|
-
visible: true,
|
23
|
-
x: x,
|
24
|
-
y: y).store
|
25
|
-
Vedeu::Cursor.new(name: 'move_without_border',
|
26
|
-
ox: ox,
|
27
|
-
oy: oy,
|
28
|
-
visible: true,
|
29
|
-
x: x,
|
30
|
-
y: y).store
|
31
|
-
Vedeu.border 'move_with_border' do
|
32
|
-
# ...
|
33
|
-
end
|
34
|
-
Vedeu.geometry 'move_with_border' do
|
35
|
-
x 5
|
36
|
-
xn 10
|
37
|
-
y 5
|
38
|
-
yn 10
|
39
|
-
end
|
40
|
-
Vedeu.geometry 'move_without_border' do
|
41
|
-
x 5
|
42
|
-
xn 10
|
43
|
-
y 5
|
44
|
-
yn 10
|
45
|
-
end
|
46
33
|
IO.console.stubs(:winsize).returns([25, 80])
|
47
34
|
IO.console.stubs(:print)
|
48
|
-
|
49
|
-
|
50
|
-
Vedeu.
|
51
|
-
Vedeu.
|
52
|
-
|
35
|
+
|
36
|
+
Vedeu.borders.stubs(:by_name).returns(border)
|
37
|
+
Vedeu.cursors.stubs(:by_name).returns(cursor)
|
38
|
+
Vedeu.geometries.stubs(:by_name).returns(geometry)
|
39
|
+
|
40
|
+
Vedeu.stubs(:trigger).with(:_refresh_cursor_, _name)
|
53
41
|
}
|
54
42
|
|
55
43
|
describe '#initialize' do
|
@@ -63,11 +51,12 @@ module Vedeu
|
|
63
51
|
describe '.by_name' do
|
64
52
|
let(:direction) { :down }
|
65
53
|
let(:_name) { 'manganese' }
|
54
|
+
let(:oy) { 2 }
|
55
|
+
let(:ox) { 3 }
|
56
|
+
let(:x) { 8 }
|
57
|
+
let(:y) { 7 }
|
66
58
|
|
67
|
-
before {
|
68
|
-
Vedeu::Cursor.new(name: 'manganese', oy: 2, ox: 3, x: 8, y: 7).store
|
69
|
-
Vedeu.stubs(:focus).returns('neon')
|
70
|
-
}
|
59
|
+
before { Vedeu.stubs(:focus).returns('neon') }
|
71
60
|
|
72
61
|
subject { described.by_name(entity, direction, _name) }
|
73
62
|
|
@@ -115,9 +104,8 @@ module Vedeu
|
|
115
104
|
|
116
105
|
it { subject.must_be_instance_of(Vedeu::Cursor) }
|
117
106
|
|
118
|
-
it { subject.y.must_equal(2) }
|
119
|
-
|
120
107
|
context 'when within the boundary of the interface' do
|
108
|
+
let(:enabled) { false }
|
121
109
|
let(:_name) { 'move_without_border' }
|
122
110
|
let(:oy) { 15 }
|
123
111
|
|
@@ -127,6 +115,7 @@ module Vedeu
|
|
127
115
|
end
|
128
116
|
|
129
117
|
context 'when within the border of the interface' do
|
118
|
+
let(:enabled) { true }
|
130
119
|
let(:_name) { 'move_with_border' }
|
131
120
|
let(:oy) { 15 }
|
132
121
|
|
@@ -143,9 +132,8 @@ module Vedeu
|
|
143
132
|
|
144
133
|
it { subject.must_be_instance_of(Vedeu::Cursor) }
|
145
134
|
|
146
|
-
it { subject.x.must_equal(1) }
|
147
|
-
|
148
135
|
context 'when within the boundary of the interface' do
|
136
|
+
let(:enabled) { false }
|
149
137
|
let(:_name) { 'move_without_border' }
|
150
138
|
|
151
139
|
it 'does not move past the left of the interface' do
|
@@ -154,6 +142,7 @@ module Vedeu
|
|
154
142
|
end
|
155
143
|
|
156
144
|
context 'when within the border of the interface' do
|
145
|
+
let(:enabled) { true }
|
157
146
|
let(:_name) { 'move_with_border' }
|
158
147
|
|
159
148
|
it 'does not move past the left border' do
|
@@ -169,9 +158,8 @@ module Vedeu
|
|
169
158
|
|
170
159
|
it { subject.must_be_instance_of(Vedeu::Cursor) }
|
171
160
|
|
172
|
-
it { subject.x.must_equal(2) }
|
173
|
-
|
174
161
|
context 'when within the boundary of the interface' do
|
162
|
+
let(:enabled) { false }
|
175
163
|
let(:_name) { 'move_without_border' }
|
176
164
|
let(:ox) { 15 }
|
177
165
|
|
@@ -181,6 +169,7 @@ module Vedeu
|
|
181
169
|
end
|
182
170
|
|
183
171
|
context 'when within the border of the interface' do
|
172
|
+
let(:enabled) { true }
|
184
173
|
let(:_name) { 'move_with_border' }
|
185
174
|
let(:ox) { 15 }
|
186
175
|
|
@@ -197,9 +186,8 @@ module Vedeu
|
|
197
186
|
|
198
187
|
it { subject.must_be_instance_of(Vedeu::Cursor) }
|
199
188
|
|
200
|
-
it { subject.y.must_equal(1) }
|
201
|
-
|
202
189
|
context 'when within the boundary of the interface' do
|
190
|
+
let(:enabled) { false }
|
203
191
|
let(:_name) { 'move_without_border' }
|
204
192
|
|
205
193
|
it 'does not move past the top of the interface' do
|
@@ -208,6 +196,7 @@ module Vedeu
|
|
208
196
|
end
|
209
197
|
|
210
198
|
context 'when within the border of the interface' do
|
199
|
+
let(:enabled) { true }
|
211
200
|
let(:_name) { 'move_with_border' }
|
212
201
|
|
213
202
|
it 'does not move past the top border' do
|
@@ -223,12 +212,8 @@ module Vedeu
|
|
223
212
|
|
224
213
|
it { subject.must_be_instance_of(Vedeu::Cursor) }
|
225
214
|
|
226
|
-
context 'within the visible area for the console' do
|
227
|
-
it { subject.x.must_equal(1) }
|
228
|
-
it { subject.y.must_equal(1) }
|
229
|
-
end
|
230
|
-
|
231
215
|
context 'within the boundary of the interface' do
|
216
|
+
let(:enabled) { false }
|
232
217
|
let(:_name) { 'move_without_border' }
|
233
218
|
|
234
219
|
it { subject.x.must_equal(5) }
|
@@ -236,6 +221,7 @@ module Vedeu
|
|
236
221
|
end
|
237
222
|
|
238
223
|
context 'within the border of the interface' do
|
224
|
+
let(:enabled) { true }
|
239
225
|
let(:_name) { 'move_with_border' }
|
240
226
|
|
241
227
|
it { subject.x.must_equal(6) }
|
@@ -6,12 +6,8 @@ module Vedeu
|
|
6
6
|
|
7
7
|
let(:described) { Vedeu::EventAliases }
|
8
8
|
|
9
|
-
before
|
10
|
-
|
11
|
-
end
|
12
|
-
after do
|
13
|
-
Vedeu::Bindings.setup!
|
14
|
-
end
|
9
|
+
before { Vedeu::EventAliases.reset }
|
10
|
+
after { Vedeu::Bindings.setup! }
|
15
11
|
|
16
12
|
describe '.add' do
|
17
13
|
let(:alias_name) { :alias_test }
|
@@ -95,7 +95,6 @@ module Vedeu
|
|
95
95
|
subject { instance.maximise }
|
96
96
|
|
97
97
|
it { subject.must_be_instance_of(described) }
|
98
|
-
|
99
98
|
it { subject.maximised.must_equal(true) }
|
100
99
|
end
|
101
100
|
|
@@ -114,7 +113,6 @@ module Vedeu
|
|
114
113
|
subject { instance.unmaximise }
|
115
114
|
|
116
115
|
it { subject.must_be_instance_of(described) }
|
117
|
-
|
118
116
|
it { subject.maximised.must_equal(false) }
|
119
117
|
end
|
120
118
|
|
@@ -138,12 +138,16 @@ module Vedeu
|
|
138
138
|
let(:view) { mock('Vedeu::Viewport') }
|
139
139
|
|
140
140
|
before {
|
141
|
+
Vedeu.stubs(:trigger).with(:_hide_cursor_, _name)
|
142
|
+
|
141
143
|
Vedeu::Clear::NamedInterface.stubs(:render).returns(:clear)
|
142
144
|
|
145
|
+
Vedeu::Viewport.stubs(:render).returns(:view)
|
146
|
+
|
143
147
|
Vedeu.borders.stubs(:by_name).returns(border)
|
144
148
|
border.stubs(:render).returns(:border)
|
145
|
-
|
146
|
-
|
149
|
+
|
150
|
+
Vedeu.stubs(:trigger).with(:_show_cursor_, _name)
|
147
151
|
}
|
148
152
|
|
149
153
|
subject { instance.render }
|
data/test/test_helper.rb
CHANGED
@@ -5,11 +5,6 @@ require 'minitest/autorun'
|
|
5
5
|
require 'minitest/pride' unless ENV['NO_COLOR']
|
6
6
|
require 'minitest/hell'
|
7
7
|
|
8
|
-
# Notes: (2015-07-20)
|
9
|
-
#
|
10
|
-
# On my MacBookPro 6,2 (Mid-2010), the test speed is around 0.9s to 1.1s.
|
11
|
-
# On my Raspberry Pi 2 (Early 2015), the test speed is around 6.5s to 7.0s.
|
12
|
-
|
13
8
|
# GC.disable # Uncomment to remove ~20ms from test run speed; left uncommented
|
14
9
|
# though makes tests slower over time with 'guard'.
|
15
10
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vedeu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Laking
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|