vedeu 0.6.34 → 0.6.35
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/api.md +5 -0
- data/docs/dsl.md +4 -0
- data/docs/geometry.md +3 -0
- data/examples/alignment.rb +183 -0
- data/lib/vedeu/cursors/cursor.rb +1 -1
- data/lib/vedeu/geometry/alignment.rb +87 -0
- data/lib/vedeu/geometry/all.rb +1 -0
- data/lib/vedeu/geometry/area.rb +5 -1
- data/lib/vedeu/geometry/dimension.rb +109 -11
- data/lib/vedeu/geometry/dsl.rb +96 -1
- data/lib/vedeu/geometry/geometry.rb +13 -3
- data/lib/vedeu/input/translator.rb +91 -140
- data/lib/vedeu/models/focus.rb +18 -18
- data/lib/vedeu/output/renderers/options.rb +8 -0
- data/lib/vedeu/runtime/launcher.rb +1 -1
- data/lib/vedeu/runtime/main_loop.rb +1 -2
- data/lib/vedeu/terminal/buffer.rb +6 -6
- data/lib/vedeu/terminal/terminal.rb +1 -1
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/geometry/alignment_test.rb +100 -0
- data/test/lib/vedeu/geometry/area_test.rb +2 -0
- data/test/lib/vedeu/geometry/dimension_test.rb +136 -75
- data/test/lib/vedeu/geometry/dsl_test.rb +96 -0
- data/test/lib/vedeu/geometry/geometry_test.rb +14 -1
- data/test/lib/vedeu/output/renderers/options_test.rb +43 -0
- data/test/support/ttyrec.rb +35 -0
- data/vedeu.gemspec +1 -1
- metadata +10 -4
@@ -7,6 +7,14 @@ module Vedeu
|
|
7
7
|
# :nocov:
|
8
8
|
module Options
|
9
9
|
|
10
|
+
# @!attribute [w] options
|
11
|
+
# @return [Hash<Symbol => void>]
|
12
|
+
attr_writer :options
|
13
|
+
|
14
|
+
def compress?
|
15
|
+
options[:compression] || false
|
16
|
+
end
|
17
|
+
|
10
18
|
private
|
11
19
|
|
12
20
|
# Combines the options provided at instantiation with the
|
@@ -20,9 +20,9 @@ module Vedeu
|
|
20
20
|
#
|
21
21
|
# @return [Array<Array<Vedeu::Models::Cell>>]
|
22
22
|
def buffer
|
23
|
-
@output ||= Array.new(Vedeu.height) do |y|
|
24
|
-
Array.new(Vedeu.width) do |x|
|
25
|
-
Vedeu::Models::Cell.new(position: [y
|
23
|
+
@output ||= Array.new(Vedeu.height + 1) do |y|
|
24
|
+
Array.new(Vedeu.width + 1) do |x|
|
25
|
+
Vedeu::Models::Cell.new(position: [y, x])
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -77,9 +77,9 @@ module Vedeu
|
|
77
77
|
#
|
78
78
|
# @return [Array<Array<Vedeu::Models::Cell>>]
|
79
79
|
def reset
|
80
|
-
@output = Array.new(Vedeu.height) do |y|
|
81
|
-
Array.new(Vedeu.width) do |x|
|
82
|
-
Vedeu::Models::Cell.new(position: [y
|
80
|
+
@output = Array.new(Vedeu.height + 1) do |y|
|
81
|
+
Array.new(Vedeu.width + 1) do |x|
|
82
|
+
Vedeu::Models::Cell.new(position: [y, x])
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
@@ -75,7 +75,7 @@ module Vedeu
|
|
75
75
|
# @param mode [Symbol]
|
76
76
|
# @return [void]
|
77
77
|
def initialize_screen(mode)
|
78
|
-
Vedeu.log(
|
78
|
+
Vedeu.log(message: "Terminal entering '#{mode}' mode".freeze)
|
79
79
|
|
80
80
|
output(Vedeu::EscapeSequences::Esc.string('screen_init'))
|
81
81
|
|
data/lib/vedeu/version.rb
CHANGED
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Geometry
|
6
|
+
|
7
|
+
describe Alignment do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Geometry::Alignment }
|
10
|
+
let(:instance) { described.new(_value) }
|
11
|
+
let(:_value) {}
|
12
|
+
|
13
|
+
describe '#initialize' do
|
14
|
+
it { instance.must_be_instance_of(described) }
|
15
|
+
it { instance.instance_variable_get('@value').must_equal(_value) }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.align' do
|
19
|
+
subject { described.align(_value) }
|
20
|
+
|
21
|
+
context 'when the value is nil' do
|
22
|
+
it { subject.must_equal(:none) }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when the value is not a Symbol' do
|
26
|
+
let(:_value) { 'invalid' }
|
27
|
+
|
28
|
+
it { subject.must_equal(:none) }
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when the value is :center' do
|
32
|
+
let(:_value) { :center }
|
33
|
+
|
34
|
+
it { subject.must_equal(:centre) }
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when the value is :centre' do
|
38
|
+
let(:_value) { :centre }
|
39
|
+
|
40
|
+
it { subject.must_equal(:centre) }
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'when the value is :left' do
|
44
|
+
let(:_value) { :left }
|
45
|
+
|
46
|
+
it { subject.must_equal(:left) }
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when the value is :right' do
|
50
|
+
let(:_value) { :right }
|
51
|
+
|
52
|
+
it { subject.must_equal(:right) }
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'when the value is :alignment' do
|
56
|
+
let(:_value) { :alignment }
|
57
|
+
|
58
|
+
it { subject.must_equal(:none) }
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'when the value is :align_center' do
|
62
|
+
let(:_value) { :align_center }
|
63
|
+
|
64
|
+
it { subject.must_equal(:centre) }
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'when the value is :align_centre' do
|
68
|
+
let(:_value) { :align_centre }
|
69
|
+
|
70
|
+
it { subject.must_equal(:centre) }
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'when the value is :align_left' do
|
74
|
+
let(:_value) { :align_left }
|
75
|
+
|
76
|
+
it { subject.must_equal(:left) }
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'when the value is :align_right' do
|
80
|
+
let(:_value) { :align_right }
|
81
|
+
|
82
|
+
it { subject.must_equal(:right) }
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'when the value is :align_invalid' do
|
86
|
+
let(:_value) { :align_invalid }
|
87
|
+
|
88
|
+
it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe '#align' do
|
93
|
+
it { instance.must_respond_to(:align) }
|
94
|
+
end
|
95
|
+
|
96
|
+
end # Alignment
|
97
|
+
|
98
|
+
end # Geometry
|
99
|
+
|
100
|
+
end # Vedeu
|
@@ -48,6 +48,7 @@ module Vedeu
|
|
48
48
|
x_default: x_default,
|
49
49
|
maximised: maximised,
|
50
50
|
centred: centred,
|
51
|
+
alignment: alignment,
|
51
52
|
}
|
52
53
|
}
|
53
54
|
let(:y) {}
|
@@ -60,6 +61,7 @@ module Vedeu
|
|
60
61
|
let(:x_default) {}
|
61
62
|
let(:maximised) {}
|
62
63
|
let(:centred) {}
|
64
|
+
let(:alignment) {}
|
63
65
|
|
64
66
|
subject { described.from_attributes(attributes) }
|
65
67
|
|
@@ -16,6 +16,7 @@ module Vedeu
|
|
16
16
|
default: default,
|
17
17
|
maximised: maximised,
|
18
18
|
centred: centred,
|
19
|
+
alignment: alignment,
|
19
20
|
}
|
20
21
|
}
|
21
22
|
let(:d) {}
|
@@ -24,6 +25,7 @@ module Vedeu
|
|
24
25
|
let(:default) {}
|
25
26
|
let(:maximised) {}
|
26
27
|
let(:centred) {}
|
28
|
+
let(:alignment) {}
|
27
29
|
|
28
30
|
describe '#initialize' do
|
29
31
|
it { instance.must_be_instance_of(described) }
|
@@ -33,6 +35,7 @@ module Vedeu
|
|
33
35
|
it { instance.instance_variable_get('@default').must_equal(default) }
|
34
36
|
it { instance.instance_variable_get('@maximised').must_equal(maximised) }
|
35
37
|
it { instance.instance_variable_get('@centred').must_equal(centred) }
|
38
|
+
it { instance.instance_variable_get('@alignment').must_equal(alignment) }
|
36
39
|
end
|
37
40
|
|
38
41
|
describe '.pair' do
|
@@ -51,8 +54,64 @@ module Vedeu
|
|
51
54
|
it { subject.must_equal([1, 80]) }
|
52
55
|
end
|
53
56
|
|
54
|
-
context 'when
|
55
|
-
let(:
|
57
|
+
context 'when left aligned' do
|
58
|
+
let(:alignment) { :left }
|
59
|
+
let(:default) { 80 }
|
60
|
+
|
61
|
+
context 'when a width (d_dn) is set' do
|
62
|
+
let(:d_dn) { 20 }
|
63
|
+
|
64
|
+
it { subject.must_equal([1, 20]) }
|
65
|
+
|
66
|
+
context 'when the width is greater than the terminal width' do
|
67
|
+
let(:d_dn) { 100 }
|
68
|
+
|
69
|
+
it { subject.must_equal([1, 80]) }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'when a dn is set' do
|
74
|
+
it { subject.must_equal([1, 38]) }
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'when neither width nor dn is set' do
|
78
|
+
let(:dn) {}
|
79
|
+
|
80
|
+
it { subject.must_equal([1, 80]) }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'when right aligned' do
|
85
|
+
let(:alignment) { :right }
|
86
|
+
let(:default) { 80 }
|
87
|
+
|
88
|
+
context 'when a width (d_dn) is set' do
|
89
|
+
let(:d_dn) { 20 }
|
90
|
+
|
91
|
+
it { subject.must_equal([60, 80]) }
|
92
|
+
|
93
|
+
context 'when the width is greater than the terminal width' do
|
94
|
+
let(:d_dn) { 100 }
|
95
|
+
|
96
|
+
it { subject.must_equal([1, 80]) }
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'when a d is set' do
|
101
|
+
let(:d) { 58 }
|
102
|
+
|
103
|
+
it { subject.must_equal([58, 80]) }
|
104
|
+
end
|
105
|
+
|
106
|
+
context 'when neither width nor d is set' do
|
107
|
+
let(:d) {}
|
108
|
+
|
109
|
+
it { subject.must_equal([1, 80]) }
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'when centre aligned' do
|
114
|
+
let(:alignment) { :centre }
|
56
115
|
let(:default) { 80 }
|
57
116
|
|
58
117
|
context 'when d and dn are given' do
|
@@ -79,110 +138,112 @@ module Vedeu
|
|
79
138
|
|
80
139
|
it { subject.must_be_instance_of(Fixnum) }
|
81
140
|
|
82
|
-
context 'when not centred and/or a length cannot be determined' do
|
83
|
-
|
84
|
-
|
141
|
+
# context 'when not centred and/or a length cannot be determined' do
|
142
|
+
# context 'when d is given' do
|
143
|
+
# let(:d) { 5 }
|
85
144
|
|
86
|
-
|
87
|
-
|
145
|
+
# it { subject.must_equal(5) }
|
146
|
+
# end
|
88
147
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
end
|
148
|
+
# context 'when d is not given' do
|
149
|
+
# it { subject.must_equal(1) }
|
150
|
+
# end
|
151
|
+
# end
|
93
152
|
|
94
|
-
context 'when centred and a length can be determined' do
|
95
|
-
|
96
|
-
|
153
|
+
# context 'when centred and a length can be determined' do
|
154
|
+
# let(:centred) { true }
|
155
|
+
# let(:default) { 80 }
|
97
156
|
|
98
|
-
|
99
|
-
|
100
|
-
|
157
|
+
# context 'when d and dn are given' do
|
158
|
+
# let(:d) { 7 }
|
159
|
+
# let(:dn) { 47 }
|
101
160
|
|
102
|
-
|
103
|
-
|
161
|
+
# it { subject.must_equal(20) }
|
162
|
+
# end
|
104
163
|
|
105
|
-
|
106
|
-
|
164
|
+
# context 'when only a d_dn is given' do
|
165
|
+
# let(:d_dn) { 30 }
|
107
166
|
|
108
|
-
|
109
|
-
|
167
|
+
# it { subject.must_equal(25) }
|
168
|
+
# end
|
110
169
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
end
|
170
|
+
# context 'when only a default is given' do
|
171
|
+
# it { subject.must_equal(1) }
|
172
|
+
# end
|
173
|
+
# end
|
115
174
|
end
|
116
175
|
|
117
176
|
describe '#d2' do
|
118
177
|
subject { instance.d2 }
|
119
178
|
|
120
|
-
|
121
|
-
context 'when d and dn are given' do
|
122
|
-
let(:d) { 5 }
|
123
|
-
let(:dn) { 8 }
|
179
|
+
it { subject.must_be_instance_of(Fixnum) }
|
124
180
|
|
125
|
-
|
126
|
-
|
181
|
+
# context 'when not centred and/or a length cannot be determined' do
|
182
|
+
# context 'when d and dn are given' do
|
183
|
+
# let(:d) { 5 }
|
184
|
+
# let(:dn) { 8 }
|
127
185
|
|
128
|
-
|
129
|
-
|
130
|
-
let(:d_dn) { 2 }
|
186
|
+
# it { subject.must_equal(8) }
|
187
|
+
# end
|
131
188
|
|
132
|
-
|
133
|
-
|
189
|
+
# context 'when d and d_dn are given' do
|
190
|
+
# let(:d) { 5 }
|
191
|
+
# let(:d_dn) { 2 }
|
134
192
|
|
135
|
-
|
136
|
-
|
193
|
+
# it { subject.must_equal(6) }
|
194
|
+
# end
|
137
195
|
|
138
|
-
|
139
|
-
|
196
|
+
# context 'when only d_dn is given' do
|
197
|
+
# let(:d_dn) { 6 }
|
140
198
|
|
141
|
-
|
142
|
-
|
199
|
+
# it { subject.must_equal(6) }
|
200
|
+
# end
|
143
201
|
|
144
|
-
|
145
|
-
|
202
|
+
# context 'when only dn is given' do
|
203
|
+
# let(:dn) { 8 }
|
146
204
|
|
147
|
-
|
148
|
-
|
149
|
-
let(:default) { 40 }
|
205
|
+
# it { subject.must_equal(8) }
|
206
|
+
# end
|
150
207
|
|
151
|
-
|
152
|
-
|
208
|
+
# context 'when d and a default is given' do
|
209
|
+
# let(:d) { 1 }
|
210
|
+
# let(:default) { 40 }
|
153
211
|
|
154
|
-
|
155
|
-
|
212
|
+
# it { subject.must_equal(40) }
|
213
|
+
# end
|
156
214
|
|
157
|
-
|
158
|
-
|
215
|
+
# context 'when only a default is given' do
|
216
|
+
# let(:default) { 25 }
|
159
217
|
|
160
|
-
|
161
|
-
|
162
|
-
end
|
163
|
-
end
|
218
|
+
# it { subject.must_equal(25) }
|
219
|
+
# end
|
164
220
|
|
165
|
-
context 'when
|
166
|
-
|
167
|
-
|
221
|
+
# context 'when no default is given' do
|
222
|
+
# it { subject.must_equal(nil) }
|
223
|
+
# end
|
224
|
+
# end
|
168
225
|
|
169
|
-
|
170
|
-
|
171
|
-
|
226
|
+
# context 'when centred and a length can be determined' do
|
227
|
+
# let(:centred) { true }
|
228
|
+
# let(:default) { 80 }
|
172
229
|
|
173
|
-
|
174
|
-
|
230
|
+
# context 'when d and dn are given' do
|
231
|
+
# let(:d) { 7 }
|
232
|
+
# let(:dn) { 47 }
|
175
233
|
|
176
|
-
|
177
|
-
|
234
|
+
# it { subject.must_equal(60) }
|
235
|
+
# end
|
178
236
|
|
179
|
-
|
180
|
-
|
237
|
+
# context 'when only a d_dn is given' do
|
238
|
+
# let(:d_dn) { 30 }
|
181
239
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
240
|
+
# it { subject.must_equal(55) }
|
241
|
+
# end
|
242
|
+
|
243
|
+
# context 'when only a default is given' do
|
244
|
+
# it { subject.must_equal(80) }
|
245
|
+
# end
|
246
|
+
# end
|
186
247
|
end
|
187
248
|
|
188
249
|
end # Dimension
|