vedeu 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vedeu.rb +1 -0
- data/lib/vedeu/api/events.rb +1 -0
- data/lib/vedeu/api/interface.rb +17 -1
- data/lib/vedeu/api/view.rb +2 -2
- data/lib/vedeu/models/attributes/interface_collection.rb +1 -0
- data/lib/vedeu/models/composition.rb +4 -3
- data/lib/vedeu/models/interface.rb +0 -51
- data/lib/vedeu/output/buffers.rb +51 -0
- data/lib/vedeu/output/render.rb +25 -14
- data/test/lib/vedeu/models/attributes/interface_collection_test.rb +1 -1
- data/test/lib/vedeu/models/composition_test.rb +6 -5
- data/test/lib/vedeu/models/interface_test.rb +0 -119
- data/test/lib/vedeu/output/buffers_test.rb +128 -0
- data/test/lib/vedeu/support/input_test.rb +3 -1
- data/vedeu.gemspec +1 -1
- metadata +5 -21
- data/deps.md +0 -191
- data/test/support/dummy_interface.rb +0 -5
- data/test/support/erb/colour.erb +0 -3
- data/test/support/erb/colour_style.erb +0 -1
- data/test/support/erb/line.erb +0 -4
- data/test/support/erb/line_2x.erb +0 -10
- data/test/support/erb/line_foreground.erb +0 -4
- data/test/support/erb/line_foreground_2x.erb +0 -5
- data/test/support/erb/style.erb +0 -3
- data/test/support/template.erb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e5e01aa9e53954f48c2dec1ab53d3cbf2bdbe9f
|
4
|
+
data.tar.gz: 3ee412af2d4751e6e7cf7def63f59b049283fc89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce32b74810f69dcbf687a527f2399d05f908095113a9fda6d213c49ddc9d0ef372f3dc70d78e1cf4aa8658330c3d6a8ad73042c94308ecc4c338200f23c9070a
|
7
|
+
data.tar.gz: 853a70f364f8876adec5284120a18f4ddc85027db12decf0b3a8d2a17a4dd621076f73c68e73958a89551357ac6c10a2528f2f6b119a1d6de884575599f53e65
|
data/lib/vedeu.rb
CHANGED
data/lib/vedeu/api/events.rb
CHANGED
data/lib/vedeu/api/interface.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'vedeu/models/geometry'
|
2
|
+
require 'vedeu/models/composition'
|
2
3
|
require 'vedeu/api/grid'
|
3
4
|
require 'vedeu/api/store'
|
4
5
|
require 'vedeu/support/terminal'
|
@@ -27,8 +28,23 @@ module Vedeu
|
|
27
28
|
self.instance_eval(&block) if block_given?
|
28
29
|
|
29
30
|
stored_attributes = Store.create(attributes)
|
31
|
+
interface = Vedeu::Interface.new(stored_attributes)
|
30
32
|
|
31
|
-
Vedeu::
|
33
|
+
Vedeu::Buffers.create(interface.name, interface.clear)
|
34
|
+
|
35
|
+
Vedeu.events.on("_refresh_#{interface.name}_".to_sym, interface.delay) do
|
36
|
+
Vedeu::Buffers.refresh(interface.name)
|
37
|
+
end
|
38
|
+
|
39
|
+
# TODO:
|
40
|
+
# cannot do group at this time
|
41
|
+
# unless interface.group.nil? || interface.group.empty?
|
42
|
+
# Vedeu.events.on("_refresh_group_#{interface.group}_".to_sym, interface.delay) do
|
43
|
+
# buffer.refresh_group(interface.group)
|
44
|
+
# end
|
45
|
+
# end
|
46
|
+
|
47
|
+
interface
|
32
48
|
end
|
33
49
|
|
34
50
|
private
|
data/lib/vedeu/api/view.rb
CHANGED
@@ -19,7 +19,7 @@ module Vedeu
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def initialize(name = '')
|
22
|
-
fail
|
22
|
+
fail InterfaceNotSpecified if name.nil? || name.empty?
|
23
23
|
|
24
24
|
@name = name.to_s
|
25
25
|
end
|
@@ -33,7 +33,7 @@ module Vedeu
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def line(&block)
|
36
|
-
attributes[:lines] <<
|
36
|
+
attributes[:lines] << Line.build(&block)
|
37
37
|
end
|
38
38
|
|
39
39
|
def attributes
|
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'virtus'
|
2
2
|
|
3
3
|
require 'vedeu/models/attributes/interface_collection'
|
4
|
-
|
5
|
-
# Todo: mutation (interfaces)
|
4
|
+
require 'vedeu/output/buffers'
|
6
5
|
|
7
6
|
module Vedeu
|
8
7
|
class Composition
|
@@ -15,7 +14,9 @@ module Vedeu
|
|
15
14
|
end
|
16
15
|
|
17
16
|
def enqueue
|
18
|
-
interfaces.map
|
17
|
+
interfaces.map do |interface|
|
18
|
+
Buffers.enqueue(interface.name, interface.to_s)
|
19
|
+
end
|
19
20
|
end
|
20
21
|
|
21
22
|
def to_s
|
@@ -1,16 +1,12 @@
|
|
1
1
|
require 'forwardable'
|
2
2
|
require 'virtus'
|
3
3
|
|
4
|
-
require 'vedeu'
|
5
4
|
require 'vedeu/models/attributes/line_collection'
|
6
5
|
require 'vedeu/models/colour'
|
7
6
|
require 'vedeu/models/style'
|
8
7
|
require 'vedeu/output/clear'
|
9
8
|
require 'vedeu/output/render'
|
10
9
|
require 'vedeu/models/geometry'
|
11
|
-
require 'vedeu/support/terminal'
|
12
|
-
|
13
|
-
# Todo: mutation (events, current)
|
14
10
|
|
15
11
|
module Vedeu
|
16
12
|
class Interface
|
@@ -23,66 +19,19 @@ module Vedeu
|
|
23
19
|
attribute :colour, Colour, default: Colour.new
|
24
20
|
attribute :style, Style, default: ''
|
25
21
|
attribute :geometry, Geometry, default: Geometry.new
|
26
|
-
attribute :current, String, default: ''
|
27
22
|
attribute :cursor, Boolean, default: true
|
28
23
|
attribute :delay, Float, default: 0
|
29
|
-
attribute :buffer, Array, default: []
|
30
24
|
|
31
25
|
def_delegators :@geometry, :north, :east, :south, :west,
|
32
26
|
:top, :right, :bottom, :left,
|
33
27
|
:width, :height, :origin
|
34
28
|
|
35
|
-
def initialize(attributes = {})
|
36
|
-
super
|
37
|
-
|
38
|
-
Vedeu.events.on(:_refresh_, self.delay) { refresh }
|
39
|
-
Vedeu.events.on("_refresh_#{name}_".to_sym, self.delay) { refresh }
|
40
|
-
|
41
|
-
unless group.nil? || group.empty?
|
42
|
-
Vedeu.events.on("_refresh_group_#{group}_".to_sym, self.delay) do
|
43
|
-
refresh
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
self
|
48
|
-
end
|
49
|
-
|
50
29
|
def clear
|
51
30
|
@_clear ||= Clear.call(self)
|
52
31
|
end
|
53
32
|
|
54
|
-
def dequeue
|
55
|
-
buffer.pop
|
56
|
-
end
|
57
|
-
|
58
|
-
def enqueue
|
59
|
-
buffer.unshift(self.to_s)
|
60
|
-
end
|
61
|
-
|
62
|
-
def refresh
|
63
|
-
if buffer.any?
|
64
|
-
self.current = buffer.pop
|
65
|
-
|
66
|
-
elsif no_content?
|
67
|
-
self.current = clear
|
68
|
-
|
69
|
-
else
|
70
|
-
self.current
|
71
|
-
|
72
|
-
end
|
73
|
-
Terminal.output(self.current)
|
74
|
-
|
75
|
-
self.current
|
76
|
-
end
|
77
|
-
|
78
33
|
def to_s
|
79
34
|
Render.call(self)
|
80
35
|
end
|
81
|
-
|
82
|
-
private
|
83
|
-
|
84
|
-
def no_content?
|
85
|
-
self.current.nil? || self.current.empty?
|
86
|
-
end
|
87
36
|
end
|
88
37
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'vedeu/support/terminal'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
RefreshFailed = Class.new(StandardError)
|
5
|
+
|
6
|
+
module Buffers
|
7
|
+
extend self
|
8
|
+
|
9
|
+
def create(name, sequence)
|
10
|
+
buffers[name][:clear] = sequence
|
11
|
+
end
|
12
|
+
|
13
|
+
def enqueue(name, sequence)
|
14
|
+
buffers[name][:next].unshift(sequence)
|
15
|
+
end
|
16
|
+
|
17
|
+
def refresh(name)
|
18
|
+
data = buffers.fetch(name) do
|
19
|
+
fail RefreshFailed, 'Cannot refresh non-existent interface.'
|
20
|
+
end
|
21
|
+
|
22
|
+
sequence = if data[:next].any?
|
23
|
+
data[:current] = data[:next].pop
|
24
|
+
|
25
|
+
elsif data[:current].empty?
|
26
|
+
data[:clear]
|
27
|
+
|
28
|
+
else
|
29
|
+
data[:current]
|
30
|
+
|
31
|
+
end
|
32
|
+
Terminal.output(sequence)
|
33
|
+
end
|
34
|
+
|
35
|
+
def refresh_all
|
36
|
+
buffers.keys.map { |name| refresh(name) }
|
37
|
+
end
|
38
|
+
|
39
|
+
def reset
|
40
|
+
@buffers = {}
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def buffers
|
46
|
+
@buffers ||= Hash.new do |hash, key|
|
47
|
+
hash[key] = { current: '', next: [], clear: '' }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/vedeu/output/render.rb
CHANGED
@@ -26,33 +26,44 @@ module Vedeu
|
|
26
26
|
|
27
27
|
attr_reader :interface
|
28
28
|
|
29
|
+
# The client application may have created a line that us too long for the
|
30
|
+
# interface. This code tries to truncate streams whilst preserving styles
|
31
|
+
# and colours.
|
29
32
|
def processed_lines
|
30
33
|
return [] unless lines.any? { |line| line.streams.any? }
|
31
34
|
|
32
35
|
lines.map do |line|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
+
if exceeds_width?(line)
|
37
|
+
line_length = 0
|
38
|
+
processed = []
|
39
|
+
line.streams.each do |stream|
|
40
|
+
next if stream.text.empty?
|
36
41
|
|
37
|
-
|
38
|
-
|
42
|
+
if (line_length += stream.text.size) >= width
|
43
|
+
remainder = width - line_length
|
39
44
|
|
40
|
-
|
41
|
-
|
42
|
-
|
45
|
+
processed << Stream.new(text: truncate(stream.text, remainder),
|
46
|
+
style: stream.style,
|
47
|
+
colour: stream.colour)
|
43
48
|
|
44
|
-
|
45
|
-
|
49
|
+
else
|
50
|
+
processed << stream
|
46
51
|
|
52
|
+
end
|
47
53
|
end
|
48
|
-
end
|
49
54
|
|
50
|
-
|
51
|
-
|
52
|
-
|
55
|
+
Line.new(streams: processed, style: line.style, colour: line.colour)
|
56
|
+
else
|
57
|
+
line
|
58
|
+
end
|
53
59
|
end
|
54
60
|
end
|
55
61
|
|
62
|
+
def exceeds_width?(line)
|
63
|
+
content = line.streams.map(&:text).join
|
64
|
+
content.size > width
|
65
|
+
end
|
66
|
+
|
56
67
|
def truncate(text, value)
|
57
68
|
text.chomp.slice(0...value)
|
58
69
|
end
|
@@ -4,6 +4,7 @@ require 'json'
|
|
4
4
|
|
5
5
|
require 'vedeu/models/composition'
|
6
6
|
require 'vedeu/api/store'
|
7
|
+
require 'vedeu'
|
7
8
|
|
8
9
|
module Vedeu
|
9
10
|
describe Composition do
|
@@ -116,7 +117,7 @@ module Vedeu
|
|
116
117
|
"\e[3;3H \e[3;3H" \
|
117
118
|
"\e[4;3H \e[4;3H" \
|
118
119
|
"\e[5;3H \e[5;3H" \
|
119
|
-
"\e[3;3H\e[38;5;16m\e[48;5;
|
120
|
+
"\e[3;3H\e[38;5;16m\e[48;5;21m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;5;226m\e[48;5;46m\e[24m\e[21m\e[27m \e[38;5;231m\e[48;5;201m\e[1mmore text..."
|
120
121
|
)
|
121
122
|
end
|
122
123
|
|
@@ -256,13 +257,13 @@ module Vedeu
|
|
256
257
|
"\e[3;3H \e[3;3H" \
|
257
258
|
"\e[4;3H \e[4;3H" \
|
258
259
|
"\e[5;3H \e[5;3H" \
|
259
|
-
"\e[3;3H\e[38;5;16m\e[48;5;
|
260
|
-
"\e[4;3H\e[38;5;16m\e[48;5;
|
260
|
+
"\e[3;3H\e[38;5;16m\e[48;5;21m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;5;226m\e[48;5;46m\e[24m\e[21m\e[27m \e[38;5;231m\e[48;5;201m\e[1mmore text..." \
|
261
|
+
"\e[4;3H\e[38;5;16m\e[48;5;21m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;5;226m\e[48;5;46m\e[24m\e[21m\e[27m \e[38;5;231m\e[48;5;201m\e[1mmore text..." \
|
261
262
|
"\e[6;6H \e[6;6H" \
|
262
263
|
"\e[7;6H \e[7;6H" \
|
263
264
|
"\e[8;6H \e[8;6H" \
|
264
|
-
"\e[6;6H\e[38;5;16m\e[48;5;
|
265
|
-
"\e[7;6H\e[38;5;16m\e[48;5;
|
265
|
+
"\e[6;6H\e[38;5;16m\e[48;5;21m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;5;226m\e[48;5;46m\e[24m\e[21m\e[27m \e[38;5;231m\e[48;5;201m\e[1mmore text..." \
|
266
|
+
"\e[7;6H\e[38;5;16m\e[48;5;21m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;5;226m\e[48;5;46m\e[24m\e[21m\e[27m \e[38;5;231m\e[48;5;201m\e[1mmore text..."
|
266
267
|
)
|
267
268
|
end
|
268
269
|
end
|
@@ -46,10 +46,6 @@ module Vedeu
|
|
46
46
|
interface.geometry.must_be_instance_of(Geometry)
|
47
47
|
end
|
48
48
|
|
49
|
-
it 'has a current attribute' do
|
50
|
-
interface.current.must_equal("\e[1;1H#initialize")
|
51
|
-
end
|
52
|
-
|
53
49
|
it 'has a cursor attribute' do
|
54
50
|
interface.cursor.must_equal(true)
|
55
51
|
Interface.new({ cursor: false }).cursor.must_equal(false)
|
@@ -59,121 +55,6 @@ module Vedeu
|
|
59
55
|
interface.delay.must_equal(0.0)
|
60
56
|
end
|
61
57
|
|
62
|
-
describe '#enqueue' do
|
63
|
-
it 'delegates to the Queue class to enqueue itself' do
|
64
|
-
interface = Interface.new({
|
65
|
-
name: 'Interface#enqueue',
|
66
|
-
geometry: {
|
67
|
-
width: 8,
|
68
|
-
height: 2,
|
69
|
-
},
|
70
|
-
lines: [ { streams: { text: 'a8f39' } } ]
|
71
|
-
})
|
72
|
-
interface.enqueue
|
73
|
-
interface.dequeue.must_equal(
|
74
|
-
"\e[1;1H \e[1;1H" \
|
75
|
-
"\e[2;1H \e[2;1H" \
|
76
|
-
"\e[1;1Ha8f39"
|
77
|
-
)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
describe '#refresh' do
|
82
|
-
let(:attributes) {
|
83
|
-
{
|
84
|
-
name: '#refresh',
|
85
|
-
lines: [],
|
86
|
-
colour: {
|
87
|
-
foreground: '#ff0000',
|
88
|
-
background: '#000000'
|
89
|
-
},
|
90
|
-
geometry: {
|
91
|
-
width: 3,
|
92
|
-
height: 3
|
93
|
-
}
|
94
|
-
}
|
95
|
-
}
|
96
|
-
|
97
|
-
it 'returns a blank interface when there is no content to display (initial state)' do
|
98
|
-
Terminal.stub(:output, nil) do
|
99
|
-
Interface.new(attributes).refresh.must_equal(
|
100
|
-
"\e[38;5;196m\e[48;5;16m" \
|
101
|
-
"\e[1;1H \e[1;1H" \
|
102
|
-
"\e[2;1H \e[2;1H" \
|
103
|
-
"\e[3;1H \e[3;1H"
|
104
|
-
)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
it 'returns the fresh content when content is queued up to be displayed' do
|
109
|
-
attributes = {
|
110
|
-
name: '#refresh',
|
111
|
-
lines: [
|
112
|
-
{ streams: [{ text: '#refresh' }] },
|
113
|
-
{ streams: [{ text: '#refresh' }] },
|
114
|
-
{ streams: [{ text: '#refresh' }] }
|
115
|
-
],
|
116
|
-
colour: {
|
117
|
-
foreground: '#ff0000',
|
118
|
-
background: '#000000'
|
119
|
-
},
|
120
|
-
geometry: {
|
121
|
-
width: 11,
|
122
|
-
height: 3
|
123
|
-
}
|
124
|
-
}
|
125
|
-
interface = Interface.new(attributes)
|
126
|
-
diode = interface.enqueue
|
127
|
-
|
128
|
-
Terminal.stub(:output, nil) do
|
129
|
-
interface.refresh.must_equal(
|
130
|
-
"\e[38;5;196m\e[48;5;16m" \
|
131
|
-
"\e[1;1H \e[1;1H" \
|
132
|
-
"\e[2;1H \e[2;1H" \
|
133
|
-
"\e[3;1H \e[3;1H" \
|
134
|
-
"\e[1;1H#refresh" \
|
135
|
-
"\e[2;1H#refresh" \
|
136
|
-
"\e[3;1H#refresh"
|
137
|
-
)
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
it 'returns the previously shown content when there is stale content from last run' do
|
142
|
-
attributes = {
|
143
|
-
name: '#refresh',
|
144
|
-
lines: [],
|
145
|
-
colour: {
|
146
|
-
foreground: '#ff0000',
|
147
|
-
background: '#000000'
|
148
|
-
},
|
149
|
-
geometry: {
|
150
|
-
width: 11,
|
151
|
-
height: 3
|
152
|
-
}
|
153
|
-
}
|
154
|
-
interface = Interface.new(attributes)
|
155
|
-
interface.current = "\e[38;5;196m\e[48;5;16m" \
|
156
|
-
"\e[1;1H \e[1;1H" \
|
157
|
-
"\e[2;1H \e[2;1H" \
|
158
|
-
"\e[3;1H \e[3;1H" \
|
159
|
-
"\e[1;1H#refresh" \
|
160
|
-
"\e[2;1H#refresh" \
|
161
|
-
"\e[3;1H#refresh"
|
162
|
-
|
163
|
-
Terminal.stub(:output, nil) do
|
164
|
-
interface.refresh.must_equal(
|
165
|
-
"\e[38;5;196m\e[48;5;16m" \
|
166
|
-
"\e[1;1H \e[1;1H" \
|
167
|
-
"\e[2;1H \e[2;1H" \
|
168
|
-
"\e[3;1H \e[3;1H" \
|
169
|
-
"\e[1;1H#refresh" \
|
170
|
-
"\e[2;1H#refresh" \
|
171
|
-
"\e[3;1H#refresh"
|
172
|
-
)
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
58
|
describe '#to_s' do
|
178
59
|
it 'returns an string' do
|
179
60
|
Interface.new({
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
require 'vedeu/output/buffers'
|
4
|
+
|
5
|
+
module Vedeu
|
6
|
+
describe Buffers do
|
7
|
+
describe '.create' do
|
8
|
+
it 'creates an entry for the interface, and saves :clear' do
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '.enqueue' do
|
13
|
+
it 'saves the new sequence for the interface into :next' do
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '.refresh' do
|
18
|
+
it 'raises an exception if the interface cannot be found by name' do
|
19
|
+
end
|
20
|
+
|
21
|
+
# describe '#refresh' do
|
22
|
+
# let(:attributes) {
|
23
|
+
# {
|
24
|
+
# name: '#refresh',
|
25
|
+
# lines: [],
|
26
|
+
# colour: {
|
27
|
+
# foreground: '#ff0000',
|
28
|
+
# background: '#000000'
|
29
|
+
# },
|
30
|
+
# geometry: {
|
31
|
+
# width: 3,
|
32
|
+
# height: 3
|
33
|
+
# }
|
34
|
+
# }
|
35
|
+
# }
|
36
|
+
|
37
|
+
# it 'returns a blank interface when there is no content to display (initial state)' do
|
38
|
+
# Terminal.stub(:output, nil) do
|
39
|
+
# Interface.new(attributes).refresh.must_equal(
|
40
|
+
# "\e[38;5;196m\e[48;5;16m" \
|
41
|
+
# "\e[1;1H \e[1;1H" \
|
42
|
+
# "\e[2;1H \e[2;1H" \
|
43
|
+
# "\e[3;1H \e[3;1H"
|
44
|
+
# )
|
45
|
+
# end
|
46
|
+
# end
|
47
|
+
|
48
|
+
# it 'returns the fresh content when content is queued up to be displayed' do
|
49
|
+
# attributes = {
|
50
|
+
# name: '#refresh',
|
51
|
+
# lines: [
|
52
|
+
# { streams: [{ text: '#refresh' }] },
|
53
|
+
# { streams: [{ text: '#refresh' }] },
|
54
|
+
# { streams: [{ text: '#refresh' }] }
|
55
|
+
# ],
|
56
|
+
# colour: {
|
57
|
+
# foreground: '#ff0000',
|
58
|
+
# background: '#000000'
|
59
|
+
# },
|
60
|
+
# geometry: {
|
61
|
+
# width: 11,
|
62
|
+
# height: 3
|
63
|
+
# }
|
64
|
+
# }
|
65
|
+
# interface = Interface.new(attributes)
|
66
|
+
# diode = interface.enqueue
|
67
|
+
|
68
|
+
# Terminal.stub(:output, nil) do
|
69
|
+
# interface.refresh.must_equal(
|
70
|
+
# "\e[38;5;196m\e[48;5;16m" \
|
71
|
+
# "\e[1;1H \e[1;1H" \
|
72
|
+
# "\e[2;1H \e[2;1H" \
|
73
|
+
# "\e[3;1H \e[3;1H" \
|
74
|
+
# "\e[1;1H#refresh" \
|
75
|
+
# "\e[2;1H#refresh" \
|
76
|
+
# "\e[3;1H#refresh"
|
77
|
+
# )
|
78
|
+
# end
|
79
|
+
# end
|
80
|
+
|
81
|
+
# it 'returns the previously shown content when there is stale content from last run' do
|
82
|
+
# attributes = {
|
83
|
+
# name: '#refresh',
|
84
|
+
# lines: [],
|
85
|
+
# colour: {
|
86
|
+
# foreground: '#ff0000',
|
87
|
+
# background: '#000000'
|
88
|
+
# },
|
89
|
+
# geometry: {
|
90
|
+
# width: 11,
|
91
|
+
# height: 3
|
92
|
+
# }
|
93
|
+
# }
|
94
|
+
# interface = Interface.new(attributes)
|
95
|
+
# interface.current = "\e[38;5;196m\e[48;5;16m" \
|
96
|
+
# "\e[1;1H \e[1;1H" \
|
97
|
+
# "\e[2;1H \e[2;1H" \
|
98
|
+
# "\e[3;1H \e[3;1H" \
|
99
|
+
# "\e[1;1H#refresh" \
|
100
|
+
# "\e[2;1H#refresh" \
|
101
|
+
# "\e[3;1H#refresh"
|
102
|
+
|
103
|
+
# Terminal.stub(:output, nil) do
|
104
|
+
# interface.refresh.must_equal(
|
105
|
+
# "\e[38;5;196m\e[48;5;16m" \
|
106
|
+
# "\e[1;1H \e[1;1H" \
|
107
|
+
# "\e[2;1H \e[2;1H" \
|
108
|
+
# "\e[3;1H \e[3;1H" \
|
109
|
+
# "\e[1;1H#refresh" \
|
110
|
+
# "\e[2;1H#refresh" \
|
111
|
+
# "\e[3;1H#refresh"
|
112
|
+
# )
|
113
|
+
# end
|
114
|
+
# end
|
115
|
+
# end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe '.refresh_all' do
|
119
|
+
it 'requests each stored interface to be refreshed' do
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe '.reset' do
|
124
|
+
it 'destroys all saved buffers' do
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -48,7 +48,9 @@ module Vedeu
|
|
48
48
|
|
49
49
|
it 'switches the terminal mode when escape is pressed' do
|
50
50
|
Terminal.stub :input, "\e" do
|
51
|
-
|
51
|
+
Vedeu.stub :log, nil do
|
52
|
+
proc { Input.capture }.must_raise(ModeSwitch)
|
53
|
+
end
|
52
54
|
end
|
53
55
|
end
|
54
56
|
end
|
data/vedeu.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'vedeu'
|
7
|
-
spec.version = '0.1.
|
7
|
+
spec.version = '0.1.9'
|
8
8
|
spec.authors = ['Gavin Laking']
|
9
9
|
spec.email = ['gavinlaking@gmail.com']
|
10
10
|
spec.summary = %q{A terminal case of wonderland.}
|
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.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Laking
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -183,7 +183,6 @@ files:
|
|
183
183
|
- Rakefile
|
184
184
|
- bin/log
|
185
185
|
- bin/vedeu
|
186
|
-
- deps.md
|
187
186
|
- lib/vedeu.rb
|
188
187
|
- lib/vedeu/api/base.rb
|
189
188
|
- lib/vedeu/api/events.rb
|
@@ -211,6 +210,7 @@ files:
|
|
211
210
|
- lib/vedeu/models/line.rb
|
212
211
|
- lib/vedeu/models/stream.rb
|
213
212
|
- lib/vedeu/models/style.rb
|
213
|
+
- lib/vedeu/output/buffers.rb
|
214
214
|
- lib/vedeu/output/clear.rb
|
215
215
|
- lib/vedeu/output/render.rb
|
216
216
|
- lib/vedeu/output/view.rb
|
@@ -245,6 +245,7 @@ files:
|
|
245
245
|
- test/lib/vedeu/models/line_test.rb
|
246
246
|
- test/lib/vedeu/models/stream_test.rb
|
247
247
|
- test/lib/vedeu/models/style_test.rb
|
248
|
+
- test/lib/vedeu/output/buffers_test.rb
|
248
249
|
- test/lib/vedeu/output/clear_test.rb
|
249
250
|
- test/lib/vedeu/output/render_test.rb
|
250
251
|
- test/lib/vedeu/output/view_test.rb
|
@@ -257,14 +258,6 @@ files:
|
|
257
258
|
- test/stats.sh
|
258
259
|
- test/support/bench.rb
|
259
260
|
- test/support/colours.rb
|
260
|
-
- test/support/dummy_interface.rb
|
261
|
-
- test/support/erb/colour.erb
|
262
|
-
- test/support/erb/colour_style.erb
|
263
|
-
- test/support/erb/line.erb
|
264
|
-
- test/support/erb/line_2x.erb
|
265
|
-
- test/support/erb/line_foreground.erb
|
266
|
-
- test/support/erb/line_foreground_2x.erb
|
267
|
-
- test/support/erb/style.erb
|
268
261
|
- test/support/json/int1_lin1_str1.json
|
269
262
|
- test/support/json/int1_lin1_str3.json
|
270
263
|
- test/support/json/int1_lin2_str1.json
|
@@ -275,7 +268,6 @@ files:
|
|
275
268
|
- test/support/json/int2_lin2_str1.json
|
276
269
|
- test/support/json/int2_lin2_str3.json
|
277
270
|
- test/support/json/int2_lin2_str3_styles.json
|
278
|
-
- test/support/template.erb
|
279
271
|
- test/test_helper.rb
|
280
272
|
- vedeu.gemspec
|
281
273
|
homepage: https://github.com/gavinlaking/vedeu
|
@@ -328,6 +320,7 @@ test_files:
|
|
328
320
|
- test/lib/vedeu/models/line_test.rb
|
329
321
|
- test/lib/vedeu/models/stream_test.rb
|
330
322
|
- test/lib/vedeu/models/style_test.rb
|
323
|
+
- test/lib/vedeu/output/buffers_test.rb
|
331
324
|
- test/lib/vedeu/output/clear_test.rb
|
332
325
|
- test/lib/vedeu/output/render_test.rb
|
333
326
|
- test/lib/vedeu/output/view_test.rb
|
@@ -340,14 +333,6 @@ test_files:
|
|
340
333
|
- test/stats.sh
|
341
334
|
- test/support/bench.rb
|
342
335
|
- test/support/colours.rb
|
343
|
-
- test/support/dummy_interface.rb
|
344
|
-
- test/support/erb/colour.erb
|
345
|
-
- test/support/erb/colour_style.erb
|
346
|
-
- test/support/erb/line.erb
|
347
|
-
- test/support/erb/line_2x.erb
|
348
|
-
- test/support/erb/line_foreground.erb
|
349
|
-
- test/support/erb/line_foreground_2x.erb
|
350
|
-
- test/support/erb/style.erb
|
351
336
|
- test/support/json/int1_lin1_str1.json
|
352
337
|
- test/support/json/int1_lin1_str3.json
|
353
338
|
- test/support/json/int1_lin2_str1.json
|
@@ -358,5 +343,4 @@ test_files:
|
|
358
343
|
- test/support/json/int2_lin2_str1.json
|
359
344
|
- test/support/json/int2_lin2_str3.json
|
360
345
|
- test/support/json/int2_lin2_str3_styles.json
|
361
|
-
- test/support/template.erb
|
362
346
|
- test/test_helper.rb
|
data/deps.md
DELETED
@@ -1,191 +0,0 @@
|
|
1
|
-
----------------------------------------------------------------------
|
2
|
-
By class
|
3
|
-
----------------------------------------------------------------------
|
4
|
-
|
5
|
-
StandardError
|
6
|
-
API::InterfaceNotSpecified
|
7
|
-
EntityNotFound
|
8
|
-
InvalidHeight
|
9
|
-
InvalidWidth
|
10
|
-
ModeSwitch
|
11
|
-
OutOfRange
|
12
|
-
XOutOfBounds
|
13
|
-
YOutOfBounds
|
14
|
-
|
15
|
-
API::Base
|
16
|
-
API::Stream
|
17
|
-
|
18
|
-
API::Grid
|
19
|
-
Terminal
|
20
|
-
|
21
|
-
API::Interface
|
22
|
-
API::Grid
|
23
|
-
Geometry
|
24
|
-
Interface
|
25
|
-
API::Store
|
26
|
-
Terminal
|
27
|
-
|
28
|
-
API::Line
|
29
|
-
API::Base
|
30
|
-
API::Stream
|
31
|
-
|
32
|
-
API::Stream
|
33
|
-
API::Base
|
34
|
-
|
35
|
-
API::View
|
36
|
-
API::Line
|
37
|
-
API::Store
|
38
|
-
|
39
|
-
Application
|
40
|
-
Input
|
41
|
-
Terminal
|
42
|
-
|
43
|
-
Clear
|
44
|
-
|
45
|
-
Collection
|
46
|
-
|
47
|
-
Colour
|
48
|
-
Background
|
49
|
-
ColourTranslator
|
50
|
-
Foreground
|
51
|
-
ColourTranslator
|
52
|
-
|
53
|
-
Composition
|
54
|
-
InterfaceCollection
|
55
|
-
|
56
|
-
Configuration
|
57
|
-
|
58
|
-
DSLParser
|
59
|
-
|
60
|
-
Geometry
|
61
|
-
Esc
|
62
|
-
Terminal
|
63
|
-
|
64
|
-
Esc
|
65
|
-
|
66
|
-
API::Events
|
67
|
-
|
68
|
-
Input
|
69
|
-
API::Events
|
70
|
-
Terminal
|
71
|
-
|
72
|
-
Instrumentation
|
73
|
-
Log
|
74
|
-
Trace
|
75
|
-
|
76
|
-
Interface
|
77
|
-
Clear
|
78
|
-
Colour
|
79
|
-
Geometry
|
80
|
-
LineCollection
|
81
|
-
Render
|
82
|
-
Style
|
83
|
-
Terminal
|
84
|
-
|
85
|
-
InterfaceCollection
|
86
|
-
API::Store
|
87
|
-
|
88
|
-
Launcher
|
89
|
-
Application
|
90
|
-
Configuration
|
91
|
-
|
92
|
-
Line
|
93
|
-
Colour
|
94
|
-
StreamCollection
|
95
|
-
Style
|
96
|
-
|
97
|
-
LineCollection
|
98
|
-
Collection
|
99
|
-
Line
|
100
|
-
|
101
|
-
Menu
|
102
|
-
API::Events
|
103
|
-
|
104
|
-
API::Store
|
105
|
-
Interface
|
106
|
-
|
107
|
-
Render
|
108
|
-
Line
|
109
|
-
Stream
|
110
|
-
|
111
|
-
Stream
|
112
|
-
Colour
|
113
|
-
Style
|
114
|
-
|
115
|
-
StreamCollection
|
116
|
-
Collection
|
117
|
-
Stream
|
118
|
-
|
119
|
-
Style
|
120
|
-
Esc
|
121
|
-
|
122
|
-
Terminal
|
123
|
-
Esc
|
124
|
-
Application
|
125
|
-
|
126
|
-
TextAdaptor
|
127
|
-
|
128
|
-
View
|
129
|
-
Composition
|
130
|
-
DSLParser
|
131
|
-
|
132
|
-
ColourTranslator
|
133
|
-
|
134
|
-
Wordwrap
|
135
|
-
|
136
|
-
|
137
|
-
----------------------------------------------------------------------
|
138
|
-
Grouped
|
139
|
-
----------------------------------------------------------------------
|
140
|
-
|
141
|
-
API::Interface
|
142
|
-
Interface
|
143
|
-
Geometry
|
144
|
-
API::Store
|
145
|
-
|
146
|
-
Launcher
|
147
|
-
Application
|
148
|
-
Events
|
149
|
-
Input
|
150
|
-
Events
|
151
|
-
Terminal
|
152
|
-
Esc
|
153
|
-
Configuration
|
154
|
-
|
155
|
-
View
|
156
|
-
Composition
|
157
|
-
InterfaceCollection
|
158
|
-
API::Store
|
159
|
-
Interface
|
160
|
-
Clear
|
161
|
-
Colour
|
162
|
-
Background
|
163
|
-
Foreground
|
164
|
-
Geometry
|
165
|
-
Esc
|
166
|
-
Terminal
|
167
|
-
Esc
|
168
|
-
LineCollection
|
169
|
-
Collection
|
170
|
-
Line
|
171
|
-
Colour
|
172
|
-
Background
|
173
|
-
Foreground
|
174
|
-
StreamCollection
|
175
|
-
Collection
|
176
|
-
Stream
|
177
|
-
Colour
|
178
|
-
Background
|
179
|
-
Foreground
|
180
|
-
Style
|
181
|
-
Esc
|
182
|
-
Style
|
183
|
-
Esc
|
184
|
-
Render
|
185
|
-
Line
|
186
|
-
Stream
|
187
|
-
Style
|
188
|
-
Esc
|
189
|
-
Terminal
|
190
|
-
Esc
|
191
|
-
DSLParser
|
data/test/support/erb/colour.erb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
<%= foreground('#0000ff') -%><%= style('underline') -%><%= background('#00005a') -%>Blue underline text on dark blue background.
|
data/test/support/erb/line.erb
DELETED
data/test/support/erb/style.erb
DELETED
data/test/support/template.erb
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
This is the test template.
|
2
|
-
|
3
|
-
<%= foreground('#5f00af') %><%= object.value %>
|
4
|
-
<%= background('#ffff00') %><%= object.value %>
|
5
|
-
<%= foreground('#ff8700') %><%= background('#ffff00') %><%= object.value %>
|
6
|
-
<%= style('underline') %><%= object.value %>
|
7
|
-
|
8
|
-
Some more content...
|