vedeu 0.6.35 → 0.6.36
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +3 -3
- data/examples/dsl_alignment.rb +162 -0
- data/examples/{demo_groups.rb → dsl_demo_groups.rb} +0 -0
- data/examples/{hello_worlds.rb → dsl_hello_worlds.rb} +0 -0
- data/examples/{alignment.rb → dsl_horizontal_alignment.rb} +13 -25
- data/examples/dsl_vertical_alignment.rb +183 -0
- data/lib/vedeu/geometry/alignment.rb +14 -25
- data/lib/vedeu/geometry/all.rb +4 -0
- data/lib/vedeu/geometry/area.rb +18 -17
- data/lib/vedeu/geometry/dimension.rb +61 -19
- data/lib/vedeu/geometry/dsl.rb +193 -13
- data/lib/vedeu/geometry/geometry.rb +58 -38
- data/lib/vedeu/geometry/horizontal_alignment.rb +25 -0
- data/lib/vedeu/geometry/vertical_alignment.rb +25 -0
- data/lib/vedeu/geometry/x_dimension.rb +33 -0
- data/lib/vedeu/geometry/y_dimension.rb +33 -0
- data/lib/vedeu/output/compressor.rb +9 -6
- data/lib/vedeu/output/renderers/file.rb +35 -11
- data/lib/vedeu/output/renderers/json.rb +2 -2
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/geometry/alignment_test.rb +4 -70
- data/test/lib/vedeu/geometry/area_test.rb +24 -22
- data/test/lib/vedeu/geometry/dimension_test.rb +97 -189
- data/test/lib/vedeu/geometry/dsl_test.rb +191 -24
- data/test/lib/vedeu/geometry/geometry_test.rb +31 -26
- data/test/lib/vedeu/geometry/horizontal_alignment_test.rb +61 -0
- data/test/lib/vedeu/geometry/vertical_alignment_test.rb +55 -0
- data/test/lib/vedeu/geometry/x_dimension_test.rb +74 -0
- data/test/lib/vedeu/geometry/y_dimension_test.rb +74 -0
- data/test/lib/vedeu/output/renderers/file_test.rb +6 -4
- metadata +19 -5
@@ -2,8 +2,13 @@ module Vedeu
|
|
2
2
|
|
3
3
|
module Geometry
|
4
4
|
|
5
|
-
#
|
6
|
-
#
|
5
|
+
# The subclasses of this class, HorizontalAlignment and
|
6
|
+
# VerticalAlignment provide the mechanism to align an interface or
|
7
|
+
# view horizontally or vertically within the available terminal
|
8
|
+
# space.
|
9
|
+
#
|
10
|
+
# @see Vedeu::Geometry::HorizontalAlignment
|
11
|
+
# @see Vedeu::Geometry::VerticalAlignment
|
7
12
|
#
|
8
13
|
class Alignment
|
9
14
|
|
@@ -19,33 +24,17 @@ module Vedeu
|
|
19
24
|
@value = value
|
20
25
|
end
|
21
26
|
|
22
|
-
# @raise [Vedeu::Error::
|
23
|
-
#
|
24
|
-
# @return [Symbol]
|
27
|
+
# @raise [Vedeu::Error::NotImplemented] Subclasses of this class
|
28
|
+
# must implement this method.
|
25
29
|
def align
|
26
|
-
|
27
|
-
|
28
|
-
fail Vedeu::Error::InvalidSyntax,
|
29
|
-
'Cannot align as value is invalid or undefined.'.freeze
|
30
|
+
fail Vedeu::Error::NotImplemented, 'Subclasses implement this.'.freeze
|
30
31
|
end
|
31
32
|
|
32
33
|
private
|
33
34
|
|
34
|
-
# @return [Boolean]
|
35
|
-
def align_value?
|
36
|
-
@value.to_s.start_with?('align_')
|
37
|
-
end
|
38
|
-
|
39
|
-
# @return [Symbol]
|
40
|
-
def coerced_value
|
41
|
-
coerced = @value.to_s.gsub!('align_', '').to_sym
|
42
|
-
|
43
|
-
coerced == :center ? :centre : coerced
|
44
|
-
end
|
45
|
-
|
46
35
|
# @return [Boolean]
|
47
36
|
def none?
|
48
|
-
@value.nil? || !(@value.is_a?(Symbol))
|
37
|
+
@value.nil? || !(@value.is_a?(Symbol))
|
49
38
|
end
|
50
39
|
|
51
40
|
# @return [Boolean]
|
@@ -61,9 +50,6 @@ module Vedeu
|
|
61
50
|
elsif @value == :center
|
62
51
|
:centre
|
63
52
|
|
64
|
-
elsif align_value?
|
65
|
-
coerced_value
|
66
|
-
|
67
53
|
else
|
68
54
|
@value.to_sym
|
69
55
|
|
@@ -73,10 +59,13 @@ module Vedeu
|
|
73
59
|
# @return [Array<Symbol>]
|
74
60
|
def values
|
75
61
|
[
|
62
|
+
:bottom,
|
76
63
|
:centre,
|
77
64
|
:left,
|
65
|
+
:middle,
|
78
66
|
:none,
|
79
67
|
:right,
|
68
|
+
:top,
|
80
69
|
]
|
81
70
|
end
|
82
71
|
|
data/lib/vedeu/geometry/all.rb
CHANGED
@@ -14,9 +14,13 @@ module Vedeu
|
|
14
14
|
end # Vedeu
|
15
15
|
|
16
16
|
require 'vedeu/geometry/alignment'
|
17
|
+
require 'vedeu/geometry/horizontal_alignment'
|
18
|
+
require 'vedeu/geometry/vertical_alignment'
|
17
19
|
require 'vedeu/geometry/area'
|
18
20
|
require 'vedeu/geometry/coordinate'
|
19
21
|
require 'vedeu/geometry/dimension'
|
22
|
+
require 'vedeu/geometry/x_dimension'
|
23
|
+
require 'vedeu/geometry/y_dimension'
|
20
24
|
require 'vedeu/geometry/dsl'
|
21
25
|
require 'vedeu/geometry/coordinate'
|
22
26
|
require 'vedeu/geometry/geometry'
|
data/lib/vedeu/geometry/area.rb
CHANGED
@@ -41,29 +41,30 @@ module Vedeu
|
|
41
41
|
# @option attributes x_default [Fixnum]
|
42
42
|
# @option attributes maximised [Boolean]
|
43
43
|
# @option attributes centred [Boolean]
|
44
|
-
# @option attributes
|
44
|
+
# @option attributes horizontal_alignment [Symbol]
|
45
|
+
# @option attributes vertical_alignment [Symbol]
|
45
46
|
# @return [Vedeu::Geometry::Area]
|
46
47
|
def self.from_attributes(attributes = {})
|
47
48
|
y_attributes = {
|
48
|
-
d:
|
49
|
-
dn:
|
50
|
-
d_dn:
|
51
|
-
default:
|
52
|
-
maximised:
|
53
|
-
centred:
|
54
|
-
|
49
|
+
d: attributes[:y],
|
50
|
+
dn: attributes[:yn],
|
51
|
+
d_dn: attributes[:y_yn],
|
52
|
+
default: Vedeu.height,
|
53
|
+
maximised: attributes[:maximised],
|
54
|
+
centred: attributes[:centred],
|
55
|
+
vertical_alignment: attributes[:vertical_alignment],
|
55
56
|
}
|
56
57
|
x_attributes = {
|
57
|
-
d:
|
58
|
-
dn:
|
59
|
-
d_dn:
|
60
|
-
default:
|
61
|
-
maximised:
|
62
|
-
centred:
|
63
|
-
|
58
|
+
d: attributes[:x],
|
59
|
+
dn: attributes[:xn],
|
60
|
+
d_dn: attributes[:x_xn],
|
61
|
+
default: Vedeu.width,
|
62
|
+
maximised: attributes[:maximised],
|
63
|
+
centred: attributes[:centred],
|
64
|
+
horizontal_alignment: attributes[:horizontal_alignment],
|
64
65
|
}
|
65
|
-
y_yn = Vedeu::Geometry::
|
66
|
-
x_xn = Vedeu::Geometry::
|
66
|
+
y_yn = Vedeu::Geometry::YDimension.pair(y_attributes)
|
67
|
+
x_xn = Vedeu::Geometry::XDimension.pair(x_attributes)
|
67
68
|
|
68
69
|
new(y: y_yn[0], yn: y_yn[-1], x: x_xn[0], xn: x_xn[-1])
|
69
70
|
end
|
@@ -24,7 +24,8 @@ module Vedeu
|
|
24
24
|
# The terminal width or height.
|
25
25
|
# @option attributes maximised [Boolean]
|
26
26
|
# @option attributes centered [Boolean]
|
27
|
-
# @option attributes
|
27
|
+
# @option attributes horizontal_alignment [Symbol]
|
28
|
+
# @option attributes vertical_alignment [Symbol]
|
28
29
|
# @return [Vedeu::Geometry::Dimension]
|
29
30
|
def initialize(attributes = {})
|
30
31
|
defaults.merge!(attributes).each do |key, value|
|
@@ -32,20 +33,6 @@ module Vedeu
|
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
35
|
-
# Fetch the starting coordinate.
|
36
|
-
#
|
37
|
-
# @return [Fixnum]
|
38
|
-
def d1
|
39
|
-
dimension[0] < 1 ? 1 : dimension[0]
|
40
|
-
end
|
41
|
-
|
42
|
-
# Fetch the ending coordinate.
|
43
|
-
#
|
44
|
-
# @return [Fixnum]
|
45
|
-
def d2
|
46
|
-
dimension[-1]
|
47
|
-
end
|
48
|
-
|
49
36
|
# Fetch the coordinates.
|
50
37
|
#
|
51
38
|
# @return [Array<Fixnum>]
|
@@ -81,12 +68,22 @@ module Vedeu
|
|
81
68
|
attr_reader :centred
|
82
69
|
alias_method :centred?, :centred
|
83
70
|
|
84
|
-
# @!attribute [r]
|
71
|
+
# @!attribute [r] horizontal_alignment
|
85
72
|
# @return [Symbol]
|
86
|
-
attr_reader :
|
73
|
+
attr_reader :horizontal_alignment
|
74
|
+
|
75
|
+
# @!attribute [r] vertical_alignment
|
76
|
+
# @return [Symbol]
|
77
|
+
attr_reader :vertical_alignment
|
87
78
|
|
88
79
|
private
|
89
80
|
|
81
|
+
# @raise [Vedeu::Error::NotImplemented] Subclasses of this class
|
82
|
+
# must implement this method.
|
83
|
+
def alignment
|
84
|
+
fail Vedeu::Error::NotImplemented, 'Subclasses implement this.'.freeze
|
85
|
+
end
|
86
|
+
|
90
87
|
# Return the dimension.
|
91
88
|
#
|
92
89
|
# 1) If maximised, it will be from the first row/line or column/
|
@@ -99,15 +96,24 @@ module Vedeu
|
|
99
96
|
@dimension = if maximised?
|
100
97
|
[1, default]
|
101
98
|
|
99
|
+
elsif bottom_aligned?
|
100
|
+
[bottom_d, default]
|
101
|
+
|
102
102
|
elsif centre_aligned?
|
103
103
|
[centred_d, centred_dn]
|
104
104
|
|
105
105
|
elsif left_aligned?
|
106
106
|
[1, left_dn]
|
107
107
|
|
108
|
+
elsif middle_aligned?
|
109
|
+
[centred_d, centred_dn]
|
110
|
+
|
108
111
|
elsif right_aligned?
|
109
112
|
[right_d, default]
|
110
113
|
|
114
|
+
elsif top_aligned?
|
115
|
+
[1, top_dn]
|
116
|
+
|
111
117
|
elsif centred? && length?
|
112
118
|
[centred_d, centred_dn]
|
113
119
|
|
@@ -173,6 +179,13 @@ module Vedeu
|
|
173
179
|
dn > default ? default : dn
|
174
180
|
end
|
175
181
|
|
182
|
+
# Ascertains the ending coordinate for a left or top aligned
|
183
|
+
# interface/view.
|
184
|
+
#
|
185
|
+
# 1) Use the width or height (d_dn), or
|
186
|
+
# 2) Use the xn or yn (dn), or
|
187
|
+
# 3) Default to the terminal width or height.
|
188
|
+
#
|
176
189
|
# @return [Fixnum]
|
177
190
|
def left_dn
|
178
191
|
if d_dn
|
@@ -186,7 +199,15 @@ module Vedeu
|
|
186
199
|
|
187
200
|
end
|
188
201
|
end
|
202
|
+
alias_method :top_dn, :left_dn
|
189
203
|
|
204
|
+
# Ascertains the starting coordinate for a right or bottom
|
205
|
+
# aligned interface/view.
|
206
|
+
#
|
207
|
+
# 1) Use the width or height (d_dn), or
|
208
|
+
# 2) Use the x or y (d), or
|
209
|
+
# 3) Default to 1.
|
210
|
+
#
|
190
211
|
# @return [Fixnum]
|
191
212
|
def right_d
|
192
213
|
if d_dn
|
@@ -200,6 +221,7 @@ module Vedeu
|
|
200
221
|
|
201
222
|
end
|
202
223
|
end
|
224
|
+
alias_method :bottom_d, :right_d
|
203
225
|
|
204
226
|
# Fetch the starting coordinate, or use 1 when not set.
|
205
227
|
#
|
@@ -244,6 +266,20 @@ module Vedeu
|
|
244
266
|
alignment == :left
|
245
267
|
end
|
246
268
|
|
269
|
+
# Return a boolean indicating alignment was set to :middle.
|
270
|
+
#
|
271
|
+
# @return [Boolean]
|
272
|
+
def middle_aligned?
|
273
|
+
alignment == :middle
|
274
|
+
end
|
275
|
+
|
276
|
+
# Return a boolean indicating alignment was set to :bottom.
|
277
|
+
#
|
278
|
+
# @return [Boolean]
|
279
|
+
def bottom_aligned?
|
280
|
+
alignment == :bottom
|
281
|
+
end
|
282
|
+
|
247
283
|
# Return a boolean indicating alignment was set to :centre.
|
248
284
|
#
|
249
285
|
# @return [Boolean]
|
@@ -258,9 +294,16 @@ module Vedeu
|
|
258
294
|
alignment == :right
|
259
295
|
end
|
260
296
|
|
297
|
+
# Return a boolean indicating alignment was set to :top.
|
298
|
+
#
|
299
|
+
# @return [Boolean]
|
300
|
+
def top_aligned?
|
301
|
+
alignment == :top
|
302
|
+
end
|
303
|
+
|
261
304
|
# Returns the default options/attributes for this class.
|
262
305
|
#
|
263
|
-
# @return [Hash<Symbol => NilClass,Boolean>]
|
306
|
+
# @return [Hash<Symbol => NilClass,Boolean,Symbol>]
|
264
307
|
def defaults
|
265
308
|
{
|
266
309
|
d: nil,
|
@@ -269,7 +312,6 @@ module Vedeu
|
|
269
312
|
default: nil,
|
270
313
|
centred: false,
|
271
314
|
maximised: false,
|
272
|
-
alignment: Vedeu::Geometry::Alignment.align(:none),
|
273
315
|
}
|
274
316
|
end
|
275
317
|
|
data/lib/vedeu/geometry/dsl.rb
CHANGED
@@ -114,59 +114,204 @@ module Vedeu
|
|
114
114
|
# @raise [Vedeu::Error::InvalidSyntax] When the value or width
|
115
115
|
# is not given.
|
116
116
|
# @return [Vedeu::Geometry::Geometry]
|
117
|
-
def alignment(value, width)
|
117
|
+
# def alignment(value, width)
|
118
|
+
# fail Vedeu::Error::InvalidSyntax,
|
119
|
+
# 'No alignment given. Valid values are :center, :centre, ' \
|
120
|
+
# ':left, :none, :right.'.freeze unless present?(value)
|
121
|
+
# fail Vedeu::Error::InvalidSyntax,
|
122
|
+
# 'No width given.'.freeze unless present?(width)
|
123
|
+
|
124
|
+
# model.alignment = Vedeu::Geometry::Alignment.align(value)
|
125
|
+
# model.width = width
|
126
|
+
# model
|
127
|
+
# end
|
128
|
+
|
129
|
+
# Align the interface/view horizontally or vertically within
|
130
|
+
# the terminal.
|
131
|
+
#
|
132
|
+
# @param vertical [Symbol] One of :bottom, :middle, :none, :top.
|
133
|
+
# @param horizontal [Symbol] One of :center, :centre, :left,
|
134
|
+
# :none, :right.
|
135
|
+
# @param width [Fixnum] The number of characters/columns wide;
|
136
|
+
# this is required when the given value for horizontal is any
|
137
|
+
# value other than :none.
|
138
|
+
# @param height [Fixnum] The number of lines/rows tall; this is
|
139
|
+
# required when the given value for vertical is any value
|
140
|
+
# other than :none.
|
141
|
+
# @raise [Vedeu::Error::InvalidSyntax]
|
142
|
+
# - When the vertical is not given.
|
143
|
+
# - When the horizontal is not given.
|
144
|
+
# - When the horizontal is given (and not :none) and the width
|
145
|
+
# is not given.
|
146
|
+
# - When the vertical is given (and not :none) and the height
|
147
|
+
# is not given.
|
148
|
+
# @return [Vedeu::Geometry::Geometry]
|
149
|
+
def align(vertical, horizontal, width, height)
|
150
|
+
fail Vedeu::Error::InvalidSyntax,
|
151
|
+
'No vertical alignment given. Valid values are :bottom, ' \
|
152
|
+
':middle, :none, :top.'.freeze unless present?(vertical)
|
153
|
+
fail Vedeu::Error::InvalidSyntax,
|
154
|
+
'No horizontal alignment given. Valid values are :center, ' \
|
155
|
+
':centre, :left, :none, :right.'.freeze unless present?(horizontal)
|
156
|
+
|
157
|
+
unless vertical == :none
|
158
|
+
fail Vedeu::Error::InvalidSyntax,
|
159
|
+
'No height given.'.freeze if absent?(height)
|
160
|
+
end
|
161
|
+
|
162
|
+
unless horizontal == :none
|
163
|
+
fail Vedeu::Error::InvalidSyntax,
|
164
|
+
'No width given.'.freeze if absent?(width)
|
165
|
+
end
|
166
|
+
|
167
|
+
horizontal_alignment(horizontal, width)
|
168
|
+
vertical_alignment(vertical, height)
|
169
|
+
end
|
170
|
+
|
171
|
+
# @param value [Symbol] One of :center, :centre, :left, :none,
|
172
|
+
# :right.
|
173
|
+
# @param width [Fixnum] The number of characters/columns.
|
174
|
+
# @return [Vedeu::Geometry::Geometry]
|
175
|
+
def horizontal_alignment(value, width)
|
118
176
|
fail Vedeu::Error::InvalidSyntax,
|
119
|
-
'No alignment given. Valid values are :center,
|
120
|
-
':none, :right.'.freeze unless present?(value)
|
177
|
+
'No horizontal alignment given. Valid values are :center, ' \
|
178
|
+
':centre, :left, :none, :right.'.freeze unless present?(value)
|
121
179
|
fail Vedeu::Error::InvalidSyntax,
|
122
180
|
'No width given.'.freeze unless present?(width)
|
123
181
|
|
124
|
-
model.
|
125
|
-
|
182
|
+
model.horizontal_alignment = Vedeu::Geometry::HorizontalAlignment
|
183
|
+
.align(value)
|
184
|
+
model.width = width
|
185
|
+
model
|
186
|
+
end
|
187
|
+
|
188
|
+
# @param value [Symbol] One of :bottom, :middle, :none, :top.
|
189
|
+
# @param height [Fixnum] The number of lines/rows.
|
190
|
+
# @return [Vedeu::Geometry::Geometry]
|
191
|
+
def vertical_alignment(value, height)
|
192
|
+
fail Vedeu::Error::InvalidSyntax,
|
193
|
+
'No vertical alignment given. Valid values are :bottom, ' \
|
194
|
+
':middle, :none, :top.'.freeze unless present?(value)
|
195
|
+
fail Vedeu::Error::InvalidSyntax,
|
196
|
+
'No height given.'.freeze unless present?(height)
|
197
|
+
|
198
|
+
model.vertical_alignment = Vedeu::Geometry::VerticalAlignment
|
199
|
+
.align(value)
|
200
|
+
model.height = height
|
126
201
|
model
|
127
202
|
end
|
128
203
|
|
129
|
-
#
|
204
|
+
# Vertically align the interface/view to the bottom of the
|
205
|
+
# terminal.
|
206
|
+
#
|
207
|
+
# Vedeu.geometry :some_interface do
|
208
|
+
# # `height` is a positive integer, e.g. 30
|
209
|
+
# align_bottom 30
|
210
|
+
#
|
211
|
+
# # this is the same as:
|
212
|
+
# # vertical_alignment(:bottom, 30)
|
213
|
+
#
|
214
|
+
# # or you can use: (see notes)
|
215
|
+
# # align(:bottom, :none, Vedeu.width, 30)
|
216
|
+
#
|
217
|
+
# # ... some code
|
218
|
+
# end
|
219
|
+
#
|
220
|
+
# @note
|
221
|
+
# Vedeu.width in the example above will set the width to the
|
222
|
+
# default width of the terminal, this can be substituted for
|
223
|
+
# your own positive integer.
|
224
|
+
# @param height [Fixnum] The number of lines/rows.
|
225
|
+
# @raise [Vedeu::Error::InvalidSyntax] When the height is not
|
226
|
+
# given.
|
227
|
+
# @return [Vedeu::Geometry::Geometry]
|
228
|
+
def align_bottom(height)
|
229
|
+
vertical_alignment(:bottom, height)
|
230
|
+
end
|
231
|
+
|
232
|
+
# Horizontally align the interface/view centrally.
|
130
233
|
#
|
131
234
|
# Vedeu.geometry :some_interface do
|
132
235
|
# # `width` is a positive integer, e.g. 30
|
133
236
|
# align_centre 30
|
134
237
|
#
|
135
238
|
# # this is the same as:
|
136
|
-
# #
|
239
|
+
# # horizontal_alignment(:centre, 30)
|
240
|
+
#
|
241
|
+
# # or you can use: (see notes)
|
242
|
+
# # align(:none, :centre, 30, Vedeu.height)
|
137
243
|
#
|
138
244
|
# # ... some code
|
139
245
|
# end
|
140
246
|
#
|
141
247
|
# # Also allows `align_center` if preferred.
|
142
248
|
#
|
249
|
+
# @note
|
250
|
+
# Vedeu.height in the example above will set the height to the
|
251
|
+
# default height of the terminal, this can be substituted for
|
252
|
+
# your own positive integer.
|
143
253
|
# @param width [Fixnum] The number of characters/columns.
|
144
254
|
# @raise [Vedeu::Error::InvalidSyntax] When the width is not
|
145
255
|
# given.
|
146
256
|
# @return [Vedeu::Geometry::Geometry]
|
147
257
|
def align_centre(width)
|
148
|
-
|
258
|
+
horizontal_alignment(:centre, width)
|
149
259
|
end
|
150
260
|
alias_method :align_center, :align_centre
|
151
261
|
|
152
|
-
#
|
262
|
+
# Horizontally align the interface/view to the left.
|
153
263
|
#
|
154
264
|
# Vedeu.geometry :some_interface do
|
155
265
|
# # `width` is a positive integer, e.g. 30
|
156
266
|
# align_left 30
|
157
267
|
#
|
158
268
|
# # this is the same as:
|
159
|
-
# #
|
269
|
+
# # horizontal_alignment(:left, 30)
|
270
|
+
#
|
271
|
+
# # or you can use: (see notes)
|
272
|
+
# # align(:none, :left, 30, Vedeu.height)
|
160
273
|
#
|
161
274
|
# # ... some code
|
162
275
|
# end
|
163
276
|
#
|
277
|
+
# @note
|
278
|
+
# Vedeu.height in the example above will set the height to the
|
279
|
+
# default height of the terminal, this can be substituted for
|
280
|
+
# your own positive integer.
|
164
281
|
# @param width [Fixnum] The number of characters/columns.
|
165
282
|
# @raise [Vedeu::Error::InvalidSyntax] When the width is not
|
166
283
|
# given.
|
167
284
|
# @return [Vedeu::Geometry::Geometry]
|
168
285
|
def align_left(width)
|
169
|
-
|
286
|
+
horizontal_alignment(:left, width)
|
287
|
+
end
|
288
|
+
|
289
|
+
# Vertically align the interface/view to the middle of the
|
290
|
+
# terminal.
|
291
|
+
#
|
292
|
+
# Vedeu.geometry :some_interface do
|
293
|
+
# # `height` is a positive integer, e.g. 30
|
294
|
+
# align_middle 30
|
295
|
+
#
|
296
|
+
# # this is the same as:
|
297
|
+
# # vertical_alignment(:middle, 30)
|
298
|
+
#
|
299
|
+
# # or you can use: (see notes)
|
300
|
+
# # align(:middle, :none, Vedeu.width, 30)
|
301
|
+
#
|
302
|
+
# # ... some code
|
303
|
+
# end
|
304
|
+
#
|
305
|
+
# @note
|
306
|
+
# Vedeu.width in the example above will set the width to the
|
307
|
+
# default width of the terminal, this can be substituted for
|
308
|
+
# your own positive integer.
|
309
|
+
# @param height [Fixnum] The number of lines/rows.
|
310
|
+
# @raise [Vedeu::Error::InvalidSyntax] When the height is not
|
311
|
+
# given.
|
312
|
+
# @return [Vedeu::Geometry::Geometry]
|
313
|
+
def align_middle(height)
|
314
|
+
vertical_alignment(:middle, height)
|
170
315
|
end
|
171
316
|
|
172
317
|
# Align the interface/view to the right.
|
@@ -176,17 +321,52 @@ module Vedeu
|
|
176
321
|
# align_right 30
|
177
322
|
#
|
178
323
|
# # this is the same as:
|
179
|
-
# #
|
324
|
+
# # horizontal_alignment(:right, 30)
|
325
|
+
#
|
326
|
+
# # or you can use: (see notes)
|
327
|
+
# # align(:none, :right, 30, Vedeu.height)
|
180
328
|
#
|
181
329
|
# # ... some code
|
182
330
|
# end
|
183
331
|
#
|
332
|
+
# @note
|
333
|
+
# Vedeu.height in the example above will set the height to the
|
334
|
+
# default height of the terminal, this can be substituted for
|
335
|
+
# your own positive integer.
|
184
336
|
# @param width [Fixnum] The number of characters/columns.
|
185
337
|
# @raise [Vedeu::Error::InvalidSyntax] When the width is not
|
186
338
|
# given.
|
187
339
|
# @return [Vedeu::Geometry::Geometry]
|
188
340
|
def align_right(width)
|
189
|
-
|
341
|
+
horizontal_alignment(:right, width)
|
342
|
+
end
|
343
|
+
|
344
|
+
# Vertically align the interface/view to the top of the
|
345
|
+
# terminal.
|
346
|
+
#
|
347
|
+
# Vedeu.geometry :some_interface do
|
348
|
+
# # `height` is a positive integer, e.g. 30
|
349
|
+
# align_top 30
|
350
|
+
#
|
351
|
+
# # this is the same as:
|
352
|
+
# # vertical_alignment(:top, 30)
|
353
|
+
#
|
354
|
+
# # or you can use: (see notes)
|
355
|
+
# # align(:top, :none, Vedeu.width, 30)
|
356
|
+
#
|
357
|
+
# # ... some code
|
358
|
+
# end
|
359
|
+
#
|
360
|
+
# @note
|
361
|
+
# Vedeu.width in the example above will set the width to the
|
362
|
+
# default width of the terminal, this can be substituted for
|
363
|
+
# your own positive integer.
|
364
|
+
# @param height [Fixnum] The number of lines/rows.
|
365
|
+
# @raise [Vedeu::Error::InvalidSyntax] When the height is not
|
366
|
+
# given.
|
367
|
+
# @return [Vedeu::Geometry::Geometry]
|
368
|
+
def align_top(height)
|
369
|
+
vertical_alignment(:top, height)
|
190
370
|
end
|
191
371
|
|
192
372
|
# Instructs Vedeu to calculate x and y geometry automatically
|