vedeu 0.4.22 → 0.4.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +5 -5
- data/examples/geometry_app.rb +2 -2
- data/lib/vedeu/bindings.rb +2 -15
- data/lib/vedeu/buffers/buffer.rb +2 -6
- data/lib/vedeu/configuration/cli.rb +4 -4
- data/lib/vedeu/dsl/components/border.rb +24 -8
- data/lib/vedeu/dsl/components/geometry.rb +10 -0
- data/lib/vedeu/events/event.rb +1 -2
- data/lib/vedeu/geometry/area.rb +4 -1
- data/lib/vedeu/geometry/geometry.rb +51 -18
- data/lib/vedeu/geometry/grid.rb +4 -28
- data/lib/vedeu/launcher.rb +6 -2
- data/lib/vedeu/models/line.rb +1 -1
- data/lib/vedeu/output/clear.rb +8 -8
- data/lib/vedeu/output/compressor.rb +1 -0
- data/lib/vedeu/output/esc.rb +29 -101
- data/lib/vedeu/output/html_char.rb +9 -9
- data/lib/vedeu/output/refresh.rb +17 -5
- data/lib/vedeu/output/renderers/all.rb +1 -9
- data/lib/vedeu/output/translator.rb +1 -1
- data/lib/vedeu/output/viewport.rb +1 -1
- data/lib/vedeu/repositories/repositories/colours.rb +6 -3
- data/lib/vedeu/support/all.rb +1 -0
- data/lib/vedeu/support/template.rb +2 -1
- data/lib/vedeu/support/terminal.rb +2 -0
- data/lib/vedeu/support/timer.rb +44 -0
- data/test/lib/vedeu/buffers/buffer_test.rb +1 -7
- data/test/lib/vedeu/configuration/cli_test.rb +28 -0
- data/test/lib/vedeu/dsl/components/geometry_test.rb +12 -0
- data/test/lib/vedeu/geometry/geometry_test.rb +8 -0
- data/test/lib/vedeu/geometry/grid_test.rb +0 -20
- data/test/lib/vedeu/geometry/position_test.rb +6 -0
- data/test/lib/vedeu/null/border_test.rb +6 -0
- data/test/lib/vedeu/output/clear_test.rb +12 -6
- data/test/lib/vedeu/output/compressor_test.rb +29 -0
- data/test/lib/vedeu/output/esc_test.rb +26 -26
- data/test/lib/vedeu/output/presentation_test.rb +22 -0
- data/test/lib/vedeu/output/translator_test.rb +18 -16
- data/test/lib/vedeu/output/viewport_test.rb +163 -97
- data/test/lib/vedeu/output/virtual_terminal_test.rb +6 -0
- data/test/lib/vedeu/repositories/repositories/colours_test.rb +29 -4
- data/test/lib/vedeu/repositories/repository_test.rb +6 -0
- data/vedeu.gemspec +4 -4
- metadata +3 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 365b29b26543c213bcb8ca54063e55261dca7d47
|
4
|
+
data.tar.gz: 8fbbb26db13f252b6cdba3ccaaf851718335a854
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 224fd3df8947ad37738184011a53c1814530cb8ee923f3e634a8e398710b42399aa15d9ad95cc57c2356da16208fb3c972dc9b0a92c0c2e9cb73d059074f1c86
|
7
|
+
data.tar.gz: 2d99311229522afc70142dbca1f15d05f2cce5954548cf1f05d275a51545d7b729e67748c48b9ead6578457d503097418239826fd658501a8d2c5c59c1a5cec9
|
data/Rakefile
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
2
|
require 'rake/testtask'
|
3
|
-
require 'cucumber'
|
4
|
-
require 'cucumber/rake/task'
|
3
|
+
# require 'cucumber'
|
4
|
+
# require 'cucumber/rake/task'
|
5
5
|
require 'inch/rake'
|
6
6
|
require 'yard'
|
7
7
|
require 'rubocop/rake_task'
|
8
8
|
|
9
|
-
Cucumber::Rake::Task.new(:cucumber) do |t|
|
10
|
-
|
11
|
-
end
|
9
|
+
# Cucumber::Rake::Task.new(:cucumber) do |t|
|
10
|
+
# t.cucumber_opts = 'features --format progress'
|
11
|
+
# end
|
12
12
|
|
13
13
|
Rake::TestTask.new(:test) do |t|
|
14
14
|
t.libs.push 'lib'
|
data/examples/geometry_app.rb
CHANGED
@@ -21,7 +21,7 @@ class VedeuGeometryApp
|
|
21
21
|
|
22
22
|
# Geometry can be defined within the interface.
|
23
23
|
geometry do
|
24
|
-
height
|
24
|
+
height rows(4)
|
25
25
|
width 8
|
26
26
|
x 2
|
27
27
|
y 2
|
@@ -36,7 +36,7 @@ class VedeuGeometryApp
|
|
36
36
|
# Geometry can be defined either before or after the interface.
|
37
37
|
geometry 'second' do
|
38
38
|
height 8
|
39
|
-
width
|
39
|
+
width columns(1)
|
40
40
|
x 12
|
41
41
|
y 2
|
42
42
|
end
|
data/lib/vedeu/bindings.rb
CHANGED
@@ -60,7 +60,6 @@ module Vedeu
|
|
60
60
|
# `_mode_switch_` is triggered.
|
61
61
|
Vedeu.bind(:_keypress_) do |key|
|
62
62
|
Vedeu.trigger(:key, key)
|
63
|
-
|
64
63
|
Vedeu.keypress(key)
|
65
64
|
end
|
66
65
|
|
@@ -82,12 +81,8 @@ module Vedeu
|
|
82
81
|
# events. Please see those events for their behaviour.
|
83
82
|
Vedeu.bind(:_resize_, delay: 0.15) { Vedeu.resize }
|
84
83
|
|
85
|
-
Vedeu.bind(:tick)
|
86
|
-
|
87
|
-
end
|
88
|
-
Vedeu.bind(:tock) do |time|
|
89
|
-
Vedeu.log(type: :debug, message: "Tock: #{time}")
|
90
|
-
end
|
84
|
+
Vedeu.bind(:tick) { |t| Vedeu.log(type: :debug, message: "Tick: #{t}") }
|
85
|
+
Vedeu.bind(:tock) { |t| Vedeu.log(type: :debug, message: "Tock: #{t}") }
|
91
86
|
|
92
87
|
# Hide the cursor of the named interface or interface currently in focus.
|
93
88
|
Vedeu.bind(:_cursor_hide_) do |name|
|
@@ -175,7 +170,6 @@ module Vedeu
|
|
175
170
|
|
176
171
|
else
|
177
172
|
Vedeu::Terminal.virtual.clear if Vedeu::Configuration.drb?
|
178
|
-
|
179
173
|
Vedeu::Terminal.clear
|
180
174
|
end
|
181
175
|
end
|
@@ -206,7 +200,6 @@ module Vedeu
|
|
206
200
|
# the named group.
|
207
201
|
Vedeu.bind(:_show_group_) do |name|
|
208
202
|
Vedeu.trigger(:_clear_)
|
209
|
-
|
210
203
|
Vedeu.trigger(:_refresh_group_, name)
|
211
204
|
end
|
212
205
|
|
@@ -266,8 +259,6 @@ module Vedeu
|
|
266
259
|
# of the available space on the terminal window.
|
267
260
|
Vedeu.bind(:_maximise_) do |name|
|
268
261
|
Vedeu.geometries.by_name(name).maximise
|
269
|
-
|
270
|
-
Vedeu.trigger(:_refresh_, name)
|
271
262
|
end
|
272
263
|
|
273
264
|
# Will unmaximise the named interface geometry. Previously, if a geometry
|
@@ -275,11 +266,7 @@ module Vedeu
|
|
275
266
|
# usual defined size (terminal size permitting: if the terminal has been
|
276
267
|
# resized, then the new geometry size should adapt).
|
277
268
|
Vedeu.bind(:_unmaximise_) do |name|
|
278
|
-
Vedeu.trigger(:_clear_, name)
|
279
|
-
|
280
269
|
Vedeu.geometries.by_name(name).unmaximise
|
281
|
-
|
282
|
-
Vedeu.trigger(:_refresh_, name)
|
283
270
|
end
|
284
271
|
|
285
272
|
end # Bindings
|
data/lib/vedeu/buffers/buffer.rb
CHANGED
@@ -72,9 +72,7 @@ module Vedeu
|
|
72
72
|
#
|
73
73
|
# @return [void]
|
74
74
|
def clear
|
75
|
-
|
76
|
-
Vedeu::Output.render(clear_buffer)
|
77
|
-
end
|
75
|
+
Vedeu::Output.render(clear_buffer)
|
78
76
|
end
|
79
77
|
|
80
78
|
# Hide this buffer.
|
@@ -100,9 +98,7 @@ module Vedeu
|
|
100
98
|
#
|
101
99
|
# @return [Array<Array<Array<Vedeu::Char>>>]
|
102
100
|
def render
|
103
|
-
Vedeu::Output.render(buffer)
|
104
|
-
|
105
|
-
buffer
|
101
|
+
Vedeu::Output.render(buffer)
|
106
102
|
end
|
107
103
|
alias_method :content, :render
|
108
104
|
|
@@ -124,7 +124,7 @@ module Vedeu
|
|
124
124
|
def drb_height
|
125
125
|
parser.on('--drb-height',
|
126
126
|
'Set the height for fake terminal.') do |height|
|
127
|
-
|
127
|
+
options[:drb] = true
|
128
128
|
options[:drb_height] = height
|
129
129
|
end
|
130
130
|
end
|
@@ -133,7 +133,7 @@ module Vedeu
|
|
133
133
|
def drb_host
|
134
134
|
parser.on('--drb-host',
|
135
135
|
'Set the hostname/IP for the DRb server.') do |hostname|
|
136
|
-
|
136
|
+
options[:drb] = true
|
137
137
|
options[:drb_host] = hostname
|
138
138
|
end
|
139
139
|
end
|
@@ -141,7 +141,7 @@ module Vedeu
|
|
141
141
|
# @return [OptionParser]
|
142
142
|
def drb_port
|
143
143
|
parser.on('--drb-port', 'Set the port for the DRb server.') do |port|
|
144
|
-
|
144
|
+
options[:drb] = true
|
145
145
|
options[:drb_port] = port
|
146
146
|
end
|
147
147
|
end
|
@@ -150,7 +150,7 @@ module Vedeu
|
|
150
150
|
def drb_width
|
151
151
|
parser.on('--drb-width',
|
152
152
|
'Set the width for fake terminal.') do |width|
|
153
|
-
|
153
|
+
options[:drb] = true
|
154
154
|
options[:drb_width] = width
|
155
155
|
end
|
156
156
|
end
|
@@ -130,12 +130,16 @@ module Vedeu
|
|
130
130
|
end
|
131
131
|
alias_method :show_bottom, :bottom
|
132
132
|
|
133
|
-
#
|
133
|
+
# Disable the bottom border.
|
134
|
+
#
|
135
|
+
# @see Vedeu::DSL::Border#bottom
|
134
136
|
def hide_bottom!
|
135
137
|
bottom(false)
|
136
138
|
end
|
137
139
|
|
138
|
-
#
|
140
|
+
# Enable the bottom border.
|
141
|
+
#
|
142
|
+
# @see Vedeu::DSL::Border#bottom
|
139
143
|
def show_bottom!
|
140
144
|
bottom(true)
|
141
145
|
end
|
@@ -162,12 +166,16 @@ module Vedeu
|
|
162
166
|
end
|
163
167
|
alias_method :show_left, :left
|
164
168
|
|
165
|
-
#
|
169
|
+
# Disable the left border.
|
170
|
+
#
|
171
|
+
# @see Vedeu::DSL::Border#left
|
166
172
|
def hide_left!
|
167
173
|
left(false)
|
168
174
|
end
|
169
175
|
|
170
|
-
#
|
176
|
+
# Enable the left border.
|
177
|
+
#
|
178
|
+
# @see Vedeu::DSL::Border#left
|
171
179
|
def show_left!
|
172
180
|
left(true)
|
173
181
|
end
|
@@ -194,12 +202,16 @@ module Vedeu
|
|
194
202
|
end
|
195
203
|
alias_method :show_right, :right
|
196
204
|
|
197
|
-
#
|
205
|
+
# Disable the right border.
|
206
|
+
#
|
207
|
+
# @see Vedeu::DSL::Border#right
|
198
208
|
def hide_right!
|
199
209
|
right(false)
|
200
210
|
end
|
201
211
|
|
202
|
-
#
|
212
|
+
# Enable the right border.
|
213
|
+
#
|
214
|
+
# @see Vedeu::DSL::Border#right
|
203
215
|
def show_right!
|
204
216
|
right(true)
|
205
217
|
end
|
@@ -244,12 +256,16 @@ module Vedeu
|
|
244
256
|
end
|
245
257
|
alias_method :show_top, :top
|
246
258
|
|
247
|
-
#
|
259
|
+
# Disable the top border.
|
260
|
+
#
|
261
|
+
# @see Vedeu::DSL::Border#top
|
248
262
|
def hide_top!
|
249
263
|
top(false)
|
250
264
|
end
|
251
265
|
|
252
|
-
#
|
266
|
+
# Enable the top border.
|
267
|
+
#
|
268
|
+
# @see Vedeu::DSL::Border#top
|
253
269
|
def show_top!
|
254
270
|
top(true)
|
255
271
|
end
|
@@ -58,6 +58,11 @@ module Vedeu
|
|
58
58
|
end
|
59
59
|
alias_method :centred!, :centred
|
60
60
|
|
61
|
+
# @see Vedeu::Grid.columns
|
62
|
+
def columns(value)
|
63
|
+
Vedeu::Grid.columns(value)
|
64
|
+
end
|
65
|
+
|
61
66
|
# Specify the number of characters/rows/lines tall the interface will be.
|
62
67
|
#
|
63
68
|
# @example
|
@@ -74,6 +79,11 @@ module Vedeu
|
|
74
79
|
model.height = value
|
75
80
|
end
|
76
81
|
|
82
|
+
# @see Vedeu::Grid.columns
|
83
|
+
def rows(value)
|
84
|
+
Vedeu::Grid.rows(value)
|
85
|
+
end
|
86
|
+
|
77
87
|
# Specify the number of characters/columns wide the interface will be.
|
78
88
|
#
|
79
89
|
# @param value [Fixnum]
|
data/lib/vedeu/events/event.rb
CHANGED
@@ -123,8 +123,7 @@ module Vedeu
|
|
123
123
|
# @see Vedeu::Event.bind
|
124
124
|
def bind
|
125
125
|
if repository.registered?(name)
|
126
|
-
|
127
|
-
new_collection = collection.add(self)
|
126
|
+
new_collection = repository.find(name).add(self)
|
128
127
|
|
129
128
|
else
|
130
129
|
new_collection = Vedeu::Events.new([self], nil, name)
|
data/lib/vedeu/geometry/area.rb
CHANGED
@@ -61,6 +61,7 @@ module Vedeu
|
|
61
61
|
# @!attribute [rw] maximised
|
62
62
|
# @return [Boolean]
|
63
63
|
attr_accessor :maximised
|
64
|
+
alias_method :maximised?, :maximised
|
64
65
|
|
65
66
|
# @!attribute [w] width
|
66
67
|
# @return [Fixnum]
|
@@ -109,16 +110,30 @@ module Vedeu
|
|
109
110
|
|
110
111
|
# @return [Vedeu::Geometry]
|
111
112
|
def maximise
|
112
|
-
|
113
|
+
unless maximised?
|
114
|
+
@maximised = true
|
113
115
|
|
114
|
-
|
116
|
+
work = store
|
117
|
+
|
118
|
+
Vedeu.trigger(:_refresh_, name)
|
119
|
+
|
120
|
+
work
|
121
|
+
end
|
115
122
|
end
|
116
123
|
|
117
124
|
# @return [Vedeu::Geometry]
|
118
125
|
def unmaximise
|
119
|
-
|
126
|
+
if maximised?
|
127
|
+
Vedeu.trigger(:_clear_, name)
|
128
|
+
|
129
|
+
@maximised = false
|
130
|
+
|
131
|
+
work = store
|
132
|
+
|
133
|
+
Vedeu.trigger(:_refresh_, name)
|
120
134
|
|
121
|
-
|
135
|
+
work
|
136
|
+
end
|
122
137
|
end
|
123
138
|
|
124
139
|
private
|
@@ -128,26 +143,44 @@ module Vedeu
|
|
128
143
|
@area = Vedeu::Area.from_dimensions(y_yn: y_yn, x_xn: x_xn)
|
129
144
|
end
|
130
145
|
|
146
|
+
# @return [Hash<Symbol => Fixnum, Hash]
|
147
|
+
def height_attributes
|
148
|
+
{
|
149
|
+
d: _y,
|
150
|
+
dn: _yn,
|
151
|
+
d_dn: @height,
|
152
|
+
default: Vedeu::Terminal.height,
|
153
|
+
options: dimension_options,
|
154
|
+
}
|
155
|
+
end
|
156
|
+
|
157
|
+
# @return [Hash<Symbol => Fixnum, Hash]
|
158
|
+
def width_attributes
|
159
|
+
{
|
160
|
+
d: _x,
|
161
|
+
dn: _xn,
|
162
|
+
d_dn: @width,
|
163
|
+
default: Vedeu::Terminal.width,
|
164
|
+
options: dimension_options,
|
165
|
+
}
|
166
|
+
end
|
167
|
+
|
168
|
+
# @return [Hash<Symbol => Boolean>]
|
169
|
+
def dimension_options
|
170
|
+
{
|
171
|
+
centred: centred,
|
172
|
+
maximised: maximised,
|
173
|
+
}
|
174
|
+
end
|
175
|
+
|
131
176
|
# @return [Array<Fixnum>]
|
132
177
|
def x_xn
|
133
|
-
@x_xn = Vedeu::Dimension.pair(
|
134
|
-
dn: _xn,
|
135
|
-
d_dn: @width,
|
136
|
-
default: Vedeu::Terminal.width,
|
137
|
-
options: {
|
138
|
-
centred: centred,
|
139
|
-
maximised: maximised })
|
178
|
+
@x_xn = Vedeu::Dimension.pair(width_attributes)
|
140
179
|
end
|
141
180
|
|
142
181
|
# @return [Array<Fixnum>]
|
143
182
|
def y_yn
|
144
|
-
@y_yn = Vedeu::Dimension.pair(
|
145
|
-
dn: _yn,
|
146
|
-
d_dn: @height,
|
147
|
-
default: Vedeu::Terminal.height,
|
148
|
-
options: {
|
149
|
-
centred: centred,
|
150
|
-
maximised: maximised })
|
183
|
+
@y_yn = Vedeu::Dimension.pair(height_attributes)
|
151
184
|
end
|
152
185
|
|
153
186
|
# Returns the row/line start position for the interface.
|
data/lib/vedeu/geometry/grid.rb
CHANGED
@@ -1,29 +1,3 @@
|
|
1
|
-
# Monkey-patch Ruby's Fixnum to provide a columns method.
|
2
|
-
# @todo Don't monkey-patch because it is naughty.
|
3
|
-
class Fixnum
|
4
|
-
|
5
|
-
# Augment Fixnum to calculate column width in a grid-based layout.
|
6
|
-
#
|
7
|
-
# The grid system splits the terminal height and width into 12 equal parts, by
|
8
|
-
# dividing the available height and width by 12. If the terminal height or
|
9
|
-
# width is not a multiple of 12, then Grid chooses the maximum value which
|
10
|
-
# will fit.
|
11
|
-
#
|
12
|
-
# Used primarily at interface creation time:
|
13
|
-
#
|
14
|
-
# width: 9.columns # (Terminal width / 12) * 9 characters wide; e.g.
|
15
|
-
# # Terminal is 92 characters wide, maximum value is
|
16
|
-
# # therefore 84, meaning a column is 7 characters wide.
|
17
|
-
def columns
|
18
|
-
Vedeu::Grid.columns(self)
|
19
|
-
end
|
20
|
-
|
21
|
-
def rows
|
22
|
-
Vedeu::Grid.rows(self)
|
23
|
-
end
|
24
|
-
|
25
|
-
end # Fixnum
|
26
|
-
|
27
1
|
module Vedeu
|
28
2
|
|
29
3
|
# Augment Fixnum to calculate column width or row height in a grid-based
|
@@ -36,13 +10,15 @@ module Vedeu
|
|
36
10
|
#
|
37
11
|
# Used primarily whilst defining geometry:
|
38
12
|
#
|
39
|
-
# width: 9
|
13
|
+
# width: columns(9) # (Terminal width / 12) * 9 characters wide; e.g.
|
40
14
|
# # Terminal is 92 characters wide, maximum value is
|
41
15
|
# # therefore 84, meaning a column is 7 characters wide.
|
16
|
+
# # (And width is therefore 63 characters wide.)
|
42
17
|
#
|
43
|
-
# height: 3
|
18
|
+
# height: rows(3) # (Terminal height / 12) * 3 rows high; e.g.
|
44
19
|
# # Terminal is 38 characters wide, maximum value is
|
45
20
|
# # therefore 36, meaning a row is 3 characters tall.
|
21
|
+
# # (And height is therefore 9 characters tall.)
|
46
22
|
class Grid
|
47
23
|
|
48
24
|
# @see #initialize
|
data/lib/vedeu/launcher.rb
CHANGED
@@ -58,7 +58,9 @@ module Vedeu
|
|
58
58
|
|
59
59
|
# @return [void]
|
60
60
|
def execute!
|
61
|
-
$stdin
|
61
|
+
$stdin = @stdin
|
62
|
+
$stdout = @stdout
|
63
|
+
$stderr = @stderr
|
62
64
|
|
63
65
|
Vedeu::Application.start(configuration)
|
64
66
|
|
@@ -83,7 +85,9 @@ module Vedeu
|
|
83
85
|
def terminate!
|
84
86
|
Vedeu.log(type: :info, message: 'Exiting gracefully.')
|
85
87
|
|
86
|
-
$stdin
|
88
|
+
$stdin = STDIN
|
89
|
+
$stdout = STDOUT
|
90
|
+
$stderr = STDERR
|
87
91
|
|
88
92
|
@kernel.exit(exit_code)
|
89
93
|
end
|