vedeu 0.6.6 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +0 -30
- data/lib/vedeu/all.rb +0 -1
- data/lib/vedeu/api.rb +5 -139
- data/lib/vedeu/application/application_controller.rb +12 -10
- data/lib/vedeu/application/application_helper.rb +3 -3
- data/lib/vedeu/application/application_view.rb +7 -6
- data/lib/vedeu/application/controller.rb +16 -10
- data/lib/vedeu/bindings/application.rb +6 -3
- data/lib/vedeu/bindings/bindings.rb +7 -6
- data/lib/vedeu/bindings/document.rb +18 -18
- data/lib/vedeu/bindings/drb.rb +12 -8
- data/lib/vedeu/bindings/focus.rb +12 -9
- data/lib/vedeu/bindings/menus.rb +12 -11
- data/lib/vedeu/bindings/movement.rb +23 -22
- data/lib/vedeu/bindings/refresh.rb +13 -10
- data/lib/vedeu/bindings/visibility.rb +10 -8
- data/lib/vedeu/borders/all.rb +26 -0
- data/lib/vedeu/borders/dsl.rb +1 -23
- data/lib/vedeu/buffers/all.rb +12 -0
- data/lib/vedeu/buffers/buffer.rb +1 -10
- data/lib/vedeu/buffers/refresh.rb +57 -0
- data/lib/vedeu/buffers/virtual_buffer.rb +1 -1
- data/lib/vedeu/cursors/all.rb +9 -0
- data/lib/vedeu/cursors/cursor.rb +16 -0
- data/lib/vedeu/dsl/interface.rb +4 -4
- data/lib/vedeu/events/aliases.rb +28 -9
- data/lib/vedeu/events/collection.rb +1 -0
- data/lib/vedeu/events/trigger.rb +5 -3
- data/lib/vedeu/geometry/all.rb +7 -0
- data/lib/vedeu/geometry/position.rb +2 -2
- data/lib/vedeu/input/editor/editor.rb +1 -1
- data/lib/vedeu/log/log.rb +6 -0
- data/lib/vedeu/log/timer.rb +2 -2
- data/lib/vedeu/models/focus.rb +3 -0
- data/lib/vedeu/models/group.rb +13 -0
- data/lib/vedeu/models/interface.rb +17 -1
- data/lib/vedeu/models/toggleable.rb +2 -1
- data/lib/vedeu/models/views/collections/chars.rb +1 -0
- data/lib/vedeu/models/views/collections/lines.rb +1 -0
- data/lib/vedeu/models/views/collections/streams.rb +1 -0
- data/lib/vedeu/models/views/collections/view_collection.rb +1 -0
- data/lib/vedeu/models/views/line.rb +2 -2
- data/lib/vedeu/null/generic.rb +27 -4
- data/lib/vedeu/null/interface.rb +1 -32
- data/lib/vedeu/null/menu.rb +1 -16
- data/lib/vedeu/null/view.rb +1 -33
- data/lib/vedeu/options.rb +3 -0
- data/lib/vedeu/output/clear/named_group.rb +5 -0
- data/lib/vedeu/output/clear/named_interface.rb +5 -0
- data/lib/vedeu/output/direct.rb +2 -2
- data/lib/vedeu/output/viewport.rb +1 -1
- data/lib/vedeu/refresh/refresh_group.rb +1 -1
- data/lib/vedeu/runtime/application.rb +3 -0
- data/lib/vedeu/terminal/terminal.rb +3 -0
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/buffers/refresh_test.rb +54 -0
- data/test/lib/vedeu/null/generic_test.rb +18 -0
- data/test/lib/vedeu/null/interface_test.rb +4 -30
- data/test/lib/vedeu/null/menu_test.rb +1 -18
- data/test/lib/vedeu/null/view_test.rb +6 -31
- data/{examples → test/support}/colour_support.sh +0 -0
- data/{examples → test/support/examples}/borders_app.rb +0 -0
- data/{examples → test/support/examples}/configuration_app.rb +0 -0
- data/{examples → test/support/examples}/drb_app.rb +0 -0
- data/{examples → test/support/examples}/editor_app.rb +0 -0
- data/{examples → test/support/examples}/focus_app.rb +0 -0
- data/{examples → test/support/examples}/hello_world.rb +0 -0
- data/{examples → test/support/examples}/material_colours_app.rb +0 -0
- data/{examples → test/support/examples}/material_colours_app_20150721.svg +0 -0
- data/{examples → test/support/examples}/typed_commands/command.erb +0 -0
- data/{examples → test/support/examples}/typed_commands/output.erb +0 -0
- data/{examples → test/support/examples}/typed_commands/status.erb +0 -0
- data/{examples → test/support/examples}/typed_commands/typed_commands_app.rb +0 -0
- data/{examples → test/support/examples}/view_templates_app/default.erb +0 -0
- data/{examples → test/support/examples}/view_templates_app/prune.erb +0 -0
- data/{examples → test/support/examples}/view_templates_app/view_templates_app.rb +0 -0
- data/{examples → test/support/examples}/view_templates_app/wrap.erb +0 -0
- metadata +38 -21
- data/lib/vedeu/refresh/refresh_buffer.rb +0 -53
- data/test/lib/vedeu/refresh/refresh_buffer_test.rb +0 -50
data/lib/vedeu/log/timer.rb
CHANGED
@@ -13,7 +13,7 @@ module Vedeu
|
|
13
13
|
#
|
14
14
|
# @param message [String]
|
15
15
|
# @param block [Proc]
|
16
|
-
# @return [void]
|
16
|
+
# @return [void] The return value of the executed block.
|
17
17
|
def timer(message = '', &block)
|
18
18
|
new(message).measure(&block)
|
19
19
|
end
|
@@ -32,7 +32,7 @@ module Vedeu
|
|
32
32
|
# Write an entry to the log file stating how long a section of code took in
|
33
33
|
# milliseconds. Useful for debugging performance.
|
34
34
|
#
|
35
|
-
# @return [void]
|
35
|
+
# @return [void] The return value of the executed block.
|
36
36
|
def measure
|
37
37
|
work = yield
|
38
38
|
|
data/lib/vedeu/models/focus.rb
CHANGED
@@ -46,6 +46,7 @@ module Vedeu
|
|
46
46
|
# to set the initially focussed interface.
|
47
47
|
#
|
48
48
|
# @example
|
49
|
+
# Vedeu.trigger(:_focus_by_name_, name)
|
49
50
|
# Vedeu.focus_by_name('name')
|
50
51
|
#
|
51
52
|
# @param name [String] The interface to focus; must be defined.
|
@@ -96,6 +97,7 @@ module Vedeu
|
|
96
97
|
# Put the next interface relative to the current interfaces in focus.
|
97
98
|
#
|
98
99
|
# @example
|
100
|
+
# Vedeu.trigger(:_focus_next_)
|
99
101
|
# Vedeu.focus_next
|
100
102
|
#
|
101
103
|
# @return [String]
|
@@ -125,6 +127,7 @@ module Vedeu
|
|
125
127
|
# Put the previous interface relative to the current interface in focus.
|
126
128
|
#
|
127
129
|
# @example
|
130
|
+
# Vedeu.trigger(:_focus_prev_)
|
128
131
|
# Vedeu.focus_previous
|
129
132
|
#
|
130
133
|
# @return [String]
|
data/lib/vedeu/models/group.rb
CHANGED
@@ -124,6 +124,19 @@ module Vedeu
|
|
124
124
|
self
|
125
125
|
end
|
126
126
|
|
127
|
+
# Toggle the visibility of the group with the given name.
|
128
|
+
#
|
129
|
+
# @example
|
130
|
+
# Vedeu.trigger(:_toggle_group, name)
|
131
|
+
# Vedeu.toggle_group(name)
|
132
|
+
#
|
133
|
+
# @return [Vedeu::Group]
|
134
|
+
def toggle
|
135
|
+
super
|
136
|
+
|
137
|
+
self
|
138
|
+
end
|
139
|
+
|
127
140
|
private
|
128
141
|
|
129
142
|
# Returns the default options/attributes for this class.
|
@@ -22,7 +22,7 @@ module Vedeu
|
|
22
22
|
attr_accessor :delay
|
23
23
|
|
24
24
|
# @!attribute [rw] group
|
25
|
-
# @return [
|
25
|
+
# @return [Symbol|String]
|
26
26
|
attr_accessor :group
|
27
27
|
|
28
28
|
# @!attribute [rw] name
|
@@ -83,6 +83,22 @@ module Vedeu
|
|
83
83
|
Vedeu.buffers.by_name(name).show
|
84
84
|
end
|
85
85
|
|
86
|
+
# Toggle the visibility of the interface with the given name.
|
87
|
+
#
|
88
|
+
# @example
|
89
|
+
# Vedeu.toggle_interface(name)
|
90
|
+
#
|
91
|
+
# @return [void]
|
92
|
+
def toggle
|
93
|
+
if visible?
|
94
|
+
hide
|
95
|
+
|
96
|
+
else
|
97
|
+
show
|
98
|
+
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
86
102
|
private
|
87
103
|
|
88
104
|
# The default values for a new instance of this class.
|
data/lib/vedeu/null/generic.rb
CHANGED
@@ -6,6 +6,14 @@ module Vedeu
|
|
6
6
|
#
|
7
7
|
class Generic
|
8
8
|
|
9
|
+
# @!attribute [r] attributes
|
10
|
+
# @return [String]
|
11
|
+
attr_reader :attributes
|
12
|
+
|
13
|
+
# @!attribute [r] name
|
14
|
+
# @return [String]
|
15
|
+
attr_reader :name
|
16
|
+
|
9
17
|
# Returns an instance of the Vedeu::Null::Generic class.
|
10
18
|
#
|
11
19
|
# @param attributes [Hash<Symbol => void>]
|
@@ -20,10 +28,25 @@ module Vedeu
|
|
20
28
|
def null(*)
|
21
29
|
nil
|
22
30
|
end
|
23
|
-
alias_method :add,
|
24
|
-
alias_method :
|
25
|
-
alias_method :
|
26
|
-
alias_method :
|
31
|
+
alias_method :add, :null
|
32
|
+
alias_method :bottom_item, :null
|
33
|
+
alias_method :colour, :null
|
34
|
+
alias_method :current_item, :null
|
35
|
+
alias_method :deselect_item, :null
|
36
|
+
alias_method :hide, :null
|
37
|
+
alias_method :item, :null
|
38
|
+
alias_method :items, :null
|
39
|
+
alias_method :next_item, :null
|
40
|
+
alias_method :parent, :null
|
41
|
+
alias_method :prev_item, :null
|
42
|
+
alias_method :select_item, :null
|
43
|
+
alias_method :selected_item, :null
|
44
|
+
alias_method :show, :null
|
45
|
+
alias_method :style, :null
|
46
|
+
alias_method :toggle, :null
|
47
|
+
alias_method :top_item, :null
|
48
|
+
alias_method :view, :null
|
49
|
+
alias_method :zindex, :null
|
27
50
|
|
28
51
|
# @return [Boolean]
|
29
52
|
def null?
|
data/lib/vedeu/null/interface.rb
CHANGED
@@ -6,23 +6,14 @@ module Vedeu
|
|
6
6
|
|
7
7
|
# Provides a non-existent model to swallow messages.
|
8
8
|
#
|
9
|
-
class Interface
|
9
|
+
class Interface < Vedeu::Null::Generic
|
10
10
|
|
11
11
|
include Vedeu::Presentation
|
12
12
|
|
13
|
-
# @!attribute [r] name
|
14
|
-
# @return [String]
|
15
|
-
attr_reader :name
|
16
|
-
|
17
13
|
# @!attribute [r] attributes
|
18
14
|
# @return [String]
|
19
15
|
attr_reader :attributes
|
20
16
|
|
21
|
-
# @!attribute [rw] visible
|
22
|
-
# @return [String]
|
23
|
-
attr_accessor :visible
|
24
|
-
alias_method :visible?, :visible
|
25
|
-
|
26
17
|
# Returns a new instance of Vedeu::Null::Interface.
|
27
18
|
#
|
28
19
|
# @param attributes [Hash<Symbol => void>]
|
@@ -34,28 +25,6 @@ module Vedeu
|
|
34
25
|
@visible = false
|
35
26
|
end
|
36
27
|
|
37
|
-
# @return [NilClass]
|
38
|
-
def null
|
39
|
-
nil
|
40
|
-
end
|
41
|
-
alias_method :hide, :null
|
42
|
-
alias_method :parent, :null
|
43
|
-
alias_method :show, :null
|
44
|
-
alias_method :toggle, :null
|
45
|
-
alias_method :zindex, :null
|
46
|
-
|
47
|
-
# @return [Boolean]
|
48
|
-
def null?
|
49
|
-
true
|
50
|
-
end
|
51
|
-
|
52
|
-
# Pretend to store this model in the repository.
|
53
|
-
#
|
54
|
-
# @return [Vedeu::Null::Interface]
|
55
|
-
def store
|
56
|
-
self
|
57
|
-
end
|
58
|
-
|
59
28
|
end # Interface
|
60
29
|
|
61
30
|
end # Null
|
data/lib/vedeu/null/menu.rb
CHANGED
@@ -4,7 +4,7 @@ module Vedeu
|
|
4
4
|
|
5
5
|
# Provides a non-existent model to swallow messages.
|
6
6
|
#
|
7
|
-
class Menu
|
7
|
+
class Menu < Vedeu::Null::Generic
|
8
8
|
|
9
9
|
# Returns an instance of the Vedeu::Null::Menu class.
|
10
10
|
#
|
@@ -16,21 +16,6 @@ module Vedeu
|
|
16
16
|
@name = @attributes[:name]
|
17
17
|
end
|
18
18
|
|
19
|
-
# @return [NilClass]
|
20
|
-
def item
|
21
|
-
nil
|
22
|
-
end
|
23
|
-
alias_method :bottom_item, :item
|
24
|
-
alias_method :current_item, :item
|
25
|
-
alias_method :deselect_item, :item
|
26
|
-
alias_method :items, :item
|
27
|
-
alias_method :next_item, :item
|
28
|
-
alias_method :prev_item, :item
|
29
|
-
alias_method :select_item, :item
|
30
|
-
alias_method :selected_item, :item
|
31
|
-
alias_method :top_item, :item
|
32
|
-
alias_method :view, :item
|
33
|
-
|
34
19
|
end # Menu
|
35
20
|
|
36
21
|
end # Null
|
data/lib/vedeu/null/view.rb
CHANGED
@@ -6,23 +6,10 @@ module Vedeu
|
|
6
6
|
|
7
7
|
# Provides a non-existent model to swallow messages.
|
8
8
|
#
|
9
|
-
class View
|
9
|
+
class View < Vedeu::Null::Generic
|
10
10
|
|
11
11
|
include Vedeu::Presentation
|
12
12
|
|
13
|
-
# @!attribute [r] name,
|
14
|
-
# @return [String]
|
15
|
-
attr_reader :name
|
16
|
-
|
17
|
-
# @!attribute [r] attributes
|
18
|
-
# @return [String]
|
19
|
-
attr_reader :attributes
|
20
|
-
|
21
|
-
# @!attribute [rw] visible
|
22
|
-
# @return [String]
|
23
|
-
attr_accessor :visible
|
24
|
-
alias_method :visible?, :visible
|
25
|
-
|
26
13
|
# Returns a new instance of Vedeu::Null::View.
|
27
14
|
#
|
28
15
|
# @param attributes [Hash<Symbol => void>]
|
@@ -34,25 +21,6 @@ module Vedeu
|
|
34
21
|
@visible = false
|
35
22
|
end
|
36
23
|
|
37
|
-
# @return [NilClass]
|
38
|
-
def null
|
39
|
-
nil
|
40
|
-
end
|
41
|
-
alias_method :parent, :null
|
42
|
-
alias_method :zindex, :null
|
43
|
-
|
44
|
-
# @return [Boolean]
|
45
|
-
def null?
|
46
|
-
true
|
47
|
-
end
|
48
|
-
|
49
|
-
# Pretend to store this model in the repository.
|
50
|
-
#
|
51
|
-
# @return [Vedeu::Null::View]
|
52
|
-
def store
|
53
|
-
self
|
54
|
-
end
|
55
|
-
|
56
24
|
end # View
|
57
25
|
|
58
26
|
end # Null
|
data/lib/vedeu/options.rb
CHANGED
data/lib/vedeu/output/direct.rb
CHANGED
@@ -7,7 +7,7 @@ module Vedeu
|
|
7
7
|
# @param value [String]
|
8
8
|
# @param x [Fixnum]
|
9
9
|
# @param y [Fixnum]
|
10
|
-
# @return [
|
10
|
+
# @return [String]
|
11
11
|
def self.write(value:, x:, y:)
|
12
12
|
new(value: value, x: x, y: y).write
|
13
13
|
end
|
@@ -24,7 +24,7 @@ module Vedeu
|
|
24
24
|
@y = y || 1
|
25
25
|
end
|
26
26
|
|
27
|
-
# @return [
|
27
|
+
# @return [String]
|
28
28
|
def write
|
29
29
|
Vedeu::Terminal.output(output)
|
30
30
|
|
@@ -129,7 +129,7 @@ module Vedeu
|
|
129
129
|
# @param dimension [Fixnum] Either the height or width.
|
130
130
|
# @return [Fixnum]
|
131
131
|
def content_offset(offset, dimension)
|
132
|
-
if offset >= dimension
|
132
|
+
if offset >= dimension
|
133
133
|
offset - dimension
|
134
134
|
|
135
135
|
else
|
data/lib/vedeu/version.rb
CHANGED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Buffers
|
6
|
+
|
7
|
+
describe Refresh do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Buffers::Refresh }
|
10
|
+
let(:instance) { described.new(_name) }
|
11
|
+
let(:_name) { 'Vedeu::Buffers::Refresh' }
|
12
|
+
|
13
|
+
describe '#initialize' do
|
14
|
+
it { instance.must_be_instance_of(described) }
|
15
|
+
it { instance.instance_variable_get('@name').must_equal(_name) }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.by_name' do
|
19
|
+
subject { described.by_name(_name) }
|
20
|
+
|
21
|
+
context 'when the name is not present' do
|
22
|
+
let(:_name) { '' }
|
23
|
+
|
24
|
+
it { proc { subject }.must_raise(Vedeu::Error::MissingRequired) }
|
25
|
+
end
|
26
|
+
|
27
|
+
# describe '.by_name' do
|
28
|
+
# let(:_name) { 'aluminium' }
|
29
|
+
# let(:buffer) { Vedeu::Buffers::Null.new(name: _name) }
|
30
|
+
#
|
31
|
+
# subject { described.by_name(_name) }
|
32
|
+
#
|
33
|
+
# it {
|
34
|
+
# Vedeu.buffers.expects(:by_name).with(_name).returns(buffer)
|
35
|
+
# buffer.expects(:render)
|
36
|
+
# subject
|
37
|
+
# }
|
38
|
+
# end
|
39
|
+
|
40
|
+
context 'when the name is present' do
|
41
|
+
# @todo Add more tests.
|
42
|
+
# it { skip }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#by_name' do
|
47
|
+
it { instance.must_respond_to(:by_name) }
|
48
|
+
end
|
49
|
+
|
50
|
+
end # Refresh
|
51
|
+
|
52
|
+
end # Buffers
|
53
|
+
|
54
|
+
end # Vedeu
|