vedeu 0.4.58 → 0.4.59

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +0 -558
  3. data/README.md +2 -0
  4. data/docs/dsl.md +66 -54
  5. data/lib/vedeu/all.rb +44 -16
  6. data/lib/vedeu/api.rb +0 -2
  7. data/lib/vedeu/bindings/drb.rb +0 -1
  8. data/lib/vedeu/bindings/menus.rb +0 -1
  9. data/lib/vedeu/bindings/movement.rb +0 -1
  10. data/lib/vedeu/bindings/system.rb +0 -1
  11. data/lib/vedeu/bindings/visibility.rb +0 -1
  12. data/lib/vedeu/bootstrap.rb +2 -2
  13. data/lib/vedeu/buffers/buffers.rb +0 -4
  14. data/lib/vedeu/cli/generator/all.rb +0 -4
  15. data/lib/vedeu/cli/generator/helpers.rb +0 -2
  16. data/lib/vedeu/cli/generator/templates/application/application.erb +8 -5
  17. data/lib/vedeu/cli/generator/view.rb +4 -2
  18. data/lib/vedeu/cli/main.rb +0 -2
  19. data/lib/vedeu/colours/backgrounds.rb +0 -1
  20. data/lib/vedeu/colours/colours.rb +0 -1
  21. data/lib/vedeu/colours/foregrounds.rb +0 -1
  22. data/lib/vedeu/configuration/api.rb +19 -6
  23. data/lib/vedeu/configuration/cli.rb +9 -1
  24. data/lib/vedeu/configuration/configuration.rb +9 -0
  25. data/lib/vedeu/cursor/cursor.rb +0 -2
  26. data/lib/vedeu/cursor/cursors.rb +0 -3
  27. data/lib/vedeu/debug.rb +0 -1
  28. data/lib/vedeu/dsl.rb +0 -1
  29. data/lib/vedeu/dsl/border.rb +69 -106
  30. data/lib/vedeu/dsl/composition.rb +1 -2
  31. data/lib/vedeu/dsl/geometry.rb +102 -67
  32. data/lib/vedeu/dsl/group.rb +21 -9
  33. data/lib/vedeu/dsl/interface.rb +0 -1
  34. data/lib/vedeu/dsl/keymap.rb +26 -36
  35. data/lib/vedeu/dsl/line.rb +5 -10
  36. data/lib/vedeu/dsl/menu.rb +7 -13
  37. data/lib/vedeu/dsl/presentation.rb +0 -1
  38. data/lib/vedeu/dsl/stream.rb +0 -1
  39. data/lib/vedeu/dsl/text.rb +0 -1
  40. data/lib/vedeu/dsl/use.rb +0 -1
  41. data/lib/vedeu/dsl/view.rb +28 -31
  42. data/lib/vedeu/events/event.rb +0 -3
  43. data/lib/vedeu/events/events.rb +0 -1
  44. data/lib/vedeu/events/trigger.rb +0 -1
  45. data/lib/vedeu/geometry/geometries.rb +0 -4
  46. data/lib/vedeu/geometry/geometry.rb +0 -2
  47. data/lib/vedeu/geometry/grid.rb +2 -25
  48. data/lib/vedeu/input/keymap.rb +0 -3
  49. data/lib/vedeu/input/keymaps.rb +0 -3
  50. data/lib/vedeu/launcher.rb +0 -1
  51. data/lib/vedeu/log.rb +0 -1
  52. data/lib/vedeu/models/char.rb +0 -5
  53. data/lib/vedeu/models/group.rb +0 -2
  54. data/lib/vedeu/models/groups.rb +0 -3
  55. data/lib/vedeu/models/interface.rb +0 -19
  56. data/lib/vedeu/models/interfaces.rb +0 -4
  57. data/lib/vedeu/models/menus.rb +0 -3
  58. data/lib/vedeu/null/interface.rb +6 -7
  59. data/lib/vedeu/output/border.rb +0 -2
  60. data/lib/vedeu/output/borders.rb +0 -4
  61. data/lib/vedeu/output/esc.rb +0 -1
  62. data/lib/vedeu/output/html_char.rb +0 -2
  63. data/lib/vedeu/output/refresh.rb +0 -3
  64. data/lib/vedeu/output/refresh_group.rb +0 -2
  65. data/lib/vedeu/output/renderers.rb +0 -13
  66. data/lib/vedeu/repositories.rb +2 -15
  67. data/lib/vedeu/repositories/model.rb +0 -2
  68. data/lib/vedeu/repositories/repository.rb +0 -2
  69. data/lib/vedeu/templating/template.rb +0 -2
  70. data/lib/vedeu/terminal.rb +0 -3
  71. data/lib/vedeu/timer.rb +0 -1
  72. data/lib/vedeu/version.rb +1 -1
  73. data/test/lib/vedeu/bootstrap_test.rb +8 -1
  74. data/test/lib/vedeu/configuration/api_test.rb +14 -0
  75. data/test/lib/vedeu/configuration/cli_test.rb +15 -0
  76. data/test/lib/vedeu/cursor/cursor_test.rb +0 -1
  77. data/test/lib/vedeu/models/interface_test.rb +12 -4
  78. data/test/lib/vedeu/null/interface_test.rb +3 -12
  79. data/test/support/helpers/model_test_class.rb +0 -3
  80. data/test/test_helper.rb +0 -2
  81. data/vedeu.gemspec +1 -1
  82. metadata +4 -4
@@ -2,19 +2,61 @@ module Vedeu
2
2
 
3
3
  module DSL
4
4
 
5
- # Provide DSL methods for configuring the geometry of an interface.
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
- # @example
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
- # This crude ASCII diagram represents a Geometry within Vedeu, each of the
17
- # labels is a value you can access or define.
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
- # @param value [Boolean] Any value other than nil or false will evaluate
67
- # to true.
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
- # geometry 'some_interface' do
76
- # centred false
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
- # @see Vedeu::Grid.columns
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
- # @example
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
- # @see Vedeu::Grid.columns
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
- # @param value [Fixnum]
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
- # @note
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
- # @example
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
- # # ... # `other_interface` changes
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
- # @example
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
- # # ... # position, `some_interface`
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
- # @example
184
- # geometry 'some_interface' do
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
- # # ... # `other_interface` changes
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
- # @example
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
- # # ... # position, `some_interface`
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]
@@ -2,34 +2,42 @@ module Vedeu
2
2
 
3
3
  module DSL
4
4
 
5
- # DSL for adding interfaces to a group.
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
- # @note
31
- # Creating a group with the same name as an existing group overwrites
32
- # the existing group.
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)
@@ -4,7 +4,6 @@ module Vedeu
4
4
 
5
5
  # DSL for creating interfaces.
6
6
  #
7
- # @api public
8
7
  class Interface
9
8
 
10
9
  include Vedeu::Common
@@ -2,9 +2,11 @@ module Vedeu
2
2
 
3
3
  module DSL
4
4
 
5
- # Provides methods to be used to define keypress mapped to actions.
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
- # @note
18
- # When defining an interface, there is no need to provide a name since
19
- # this can be discerned from the interface itself, e.g:
20
- #
21
- # Vedeu.interface 'my_interface' do
22
- # keymap do
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
- # @param name [String] The name of the interface which this keymap relates
28
- # to.
29
- # @param block [Proc]
29
+ # # or...
30
30
  #
31
- # @example
32
- # Vedeu.keymap 'my_interface' do
33
- # # ...
31
+ # Vedeu.keys 'some_interface' do
32
+ # # ... some code
34
33
  # end
35
34
  #
36
- # Vedeu.keys 'my_interface' do
37
- # # ...
38
- # end
35
+ # # or...
39
36
  #
40
- # Vedeu.interface 'my_interface' do
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)