vedeu 0.4.24 → 0.4.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/examples/material_colours_app.rb +27 -11
- data/lib/vedeu/bindings.rb +22 -64
- data/lib/vedeu/cursor/cursor.rb +13 -9
- data/lib/vedeu/cursor/move.rb +68 -38
- data/lib/vedeu/debug.rb +5 -5
- data/lib/vedeu/distributed/uri.rb +1 -0
- data/lib/vedeu/geometry/geometry.rb +0 -22
- data/lib/vedeu/geometry/position.rb +1 -0
- data/lib/vedeu/models/all.rb +1 -0
- data/lib/vedeu/models/char.rb +7 -1
- data/lib/vedeu/models/escape_char.rb +49 -0
- data/lib/vedeu/output/border.rb +9 -8
- data/lib/vedeu/output/clear.rb +3 -1
- data/lib/vedeu/output/colour.rb +1 -0
- data/lib/vedeu/output/compressor.rb +6 -12
- data/lib/vedeu/output/presentation.rb +13 -6
- data/lib/vedeu/output/style.rb +1 -0
- data/lib/vedeu/output/translator.rb +1 -0
- data/lib/vedeu/output/viewport.rb +2 -1
- data/lib/vedeu/repositories/collection.rb +1 -0
- data/lib/vedeu/support/terminal.rb +6 -12
- data/test/lib/vedeu/cursor/cursor_test.rb +4 -4
- data/test/lib/vedeu/geometry/geometry_test.rb +0 -9
- data/test/lib/vedeu/models/escape_char_test.rb +56 -0
- data/test/lib/vedeu/output/compressor_test.rb +2 -8
- data/vedeu.gemspec +1 -1
- metadata +5 -5
- data/examples/cursor_app.rb +0 -126
- data/examples/lines_app.rb +0 -71
- data/examples/maximise_unmaximise_app.rb +0 -120
data/lib/vedeu/debug.rb
CHANGED
|
@@ -12,9 +12,9 @@ module Vedeu
|
|
|
12
12
|
|
|
13
13
|
require 'ruby-prof'
|
|
14
14
|
|
|
15
|
-
RubyProf.measure_mode = RubyProf::WALL_TIME
|
|
15
|
+
# RubyProf.measure_mode = RubyProf::WALL_TIME
|
|
16
16
|
# RubyProf.measure_mode = RubyProf::PROCESS_TIME
|
|
17
|
-
|
|
17
|
+
RubyProf.measure_mode = RubyProf::CPU_TIME
|
|
18
18
|
# RubyProf.measure_mode = RubyProf::ALLOCATIONS
|
|
19
19
|
# RubyProf.measure_mode = RubyProf::MEMORY
|
|
20
20
|
# RubyProf.measure_mode = RubyProf::GC_TIME
|
|
@@ -28,9 +28,12 @@ module Vedeu
|
|
|
28
28
|
result.eliminate_methods!([
|
|
29
29
|
/^Array/,
|
|
30
30
|
/^Hash/,
|
|
31
|
+
/^String/,
|
|
32
|
+
/^Fixnum/,
|
|
31
33
|
])
|
|
32
34
|
|
|
33
35
|
File.open('/tmp/' + filename, 'w') do |file|
|
|
36
|
+
# - Creates a HTML visualization of the Ruby stack
|
|
34
37
|
RubyProf::CallStackPrinter.new(result).print(file)
|
|
35
38
|
|
|
36
39
|
# Used with QTCacheGrind to analyse performance.
|
|
@@ -55,9 +58,6 @@ module Vedeu
|
|
|
55
58
|
# - Creates a call tree report compatible with KCachegrind.
|
|
56
59
|
# RubyProf::CallTreePrinter
|
|
57
60
|
|
|
58
|
-
# - Creates a HTML visualization of the Ruby stack
|
|
59
|
-
# RubyProf::CallStackPrinter
|
|
60
|
-
|
|
61
61
|
# - Uses the other printers to create several reports in one profiling run
|
|
62
62
|
# RubyProf::MultiPrinter
|
|
63
63
|
end
|
|
@@ -142,28 +142,6 @@ module Vedeu
|
|
|
142
142
|
work
|
|
143
143
|
end
|
|
144
144
|
|
|
145
|
-
# @param dy [Fixnum]
|
|
146
|
-
# @param dx [Fixnum]
|
|
147
|
-
# @return [Vedeu::Geometry]
|
|
148
|
-
def move(dy = 0, dx = 0)
|
|
149
|
-
new_attrs = {
|
|
150
|
-
centred: false,
|
|
151
|
-
maximised: false,
|
|
152
|
-
name: name,
|
|
153
|
-
x: (area.x + dx),
|
|
154
|
-
y: (area.y + dy),
|
|
155
|
-
xn: (area.xn + dx),
|
|
156
|
-
yn: (area.yn + dy),
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
work = Vedeu::Geometry.new(new_attrs).store
|
|
160
|
-
|
|
161
|
-
Vedeu.trigger(:_clear_)
|
|
162
|
-
Vedeu.trigger(:_refresh_, name)
|
|
163
|
-
|
|
164
|
-
work
|
|
165
|
-
end
|
|
166
|
-
|
|
167
145
|
private
|
|
168
146
|
|
|
169
147
|
# @return [Vedeu::Area]
|
data/lib/vedeu/models/all.rb
CHANGED
data/lib/vedeu/models/char.rb
CHANGED
|
@@ -84,7 +84,13 @@ module Vedeu
|
|
|
84
84
|
# @param value [Vedeu::Position]
|
|
85
85
|
# @return [Vedeu::Position]
|
|
86
86
|
def position=(value)
|
|
87
|
-
|
|
87
|
+
if value.is_a?(Vedeu::Position)
|
|
88
|
+
@position = @attributes[:position] = value
|
|
89
|
+
|
|
90
|
+
else
|
|
91
|
+
@position = @attributes[:position] = Vedeu::Position.coerce(value)
|
|
92
|
+
|
|
93
|
+
end
|
|
88
94
|
end
|
|
89
95
|
|
|
90
96
|
# @return [String]
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module Vedeu
|
|
2
|
+
|
|
3
|
+
class EscapeChar
|
|
4
|
+
|
|
5
|
+
# @param value [String]
|
|
6
|
+
# @return [Vedeu::EscapeChar]
|
|
7
|
+
def initialize(value)
|
|
8
|
+
@value = value
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# @return [String]
|
|
12
|
+
def colour
|
|
13
|
+
''
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# An object is equal when its values are the same.
|
|
17
|
+
#
|
|
18
|
+
# @param other [Vedeu::Char]
|
|
19
|
+
# @return [Boolean]
|
|
20
|
+
def eql?(other)
|
|
21
|
+
self.class == other.class && value == other.value
|
|
22
|
+
end
|
|
23
|
+
alias_method :==, :eql?
|
|
24
|
+
|
|
25
|
+
# @return [String]
|
|
26
|
+
def inspect
|
|
27
|
+
"<Vedeu::EscapeChar '#{Vedeu::Esc.escape(to_s)}'>"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# @return [String]
|
|
31
|
+
def position
|
|
32
|
+
''
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# @return [String]
|
|
36
|
+
def style
|
|
37
|
+
''
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# @return [String]
|
|
41
|
+
def value
|
|
42
|
+
@value
|
|
43
|
+
end
|
|
44
|
+
alias_method :to_s, :value
|
|
45
|
+
alias_method :to_str, :value
|
|
46
|
+
|
|
47
|
+
end # EscapeChar
|
|
48
|
+
|
|
49
|
+
end # Vedeu
|
data/lib/vedeu/output/border.rb
CHANGED
|
@@ -174,6 +174,7 @@ module Vedeu
|
|
|
174
174
|
def to_s
|
|
175
175
|
Vedeu::Renderers::Text.render(render)
|
|
176
176
|
end
|
|
177
|
+
alias_method :to_str, :to_s
|
|
177
178
|
|
|
178
179
|
# Renders the bottom border for the interface.
|
|
179
180
|
#
|
|
@@ -361,14 +362,14 @@ module Vedeu
|
|
|
361
362
|
# @return [Vedeu::Position]
|
|
362
363
|
def position(name, iy = 0, ix = 0)
|
|
363
364
|
case name
|
|
364
|
-
when :top_horizontal then [y, (bx + ix)]
|
|
365
|
-
when :bottom_horizontal then [yn, (bx + ix)]
|
|
366
|
-
when :left_vertical then [(by + iy), x]
|
|
367
|
-
when :right_vertical then [(by + iy), xn]
|
|
368
|
-
when :bottom_left then [yn, x]
|
|
369
|
-
when :bottom_right then [yn, xn]
|
|
370
|
-
when :top_left then [y, x]
|
|
371
|
-
when :top_right then [y, xn]
|
|
365
|
+
when :top_horizontal then Vedeu::Position.coerce([y, (bx + ix)])
|
|
366
|
+
when :bottom_horizontal then Vedeu::Position.coerce([yn, (bx + ix)])
|
|
367
|
+
when :left_vertical then Vedeu::Position.coerce([(by + iy), x])
|
|
368
|
+
when :right_vertical then Vedeu::Position.coerce([(by + iy), xn])
|
|
369
|
+
when :bottom_left then Vedeu::Position.coerce([yn, x])
|
|
370
|
+
when :bottom_right then Vedeu::Position.coerce([yn, xn])
|
|
371
|
+
when :top_left then Vedeu::Position.coerce([y, x])
|
|
372
|
+
when :top_right then Vedeu::Position.coerce([y, xn])
|
|
372
373
|
end
|
|
373
374
|
end
|
|
374
375
|
|
data/lib/vedeu/output/clear.rb
CHANGED
|
@@ -59,12 +59,14 @@ module Vedeu
|
|
|
59
59
|
def clear
|
|
60
60
|
if visible?
|
|
61
61
|
Vedeu::Timer.for(:debug, "Clearing: #{name}") do
|
|
62
|
+
y, x = *position
|
|
63
|
+
|
|
62
64
|
@clear ||= Array.new(height) do |iy|
|
|
63
65
|
Array.new(width) do |ix|
|
|
64
66
|
Vedeu::Char.new(value: ' ',
|
|
65
67
|
colour: clear_colour,
|
|
66
68
|
style: style,
|
|
67
|
-
position:
|
|
69
|
+
position: [y + iy, x + ix])
|
|
68
70
|
end
|
|
69
71
|
end
|
|
70
72
|
end
|
data/lib/vedeu/output/colour.rb
CHANGED
|
@@ -17,18 +17,12 @@ module Vedeu
|
|
|
17
17
|
# @return [String]
|
|
18
18
|
def render
|
|
19
19
|
Array(output).flatten.map do |char|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
out
|
|
27
|
-
|
|
28
|
-
else
|
|
29
|
-
char.to_s
|
|
30
|
-
|
|
31
|
-
end
|
|
20
|
+
out = ''
|
|
21
|
+
out << char.position.to_s
|
|
22
|
+
out << colour_for(char)
|
|
23
|
+
out << style_for(char)
|
|
24
|
+
out << char.value
|
|
25
|
+
out
|
|
32
26
|
end.join
|
|
33
27
|
end
|
|
34
28
|
|
|
@@ -7,7 +7,7 @@ module Vedeu
|
|
|
7
7
|
|
|
8
8
|
# @return [Vedeu::Background]
|
|
9
9
|
def background
|
|
10
|
-
if colour
|
|
10
|
+
@background ||= if colour
|
|
11
11
|
colour.background
|
|
12
12
|
|
|
13
13
|
else
|
|
@@ -20,7 +20,7 @@ module Vedeu
|
|
|
20
20
|
# @return [Vedeu::Background]
|
|
21
21
|
def background=(value)
|
|
22
22
|
attributes[:background] = value
|
|
23
|
-
colour.background = value
|
|
23
|
+
@background = colour.background = Vedeu::Background.coerce(value)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
# @return [Vedeu::Colour]
|
|
@@ -36,7 +36,7 @@ module Vedeu
|
|
|
36
36
|
|
|
37
37
|
# @return [Vedeu::Foreground]
|
|
38
38
|
def foreground
|
|
39
|
-
if colour
|
|
39
|
+
@foreground ||= if colour
|
|
40
40
|
colour.foreground
|
|
41
41
|
|
|
42
42
|
else
|
|
@@ -49,7 +49,7 @@ module Vedeu
|
|
|
49
49
|
# @return [Vedeu::Foreground]
|
|
50
50
|
def foreground=(value)
|
|
51
51
|
attributes[:foreground] = value
|
|
52
|
-
colour.foreground = value
|
|
52
|
+
@foreground = colour.foreground = Vedeu::Foreground.coerce(value)
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
# @return [Vedeu::Background]
|
|
@@ -98,10 +98,17 @@ module Vedeu
|
|
|
98
98
|
# model has previously set the colour and style, reverts back to that for
|
|
99
99
|
# consistent formatting.
|
|
100
100
|
#
|
|
101
|
+
# @note
|
|
102
|
+
# Aliasing #to_str to #to_s seems to reduce rendering time by around ~20ms
|
|
103
|
+
# for normal sized (80x25) terminals.
|
|
104
|
+
# @todo
|
|
105
|
+
# Must investigate. (GL 2015-06-05)
|
|
106
|
+
#
|
|
101
107
|
# @return [String] An escape sequence with value interpolated.
|
|
102
108
|
def to_s
|
|
103
109
|
render_position { render_colour { render_style { value } } }
|
|
104
110
|
end
|
|
111
|
+
alias_method :to_str, :to_s
|
|
105
112
|
|
|
106
113
|
private
|
|
107
114
|
|
|
@@ -110,7 +117,7 @@ module Vedeu
|
|
|
110
117
|
if attributes[:colour]
|
|
111
118
|
attributes[:colour]
|
|
112
119
|
|
|
113
|
-
elsif parent_colour
|
|
120
|
+
elsif parent && parent_colour
|
|
114
121
|
parent_colour
|
|
115
122
|
|
|
116
123
|
end
|
|
@@ -148,7 +155,7 @@ module Vedeu
|
|
|
148
155
|
if attributes[:style]
|
|
149
156
|
attributes[:style]
|
|
150
157
|
|
|
151
|
-
elsif parent_style
|
|
158
|
+
elsif parent && parent_style
|
|
152
159
|
parent_style
|
|
153
160
|
|
|
154
161
|
end
|
data/lib/vedeu/output/style.rb
CHANGED
|
@@ -56,7 +56,7 @@ module Vedeu
|
|
|
56
56
|
out = []
|
|
57
57
|
show[0...height].each_with_index do |line, iy|
|
|
58
58
|
line[0...width].each_with_index do |column, ix|
|
|
59
|
-
column.position =
|
|
59
|
+
column.position = [by + iy, bx + ix]
|
|
60
60
|
out << column
|
|
61
61
|
end
|
|
62
62
|
end
|
|
@@ -70,6 +70,7 @@ module Vedeu
|
|
|
70
70
|
def to_s
|
|
71
71
|
render.map(&:to_s).join("\n")
|
|
72
72
|
end
|
|
73
|
+
alias_method :to_str, :to_s
|
|
73
74
|
|
|
74
75
|
protected
|
|
75
76
|
|
|
@@ -101,6 +101,8 @@ module Vedeu
|
|
|
101
101
|
#
|
|
102
102
|
# @return [String]
|
|
103
103
|
def clear
|
|
104
|
+
virtual.clear if Vedeu::Configuration.drb?
|
|
105
|
+
|
|
104
106
|
output(Esc.string('clear'))
|
|
105
107
|
end
|
|
106
108
|
|
|
@@ -217,13 +219,9 @@ module Vedeu
|
|
|
217
219
|
#
|
|
218
220
|
# @return [Fixnum]
|
|
219
221
|
def width
|
|
220
|
-
if Vedeu::Configuration.drb?
|
|
221
|
-
Vedeu::Configuration.drb_width
|
|
222
|
-
|
|
223
|
-
else
|
|
224
|
-
size.last
|
|
222
|
+
return Vedeu::Configuration.drb_width if Vedeu::Configuration.drb?
|
|
225
223
|
|
|
226
|
-
|
|
224
|
+
size.last
|
|
227
225
|
end
|
|
228
226
|
alias_method :xn, :width
|
|
229
227
|
alias_method :txn, :width
|
|
@@ -235,13 +233,9 @@ module Vedeu
|
|
|
235
233
|
#
|
|
236
234
|
# @return [Fixnum]
|
|
237
235
|
def height
|
|
238
|
-
if Vedeu::Configuration.drb?
|
|
239
|
-
Vedeu::Configuration.drb_height
|
|
236
|
+
return Vedeu::Configuration.drb_height if Vedeu::Configuration.drb?
|
|
240
237
|
|
|
241
|
-
|
|
242
|
-
size.first
|
|
243
|
-
|
|
244
|
-
end
|
|
238
|
+
size.first
|
|
245
239
|
end
|
|
246
240
|
alias_method :yn, :height
|
|
247
241
|
alias_method :tyn, :height
|
|
@@ -42,8 +42,8 @@ module Vedeu
|
|
|
42
42
|
describe '#hide_cursor' do
|
|
43
43
|
subject { instance.hide_cursor }
|
|
44
44
|
|
|
45
|
-
it { subject.must_be_instance_of(
|
|
46
|
-
it { subject.must_equal("\e[?25l") }
|
|
45
|
+
it { subject.must_be_instance_of(Vedeu::EscapeChar) }
|
|
46
|
+
it { subject.to_s.must_equal("\e[?25l") }
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
describe '#inspect' do
|
|
@@ -58,8 +58,8 @@ module Vedeu
|
|
|
58
58
|
describe '#show_cursor' do
|
|
59
59
|
subject { instance.show_cursor }
|
|
60
60
|
|
|
61
|
-
it { subject.must_be_instance_of(
|
|
62
|
-
it { subject.must_equal("\e[?25h") }
|
|
61
|
+
it { subject.must_be_instance_of(Vedeu::EscapeChar) }
|
|
62
|
+
it { subject.to_s.must_equal("\e[?25h") }
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
describe '#to_s' do
|
|
@@ -96,15 +96,6 @@ module Vedeu
|
|
|
96
96
|
it { subject.maximised.must_equal(false) }
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
-
describe '#move' do
|
|
100
|
-
let(:dy) {}
|
|
101
|
-
let(:dx) {}
|
|
102
|
-
|
|
103
|
-
subject { instance.move(dy, dx) }
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
end
|
|
107
|
-
|
|
108
99
|
describe '#top, #right, #bottom, #left' do
|
|
109
100
|
context 'maximised is true' do
|
|
110
101
|
let(:attributes) { { maximised: true } }
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
module Vedeu
|
|
4
|
+
|
|
5
|
+
describe EscapeChar do
|
|
6
|
+
|
|
7
|
+
let(:described) { Vedeu::EscapeChar }
|
|
8
|
+
let(:instance) { described.new(_value) }
|
|
9
|
+
let(:_value) { "\e[?25h" }
|
|
10
|
+
|
|
11
|
+
describe '#initialize' do
|
|
12
|
+
it { instance.must_be_instance_of(described) }
|
|
13
|
+
it { instance.instance_variable_get('@value').must_equal(_value) }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe '#colour' do
|
|
17
|
+
it { instance.colour.must_equal('') }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe '#eql?' do
|
|
21
|
+
let(:other) { instance }
|
|
22
|
+
|
|
23
|
+
subject { instance.eql?(other) }
|
|
24
|
+
|
|
25
|
+
it { subject.must_equal(true) }
|
|
26
|
+
|
|
27
|
+
context 'when different to other' do
|
|
28
|
+
let(:other) { described.new(value: 'b') }
|
|
29
|
+
|
|
30
|
+
it { subject.must_equal(false) }
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe '#inspect' do
|
|
35
|
+
it { instance.inspect.must_equal(
|
|
36
|
+
"<Vedeu::EscapeChar '" \
|
|
37
|
+
"\\e[?25h" \
|
|
38
|
+
"'>"
|
|
39
|
+
) }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe '#position' do
|
|
43
|
+
it { instance.position.must_equal('') }
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe '#style' do
|
|
47
|
+
it { instance.style.must_equal('') }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe '#to_s' do
|
|
51
|
+
it { instance.to_s.must_be_instance_of(String) }
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end # EscapeChar
|
|
55
|
+
|
|
56
|
+
end # Vedeu
|