vedeu 0.4.23 → 0.4.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/cursor_app.rb +9 -4
- data/lib/vedeu/bindings.rb +36 -9
- data/lib/vedeu/cursor/move.rb +49 -55
- data/lib/vedeu/geometry/coordinate.rb +51 -38
- data/lib/vedeu/geometry/geometry.rb +44 -16
- data/lib/vedeu/geometry/position.rb +2 -6
- data/lib/vedeu/input/mapper.rb +2 -0
- data/lib/vedeu/models/char.rb +2 -2
- data/lib/vedeu/output/all.rb +1 -1
- data/lib/vedeu/output/border.rb +8 -6
- data/lib/vedeu/output/clear.rb +17 -19
- data/lib/vedeu/output/refresh.rb +4 -10
- data/lib/vedeu/output/renderers/all.rb +1 -2
- data/lib/vedeu/output/renderers/terminal.rb +3 -1
- data/lib/vedeu/output/viewport.rb +8 -8
- data/lib/vedeu/repositories/collections/all.rb +33 -6
- data/lib/vedeu/repositories/registerable.rb +21 -0
- data/lib/vedeu/repositories/repositories/borders.rb +2 -1
- data/lib/vedeu/repositories/repositories/buffers.rb +2 -1
- data/lib/vedeu/repositories/repositories/cursors.rb +1 -1
- data/lib/vedeu/repositories/repositories/events_repository.rb +1 -1
- data/lib/vedeu/repositories/repositories/geometries.rb +2 -1
- data/lib/vedeu/repositories/repositories/groups.rb +1 -1
- data/lib/vedeu/repositories/repositories/interfaces_repository.rb +2 -1
- data/lib/vedeu/repositories/repositories/keymaps.rb +1 -1
- data/lib/vedeu/repositories/repositories/menus.rb +1 -1
- data/lib/vedeu/repositories/repository.rb +1 -10
- data/lib/vedeu/support/log.rb +27 -13
- data/lib/vedeu/support/terminal.rb +1 -1
- data/lib/vedeu/support/timer.rb +11 -4
- data/test/lib/vedeu/cursor/move_test.rb +9 -7
- data/test/lib/vedeu/geometry/coordinate_test.rb +29 -21
- data/test/lib/vedeu/geometry/geometry_test.rb +14 -2
- data/test/lib/vedeu/repositories/collections/all_test.rb +71 -0
- data/vedeu.gemspec +2 -5
- metadata +6 -22
- data/lib/vedeu/repositories/collections/chars.rb +0 -8
- data/lib/vedeu/repositories/collections/events.rb +0 -8
- data/lib/vedeu/repositories/collections/interfaces.rb +0 -8
- data/lib/vedeu/repositories/collections/keys.rb +0 -8
- data/lib/vedeu/repositories/collections/lines.rb +0 -8
- data/lib/vedeu/repositories/collections/streams.rb +0 -8
- data/test/lib/vedeu/repositories/collections/chars_test.rb +0 -16
- data/test/lib/vedeu/repositories/collections/events_test.rb +0 -16
- data/test/lib/vedeu/repositories/collections/interfaces_test.rb +0 -16
- data/test/lib/vedeu/repositories/collections/keys_test.rb +0 -16
- data/test/lib/vedeu/repositories/collections/lines_test.rb +0 -16
- data/test/lib/vedeu/repositories/collections/streams_test.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d53834cae0f1a3dc8708b3706bf87d4014f16c90
|
4
|
+
data.tar.gz: 08bc9cd02ad0672be13d272172912d6b7975fd41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 522ba5bc35cfb89d15c28b8784da90634a80106e3aaa463e039c9b1c01c310a4cec9e87dccc7b9fba55a6b5f81bd39573cf854241e203c7400bbe8652cc593d1
|
7
|
+
data.tar.gz: 44e0de6a4e2541b1672e0c79bfdf183bd4b2ce9e408525c41c79c9772ca160a6e6387d46950201ef05eb925672e3b6329347eaa61db186d08525af144fed640e
|
data/examples/cursor_app.rb
CHANGED
@@ -28,10 +28,15 @@ class VedeuCursorApp
|
|
28
28
|
end
|
29
29
|
|
30
30
|
keymap('_global_') do
|
31
|
-
key(:up
|
32
|
-
key(:right
|
33
|
-
key(:down
|
34
|
-
key(:left
|
31
|
+
key(:up) { Vedeu.trigger(:_cursor_up_) }
|
32
|
+
key(:right) { Vedeu.trigger(:_cursor_right_) }
|
33
|
+
key(:down) { Vedeu.trigger(:_cursor_down_) }
|
34
|
+
key(:left) { Vedeu.trigger(:_cursor_left_) }
|
35
|
+
|
36
|
+
key('k') { Vedeu.trigger(:_geometry_up_, 'main_interface') }
|
37
|
+
key('l') { Vedeu.trigger(:_geometry_right_, 'main_interface') }
|
38
|
+
key('j') { Vedeu.trigger(:_geometry_down_, 'main_interface') }
|
39
|
+
key('h') { Vedeu.trigger(:_geometry_left_, 'main_interface') }
|
35
40
|
|
36
41
|
key('m') { Vedeu.trigger(:_maximise_, 'main_interface') }
|
37
42
|
key('u') { Vedeu.trigger(:_unmaximise_, 'main_interface') }
|
data/lib/vedeu/bindings.rb
CHANGED
@@ -58,10 +58,7 @@ module Vedeu
|
|
58
58
|
# you should define to 'do things'. If the `escape` key is pressed, then
|
59
59
|
# `key` is triggered with the argument `:escape`, also an internal event
|
60
60
|
# `_mode_switch_` is triggered.
|
61
|
-
Vedeu.bind(:_keypress_)
|
62
|
-
Vedeu.trigger(:key, key)
|
63
|
-
Vedeu.keypress(key)
|
64
|
-
end
|
61
|
+
Vedeu.bind(:_keypress_) { |key| Vedeu.keypress(key) }
|
65
62
|
|
66
63
|
# Will cause the triggering of the `:command` event; which you should define
|
67
64
|
# to 'do things'.
|
@@ -95,19 +92,49 @@ module Vedeu
|
|
95
92
|
end
|
96
93
|
|
97
94
|
# @see {Vedeu::Move}
|
98
|
-
Vedeu.bind(:_cursor_down_)
|
95
|
+
Vedeu.bind(:_cursor_down_) do |name|
|
96
|
+
Vedeu::Move.by_name(Vedeu::Cursor, :down, name)
|
97
|
+
end
|
98
|
+
|
99
|
+
# @see {Vedeu::Move}
|
100
|
+
Vedeu.bind(:_cursor_left_) do |name|
|
101
|
+
Vedeu::Move.by_name(Vedeu::Cursor, :left, name)
|
102
|
+
end
|
103
|
+
|
104
|
+
# @see {Vedeu::Move}
|
105
|
+
Vedeu.bind(:_cursor_right_) do |name|
|
106
|
+
Vedeu::Move.by_name(Vedeu::Cursor, :right, name)
|
107
|
+
end
|
108
|
+
|
109
|
+
# @see {Vedeu::Move}
|
110
|
+
Vedeu.bind(:_cursor_up_) do |name|
|
111
|
+
Vedeu::Move.by_name(Vedeu::Cursor, :up, name)
|
112
|
+
end
|
99
113
|
|
100
114
|
# @see {Vedeu::Move}
|
101
|
-
Vedeu.bind(:
|
115
|
+
Vedeu.bind(:_cursor_origin_) do |name|
|
116
|
+
Vedeu::Move.by_name(Vedeu::Cursor, :origin, name)
|
117
|
+
end
|
102
118
|
|
103
119
|
# @see {Vedeu::Move}
|
104
|
-
Vedeu.bind(:
|
120
|
+
Vedeu.bind(:_geometry_down_) do |name|
|
121
|
+
Vedeu.geometries.by_name(name).move(1, 0)
|
122
|
+
end
|
105
123
|
|
106
124
|
# @see {Vedeu::Move}
|
107
|
-
Vedeu.bind(:
|
125
|
+
Vedeu.bind(:_geometry_left_) do |name|
|
126
|
+
Vedeu.geometries.by_name(name).move(0, -1)
|
127
|
+
end
|
108
128
|
|
109
129
|
# @see {Vedeu::Move}
|
110
|
-
Vedeu.bind(:
|
130
|
+
Vedeu.bind(:_geometry_right_) do |name|
|
131
|
+
Vedeu.geometries.by_name(name).move(0, 1)
|
132
|
+
end
|
133
|
+
|
134
|
+
# @see {Vedeu::Move}
|
135
|
+
Vedeu.bind(:_geometry_up_) do |name|
|
136
|
+
Vedeu.geometries.by_name(name).move(-1, 0)
|
137
|
+
end
|
111
138
|
|
112
139
|
# @see {Vedeu::Move}
|
113
140
|
Vedeu.bind(:_cursor_reset_) { |name| Vedeu.trigger(:_cursor_origin_, name) }
|
data/lib/vedeu/cursor/move.rb
CHANGED
@@ -30,26 +30,6 @@ module Vedeu
|
|
30
30
|
# irrespective of content.
|
31
31
|
class Move
|
32
32
|
|
33
|
-
extend Forwardable
|
34
|
-
|
35
|
-
def_delegators :border,
|
36
|
-
:height,
|
37
|
-
:width,
|
38
|
-
:x,
|
39
|
-
:y
|
40
|
-
|
41
|
-
# Returns an instance of Vedeu::Move.
|
42
|
-
#
|
43
|
-
# @param name [String] The name of the cursor.
|
44
|
-
# @param dy [Fixnum] Move up (-1), or down (1), or no action (0).
|
45
|
-
# @param dx [Fixnum] Move left (-1), or right (1), or no action (0).
|
46
|
-
# @return [Move]
|
47
|
-
def initialize(name, dy = 0, dx = 0)
|
48
|
-
@name = name
|
49
|
-
@dy = dy
|
50
|
-
@dx = dx
|
51
|
-
end
|
52
|
-
|
53
33
|
# Move the named cursor, or that which is currently in focus in the
|
54
34
|
# specified direction.
|
55
35
|
#
|
@@ -60,61 +40,88 @@ module Vedeu
|
|
60
40
|
# moved; when not given, the interface currently in focus determines which
|
61
41
|
# cursor instance to move.
|
62
42
|
# @return [Cursor]
|
63
|
-
def self.by_name(direction, name = nil)
|
43
|
+
def self.by_name(entity, direction, name = nil)
|
64
44
|
name = name ? name : Vedeu.focus
|
65
45
|
|
66
|
-
Vedeu::Move.send(direction, name)
|
46
|
+
Vedeu::Move.send(direction, entity, name)
|
67
47
|
end
|
68
48
|
|
69
49
|
# Moves the cursor down by one row.
|
70
50
|
#
|
51
|
+
# @param entity [Class]
|
71
52
|
# @param name [String]
|
72
53
|
# @return [Cursor]
|
73
|
-
def self.down(name)
|
74
|
-
new(name, 1, 0).move
|
54
|
+
def self.down(entity, name)
|
55
|
+
new(entity, name, 1, 0).move
|
75
56
|
end
|
76
57
|
|
77
58
|
# Moves the cursor left by one column.
|
78
59
|
#
|
60
|
+
# @param entity [Class]
|
79
61
|
# @param name [String]
|
80
62
|
# @return [Cursor]
|
81
|
-
def self.left(name)
|
82
|
-
new(name, 0, -1).move
|
63
|
+
def self.left(entity, name)
|
64
|
+
new(entity, name, 0, -1).move
|
83
65
|
end
|
84
66
|
|
85
67
|
# Moves the cursor right by one column.
|
86
68
|
#
|
69
|
+
# @param entity [Class]
|
87
70
|
# @param name [String]
|
88
71
|
# @return [Cursor]
|
89
|
-
def self.right(name)
|
90
|
-
new(name, 0, 1).move
|
72
|
+
def self.right(entity, name)
|
73
|
+
new(entity, name, 0, 1).move
|
91
74
|
end
|
92
75
|
|
93
76
|
# Moves the cursor up by one row.
|
94
77
|
#
|
78
|
+
# @param entity [Class]
|
95
79
|
# @param name [String]
|
96
80
|
# @return [Cursor]
|
97
|
-
def self.up(name)
|
98
|
-
new(name, -1, 0).move
|
81
|
+
def self.up(entity, name)
|
82
|
+
new(entity, name, -1, 0).move
|
99
83
|
end
|
100
84
|
|
101
85
|
# Moves the cursor to the top left coordinate of the interface.
|
102
86
|
#
|
87
|
+
# @param entity [Class]
|
103
88
|
# @param name [String]
|
104
89
|
# @return [Cursor]
|
105
|
-
def self.origin(name)
|
106
|
-
new(name, -2000, -2000).move
|
90
|
+
def self.origin(entity, name)
|
91
|
+
new(entity, name, -2000, -2000).move
|
92
|
+
end
|
93
|
+
|
94
|
+
# Returns an instance of Vedeu::Move.
|
95
|
+
#
|
96
|
+
# @param entity [Class]
|
97
|
+
# @param name [String] The name of the cursor.
|
98
|
+
# @param dy [Fixnum] Move up (-1), or down (1), or no action (0).
|
99
|
+
# @param dx [Fixnum] Move left (-1), or right (1), or no action (0).
|
100
|
+
# @return [Move]
|
101
|
+
def initialize(entity, name, dy = 0, dx = 0)
|
102
|
+
@entity = entity
|
103
|
+
@name = name
|
104
|
+
@dy = dy
|
105
|
+
@dx = dx
|
107
106
|
end
|
108
107
|
|
109
108
|
# Returns a newly positioned and stored Cursor.
|
110
109
|
#
|
111
110
|
# @return [Cursor]
|
112
111
|
def move
|
113
|
-
|
112
|
+
attrs = attributes.merge!(new_attributes)
|
113
|
+
|
114
|
+
model = entity.new(attrs).store
|
114
115
|
|
115
|
-
|
116
|
+
if model.is_a?(Vedeu::Cursor)
|
117
|
+
Vedeu.trigger(:_refresh_cursor_, name)
|
116
118
|
|
117
|
-
|
119
|
+
else
|
120
|
+
Vedeu.trigger(:_refresh_, name)
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
model
|
118
125
|
end
|
119
126
|
|
120
127
|
protected
|
@@ -127,6 +134,10 @@ module Vedeu
|
|
127
134
|
# @return [Fixnum]
|
128
135
|
attr_reader :dy
|
129
136
|
|
137
|
+
# @!attribute [r] entity
|
138
|
+
# @return [Fixnum]
|
139
|
+
attr_reader :entity
|
140
|
+
|
130
141
|
# @!attribute [r] name
|
131
142
|
# @return [String]
|
132
143
|
attr_reader :name
|
@@ -145,22 +156,13 @@ module Vedeu
|
|
145
156
|
# @return [Hash<Symbol => Fixnum>]
|
146
157
|
def new_attributes
|
147
158
|
{
|
148
|
-
x:
|
149
|
-
y:
|
159
|
+
x: x_position,
|
160
|
+
y: y_position,
|
150
161
|
ox: ox,
|
151
162
|
oy: oy,
|
152
163
|
}
|
153
164
|
end
|
154
165
|
|
155
|
-
# Validates the new position of the cursor.
|
156
|
-
#
|
157
|
-
# @return [PositionValidator]
|
158
|
-
def validator
|
159
|
-
@validator ||= Vedeu::PositionValidator.validate(name,
|
160
|
-
x_position,
|
161
|
-
y_position)
|
162
|
-
end
|
163
|
-
|
164
166
|
# Returns the cursors x position based on its current offset.
|
165
167
|
#
|
166
168
|
# @return [Fixnum]
|
@@ -175,17 +177,9 @@ module Vedeu
|
|
175
177
|
coordinate.y_position(oy)
|
176
178
|
end
|
177
179
|
|
178
|
-
# Retrieve the border for the named view: this will provide the geometry for
|
179
|
-
# the cursor, ensuring it displays within the interface boundaries.
|
180
|
-
#
|
181
|
-
# @return (see Vedeu::Borders#by_name)
|
182
|
-
def border
|
183
|
-
@border ||= Vedeu.borders.by_name(name)
|
184
|
-
end
|
185
|
-
|
186
180
|
# @return [Coordinate]
|
187
181
|
def coordinate
|
188
|
-
@coordinate ||= Vedeu::Coordinate.new(
|
182
|
+
@coordinate ||= Vedeu::Coordinate.new(name)
|
189
183
|
end
|
190
184
|
|
191
185
|
# @return (see Vedeu::Cursors#by_name)
|
@@ -3,34 +3,24 @@ module Vedeu
|
|
3
3
|
# Crudely corrects out of range values.
|
4
4
|
class Coordinate
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
# @!attribute [r] y
|
19
|
-
# @return [Fixnum]
|
20
|
-
attr_reader :y
|
6
|
+
extend Forwardable
|
7
|
+
|
8
|
+
def_delegators :border,
|
9
|
+
:bx,
|
10
|
+
:bxn,
|
11
|
+
:by,
|
12
|
+
:byn,
|
13
|
+
:height,
|
14
|
+
:width,
|
15
|
+
:x,
|
16
|
+
:y
|
21
17
|
|
22
18
|
# Returns a new instance of Vedeu::Coordinate.
|
23
19
|
#
|
24
|
-
# @param
|
25
|
-
# @param width [Fixnum]
|
26
|
-
# @param x [Fixnum]
|
27
|
-
# @param y [Fixnum]
|
20
|
+
# @param name [String]
|
28
21
|
# @return [Vedeu::Coordinate]
|
29
|
-
def initialize(
|
30
|
-
@
|
31
|
-
@width = width
|
32
|
-
@x = x
|
33
|
-
@y = y
|
22
|
+
def initialize(name)
|
23
|
+
@name = name
|
34
24
|
end
|
35
25
|
|
36
26
|
# Returns the maximum y coordinate for an area.
|
@@ -81,16 +71,17 @@ module Vedeu
|
|
81
71
|
# @param index [Fixnum]
|
82
72
|
# @return [Fixnum]
|
83
73
|
def y_position(index = 0)
|
84
|
-
if index <= 0
|
85
|
-
|
74
|
+
value = if index <= 0
|
75
|
+
y
|
86
76
|
|
87
|
-
|
88
|
-
|
77
|
+
elsif index > yn_index
|
78
|
+
yn
|
89
79
|
|
90
|
-
|
91
|
-
|
80
|
+
else
|
81
|
+
y_range[index]
|
92
82
|
|
93
|
-
|
83
|
+
end
|
84
|
+
validate_y(value)
|
94
85
|
end
|
95
86
|
|
96
87
|
# Returns the x coordinate for a given index.
|
@@ -105,16 +96,17 @@ module Vedeu
|
|
105
96
|
# @param index [Fixnum]
|
106
97
|
# @return [Fixnum]
|
107
98
|
def x_position(index = 0)
|
108
|
-
if index <= 0
|
109
|
-
|
99
|
+
value = if index <= 0
|
100
|
+
x
|
110
101
|
|
111
|
-
|
112
|
-
|
102
|
+
elsif index > xn_index
|
103
|
+
xn
|
113
104
|
|
114
|
-
|
115
|
-
|
105
|
+
else
|
106
|
+
x_range[index]
|
116
107
|
|
117
|
-
|
108
|
+
end
|
109
|
+
validate_x(value)
|
118
110
|
end
|
119
111
|
|
120
112
|
protected
|
@@ -125,6 +117,27 @@ module Vedeu
|
|
125
117
|
|
126
118
|
private
|
127
119
|
|
120
|
+
# @return (see Vedeu::Borders#by_name)
|
121
|
+
def border
|
122
|
+
@border ||= Vedeu.borders.by_name(name)
|
123
|
+
end
|
124
|
+
|
125
|
+
# @param value [Fixnum]
|
126
|
+
# @return [Fixnum]
|
127
|
+
def validate_x(value)
|
128
|
+
value = value < bx ? bx : value
|
129
|
+
value = value > bxn ? bxn : value
|
130
|
+
value
|
131
|
+
end
|
132
|
+
|
133
|
+
# @param value [Fixnum]
|
134
|
+
# @return [Fixnum]
|
135
|
+
def validate_y(value)
|
136
|
+
value = value < by ? by : value
|
137
|
+
value = value > byn ? byn : value
|
138
|
+
value
|
139
|
+
end
|
140
|
+
|
128
141
|
# Returns the maximum y index for an area.
|
129
142
|
#
|
130
143
|
# @example
|
@@ -105,35 +105,63 @@ module Vedeu
|
|
105
105
|
|
106
106
|
# @return [String]
|
107
107
|
def inspect
|
108
|
-
|
108
|
+
'<Vedeu::Geometry ' \
|
109
|
+
"x:#{x} " \
|
110
|
+
"xn:#{xn} " \
|
111
|
+
"y:#{y} " \
|
112
|
+
"yn:#{yn} " \
|
113
|
+
"centred:#{centred} " \
|
114
|
+
"maximise:#{maximised}>"
|
109
115
|
end
|
110
116
|
|
111
|
-
# @return [Vedeu::Geometry]
|
117
|
+
# @return [Vedeu::Geometry|NilClass]
|
112
118
|
def maximise
|
113
|
-
|
114
|
-
|
119
|
+
return self if maximised?
|
120
|
+
|
121
|
+
@maximised = true
|
115
122
|
|
116
|
-
|
123
|
+
work = store
|
117
124
|
|
118
|
-
|
125
|
+
Vedeu.trigger(:_refresh_, name)
|
119
126
|
|
120
|
-
|
121
|
-
end
|
127
|
+
work
|
122
128
|
end
|
123
129
|
|
124
|
-
# @return [Vedeu::Geometry]
|
130
|
+
# @return [Vedeu::Geometry|NilClass]
|
125
131
|
def unmaximise
|
126
|
-
|
127
|
-
|
132
|
+
return self unless maximised?
|
133
|
+
|
134
|
+
Vedeu.trigger(:_clear_, name)
|
135
|
+
|
136
|
+
@maximised = false
|
137
|
+
|
138
|
+
work = store
|
128
139
|
|
129
|
-
|
140
|
+
Vedeu.trigger(:_refresh_, name)
|
141
|
+
|
142
|
+
work
|
143
|
+
end
|
144
|
+
|
145
|
+
# @param dy [Fixnum]
|
146
|
+
# @param dx [Fixnum]
|
147
|
+
# @return [Vedeu::Geometry]
|
148
|
+
def move(dy = 0, dx = 0)
|
149
|
+
new_attrs = {
|
150
|
+
centred: false,
|
151
|
+
maximised: false,
|
152
|
+
name: name,
|
153
|
+
x: (area.x + dx),
|
154
|
+
y: (area.y + dy),
|
155
|
+
xn: (area.xn + dx),
|
156
|
+
yn: (area.yn + dy),
|
157
|
+
}
|
130
158
|
|
131
|
-
|
159
|
+
work = Vedeu::Geometry.new(new_attrs).store
|
132
160
|
|
133
|
-
|
161
|
+
Vedeu.trigger(:_clear_)
|
162
|
+
Vedeu.trigger(:_refresh_, name)
|
134
163
|
|
135
|
-
|
136
|
-
end
|
164
|
+
work
|
137
165
|
end
|
138
166
|
|
139
167
|
private
|
@@ -70,13 +70,9 @@ module Vedeu
|
|
70
70
|
# @yieldreturn [void] Returns the block wrapped in position escape
|
71
71
|
# sequences.
|
72
72
|
def to_s
|
73
|
-
|
74
|
-
[sequence, yield, sequence].join
|
73
|
+
return sequence unless block_given?
|
75
74
|
|
76
|
-
|
77
|
-
sequence
|
78
|
-
|
79
|
-
end
|
75
|
+
[sequence, yield, sequence].join
|
80
76
|
end
|
81
77
|
|
82
78
|
private
|
data/lib/vedeu/input/mapper.rb
CHANGED
data/lib/vedeu/models/char.rb
CHANGED
@@ -76,7 +76,7 @@ module Vedeu
|
|
76
76
|
|
77
77
|
# @return [Vedeu::Position]
|
78
78
|
def position
|
79
|
-
@position ||= Vedeu::Position.coerce(attributes[:position])
|
79
|
+
@position ||= Vedeu::Position.coerce(@attributes[:position])
|
80
80
|
end
|
81
81
|
|
82
82
|
# Sets the position of the Char.
|
@@ -84,7 +84,7 @@ module Vedeu
|
|
84
84
|
# @param value [Vedeu::Position]
|
85
85
|
# @return [Vedeu::Position]
|
86
86
|
def position=(value)
|
87
|
-
@position = Vedeu::Position.coerce(value)
|
87
|
+
@position = @attributes[:position] = Vedeu::Position.coerce(value)
|
88
88
|
end
|
89
89
|
|
90
90
|
# @return [String]
|
data/lib/vedeu/output/all.rb
CHANGED
@@ -2,11 +2,11 @@ require_relative 'esc'
|
|
2
2
|
require_relative 'translator'
|
3
3
|
require_relative 'background'
|
4
4
|
require_relative 'foreground'
|
5
|
+
require_relative 'presentation'
|
5
6
|
require_relative 'border'
|
6
7
|
require_relative 'colour'
|
7
8
|
require_relative 'compressor'
|
8
9
|
require_relative 'clear'
|
9
|
-
require_relative 'presentation'
|
10
10
|
require_relative 'style'
|
11
11
|
require_relative 'text'
|
12
12
|
require_relative 'virtual_buffer'
|
data/lib/vedeu/output/border.rb
CHANGED
@@ -159,13 +159,15 @@ module Vedeu
|
|
159
159
|
return [] unless visible?
|
160
160
|
return [] unless enabled?
|
161
161
|
|
162
|
-
|
162
|
+
Vedeu::Timer.for(:debug, "Border rendering: #{name}") do
|
163
|
+
out = [top, bottom]
|
163
164
|
|
164
|
-
|
165
|
-
|
166
|
-
|
165
|
+
height.times do |y|
|
166
|
+
out << [left(y), right(y)]
|
167
|
+
end
|
167
168
|
|
168
|
-
|
169
|
+
out.flatten
|
170
|
+
end
|
169
171
|
end
|
170
172
|
|
171
173
|
# @return [String]
|
@@ -316,7 +318,7 @@ module Vedeu
|
|
316
318
|
|
317
319
|
# @return [Vedeu::Geometry]
|
318
320
|
def geometry
|
319
|
-
|
321
|
+
Vedeu.geometries.by_name(name)
|
320
322
|
end
|
321
323
|
|
322
324
|
# @return [Vedeu::Interface]
|
data/lib/vedeu/output/clear.rb
CHANGED
@@ -58,14 +58,14 @@ module Vedeu
|
|
58
58
|
# @return [Array<Array<Vedeu::Char>>]
|
59
59
|
def clear
|
60
60
|
if visible?
|
61
|
-
Vedeu.
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
61
|
+
Vedeu::Timer.for(:debug, "Clearing: #{name}") do
|
62
|
+
@clear ||= Array.new(height) do |iy|
|
63
|
+
Array.new(width) do |ix|
|
64
|
+
Vedeu::Char.new(value: ' ',
|
65
|
+
colour: clear_colour,
|
66
|
+
style: style,
|
67
|
+
position: Vedeu::IndexPosition[iy, ix, *position])
|
68
|
+
end
|
69
69
|
end
|
70
70
|
end
|
71
71
|
else
|
@@ -106,13 +106,13 @@ module Vedeu
|
|
106
106
|
# the terminal, or the colours of the interface.
|
107
107
|
def clear_colour
|
108
108
|
@colour ||= if use_terminal_colours?
|
109
|
-
|
110
|
-
|
109
|
+
Vedeu::Colour.new(background: :default,
|
110
|
+
foreground: :default)
|
111
111
|
|
112
|
-
|
113
|
-
|
112
|
+
else
|
113
|
+
colour
|
114
114
|
|
115
|
-
|
115
|
+
end
|
116
116
|
end
|
117
117
|
|
118
118
|
# @return [Hash<Symbol => Boolean>]
|
@@ -146,17 +146,15 @@ module Vedeu
|
|
146
146
|
@_options ||= defaults.merge!(@options)
|
147
147
|
end
|
148
148
|
|
149
|
-
# @param iy [Fixnum]
|
150
|
-
# @param ix [Fixnum]
|
151
149
|
# @return [Vedeu::IndexPosition]
|
152
150
|
def position
|
153
151
|
@position ||= if clear_border?
|
154
|
-
|
152
|
+
[y, x]
|
155
153
|
|
156
|
-
|
157
|
-
|
154
|
+
else
|
155
|
+
[by, bx]
|
158
156
|
|
159
|
-
|
157
|
+
end
|
160
158
|
end
|
161
159
|
|
162
160
|
# @return [Boolean] Indicates whether the default terminal colours should be
|
data/lib/vedeu/output/refresh.rb
CHANGED
@@ -10,11 +10,9 @@ module Vedeu
|
|
10
10
|
#
|
11
11
|
# @return [Array]
|
12
12
|
def all
|
13
|
-
message =
|
13
|
+
message = 'Refreshing all interfaces'
|
14
14
|
|
15
|
-
Vedeu.
|
16
|
-
|
17
|
-
Vedeu::Timer.for(message) do
|
15
|
+
Vedeu::Timer.for(:info, message) do
|
18
16
|
Vedeu.interfaces.registered.each { |name| by_name(name) }
|
19
17
|
end
|
20
18
|
end
|
@@ -34,9 +32,7 @@ module Vedeu
|
|
34
32
|
def by_group(group_name)
|
35
33
|
message = "Refreshing group: '#{group_name}'"
|
36
34
|
|
37
|
-
Vedeu.
|
38
|
-
|
39
|
-
Vedeu::Timer.for(message) do
|
35
|
+
Vedeu::Timer.for(:info, message) do
|
40
36
|
Vedeu.groups.find!(group_name).members.each { |name| by_name(name) }
|
41
37
|
end
|
42
38
|
end
|
@@ -49,9 +45,7 @@ module Vedeu
|
|
49
45
|
def by_name(name)
|
50
46
|
message = "Refreshing interface: '#{name}'"
|
51
47
|
|
52
|
-
Vedeu.
|
53
|
-
|
54
|
-
Vedeu::Timer.for(message) { Vedeu.buffers.by_name(name).render }
|
48
|
+
Vedeu::Timer.for(:info, message) { Vedeu.buffers.by_name(name).render }
|
55
49
|
end
|
56
50
|
|
57
51
|
end # Refresh
|