vedeu 0.6.60 → 0.6.61
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/dsl.md +18 -18
- data/docs/events/drb.md +2 -8
- data/docs/events/view.md +2 -2
- data/docs/events/visibility.md +1 -4
- data/lib/vedeu/all.rb +1 -1
- data/lib/vedeu/borders/border.rb +1 -1
- data/lib/vedeu/borders/refresh.rb +1 -1
- data/lib/vedeu/buffers/empty.rb +6 -4
- data/lib/vedeu/buffers/view.rb +78 -7
- data/lib/vedeu/cursors/cursor.rb +7 -5
- data/lib/vedeu/cursors/refresh.rb +1 -1
- data/lib/vedeu/cursors/reposition.rb +5 -3
- data/lib/vedeu/cursors/repository.rb +4 -6
- data/lib/vedeu/dsl/shared.rb +5 -5
- data/lib/vedeu/editor/cropper.rb +1 -1
- data/lib/vedeu/editor/cursor.rb +2 -2
- data/lib/vedeu/editor/item.rb +3 -3
- data/lib/vedeu/error.rb +1 -1
- data/lib/vedeu/esc/esc.rb +1 -1
- data/lib/vedeu/events/aliases.rb +2 -2
- data/lib/vedeu/{geometry → geometries}/alignment.rb +8 -8
- data/lib/vedeu/geometries/all.rb +31 -0
- data/lib/vedeu/{geometry → geometries}/area.rb +8 -8
- data/lib/vedeu/{geometry → geometries}/coordinate.rb +5 -5
- data/lib/vedeu/{geometry → geometries}/dimension.rb +6 -6
- data/lib/vedeu/{geometry → geometries}/dsl.rb +22 -22
- data/lib/vedeu/{geometry → geometries}/geometry.rb +15 -15
- data/lib/vedeu/{geometry → geometries}/grid.rb +6 -6
- data/lib/vedeu/{geometry → geometries}/horizontal_alignment.rb +3 -3
- data/lib/vedeu/{geometry → geometries}/move.rb +5 -5
- data/lib/vedeu/{geometry → geometries}/position.rb +18 -18
- data/lib/vedeu/{geometry → geometries}/repository.rb +9 -9
- data/lib/vedeu/{geometry → geometries}/validator.rb +3 -3
- data/lib/vedeu/{geometry → geometries}/vertical_alignment.rb +3 -3
- data/lib/vedeu/{geometry → geometries}/x_dimension.rb +4 -4
- data/lib/vedeu/{geometry → geometries}/y_dimension.rb +4 -4
- data/lib/vedeu/groups/group.rb +2 -1
- data/lib/vedeu/input/store.rb +2 -1
- data/lib/vedeu/interfaces/clear.rb +8 -6
- data/lib/vedeu/interfaces/interface.rb +1 -1
- data/lib/vedeu/models/cell.rb +2 -2
- data/lib/vedeu/models/escape.rb +2 -2
- data/lib/vedeu/models/focus.rb +2 -1
- data/lib/vedeu/models/page.rb +3 -2
- data/lib/vedeu/models/row.rb +10 -1
- data/lib/vedeu/models/views/char.rb +6 -6
- data/lib/vedeu/models/views/line.rb +1 -1
- data/lib/vedeu/output/compressor.rb +10 -15
- data/lib/vedeu/output/presentation/presentation.rb +1 -1
- data/lib/vedeu/output/renderers/all.rb +7 -8
- data/lib/vedeu/output/viewport.rb +1 -1
- data/lib/vedeu/repositories/store.rb +2 -2
- data/lib/vedeu/terminal/buffer.rb +46 -102
- data/lib/vedeu/terminal/terminal.rb +10 -2
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/borders/refresh_test.rb +1 -1
- data/test/lib/vedeu/buffers/empty_test.rb +3 -3
- data/test/lib/vedeu/buffers/view_test.rb +48 -1
- data/test/lib/vedeu/cursors/cursor_test.rb +2 -2
- data/test/lib/vedeu/editor/cropper_test.rb +1 -1
- data/test/lib/vedeu/editor/cursor_test.rb +1 -1
- data/test/lib/vedeu/editor/document_test.rb +2 -2
- data/test/lib/vedeu/{geometry → geometries}/alignment_test.rb +5 -5
- data/test/lib/vedeu/{geometry → geometries}/area_test.rb +4 -4
- data/test/lib/vedeu/{geometry → geometries}/coordinate.rb +5 -5
- data/test/lib/vedeu/{geometry → geometries}/dimension_test.rb +7 -5
- data/test/lib/vedeu/{geometry → geometries}/dsl_test.rb +31 -27
- data/test/lib/vedeu/{geometry → geometries}/geometry_test.rb +10 -7
- data/test/lib/vedeu/{geometry → geometries}/grid_test.rb +13 -9
- data/test/lib/vedeu/{geometry → geometries}/horizontal_alignment_test.rb +3 -3
- data/test/lib/vedeu/{geometry → geometries}/move_test.rb +10 -10
- data/test/lib/vedeu/{geometry → geometries}/position_test.rb +16 -15
- data/test/lib/vedeu/{geometry → geometries}/repository_test.rb +3 -3
- data/test/lib/vedeu/{geometry → geometries}/validator_test.rb +4 -4
- data/test/lib/vedeu/{geometry → geometries}/vertical_alignment_test.rb +3 -3
- data/test/lib/vedeu/{geometry → geometries}/x_dimension_test.rb +3 -3
- data/test/lib/vedeu/{geometry → geometries}/y_dimension_test.rb +3 -3
- data/test/lib/vedeu/interfaces/clear_test.rb +1 -1
- data/test/lib/vedeu/models/cell_test.rb +1 -1
- data/test/lib/vedeu/models/escape_test.rb +2 -2
- data/test/lib/vedeu/models/page_test.rb +18 -2
- data/test/lib/vedeu/models/views/char_test.rb +3 -3
- data/test/lib/vedeu/output/compressor_test.rb +30 -16
- data/test/lib/vedeu/output/renderers/html_test.rb +1 -1
- data/test/lib/vedeu/output/renderers/json_test.rb +17 -1
- data/test/lib/vedeu/output/viewport_test.rb +1 -1
- data/test/lib/vedeu/terminal/buffer_test.rb +6 -18
- data/test/lib/vedeu/terminal/terminal_test.rb +1 -1
- data/test/support/examples/material_colours_app.rb +2 -0
- data/test/test_helper.rb +1 -1
- metadata +48 -48
- data/lib/vedeu/geometry/all.rb +0 -31
@@ -1,6 +1,6 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
module
|
3
|
+
module Geometries
|
4
4
|
|
5
5
|
# The grid system splits the terminal height and width into 12
|
6
6
|
# equal parts, by dividing the available height and width by 12.
|
@@ -23,22 +23,22 @@ module Vedeu
|
|
23
23
|
new(value).rows
|
24
24
|
end
|
25
25
|
|
26
|
-
# Returns a new instance of Vedeu::
|
26
|
+
# Returns a new instance of Vedeu::Geometries::Grid.
|
27
27
|
#
|
28
28
|
# @param value [Fixnum]
|
29
|
-
# @return [Vedeu::
|
29
|
+
# @return [Vedeu::Geometries::Grid]
|
30
30
|
def initialize(value)
|
31
31
|
@value = value
|
32
32
|
end
|
33
33
|
|
34
|
-
# @see Vedeu::
|
34
|
+
# @see Vedeu::Geometries::DSL#columns
|
35
35
|
def columns
|
36
36
|
fail Vedeu::Error::OutOfRange if out_of_range?
|
37
37
|
|
38
38
|
column * value
|
39
39
|
end
|
40
40
|
|
41
|
-
# @see Vedeu::
|
41
|
+
# @see Vedeu::Geometries::DSL#rows
|
42
42
|
def rows
|
43
43
|
fail Vedeu::Error::OutOfRange if out_of_range?
|
44
44
|
|
@@ -77,6 +77,6 @@ module Vedeu
|
|
77
77
|
|
78
78
|
end # Grid
|
79
79
|
|
80
|
-
end #
|
80
|
+
end # Geometries
|
81
81
|
|
82
82
|
end # Vedeu
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
module
|
3
|
+
module Geometries
|
4
4
|
|
5
5
|
# Provides the mechanism to align an interface/view horizontally
|
6
6
|
# within the available terminal space.
|
7
7
|
#
|
8
8
|
# @api private
|
9
9
|
#
|
10
|
-
class HorizontalAlignment < Vedeu::
|
10
|
+
class HorizontalAlignment < Vedeu::Geometries::Alignment
|
11
11
|
|
12
12
|
# @raise [Vedeu::Error::InvalidSyntax] When the value is not one
|
13
13
|
# of :bottom, :centre, :left, :middle, :right, :top.
|
@@ -22,6 +22,6 @@ module Vedeu
|
|
22
22
|
|
23
23
|
end # HorizontalAlignment
|
24
24
|
|
25
|
-
end #
|
25
|
+
end # Geometries
|
26
26
|
|
27
27
|
end # Vedeu
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
module
|
3
|
+
module Geometries
|
4
4
|
|
5
5
|
# Move an interface/view via changing its geometry.
|
6
6
|
#
|
@@ -33,11 +33,11 @@ module Vedeu
|
|
33
33
|
new(attributes).move
|
34
34
|
end
|
35
35
|
|
36
|
-
# @return [FalseClass|Vedeu::
|
36
|
+
# @return [FalseClass|Vedeu::Geometries::Geometry]
|
37
37
|
def move
|
38
38
|
return false unless valid?
|
39
39
|
|
40
|
-
Vedeu::
|
40
|
+
Vedeu::Geometries::Geometry.store(new_attributes) do
|
41
41
|
update_cursor!
|
42
42
|
refresh!
|
43
43
|
end
|
@@ -95,7 +95,7 @@ module Vedeu
|
|
95
95
|
}[direction]
|
96
96
|
end
|
97
97
|
|
98
|
-
# @return [Vedeu::
|
98
|
+
# @return [Vedeu::Geometries::Geometry]
|
99
99
|
def geometry
|
100
100
|
Vedeu.geometries.by_name(name)
|
101
101
|
end
|
@@ -203,6 +203,6 @@ module Vedeu
|
|
203
203
|
|
204
204
|
end # Move
|
205
205
|
|
206
|
-
end #
|
206
|
+
end # Geometries
|
207
207
|
|
208
208
|
end # Vedeu
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
module
|
3
|
+
module Geometries
|
4
4
|
|
5
5
|
# Change coordinates into an escape sequence to set the cursor
|
6
6
|
# position.
|
@@ -19,15 +19,15 @@ module Vedeu
|
|
19
19
|
attr_reader :x
|
20
20
|
alias_method :last, :x
|
21
21
|
|
22
|
-
# Convenience constructor for Vedeu::
|
22
|
+
# Convenience constructor for Vedeu::Geometries::Position.
|
23
23
|
#
|
24
24
|
# @param (see #initialize)
|
25
25
|
def self.[](y, x)
|
26
26
|
new(y, x)
|
27
27
|
end
|
28
28
|
|
29
|
-
# @param value [Array<Fixnum>|Vedeu::
|
30
|
-
# @return [Vedeu::
|
29
|
+
# @param value [Array<Fixnum>|Vedeu::Geometries::Position]
|
30
|
+
# @return [Vedeu::Geometries::Position]
|
31
31
|
def self.coerce(value)
|
32
32
|
if value.is_a?(self)
|
33
33
|
value
|
@@ -41,11 +41,11 @@ module Vedeu
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
# Initializes a new instance of Vedeu::
|
44
|
+
# Initializes a new instance of Vedeu::Geometries::Position.
|
45
45
|
#
|
46
46
|
# @param y [Fixnum] The row/line position.
|
47
47
|
# @param x [Fixnum] The column/character position.
|
48
|
-
# @return [Vedeu::
|
48
|
+
# @return [Vedeu::Geometries::Position]
|
49
49
|
def initialize(y = 1, x = 1)
|
50
50
|
@y = (y.nil? || y < 1) ? 1 : y
|
51
51
|
@x = (x.nil? || x < 1) ? 1 : x
|
@@ -64,7 +64,7 @@ module Vedeu
|
|
64
64
|
[yi, xi]
|
65
65
|
end
|
66
66
|
|
67
|
-
# @param other [Vedeu::
|
67
|
+
# @param other [Vedeu::Geometries::Position]
|
68
68
|
# @return [Fixnum]
|
69
69
|
def <=>(other)
|
70
70
|
if y == other.y
|
@@ -78,7 +78,7 @@ module Vedeu
|
|
78
78
|
|
79
79
|
# An object is equal when its values are the same.
|
80
80
|
#
|
81
|
-
# @param other [Vedeu::
|
81
|
+
# @param other [Vedeu::Geometries::Position]
|
82
82
|
# @return [Boolean]
|
83
83
|
def eql?(other)
|
84
84
|
self.class == other.class && (x == other.x && y == other.y)
|
@@ -92,7 +92,7 @@ module Vedeu
|
|
92
92
|
[y, x]
|
93
93
|
end
|
94
94
|
|
95
|
-
# @return [Vedeu::
|
95
|
+
# @return [Vedeu::Geometries::Position]
|
96
96
|
def to_position
|
97
97
|
self
|
98
98
|
end
|
@@ -114,30 +114,30 @@ module Vedeu
|
|
114
114
|
|
115
115
|
# Increase y coordinate; moves down.
|
116
116
|
#
|
117
|
-
# @return [Vedeu::
|
117
|
+
# @return [Vedeu::Geometries::Position]
|
118
118
|
def down
|
119
|
-
Vedeu::
|
119
|
+
Vedeu::Geometries::Position.new(y + 1, x)
|
120
120
|
end
|
121
121
|
|
122
122
|
# Decrease x coordinate; moves left.
|
123
123
|
#
|
124
|
-
# @return [Vedeu::
|
124
|
+
# @return [Vedeu::Geometries::Position]
|
125
125
|
def left
|
126
|
-
Vedeu::
|
126
|
+
Vedeu::Geometries::Position.new(y, x - 1)
|
127
127
|
end
|
128
128
|
|
129
129
|
# Increase x coordinate; moves right.
|
130
130
|
#
|
131
|
-
# @return [Vedeu::
|
131
|
+
# @return [Vedeu::Geometries::Position]
|
132
132
|
def right
|
133
|
-
Vedeu::
|
133
|
+
Vedeu::Geometries::Position.new(y, x + 1)
|
134
134
|
end
|
135
135
|
|
136
136
|
# Decrease y coordinate; moves up.
|
137
137
|
#
|
138
|
-
# @return [Vedeu::
|
138
|
+
# @return [Vedeu::Geometries::Position]
|
139
139
|
def up
|
140
|
-
Vedeu::
|
140
|
+
Vedeu::Geometries::Position.new(y - 1, x)
|
141
141
|
end
|
142
142
|
|
143
143
|
private
|
@@ -152,6 +152,6 @@ module Vedeu
|
|
152
152
|
|
153
153
|
end # Position
|
154
154
|
|
155
|
-
end #
|
155
|
+
end # Geometries
|
156
156
|
|
157
157
|
end # Vedeu
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
module
|
3
|
+
module Geometries
|
4
4
|
|
5
5
|
# Allows the storing of interface/view geometry independent of the
|
6
6
|
# interface instance.
|
@@ -9,12 +9,12 @@ module Vedeu
|
|
9
9
|
|
10
10
|
singleton_class.send(:alias_method, :geometries, :repository)
|
11
11
|
|
12
|
-
null Vedeu::
|
13
|
-
real Vedeu::
|
12
|
+
null Vedeu::Geometries::Geometry, height: Vedeu.height, width: Vedeu.width
|
13
|
+
real Vedeu::Geometries::Geometry
|
14
14
|
|
15
15
|
end # Repository
|
16
16
|
|
17
|
-
end #
|
17
|
+
end # Geometries
|
18
18
|
|
19
19
|
# Manipulate the repository of geometries.
|
20
20
|
#
|
@@ -22,8 +22,8 @@ module Vedeu
|
|
22
22
|
# Vedeu.geometries
|
23
23
|
#
|
24
24
|
# @!method geometries
|
25
|
-
# @return [Vedeu::
|
26
|
-
def_delegators Vedeu::
|
25
|
+
# @return [Vedeu::Geometries::Repository]
|
26
|
+
def_delegators Vedeu::Geometries::Repository,
|
27
27
|
:geometries
|
28
28
|
|
29
29
|
# :nocov:
|
@@ -48,9 +48,9 @@ module Vedeu
|
|
48
48
|
|
49
49
|
[:down, :left, :right, :up].each do |direction|
|
50
50
|
Vedeu.bind(:"_view_#{direction}_") do |name, offset|
|
51
|
-
Vedeu::
|
52
|
-
|
53
|
-
|
51
|
+
Vedeu::Geometries::Move.move(direction: direction,
|
52
|
+
name: name,
|
53
|
+
offset: offset)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
module
|
3
|
+
module Geometries
|
4
4
|
|
5
|
-
# Validate values given to {Vedeu::
|
5
|
+
# Validate values given to {Vedeu::Geometries::DSL}.
|
6
6
|
#
|
7
7
|
# @api private
|
8
8
|
#
|
@@ -55,6 +55,6 @@ module Vedeu
|
|
55
55
|
|
56
56
|
end # Validator
|
57
57
|
|
58
|
-
end #
|
58
|
+
end # Geometries
|
59
59
|
|
60
60
|
end # Vedeu
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
module
|
3
|
+
module Geometries
|
4
4
|
|
5
5
|
# Provides the mechanism to align an interface/view vertically
|
6
6
|
# within the available terminal space.
|
7
7
|
#
|
8
8
|
# @api private
|
9
9
|
#
|
10
|
-
class VerticalAlignment < Vedeu::
|
10
|
+
class VerticalAlignment < Vedeu::Geometries::Alignment
|
11
11
|
|
12
12
|
# @raise [Vedeu::Error::InvalidSyntax] When the value is not one
|
13
13
|
# of :bottom, :centre, :left, :middle, :right, :top.
|
@@ -22,6 +22,6 @@ module Vedeu
|
|
22
22
|
|
23
23
|
end # VerticalAlignment
|
24
24
|
|
25
|
-
end #
|
25
|
+
end # Geometries
|
26
26
|
|
27
27
|
end # Vedeu
|
@@ -1,22 +1,22 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
module
|
3
|
+
module Geometries
|
4
4
|
|
5
5
|
# The X Dimension provides the width of an entity.
|
6
6
|
#
|
7
7
|
# @api private
|
8
8
|
#
|
9
|
-
class XDimension < Vedeu::
|
9
|
+
class XDimension < Vedeu::Geometries::Dimension
|
10
10
|
|
11
11
|
private
|
12
12
|
|
13
|
-
# @see Vedeu::
|
13
|
+
# @see Vedeu::Geometries::Dimension#defaults
|
14
14
|
def defaults
|
15
15
|
super.merge!(default: Vedeu.width)
|
16
16
|
end
|
17
17
|
|
18
18
|
end # XDimension
|
19
19
|
|
20
|
-
end #
|
20
|
+
end # Geometries
|
21
21
|
|
22
22
|
end # Vedeu
|
@@ -1,22 +1,22 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
module
|
3
|
+
module Geometries
|
4
4
|
|
5
5
|
# The Y Dimension provides the height of an entity.
|
6
6
|
#
|
7
7
|
# @api private
|
8
8
|
#
|
9
|
-
class YDimension < Vedeu::
|
9
|
+
class YDimension < Vedeu::Geometries::Dimension
|
10
10
|
|
11
11
|
private
|
12
12
|
|
13
|
-
# @see Vedeu::
|
13
|
+
# @see Vedeu::Geometries::Dimension#defaults
|
14
14
|
def defaults
|
15
15
|
super.merge!(default: Vedeu.height)
|
16
16
|
end
|
17
17
|
|
18
18
|
end # YDimension
|
19
19
|
|
20
|
-
end #
|
20
|
+
end # Geometries
|
21
21
|
|
22
22
|
end # Vedeu
|
data/lib/vedeu/groups/group.rb
CHANGED
@@ -137,11 +137,12 @@ module Vedeu
|
|
137
137
|
# Remove all members from the group.
|
138
138
|
#
|
139
139
|
# @return [Vedeu::Groups::Group]
|
140
|
-
def reset
|
140
|
+
def reset!
|
141
141
|
attrs = defaults.merge!(name: name)
|
142
142
|
|
143
143
|
Vedeu::Groups::Group.store(attrs)
|
144
144
|
end
|
145
|
+
alias_method :reset, :reset!
|
145
146
|
|
146
147
|
# Show the named group of interfaces, or without a name, the
|
147
148
|
# group of the currently focussed interface.
|
data/lib/vedeu/input/store.rb
CHANGED
@@ -111,7 +111,7 @@ module Vedeu
|
|
111
111
|
|
112
112
|
# Returns the geometry for the interface.
|
113
113
|
#
|
114
|
-
# @return (see Vedeu::
|
114
|
+
# @return (see Vedeu::Geometries::Repository#by_name)
|
115
115
|
def geometry
|
116
116
|
@geometry ||= Vedeu.geometries.by_name(name)
|
117
117
|
end
|
@@ -143,8 +143,12 @@ module Vedeu
|
|
143
143
|
def optimised_output
|
144
144
|
Vedeu.timer("Optimised clearing #{clearing}: '#{name}'".freeze) do
|
145
145
|
height.times.map do |iy|
|
146
|
-
|
147
|
-
|
146
|
+
[
|
147
|
+
Vedeu::Geometries::Position.new(y + iy, x).to_s,
|
148
|
+
colour.to_s,
|
149
|
+
chars,
|
150
|
+
].join
|
151
|
+
end.join + Vedeu::Geometries::Position.new(y, x).to_s
|
148
152
|
end
|
149
153
|
end
|
150
154
|
|
@@ -217,12 +221,10 @@ module Vedeu
|
|
217
221
|
|
218
222
|
# @!method clear_by_name
|
219
223
|
# @see Vedeu::Interfaces::Clear.clear_by_name
|
220
|
-
def_delegators Vedeu::Interfaces::Clear,
|
221
|
-
:clear_by_name
|
222
|
-
|
223
224
|
# @!method clear_content_by_name
|
224
225
|
# @see Vedeu::Interfaces.Clear.clear_content_by_name
|
225
226
|
def_delegators Vedeu::Interfaces::Clear,
|
227
|
+
:clear_by_name,
|
226
228
|
:clear_content_by_name
|
227
229
|
|
228
230
|
# :nocov:
|
data/lib/vedeu/models/cell.rb
CHANGED
@@ -46,9 +46,9 @@ module Vedeu
|
|
46
46
|
@interface ||= Vedeu.interfaces.by_name(name)
|
47
47
|
end
|
48
48
|
|
49
|
-
# @return [Vedeu::
|
49
|
+
# @return [Vedeu::Geometries::Position]
|
50
50
|
def position
|
51
|
-
Vedeu::
|
51
|
+
Vedeu::Geometries::Position.coerce(@position)
|
52
52
|
end
|
53
53
|
|
54
54
|
# @return [Hash]
|