vedeu 0.6.19 → 0.6.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/configuration.md +6 -4
- data/docs/dsl.md +23 -21
- data/docs/events/system.md +9 -9
- data/docs/getting_started.md +54 -48
- data/docs/object_graph.md +4 -4
- data/lib/vedeu/all.rb +1 -1
- data/lib/vedeu/api/external.rb +10 -10
- data/lib/vedeu/api/internal.rb +2 -2
- data/lib/vedeu/bindings/application.rb +5 -2
- data/lib/vedeu/bindings/bindings.rb +15 -2
- data/lib/vedeu/bindings/movement.rb +10 -5
- data/lib/vedeu/bindings/refresh.rb +1 -1
- data/lib/vedeu/bindings/system.rb +1 -1
- data/lib/vedeu/bindings/visibility.rb +20 -37
- data/lib/vedeu/cursors/cursor.rb +1 -14
- data/lib/vedeu/dsl/all.rb +0 -1
- data/lib/vedeu/dsl/interface.rb +1 -1
- data/lib/vedeu/esc/colours.rb +1 -1
- data/lib/vedeu/geometry/geometry.rb +19 -25
- data/lib/vedeu/groups/all.rb +16 -0
- data/lib/vedeu/{output/clear/group.rb → groups/clear.rb} +7 -7
- data/lib/vedeu/{dsl/group.rb → groups/dsl.rb} +10 -10
- data/lib/vedeu/{models → groups}/group.rb +14 -31
- data/lib/vedeu/{output/refresh/refresh_group.rb → groups/refresh.rb} +7 -7
- data/lib/vedeu/groups/repository.rb +24 -0
- data/lib/vedeu/models/all.rb +0 -2
- data/lib/vedeu/models/interface.rb +0 -12
- data/lib/vedeu/models/toggleable.rb +1 -1
- data/lib/vedeu/output/clear/all.rb +0 -1
- data/lib/vedeu/output/wordwrap.rb +3 -5
- data/lib/vedeu/repositories/model.rb +8 -1
- data/lib/vedeu/runtime/main_loop.rb +2 -2
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/api/external_test.rb +1 -1
- data/test/lib/vedeu/bindings/application_test.rb +1 -0
- data/test/lib/vedeu/bindings/bindings_test.rb +27 -0
- data/test/lib/vedeu/borders/border_test.rb +43 -37
- data/test/lib/vedeu/borders/render_test.rb +5 -1
- data/test/lib/vedeu/buffers/buffer_test.rb +9 -7
- data/test/lib/vedeu/cursors/cursor_test.rb +11 -9
- data/test/lib/vedeu/distributed/test_application_test.rb +18 -16
- data/test/lib/vedeu/dsl/interface_test.rb +2 -2
- data/test/lib/vedeu/editor/cursor_test.rb +18 -16
- data/test/lib/vedeu/editor/document_test.rb +7 -5
- data/test/lib/vedeu/esc/actions_test.rb +0 -2
- data/test/lib/vedeu/esc/borders_test.rb +0 -2
- data/test/lib/vedeu/esc/colours_test.rb +0 -2
- data/test/lib/vedeu/events/aliases_test.rb +1 -1
- data/test/lib/vedeu/geometry/area_test.rb +10 -8
- data/test/lib/vedeu/geometry/dsl_test.rb +2 -2
- data/test/lib/vedeu/geometry/geometry_test.rb +18 -30
- data/test/lib/vedeu/geometry/position_test.rb +6 -4
- data/test/lib/vedeu/{output/clear/group_test.rb → groups/clear_test.rb} +8 -8
- data/test/lib/vedeu/{dsl/group_test.rb → groups/dsl_test.rb} +8 -8
- data/test/lib/vedeu/{models → groups}/group_test.rb +12 -10
- data/test/lib/vedeu/{output/refresh/refresh_group_test.rb → groups/refresh_test.rb} +7 -7
- data/test/lib/vedeu/{models/groups_test.rb → groups/repository_test.rb} +6 -6
- data/test/lib/vedeu/menus/menu_test.rb +7 -5
- data/test/lib/vedeu/models/cell_test.rb +5 -3
- data/test/lib/vedeu/models/interface_test.rb +18 -42
- data/test/lib/vedeu/models/toggleable_test.rb +5 -3
- data/test/lib/vedeu/models/views/char_test.rb +8 -6
- data/test/lib/vedeu/models/views/composition_test.rb +6 -4
- data/test/lib/vedeu/models/views/line_test.rb +5 -3
- data/test/lib/vedeu/models/views/stream_test.rb +9 -7
- data/test/lib/vedeu/models/views/view_test.rb +30 -12
- data/test/lib/vedeu/output/presentation/style_test.rb +4 -2
- data/test/lib/vedeu/plugins/plugin_test.rb +8 -6
- data/test/lib/vedeu/repositories/collection_test.rb +8 -6
- data/test/lib/vedeu/runtime/application_test.rb +1 -1
- data/test/test_helper.rb +1 -0
- metadata +18 -17
- data/lib/vedeu/models/groups.rb +0 -24
@@ -19,6 +19,16 @@ module Vedeu
|
|
19
19
|
directional!
|
20
20
|
end
|
21
21
|
|
22
|
+
# @return [TrueClass]
|
23
|
+
def setup_aliases!
|
24
|
+
%w(down left right up).each do |direction|
|
25
|
+
Vedeu.bind_alias("_geometry_#{direction}_".to_sym,
|
26
|
+
"_view_#{direction}_".to_sym)
|
27
|
+
end
|
28
|
+
|
29
|
+
Vedeu.bind_alias(:_cursor_reset_, :_cursor_origin_)
|
30
|
+
end
|
31
|
+
|
22
32
|
private
|
23
33
|
|
24
34
|
# :nocov:
|
@@ -40,9 +50,6 @@ module Vedeu
|
|
40
50
|
Vedeu.trigger(:_clear_view_, name)
|
41
51
|
Vedeu.trigger(:_refresh_view_, name)
|
42
52
|
end
|
43
|
-
|
44
|
-
Vedeu.bind_alias("_geometry_#{direction}_".to_sym,
|
45
|
-
"_view_#{direction}_".to_sym)
|
46
53
|
end
|
47
54
|
end
|
48
55
|
|
@@ -51,8 +58,6 @@ module Vedeu
|
|
51
58
|
Vedeu.bind(:_cursor_origin_) do |name|
|
52
59
|
Vedeu.cursors.by_name(name).move_origin
|
53
60
|
end
|
54
|
-
|
55
|
-
Vedeu.bind_alias(:_cursor_reset_, :_cursor_origin_)
|
56
61
|
end
|
57
62
|
|
58
63
|
# See {file:docs/events/movement.md#\_cursor_position_}
|
@@ -28,92 +28,75 @@ module Vedeu
|
|
28
28
|
toggle_interface!
|
29
29
|
end
|
30
30
|
|
31
|
+
# @return [TrueClass]
|
32
|
+
def setup_aliases!
|
33
|
+
Vedeu.bind_alias(:_cursor_hide_, :_hide_cursor_)
|
34
|
+
|
35
|
+
Vedeu.bind_alias(:_cursor_show_, :_show_cursor_)
|
36
|
+
end
|
37
|
+
|
31
38
|
private
|
32
39
|
|
33
40
|
# :nocov:
|
34
41
|
|
35
|
-
# See {file:docs/events/visibility.md#\
|
42
|
+
# See {file:docs/events/visibility.md#\_clear_}
|
36
43
|
def clear!
|
37
|
-
Vedeu.bind(:_clear_) { Vedeu
|
44
|
+
Vedeu.bind(:_clear_) { Vedeu.clear }
|
38
45
|
end
|
39
46
|
|
40
47
|
# See {file:docs/events/visibility.md#\_clear_group_}
|
41
48
|
def clear_group!
|
42
|
-
Vedeu.bind(:_clear_group_) { |name| Vedeu
|
49
|
+
Vedeu.bind(:_clear_group_) { |name| Vedeu.clear_by_group(name) }
|
43
50
|
end
|
44
51
|
|
45
52
|
# See {file:docs/events/visibility.md#\_clear_view_}
|
46
53
|
def clear_view!
|
47
|
-
Vedeu.bind(:_clear_view_)
|
48
|
-
Vedeu::Clear::Interface.render(name)
|
49
|
-
end
|
54
|
+
Vedeu.bind(:_clear_view_) { |name| Vedeu.clear_by_name(name) }
|
50
55
|
end
|
51
56
|
|
52
57
|
# See {file:docs/events/visibility.md#\_hide_cursor_}
|
53
58
|
def hide_cursor!
|
54
|
-
Vedeu.bind(:_hide_cursor_)
|
55
|
-
Vedeu::Cursors::Cursor.hide_cursor(name)
|
56
|
-
end
|
57
|
-
|
58
|
-
Vedeu.bind_alias(:_cursor_hide_, :_hide_cursor_)
|
59
|
+
Vedeu.bind(:_hide_cursor_) { |name| Vedeu.hide_cursor(name) }
|
59
60
|
end
|
60
61
|
|
61
62
|
# See {file:docs/events/visibility.md#\_hide_group_}
|
62
63
|
def hide_group!
|
63
|
-
Vedeu.bind(:_hide_group_)
|
64
|
-
Vedeu::Models::Group.hide_group(name)
|
65
|
-
end
|
64
|
+
Vedeu.bind(:_hide_group_) { |name| Vedeu.hide_group(name) }
|
66
65
|
end
|
67
66
|
|
68
67
|
# See {file:docs/events/visibility.md#\_hide_interface_}
|
69
68
|
def hide_interface!
|
70
|
-
Vedeu.bind(:_hide_interface_)
|
71
|
-
Vedeu::Models::Interface.hide_interface(name)
|
72
|
-
end
|
69
|
+
Vedeu.bind(:_hide_interface_) { |name| Vedeu.hide_interface(name) }
|
73
70
|
end
|
74
71
|
|
75
72
|
# See {file:docs/events/visibility.md#\_show_cursor_}
|
76
73
|
def show_cursor!
|
77
|
-
Vedeu.bind(:_show_cursor_)
|
78
|
-
Vedeu::Cursors::Cursor.show_cursor(name)
|
79
|
-
end
|
80
|
-
|
81
|
-
Vedeu.bind_alias(:_cursor_show_, :_show_cursor_)
|
74
|
+
Vedeu.bind(:_show_cursor_) { |name| Vedeu.show_cursor(name) }
|
82
75
|
end
|
83
76
|
|
84
77
|
# See {file:docs/events/visibility.md#\_show_group_}
|
85
78
|
def show_group!
|
86
|
-
Vedeu.bind(:_show_group_)
|
87
|
-
Vedeu::Models::Group.show_group(name)
|
88
|
-
end
|
79
|
+
Vedeu.bind(:_show_group_) { |name| Vedeu.show_group(name) }
|
89
80
|
end
|
90
81
|
|
91
82
|
# See {file:docs/events/visibility.md#\_show_interface_}
|
92
83
|
def show_interface!
|
93
|
-
Vedeu.bind(:_show_interface_)
|
94
|
-
Vedeu::Models::Interface.show_interface(name)
|
95
|
-
end
|
84
|
+
Vedeu.bind(:_show_interface_) { |name| Vedeu.show_interface(name) }
|
96
85
|
end
|
97
86
|
|
98
87
|
# See {file:docs/events/visibility.md#\_toggle_cursor_}
|
99
88
|
def toggle_cursor!
|
100
|
-
Vedeu.bind(:_toggle_cursor_)
|
101
|
-
Vedeu::Cursors::Cursor.toggle_cursor(name)
|
102
|
-
end
|
89
|
+
Vedeu.bind(:_toggle_cursor_) { |name| Vedeu.toggle_cursor(name) }
|
103
90
|
end
|
104
91
|
|
105
92
|
# See {file:docs/events/visibility.md#\_toggle_group_}
|
106
93
|
def toggle_group!
|
107
|
-
Vedeu.bind(:_toggle_group_)
|
108
|
-
Vedeu::Models::Group.toggle_group(name)
|
109
|
-
end
|
94
|
+
Vedeu.bind(:_toggle_group_) { |name| Vedeu.toggle_group(name) }
|
110
95
|
end
|
111
96
|
|
112
97
|
# See {file:docs/events/visibility.md#\_toggle_interface_}
|
113
98
|
def toggle_interface!
|
114
|
-
Vedeu.bind(:_toggle_interface_)
|
115
|
-
Vedeu::Models::Interface.toggle_interface(name)
|
116
|
-
end
|
99
|
+
Vedeu.bind(:_toggle_interface_) { |name| Vedeu.toggle_interface(name) }
|
117
100
|
end
|
118
101
|
|
119
102
|
# :nocov:
|
data/lib/vedeu/cursors/cursor.rb
CHANGED
@@ -165,8 +165,7 @@ module Vedeu
|
|
165
165
|
alias_method :to_str, :to_s
|
166
166
|
|
167
167
|
# Hide a named cursor, or without a name, the cursor of the
|
168
|
-
# currently
|
169
|
-
# focussed interface.
|
168
|
+
# currently focussed interface.
|
170
169
|
#
|
171
170
|
# @example
|
172
171
|
# Vedeu.hide_cursor(name)
|
@@ -210,18 +209,6 @@ module Vedeu
|
|
210
209
|
render
|
211
210
|
end
|
212
211
|
|
213
|
-
# Toggle the visibility of the cursor with the given name.
|
214
|
-
#
|
215
|
-
# @example
|
216
|
-
# Vedeu.toggle_cursor(name)
|
217
|
-
#
|
218
|
-
# @return [Vedeu::Models::Escape]
|
219
|
-
def toggle
|
220
|
-
return hide if visible?
|
221
|
-
|
222
|
-
show
|
223
|
-
end
|
224
|
-
|
225
212
|
# @return [Fixnum] The column/character coordinate.
|
226
213
|
def x
|
227
214
|
@x = bx if @x < bx
|
data/lib/vedeu/dsl/all.rb
CHANGED
data/lib/vedeu/dsl/interface.rb
CHANGED
data/lib/vedeu/esc/colours.rb
CHANGED
@@ -123,11 +123,9 @@ module Vedeu
|
|
123
123
|
|
124
124
|
@maximised = true
|
125
125
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
work
|
126
|
+
store do
|
127
|
+
Vedeu.trigger(:_refresh_view_, name)
|
128
|
+
end
|
131
129
|
end
|
132
130
|
|
133
131
|
# Moves the geometry down by one row.
|
@@ -137,8 +135,7 @@ module Vedeu
|
|
137
135
|
def move_down
|
138
136
|
return self if yn + 1 > Vedeu.height
|
139
137
|
|
140
|
-
Vedeu::Geometry::Geometry.store(move_attributes
|
141
|
-
yn: yn + 1))
|
138
|
+
Vedeu::Geometry::Geometry.store(move_attributes(y: y + 1, yn: yn + 1))
|
142
139
|
end
|
143
140
|
|
144
141
|
# Moves the geometry left by one column.
|
@@ -148,8 +145,7 @@ module Vedeu
|
|
148
145
|
def move_left
|
149
146
|
return self if x - 1 < 1
|
150
147
|
|
151
|
-
Vedeu::Geometry::Geometry.store(move_attributes
|
152
|
-
xn: xn - 1))
|
148
|
+
Vedeu::Geometry::Geometry.store(move_attributes(x: x - 1, xn: xn - 1))
|
153
149
|
end
|
154
150
|
|
155
151
|
# Moves the geometry to the top left of the terminal.
|
@@ -158,10 +154,7 @@ module Vedeu
|
|
158
154
|
# @return [Vedeu::Geometry::Geometry]
|
159
155
|
def move_origin
|
160
156
|
Vedeu::Geometry::Geometry.store(
|
161
|
-
move_attributes
|
162
|
-
xn: (xn - x + 1),
|
163
|
-
y: 1,
|
164
|
-
yn: (yn - y + 1)))
|
157
|
+
move_attributes(x: 1, xn: (xn - x + 1), y: 1, yn: (yn - y + 1)))
|
165
158
|
end
|
166
159
|
|
167
160
|
# Moves the geometry right by one column.
|
@@ -171,8 +164,7 @@ module Vedeu
|
|
171
164
|
def move_right
|
172
165
|
return self if xn + 1 > Vedeu.width
|
173
166
|
|
174
|
-
Vedeu::Geometry::Geometry.store(move_attributes
|
175
|
-
xn: xn + 1))
|
167
|
+
Vedeu::Geometry::Geometry.store(move_attributes(x: x + 1, xn: xn + 1))
|
176
168
|
end
|
177
169
|
|
178
170
|
# Moves the geometry up by one column.
|
@@ -182,8 +174,7 @@ module Vedeu
|
|
182
174
|
def move_up
|
183
175
|
return self if y - 1 < 1
|
184
176
|
|
185
|
-
Vedeu::Geometry::Geometry.store(move_attributes
|
186
|
-
yn: yn - 1))
|
177
|
+
Vedeu::Geometry::Geometry.store(move_attributes(y: y - 1, yn: yn - 1))
|
187
178
|
end
|
188
179
|
|
189
180
|
# Will unmaximise the named interface geometry. Previously, when
|
@@ -203,11 +194,9 @@ module Vedeu
|
|
203
194
|
|
204
195
|
@maximised = false
|
205
196
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
work
|
197
|
+
store do
|
198
|
+
Vedeu.trigger(:_refresh_)
|
199
|
+
end
|
211
200
|
end
|
212
201
|
|
213
202
|
private
|
@@ -233,15 +222,20 @@ module Vedeu
|
|
233
222
|
}
|
234
223
|
end
|
235
224
|
|
225
|
+
# @param attrs [Hash<Symbol => Fixnum>]
|
226
|
+
# @option attrs x [Fixnum]
|
227
|
+
# @option attrs xn [Fixnum]
|
228
|
+
# @option attrs y [Fixnum]
|
229
|
+
# @option attrs yn [Fixnum]
|
236
230
|
# @return [Hash<Symbol => Boolean, Fixnum>]
|
237
|
-
def move_attributes
|
238
|
-
@attributes.merge(
|
231
|
+
def move_attributes(attrs = {})
|
232
|
+
@attributes.merge!(
|
239
233
|
centred: false,
|
240
234
|
maximised: false,
|
241
235
|
x: x,
|
242
236
|
xn: xn,
|
243
237
|
y: y,
|
244
|
-
yn: yn)
|
238
|
+
yn: yn).merge!(attrs)
|
245
239
|
end
|
246
240
|
|
247
241
|
# Returns the row/line start position for the interface.
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# Views can be combined together into a group for easier
|
4
|
+
# manipulation.
|
5
|
+
#
|
6
|
+
module Groups
|
7
|
+
|
8
|
+
end # Groups
|
9
|
+
|
10
|
+
end # Vedeu
|
11
|
+
|
12
|
+
require 'vedeu/groups/clear'
|
13
|
+
require 'vedeu/groups/dsl'
|
14
|
+
require 'vedeu/groups/group'
|
15
|
+
require 'vedeu/groups/refresh'
|
16
|
+
require 'vedeu/groups/repository'
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
module
|
3
|
+
module Groups
|
4
4
|
|
5
5
|
# Clear the interfaces belonging to the named group.
|
6
6
|
#
|
7
|
-
class
|
7
|
+
class Clear
|
8
8
|
|
9
9
|
class << self
|
10
10
|
|
@@ -23,17 +23,17 @@ module Vedeu
|
|
23
23
|
|
24
24
|
end # Eigenclass
|
25
25
|
|
26
|
-
# Return a new instance of Vedeu::Clear
|
26
|
+
# Return a new instance of Vedeu::Groups::Clear.
|
27
27
|
#
|
28
28
|
# @param name [String]
|
29
|
-
# @return [Vedeu::Clear
|
29
|
+
# @return [Vedeu::Groups::Clear]
|
30
30
|
def initialize(name)
|
31
31
|
@name = name
|
32
32
|
end
|
33
33
|
|
34
34
|
# @return [void]
|
35
35
|
def render
|
36
|
-
members.each { |name| Vedeu
|
36
|
+
members.each { |name| Vedeu.trigger(:_clear_view_, name) }
|
37
37
|
end
|
38
38
|
|
39
39
|
protected
|
@@ -49,8 +49,8 @@ module Vedeu
|
|
49
49
|
Vedeu.groups.by_name(name).members
|
50
50
|
end
|
51
51
|
|
52
|
-
end #
|
52
|
+
end # Clear
|
53
53
|
|
54
|
-
end #
|
54
|
+
end # Groups
|
55
55
|
|
56
56
|
end # Vedeu
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
module
|
3
|
+
module Groups
|
4
4
|
|
5
5
|
# Interfaces can be configured to be part of a named group. Once
|
6
6
|
# an interface is a member of group, the group can be affected by
|
@@ -13,7 +13,7 @@ module Vedeu
|
|
13
13
|
# showing or hiding the group would of course, show or hide the
|
14
14
|
# interfaces of that group.
|
15
15
|
#
|
16
|
-
class
|
16
|
+
class DSL
|
17
17
|
|
18
18
|
include Vedeu::DSL
|
19
19
|
|
@@ -55,18 +55,18 @@ module Vedeu
|
|
55
55
|
# @param name [String] The name of this group.
|
56
56
|
# @param block [Proc]
|
57
57
|
# @raise [Vedeu::Error::RequiresBlock]
|
58
|
-
# @return [Vedeu::
|
58
|
+
# @return [Vedeu::Groups::Group]
|
59
59
|
def self.group(name, &block)
|
60
60
|
fail Vedeu::Error::RequiresBlock unless block_given?
|
61
61
|
|
62
|
-
Vedeu::
|
62
|
+
Vedeu::Groups::Group.build(name: name, &block).store
|
63
63
|
end
|
64
64
|
|
65
|
-
# Returns an instance of DSL
|
65
|
+
# Returns an instance of Groups::DSL.
|
66
66
|
#
|
67
|
-
# @param model [Vedeu::
|
67
|
+
# @param model [Vedeu::Groups::Group]
|
68
68
|
# @param client [Object]
|
69
|
-
# @return [Vedeu::DSL
|
69
|
+
# @return [Vedeu::Groups::DSL]
|
70
70
|
def initialize(model, client = nil)
|
71
71
|
@model = model
|
72
72
|
@client = client
|
@@ -79,7 +79,7 @@ module Vedeu
|
|
79
79
|
# end
|
80
80
|
#
|
81
81
|
# @param interface_name [String]
|
82
|
-
# @return [Vedeu::
|
82
|
+
# @return [Vedeu::Groups::Group]
|
83
83
|
def add(interface_name)
|
84
84
|
model.add(interface_name)
|
85
85
|
end
|
@@ -98,8 +98,8 @@ module Vedeu
|
|
98
98
|
interface_names.each { |name| add(name) }
|
99
99
|
end
|
100
100
|
|
101
|
-
end #
|
101
|
+
end # DSL
|
102
102
|
|
103
|
-
end #
|
103
|
+
end # Groups
|
104
104
|
|
105
105
|
end # Vedeu
|