vedeu 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/material_colours_app.rb +25 -0
- data/lib/vedeu/all.rb +0 -1
- data/lib/vedeu/colours/colour_translator.rb +6 -6
- data/lib/vedeu/cursor/cursor.rb +0 -12
- data/lib/vedeu/dsl.rb +23 -0
- data/lib/vedeu/dsl/border.rb +0 -10
- data/lib/vedeu/dsl/composition.rb +1 -19
- data/lib/vedeu/dsl/geometry.rb +0 -10
- data/lib/vedeu/dsl/group.rb +0 -10
- data/lib/vedeu/dsl/interface.rb +0 -20
- data/lib/vedeu/dsl/keymap.rb +0 -10
- data/lib/vedeu/dsl/line.rb +3 -21
- data/lib/vedeu/dsl/menu.rb +0 -10
- data/lib/vedeu/dsl/stream.rb +4 -10
- data/lib/vedeu/dsl/view.rb +0 -20
- data/lib/vedeu/geometry/geometry.rb +0 -13
- data/lib/vedeu/geometry/position.rb +11 -0
- data/lib/vedeu/models/escape.rb +0 -7
- data/lib/vedeu/models/interface.rb +4 -16
- data/lib/vedeu/models/views/all.rb +4 -5
- data/lib/vedeu/models/views/char.rb +21 -22
- data/lib/vedeu/models/views/{chars.rb → collections/chars.rb} +0 -0
- data/lib/vedeu/models/views/{lines.rb → collections/lines.rb} +0 -0
- data/lib/vedeu/models/views/{streams.rb → collections/streams.rb} +0 -0
- data/lib/vedeu/models/views/{view_collection.rb → collections/view_collection.rb} +0 -0
- data/lib/vedeu/models/views/composition.rb +17 -19
- data/lib/vedeu/models/views/line.rb +19 -31
- data/lib/vedeu/models/views/stream.rb +7 -20
- data/lib/vedeu/models/views/view.rb +22 -35
- data/lib/vedeu/output/html_char.rb +38 -28
- data/lib/vedeu/output/presentation/colour.rb +15 -44
- data/lib/vedeu/output/presentation/style.rb +7 -14
- data/lib/vedeu/output/viewport.rb +0 -3
- data/lib/vedeu/output/virtual_terminal.rb +2 -2
- data/lib/vedeu/repositories/repository.rb +0 -7
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/buffers/buffer_test.rb +4 -4
- data/test/lib/vedeu/colours/colour_translator_test.rb +14 -0
- data/test/lib/vedeu/cursor/cursor_test.rb +0 -9
- data/test/lib/vedeu/dsl/line_test.rb +15 -13
- data/test/lib/vedeu/geometry/geometry_test.rb +0 -13
- data/test/lib/vedeu/geometry/position_test.rb +18 -0
- data/test/lib/vedeu/models/escape_test.rb +0 -8
- data/test/lib/vedeu/models/interface_test.rb +0 -12
- data/test/lib/vedeu/models/views/char_test.rb +4 -23
- data/test/lib/vedeu/models/views/{chars_test.rb → collections/chars_test.rb} +0 -0
- data/test/lib/vedeu/models/views/{lines_test.rb → collections/lines_test.rb} +0 -0
- data/test/lib/vedeu/models/views/{streams_test.rb → collections/streams_test.rb} +0 -0
- data/test/lib/vedeu/models/views/collections/view_collection_test.rb +22 -0
- data/test/lib/vedeu/models/views/composition_test.rb +23 -17
- data/test/lib/vedeu/models/views/line_test.rb +13 -42
- data/test/lib/vedeu/models/views/stream_test.rb +4 -33
- data/test/lib/vedeu/output/html_char_test.rb +16 -39
- data/test/lib/vedeu/output/presentation/colour_test.rb +63 -60
- data/test/lib/vedeu/output/presentation/style_test.rb +30 -29
- data/test/lib/vedeu/output/presentation_test.rb +1 -1
- data/test/lib/vedeu/output/renderers/html_test.rb +4 -8
- data/test/lib/vedeu/output/renderers/json_test.rb +37 -3
- data/test/lib/vedeu/output/wordwrap_test.rb +4 -4
- data/test/lib/vedeu/repositories/repository_test.rb +0 -26
- data/test/lib/vedeu/templating/view_template_test.rb +8 -8
- metadata +13 -17
- data/lib/vedeu/geometry/position_index.rb +0 -68
- data/lib/vedeu/models/interface_collection.rb +0 -9
- data/test/lib/vedeu/geometry/position_index_test.rb +0 -82
- data/test/lib/vedeu/models/interface_collection_test.rb +0 -18
@@ -2,32 +2,31 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
class
|
5
|
+
class ParentPresentationStyleTestClass
|
6
|
+
|
6
7
|
include Vedeu::Presentation
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
end
|
9
|
+
attr_reader :attributes
|
10
|
+
attr_reader :parent
|
11
11
|
|
12
12
|
def attributes
|
13
13
|
{
|
14
|
-
|
15
|
-
style: ['bold']
|
14
|
+
style: ['underline']
|
16
15
|
}
|
17
16
|
end
|
17
|
+
|
18
18
|
end
|
19
19
|
|
20
|
-
class
|
20
|
+
class PresentationStyleTestClass
|
21
|
+
|
21
22
|
include Vedeu::Presentation
|
22
23
|
|
23
24
|
attr_reader :attributes
|
25
|
+
attr_reader :parent
|
24
26
|
|
25
27
|
def initialize(attributes = {})
|
26
28
|
@attributes = attributes
|
27
|
-
|
28
|
-
|
29
|
-
def parent
|
30
|
-
Vedeu::ParentPresentationTestClass.new
|
29
|
+
@parent = @attributes[:parent]
|
31
30
|
end
|
32
31
|
|
33
32
|
end # PresentationTestClass
|
@@ -36,36 +35,38 @@ module Vedeu
|
|
36
35
|
|
37
36
|
describe Style do
|
38
37
|
|
39
|
-
let(:includer) { Vedeu::
|
38
|
+
let(:includer) { Vedeu::PresentationStyleTestClass.new(attributes) }
|
40
39
|
let(:attributes) {
|
41
40
|
{
|
42
|
-
|
43
|
-
style:
|
41
|
+
parent: parent,
|
42
|
+
style: style,
|
44
43
|
}
|
45
44
|
}
|
46
|
-
let(:
|
47
|
-
let(:
|
45
|
+
let(:parent) { Vedeu::ParentPresentationStyleTestClass.new }
|
46
|
+
let(:style) { ['bold'] }
|
48
47
|
|
49
|
-
describe '#
|
50
|
-
subject { includer.
|
48
|
+
describe '#style' do
|
49
|
+
subject { includer.style }
|
51
50
|
|
52
51
|
it { subject.must_be_instance_of(Vedeu::Style) }
|
53
52
|
|
54
|
-
context 'when
|
55
|
-
|
56
|
-
end
|
53
|
+
context 'when the attribute is not set' do
|
54
|
+
let(:style) {}
|
57
55
|
|
58
|
-
|
59
|
-
|
56
|
+
context 'when a parent is available' do
|
57
|
+
it { subject.value.must_equal(['underline']) }
|
58
|
+
end
|
60
59
|
|
61
|
-
|
62
|
-
|
63
|
-
end
|
60
|
+
context 'when a parent is not available' do
|
61
|
+
let(:parent) {}
|
64
62
|
|
65
|
-
|
66
|
-
|
63
|
+
it { subject.value.must_equal(nil) }
|
64
|
+
end
|
65
|
+
end
|
67
66
|
|
68
|
-
|
67
|
+
context 'when the attribute is set' do
|
68
|
+
it { subject.value.must_equal(['bold']) }
|
69
|
+
end
|
69
70
|
end
|
70
71
|
|
71
72
|
describe '#style=' do
|
@@ -83,14 +83,10 @@ module Vedeu
|
|
83
83
|
it do
|
84
84
|
subject.must_equal(
|
85
85
|
"<tr>\n" \
|
86
|
-
"<td style='
|
87
|
-
"
|
88
|
-
|
89
|
-
"
|
90
|
-
"<td style='background:#000;color:#222;border:1px #000 solid;'>" \
|
91
|
-
"s</td>\n" \
|
92
|
-
"<td style='background:#000;color:#222;border:1px #000 solid;'>" \
|
93
|
-
"t</td>\n" \
|
86
|
+
"<td style=''>t</td>\n" \
|
87
|
+
"<td style=''>e</td>\n" \
|
88
|
+
"<td style=''>s</td>\n" \
|
89
|
+
"<td style=''>t</td>\n" \
|
94
90
|
"</tr>\n"
|
95
91
|
)
|
96
92
|
end
|
@@ -36,10 +36,12 @@ module Vedeu
|
|
36
36
|
[
|
37
37
|
Vedeu::Views::Char.new(value: 'a',
|
38
38
|
colour: colour,
|
39
|
+
parent: parent,
|
39
40
|
position: Vedeu::Position[5, 3])
|
40
41
|
]
|
41
42
|
]
|
42
43
|
}
|
44
|
+
let(:parent) {}
|
43
45
|
let(:expected) {
|
44
46
|
<<-eos
|
45
47
|
[
|
@@ -50,9 +52,6 @@ module Vedeu
|
|
50
52
|
\"foreground\": \"\\u001b[38;2;255;0;0m\"
|
51
53
|
},
|
52
54
|
\"parent\": {
|
53
|
-
\"background\": \"\",
|
54
|
-
\"foreground\": \"\",
|
55
|
-
\"style\": \"\"
|
56
55
|
},
|
57
56
|
\"position\": {
|
58
57
|
\"y\": 5,
|
@@ -66,6 +65,41 @@ module Vedeu
|
|
66
65
|
}
|
67
66
|
|
68
67
|
it { subject.must_equal(expected.chomp) }
|
68
|
+
|
69
|
+
context 'when a parent is available' do
|
70
|
+
let(:parent) {
|
71
|
+
Vedeu::Views::Stream.new(
|
72
|
+
colour: Vedeu::Colour.coerce(background: '', foreground: '')
|
73
|
+
)
|
74
|
+
}
|
75
|
+
|
76
|
+
let(:expected) {
|
77
|
+
<<-eos
|
78
|
+
[
|
79
|
+
{
|
80
|
+
\"border\": \"\",
|
81
|
+
\"colour\": {
|
82
|
+
\"background\": \"\\u001b[48;2;255;255;255m\",
|
83
|
+
\"foreground\": \"\\u001b[38;2;255;0;0m\"
|
84
|
+
},
|
85
|
+
\"parent\": {
|
86
|
+
\"background\": \"\",
|
87
|
+
\"foreground\": \"\",
|
88
|
+
\"style\": \"\"
|
89
|
+
},
|
90
|
+
\"position\": {
|
91
|
+
\"y\": 5,
|
92
|
+
\"x\": 3
|
93
|
+
},
|
94
|
+
\"style\": \"\",
|
95
|
+
\"value\": \"a\"
|
96
|
+
}
|
97
|
+
]
|
98
|
+
eos
|
99
|
+
}
|
100
|
+
|
101
|
+
it { subject.must_equal(expected.chomp) }
|
102
|
+
end
|
69
103
|
end
|
70
104
|
end
|
71
105
|
|
@@ -39,19 +39,19 @@ module Vedeu
|
|
39
39
|
}
|
40
40
|
let(:text_line_objects) {
|
41
41
|
[
|
42
|
-
Vedeu::Views::Line.new(
|
42
|
+
Vedeu::Views::Line.new(value: [
|
43
43
|
Vedeu::Views::Stream.new(
|
44
44
|
value: 'Krypton is a colorless, odorless, tasteless noble gas.'
|
45
45
|
)]),
|
46
|
-
Vedeu::Views::Line.new(
|
46
|
+
Vedeu::Views::Line.new(value: [
|
47
47
|
Vedeu::Views::Stream.new(
|
48
48
|
value: 'It occurs in trace amounts in the atmosphere.'
|
49
49
|
)]),
|
50
|
-
Vedeu::Views::Line.new(
|
50
|
+
Vedeu::Views::Line.new(value: [
|
51
51
|
Vedeu::Views::Stream.new(
|
52
52
|
value: 'It is isolated by fractionally distilling liquefied air.'
|
53
53
|
)]),
|
54
|
-
Vedeu::Views::Line.new(
|
54
|
+
Vedeu::Views::Line.new(value: [
|
55
55
|
Vedeu::Views::Stream.new(
|
56
56
|
value: 'Krypton is often used with other rare gases in ' \
|
57
57
|
'fluorescent lamps.'
|
@@ -178,32 +178,6 @@ module Vedeu
|
|
178
178
|
end
|
179
179
|
end
|
180
180
|
|
181
|
-
describe '#inspect' do
|
182
|
-
before { Vedeu.interfaces.reset }
|
183
|
-
|
184
|
-
subject { instance.inspect }
|
185
|
-
|
186
|
-
it { subject.must_be_instance_of(String) }
|
187
|
-
|
188
|
-
context 'when there are no models stored in the repository' do
|
189
|
-
it { subject.must_equal("<Vedeu::Repository: []>") }
|
190
|
-
end
|
191
|
-
|
192
|
-
context 'when there are models stored in the repository' do
|
193
|
-
before {
|
194
|
-
Vedeu.interface('hydrogen') {}
|
195
|
-
Vedeu.interface('helium') {}
|
196
|
-
}
|
197
|
-
after { Vedeu.interfaces.reset }
|
198
|
-
|
199
|
-
subject { Vedeu.interfaces.inspect }
|
200
|
-
|
201
|
-
it { subject.must_equal(
|
202
|
-
"<Vedeu::Interfaces: [\"hydrogen\", \"helium\"]>"
|
203
|
-
) }
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
181
|
describe '#registered?' do
|
208
182
|
it 'returns false with no name' do
|
209
183
|
RepositoriesTestClass.new.registered?('').must_equal(false)
|
@@ -24,7 +24,7 @@ module Vedeu
|
|
24
24
|
let(:content) { "This is a test.\n" }
|
25
25
|
let(:expected) {
|
26
26
|
Vedeu::Views::Lines.new([
|
27
|
-
Vedeu::Views::Line.new(
|
27
|
+
Vedeu::Views::Line.new(value:
|
28
28
|
Vedeu::Views::Stream.new(colour: {
|
29
29
|
background: :default,
|
30
30
|
foreground: :default },
|
@@ -40,13 +40,13 @@ module Vedeu
|
|
40
40
|
let(:content) { "This is a test.\nAnd so is this.\n" }
|
41
41
|
let(:expected) {
|
42
42
|
Vedeu::Views::Lines.new([
|
43
|
-
Vedeu::Views::Line.new(
|
43
|
+
Vedeu::Views::Line.new(value:
|
44
44
|
Vedeu::Views::Stream.new(colour: {
|
45
45
|
background: :default,
|
46
46
|
foreground: :default },
|
47
47
|
style: :normal,
|
48
48
|
value: 'This is a test.')),
|
49
|
-
Vedeu::Views::Line.new(
|
49
|
+
Vedeu::Views::Line.new(value:
|
50
50
|
Vedeu::Views::Stream.new(colour: {
|
51
51
|
background: :default,
|
52
52
|
foreground: :default },
|
@@ -66,7 +66,7 @@ module Vedeu
|
|
66
66
|
|
67
67
|
let(:expected) {
|
68
68
|
Vedeu::Views::Lines.new([
|
69
|
-
Vedeu::Views::Line.new(
|
69
|
+
Vedeu::Views::Line.new(value: [
|
70
70
|
Vedeu::Views::Stream.new(colour: {
|
71
71
|
background: :default,
|
72
72
|
foreground: :default },
|
@@ -96,7 +96,7 @@ module Vedeu
|
|
96
96
|
|
97
97
|
let(:expected) {
|
98
98
|
Vedeu::Views::Lines.new([
|
99
|
-
Vedeu::Views::Line.new(
|
99
|
+
Vedeu::Views::Line.new(value: [
|
100
100
|
Vedeu::Views::Stream.new(colour: {
|
101
101
|
background: :default,
|
102
102
|
foreground: :default },
|
@@ -130,7 +130,7 @@ module Vedeu
|
|
130
130
|
|
131
131
|
let(:expected) {
|
132
132
|
Vedeu::Views::Lines.new([
|
133
|
-
Vedeu::Views::Line.new(
|
133
|
+
Vedeu::Views::Line.new(value: [
|
134
134
|
Vedeu::Views::Stream.new(colour: {
|
135
135
|
background: :default,
|
136
136
|
foreground: :default },
|
@@ -157,7 +157,7 @@ module Vedeu
|
|
157
157
|
|
158
158
|
let(:expected) {
|
159
159
|
Vedeu::Views::Lines.new([
|
160
|
-
Vedeu::Views::Line.new(
|
160
|
+
Vedeu::Views::Line.new(value: [
|
161
161
|
Vedeu::Views::Stream.new(colour: {
|
162
162
|
background: :default,
|
163
163
|
foreground: :default },
|
@@ -184,7 +184,7 @@ module Vedeu
|
|
184
184
|
|
185
185
|
let(:expected) {
|
186
186
|
Vedeu::Views::Lines.new([
|
187
|
-
Vedeu::Views::Line.new(
|
187
|
+
Vedeu::Views::Line.new(value: [
|
188
188
|
Vedeu::Views::Stream.new(colour: {
|
189
189
|
background: :default,
|
190
190
|
foreground: :default },
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vedeu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Laking
|
@@ -362,7 +362,6 @@ files:
|
|
362
362
|
- lib/vedeu/geometry/geometry.rb
|
363
363
|
- lib/vedeu/geometry/grid.rb
|
364
364
|
- lib/vedeu/geometry/position.rb
|
365
|
-
- lib/vedeu/geometry/position_index.rb
|
366
365
|
- lib/vedeu/input/input.rb
|
367
366
|
- lib/vedeu/input/key.rb
|
368
367
|
- lib/vedeu/input/keymap.rb
|
@@ -379,21 +378,20 @@ files:
|
|
379
378
|
- lib/vedeu/models/group.rb
|
380
379
|
- lib/vedeu/models/groups.rb
|
381
380
|
- lib/vedeu/models/interface.rb
|
382
|
-
- lib/vedeu/models/interface_collection.rb
|
383
381
|
- lib/vedeu/models/interfaces.rb
|
384
382
|
- lib/vedeu/models/menu.rb
|
385
383
|
- lib/vedeu/models/menus.rb
|
386
384
|
- lib/vedeu/models/toggleable.rb
|
387
385
|
- lib/vedeu/models/views/all.rb
|
388
386
|
- lib/vedeu/models/views/char.rb
|
389
|
-
- lib/vedeu/models/views/chars.rb
|
387
|
+
- lib/vedeu/models/views/collections/chars.rb
|
388
|
+
- lib/vedeu/models/views/collections/lines.rb
|
389
|
+
- lib/vedeu/models/views/collections/streams.rb
|
390
|
+
- lib/vedeu/models/views/collections/view_collection.rb
|
390
391
|
- lib/vedeu/models/views/composition.rb
|
391
392
|
- lib/vedeu/models/views/line.rb
|
392
|
-
- lib/vedeu/models/views/lines.rb
|
393
393
|
- lib/vedeu/models/views/stream.rb
|
394
|
-
- lib/vedeu/models/views/streams.rb
|
395
394
|
- lib/vedeu/models/views/view.rb
|
396
|
-
- lib/vedeu/models/views/view_collection.rb
|
397
395
|
- lib/vedeu/null.rb
|
398
396
|
- lib/vedeu/null/border.rb
|
399
397
|
- lib/vedeu/null/buffer.rb
|
@@ -523,7 +521,6 @@ files:
|
|
523
521
|
- test/lib/vedeu/geometry/geometries_test.rb
|
524
522
|
- test/lib/vedeu/geometry/geometry_test.rb
|
525
523
|
- test/lib/vedeu/geometry/grid_test.rb
|
526
|
-
- test/lib/vedeu/geometry/position_index_test.rb
|
527
524
|
- test/lib/vedeu/geometry/position_test.rb
|
528
525
|
- test/lib/vedeu/input/input_test.rb
|
529
526
|
- test/lib/vedeu/input/key_test.rb
|
@@ -540,19 +537,19 @@ files:
|
|
540
537
|
- test/lib/vedeu/models/focus_test.rb
|
541
538
|
- test/lib/vedeu/models/group_test.rb
|
542
539
|
- test/lib/vedeu/models/groups_test.rb
|
543
|
-
- test/lib/vedeu/models/interface_collection_test.rb
|
544
540
|
- test/lib/vedeu/models/interface_test.rb
|
545
541
|
- test/lib/vedeu/models/interfaces_test.rb
|
546
542
|
- test/lib/vedeu/models/menu_test.rb
|
547
543
|
- test/lib/vedeu/models/menus_test.rb
|
548
544
|
- test/lib/vedeu/models/toggleable_test.rb
|
549
545
|
- test/lib/vedeu/models/views/char_test.rb
|
550
|
-
- test/lib/vedeu/models/views/chars_test.rb
|
546
|
+
- test/lib/vedeu/models/views/collections/chars_test.rb
|
547
|
+
- test/lib/vedeu/models/views/collections/lines_test.rb
|
548
|
+
- test/lib/vedeu/models/views/collections/streams_test.rb
|
549
|
+
- test/lib/vedeu/models/views/collections/view_collection_test.rb
|
551
550
|
- test/lib/vedeu/models/views/composition_test.rb
|
552
551
|
- test/lib/vedeu/models/views/line_test.rb
|
553
|
-
- test/lib/vedeu/models/views/lines_test.rb
|
554
552
|
- test/lib/vedeu/models/views/stream_test.rb
|
555
|
-
- test/lib/vedeu/models/views/streams_test.rb
|
556
553
|
- test/lib/vedeu/models/views/view_test.rb
|
557
554
|
- test/lib/vedeu/null/border_test.rb
|
558
555
|
- test/lib/vedeu/null/buffer_test.rb
|
@@ -711,7 +708,6 @@ test_files:
|
|
711
708
|
- test/lib/vedeu/geometry/geometries_test.rb
|
712
709
|
- test/lib/vedeu/geometry/geometry_test.rb
|
713
710
|
- test/lib/vedeu/geometry/grid_test.rb
|
714
|
-
- test/lib/vedeu/geometry/position_index_test.rb
|
715
711
|
- test/lib/vedeu/geometry/position_test.rb
|
716
712
|
- test/lib/vedeu/input/input_test.rb
|
717
713
|
- test/lib/vedeu/input/key_test.rb
|
@@ -728,19 +724,19 @@ test_files:
|
|
728
724
|
- test/lib/vedeu/models/focus_test.rb
|
729
725
|
- test/lib/vedeu/models/group_test.rb
|
730
726
|
- test/lib/vedeu/models/groups_test.rb
|
731
|
-
- test/lib/vedeu/models/interface_collection_test.rb
|
732
727
|
- test/lib/vedeu/models/interface_test.rb
|
733
728
|
- test/lib/vedeu/models/interfaces_test.rb
|
734
729
|
- test/lib/vedeu/models/menu_test.rb
|
735
730
|
- test/lib/vedeu/models/menus_test.rb
|
736
731
|
- test/lib/vedeu/models/toggleable_test.rb
|
737
732
|
- test/lib/vedeu/models/views/char_test.rb
|
738
|
-
- test/lib/vedeu/models/views/chars_test.rb
|
733
|
+
- test/lib/vedeu/models/views/collections/chars_test.rb
|
734
|
+
- test/lib/vedeu/models/views/collections/lines_test.rb
|
735
|
+
- test/lib/vedeu/models/views/collections/streams_test.rb
|
736
|
+
- test/lib/vedeu/models/views/collections/view_collection_test.rb
|
739
737
|
- test/lib/vedeu/models/views/composition_test.rb
|
740
738
|
- test/lib/vedeu/models/views/line_test.rb
|
741
|
-
- test/lib/vedeu/models/views/lines_test.rb
|
742
739
|
- test/lib/vedeu/models/views/stream_test.rb
|
743
|
-
- test/lib/vedeu/models/views/streams_test.rb
|
744
740
|
- test/lib/vedeu/models/views/view_test.rb
|
745
741
|
- test/lib/vedeu/null/border_test.rb
|
746
742
|
- test/lib/vedeu/null/buffer_test.rb
|
@@ -1,68 +0,0 @@
|
|
1
|
-
module Vedeu
|
2
|
-
|
3
|
-
# Converts a position into an index for the terminal. An index is the position
|
4
|
-
# minus 1.
|
5
|
-
#
|
6
|
-
class PositionIndex
|
7
|
-
|
8
|
-
# Convenience constructor for Vedeu::Position.
|
9
|
-
#
|
10
|
-
# @param (see #initialize)
|
11
|
-
def self.[](y, x)
|
12
|
-
new(y, x).[]
|
13
|
-
end
|
14
|
-
|
15
|
-
# Returns a new instance of Vedeu::PositionIndex.
|
16
|
-
#
|
17
|
-
# @param y [Fixnum] The row/line coordinate.
|
18
|
-
# @param x [Fixnum] The column/character coordinate.
|
19
|
-
# @return [Vedeu::PositionIndex]
|
20
|
-
def initialize(y, x)
|
21
|
-
@y = y
|
22
|
-
@x = x
|
23
|
-
end
|
24
|
-
|
25
|
-
# Returns a tuple containing the y and x coordinates.
|
26
|
-
#
|
27
|
-
# @return [Array<Fixnum>]
|
28
|
-
def []
|
29
|
-
[y, x]
|
30
|
-
end
|
31
|
-
|
32
|
-
# An object is equal when its values are the same.
|
33
|
-
#
|
34
|
-
# @param other [Vedeu::PositionIndex]
|
35
|
-
# @return [Boolean]
|
36
|
-
def eql?(other)
|
37
|
-
self.class == other.class && (x == other.x && y == other.y)
|
38
|
-
end
|
39
|
-
alias_method :==, :eql?
|
40
|
-
|
41
|
-
# Converts the index values into a Vedeu::Position.
|
42
|
-
#
|
43
|
-
# @return [Vedeu::Position]
|
44
|
-
def to_position
|
45
|
-
Vedeu::Position[y, x]
|
46
|
-
end
|
47
|
-
|
48
|
-
# Returns the x index.
|
49
|
-
# If the position for x is less than 1, then the index is 0.
|
50
|
-
#
|
51
|
-
# @return [Fixnum]
|
52
|
-
def x
|
53
|
-
@_x ||= ((@x - 1) <= 1) ? 0 : (@x - 1)
|
54
|
-
end
|
55
|
-
alias_method :last, :x
|
56
|
-
|
57
|
-
# Returns the y index.
|
58
|
-
# If the position for y is less than 1, then the index is 0.
|
59
|
-
#
|
60
|
-
# @return [Fixnum]
|
61
|
-
def y
|
62
|
-
@_y ||= ((@y - 1) <= 1) ? 0 : (@y - 1)
|
63
|
-
end
|
64
|
-
alias_method :first, :y
|
65
|
-
|
66
|
-
end # PositionIndex
|
67
|
-
|
68
|
-
end # Vedeu
|