vedeu 0.4.43 → 0.4.44
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile +1 -1
- data/bin/vedeu +19 -0
- data/lib/vedeu.rb +0 -34
- data/lib/vedeu/all.rb +4 -1
- data/lib/vedeu/application/application_view.rb +9 -9
- data/lib/vedeu/application/controller.rb +6 -5
- data/lib/vedeu/application/helper.rb +3 -16
- data/lib/vedeu/application/view.rb +3 -16
- data/lib/vedeu/bindings/all.rb +5 -0
- data/lib/vedeu/bindings/bindings.rb +115 -0
- data/lib/vedeu/bindings/drb.rb +45 -0
- data/lib/vedeu/bindings/menus.rb +53 -0
- data/lib/vedeu/bindings/movement.rb +76 -0
- data/lib/vedeu/bindings/visibility.rb +53 -0
- data/lib/vedeu/buffers/buffer.rb +2 -0
- data/lib/vedeu/cli/generator/templates/application/app/controllers/name.erb +2 -2
- data/lib/vedeu/cli/generator/templates/application/app/helpers/name.erb +2 -0
- data/lib/vedeu/cli/generator/templates/application/config/configuration.erb +3 -0
- data/lib/vedeu/cli/generator/view.rb +0 -5
- data/lib/vedeu/cli/main.rb +12 -0
- data/lib/vedeu/cursor/reposition.rb +4 -4
- data/lib/vedeu/dsl/interface.rb +0 -27
- data/lib/vedeu/exceptions.rb +65 -0
- data/lib/vedeu/geometry/geometry.rb +2 -2
- data/lib/vedeu/geometry/grid.rb +2 -2
- data/lib/vedeu/input/input.rb +34 -28
- data/lib/vedeu/null/geometry.rb +2 -2
- data/lib/vedeu/output/colour.rb +0 -2
- data/lib/vedeu/output/esc.rb +7 -1
- data/lib/vedeu/output/render_border.rb +5 -0
- data/lib/vedeu/output/renderers/json.rb +7 -2
- data/lib/vedeu/support/terminal.rb +1 -1
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/application/controller_test.rb +0 -4
- data/test/lib/vedeu/application/helper_test.rb +0 -8
- data/test/lib/vedeu/application/view_test.rb +0 -8
- data/test/lib/vedeu/bindings/bindings_test.rb +43 -0
- data/test/lib/vedeu/bindings/drb_test.rb +23 -0
- data/test/lib/vedeu/bindings/menus_test.rb +26 -0
- data/test/lib/vedeu/bindings/movement_test.rb +28 -0
- data/test/lib/vedeu/bindings/visibility_test.rb +27 -0
- data/test/lib/vedeu/buffers/buffer_test.rb +73 -38
- data/test/lib/vedeu/cli/main_test.rb +47 -0
- data/test/lib/vedeu/dsl/interface_test.rb +4 -7
- data/test/lib/vedeu/exceptions_test.rb +5 -0
- data/test/lib/vedeu/input/input_test.rb +9 -0
- data/test/lib/vedeu/output/esc_test.rb +4 -1
- metadata +21 -5
- data/lib/vedeu/bindings.rb +0 -275
- data/test/lib/vedeu/bindings_test.rb +0 -88
data/lib/vedeu/null/geometry.rb
CHANGED
@@ -71,12 +71,12 @@ module Vedeu
|
|
71
71
|
|
72
72
|
# @return [Array<Fixnum>]
|
73
73
|
def x_xn
|
74
|
-
@x_xn ||= Vedeu::Dimension.pair(default: Vedeu
|
74
|
+
@x_xn ||= Vedeu::Dimension.pair(default: Vedeu.width)
|
75
75
|
end
|
76
76
|
|
77
77
|
# @return [Array<Fixnum>]
|
78
78
|
def y_yn
|
79
|
-
@y_yn ||= Vedeu::Dimension.pair(default: Vedeu
|
79
|
+
@y_yn ||= Vedeu::Dimension.pair(default: Vedeu.height)
|
80
80
|
end
|
81
81
|
|
82
82
|
end # Geometry
|
data/lib/vedeu/output/colour.rb
CHANGED
data/lib/vedeu/output/esc.rb
CHANGED
@@ -177,7 +177,13 @@ module Vedeu
|
|
177
177
|
|
178
178
|
# @return [String]
|
179
179
|
def screen_exit
|
180
|
-
[
|
180
|
+
[
|
181
|
+
show_cursor,
|
182
|
+
colour_reset,
|
183
|
+
reset,
|
184
|
+
Vedeu::Position.new(Vedeu.height, Vedeu.width).to_s,
|
185
|
+
"\n",
|
186
|
+
].join
|
181
187
|
end
|
182
188
|
|
183
189
|
end # Esc
|
@@ -1,5 +1,8 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
+
# Renders the provided border.
|
4
|
+
#
|
5
|
+
# @api private
|
3
6
|
class RenderBorder
|
4
7
|
|
5
8
|
extend Forwardable
|
@@ -197,6 +200,7 @@ module Vedeu
|
|
197
200
|
|
198
201
|
out = []
|
199
202
|
out << build(top_left, :top_left, *[y, x]) if left?
|
203
|
+
|
200
204
|
if title? && width > title_characters.size
|
201
205
|
out << titlebar
|
202
206
|
|
@@ -204,6 +208,7 @@ module Vedeu
|
|
204
208
|
out << horizontal_border(:top_horizontal, y)
|
205
209
|
|
206
210
|
end
|
211
|
+
|
207
212
|
out << build(top_right, :top_right, *[y, xn]) if right?
|
208
213
|
out
|
209
214
|
end
|
@@ -13,12 +13,17 @@ module Vedeu
|
|
13
13
|
def parsed
|
14
14
|
return '' if output.nil? || output.empty?
|
15
15
|
|
16
|
-
::JSON.pretty_generate(
|
16
|
+
::JSON.pretty_generate(as_hash)
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [Array]
|
20
|
+
def as_hash
|
21
|
+
sorted.map(&:to_hash)
|
17
22
|
end
|
18
23
|
|
19
24
|
# @return [Array]
|
20
25
|
def sorted
|
21
|
-
Array(output).flatten.sort { |a, b| a.position <=> b.position }
|
26
|
+
Array(output).flatten.sort { |a, b| a.position <=> b.position }
|
22
27
|
end
|
23
28
|
|
24
29
|
end # JSON
|
@@ -122,7 +122,7 @@ module Vedeu
|
|
122
122
|
#
|
123
123
|
# @return [String]
|
124
124
|
def restore_screen
|
125
|
-
output(Esc.string('screen_exit')
|
125
|
+
output(Esc.string('screen_exit'))
|
126
126
|
end
|
127
127
|
|
128
128
|
# Sets the cursor to be visible unless in raw mode, whereby it will be left
|
data/lib/vedeu/version.rb
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe Bindings do
|
6
|
+
|
7
|
+
context 'the system events needed by Vedeu to run are defined' do
|
8
|
+
it { Vedeu.events.registered?(:_clear_).must_equal(true) }
|
9
|
+
it { Vedeu.events.registered?(:_clear_group_).must_equal(true) }
|
10
|
+
it { Vedeu.events.registered?(:_cleanup_).must_equal(true) }
|
11
|
+
it { Vedeu.events.registered?(:_command_).must_equal(true) }
|
12
|
+
it { Vedeu.events.registered?(:_exit_).must_equal(true) }
|
13
|
+
it { Vedeu.events.registered?(:_initialize_).must_equal(true) }
|
14
|
+
it { Vedeu.events.registered?(:_keypress_).must_equal(true) }
|
15
|
+
it { Vedeu.events.registered?(:_log_).must_equal(true) }
|
16
|
+
it { Vedeu.events.registered?(:_mode_switch_).must_equal(true) }
|
17
|
+
it { Vedeu.events.registered?(:_refresh_).must_equal(true) }
|
18
|
+
it { Vedeu.events.registered?(:_refresh_cursor_).must_equal(true) }
|
19
|
+
it { Vedeu.events.registered?(:_refresh_group_).must_equal(true) }
|
20
|
+
it { Vedeu.events.registered?(:_resize_).must_equal(true) }
|
21
|
+
end
|
22
|
+
|
23
|
+
it { Vedeu.events.registered?(:_cursor_position_).must_equal(true) }
|
24
|
+
|
25
|
+
context 'the geometry specific events are defined' do
|
26
|
+
|
27
|
+
it { Vedeu.events.registered?(:_maximise_).must_equal(true) }
|
28
|
+
it { Vedeu.events.registered?(:_unmaximise_).must_equal(true) }
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'the focus specific events are defined' do
|
32
|
+
it { Vedeu.events.registered?(:_focus_by_name_).must_equal(true) }
|
33
|
+
it { Vedeu.events.registered?(:_focus_next_).must_equal(true) }
|
34
|
+
it { Vedeu.events.registered?(:_focus_prev_).must_equal(true) }
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'the refresh event for all registered interfaces is defined' do
|
38
|
+
it { Vedeu.events.registered?(:_refresh_).must_equal(true) }
|
39
|
+
end
|
40
|
+
|
41
|
+
end # Bindings
|
42
|
+
|
43
|
+
end # Vedeu
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Bindings
|
6
|
+
|
7
|
+
describe DRB do
|
8
|
+
|
9
|
+
context 'the drb specific events are defined' do
|
10
|
+
it { Vedeu.events.registered?(:_drb_input_).must_equal(true) }
|
11
|
+
it { Vedeu.events.registered?(:_drb_retrieve_output_).must_equal(true) }
|
12
|
+
it { Vedeu.events.registered?(:_drb_store_output_).must_equal(true) }
|
13
|
+
it { Vedeu.events.registered?(:_drb_restart_).must_equal(true) }
|
14
|
+
it { Vedeu.events.registered?(:_drb_start_).must_equal(true) }
|
15
|
+
it { Vedeu.events.registered?(:_drb_status_).must_equal(true) }
|
16
|
+
it { Vedeu.events.registered?(:_drb_stop_).must_equal(true) }
|
17
|
+
end
|
18
|
+
|
19
|
+
end # DRB
|
20
|
+
|
21
|
+
end # Bindings
|
22
|
+
|
23
|
+
end # Vedeu
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Bindings
|
6
|
+
|
7
|
+
describe Menus do
|
8
|
+
|
9
|
+
context 'the menu specific events are defined' do
|
10
|
+
it { Vedeu.events.registered?(:_menu_bottom_).must_equal(true) }
|
11
|
+
it { Vedeu.events.registered?(:_menu_current_).must_equal(true) }
|
12
|
+
it { Vedeu.events.registered?(:_menu_deselect_).must_equal(true) }
|
13
|
+
it { Vedeu.events.registered?(:_menu_items_).must_equal(true) }
|
14
|
+
it { Vedeu.events.registered?(:_menu_next_).must_equal(true) }
|
15
|
+
it { Vedeu.events.registered?(:_menu_prev_).must_equal(true) }
|
16
|
+
it { Vedeu.events.registered?(:_menu_selected_).must_equal(true) }
|
17
|
+
it { Vedeu.events.registered?(:_menu_select_).must_equal(true) }
|
18
|
+
it { Vedeu.events.registered?(:_menu_top_).must_equal(true) }
|
19
|
+
it { Vedeu.events.registered?(:_menu_view_).must_equal(true) }
|
20
|
+
end
|
21
|
+
|
22
|
+
end # Menus
|
23
|
+
|
24
|
+
end # Bindings
|
25
|
+
|
26
|
+
end # Vedeu
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Bindings
|
6
|
+
|
7
|
+
describe Movement do
|
8
|
+
|
9
|
+
context 'the movement events are defined' do
|
10
|
+
it { Vedeu.events.registered?(:_cursor_down_).must_equal(true) }
|
11
|
+
it { Vedeu.events.registered?(:_cursor_left_).must_equal(true) }
|
12
|
+
it { Vedeu.events.registered?(:_cursor_origin_).must_equal(true) }
|
13
|
+
it { Vedeu.events.registered?(:_cursor_reposition_).must_equal(true) }
|
14
|
+
it { Vedeu.events.registered?(:_cursor_reset_).must_equal(true) }
|
15
|
+
it { Vedeu.events.registered?(:_cursor_right_).must_equal(true) }
|
16
|
+
it { Vedeu.events.registered?(:_cursor_up_).must_equal(true) }
|
17
|
+
|
18
|
+
it { Vedeu.events.registered?(:_geometry_down_).must_equal(true) }
|
19
|
+
it { Vedeu.events.registered?(:_geometry_left_).must_equal(true) }
|
20
|
+
it { Vedeu.events.registered?(:_geometry_right_).must_equal(true) }
|
21
|
+
it { Vedeu.events.registered?(:_geometry_up_).must_equal(true) }
|
22
|
+
end
|
23
|
+
|
24
|
+
end # Movement
|
25
|
+
|
26
|
+
end # Bindings
|
27
|
+
|
28
|
+
end # Vedeu
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Bindings
|
6
|
+
|
7
|
+
describe Visibility do
|
8
|
+
|
9
|
+
context 'the visibility events are defined' do
|
10
|
+
it { Vedeu.events.registered?(:_cursor_hide_).must_equal(true) }
|
11
|
+
it { Vedeu.events.registered?(:_cursor_show_).must_equal(true) }
|
12
|
+
it { Vedeu.events.registered?(:_hide_cursor_).must_equal(true) }
|
13
|
+
it { Vedeu.events.registered?(:_show_cursor_).must_equal(true) }
|
14
|
+
|
15
|
+
it { Vedeu.events.registered?(:_hide_group_).must_equal(true) }
|
16
|
+
it { Vedeu.events.registered?(:_show_group_).must_equal(true) }
|
17
|
+
|
18
|
+
it { Vedeu.events.registered?(:_hide_interface_).must_equal(true) }
|
19
|
+
it { Vedeu.events.registered?(:_show_interface_).must_equal(true) }
|
20
|
+
it { Vedeu.events.registered?(:_toggle_interface_).must_equal(true) }
|
21
|
+
end
|
22
|
+
|
23
|
+
end # Visibility
|
24
|
+
|
25
|
+
end # Bindings
|
26
|
+
|
27
|
+
end # Vedeu
|
@@ -23,6 +23,8 @@ module Vedeu
|
|
23
23
|
before do
|
24
24
|
Vedeu.stubs(:trigger)
|
25
25
|
# Vedeu.interfaces.stubs(:by_name).returns(interface)
|
26
|
+
Vedeu::Visibility.stubs(:show)
|
27
|
+
Vedeu::Visibility.stubs(:hide)
|
26
28
|
end
|
27
29
|
after { Vedeu.interfaces.reset }
|
28
30
|
|
@@ -142,71 +144,104 @@ module Vedeu
|
|
142
144
|
end
|
143
145
|
|
144
146
|
describe '#hide' do
|
147
|
+
let(:interface) {
|
148
|
+
Vedeu::Interface.new({ name: _name, visible: visible })
|
149
|
+
}
|
150
|
+
let(:_name) { 'Buffer#hide' }
|
151
|
+
let(:visible) {}
|
152
|
+
|
153
|
+
before do
|
154
|
+
interface.store
|
155
|
+
Vedeu::Output.stubs(:render)
|
156
|
+
end
|
157
|
+
after do
|
158
|
+
Vedeu.interfaces.reset
|
159
|
+
end
|
160
|
+
|
145
161
|
subject { instance.hide }
|
146
162
|
|
147
163
|
context 'when the interface is visible' do
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
# end
|
155
|
-
|
156
|
-
# let(:_name) { 'Buffer#hide' }
|
157
|
-
# let(:interface) { Vedeu.interface('Buffer') {} }
|
158
|
-
|
159
|
-
# it {
|
160
|
-
# Vedeu::Visibility.expects(:hide).with(interface)
|
161
|
-
# instance.expects(:clear)
|
162
|
-
# subject
|
163
|
-
# }
|
164
|
+
let(:visible) { true }
|
165
|
+
|
166
|
+
it {
|
167
|
+
Vedeu::Visibility.expects(:hide).with(interface)
|
168
|
+
subject
|
169
|
+
}
|
164
170
|
end
|
165
171
|
|
166
172
|
context 'when the interface is not visible' do
|
173
|
+
let(:visible) { false }
|
174
|
+
|
167
175
|
it { subject.must_be_instance_of(NilClass) }
|
168
176
|
end
|
169
177
|
end
|
170
178
|
|
171
179
|
describe '#show' do
|
180
|
+
let(:interface) {
|
181
|
+
Vedeu::Interface.new({ name: _name, visible: visible })
|
182
|
+
}
|
183
|
+
let(:_name) { 'Buffer#show' }
|
184
|
+
let(:visible) {}
|
185
|
+
|
186
|
+
before do
|
187
|
+
interface.store
|
188
|
+
Vedeu::Output.stubs(:render)
|
189
|
+
end
|
190
|
+
after do
|
191
|
+
Vedeu.interfaces.reset
|
192
|
+
end
|
193
|
+
|
172
194
|
subject { instance.show }
|
173
195
|
|
174
196
|
context 'when the interface is visible' do
|
175
|
-
|
176
|
-
|
197
|
+
let(:visible) { true }
|
198
|
+
|
199
|
+
it { subject.must_be_instance_of(NilClass) }
|
177
200
|
end
|
178
201
|
|
179
202
|
context 'when the interface is not visible' do
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
# after do
|
187
|
-
# Vedeu.interfaces.reset
|
188
|
-
# end
|
189
|
-
|
190
|
-
# let(:_name) { 'Buffer#show' }
|
191
|
-
# let(:interface) { Vedeu.interface('Buffer#show') {} }
|
192
|
-
|
193
|
-
# it {
|
194
|
-
# Vedeu::Visibility.expects(:show).with(interface)
|
195
|
-
# instance.expects(:render)
|
196
|
-
# subject
|
197
|
-
# }
|
203
|
+
let(:visible) { false }
|
204
|
+
|
205
|
+
it {
|
206
|
+
Vedeu::Visibility.expects(:show).with(interface)
|
207
|
+
subject
|
208
|
+
}
|
198
209
|
end
|
199
210
|
end
|
200
211
|
|
201
212
|
describe '#toggle' do
|
213
|
+
let(:interface) {
|
214
|
+
Vedeu::Interface.new({ name: _name, visible: visible })
|
215
|
+
}
|
216
|
+
let(:_name) { 'Buffer#toggle' }
|
217
|
+
let(:visible) {}
|
218
|
+
|
219
|
+
before do
|
220
|
+
interface.store
|
221
|
+
Vedeu::Output.stubs(:render)
|
222
|
+
end
|
223
|
+
after do
|
224
|
+
Vedeu.interfaces.reset
|
225
|
+
end
|
226
|
+
|
202
227
|
subject { instance.toggle }
|
203
228
|
|
204
229
|
context 'when the interface is visible' do
|
205
|
-
|
230
|
+
let(:visible) { true }
|
231
|
+
|
232
|
+
it {
|
233
|
+
Vedeu::Visibility.expects(:hide).with(interface)
|
234
|
+
subject
|
235
|
+
}
|
206
236
|
end
|
207
237
|
|
208
238
|
context 'when the interface is not visible' do
|
209
|
-
|
239
|
+
let(:visible) { false }
|
240
|
+
|
241
|
+
it {
|
242
|
+
Vedeu::Visibility.expects(:show).with(interface)
|
243
|
+
subject
|
244
|
+
}
|
210
245
|
end
|
211
246
|
end
|
212
247
|
|