vedeu 0.6.56 → 0.6.57
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/Guardfile +1 -1
- data/Rakefile +3 -3
- data/lib/vedeu/borders/all.rb +1 -0
- data/lib/vedeu/borders/border.rb +14 -80
- data/lib/vedeu/borders/caption.rb +17 -0
- data/lib/vedeu/borders/dsl.rb +2 -2
- data/lib/vedeu/borders/null.rb +14 -34
- data/lib/vedeu/borders/refresh.rb +28 -14
- data/lib/vedeu/borders/title.rb +0 -10
- data/lib/vedeu/buffers/buffer.rb +1 -1
- data/lib/vedeu/buffers/view.rb +7 -6
- data/lib/vedeu/colours/repository.rb +0 -15
- data/lib/vedeu/cursors/cursor.rb +6 -6
- data/lib/vedeu/cursors/refresh.rb +11 -19
- data/lib/vedeu/cursors/reposition.rb +3 -5
- data/lib/vedeu/editor/cropper.rb +9 -9
- data/lib/vedeu/editor/cursor.rb +5 -5
- data/lib/vedeu/editor/editor.rb +1 -1
- data/lib/vedeu/events/event.rb +1 -1
- data/lib/vedeu/events/trigger.rb +1 -1
- data/lib/vedeu/geometry/area.rb +94 -17
- data/lib/vedeu/geometry/coordinate.rb +15 -15
- data/lib/vedeu/geometry/dimension.rb +2 -2
- data/lib/vedeu/geometry/geometry.rb +30 -27
- data/lib/vedeu/geometry/null.rb +17 -11
- data/lib/vedeu/interfaces/clear.rb +5 -12
- data/lib/vedeu/output/viewport.rb +13 -13
- data/lib/vedeu/plugins/plugin.rb +1 -1
- data/lib/vedeu/repositories/repository.rb +1 -3
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/borders/border_test.rb +4 -230
- data/test/lib/vedeu/borders/caption_test.rb +15 -0
- data/test/lib/vedeu/borders/dsl_test.rb +4 -4
- data/test/lib/vedeu/borders/null_test.rb +3 -39
- data/test/lib/vedeu/buffers/view_test.rb +2 -0
- data/test/lib/vedeu/colours/repository_test.rb +0 -19
- data/test/lib/vedeu/cursors/reposition_test.rb +17 -4
- data/test/lib/vedeu/dsl/shared_test.rb +34 -0
- data/test/lib/vedeu/geometry/area_test.rb +196 -3
- data/test/lib/vedeu/geometry/dimension_test.rb +79 -79
- data/test/lib/vedeu/geometry/geometry_test.rb +4 -0
- data/test/lib/vedeu/groups/refresh_test.rb +1 -1
- data/test/lib/vedeu/logging/clock_time_test.rb +14 -0
- data/test/lib/vedeu/logging/ips_test.rb +43 -0
- data/test/lib/vedeu/output/presentation/colour_test.rb +4 -0
- data/test/lib/vedeu/repositories/repositories_test.rb +7 -1
- data/test/lib/vedeu/terminal/buffer_test.rb +10 -0
- data/test/support/examples/material_colours_app.rb +306 -47
- data/test/test_helper.rb +5 -5
- metadata +7 -4
- data/test/support/examples/borders_app.rb +0 -330
@@ -50,21 +50,6 @@ module Vedeu
|
|
50
50
|
storage.fetch(colour, '')
|
51
51
|
end
|
52
52
|
|
53
|
-
# Retrieves the escape sequence of a registered colour, or
|
54
|
-
# registers the colour with its respective escape sequence.
|
55
|
-
#
|
56
|
-
# @return [String]
|
57
|
-
# @todo Unused - GL 2015-09-26
|
58
|
-
def retrieve_or_register(colour, escape_sequence)
|
59
|
-
if registered?(colour)
|
60
|
-
retrieve(colour)
|
61
|
-
|
62
|
-
else
|
63
|
-
register(colour, escape_sequence)
|
64
|
-
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
53
|
end # Repository
|
69
54
|
|
70
55
|
end # Colours
|
data/lib/vedeu/cursors/cursor.rb
CHANGED
@@ -13,7 +13,7 @@ module Vedeu
|
|
13
13
|
include Vedeu::Toggleable
|
14
14
|
extend Forwardable
|
15
15
|
|
16
|
-
def_delegators :
|
16
|
+
def_delegators :geometry,
|
17
17
|
:bx,
|
18
18
|
:bxn,
|
19
19
|
:by,
|
@@ -47,7 +47,7 @@ module Vedeu
|
|
47
47
|
|
48
48
|
# Returns a new instance of Vedeu::Cursors::Cursor.
|
49
49
|
#
|
50
|
-
# @
|
50
|
+
# @param attributes [Hash<Symbol => Boolean|Fixnum|String|
|
51
51
|
# Vedeu::Cursors::Repository>]
|
52
52
|
# @option attributes name [String|Symbol] The name of the
|
53
53
|
# interface this cursor belongs to.
|
@@ -253,11 +253,11 @@ module Vedeu
|
|
253
253
|
|
254
254
|
private
|
255
255
|
|
256
|
-
# Returns the
|
256
|
+
# Returns the geometry for the interface.
|
257
257
|
#
|
258
|
-
# @return (see Vedeu::
|
259
|
-
def
|
260
|
-
@
|
258
|
+
# @return (see Vedeu::Geometry::Repository#by_name)
|
259
|
+
def geometry
|
260
|
+
@geometry ||= Vedeu.geometries.by_name(name)
|
261
261
|
end
|
262
262
|
|
263
263
|
# Determine correct x and y related coordinates.
|
@@ -13,9 +13,9 @@ module Vedeu
|
|
13
13
|
extend Forwardable
|
14
14
|
include Vedeu::Common
|
15
15
|
|
16
|
-
def_delegators :
|
17
|
-
:
|
18
|
-
:
|
16
|
+
def_delegators :geometry,
|
17
|
+
:bordered_height,
|
18
|
+
:bordered_width
|
19
19
|
|
20
20
|
# @example
|
21
21
|
# Vedeu.trigger(:_refresh_cursor_, name)
|
@@ -61,11 +61,13 @@ module Vedeu
|
|
61
61
|
|
62
62
|
# Returns true when the view should be refreshed. This is
|
63
63
|
# determined by checking that the offsets for x and y are
|
64
|
-
# outside the width and height of the
|
64
|
+
# outside the (bordered) width and (bordered) height of the
|
65
|
+
# named interface.
|
65
66
|
#
|
66
67
|
# @return [Boolean]
|
67
68
|
def refresh_view?
|
68
|
-
cursor.visible? && cursor.ox >=
|
69
|
+
cursor.visible? && (cursor.ox >= bordered_width ||
|
70
|
+
cursor.oy >= bordered_height)
|
69
71
|
end
|
70
72
|
|
71
73
|
# @return [Vedeu::Cursors::Cursor]
|
@@ -74,21 +76,11 @@ module Vedeu
|
|
74
76
|
@cursor ||= Vedeu.cursors.by_name(name)
|
75
77
|
end
|
76
78
|
|
77
|
-
# Fetch the
|
79
|
+
# Fetch the geometry by name.
|
78
80
|
#
|
79
|
-
# @
|
80
|
-
|
81
|
-
|
82
|
-
# {Vedeu::Borders::Null} which uses
|
83
|
-
# {Vedeu::Geometry::Geometry} to determine it's dimensions
|
84
|
-
# based on the name also. When a {Vedeu::Geometry::Geometry}
|
85
|
-
# cannot be found, this falls back to a
|
86
|
-
# {Vedeu::Geometry::Null} which uses the dimensions of the
|
87
|
-
# current terminal.
|
88
|
-
#
|
89
|
-
# @return (see Vedeu::Borders::Repository#by_name)
|
90
|
-
def border
|
91
|
-
@border ||= Vedeu.borders.by_name(name)
|
81
|
+
# @return (see Vedeu::Geometry::Repository#by_name)
|
82
|
+
def geometry
|
83
|
+
@geometry ||= Vedeu.geometries.by_name(name)
|
92
84
|
end
|
93
85
|
|
94
86
|
end # Refresh
|
@@ -27,11 +27,9 @@ module Vedeu
|
|
27
27
|
|
28
28
|
# @return [Vedeu::Cursors::Cursor]
|
29
29
|
def reposition
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
cursor
|
30
|
+
Vedeu::Cursors::Cursor.store(new_attributes) do
|
31
|
+
Vedeu.trigger(:_refresh_cursor_, name)
|
32
|
+
end
|
35
33
|
end
|
36
34
|
|
37
35
|
protected
|
data/lib/vedeu/editor/cropper.rb
CHANGED
@@ -12,13 +12,13 @@ module Vedeu
|
|
12
12
|
extend Forwardable
|
13
13
|
include Vedeu::Common
|
14
14
|
|
15
|
-
def_delegators :
|
15
|
+
def_delegators :geometry,
|
16
|
+
:bordered_height,
|
17
|
+
:bordered_width,
|
16
18
|
:bx,
|
17
19
|
:bxn,
|
18
20
|
:by,
|
19
|
-
:byn
|
20
|
-
:height,
|
21
|
-
:width
|
21
|
+
:byn
|
22
22
|
|
23
23
|
# Returns a new instance of Vedeu::Editor::Cropper.
|
24
24
|
#
|
@@ -87,7 +87,7 @@ module Vedeu
|
|
87
87
|
#
|
88
88
|
# @return [Vedeu::Editor::Lines]
|
89
89
|
def lines
|
90
|
-
@lines[oy...(oy +
|
90
|
+
@lines[oy...(oy + bordered_height)] || []
|
91
91
|
end
|
92
92
|
|
93
93
|
# Returns the interface by name.
|
@@ -101,14 +101,14 @@ module Vedeu
|
|
101
101
|
#
|
102
102
|
# @return [String]
|
103
103
|
def columns(line)
|
104
|
-
line[ox...(ox +
|
104
|
+
line[ox...(ox + bordered_width)] || ''
|
105
105
|
end
|
106
106
|
|
107
107
|
# Returns the border for the interface.
|
108
108
|
#
|
109
|
-
# @return (see Vedeu::
|
110
|
-
def
|
111
|
-
@
|
109
|
+
# @return (see Vedeu::Geometry::Repository#by_name)
|
110
|
+
def geometry
|
111
|
+
@geometry ||= Vedeu.geometries.by_name(name)
|
112
112
|
end
|
113
113
|
|
114
114
|
end # Editor
|
data/lib/vedeu/editor/cursor.rb
CHANGED
@@ -11,7 +11,7 @@ module Vedeu
|
|
11
11
|
|
12
12
|
extend Forwardable
|
13
13
|
|
14
|
-
def_delegators :
|
14
|
+
def_delegators :geometry,
|
15
15
|
:bx,
|
16
16
|
:bxn,
|
17
17
|
:by,
|
@@ -162,11 +162,11 @@ module Vedeu
|
|
162
162
|
|
163
163
|
private
|
164
164
|
|
165
|
-
# Returns the
|
165
|
+
# Returns the geometry for the interface.
|
166
166
|
#
|
167
|
-
# @return (see Vedeu::
|
168
|
-
def
|
169
|
-
@border ||= Vedeu.
|
167
|
+
# @return (see Vedeu::Geometry::Repository#by_name)
|
168
|
+
def geometry
|
169
|
+
@border ||= Vedeu.geometries.by_name(name)
|
170
170
|
end
|
171
171
|
|
172
172
|
# Returns the default options/attributes for this class.
|
data/lib/vedeu/editor/editor.rb
CHANGED
data/lib/vedeu/events/event.rb
CHANGED
data/lib/vedeu/events/trigger.rb
CHANGED
data/lib/vedeu/geometry/area.rb
CHANGED
@@ -8,6 +8,15 @@ module Vedeu
|
|
8
8
|
#
|
9
9
|
class Area
|
10
10
|
|
11
|
+
extend Forwardable
|
12
|
+
|
13
|
+
def_delegators :border,
|
14
|
+
:bottom?,
|
15
|
+
:enabled?,
|
16
|
+
:left?,
|
17
|
+
:right?,
|
18
|
+
:top?
|
19
|
+
|
11
20
|
# @!attribute [r] y
|
12
21
|
# @return [Fixnum] Returns the top coordinate (row/line start
|
13
22
|
# position) of the interface.
|
@@ -33,51 +42,58 @@ module Vedeu
|
|
33
42
|
alias_method :right, :xn
|
34
43
|
|
35
44
|
# @param attributes [Hash<Symbol => Boolean|Fixnum|Symbol>]
|
36
|
-
# @option attributes
|
37
|
-
# @option attributes
|
38
|
-
# @option attributes
|
39
|
-
# @option attributes
|
45
|
+
# @option attributes horizontal_alignment [Symbol]
|
46
|
+
# @option attributes maximised [Boolean]
|
47
|
+
# @option attributes name [String|Symbol]
|
48
|
+
# @option attributes vertical_alignment [Symbol]
|
40
49
|
# @option attributes x [Fixnum]
|
41
50
|
# @option attributes xn [Fixnum]
|
42
51
|
# @option attributes x_xn [Fixnum]
|
43
52
|
# @option attributes x_default [Fixnum]
|
44
|
-
# @option attributes
|
45
|
-
# @option attributes
|
46
|
-
# @option attributes
|
53
|
+
# @option attributes y [Fixnum]
|
54
|
+
# @option attributes yn [Fixnum]
|
55
|
+
# @option attributes y_yn [Fixnum]
|
56
|
+
# @option attributes y_default [Fixnum]
|
47
57
|
# @return [Vedeu::Geometry::Area]
|
48
58
|
def self.from_attributes(attributes = {})
|
49
59
|
y_attributes = {
|
60
|
+
alignment: attributes[:vertical_alignment],
|
50
61
|
d: attributes[:y],
|
51
62
|
dn: attributes[:yn],
|
52
63
|
d_dn: attributes[:y_yn],
|
53
64
|
maximised: attributes[:maximised],
|
54
|
-
alignment: attributes[:vertical_alignment],
|
55
65
|
}
|
56
66
|
x_attributes = {
|
67
|
+
alignment: attributes[:horizontal_alignment],
|
57
68
|
d: attributes[:x],
|
58
69
|
dn: attributes[:xn],
|
59
70
|
d_dn: attributes[:x_xn],
|
60
71
|
maximised: attributes[:maximised],
|
61
|
-
alignment: attributes[:horizontal_alignment],
|
62
72
|
}
|
63
73
|
y_yn = Vedeu::Geometry::YDimension.pair(y_attributes)
|
64
74
|
x_xn = Vedeu::Geometry::XDimension.pair(x_attributes)
|
65
75
|
|
66
|
-
new(
|
76
|
+
new(name: attributes[:name],
|
77
|
+
y: y_yn[0],
|
78
|
+
yn: y_yn[-1],
|
79
|
+
x: x_xn[0],
|
80
|
+
xn: x_xn[-1])
|
67
81
|
end
|
68
82
|
|
69
83
|
# Returns a new instance of Vedeu::Area.
|
70
84
|
#
|
85
|
+
# @param name [Symbol|String]
|
71
86
|
# @param y [Fixnum] The starting row/line position.
|
72
87
|
# @param yn [Fixnum] The ending row/line position.
|
73
88
|
# @param x [Fixnum] The starting column/character position.
|
74
89
|
# @param xn [Fixnum] The ending column/character position.
|
75
90
|
# @return [Vedeu::Geometry::Area]
|
76
|
-
def initialize(y:, yn:, x:, xn:)
|
77
|
-
@
|
78
|
-
@
|
79
|
-
@
|
80
|
-
@
|
91
|
+
def initialize(name:, y:, yn:, x:, xn:)
|
92
|
+
@name = name
|
93
|
+
@y = y
|
94
|
+
@yn = yn
|
95
|
+
@x = x
|
96
|
+
@xn = xn
|
81
97
|
end
|
82
98
|
|
83
99
|
# An object is equal when its values are the same.
|
@@ -90,6 +106,54 @@ module Vedeu
|
|
90
106
|
end
|
91
107
|
alias_method :==, :eql?
|
92
108
|
|
109
|
+
# Returns the width of the interface determined by whether a
|
110
|
+
# left, right, both or neither borders are shown.
|
111
|
+
#
|
112
|
+
# @return [Fixnum]
|
113
|
+
def bordered_width
|
114
|
+
(bxn - bx) + 1
|
115
|
+
end
|
116
|
+
|
117
|
+
# Returns the height of the interface determined by whether a
|
118
|
+
# top, bottom, both or neither borders are shown.
|
119
|
+
#
|
120
|
+
# @return [Fixnum]
|
121
|
+
def bordered_height
|
122
|
+
(byn - by) + 1
|
123
|
+
end
|
124
|
+
|
125
|
+
# Return the column position for 1 character right of the left
|
126
|
+
# border.
|
127
|
+
#
|
128
|
+
# @return [Fixnum]
|
129
|
+
def bx
|
130
|
+
(enabled? && left?) ? x + 1 : x
|
131
|
+
end
|
132
|
+
|
133
|
+
# Return the column position for 1 character left of the right
|
134
|
+
# border.
|
135
|
+
#
|
136
|
+
# @return [Fixnum]
|
137
|
+
def bxn
|
138
|
+
(enabled? && right?) ? xn - 1 : xn
|
139
|
+
end
|
140
|
+
|
141
|
+
# Return the row position for 1 character under of the top
|
142
|
+
# border.
|
143
|
+
#
|
144
|
+
# @return [Fixnum]
|
145
|
+
def by
|
146
|
+
(enabled? && top?) ? y + 1 : y
|
147
|
+
end
|
148
|
+
|
149
|
+
# Return the column position for 1 character above of the bottom
|
150
|
+
# border.
|
151
|
+
#
|
152
|
+
# @return [Fixnum]
|
153
|
+
def byn
|
154
|
+
(enabled? && bottom?) ? yn - 1 : yn
|
155
|
+
end
|
156
|
+
|
93
157
|
# Returns an array containing the centred y and x coordinates of
|
94
158
|
# the interface.
|
95
159
|
#
|
@@ -118,14 +182,14 @@ module Vedeu
|
|
118
182
|
#
|
119
183
|
# @return [Fixnum]
|
120
184
|
def height
|
121
|
-
(y
|
185
|
+
(yn - y) + 1
|
122
186
|
end
|
123
187
|
|
124
188
|
# Returns the width of the interface.
|
125
189
|
#
|
126
190
|
# @return [Fixnum]
|
127
191
|
def width
|
128
|
-
(x
|
192
|
+
(xn - x) + 1
|
129
193
|
end
|
130
194
|
|
131
195
|
# Returns the row above the top by default.
|
@@ -188,6 +252,19 @@ module Vedeu
|
|
188
252
|
x - offset
|
189
253
|
end
|
190
254
|
|
255
|
+
protected
|
256
|
+
|
257
|
+
# @!attribute [r] name
|
258
|
+
# @return [String|Symbol]
|
259
|
+
attr_reader :name
|
260
|
+
|
261
|
+
private
|
262
|
+
|
263
|
+
# @return [Vedeu::Borders::Border]
|
264
|
+
def border
|
265
|
+
@border = Vedeu.borders.by_name(name)
|
266
|
+
end
|
267
|
+
|
191
268
|
end # Area
|
192
269
|
|
193
270
|
end # Geometry
|
@@ -69,7 +69,7 @@ module Vedeu
|
|
69
69
|
protected
|
70
70
|
|
71
71
|
# @!attribute [r] name
|
72
|
-
# @return [String]
|
72
|
+
# @return [String|Symbol]
|
73
73
|
attr_reader :name
|
74
74
|
|
75
75
|
# @!attribute [r] offset
|
@@ -82,39 +82,39 @@ module Vedeu
|
|
82
82
|
|
83
83
|
private
|
84
84
|
|
85
|
-
# Returns the
|
85
|
+
# Returns the geometry for the interface.
|
86
86
|
#
|
87
|
-
# @return (see Vedeu::
|
88
|
-
def
|
89
|
-
@
|
87
|
+
# @return (see Vedeu::Geometry::Repository#by_name)
|
88
|
+
def geometry
|
89
|
+
@geometry ||= Vedeu.geometries.by_name(name)
|
90
90
|
end
|
91
91
|
|
92
|
-
# Return the :x or :y value from the
|
92
|
+
# Return the :x or :y value from the geometry.
|
93
93
|
#
|
94
94
|
# @return [Fixnum]
|
95
95
|
def d
|
96
|
-
|
96
|
+
geometry.send(coordinate_type[0])
|
97
97
|
end
|
98
98
|
|
99
|
-
# Return the :bx or :by value from the
|
99
|
+
# Return the :bx or :by value from the geometry.
|
100
100
|
#
|
101
101
|
# @return [Fixnum]
|
102
102
|
def bd
|
103
|
-
|
103
|
+
geometry.send(coordinate_type[1])
|
104
104
|
end
|
105
105
|
|
106
|
-
# Return the :bxn or :byn value from the
|
106
|
+
# Return the :bxn or :byn value from the geometry.
|
107
107
|
#
|
108
108
|
# @return [Fixnum]
|
109
109
|
def bdn
|
110
|
-
|
110
|
+
geometry.send(coordinate_type[2])
|
111
111
|
end
|
112
112
|
|
113
|
-
# Return the :width or :height value from the
|
113
|
+
# Return the :width or :height value from the geometry.
|
114
114
|
#
|
115
115
|
# @return [Fixnum]
|
116
116
|
def d_dn
|
117
|
-
|
117
|
+
geometry.send(coordinate_type[3])
|
118
118
|
end
|
119
119
|
|
120
120
|
# Ascertain the correct methods to use for determining the
|
@@ -125,8 +125,8 @@ module Vedeu
|
|
125
125
|
# @return [Fixnum]
|
126
126
|
def coordinate_type
|
127
127
|
@_type ||= case type
|
128
|
-
when :x then [:x, :bx, :bxn, :
|
129
|
-
when :y then [:y, :by, :byn, :
|
128
|
+
when :x then [:x, :bx, :bxn, :bordered_width]
|
129
|
+
when :y then [:y, :by, :byn, :bordered_height]
|
130
130
|
else
|
131
131
|
fail Vedeu::Error::InvalidSyntax,
|
132
132
|
'Coordinate type not given, cannot continue.'.freeze
|