vedeu 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +40 -0
- data/README.md +1 -0
- data/docs/dsl.md +24 -24
- data/lib/vedeu/all.rb +21 -44
- data/lib/vedeu/api.rb +13 -13
- data/lib/vedeu/application/application_controller.rb +2 -0
- data/lib/vedeu/bindings/movement.rb +53 -18
- data/lib/vedeu/bindings/refresh.rb +1 -1
- data/lib/vedeu/bindings/system.rb +2 -2
- data/lib/vedeu/bindings/visibility.rb +3 -3
- data/lib/vedeu/borders/all.rb +13 -0
- data/lib/vedeu/borders/border.rb +209 -202
- data/lib/vedeu/{dsl/border.rb → borders/dsl.rb} +15 -15
- data/lib/vedeu/{null/border.rb → borders/null.rb} +9 -9
- data/lib/vedeu/borders/render.rb +347 -0
- data/lib/vedeu/borders/repository.rb +19 -0
- data/lib/vedeu/buffers/all.rb +13 -0
- data/lib/vedeu/buffers/buffer.rb +182 -176
- data/lib/vedeu/{null/buffer.rb → buffers/null.rb} +8 -8
- data/lib/vedeu/buffers/repository.rb +24 -0
- data/lib/vedeu/buffers/virtual_buffer.rb +2 -2
- data/lib/vedeu/cursors/all.rb +11 -0
- data/lib/vedeu/cursors/cursor.rb +276 -0
- data/lib/vedeu/cursors/refresh.rb +84 -0
- data/lib/vedeu/cursors/repository.rb +34 -0
- data/lib/vedeu/dsl/interface.rb +9 -9
- data/lib/vedeu/dsl/shared.rb +11 -11
- data/lib/vedeu/{exceptions.rb → error.rb} +2 -2
- data/lib/vedeu/esc/esc.rb +1 -1
- data/lib/vedeu/geometry/all.rb +18 -0
- data/lib/vedeu/geometry/area.rb +170 -160
- data/lib/vedeu/geometry/coordinate.rb +61 -39
- data/lib/vedeu/geometry/dimension.rb +139 -132
- data/lib/vedeu/{dsl/geometry.rb → geometry/dsl.rb} +11 -11
- data/lib/vedeu/geometry/generic_coordinate.rb +159 -153
- data/lib/vedeu/geometry/geometry.rb +310 -212
- data/lib/vedeu/geometry/grid.rb +73 -69
- data/lib/vedeu/{null/geometry.rb → geometry/null.rb} +10 -10
- data/lib/vedeu/geometry/position.rb +124 -120
- data/lib/vedeu/geometry/repository.rb +19 -0
- data/lib/vedeu/input/editor/document.rb +2 -2
- data/lib/vedeu/internal_api.rb +8 -8
- data/lib/vedeu/models/escape.rb +2 -2
- data/lib/vedeu/models/interface.rb +1 -1
- data/lib/vedeu/models/page.rb +89 -0
- data/lib/vedeu/models/row.rb +66 -0
- data/lib/vedeu/models/toggleable.rb +1 -1
- data/lib/vedeu/models/views/char.rb +7 -6
- data/lib/vedeu/models/views/line.rb +1 -1
- data/lib/vedeu/models/views/view.rb +2 -2
- data/lib/vedeu/options.rb +19 -0
- data/lib/vedeu/output/clear/named_interface.rb +1 -1
- data/lib/vedeu/output/direct.rb +1 -1
- data/lib/vedeu/output/presentation.rb +2 -1
- data/lib/vedeu/output/viewport.rb +3 -3
- data/lib/vedeu/repositories/model.rb +9 -1
- data/lib/vedeu/repositories/repository.rb +5 -0
- data/lib/vedeu/terminal/terminal.rb +3 -3
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/borders/border_test.rb +299 -291
- data/test/lib/vedeu/{dsl/border_test.rb → borders/dsl_test.rb} +6 -6
- data/test/lib/vedeu/{null/border_test.rb → borders/null_test.rb} +6 -6
- data/test/lib/vedeu/borders/render_test.rb +125 -0
- data/test/lib/vedeu/borders/repository_test.rb +17 -0
- data/test/lib/vedeu/buffers/buffer_test.rb +116 -112
- data/test/lib/vedeu/{null/buffer_test.rb → buffers/null_test.rb} +5 -5
- data/test/lib/vedeu/buffers/repository_test.rb +18 -0
- data/test/lib/vedeu/cursors/cursor_test.rb +370 -0
- data/test/lib/vedeu/cursors/refresh_test.rb +69 -0
- data/test/lib/vedeu/cursors/repository_test.rb +41 -0
- data/test/lib/vedeu/dsl/interface_test.rb +5 -5
- data/test/lib/vedeu/{exceptions_test.rb → error_test.rb} +0 -0
- data/test/lib/vedeu/geometry/area_test.rb +141 -137
- data/test/lib/vedeu/geometry/coordinate_test.rb +93 -89
- data/test/lib/vedeu/geometry/dimension_test.rb +137 -133
- data/test/lib/vedeu/{dsl/geometry_test.rb → geometry/dsl_test.rb} +17 -17
- data/test/lib/vedeu/geometry/generic_coordinate_test.rb +32 -28
- data/test/lib/vedeu/geometry/geometry_test.rb +282 -157
- data/test/lib/vedeu/geometry/grid_test.rb +35 -31
- data/test/lib/vedeu/{null/geometry_test.rb → geometry/null_test.rb} +5 -5
- data/test/lib/vedeu/geometry/position_test.rb +146 -142
- data/test/lib/vedeu/geometry/repository_test.rb +19 -0
- data/test/lib/vedeu/input/editor/document_test.rb +1 -1
- data/test/lib/vedeu/models/escape_test.rb +1 -1
- data/test/lib/vedeu/models/interface_test.rb +2 -2
- data/test/lib/vedeu/models/page_test.rb +235 -0
- data/test/lib/vedeu/models/row_test.rb +111 -0
- data/test/lib/vedeu/models/views/char_test.rb +3 -3
- data/test/lib/vedeu/options_test.rb +57 -0
- data/test/lib/vedeu/output/clear/named_interface_test.rb +1 -1
- data/test/lib/vedeu/output/renderers/json_test.rb +1 -1
- data/test/lib/vedeu/output/viewport_test.rb +15 -9
- data/test/lib/vedeu/refresh/refresh_buffer_test.rb +12 -12
- data/test/lib/vedeu/repositories/repositories_test.rb +1 -1
- data/test/lib/vedeu/repositories/repository_test.rb +7 -0
- data/test/lib/vedeu/terminal/terminal_test.rb +1 -1
- data/test/test_helper.rb +1 -1
- data/vedeu.gemspec +2 -2
- metadata +57 -63
- data/lib/vedeu/borders/borders.rb +0 -15
- data/lib/vedeu/borders/render_border.rb +0 -331
- data/lib/vedeu/buffers/buffers.rb +0 -20
- data/lib/vedeu/cursor/cursor.rb +0 -174
- data/lib/vedeu/cursor/cursors.rb +0 -30
- data/lib/vedeu/cursor/move.rb +0 -239
- data/lib/vedeu/cursor/reposition.rb +0 -78
- data/lib/vedeu/geometry/geometries.rb +0 -15
- data/lib/vedeu/refresh/refresh_cursor.rb +0 -92
- data/test/lib/vedeu/borders/borders_test.rb +0 -13
- data/test/lib/vedeu/borders/render_border_test.rb +0 -121
- data/test/lib/vedeu/buffers/buffers_test.rb +0 -14
- data/test/lib/vedeu/cursor/cursor_test.rb +0 -246
- data/test/lib/vedeu/cursor/cursors_test.rb +0 -37
- data/test/lib/vedeu/cursor/move_test.rb +0 -301
- data/test/lib/vedeu/cursor/reposition_test.rb +0 -63
- data/test/lib/vedeu/geometry/geometries_test.rb +0 -15
- data/test/lib/vedeu/refresh/refresh_cursor_test.rb +0 -65
data/lib/vedeu/cursor/cursors.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
module Vedeu
|
2
|
-
|
3
|
-
# Allows the storing of each interface's cursor.
|
4
|
-
#
|
5
|
-
class Cursors < Vedeu::Repository
|
6
|
-
|
7
|
-
singleton_class.send(:alias_method, :cursors, :repository)
|
8
|
-
|
9
|
-
class << self
|
10
|
-
|
11
|
-
# @return [Vedeu::Cursor]
|
12
|
-
# @see Vedeu::API.cursor
|
13
|
-
def cursor
|
14
|
-
cursors.by_name(Vedeu.focus) if Vedeu.focus
|
15
|
-
end
|
16
|
-
|
17
|
-
end # Eigenclass
|
18
|
-
|
19
|
-
null Vedeu::Cursor
|
20
|
-
real Vedeu::Cursor
|
21
|
-
|
22
|
-
end # Cursors
|
23
|
-
|
24
|
-
class Cursor
|
25
|
-
|
26
|
-
repo Vedeu::Cursors.repository
|
27
|
-
|
28
|
-
end # Cursor
|
29
|
-
|
30
|
-
end # Vedeu
|
data/lib/vedeu/cursor/move.rb
DELETED
@@ -1,239 +0,0 @@
|
|
1
|
-
module Vedeu
|
2
|
-
|
3
|
-
# Adjusts the position of the cursor or view. To use this class, call the
|
4
|
-
# appropriate event:
|
5
|
-
#
|
6
|
-
# @example
|
7
|
-
# Vedeu.trigger(:_cursor_down_)
|
8
|
-
#
|
9
|
-
# Vedeu.trigger(:_cursor_left_) # When a name is not given, the cursor in
|
10
|
-
# # the interface which is currently in focus
|
11
|
-
# # should move to the left.
|
12
|
-
#
|
13
|
-
# Vedeu.trigger(:_cursor_left_, 'my_interface')
|
14
|
-
# # When a name is given, the cursor instance
|
15
|
-
# # belonging to this interface moves to the
|
16
|
-
# # left.
|
17
|
-
#
|
18
|
-
# Vedeu.trigger(:_cursor_right_)
|
19
|
-
# Vedeu.trigger(:_cursor_up_)
|
20
|
-
#
|
21
|
-
# Vedeu.trigger(:_cursor_origin_) # /or/
|
22
|
-
# Vedeu.trigger(:_cursor_origin_, 'my_interface')
|
23
|
-
# # Moves the cursor to the top left of the
|
24
|
-
# # named or current interface in focus.
|
25
|
-
#
|
26
|
-
# Vedeu.trigger(:_view_down_, 'my_interface')
|
27
|
-
# Vedeu.trigger(:_view_left_, 'my_interface')
|
28
|
-
# Vedeu.trigger(:_view_right_, 'my_interface')
|
29
|
-
# Vedeu.trigger(:_view_up_, 'my_interface')
|
30
|
-
#
|
31
|
-
# @note
|
32
|
-
# The cursor or view may not be visible, but it will still move if
|
33
|
-
# requested.
|
34
|
-
# The cursor will not exceed the border or boundary of the interface, or
|
35
|
-
# boundary of the visible terminal.
|
36
|
-
# The cursor will move freely within the bounds of the interface,
|
37
|
-
# irrespective of content.
|
38
|
-
# The view will not exceed the boundary of the visible terminal.
|
39
|
-
# The view will move freely within the bounds of the interface,
|
40
|
-
# irrespective of content.
|
41
|
-
#
|
42
|
-
class Move
|
43
|
-
|
44
|
-
extend Forwardable
|
45
|
-
|
46
|
-
def_delegators :geometry, :x, :xn, :y, :yn
|
47
|
-
|
48
|
-
# Move the named cursor or view, or that which is currently in focus in the
|
49
|
-
# specified direction.
|
50
|
-
#
|
51
|
-
# @param direction [Symbol] The direction of travel. Directions include:
|
52
|
-
# (:down, :left, :right, :up, :origin). When ':origin' the cursor is moved
|
53
|
-
# to the top left of the interface.
|
54
|
-
# @param name [String|NilClass] The name of the interface/cursor to be
|
55
|
-
# moved; when not given, the interface currently in focus determines which
|
56
|
-
# cursor instance to move.
|
57
|
-
# @return [Vedeu::Cursor]
|
58
|
-
def self.by_name(entity, direction, name = nil)
|
59
|
-
name = name ? name : Vedeu.focus
|
60
|
-
|
61
|
-
Vedeu::Move.send(direction, entity, name)
|
62
|
-
end
|
63
|
-
|
64
|
-
# Moves the cursor or view down by one row.
|
65
|
-
#
|
66
|
-
# @param entity [Class]
|
67
|
-
# @param name [String]
|
68
|
-
# @return [Vedeu::Cursor]
|
69
|
-
def self.down(entity, name)
|
70
|
-
new(entity, name, 1, 0).move
|
71
|
-
end
|
72
|
-
|
73
|
-
# Moves the cursor or view left by one column.
|
74
|
-
#
|
75
|
-
# @param entity [Class]
|
76
|
-
# @param name [String]
|
77
|
-
# @return [Vedeu::Cursor]
|
78
|
-
def self.left(entity, name)
|
79
|
-
new(entity, name, 0, -1).move
|
80
|
-
end
|
81
|
-
|
82
|
-
# Moves the cursor or view right by one column.
|
83
|
-
#
|
84
|
-
# @param entity [Class]
|
85
|
-
# @param name [String]
|
86
|
-
# @return [Vedeu::Cursor]
|
87
|
-
def self.right(entity, name)
|
88
|
-
new(entity, name, 0, 1).move
|
89
|
-
end
|
90
|
-
|
91
|
-
# Moves the cursor or view up by one row.
|
92
|
-
#
|
93
|
-
# @param entity [Class]
|
94
|
-
# @param name [String]
|
95
|
-
# @return [Vedeu::Cursor]
|
96
|
-
def self.up(entity, name)
|
97
|
-
new(entity, name, -1, 0).move
|
98
|
-
end
|
99
|
-
|
100
|
-
# Moves the cursor or view to the top left coordinate of the interface or
|
101
|
-
# terminal screen.
|
102
|
-
#
|
103
|
-
# @param entity [Class]
|
104
|
-
# @param name [String]
|
105
|
-
# @return [Vedeu::Cursor]
|
106
|
-
def self.origin(entity, name)
|
107
|
-
new(entity, name, -2000, -2000).move
|
108
|
-
end
|
109
|
-
|
110
|
-
# Returns an instance of Vedeu::Move.
|
111
|
-
#
|
112
|
-
# @param entity [Class]
|
113
|
-
# @param name [String] The name of the cursor or view.
|
114
|
-
# @param dy [Fixnum] Move up (-1), or down (1), or no action (0).
|
115
|
-
# @param dx [Fixnum] Move left (-1), or right (1), or no action (0).
|
116
|
-
# @return [Vedeu::Move]
|
117
|
-
def initialize(entity, name = nil, dy = 0, dx = 0)
|
118
|
-
@entity = entity
|
119
|
-
@name = name ? name : Vedeu.focus
|
120
|
-
@dy = dy
|
121
|
-
@dx = dx
|
122
|
-
end
|
123
|
-
|
124
|
-
# Returns a newly positioned and stored cursor or view.
|
125
|
-
#
|
126
|
-
# @return [Vedeu::Cursor|Vedeu::Geometry]
|
127
|
-
def move
|
128
|
-
model = entity.new(merged_attributes).store
|
129
|
-
|
130
|
-
refresh
|
131
|
-
|
132
|
-
model
|
133
|
-
end
|
134
|
-
|
135
|
-
# @return [void]
|
136
|
-
def refresh
|
137
|
-
if entity.to_s == 'Vedeu::Geometry'
|
138
|
-
Vedeu.trigger(:_clear_)
|
139
|
-
Vedeu.trigger(:_refresh_)
|
140
|
-
Vedeu.trigger(:_clear_, name)
|
141
|
-
Vedeu.trigger(:_refresh_, name)
|
142
|
-
|
143
|
-
else
|
144
|
-
Vedeu.trigger(:_refresh_cursor_, name)
|
145
|
-
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
# @return [Hash<Symbol => Boolean,Fixnum, String>]
|
150
|
-
def merged_attributes
|
151
|
-
if entity.to_s == 'Vedeu::Geometry'
|
152
|
-
geometry_attributes
|
153
|
-
|
154
|
-
else
|
155
|
-
cursor_attributes
|
156
|
-
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
protected
|
161
|
-
|
162
|
-
# @!attribute [r] dx
|
163
|
-
# @return [Fixnum]
|
164
|
-
attr_reader :dx
|
165
|
-
|
166
|
-
# @!attribute [r] dy
|
167
|
-
# @return [Fixnum]
|
168
|
-
attr_reader :dy
|
169
|
-
|
170
|
-
# @!attribute [r] entity
|
171
|
-
# @return [Fixnum]
|
172
|
-
attr_reader :entity
|
173
|
-
|
174
|
-
# @!attribute [r] name
|
175
|
-
# @return [String]
|
176
|
-
attr_reader :name
|
177
|
-
|
178
|
-
private
|
179
|
-
|
180
|
-
# @return [Vedeu::Coordinate]
|
181
|
-
def coordinate
|
182
|
-
@coordinate ||= Vedeu::Coordinate.new(name, oy, ox)
|
183
|
-
end
|
184
|
-
|
185
|
-
# @return [Vedeu::Cursor]
|
186
|
-
# @see Vedeu::Cursors#by_name
|
187
|
-
def cursor
|
188
|
-
@cursor ||= Vedeu.cursors.by_name(name)
|
189
|
-
end
|
190
|
-
|
191
|
-
# @return [Hash<Symbol => void>]
|
192
|
-
def cursor_attributes
|
193
|
-
cursor.attributes.merge!(x: coordinate.x_position,
|
194
|
-
y: coordinate.y_position,
|
195
|
-
ox: ox,
|
196
|
-
oy: oy)
|
197
|
-
end
|
198
|
-
|
199
|
-
# @see Vedeu::Geometries#by_name
|
200
|
-
def geometry
|
201
|
-
@geometry ||= Vedeu.geometries.by_name(name)
|
202
|
-
end
|
203
|
-
|
204
|
-
# @return [Hash<Symbol => FalseClass,String,Fixnum>]
|
205
|
-
def geometry_attributes
|
206
|
-
{
|
207
|
-
centred: false,
|
208
|
-
maximised: false,
|
209
|
-
name: name,
|
210
|
-
x: (x + dx),
|
211
|
-
y: (y + dy),
|
212
|
-
xn: (xn + dx),
|
213
|
-
yn: (yn + dy),
|
214
|
-
}
|
215
|
-
end
|
216
|
-
|
217
|
-
# Apply the direction amount to the cursor offset. If the offset is less
|
218
|
-
# than 0, correct to 0.
|
219
|
-
#
|
220
|
-
# @return [Fixnum]
|
221
|
-
def ox
|
222
|
-
ox = cursor.ox + dx
|
223
|
-
ox = 0 if ox < 0
|
224
|
-
ox
|
225
|
-
end
|
226
|
-
|
227
|
-
# Apply the direction amount to the cursor offset. If the offset is less
|
228
|
-
# than 0, correct to 0.
|
229
|
-
#
|
230
|
-
# @return [Fixnum]
|
231
|
-
def oy
|
232
|
-
oy = cursor.oy + dy
|
233
|
-
oy = 0 if oy < 0
|
234
|
-
oy
|
235
|
-
end
|
236
|
-
|
237
|
-
end # Move
|
238
|
-
|
239
|
-
end # Vedeu
|
@@ -1,78 +0,0 @@
|
|
1
|
-
module Vedeu
|
2
|
-
|
3
|
-
# Provides the mechanism to arbitrarily move a cursor to a given position.
|
4
|
-
#
|
5
|
-
class Reposition
|
6
|
-
|
7
|
-
# @return [Vedeu::Cursor]
|
8
|
-
# @see Vedeu::Reposition.new
|
9
|
-
def self.to(entity, name, y, x)
|
10
|
-
new(entity, name, y, x).to
|
11
|
-
end
|
12
|
-
|
13
|
-
# Returns a new instance of Vedeu::Reposition.
|
14
|
-
#
|
15
|
-
# @param entity [void]
|
16
|
-
# @param name [String]
|
17
|
-
# @param y [Fixnum] The row/line position.
|
18
|
-
# @param x [Fixnum] The column/character position.
|
19
|
-
# @return [Vedeu::Reposition]
|
20
|
-
def initialize(entity, name, y, x)
|
21
|
-
@entity = entity
|
22
|
-
@name = name
|
23
|
-
@y = y
|
24
|
-
@x = x
|
25
|
-
end
|
26
|
-
|
27
|
-
# @return [Vedeu::Cursor]
|
28
|
-
def to
|
29
|
-
build_entity!
|
30
|
-
|
31
|
-
Vedeu.trigger(:_clear_, name)
|
32
|
-
Vedeu.trigger(:_refresh_, name)
|
33
|
-
Vedeu.trigger(:_refresh_cursor_, name)
|
34
|
-
|
35
|
-
new_entity
|
36
|
-
end
|
37
|
-
|
38
|
-
protected
|
39
|
-
|
40
|
-
# @!attribute [r] entity
|
41
|
-
# @return [String]
|
42
|
-
attr_reader :entity
|
43
|
-
|
44
|
-
# @!attribute [r] name
|
45
|
-
# @return [String]
|
46
|
-
attr_reader :name
|
47
|
-
|
48
|
-
# @!attribute [r] x
|
49
|
-
# @return [Fixnum]
|
50
|
-
attr_reader :x
|
51
|
-
|
52
|
-
# @!attribute [r] y
|
53
|
-
# @return [Fixnum]
|
54
|
-
attr_reader :y
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
# Build a new instance of the entity that is being repositioned and replace
|
59
|
-
# existing stored version.
|
60
|
-
#
|
61
|
-
# @return [Vedeu::Cursor|Vedeu::Geometry]
|
62
|
-
def build_entity!
|
63
|
-
@_entity ||= entity.new(name: name,
|
64
|
-
y: coordinate.y_position,
|
65
|
-
x: coordinate.x_position,
|
66
|
-
oy: y,
|
67
|
-
ox: x).store
|
68
|
-
end
|
69
|
-
alias_method :new_entity, :build_entity!
|
70
|
-
|
71
|
-
# @return [Vedeu::Coordinate]
|
72
|
-
def coordinate
|
73
|
-
@coordinate ||= Vedeu::Coordinate.new(name, y, x)
|
74
|
-
end
|
75
|
-
|
76
|
-
end # Reposition
|
77
|
-
|
78
|
-
end # Vedeu
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Vedeu
|
2
|
-
|
3
|
-
# Allows the storing of interface/view geometry independent of the interface
|
4
|
-
# instance.
|
5
|
-
#
|
6
|
-
class Geometries < Vedeu::Repository
|
7
|
-
|
8
|
-
singleton_class.send(:alias_method, :geometries, :repository)
|
9
|
-
|
10
|
-
null Vedeu::Null::Geometry
|
11
|
-
real Vedeu::Geometry
|
12
|
-
|
13
|
-
end # Geometries
|
14
|
-
|
15
|
-
end # Vedeu
|
@@ -1,92 +0,0 @@
|
|
1
|
-
module Vedeu
|
2
|
-
|
3
|
-
# Handle the refreshing (redrawing) of a cursor, without redrawing the whole
|
4
|
-
# interface; unless the cursor's offset has caused the view to change.
|
5
|
-
#
|
6
|
-
class RefreshCursor
|
7
|
-
|
8
|
-
extend Forwardable
|
9
|
-
|
10
|
-
def_delegators :border,
|
11
|
-
:height,
|
12
|
-
:width
|
13
|
-
|
14
|
-
# @param (see #initialize)
|
15
|
-
def self.by_name(name = Vedeu.focus)
|
16
|
-
new(name).by_name
|
17
|
-
end
|
18
|
-
|
19
|
-
# Returns a new instance of Vedeu::RefreshCursor.
|
20
|
-
#
|
21
|
-
# @param name [String] The name of the cursor.
|
22
|
-
# @return [Vedeu::RefreshCursor]
|
23
|
-
def initialize(name)
|
24
|
-
@name = name
|
25
|
-
end
|
26
|
-
|
27
|
-
# Renders the cursor in the terminal. If the cursor's x or y offsets are
|
28
|
-
# greater or equal to the interface's width or height respectively, then
|
29
|
-
# the view is also refreshed, causing the content to be offset also.
|
30
|
-
#
|
31
|
-
# @return [Array]
|
32
|
-
def by_name
|
33
|
-
Vedeu.log(type: :info, message: "Refreshing cursor: '#{name}'")
|
34
|
-
|
35
|
-
Vedeu.trigger(:_refresh_, name) if refresh_view?
|
36
|
-
|
37
|
-
Vedeu::Terminal.output(new_cursor.to_s)
|
38
|
-
end
|
39
|
-
|
40
|
-
protected
|
41
|
-
|
42
|
-
# @!attribute [r] name
|
43
|
-
# @return [String]
|
44
|
-
attr_reader :name
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
# Returns true when the view should be refreshed. This is determined by
|
49
|
-
# checking that the offsets for x and y are outside the width and height
|
50
|
-
# of the named interface.
|
51
|
-
#
|
52
|
-
# @return [Boolean]
|
53
|
-
def refresh_view?
|
54
|
-
new_cursor.ox >= width || new_cursor.oy >= height
|
55
|
-
end
|
56
|
-
|
57
|
-
# @return [Vedeu::Cursor]
|
58
|
-
def new_cursor
|
59
|
-
@new_cursor ||= Vedeu::Cursor.new(cursor.attributes.merge!(position))
|
60
|
-
end
|
61
|
-
|
62
|
-
# @return [Hash<Symbol => Fixnum>]
|
63
|
-
def position
|
64
|
-
{
|
65
|
-
x: cursor.x,
|
66
|
-
y: cursor.y,
|
67
|
-
}
|
68
|
-
end
|
69
|
-
|
70
|
-
# @return [Vedeu::Cursor]
|
71
|
-
# @see Vedeu::Cursors#by_name
|
72
|
-
def cursor
|
73
|
-
@cursor ||= Vedeu.cursors.by_name(name)
|
74
|
-
end
|
75
|
-
|
76
|
-
# Fetch the border by name.
|
77
|
-
#
|
78
|
-
# @note
|
79
|
-
# Vedeu::Border is used in this way because when there is not a border
|
80
|
-
# defined, it will fallback to a Vedeu::Null::Border which uses
|
81
|
-
# Vedeu::Geometry to determine it's dimensions based on the name also.
|
82
|
-
# When a Vedeu::Geometry cannot be found, this falls back to a
|
83
|
-
# Vedeu::Null::Geometry which uses the current terminal's dimensions.
|
84
|
-
#
|
85
|
-
# @return (see Vedeu::Borders#by_name)
|
86
|
-
def border
|
87
|
-
@border ||= Vedeu.borders.by_name(name)
|
88
|
-
end
|
89
|
-
|
90
|
-
end # RefreshCursor
|
91
|
-
|
92
|
-
end # Vedeu
|