vedeu 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/borders_app.rb +15 -14
- data/examples/colours_app.rb +1 -2
- data/examples/cursor_app.rb +2 -5
- data/examples/geometry_app.rb +141 -0
- data/lib/vedeu.rb +0 -17
- data/lib/vedeu/api.rb +18 -3
- data/lib/vedeu/buffers/all.rb +0 -6
- data/lib/vedeu/buffers/buffer.rb +5 -2
- data/lib/vedeu/cursor/all.rb +0 -13
- data/lib/vedeu/cursor/cursor.rb +1 -1
- data/lib/vedeu/dsl/components/border.rb +94 -12
- data/lib/vedeu/dsl/components/geometry.rb +40 -48
- data/lib/vedeu/dsl/components/keymap.rb +36 -0
- data/lib/vedeu/dsl/interface.rb +20 -5
- data/lib/vedeu/dsl/stream.rb +2 -0
- data/lib/vedeu/events/all.rb +0 -5
- data/lib/vedeu/events/event.rb +2 -1
- data/lib/vedeu/events/trigger.rb +1 -3
- data/lib/vedeu/input/all.rb +7 -12
- data/lib/vedeu/input/keymap.rb +10 -34
- data/lib/vedeu/input/keys.rb +1 -0
- data/lib/vedeu/input/mapper.rb +1 -5
- data/lib/vedeu/models/collection.rb +4 -0
- data/lib/vedeu/models/geometry.rb +2 -1
- data/lib/vedeu/models/model.rb +4 -0
- data/lib/vedeu/models/view/char.rb +10 -0
- data/lib/vedeu/models/view/chars.rb +3 -2
- data/lib/vedeu/models/view/interface.rb +18 -28
- data/lib/vedeu/models/view/interfaces.rb +3 -2
- data/lib/vedeu/models/view/lines.rb +3 -2
- data/lib/vedeu/models/view/stream.rb +1 -1
- data/lib/vedeu/models/view/streams.rb +3 -2
- data/lib/vedeu/output/border.rb +29 -21
- data/lib/vedeu/output/compositor.rb +2 -3
- data/lib/vedeu/output/output.rb +5 -1
- data/lib/vedeu/output/viewport.rb +45 -24
- data/lib/vedeu/output/wordwrap.rb +7 -1
- data/lib/vedeu/output/writer.rb +3 -0
- data/lib/vedeu/presentation/presentation.rb +2 -0
- data/lib/vedeu/repositories/all.rb +107 -1
- data/lib/vedeu/repositories/repository.rb +4 -0
- data/lib/vedeu/support/bounding_area.rb +1 -1
- data/lib/vedeu/support/position_validator.rb +18 -0
- data/test/lib/vedeu/buffers/buffer_test.rb +8 -8
- data/test/lib/vedeu/cursor/move_cursor_test.rb +3 -6
- data/test/lib/vedeu/dsl/components/border_test.rb +53 -4
- data/test/lib/vedeu/dsl/components/geometry_test.rb +0 -24
- data/test/lib/vedeu/dsl/interface_test.rb +11 -3
- data/test/lib/vedeu/events/event_test.rb +2 -2
- data/test/lib/vedeu/models/view/interface_test.rb +1 -25
- data/test/lib/vedeu/models/view/stream_test.rb +8 -0
- data/test/lib/vedeu/output/border_test.rb +159 -81
- data/test/lib/vedeu/output/output_test.rb +1 -2
- data/test/lib/vedeu/output/viewport_test.rb +3 -10
- data/test/lib/vedeu/repositories/all_test.rb +128 -0
- data/test/lib/vedeu/support/content_geometry_test.rb +1 -2
- data/vedeu.gemspec +1 -1
- metadata +3 -13
- data/lib/vedeu/repositories/menus.rb +0 -13
- data/test/lib/vedeu/buffers/all_test.rb +0 -11
- data/test/lib/vedeu/cursor/all_test.rb +0 -33
- data/test/lib/vedeu/events/all_test.rb +0 -11
- data/test/lib/vedeu/input/all_test.rb +0 -11
- data/test/lib/vedeu/repositories/menus_test.rb +0 -15
@@ -1,5 +1,7 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
+
# Wrap or prune text.
|
4
|
+
#
|
3
5
|
class Wordwrap
|
4
6
|
|
5
7
|
# @param text [String]
|
@@ -58,6 +60,7 @@ module Vedeu
|
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
63
|
+
# @return [Vedeu::Lines]
|
61
64
|
def as_lines
|
62
65
|
if __callee__ == :prune_as_lines
|
63
66
|
to_line_objects(prune)
|
@@ -75,7 +78,8 @@ module Vedeu
|
|
75
78
|
|
76
79
|
private
|
77
80
|
|
78
|
-
attr_reader :text,
|
81
|
+
attr_reader :text,
|
82
|
+
:options
|
79
83
|
|
80
84
|
# @param text_as_lines [Array<String>]
|
81
85
|
# @return [Vedeu::Lines]
|
@@ -102,6 +106,7 @@ module Vedeu
|
|
102
106
|
end.join("\n")
|
103
107
|
end
|
104
108
|
|
109
|
+
# @param string [String]
|
105
110
|
# @return [String]
|
106
111
|
def ellipsis_string(string)
|
107
112
|
if string.size < ellipsis.size
|
@@ -113,6 +118,7 @@ module Vedeu
|
|
113
118
|
end
|
114
119
|
end
|
115
120
|
|
121
|
+
# @param string [String]
|
116
122
|
# @return [String]
|
117
123
|
def prune_string(string)
|
118
124
|
string.chomp.slice(0..pruned_width)
|
data/lib/vedeu/output/writer.rb
CHANGED
@@ -4,10 +4,12 @@ module Vedeu
|
|
4
4
|
|
5
5
|
attr_reader :writers
|
6
6
|
|
7
|
+
# @return [Vedeu::Writer]
|
7
8
|
def self.[](*args)
|
8
9
|
new(args)
|
9
10
|
end
|
10
11
|
|
12
|
+
# @return [Vedeu::Writer]
|
11
13
|
def initialize(writers)
|
12
14
|
@writers = writers
|
13
15
|
end
|
@@ -16,6 +18,7 @@ module Vedeu
|
|
16
18
|
writers == other.writers
|
17
19
|
end
|
18
20
|
|
21
|
+
# @return [Vedeu::Writer]
|
19
22
|
def +(other)
|
20
23
|
Writer[*(writers + other.writers)]
|
21
24
|
end
|
@@ -1,5 +1,111 @@
|
|
1
1
|
require 'vedeu/repositories/repository'
|
2
|
-
require 'vedeu/repositories/menus'
|
3
2
|
|
4
3
|
module Vedeu
|
4
|
+
|
5
|
+
# Allows the storing of interface/view borders independent of the interface
|
6
|
+
# instance.
|
7
|
+
#
|
8
|
+
class Borders < Repository
|
9
|
+
|
10
|
+
# @return [Vedeu::Borders]
|
11
|
+
def self.borders
|
12
|
+
@_borders ||= Vedeu::Borders.new(Vedeu::Border)
|
13
|
+
end
|
14
|
+
|
15
|
+
end # Borders
|
16
|
+
|
17
|
+
# Allows the storing of view buffers.
|
18
|
+
#
|
19
|
+
class Buffers < Repository
|
20
|
+
|
21
|
+
# @return [Vedeu::Buffers]
|
22
|
+
def self.buffers
|
23
|
+
@_buffers ||= Vedeu::Buffers.new(Vedeu::Buffer)
|
24
|
+
end
|
25
|
+
|
26
|
+
end # Buffers
|
27
|
+
|
28
|
+
# Allows the storing of each interface's cursor.
|
29
|
+
#
|
30
|
+
class Cursors < Repository
|
31
|
+
|
32
|
+
# @return [Vedeu::Cursors]
|
33
|
+
def self.cursors
|
34
|
+
@_cursors ||= Vedeu::Cursors.new(Vedeu::Cursor)
|
35
|
+
end
|
36
|
+
|
37
|
+
# @return [Vedeu::Cursor]
|
38
|
+
def self.cursor
|
39
|
+
cursors.current
|
40
|
+
end
|
41
|
+
|
42
|
+
end # Cursors
|
43
|
+
|
44
|
+
# Allows the storing of events.
|
45
|
+
#
|
46
|
+
class Events < Repository
|
47
|
+
|
48
|
+
# @return [Vedeu::Events]
|
49
|
+
def self.events
|
50
|
+
@_events ||= Vedeu::Events.new(Vedeu::Model::Collection)
|
51
|
+
end
|
52
|
+
|
53
|
+
end # Events
|
54
|
+
|
55
|
+
# Allows the storing of interface/view geometry independent of the interface
|
56
|
+
# instance.
|
57
|
+
#
|
58
|
+
class Geometries < Repository
|
59
|
+
|
60
|
+
# @return [Vedeu::Geometries]
|
61
|
+
def self.geometries
|
62
|
+
@_geometries ||= Vedeu::Geometries.new(Vedeu::Geometry)
|
63
|
+
end
|
64
|
+
|
65
|
+
end # Geometries
|
66
|
+
|
67
|
+
# Allows the storing of view groups.
|
68
|
+
#
|
69
|
+
class Groups < Repository
|
70
|
+
|
71
|
+
# @return [Vedeu::Groups]
|
72
|
+
def self.groups
|
73
|
+
@_groups ||= Vedeu::Groups.new(Vedeu::Group)
|
74
|
+
end
|
75
|
+
|
76
|
+
end # Groups
|
77
|
+
|
78
|
+
# Allows the storing of interfaces and views.
|
79
|
+
#
|
80
|
+
class InterfacesRepository < Repository
|
81
|
+
|
82
|
+
# @return [Vedeu::InterfacesRepository]
|
83
|
+
def self.interfaces
|
84
|
+
@_interfaces ||= Vedeu::InterfacesRepository.new(Vedeu::Interface)
|
85
|
+
end
|
86
|
+
|
87
|
+
end # InterfacesRepository
|
88
|
+
|
89
|
+
# Allows the storing of keymaps.
|
90
|
+
#
|
91
|
+
class Keymaps < Repository
|
92
|
+
|
93
|
+
# @return [Vedeu::Keymaps]
|
94
|
+
def self.keymaps
|
95
|
+
@_keymaps ||= Vedeu::Keymaps.new(Vedeu::Keymap)
|
96
|
+
end
|
97
|
+
|
98
|
+
end # Keymaps
|
99
|
+
|
100
|
+
# Allows the storing of menus by name.
|
101
|
+
#
|
102
|
+
class Menus < Repository
|
103
|
+
|
104
|
+
# @return [Vedeu::Menus]
|
105
|
+
def self.menus
|
106
|
+
@_menus ||= Vedeu::Menus.new(Vedeu::Menu)
|
107
|
+
end
|
108
|
+
|
109
|
+
end # Menus
|
110
|
+
|
5
111
|
end # Vedeu
|
@@ -19,6 +19,9 @@ module Vedeu
|
|
19
19
|
|
20
20
|
attr_reader :model, :storage
|
21
21
|
|
22
|
+
# @param model [Class]
|
23
|
+
# @param storage [Class|Hash]
|
24
|
+
# @return [Vedeu::Repository]
|
22
25
|
def initialize(model = nil, storage = {})
|
23
26
|
@model = model
|
24
27
|
@storage = storage
|
@@ -45,6 +48,7 @@ module Vedeu
|
|
45
48
|
find_or_create(Vedeu.focus) if Vedeu.focus
|
46
49
|
end
|
47
50
|
|
51
|
+
# @return [Enumerator]
|
48
52
|
def each(&block)
|
49
53
|
storage.each(&block)
|
50
54
|
end
|
@@ -60,25 +60,43 @@ module Vedeu
|
|
60
60
|
|
61
61
|
attr_reader :interface
|
62
62
|
|
63
|
+
# Validate the x and y coordinates are within the dimensions of the
|
64
|
+
# terminal.
|
65
|
+
#
|
66
|
+
# @return [PositionValidator]
|
63
67
|
def terminal_validation
|
64
68
|
@x = tx if x < tx
|
65
69
|
@x = txn if x > txn
|
66
70
|
@y = ty if y < ty
|
67
71
|
@y = tyn if y > tyn
|
72
|
+
|
73
|
+
self
|
68
74
|
end
|
69
75
|
|
76
|
+
# Validate the x and y coordinates are within the dimensions of the
|
77
|
+
# interface.
|
78
|
+
#
|
79
|
+
# @return [PositionValidator]
|
70
80
|
def interface_validation
|
71
81
|
@x = left if x < left
|
72
82
|
@x = right if x > right
|
73
83
|
@y = top if y < top
|
74
84
|
@y = bottom if y > bottom
|
85
|
+
|
86
|
+
self
|
75
87
|
end
|
76
88
|
|
89
|
+
# Validate the x and y coordinates are within the dimensions of an interface
|
90
|
+
# with a border.
|
91
|
+
#
|
92
|
+
# @return [PositionValidator]
|
77
93
|
def border_validation
|
78
94
|
@x = left + 1 if left? && x < (left + 1)
|
79
95
|
@x = right - 2 if right? && x > (right - 1)
|
80
96
|
@y = top + 1 if top? && y < (top + 1)
|
81
97
|
@y = bottom - 2 if bottom? && y > (bottom - 1)
|
98
|
+
|
99
|
+
self
|
82
100
|
end
|
83
101
|
|
84
102
|
# def x
|
@@ -33,14 +33,14 @@ module Vedeu
|
|
33
33
|
|
34
34
|
describe '#add' do
|
35
35
|
let(:back) {
|
36
|
-
Vedeu
|
36
|
+
Vedeu.interface 'buffer' do
|
37
37
|
lines do
|
38
38
|
line 'old_back'
|
39
39
|
end
|
40
40
|
end
|
41
41
|
}
|
42
42
|
let(:content) {
|
43
|
-
Vedeu
|
43
|
+
Vedeu.interface 'buffer' do
|
44
44
|
lines do
|
45
45
|
line 'new_back'
|
46
46
|
end
|
@@ -67,7 +67,7 @@ module Vedeu
|
|
67
67
|
|
68
68
|
context 'when there is content on the back buffer' do
|
69
69
|
let(:back) {
|
70
|
-
Vedeu
|
70
|
+
Vedeu.interface 'buffer' do
|
71
71
|
lines do
|
72
72
|
line 'old_back'
|
73
73
|
end
|
@@ -94,7 +94,7 @@ module Vedeu
|
|
94
94
|
context 'when there is content on the front buffer' do
|
95
95
|
let(:buffer) { :front }
|
96
96
|
let(:front) {
|
97
|
-
Vedeu
|
97
|
+
Vedeu.interface 'buffer' do
|
98
98
|
lines do
|
99
99
|
line 'front'
|
100
100
|
end
|
@@ -120,7 +120,7 @@ module Vedeu
|
|
120
120
|
context 'when there is content on the previous buffer' do
|
121
121
|
let(:buffer) { :previous }
|
122
122
|
let(:previous) {
|
123
|
-
Vedeu
|
123
|
+
Vedeu.interface 'buffer' do
|
124
124
|
lines do
|
125
125
|
line 'old_back'
|
126
126
|
end
|
@@ -149,21 +149,21 @@ module Vedeu
|
|
149
149
|
|
150
150
|
context 'when there is new content on the back buffer' do
|
151
151
|
let(:back) {
|
152
|
-
Vedeu
|
152
|
+
Vedeu.interface 'buffer' do
|
153
153
|
lines do
|
154
154
|
line 'back'
|
155
155
|
end
|
156
156
|
end
|
157
157
|
}
|
158
158
|
let(:front) {
|
159
|
-
Vedeu
|
159
|
+
Vedeu.interface 'buffer' do
|
160
160
|
lines do
|
161
161
|
line 'front'
|
162
162
|
end
|
163
163
|
end
|
164
164
|
}
|
165
165
|
let(:previous) {
|
166
|
-
Vedeu
|
166
|
+
Vedeu.interface 'buffer' do
|
167
167
|
lines do
|
168
168
|
line 'previous'
|
169
169
|
end
|
@@ -13,16 +13,14 @@ module Vedeu
|
|
13
13
|
let(:y) { 1 }
|
14
14
|
|
15
15
|
let(:interface) {
|
16
|
-
Vedeu
|
17
|
-
name 'magnesium'
|
16
|
+
Vedeu.interface 'magnesium' do
|
18
17
|
geometry do
|
19
18
|
|
20
19
|
end
|
21
20
|
end
|
22
21
|
}
|
23
22
|
let(:interface_with_border) {
|
24
|
-
Vedeu
|
25
|
-
name 'manganese'
|
23
|
+
Vedeu.interface 'manganese' do
|
26
24
|
border do
|
27
25
|
# ...
|
28
26
|
end
|
@@ -35,8 +33,7 @@ module Vedeu
|
|
35
33
|
end
|
36
34
|
}
|
37
35
|
let(:interface_without_border) {
|
38
|
-
Vedeu
|
39
|
-
name 'meitnerium'
|
36
|
+
Vedeu.interface 'meitnerium' do
|
40
37
|
geometry do
|
41
38
|
height 5
|
42
39
|
width 5
|
@@ -7,14 +7,15 @@ module Vedeu
|
|
7
7
|
describe Border do
|
8
8
|
|
9
9
|
let(:described) { Vedeu::DSL::Border }
|
10
|
-
let(:instance) { described.new(model) }
|
11
|
-
let(:model) { Vedeu::Border.new(
|
10
|
+
let(:instance) { described.new(model, client) }
|
11
|
+
let(:model) { Vedeu::Border.new(attributes) }
|
12
12
|
let(:client) {}
|
13
|
-
let(:
|
14
|
-
let(:attributes) { {} }
|
13
|
+
let(:attributes) { { name: 'borders' } }
|
15
14
|
let(:boolean) { true }
|
16
15
|
|
17
16
|
before do
|
17
|
+
Vedeu.borders.reset
|
18
|
+
Vedeu.buffers.reset
|
18
19
|
Vedeu.interfaces.reset
|
19
20
|
Vedeu.interface 'borders' do
|
20
21
|
geometry do
|
@@ -182,6 +183,18 @@ module Vedeu
|
|
182
183
|
end
|
183
184
|
end
|
184
185
|
|
186
|
+
describe '#hide_bottom!' do
|
187
|
+
subject { instance.hide_bottom! }
|
188
|
+
|
189
|
+
it { subject.must_be_instance_of(FalseClass) }
|
190
|
+
end
|
191
|
+
|
192
|
+
describe '#show_bottom!' do
|
193
|
+
subject { instance.show_bottom! }
|
194
|
+
|
195
|
+
it { subject.must_be_instance_of(TrueClass) }
|
196
|
+
end
|
197
|
+
|
185
198
|
describe '#show_left' do
|
186
199
|
subject { instance.show_left(boolean) }
|
187
200
|
|
@@ -221,6 +234,18 @@ module Vedeu
|
|
221
234
|
end
|
222
235
|
end
|
223
236
|
|
237
|
+
describe '#hide_left!' do
|
238
|
+
subject { instance.hide_left! }
|
239
|
+
|
240
|
+
it { subject.must_be_instance_of(FalseClass) }
|
241
|
+
end
|
242
|
+
|
243
|
+
describe '#show_left!' do
|
244
|
+
subject { instance.show_left! }
|
245
|
+
|
246
|
+
it { subject.must_be_instance_of(TrueClass) }
|
247
|
+
end
|
248
|
+
|
224
249
|
describe '#show_right' do
|
225
250
|
subject { instance.show_right(boolean) }
|
226
251
|
|
@@ -260,6 +285,18 @@ module Vedeu
|
|
260
285
|
end
|
261
286
|
end
|
262
287
|
|
288
|
+
describe '#hide_right!' do
|
289
|
+
subject { instance.hide_right! }
|
290
|
+
|
291
|
+
it { subject.must_be_instance_of(FalseClass) }
|
292
|
+
end
|
293
|
+
|
294
|
+
describe '#show_right!' do
|
295
|
+
subject { instance.show_right! }
|
296
|
+
|
297
|
+
it { subject.must_be_instance_of(TrueClass) }
|
298
|
+
end
|
299
|
+
|
263
300
|
describe '#show_top' do
|
264
301
|
subject { instance.show_top(boolean) }
|
265
302
|
|
@@ -299,6 +336,18 @@ module Vedeu
|
|
299
336
|
end
|
300
337
|
end
|
301
338
|
|
339
|
+
describe '#hide_top!' do
|
340
|
+
subject { instance.hide_top! }
|
341
|
+
|
342
|
+
it { subject.must_be_instance_of(FalseClass) }
|
343
|
+
end
|
344
|
+
|
345
|
+
describe '#show_top!' do
|
346
|
+
subject { instance.show_top! }
|
347
|
+
|
348
|
+
it { subject.must_be_instance_of(TrueClass) }
|
349
|
+
end
|
350
|
+
|
302
351
|
describe '#top_left' do
|
303
352
|
let(:char) { 'A' }
|
304
353
|
|