vedeu 0.4.58 → 0.4.59
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +0 -558
- data/README.md +2 -0
- data/docs/dsl.md +66 -54
- data/lib/vedeu/all.rb +44 -16
- data/lib/vedeu/api.rb +0 -2
- data/lib/vedeu/bindings/drb.rb +0 -1
- data/lib/vedeu/bindings/menus.rb +0 -1
- data/lib/vedeu/bindings/movement.rb +0 -1
- data/lib/vedeu/bindings/system.rb +0 -1
- data/lib/vedeu/bindings/visibility.rb +0 -1
- data/lib/vedeu/bootstrap.rb +2 -2
- data/lib/vedeu/buffers/buffers.rb +0 -4
- data/lib/vedeu/cli/generator/all.rb +0 -4
- data/lib/vedeu/cli/generator/helpers.rb +0 -2
- data/lib/vedeu/cli/generator/templates/application/application.erb +8 -5
- data/lib/vedeu/cli/generator/view.rb +4 -2
- data/lib/vedeu/cli/main.rb +0 -2
- data/lib/vedeu/colours/backgrounds.rb +0 -1
- data/lib/vedeu/colours/colours.rb +0 -1
- data/lib/vedeu/colours/foregrounds.rb +0 -1
- data/lib/vedeu/configuration/api.rb +19 -6
- data/lib/vedeu/configuration/cli.rb +9 -1
- data/lib/vedeu/configuration/configuration.rb +9 -0
- data/lib/vedeu/cursor/cursor.rb +0 -2
- data/lib/vedeu/cursor/cursors.rb +0 -3
- data/lib/vedeu/debug.rb +0 -1
- data/lib/vedeu/dsl.rb +0 -1
- data/lib/vedeu/dsl/border.rb +69 -106
- data/lib/vedeu/dsl/composition.rb +1 -2
- data/lib/vedeu/dsl/geometry.rb +102 -67
- data/lib/vedeu/dsl/group.rb +21 -9
- data/lib/vedeu/dsl/interface.rb +0 -1
- data/lib/vedeu/dsl/keymap.rb +26 -36
- data/lib/vedeu/dsl/line.rb +5 -10
- data/lib/vedeu/dsl/menu.rb +7 -13
- data/lib/vedeu/dsl/presentation.rb +0 -1
- data/lib/vedeu/dsl/stream.rb +0 -1
- data/lib/vedeu/dsl/text.rb +0 -1
- data/lib/vedeu/dsl/use.rb +0 -1
- data/lib/vedeu/dsl/view.rb +28 -31
- data/lib/vedeu/events/event.rb +0 -3
- data/lib/vedeu/events/events.rb +0 -1
- data/lib/vedeu/events/trigger.rb +0 -1
- data/lib/vedeu/geometry/geometries.rb +0 -4
- data/lib/vedeu/geometry/geometry.rb +0 -2
- data/lib/vedeu/geometry/grid.rb +2 -25
- data/lib/vedeu/input/keymap.rb +0 -3
- data/lib/vedeu/input/keymaps.rb +0 -3
- data/lib/vedeu/launcher.rb +0 -1
- data/lib/vedeu/log.rb +0 -1
- data/lib/vedeu/models/char.rb +0 -5
- data/lib/vedeu/models/group.rb +0 -2
- data/lib/vedeu/models/groups.rb +0 -3
- data/lib/vedeu/models/interface.rb +0 -19
- data/lib/vedeu/models/interfaces.rb +0 -4
- data/lib/vedeu/models/menus.rb +0 -3
- data/lib/vedeu/null/interface.rb +6 -7
- data/lib/vedeu/output/border.rb +0 -2
- data/lib/vedeu/output/borders.rb +0 -4
- data/lib/vedeu/output/esc.rb +0 -1
- data/lib/vedeu/output/html_char.rb +0 -2
- data/lib/vedeu/output/refresh.rb +0 -3
- data/lib/vedeu/output/refresh_group.rb +0 -2
- data/lib/vedeu/output/renderers.rb +0 -13
- data/lib/vedeu/repositories.rb +2 -15
- data/lib/vedeu/repositories/model.rb +0 -2
- data/lib/vedeu/repositories/repository.rb +0 -2
- data/lib/vedeu/templating/template.rb +0 -2
- data/lib/vedeu/terminal.rb +0 -3
- data/lib/vedeu/timer.rb +0 -1
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/bootstrap_test.rb +8 -1
- data/test/lib/vedeu/configuration/api_test.rb +14 -0
- data/test/lib/vedeu/configuration/cli_test.rb +15 -0
- data/test/lib/vedeu/cursor/cursor_test.rb +0 -1
- data/test/lib/vedeu/models/interface_test.rb +12 -4
- data/test/lib/vedeu/null/interface_test.rb +3 -12
- data/test/support/helpers/model_test_class.rb +0 -3
- data/test/test_helper.rb +0 -2
- data/vedeu.gemspec +1 -1
- metadata +4 -4
data/lib/vedeu/dsl/geometry.rb
CHANGED
@@ -2,19 +2,61 @@ module Vedeu
|
|
2
2
|
|
3
3
|
module DSL
|
4
4
|
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# Geometry for Vedeu, as the same for ANSI terminals, has the origin at
|
5
|
+
# Geometry allows the configuration of the position and size of an
|
6
|
+
# interface. Within Vedeu, as the same for ANSI terminals, has the origin at
|
8
7
|
# top-left, y = 1, x = 1. The 'y' coordinate is deliberately first.
|
9
8
|
#
|
10
|
-
#
|
9
|
+
# The Geometry DSL can be used within the Interface DSL or standalone. Here
|
10
|
+
# are example of declarations for a `geometry` block:
|
11
|
+
#
|
12
|
+
# A standalone geometry definition:
|
11
13
|
#
|
12
14
|
# Vedeu.geometry 'some_interface' do
|
13
|
-
# #
|
15
|
+
# height 5 # Sets the height of the view to 5
|
16
|
+
# width 20 # Sets the width of the view to 20
|
17
|
+
# x 3 # Start drawing 3 spaces from left
|
18
|
+
# y 10 # Start drawing 10 spaces from top
|
19
|
+
# xn 30 # Stop drawing 30 spaces from the left
|
20
|
+
# yn 20 # Stop drawing 20 spaces from top
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# An interface including a geometry definition:
|
24
|
+
#
|
25
|
+
# Vedeu.interface 'some_interface' do
|
26
|
+
# geometry do
|
27
|
+
# height 5
|
28
|
+
# width 20
|
29
|
+
# x 3
|
30
|
+
# y 10
|
31
|
+
# xn 30
|
32
|
+
# yn 20
|
33
|
+
# end
|
34
|
+
# # ... some code here
|
35
|
+
# end
|
36
|
+
#
|
37
|
+
# If a declaration is omitted for `height` or `width` the full remaining
|
38
|
+
# space available in the terminal will be used. `x` and `y` both default to
|
39
|
+
# 1.
|
40
|
+
#
|
41
|
+
# You can also make a geometry declaration dependent on another view:
|
42
|
+
#
|
43
|
+
# Vedeu.interface 'other_panel' do
|
44
|
+
# # ... some code here
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
# Vedeu.interface 'main' do
|
48
|
+
# geometry do
|
49
|
+
# height 10
|
50
|
+
# y { use('other_panel').south }
|
51
|
+
# end
|
52
|
+
# # ... some code here
|
14
53
|
# end
|
15
54
|
#
|
16
|
-
#
|
17
|
-
#
|
55
|
+
#
|
56
|
+
# This view will begin just below "other\_panel".
|
57
|
+
#
|
58
|
+
# This crude ASCII diagram represents a Geometry within Vedeu, each of the
|
59
|
+
# labels is a value you can access or define.
|
18
60
|
#
|
19
61
|
# x north xn # north: y - 1
|
20
62
|
# y +--------------+ # top: y
|
@@ -26,7 +68,6 @@ module Vedeu
|
|
26
68
|
# yn +--------------+ # south: yn + 1
|
27
69
|
# south
|
28
70
|
#
|
29
|
-
# @api public
|
30
71
|
class Geometry
|
31
72
|
|
32
73
|
include Vedeu::DSL
|
@@ -34,7 +75,6 @@ module Vedeu
|
|
34
75
|
|
35
76
|
# Specify the geometry of an interface or view with a simple DSL.
|
36
77
|
#
|
37
|
-
# @example
|
38
78
|
# Vedeu.geometry 'some_interface' do
|
39
79
|
# # ...
|
40
80
|
# end
|
@@ -63,20 +103,16 @@ module Vedeu
|
|
63
103
|
# Instructs Vedeu to calculate x and y geometry automatically based on the
|
64
104
|
# centre character of the terminal, the width and the height.
|
65
105
|
#
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#
|
69
|
-
# @example
|
70
|
-
# geometry 'some_interface' do
|
71
|
-
# centred!
|
72
|
-
# # ...
|
73
|
-
# end
|
106
|
+
# Vedeu.geometry 'some_interface' do
|
107
|
+
# centred false # or...
|
74
108
|
#
|
75
|
-
#
|
76
|
-
# centred
|
77
|
-
# # ...
|
109
|
+
# centred true # or...
|
110
|
+
# centred! # or...
|
111
|
+
# # ... some code
|
78
112
|
# end
|
79
113
|
#
|
114
|
+
# @param value [Boolean] Any value other than nil or false will evaluate
|
115
|
+
# to true.
|
80
116
|
# @return [Boolean]
|
81
117
|
def centred(value = true)
|
82
118
|
boolean = value ? true : false
|
@@ -85,46 +121,65 @@ module Vedeu
|
|
85
121
|
end
|
86
122
|
alias_method :centred!, :centred
|
87
123
|
|
88
|
-
#
|
124
|
+
# Returns the width in characters for the number of columns specified.
|
125
|
+
#
|
126
|
+
# Vedeu.geometry 'main_interface' do
|
127
|
+
# # ... some code
|
128
|
+
# width columns(9) # Vedeu.width # => 92 (for example)
|
129
|
+
# # 92 / 12 = 7
|
130
|
+
# # 7 * 9 = 63
|
131
|
+
# # Therefore, width is 63 characters.
|
132
|
+
# end
|
133
|
+
#
|
134
|
+
# @param value [Fixnum]
|
135
|
+
# @raise [Vedeu::OutOfRange] When the value parameter is not between 1 and
|
136
|
+
# 12 inclusive.
|
137
|
+
# @return [Fixnum|Vedeu::OutOfRange]
|
89
138
|
def columns(value)
|
90
139
|
Vedeu::Grid.columns(value)
|
91
140
|
end
|
92
141
|
|
93
142
|
# Specify the number of characters/rows/lines tall the interface will be.
|
143
|
+
# This value will be ignored if by `y` and `yn` are set.
|
94
144
|
#
|
95
|
-
#
|
96
|
-
# geometry 'some_interface' do
|
145
|
+
# Vedeu.geometry 'some_interface' do
|
97
146
|
# height 8
|
98
|
-
# # ...
|
147
|
+
# # ... some code
|
99
148
|
# end
|
100
149
|
#
|
101
|
-
# @note
|
102
|
-
# This value will be ignored if by `y` and `yn` are set.
|
103
|
-
#
|
104
150
|
# @param value [Fixnum]
|
105
151
|
# @return [Fixnum]
|
106
152
|
def height(value)
|
107
153
|
model.height = value
|
108
154
|
end
|
109
155
|
|
110
|
-
#
|
156
|
+
# Returns the height in characters for the number of rows specified.
|
157
|
+
#
|
158
|
+
# Vedeu.geometry 'main_interface' do
|
159
|
+
# # ... some code
|
160
|
+
# height rows(3) # Vedeu.height # => 38 (for example)
|
161
|
+
# # 38 / 12 = 3
|
162
|
+
# # 3 * 3 = 9
|
163
|
+
# # Therefore, height is 9 characters.
|
164
|
+
# end
|
165
|
+
#
|
166
|
+
# @param value [Fixnum]
|
167
|
+
# @raise [Vedeu::OutOfRange] When the value parameter is not between 1 and
|
168
|
+
# 12 inclusive.
|
169
|
+
# @return [Fixnum]
|
111
170
|
def rows(value)
|
112
171
|
Vedeu::Grid.rows(value)
|
113
172
|
end
|
114
173
|
|
115
174
|
# Specify the number of characters/columns wide the interface will be.
|
175
|
+
# This value will be ignored if by `x` and `xn` are set.
|
116
176
|
#
|
117
|
-
#
|
118
|
-
#
|
119
|
-
# @example
|
120
|
-
# geometry 'some_interface' do
|
177
|
+
# Vedeu.geometry 'some_interface' do
|
121
178
|
# width 25
|
122
|
-
# # ...
|
179
|
+
# # ... some code
|
123
180
|
# end
|
124
181
|
#
|
125
|
-
# @
|
126
|
-
# This value will be ignored if by `x` and `xn` are set.
|
127
|
-
#
|
182
|
+
# @param value [Fixnum]
|
128
183
|
# @return [Fixnum]
|
129
184
|
def width(value)
|
130
185
|
model.width = value
|
@@ -132,15 +187,11 @@ module Vedeu
|
|
132
187
|
|
133
188
|
# Specify the starting x position (column) of the interface.
|
134
189
|
#
|
135
|
-
#
|
136
|
-
# geometry 'some_interface' do
|
190
|
+
# Vedeu.geometry 'some_interface' do
|
137
191
|
# x 7 # start on column 7.
|
138
|
-
# # ...
|
139
|
-
# end
|
140
192
|
#
|
141
|
-
# geometry 'some_interface' do
|
142
193
|
# x { use('other_interface').east } # start on column 8, if
|
143
|
-
# # ...
|
194
|
+
# # ... some code # `other_interface` changes
|
144
195
|
# end # position, `some_interface` will
|
145
196
|
# # too.
|
146
197
|
#
|
@@ -154,21 +205,15 @@ module Vedeu
|
|
154
205
|
end
|
155
206
|
|
156
207
|
# Specify the ending x position (column) of the interface.
|
208
|
+
# This value will override `width`.
|
157
209
|
#
|
158
|
-
#
|
159
|
-
# geometry 'some_interface' do
|
210
|
+
# Vedeu.geometry 'some_interface' do
|
160
211
|
# xn 37 # end at column 37.
|
161
|
-
# # ...
|
162
|
-
# end
|
163
212
|
#
|
164
|
-
# geometry 'some_interface' do
|
165
213
|
# xn { use('other_interface').right } # if `other_interface` changes
|
166
|
-
# # ...
|
214
|
+
# # ... some code # position, `some_interface`
|
167
215
|
# end # will too.
|
168
216
|
#
|
169
|
-
# @note
|
170
|
-
# This value will override `width`.
|
171
|
-
#
|
172
217
|
# @param value [Fixnum]
|
173
218
|
# @param block [Proc]
|
174
219
|
# @return [Fixnum]
|
@@ -180,15 +225,11 @@ module Vedeu
|
|
180
225
|
|
181
226
|
# Specify the starting y position (row/line) of the interface.
|
182
227
|
#
|
183
|
-
#
|
184
|
-
#
|
185
|
-
# y 4
|
186
|
-
# # ...
|
187
|
-
# end
|
228
|
+
# Vedeu.geometry 'some_interface' do
|
229
|
+
# y 4 # start at row 4
|
188
230
|
#
|
189
|
-
# geometry 'some_interface' do
|
190
231
|
# y { use('other_interface').north } # start on row/line 3, if
|
191
|
-
# # ...
|
232
|
+
# # ... some code # `other_interface` changes
|
192
233
|
# end # position, `some_interface`
|
193
234
|
# # will too.
|
194
235
|
#
|
@@ -202,21 +243,15 @@ module Vedeu
|
|
202
243
|
end
|
203
244
|
|
204
245
|
# Specify the ending y position (row/line) of the interface.
|
246
|
+
# This value will override `height`.
|
205
247
|
#
|
206
|
-
#
|
207
|
-
# geometry 'some_interface' do
|
248
|
+
# Vedeu.geometry 'some_interface' do
|
208
249
|
# yn 24 # end at row 24.
|
209
|
-
# # ...
|
210
|
-
# end
|
211
250
|
#
|
212
|
-
# geometry 'some_interface' do
|
213
251
|
# yn { use('other_interface').bottom } # if `other_interface` changes
|
214
|
-
# # ...
|
252
|
+
# # ... some code # position, `some_interface`
|
215
253
|
# end # will too.
|
216
254
|
#
|
217
|
-
# @note
|
218
|
-
# This value will override `height`.
|
219
|
-
#
|
220
255
|
# @param value [Fixnum]
|
221
256
|
# @param block [Proc]
|
222
257
|
# @return [Fixnum]
|
data/lib/vedeu/dsl/group.rb
CHANGED
@@ -2,34 +2,42 @@ module Vedeu
|
|
2
2
|
|
3
3
|
module DSL
|
4
4
|
|
5
|
-
#
|
5
|
+
# Interfaces can be configured to be part of a named group. Once an
|
6
|
+
# interface is a member of group, the group can be affected by other
|
7
|
+
# controls. For example, assuming the client application is a simple Git
|
8
|
+
# client, it may have a group called 'commit'. The 'commit' group will
|
9
|
+
# contain the interfaces 'diff' (to show the changes), 'staged' (to show
|
10
|
+
# which files are staged) and 'unstaged'. A refresh of the 'commit' group
|
11
|
+
# would cause all interfaces belonging to the group to refresh. Similarly,
|
12
|
+
# showing or hiding the group would of course, show or hide the interfaces
|
13
|
+
# of that group.
|
6
14
|
#
|
7
|
-
# @api public
|
8
15
|
class Group
|
9
16
|
|
10
17
|
include Vedeu::DSL
|
11
18
|
|
12
|
-
# Specify a new group of interfaces with a simple DSL.
|
19
|
+
# Specify a new group of interfaces with a simple DSL. Creating a group
|
20
|
+
# with the same name as an existing group overwrites the existing group.
|
13
21
|
#
|
14
22
|
# The example below resembles 'vim' (the popular terminal-based text
|
15
23
|
# editor):
|
16
24
|
#
|
17
|
-
# @example
|
18
25
|
# Vedeu.group 'title_screen' do
|
19
26
|
# add 'welcome_interface'
|
20
|
-
# # ...
|
27
|
+
# # ... some code
|
21
28
|
# end
|
22
29
|
#
|
23
30
|
# Vedeu.group 'main_screen' do
|
24
31
|
# add 'editor_interface'
|
25
32
|
# add 'status_interface'
|
26
33
|
# add 'command_interface'
|
27
|
-
# # ...
|
34
|
+
# # ... some code
|
28
35
|
# end
|
29
36
|
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
37
|
+
# Vedeu.interface 'some_interface' do
|
38
|
+
# group 'some_group'
|
39
|
+
# # ... some code
|
40
|
+
# end
|
33
41
|
#
|
34
42
|
# @param name [String] The name of this group.
|
35
43
|
# @param block [Proc]
|
@@ -53,6 +61,10 @@ module Vedeu
|
|
53
61
|
|
54
62
|
# Add the named interface to this group.
|
55
63
|
#
|
64
|
+
# Vedeu.group 'main_screen' do
|
65
|
+
# add 'editor_interface'
|
66
|
+
# end
|
67
|
+
#
|
56
68
|
# @param interface_name [String]
|
57
69
|
# @return [void]
|
58
70
|
def add(interface_name)
|
data/lib/vedeu/dsl/interface.rb
CHANGED
data/lib/vedeu/dsl/keymap.rb
CHANGED
@@ -2,9 +2,11 @@ module Vedeu
|
|
2
2
|
|
3
3
|
module DSL
|
4
4
|
|
5
|
-
#
|
5
|
+
# You can define keymaps by name which matches a defined interface. When
|
6
|
+
# that interface is in focus, keys pressed as part of this definition will
|
7
|
+
# affect that interface. This allows you to form context driven behaviour
|
8
|
+
# for your application.
|
6
9
|
#
|
7
|
-
# @api public
|
8
10
|
class Keymap
|
9
11
|
|
10
12
|
include Vedeu::Common
|
@@ -14,41 +16,37 @@ module Vedeu
|
|
14
16
|
# Unless an interface is specified, the key will be assumed to be global,
|
15
17
|
# meaning its action will happen regardless of the interface in focus.
|
16
18
|
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
# # ...
|
19
|
+
# Vedeu.keymap 'some_interface' do
|
20
|
+
# key('s') { Vedeu.trigger(:save) }
|
21
|
+
# key('h', :left) { Vedeu.trigger(:left) }
|
22
|
+
# key('j', :down) { Vedeu.trigger(:down) }
|
23
|
+
# key('p') do
|
24
|
+
# # ... some code
|
24
25
|
# end
|
26
|
+
# # ... some code
|
25
27
|
# end
|
26
28
|
#
|
27
|
-
#
|
28
|
-
# to.
|
29
|
-
# @param block [Proc]
|
29
|
+
# # or...
|
30
30
|
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
# # ...
|
31
|
+
# Vedeu.keys 'some_interface' do
|
32
|
+
# # ... some code
|
34
33
|
# end
|
35
34
|
#
|
36
|
-
#
|
37
|
-
# # ...
|
38
|
-
# end
|
35
|
+
# # or...
|
39
36
|
#
|
40
|
-
# Vedeu.interface '
|
37
|
+
# Vedeu.interface 'some_interface' do
|
41
38
|
# keymap do
|
42
|
-
# # ...
|
43
|
-
# end
|
44
|
-
# end
|
39
|
+
# # ... some code
|
40
|
+
# end # or...
|
45
41
|
#
|
46
|
-
# Vedeu.interface 'my_interface' do
|
47
42
|
# keys do
|
48
|
-
# # ...
|
43
|
+
# # ... some code
|
49
44
|
# end
|
50
45
|
# end
|
51
46
|
#
|
47
|
+
# @param name [String] The name of the interface which this keymap relates
|
48
|
+
# to.
|
49
|
+
# @param block [Proc]
|
52
50
|
# @raise [Vedeu::InvalidSyntax] The required block was not given.
|
53
51
|
# @return [Vedeu::Keymap]
|
54
52
|
# @todo Try to remember why we need to pre-create the keymap in the
|
@@ -77,18 +75,6 @@ module Vedeu
|
|
77
75
|
# extras are treated as aliases.
|
78
76
|
# @param block [Proc] The action to perform when this key is pressed. Can
|
79
77
|
# be a method call or event triggered.
|
80
|
-
#
|
81
|
-
# @example
|
82
|
-
# Vedeu.keymap do
|
83
|
-
# key('s') { Vedeu.trigger(:save) }
|
84
|
-
# key('h', :left) { Vedeu.trigger(:left) }
|
85
|
-
# key('j', :down) { Vedeu.trigger(:down) }
|
86
|
-
# key('p') do
|
87
|
-
# # ...
|
88
|
-
# end
|
89
|
-
# # ...
|
90
|
-
# end
|
91
|
-
#
|
92
78
|
# @raise [Vedeu::InvalidSyntax] When the required block is not given, the
|
93
79
|
# value_or_values parameter is undefined, or when processing the
|
94
80
|
# collection, a member is undefined.
|
@@ -120,6 +106,10 @@ module Vedeu
|
|
120
106
|
# available to all interfaces. Once a key has been defined in the
|
121
107
|
# '_global_' keymap, it cannot be used for a specific interface.
|
122
108
|
#
|
109
|
+
# Vedeu.keymap do
|
110
|
+
# name 'some_interface'
|
111
|
+
# end
|
112
|
+
#
|
123
113
|
# @param value [String]
|
124
114
|
# @return [String]
|
125
115
|
def name(value)
|