vedeu 0.8.18 → 0.8.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vedeu/borders/border.rb +1 -1
- data/lib/vedeu/borders/refresh.rb +20 -22
- data/lib/vedeu/buffers/buffer.rb +18 -15
- data/lib/vedeu/cells/cursor.rb +10 -0
- data/lib/vedeu/cells/empty.rb +1 -1
- data/lib/vedeu/cells/escape.rb +5 -0
- data/lib/vedeu/configuration/configuration.rb +1 -0
- data/lib/vedeu/cursors/cursor.rb +1 -6
- data/lib/vedeu/cursors/refresh.rb +4 -8
- data/lib/vedeu/dsl/elements.rb +1 -4
- data/lib/vedeu/editor/cursor.rb +1 -1
- data/lib/vedeu/events/trigger.rb +1 -1
- data/lib/vedeu/geometries/move.rb +1 -1
- data/lib/vedeu/groups/group.rb +1 -1
- data/lib/vedeu/input/keymap.rb +1 -1
- data/lib/vedeu/interfaces/interface.rb +1 -1
- data/lib/vedeu/menus/menu.rb +1 -1
- data/lib/vedeu/output/compressor.rb +4 -2
- data/lib/vedeu/output/viewport.rb +1 -1
- data/lib/vedeu/renderers/escape.rb +1 -36
- data/lib/vedeu/renderers/text.rb +1 -34
- data/lib/vedeu/repositories/collection.rb +13 -3
- data/lib/vedeu/version.rb +1 -1
- data/lib/vedeu/views/view.rb +3 -7
- data/test/lib/vedeu/cells/cursor_test.rb +12 -0
- data/test/lib/vedeu/cells/empty_test.rb +1 -1
- data/test/lib/vedeu/cells/escape_test.rb +6 -0
- data/test/lib/vedeu/geometries/move_test.rb +1 -1
- data/test/lib/vedeu/output/viewport_test.rb +7 -1
- data/test/lib/vedeu/templating/helpers_test.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b277bb2a5c69ac52c885232267ee82fdb002277d
|
4
|
+
data.tar.gz: edc448e3e5a89a5ad038bae149d9a2adbff9f939
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a615ad7a66fa2d035a9b996cbe45346d5c0d5d649135a4f0dff83d9e407e6e06dedaaacfcb225f8dbfe1beeee7e528054fd659c71f17d510d192f261a803620d
|
7
|
+
data.tar.gz: e9e791cb8613bbaaf07d54904dd052254dd5fd4bb7f09f3caa7df79db934ae8a9ae5186d404849665d631661acdff2c911a4f47f066474ff72c7589cb8157f35
|
data/lib/vedeu/borders/border.rb
CHANGED
@@ -120,6 +120,13 @@ module Vedeu
|
|
120
120
|
[(bottom_left if left?), captionbar, (bottom_right if right?)].compact
|
121
121
|
end
|
122
122
|
|
123
|
+
# @return [Array<void>]
|
124
|
+
def bottom_border
|
125
|
+
build_collection(bordered_width) do |ix|
|
126
|
+
bottom_horizontal.dup.tap { |cell| cell.position = [yn, bx + ix] }
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
123
130
|
# @macro geometry_by_name
|
124
131
|
def geometry
|
125
132
|
Vedeu.geometries.by_name(name)
|
@@ -141,9 +148,7 @@ module Vedeu
|
|
141
148
|
# @return [Array<void>]
|
142
149
|
def left
|
143
150
|
build_collection(bordered_height) do |iy|
|
144
|
-
cell =
|
145
|
-
cell.position = [by + iy, x]
|
146
|
-
cell
|
151
|
+
left_vertical.dup.tap { |cell| cell.position = [by + iy, x] }
|
147
152
|
end
|
148
153
|
end
|
149
154
|
|
@@ -152,9 +157,7 @@ module Vedeu
|
|
152
157
|
# @return [Array<void>]
|
153
158
|
def right
|
154
159
|
build_collection(bordered_height) do |iy|
|
155
|
-
cell =
|
156
|
-
cell.position = [by + iy, xn]
|
157
|
-
cell
|
160
|
+
right_vertical.dup.tap { |cell| cell.position = [by + iy, xn] }
|
158
161
|
end
|
159
162
|
end
|
160
163
|
|
@@ -170,34 +173,29 @@ module Vedeu
|
|
170
173
|
[(top_left if left?), titlebar, (top_right if right?)].compact
|
171
174
|
end
|
172
175
|
|
176
|
+
# @return [Array<void>]
|
177
|
+
def top_border
|
178
|
+
build_collection(bordered_width) do |ix|
|
179
|
+
top_horizontal.dup.tap { |cell| cell.position = [y, bx + ix] }
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
173
183
|
# An optional caption for when the bottom border is to be shown.
|
174
184
|
#
|
175
185
|
# @return (see Vedeu::Borders::Caption#render)
|
176
186
|
def captionbar
|
177
|
-
|
178
|
-
cell = bottom_horizontal.dup
|
179
|
-
cell.position = [yn, bx + ix]
|
180
|
-
cell
|
181
|
-
end
|
187
|
+
return bottom_border unless present?(caption)
|
182
188
|
|
183
|
-
|
184
|
-
|
185
|
-
Vedeu::Borders::Caption.render(name, caption, characters)
|
189
|
+
Vedeu::Borders::Caption.render(name, caption, bottom_border)
|
186
190
|
end
|
187
191
|
|
188
192
|
# An optional title for when the top border is to be shown.
|
189
193
|
#
|
190
194
|
# @return (see Vedeu::Borders::Title#render)
|
191
195
|
def titlebar
|
192
|
-
|
193
|
-
cell = top_horizontal.dup
|
194
|
-
cell.position = [y, bx + ix]
|
195
|
-
cell
|
196
|
-
end
|
197
|
-
|
198
|
-
return characters unless present?(title)
|
196
|
+
return top_border unless present?(title)
|
199
197
|
|
200
|
-
Vedeu::Borders::Title.render(name, title,
|
198
|
+
Vedeu::Borders::Title.render(name, title, top_border)
|
201
199
|
end
|
202
200
|
|
203
201
|
# Build a collection with the given size of objects given within
|
data/lib/vedeu/buffers/buffer.rb
CHANGED
@@ -136,20 +136,7 @@ module Vedeu
|
|
136
136
|
#
|
137
137
|
# @return [Array<Array<Array<Vedeu::Cells::Char>>>]
|
138
138
|
def render
|
139
|
-
current
|
140
|
-
swap
|
141
|
-
|
142
|
-
front
|
143
|
-
|
144
|
-
elsif front?
|
145
|
-
front
|
146
|
-
|
147
|
-
elsif previous?
|
148
|
-
previous
|
149
|
-
|
150
|
-
end
|
151
|
-
|
152
|
-
Vedeu::Output::Viewport.render(current) unless current.nil?
|
139
|
+
Vedeu::Output::Viewport.render(current)
|
153
140
|
end
|
154
141
|
|
155
142
|
# Returns the number of lines of content for the buffer or 0 if
|
@@ -174,12 +161,28 @@ module Vedeu
|
|
174
161
|
|
175
162
|
private
|
176
163
|
|
164
|
+
# @return [Vedeu::Views::View|NilClass]
|
165
|
+
def current
|
166
|
+
if back?
|
167
|
+
swap
|
168
|
+
|
169
|
+
front
|
170
|
+
|
171
|
+
elsif front?
|
172
|
+
front
|
173
|
+
|
174
|
+
elsif previous?
|
175
|
+
previous
|
176
|
+
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
177
180
|
# @macro defaults_method
|
178
181
|
def defaults
|
179
182
|
{
|
180
183
|
back: nil,
|
181
184
|
front: nil,
|
182
|
-
name:
|
185
|
+
name: nil,
|
183
186
|
previous: nil,
|
184
187
|
repository: Vedeu.buffers,
|
185
188
|
}
|
data/lib/vedeu/cells/cursor.rb
CHANGED
@@ -20,6 +20,11 @@ module Vedeu
|
|
20
20
|
alias foreground null
|
21
21
|
alias style null
|
22
22
|
|
23
|
+
# @return [String]
|
24
|
+
def to_ast
|
25
|
+
''
|
26
|
+
end
|
27
|
+
|
23
28
|
# Return an empty hash as most escape sequences won't make
|
24
29
|
# sense as JSON.
|
25
30
|
#
|
@@ -44,6 +49,11 @@ module Vedeu
|
|
44
49
|
end
|
45
50
|
alias to_str to_s
|
46
51
|
|
52
|
+
# @return [String]
|
53
|
+
def text
|
54
|
+
''
|
55
|
+
end
|
56
|
+
|
47
57
|
# @return [Symbol]
|
48
58
|
def type
|
49
59
|
:cursor
|
data/lib/vedeu/cells/empty.rb
CHANGED
data/lib/vedeu/cells/escape.rb
CHANGED
data/lib/vedeu/cursors/cursor.rb
CHANGED
@@ -231,7 +231,7 @@ module Vedeu
|
|
231
231
|
# @macro defaults_method
|
232
232
|
def defaults
|
233
233
|
{
|
234
|
-
name:
|
234
|
+
name: nil,
|
235
235
|
ox: 1,
|
236
236
|
oy: 1,
|
237
237
|
repository: Vedeu.cursors,
|
@@ -246,11 +246,6 @@ module Vedeu
|
|
246
246
|
Vedeu::Cells::Cursor.new(position: position, value: visibility)
|
247
247
|
end
|
248
248
|
|
249
|
-
# @return [Hash<Symbol => Fixnum>]
|
250
|
-
def new_attributes(new_y = y, new_x = x, new_oy = oy, new_ox = ox)
|
251
|
-
attributes.merge!(x: new_x, y: new_y, ox: new_ox, oy: new_oy)
|
252
|
-
end
|
253
|
-
|
254
249
|
# Returns the escape sequence for setting the visibility of the
|
255
250
|
# cursor.
|
256
251
|
#
|
@@ -19,10 +19,7 @@ module Vedeu
|
|
19
19
|
:ox,
|
20
20
|
:oy,
|
21
21
|
:render,
|
22
|
-
:visible
|
23
|
-
:visible?,
|
24
|
-
:x,
|
25
|
-
:y
|
22
|
+
:visible?
|
26
23
|
|
27
24
|
def_delegators :geometry,
|
28
25
|
:bordered_height,
|
@@ -52,13 +49,12 @@ module Vedeu
|
|
52
49
|
#
|
53
50
|
# @return [Array]
|
54
51
|
def by_name
|
55
|
-
Vedeu.trigger(:_refresh_view_content_, name) if refresh_view?
|
56
|
-
|
57
52
|
Vedeu.log(type: :cursor,
|
58
|
-
message: "Refreshing cursor:
|
59
|
-
"ox:#{ox}, oy:#{oy}, visible:#{visible})")
|
53
|
+
message: "Refreshing cursor: (#{cursor.inspect})")
|
60
54
|
|
61
55
|
render
|
56
|
+
|
57
|
+
Vedeu.trigger(:_refresh_view_content_, name) if refresh_view?
|
62
58
|
end
|
63
59
|
|
64
60
|
private
|
data/lib/vedeu/dsl/elements.rb
CHANGED
@@ -171,12 +171,9 @@ module Vedeu
|
|
171
171
|
|
172
172
|
end
|
173
173
|
|
174
|
-
if view_model?
|
174
|
+
if view_model? || line_model? || stream_model?
|
175
175
|
model.add(l)
|
176
176
|
|
177
|
-
elsif line_model? || stream_model?
|
178
|
-
model.add([l])
|
179
|
-
|
180
177
|
else
|
181
178
|
raise Vedeu::Error::Fatal,
|
182
179
|
"Cannot add stream to '#{model.class.name}' model."
|
data/lib/vedeu/editor/cursor.rb
CHANGED
data/lib/vedeu/events/trigger.rb
CHANGED
data/lib/vedeu/groups/group.rb
CHANGED
data/lib/vedeu/input/keymap.rb
CHANGED
data/lib/vedeu/menus/menu.rb
CHANGED
@@ -61,8 +61,10 @@ module Vedeu
|
|
61
61
|
#
|
62
62
|
# @return [Array]
|
63
63
|
def content
|
64
|
-
@_content ||=
|
65
|
-
|
64
|
+
@_content ||= Vedeu.timer('Removing empty cells...') do
|
65
|
+
output.content.reject do |cell|
|
66
|
+
cell.class == Vedeu::Cells::Empty
|
67
|
+
end
|
66
68
|
end
|
67
69
|
end
|
68
70
|
|
@@ -39,9 +39,7 @@ module Vedeu
|
|
39
39
|
|
40
40
|
output.each do |row|
|
41
41
|
row.each do |char|
|
42
|
-
next unless
|
43
|
-
positionable?(char) &&
|
44
|
-
escapable?(char)
|
42
|
+
next unless positionable?(char)
|
45
43
|
|
46
44
|
empty[char.position.y - 1][char.position.x - 1] = char.to_ast
|
47
45
|
end
|
@@ -50,39 +48,6 @@ module Vedeu
|
|
50
48
|
empty
|
51
49
|
end
|
52
50
|
|
53
|
-
# @return [Array<Class>]
|
54
|
-
def renderables
|
55
|
-
[
|
56
|
-
Vedeu::Cells::Border,
|
57
|
-
Vedeu::Cells::BottomHorizontal,
|
58
|
-
Vedeu::Cells::BottomLeft,
|
59
|
-
Vedeu::Cells::BottomRight,
|
60
|
-
Vedeu::Cells::Corner,
|
61
|
-
Vedeu::Cells::Char,
|
62
|
-
Vedeu::Cells::Clear,
|
63
|
-
Vedeu::Cells::Cursor,
|
64
|
-
Vedeu::Cells::Empty,
|
65
|
-
Vedeu::Cells::Escape,
|
66
|
-
Vedeu::Cells::Horizontal,
|
67
|
-
Vedeu::Cells::LeftVertical,
|
68
|
-
Vedeu::Cells::RightVertical,
|
69
|
-
Vedeu::Cells::TopHorizontal,
|
70
|
-
Vedeu::Cells::TopLeft,
|
71
|
-
Vedeu::Cells::TopRight,
|
72
|
-
Vedeu::Cells::Vertical,
|
73
|
-
]
|
74
|
-
end
|
75
|
-
|
76
|
-
# @return [Boolean]
|
77
|
-
def renderable?(char)
|
78
|
-
renderables.include?(char.class)
|
79
|
-
end
|
80
|
-
|
81
|
-
# @return [Boolean]
|
82
|
-
def escapable?(char)
|
83
|
-
char.respond_to?(:to_ast)
|
84
|
-
end
|
85
|
-
|
86
51
|
end # Escape
|
87
52
|
|
88
53
|
end # Renderers
|
data/lib/vedeu/renderers/text.rb
CHANGED
@@ -34,9 +34,7 @@ module Vedeu
|
|
34
34
|
|
35
35
|
output.each do |row|
|
36
36
|
row.each do |char|
|
37
|
-
next unless
|
38
|
-
positionable?(char) &&
|
39
|
-
textual?(char)
|
37
|
+
next unless positionable?(char)
|
40
38
|
|
41
39
|
empty[char.position.y - 1][char.position.x - 1] = char.text
|
42
40
|
end
|
@@ -45,37 +43,6 @@ module Vedeu
|
|
45
43
|
empty
|
46
44
|
end
|
47
45
|
|
48
|
-
# @return [Array<Class>]
|
49
|
-
def renderables
|
50
|
-
[
|
51
|
-
Vedeu::Cells::Border,
|
52
|
-
Vedeu::Cells::BottomHorizontal,
|
53
|
-
Vedeu::Cells::BottomLeft,
|
54
|
-
Vedeu::Cells::BottomRight,
|
55
|
-
Vedeu::Cells::Corner,
|
56
|
-
Vedeu::Cells::Char,
|
57
|
-
Vedeu::Cells::Clear,
|
58
|
-
Vedeu::Cells::Empty,
|
59
|
-
Vedeu::Cells::Horizontal,
|
60
|
-
Vedeu::Cells::LeftVertical,
|
61
|
-
Vedeu::Cells::RightVertical,
|
62
|
-
Vedeu::Cells::TopHorizontal,
|
63
|
-
Vedeu::Cells::TopLeft,
|
64
|
-
Vedeu::Cells::TopRight,
|
65
|
-
Vedeu::Cells::Vertical,
|
66
|
-
]
|
67
|
-
end
|
68
|
-
|
69
|
-
# @return [Boolean]
|
70
|
-
def renderable?(char)
|
71
|
-
renderables.include?(char.class)
|
72
|
-
end
|
73
|
-
|
74
|
-
# @return [Boolean]
|
75
|
-
def textual?(char)
|
76
|
-
char.respond_to?(:text)
|
77
|
-
end
|
78
|
-
|
79
46
|
end # Text
|
80
47
|
|
81
48
|
end # Renderers
|
@@ -5,7 +5,8 @@ module Vedeu
|
|
5
5
|
module Repositories
|
6
6
|
|
7
7
|
# Convert an Array into an object which has some meaning in the
|
8
|
-
# context it is being used.
|
8
|
+
# context it is being used. Various classes throughout Vedeu
|
9
|
+
# subclass this class.
|
9
10
|
#
|
10
11
|
# @api private
|
11
12
|
#
|
@@ -60,10 +61,10 @@ module Vedeu
|
|
60
61
|
# @return [Vedeu::Repositories::Collection]
|
61
62
|
def add(other)
|
62
63
|
if other.is_a?(Vedeu::Repositories::Collection)
|
63
|
-
return
|
64
|
+
return klass.coerce(other, parent, name) if empty?
|
64
65
|
|
65
66
|
else
|
66
|
-
|
67
|
+
klass.new(@collection += Array(other), parent, name)
|
67
68
|
|
68
69
|
end
|
69
70
|
end
|
@@ -77,6 +78,15 @@ module Vedeu
|
|
77
78
|
end
|
78
79
|
alias to_str to_s
|
79
80
|
|
81
|
+
private
|
82
|
+
|
83
|
+
# Return the inheriting class.
|
84
|
+
#
|
85
|
+
# @return [void]
|
86
|
+
def klass
|
87
|
+
self.class
|
88
|
+
end
|
89
|
+
|
80
90
|
end # Collection
|
81
91
|
|
82
92
|
end # Repositories
|
data/lib/vedeu/version.rb
CHANGED
data/lib/vedeu/views/view.rb
CHANGED
@@ -125,14 +125,10 @@ module Vedeu
|
|
125
125
|
# @macro raise_missing_required
|
126
126
|
# @return [Vedeu::Views::View]
|
127
127
|
def update_buffer(refresh = false)
|
128
|
-
|
129
|
-
|
128
|
+
raise Vedeu::Error::MissingRequired,
|
129
|
+
'Cannot store a view without a name.' unless present?(name)
|
130
130
|
|
131
|
-
|
132
|
-
raise Vedeu::Error::MissingRequired,
|
133
|
-
'Cannot store a view without a name.'
|
134
|
-
|
135
|
-
end
|
131
|
+
buffer.add(self, refresh)
|
136
132
|
|
137
133
|
self
|
138
134
|
end
|
@@ -58,6 +58,12 @@ module Vedeu
|
|
58
58
|
it { subject.must_equal("\e[?25h") }
|
59
59
|
end
|
60
60
|
|
61
|
+
describe '#to_ast' do
|
62
|
+
subject { instance.to_ast }
|
63
|
+
|
64
|
+
it { subject.must_equal('') }
|
65
|
+
end
|
66
|
+
|
61
67
|
describe '#to_h' do
|
62
68
|
let(:expected) {
|
63
69
|
{
|
@@ -96,6 +102,12 @@ module Vedeu
|
|
96
102
|
it { instance.must_respond_to(:to_str) }
|
97
103
|
end
|
98
104
|
|
105
|
+
describe '#text' do
|
106
|
+
subject { instance.text }
|
107
|
+
|
108
|
+
it { subject.must_equal('') }
|
109
|
+
end
|
110
|
+
|
99
111
|
describe '#type' do
|
100
112
|
subject { instance.type }
|
101
113
|
|
@@ -55,7 +55,13 @@ module Vedeu
|
|
55
55
|
|
56
56
|
subject { described.render(view) }
|
57
57
|
|
58
|
-
context 'when the
|
58
|
+
context 'when the view is empty or nil' do
|
59
|
+
let(:view) {}
|
60
|
+
|
61
|
+
it { subject.must_equal(nil) }
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'when the view is visible' do
|
59
65
|
context 'and Vedeu is ready' do
|
60
66
|
it do
|
61
67
|
Vedeu.expects(:render_output)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vedeu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Laking
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|