vedeu 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/vedeu +0 -3
- data/examples/borders_app.rb +0 -3
- data/examples/colours_app.rb +0 -3
- data/examples/configuration_app.rb +0 -3
- data/examples/cursor_app.rb +0 -3
- data/examples/focus_app.rb +0 -3
- data/examples/geometry_app.rb +0 -3
- data/examples/lines_app.rb +0 -3
- data/examples/view_templates_app/template.erb +1 -0
- data/examples/view_templates_app/view_templates_app.rb +82 -0
- data/lib/vedeu/all.rb +0 -1
- data/lib/vedeu/application.rb +7 -6
- data/lib/vedeu/bindings.rb +8 -8
- data/lib/vedeu/buffers/buffer.rb +14 -4
- data/lib/vedeu/buffers/display_buffer.rb +2 -2
- data/lib/vedeu/configuration/cli.rb +7 -1
- data/lib/vedeu/configuration/configuration.rb +4 -2
- data/lib/vedeu/cursor/all.rb +1 -1
- data/lib/vedeu/cursor/cursor.rb +29 -2
- data/lib/vedeu/cursor/move_cursor.rb +20 -6
- data/lib/vedeu/cursor/toggle_cursor.rb +2 -0
- data/lib/vedeu/distributed/client.rb +2 -0
- data/lib/vedeu/distributed/server.rb +3 -1
- data/lib/vedeu/distributed/subprocess.rb +6 -1
- data/lib/vedeu/distributed/test_application.rb +32 -9
- data/lib/vedeu/distributed/uri.rb +7 -1
- data/lib/vedeu/dsl/components/border.rb +2 -0
- data/lib/vedeu/dsl/components/geometry.rb +2 -0
- data/lib/vedeu/dsl/components/keymap.rb +2 -0
- data/lib/vedeu/dsl/components/menu.rb +3 -1
- data/lib/vedeu/dsl/composition.rb +31 -2
- data/lib/vedeu/dsl/group.rb +2 -0
- data/lib/vedeu/dsl/interface.rb +3 -1
- data/lib/vedeu/dsl/line.rb +2 -0
- data/lib/vedeu/dsl/shared/style.rb +1 -1
- data/lib/vedeu/dsl/shared/text.rb +1 -2
- data/lib/vedeu/dsl/stream.rb +2 -0
- data/lib/vedeu/dsl/view.rb +1 -1
- data/lib/vedeu/events/all.rb +1 -1
- data/lib/vedeu/events/event.rb +26 -10
- data/lib/vedeu/events/trigger.rb +11 -3
- data/lib/vedeu/geometry/all.rb +2 -0
- data/lib/vedeu/geometry/bounding_area.rb +7 -2
- data/lib/vedeu/geometry/content_geometry.rb +2 -0
- data/lib/vedeu/geometry/coordinate.rb +15 -6
- data/lib/vedeu/geometry/grid.rb +3 -1
- data/lib/vedeu/geometry/index_position.rb +77 -0
- data/lib/vedeu/geometry/limit.rb +15 -1
- data/lib/vedeu/geometry/position.rb +7 -2
- data/lib/vedeu/{output → geometry}/position_index.rb +12 -2
- data/lib/vedeu/geometry/position_validator.rb +9 -1
- data/lib/vedeu/input/all.rb +0 -1
- data/lib/vedeu/input/input.rb +2 -0
- data/lib/vedeu/input/keymap.rb +5 -3
- data/lib/vedeu/input/mapper.rb +7 -1
- data/lib/vedeu/launcher.rb +1 -1
- data/lib/vedeu/models/all.rb +6 -3
- data/lib/vedeu/models/char.rb +157 -0
- data/lib/vedeu/models/{view/composition.rb → composition.rb} +1 -4
- data/lib/vedeu/models/geometry.rb +36 -12
- data/lib/vedeu/models/group.rb +7 -3
- data/lib/vedeu/models/{view/interface.rb → interface.rb} +26 -10
- data/lib/vedeu/models/{view/line.rb → line.rb} +8 -4
- data/lib/vedeu/models/menu.rb +11 -3
- data/lib/vedeu/models/{view/stream.rb → stream.rb} +9 -4
- data/lib/vedeu/output/all.rb +3 -2
- data/lib/vedeu/output/background.rb +2 -2
- data/lib/vedeu/output/border.rb +65 -22
- data/lib/vedeu/output/char_builder.rb +36 -0
- data/lib/vedeu/output/clear.rb +62 -0
- data/lib/vedeu/output/colour.rb +15 -7
- data/lib/vedeu/output/compositor.rb +3 -1
- data/lib/vedeu/output/esc.rb +2 -2
- data/lib/vedeu/output/foreground.rb +2 -2
- data/lib/vedeu/output/html_char.rb +2 -0
- data/lib/vedeu/output/html_renderer.rb +6 -3
- data/lib/vedeu/output/output.rb +20 -92
- data/lib/vedeu/output/presentation.rb +21 -21
- data/lib/vedeu/output/renderer.rb +2 -0
- data/lib/vedeu/output/style.rb +4 -2
- data/lib/vedeu/output/text.rb +7 -1
- data/lib/vedeu/output/translator.rb +4 -2
- data/lib/vedeu/output/viewport.rb +4 -2
- data/lib/vedeu/output/virtual_buffer.rb +11 -1
- data/lib/vedeu/output/virtual_terminal.rb +34 -11
- data/lib/vedeu/output/wordwrap.rb +31 -20
- data/lib/vedeu/repositories/all.rb +3 -0
- data/lib/vedeu/repositories/collection.rb +83 -0
- data/lib/vedeu/repositories/collections.rb +35 -0
- data/lib/vedeu/{models → repositories}/model.rb +2 -0
- data/lib/vedeu/repositories/repository.rb +7 -1
- data/lib/vedeu/support/log.rb +1 -1
- data/lib/vedeu/support/sentence.rb +7 -1
- data/lib/vedeu/support/template.rb +14 -2
- data/lib/vedeu/support/terminal.rb +6 -6
- data/lib/vedeu/support/trace.rb +4 -4
- data/lib/vedeu/support/visible.rb +4 -4
- data/test/lib/vedeu/dsl/composition_test.rb +23 -0
- data/test/lib/vedeu/geometry/index_position_test.rb +121 -0
- data/test/lib/vedeu/{output → geometry}/position_index_test.rb +6 -0
- data/test/lib/vedeu/input/keymap_test.rb +2 -2
- data/test/lib/vedeu/models/{view/char_test.rb → char_test.rb} +31 -15
- data/test/lib/vedeu/models/{view/composition_test.rb → composition_test.rb} +0 -0
- data/test/lib/vedeu/models/{view/interface_test.rb → interface_test.rb} +0 -0
- data/test/lib/vedeu/models/line_test.rb +156 -0
- data/test/lib/vedeu/models/{view/stream_test.rb → stream_test.rb} +1 -16
- data/test/lib/vedeu/output/char_builder_test.rb +50 -0
- data/test/lib/vedeu/output/clear_test.rb +26 -0
- data/test/lib/vedeu/output/compositor_test.rb +0 -10
- data/test/lib/vedeu/output/html_renderer_test.rb +8 -3
- data/test/lib/vedeu/output/output_test.rb +0 -39
- data/test/lib/vedeu/output/viewport_test.rb +10 -66
- data/test/lib/vedeu/output/virtual_buffer_test.rb +18 -2
- data/test/lib/vedeu/output/virtual_terminal_test.rb +3 -14
- data/test/lib/vedeu/output/wordwrap_test.rb +8 -15
- data/test/lib/vedeu/repositories/collection_test.rb +108 -0
- data/test/lib/vedeu/repositories/collections_test.rb +71 -0
- data/test/lib/vedeu/{models → repositories}/model_test.rb +0 -0
- data/test/lib/vedeu/support/template_test.rb +21 -1
- data/test/support/helpers/model_test_class.rb +1 -1
- data/test/test_helper.rb +0 -1
- data/vedeu.gemspec +1 -1
- metadata +40 -44
- data/lib/vedeu/events/events.rb +0 -10
- data/lib/vedeu/input/keys.rb +0 -10
- data/lib/vedeu/models/collection.rb +0 -81
- data/lib/vedeu/models/view/all.rb +0 -12
- data/lib/vedeu/models/view/char.rb +0 -99
- data/lib/vedeu/models/view/chars.rb +0 -10
- data/lib/vedeu/models/view/interfaces.rb +0 -10
- data/lib/vedeu/models/view/lines.rb +0 -10
- data/lib/vedeu/models/view/streams.rb +0 -10
- data/lib/vedeu/output/index_position.rb +0 -35
- data/test/lib/vedeu/models/collection_test.rb +0 -112
- data/test/lib/vedeu/models/view/chars_test.rb +0 -16
- data/test/lib/vedeu/models/view/interfaces_test.rb +0 -16
- data/test/lib/vedeu/models/view/line_test.rb +0 -214
- data/test/lib/vedeu/models/view/lines_test.rb +0 -16
- data/test/lib/vedeu/models/view/streams_test.rb +0 -16
- data/test/lib/vedeu/output/index_position_test.rb +0 -64
@@ -0,0 +1,156 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe Line do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::Line }
|
8
|
+
let(:instance) { described.new(attributes) }
|
9
|
+
let(:attributes) {
|
10
|
+
{
|
11
|
+
streams: streams,
|
12
|
+
parent: parent,
|
13
|
+
colour: colour,
|
14
|
+
style: style,
|
15
|
+
}
|
16
|
+
}
|
17
|
+
let(:streams) {
|
18
|
+
[
|
19
|
+
Stream.new({ value: 'Something interesting ',
|
20
|
+
parent: streams_parent,
|
21
|
+
colour: Colour.new({ foreground: '#ffff00' }),
|
22
|
+
style: Style.new('normal') }),
|
23
|
+
Stream.new({ value: 'on this line ',
|
24
|
+
parent: streams_parent,
|
25
|
+
colour: Colour.new({ foreground: '#00ff00' }),
|
26
|
+
style: Style.new('normal') }),
|
27
|
+
Stream.new({ value: 'would be cool, eh?',
|
28
|
+
parent: streams_parent,
|
29
|
+
colour: Colour.new({ foreground: '#0000ff' }),
|
30
|
+
style: Style.new('normal') })
|
31
|
+
]
|
32
|
+
}
|
33
|
+
|
34
|
+
let(:streams_parent) { Line.new({ streams: nil, parent: parent, colour: colour, style: style }) }
|
35
|
+
|
36
|
+
let(:parent) { Vedeu::Interface.new }
|
37
|
+
let(:colour) { Colour.new({ foreground: '#ff0000', background: '#000000' }) }
|
38
|
+
let(:style) { Style.new('normal') }
|
39
|
+
|
40
|
+
before do
|
41
|
+
parent.stubs(:colour)
|
42
|
+
parent.stubs(:style)
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#initialize' do
|
46
|
+
it { instance.must_be_instance_of(described) }
|
47
|
+
it { instance.instance_variable_get('@streams').must_equal(streams) }
|
48
|
+
it { instance.instance_variable_get('@parent').must_equal(parent) }
|
49
|
+
it { instance.instance_variable_get('@colour').must_equal(colour) }
|
50
|
+
it { instance.instance_variable_get('@style').must_equal(style) }
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#chars' do
|
54
|
+
subject { instance.chars }
|
55
|
+
|
56
|
+
it { subject.must_be_instance_of(Array) }
|
57
|
+
|
58
|
+
context 'when there is no content' do
|
59
|
+
let(:streams) { [] }
|
60
|
+
|
61
|
+
it { subject.must_equal([]) }
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'when there is content' do
|
65
|
+
it { subject.size.must_equal(53) }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe '#empty?' do
|
70
|
+
subject { instance.empty? }
|
71
|
+
|
72
|
+
context 'when there is no content' do
|
73
|
+
let(:streams) { [] }
|
74
|
+
|
75
|
+
it { subject.must_be_instance_of(TrueClass) }
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'when there is content' do
|
79
|
+
it { subject.must_be_instance_of(FalseClass) }
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe '#size' do
|
84
|
+
subject { instance.size }
|
85
|
+
|
86
|
+
it { subject.must_be_instance_of(Fixnum) }
|
87
|
+
|
88
|
+
it 'returns the size of the line' do
|
89
|
+
subject.must_equal(53)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe '#streams' do
|
94
|
+
subject { instance.streams }
|
95
|
+
|
96
|
+
it { subject.must_be_instance_of(Vedeu::Streams) }
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#to_s' do
|
100
|
+
subject { instance.to_s }
|
101
|
+
|
102
|
+
it { subject.must_be_instance_of(String) }
|
103
|
+
|
104
|
+
it 'returns the line complete with formatting' do
|
105
|
+
# (starts in Line colour)
|
106
|
+
# (starts in Line style)
|
107
|
+
# Stream 1 colour
|
108
|
+
# Stream 1 style
|
109
|
+
# Stream 1 value
|
110
|
+
# (resets style to Line style)
|
111
|
+
# (resets colour to Line colour)
|
112
|
+
# Stream 2 colour
|
113
|
+
# Stream 2 style
|
114
|
+
# Stream 2 value
|
115
|
+
# (resets style to Line style)
|
116
|
+
# (resets colour to Line colour)
|
117
|
+
# Stream 3 colour
|
118
|
+
# Stream 3 style
|
119
|
+
# Stream 3 value
|
120
|
+
# (resets style to Line style)
|
121
|
+
# (resets colour to Line colour)
|
122
|
+
|
123
|
+
subject.must_equal(
|
124
|
+
"\e[38;2;255;0;0m\e[48;2;0;0;0m" \
|
125
|
+
"\e[24m\e[22m\e[27m" \
|
126
|
+
"\e[38;2;255;255;0m" \
|
127
|
+
"\e[24m\e[22m\e[27m" \
|
128
|
+
"Something interesting " \
|
129
|
+
"\e[24m\e[22m\e[27m" \
|
130
|
+
"\e[38;2;255;0;0m\e[48;2;0;0;0m" \
|
131
|
+
"\e[38;2;0;255;0m" \
|
132
|
+
"\e[24m\e[22m\e[27m" \
|
133
|
+
"on this line " \
|
134
|
+
"\e[24m\e[22m\e[27m" \
|
135
|
+
"\e[38;2;255;0;0m" \
|
136
|
+
"\e[48;2;0;0;0m\e[38;2;0;0;255m" \
|
137
|
+
"\e[24m\e[22m\e[27m" \
|
138
|
+
"would be cool, eh?" \
|
139
|
+
"\e[24m\e[22m\e[27m" \
|
140
|
+
"\e[38;2;255;0;0m\e[48;2;0;0;0m"
|
141
|
+
)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
describe '#width' do
|
146
|
+
before { parent.stubs(:width).returns(25) }
|
147
|
+
|
148
|
+
subject { instance.width }
|
149
|
+
|
150
|
+
it { subject.must_be_instance_of(Fixnum) }
|
151
|
+
it { subject.must_equal(25) }
|
152
|
+
end
|
153
|
+
|
154
|
+
end # Line
|
155
|
+
|
156
|
+
end # Vedeu
|
@@ -49,22 +49,7 @@ module Vedeu
|
|
49
49
|
it { subject.must_be_instance_of(Array) }
|
50
50
|
|
51
51
|
context 'when there is content' do
|
52
|
-
it
|
53
|
-
'content' do
|
54
|
-
subject.must_equal(
|
55
|
-
[
|
56
|
-
"\e[38;2;0;0;0m\e[48;2;255;0;0m\e[24m\e[22m\e[27mS\e[24m\e[22m\e[27m\e[38;2;255;255;0m\e[48;2;0;0;255m",
|
57
|
-
"\e[38;2;0;0;0m\e[48;2;255;0;0m\e[24m\e[22m\e[27mo\e[24m\e[22m\e[27m\e[38;2;255;255;0m\e[48;2;0;0;255m",
|
58
|
-
"\e[38;2;0;0;0m\e[48;2;255;0;0m\e[24m\e[22m\e[27mm\e[24m\e[22m\e[27m\e[38;2;255;255;0m\e[48;2;0;0;255m",
|
59
|
-
"\e[38;2;0;0;0m\e[48;2;255;0;0m\e[24m\e[22m\e[27me\e[24m\e[22m\e[27m\e[38;2;255;255;0m\e[48;2;0;0;255m",
|
60
|
-
"\e[38;2;0;0;0m\e[48;2;255;0;0m\e[24m\e[22m\e[27m \e[24m\e[22m\e[27m\e[38;2;255;255;0m\e[48;2;0;0;255m",
|
61
|
-
"\e[38;2;0;0;0m\e[48;2;255;0;0m\e[24m\e[22m\e[27mt\e[24m\e[22m\e[27m\e[38;2;255;255;0m\e[48;2;0;0;255m",
|
62
|
-
"\e[38;2;0;0;0m\e[48;2;255;0;0m\e[24m\e[22m\e[27me\e[24m\e[22m\e[27m\e[38;2;255;255;0m\e[48;2;0;0;255m",
|
63
|
-
"\e[38;2;0;0;0m\e[48;2;255;0;0m\e[24m\e[22m\e[27mx\e[24m\e[22m\e[27m\e[38;2;255;255;0m\e[48;2;0;0;255m",
|
64
|
-
"\e[38;2;0;0;0m\e[48;2;255;0;0m\e[24m\e[22m\e[27mt\e[24m\e[22m\e[27m\e[38;2;255;255;0m\e[48;2;0;0;255m"
|
65
|
-
]
|
66
|
-
)
|
67
|
-
end
|
52
|
+
it { subject.size.must_equal(9) }
|
68
53
|
end
|
69
54
|
|
70
55
|
context 'when there is no content' do
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe CharBuilder do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::CharBuilder }
|
8
|
+
|
9
|
+
# describe '#origin' do
|
10
|
+
# it 'returns the origin for the interface' do
|
11
|
+
# geometry = Geometry.new({ width: 5, height: 5 })
|
12
|
+
# geometry.origin.must_be_instance_of(Vedeu::Position)
|
13
|
+
# geometry.origin.y.must_equal(1)
|
14
|
+
# geometry.origin.x.must_equal(1)
|
15
|
+
# end
|
16
|
+
|
17
|
+
# it 'returns the origin for the interface' do
|
18
|
+
# geometry = Geometry.new({ width: 5, height: 5, centred: true })
|
19
|
+
# geometry.origin.must_be_instance_of(Vedeu::Position)
|
20
|
+
# geometry.origin.y.must_equal(10)
|
21
|
+
# geometry.origin.x.must_equal(38)
|
22
|
+
# end
|
23
|
+
|
24
|
+
# it 'returns the line position relative to the origin' do
|
25
|
+
# geometry = Geometry.new({ width: 5, height: 5 })
|
26
|
+
# geometry.origin(3).must_be_instance_of(Vedeu::Position)
|
27
|
+
# geometry.origin(3).y.must_equal(4)
|
28
|
+
# geometry.origin(3).x.must_equal(1)
|
29
|
+
# end
|
30
|
+
|
31
|
+
# it 'returns the origin for the interface when the interface' \
|
32
|
+
# ' is at a custom position' do
|
33
|
+
# geometry = Geometry.new({ width: 5, height: 5, x: 3, y: 6 })
|
34
|
+
# geometry.origin.must_be_instance_of(Vedeu::Position)
|
35
|
+
# geometry.origin.y.must_equal(6)
|
36
|
+
# geometry.origin.x.must_equal(3)
|
37
|
+
# end
|
38
|
+
|
39
|
+
# it 'returns the line position relative to the origin when the' \
|
40
|
+
# ' interface is at a custom position' do
|
41
|
+
# geometry = Geometry.new({ width: 5, height: 5, x: 3, y: 6 })
|
42
|
+
# geometry.origin(3).must_be_instance_of(Vedeu::Position)
|
43
|
+
# geometry.origin(3).y.must_equal(9)
|
44
|
+
# geometry.origin(3).x.must_equal(3)
|
45
|
+
# end
|
46
|
+
# end
|
47
|
+
|
48
|
+
end # CharBuilder
|
49
|
+
|
50
|
+
end # Vedeu
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe Clear do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::Clear }
|
8
|
+
let(:instance) { described.new(interface) }
|
9
|
+
let(:interface) { Vedeu::Interface.new({ name: 'xenon' }) }
|
10
|
+
|
11
|
+
describe '#initialize' do
|
12
|
+
it { instance.must_be_instance_of(Vedeu::Clear) }
|
13
|
+
it { instance.instance_variable_get('@interface').must_equal(interface) }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '.clear' do
|
17
|
+
subject { described.clear(interface) }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#write' do
|
21
|
+
subject { instance.write }
|
22
|
+
end
|
23
|
+
|
24
|
+
end # Clear
|
25
|
+
|
26
|
+
end # Vedeu
|
@@ -39,16 +39,6 @@ module Vedeu
|
|
39
39
|
describe '.compose' do
|
40
40
|
subject { described.compose(_name) }
|
41
41
|
|
42
|
-
context 'when there is no content' do
|
43
|
-
end
|
44
|
-
|
45
|
-
context 'when there is content' do
|
46
|
-
context 'when the view has redefined the geometry' do
|
47
|
-
end
|
48
|
-
|
49
|
-
context 'when the view has not redefined the geometry' do
|
50
|
-
end
|
51
|
-
end
|
52
42
|
end
|
53
43
|
|
54
44
|
end # Compositor
|
@@ -19,16 +19,21 @@ module Vedeu
|
|
19
19
|
it { subject.must_be_instance_of(String) }
|
20
20
|
end
|
21
21
|
|
22
|
-
describe '
|
23
|
-
|
22
|
+
describe '.to_file' do
|
23
|
+
before { File.stubs(:open) }
|
24
24
|
|
25
|
-
subject {
|
25
|
+
subject { described.to_file(output, path) }
|
26
26
|
|
27
27
|
context 'when a path is given' do
|
28
28
|
let(:path) { '/tmp/test_vedeu_html_renderer.html' }
|
29
|
+
|
30
|
+
#it { subject.must_equal('') }
|
29
31
|
end
|
30
32
|
|
31
33
|
context 'when a path is not given' do
|
34
|
+
let(:path) {}
|
35
|
+
|
36
|
+
|
32
37
|
end
|
33
38
|
end
|
34
39
|
|
@@ -45,45 +45,6 @@ module Vedeu
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
# describe '#origin' do
|
49
|
-
# it 'returns the origin for the interface' do
|
50
|
-
# geometry = Geometry.new({ width: 5, height: 5 })
|
51
|
-
# geometry.origin.must_be_instance_of(Vedeu::Position)
|
52
|
-
# geometry.origin.y.must_equal(1)
|
53
|
-
# geometry.origin.x.must_equal(1)
|
54
|
-
# end
|
55
|
-
|
56
|
-
# it 'returns the origin for the interface' do
|
57
|
-
# geometry = Geometry.new({ width: 5, height: 5, centred: true })
|
58
|
-
# geometry.origin.must_be_instance_of(Vedeu::Position)
|
59
|
-
# geometry.origin.y.must_equal(10)
|
60
|
-
# geometry.origin.x.must_equal(38)
|
61
|
-
# end
|
62
|
-
|
63
|
-
# it 'returns the line position relative to the origin' do
|
64
|
-
# geometry = Geometry.new({ width: 5, height: 5 })
|
65
|
-
# geometry.origin(3).must_be_instance_of(Vedeu::Position)
|
66
|
-
# geometry.origin(3).y.must_equal(4)
|
67
|
-
# geometry.origin(3).x.must_equal(1)
|
68
|
-
# end
|
69
|
-
|
70
|
-
# it 'returns the origin for the interface when the interface' \
|
71
|
-
# ' is at a custom position' do
|
72
|
-
# geometry = Geometry.new({ width: 5, height: 5, x: 3, y: 6 })
|
73
|
-
# geometry.origin.must_be_instance_of(Vedeu::Position)
|
74
|
-
# geometry.origin.y.must_equal(6)
|
75
|
-
# geometry.origin.x.must_equal(3)
|
76
|
-
# end
|
77
|
-
|
78
|
-
# it 'returns the line position relative to the origin when the' \
|
79
|
-
# ' interface is at a custom position' do
|
80
|
-
# geometry = Geometry.new({ width: 5, height: 5, x: 3, y: 6 })
|
81
|
-
# geometry.origin(3).must_be_instance_of(Vedeu::Position)
|
82
|
-
# geometry.origin(3).y.must_equal(9)
|
83
|
-
# geometry.origin(3).x.must_equal(3)
|
84
|
-
# end
|
85
|
-
# end
|
86
|
-
|
87
48
|
end # Output
|
88
49
|
|
89
50
|
end # Vedeu
|
@@ -58,17 +58,9 @@ module Vedeu
|
|
58
58
|
let(:ox) { -4 }
|
59
59
|
let(:oy) { -4 }
|
60
60
|
|
61
|
-
it
|
62
|
-
|
63
|
-
[
|
64
|
-
["b", "a", "r"],
|
65
|
-
["c", "a", "r"],
|
66
|
-
["h", "e", "l"]
|
67
|
-
]
|
68
|
-
)
|
61
|
+
it 'scrolls the content the correct position' do
|
62
|
+
instance.to_s.must_equal("bar\ncar\nhel")
|
69
63
|
end
|
70
|
-
|
71
|
-
it { instance.to_s.must_equal("bar\ncar\nhel") }
|
72
64
|
end
|
73
65
|
|
74
66
|
context "when the cursor's y position is inside the viewable area" do
|
@@ -76,17 +68,9 @@ module Vedeu
|
|
76
68
|
let(:ox) { 3 }
|
77
69
|
let(:oy) { 7 }
|
78
70
|
|
79
|
-
it
|
80
|
-
|
81
|
-
[
|
82
|
-
["n", "i", "c"],
|
83
|
-
["o", "s", "m"],
|
84
|
-
[" ", " ", " "]
|
85
|
-
]
|
86
|
-
)
|
71
|
+
it 'is padded with spaces' do
|
72
|
+
instance.to_s.must_equal("nic\nosm\n ")
|
87
73
|
end
|
88
|
-
|
89
|
-
it { instance.to_s.must_equal("nic\nosm\n ") }
|
90
74
|
end
|
91
75
|
|
92
76
|
context "when there is more content than the height" do
|
@@ -94,16 +78,8 @@ module Vedeu
|
|
94
78
|
let(:oy) { 3 }
|
95
79
|
|
96
80
|
it "is cropped to show only that which fits" do
|
97
|
-
|
98
|
-
[
|
99
|
-
["b", "a", "r"],
|
100
|
-
["c", "a", "r"],
|
101
|
-
["h", "e", "l"]
|
102
|
-
]
|
103
|
-
)
|
81
|
+
instance.to_s.must_equal("bar\ncar\nhel")
|
104
82
|
end
|
105
|
-
|
106
|
-
it { instance.to_s.must_equal("bar\ncar\nhel") }
|
107
83
|
end
|
108
84
|
end
|
109
85
|
|
@@ -112,17 +88,9 @@ module Vedeu
|
|
112
88
|
let(:ox) { 6 }
|
113
89
|
let(:oy) { 6 }
|
114
90
|
|
115
|
-
it
|
116
|
-
|
117
|
-
[
|
118
|
-
["i", "n", "e"],
|
119
|
-
["k", "e", "l"],
|
120
|
-
["i", "u", "m"]
|
121
|
-
]
|
122
|
-
)
|
91
|
+
it 'scrolls the content the correct position' do
|
92
|
+
instance.to_s.must_equal("ine\nkel\nium")
|
123
93
|
end
|
124
|
-
|
125
|
-
it { instance.to_s.must_equal("ine\nkel\nium") }
|
126
94
|
end
|
127
95
|
|
128
96
|
context "and outside the content" do
|
@@ -130,16 +98,8 @@ module Vedeu
|
|
130
98
|
let(:oy) { 7 }
|
131
99
|
|
132
100
|
it "scrolls the content the correct position" do
|
133
|
-
|
134
|
-
[
|
135
|
-
["e", "l", " "],
|
136
|
-
["u", "m", " "],
|
137
|
-
[" ", " ", " "]
|
138
|
-
]
|
139
|
-
)
|
101
|
+
instance.to_s.must_equal("el \num \n ")
|
140
102
|
end
|
141
|
-
|
142
|
-
it { instance.to_s.must_equal("el \num \n ") }
|
143
103
|
end
|
144
104
|
end
|
145
105
|
|
@@ -149,16 +109,8 @@ module Vedeu
|
|
149
109
|
let(:oy) { 3 }
|
150
110
|
|
151
111
|
it "is padded with spaces" do
|
152
|
-
|
153
|
-
[
|
154
|
-
["u", "m", " "],
|
155
|
-
["o", "n", " "],
|
156
|
-
["u", "m", " "]
|
157
|
-
]
|
158
|
-
)
|
112
|
+
instance.to_s.must_equal("um \non \num ")
|
159
113
|
end
|
160
|
-
|
161
|
-
it { instance.to_s.must_equal("um \non \num ") }
|
162
114
|
end
|
163
115
|
|
164
116
|
context "when there is more content than the width" do
|
@@ -166,16 +118,8 @@ module Vedeu
|
|
166
118
|
let(:oy) { 3 }
|
167
119
|
|
168
120
|
it "is cropped to show only that which fits" do
|
169
|
-
|
170
|
-
[
|
171
|
-
["b", "a", "r"],
|
172
|
-
["c", "a", "r"],
|
173
|
-
["h", "e", "l"]
|
174
|
-
]
|
175
|
-
)
|
121
|
+
instance.to_s.must_equal("bar\ncar\nhel")
|
176
122
|
end
|
177
|
-
|
178
|
-
it { instance.to_s.must_equal("bar\ncar\nhel") }
|
179
123
|
end
|
180
124
|
end
|
181
125
|
end
|
@@ -16,9 +16,19 @@ module Vedeu
|
|
16
16
|
end
|
17
17
|
|
18
18
|
context 'when buffers are stored' do
|
19
|
-
|
19
|
+
let(:buffer) { [[Vedeu::Char.new]] }
|
20
|
+
|
21
|
+
before { described.store(buffer) }
|
20
22
|
|
21
23
|
it { subject.must_be_instance_of(Array) }
|
24
|
+
|
25
|
+
it { subject.must_equal(buffer) }
|
26
|
+
|
27
|
+
it 'removes the stored buffer from the storage' do
|
28
|
+
described.size.must_equal(1)
|
29
|
+
subject
|
30
|
+
described.size.must_equal(0)
|
31
|
+
end
|
22
32
|
end
|
23
33
|
end
|
24
34
|
|
@@ -29,7 +39,13 @@ module Vedeu
|
|
29
39
|
|
30
40
|
it { subject.must_be_instance_of(Array) }
|
31
41
|
|
32
|
-
it { subject.
|
42
|
+
it { subject.must_equal([:data]) }
|
43
|
+
|
44
|
+
it 'adds the buffer (data) to the storage' do
|
45
|
+
described.size.must_equal(0)
|
46
|
+
subject
|
47
|
+
described.size.must_equal(1)
|
48
|
+
end
|
33
49
|
end
|
34
50
|
|
35
51
|
describe '#size' do
|
@@ -14,8 +14,6 @@ module Vedeu
|
|
14
14
|
|
15
15
|
describe '#initialize' do
|
16
16
|
it { instance.must_be_instance_of(Vedeu::VirtualTerminal) }
|
17
|
-
it { instance.instance_variable_get('@cell_height').must_equal(4) }
|
18
|
-
it { instance.instance_variable_get('@cell_width').must_equal(9) }
|
19
17
|
it { instance.instance_variable_get('@height').must_equal(5) }
|
20
18
|
it { instance.instance_variable_get('@width').must_equal(10) }
|
21
19
|
it { instance.instance_variable_get('@renderer').must_equal(Vedeu::HTMLRenderer) }
|
@@ -33,19 +31,8 @@ module Vedeu
|
|
33
31
|
it { subject.must_equal(Vedeu::FakeRenderer) }
|
34
32
|
end
|
35
33
|
end
|
36
|
-
describe 'attr_reader' do
|
37
|
-
context '#cell_height' do
|
38
|
-
subject { instance.cell_height }
|
39
|
-
|
40
|
-
it { subject.must_equal(4) }
|
41
|
-
end
|
42
|
-
|
43
|
-
context '#cell_width' do
|
44
|
-
subject { instance.cell_width }
|
45
|
-
|
46
|
-
it { subject.must_equal(9) }
|
47
|
-
end
|
48
34
|
|
35
|
+
describe 'attr_reader' do
|
49
36
|
context '#height' do
|
50
37
|
subject { instance.height }
|
51
38
|
|
@@ -63,6 +50,8 @@ module Vedeu
|
|
63
50
|
subject { instance.cells }
|
64
51
|
|
65
52
|
it { subject.must_be_instance_of(Array) }
|
53
|
+
it { subject.size.must_equal(5) }
|
54
|
+
it { subject.flatten.size.must_equal(50) }
|
66
55
|
end
|
67
56
|
|
68
57
|
describe '#read' do
|
@@ -10,9 +10,11 @@ module Vedeu
|
|
10
10
|
let(:options) {
|
11
11
|
{
|
12
12
|
ellipsis: '...',
|
13
|
+
mode: mode,
|
13
14
|
width: width,
|
14
15
|
}
|
15
16
|
}
|
17
|
+
let(:mode) { :default }
|
16
18
|
let(:width) { 30 }
|
17
19
|
|
18
20
|
let(:text_line) {
|
@@ -44,11 +46,6 @@ module Vedeu
|
|
44
46
|
]
|
45
47
|
}
|
46
48
|
|
47
|
-
describe 'alias methods' do
|
48
|
-
it { instance.must_respond_to(:prune_as_lines) }
|
49
|
-
it { instance.must_respond_to(:wrap_as_lines) }
|
50
|
-
end
|
51
|
-
|
52
49
|
describe '#initialize' do
|
53
50
|
it { instance.must_be_instance_of(described) }
|
54
51
|
it { instance.instance_variable_get('@text').must_equal(text) }
|
@@ -174,8 +171,8 @@ module Vedeu
|
|
174
171
|
end
|
175
172
|
end
|
176
173
|
|
177
|
-
describe '#
|
178
|
-
subject { instance.
|
174
|
+
describe '#content' do
|
175
|
+
subject { instance.content }
|
179
176
|
|
180
177
|
it { subject.must_be_instance_of(Vedeu::Lines) }
|
181
178
|
|
@@ -203,10 +200,8 @@ module Vedeu
|
|
203
200
|
it { subject.size.must_equal(6) }
|
204
201
|
end
|
205
202
|
|
206
|
-
context '
|
207
|
-
|
208
|
-
|
209
|
-
it { subject.must_be_instance_of(Vedeu::Lines) }
|
203
|
+
context 'when mode: :prune' do
|
204
|
+
let(:mode) { :prune }
|
210
205
|
|
211
206
|
context 'with a single line of text' do
|
212
207
|
let(:text) { text_line }
|
@@ -233,10 +228,8 @@ module Vedeu
|
|
233
228
|
end
|
234
229
|
end
|
235
230
|
|
236
|
-
context '
|
237
|
-
|
238
|
-
|
239
|
-
it { subject.must_be_instance_of(Vedeu::Lines) }
|
231
|
+
context 'when mode: :wrap' do
|
232
|
+
let(:mode) { :wrap }
|
240
233
|
|
241
234
|
context 'with a single line of text' do
|
242
235
|
let(:text) { text_line }
|