vedeu 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -5
  3. data/docs/events.md +4 -0
  4. data/examples/borders_app.rb +43 -39
  5. data/examples/focus_app.rb +4 -0
  6. data/examples/hello_world.rb +10 -3
  7. data/lib/vedeu/all.rb +1 -2
  8. data/lib/vedeu/api.rb +4 -1
  9. data/lib/vedeu/application/application_controller.rb +24 -0
  10. data/lib/vedeu/application/application_view.rb +9 -9
  11. data/lib/vedeu/bindings.rb +2 -0
  12. data/lib/vedeu/bindings/movement.rb +9 -9
  13. data/lib/vedeu/bindings/system.rb +3 -3
  14. data/lib/vedeu/buffers/buffer.rb +4 -9
  15. data/lib/vedeu/buffers/display_buffer.rb +2 -48
  16. data/lib/vedeu/cli/generator/application.rb +6 -0
  17. data/lib/vedeu/cli/generator/templates/application/.ruby-version +1 -0
  18. data/lib/vedeu/cli/generator/templates/application/app/controllers/name.erb +2 -11
  19. data/lib/vedeu/configuration/api.rb +6 -0
  20. data/lib/vedeu/configuration/configuration.rb +6 -0
  21. data/lib/vedeu/cursor/cursor.rb +49 -15
  22. data/lib/vedeu/cursor/move.rb +2 -2
  23. data/lib/vedeu/cursor/refresh_cursor.rb +2 -7
  24. data/lib/vedeu/distributed/server.rb +7 -21
  25. data/lib/vedeu/dsl/view.rb +31 -6
  26. data/lib/vedeu/internal_api.rb +7 -0
  27. data/lib/vedeu/log/log.rb +5 -2
  28. data/lib/vedeu/models/escape.rb +24 -6
  29. data/lib/vedeu/models/interface.rb +2 -14
  30. data/lib/vedeu/null/buffer.rb +7 -21
  31. data/lib/vedeu/null/generic.rb +5 -16
  32. data/lib/vedeu/null/interface.rb +6 -18
  33. data/lib/vedeu/runtime/bootstrap.rb +1 -1
  34. data/lib/vedeu/runtime/flags.rb +57 -0
  35. data/lib/vedeu/runtime/router.rb +2 -2
  36. data/lib/vedeu/version.rb +2 -1
  37. data/test/lib/vedeu/api_test.rb +1 -0
  38. data/test/lib/vedeu/application/application_controller_test.rb +26 -2
  39. data/test/lib/vedeu/application/application_view_test.rb +9 -4
  40. data/test/lib/vedeu/bindings_test.rb +9 -0
  41. data/test/lib/vedeu/borders/border_test.rb +25 -42
  42. data/test/lib/vedeu/buffers/display_buffer_test.rb +0 -10
  43. data/test/lib/vedeu/configuration/api_test.rb +7 -1
  44. data/test/lib/vedeu/configuration/cli_test.rb +0 -1
  45. data/test/lib/vedeu/configuration/configuration_test.rb +16 -0
  46. data/test/lib/vedeu/cursor/cursor_test.rb +122 -4
  47. data/test/lib/vedeu/dsl/view_test.rb +2 -2
  48. data/test/lib/vedeu/internal_api_test.rb +2 -0
  49. data/test/lib/vedeu/models/escape_test.rb +16 -6
  50. data/test/lib/vedeu/models/focus_test.rb +2 -1
  51. data/test/lib/vedeu/models/interface_test.rb +9 -5
  52. data/test/lib/vedeu/null/buffer_test.rb +7 -25
  53. data/test/lib/vedeu/null/generic_test.rb +6 -20
  54. data/test/lib/vedeu/null/interface_test.rb +8 -14
  55. data/test/lib/vedeu/output/compressor_test.rb +4 -4
  56. data/test/lib/vedeu/output/renderers_test.rb +1 -1
  57. data/test/lib/vedeu/runtime/flags_test.rb +47 -0
  58. data/test/lib/vedeu/runtime/router_test.rb +4 -4
  59. data/test/test_helper.rb +2 -0
  60. metadata +6 -10
  61. data/examples/geometry_app.rb +0 -147
  62. data/examples/panel_app.rb +0 -71
  63. data/lib/vedeu/geometry/index_position.rb +0 -85
  64. data/lib/vedeu/geometry/position_validator.rb +0 -69
  65. data/test/lib/vedeu/geometry/index_position_test.rb +0 -130
  66. data/test/lib/vedeu/geometry/position_validator_test.rb +0 -149
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 52f99e59a2bd4ab818933894f1954ab87447ca02
4
- data.tar.gz: 137357a572a617e95530c6300beb880ec541f517
3
+ metadata.gz: e8cbfce4cf0a82bd72ea2ca4db302211611f3c58
4
+ data.tar.gz: 5d77ffbb1325cd04c79c6173aad0805acb53fc8c
5
5
  SHA512:
6
- metadata.gz: 1d9db9d21a9bc04bda9b3039cef7aca59be615c0ac1ed1b0064855420e84a80cf58b978e533e8bb03319165a947a714129384751bef5f3729edcb11d6656d9be
7
- data.tar.gz: 5e7aaaf8b00d308237e4a46886ef7b61bd1eac408cf091df3f65fbb605d8c2f2687cbd932aa514d1b8a87314ad978dec6fe890a0737d882f60d83cc427d488f0
6
+ metadata.gz: 0d35ab6387b6ad9b8999444d82f5c7ec622d63b98eceda8706a3f4cfd669756618335a31f05868fb681ba97dbc6d2f2ebeb562c6eb7eba8b1064284f49da051d
7
+ data.tar.gz: bf839e0f88b3390edf7f995025223df62b7b6f6eb921c42974dbed6d5923be597bf0ce230c3451598fd84d4305ae8f90ebf718784618b8108cb0c4338fdcb341
data/README.md CHANGED
@@ -7,7 +7,6 @@ Vedeu (vee-dee-you; aka VDU) is my attempt at creating a terminal based
7
7
  application framework without the need for Ncurses. I've tried to make Vedeu
8
8
  as simple and flexible as possible.
9
9
 
10
-
11
10
  ## Requirements
12
11
 
13
12
  Vedeu was been built primarily with Ruby v2.1; however, the
@@ -17,7 +16,7 @@ file will indicate the currently used Ruby version.
17
16
  When Vedeu started I was a MacOSX user, I've since moved to Linux. You shouldn't
18
17
  have any problems with either of these operating systems.
19
18
 
20
- Note: You may have trouble running Vedeu with Windows installations. (Pull
19
+ **Note**: You may have trouble running Vedeu with Windows installations. (Pull
21
20
  requests welcome!)
22
21
 
23
22
 
@@ -35,12 +34,15 @@ To use Vedeu's application scaffolding, see the
35
34
  Have a look at: [Playa](https://github.com/gavinlaking/playa). Please browse the
36
35
  source of Playa and Vedeu to get a feel for how it all works.
37
36
 
37
+ **Note**: Playa is based on an old version of Vedeu. Vedeu has significantly
38
+ improved since then and a better example is coming soon!
39
+
38
40
  If you have produced software which uses Vedeu, please let me know, I'll link
39
41
  to your project here.
40
42
 
41
43
  ## Documentation & Usage
42
44
 
43
- Vedeu is largely documented using Yard. I hope to produce more 'General Usage'
45
+ Vedeu is documented using Yard. I hope to produce more 'General Usage'
44
46
  documentation shortly. In the meantime, please browse the
45
47
  [RubyDoc](http://rubydoc.info/gems/vedeu).
46
48
 
@@ -70,7 +72,6 @@ Any branch on the repository that is not `master` is probably experimental; do
70
72
  into `master` before a release, and branches prefixed with `spike/` are me
71
73
  playing with ideas.
72
74
 
73
-
74
75
  ### General contribution help
75
76
 
76
77
  1. Fork it ([https://github.com/gavinlaking/vedeu/fork](https://github.com/gavinlaking/vedeu/fork))
@@ -83,7 +84,6 @@ Any branch on the repository that is not `master` is probably experimental; do
83
84
  8. Push to the branch (`git push origin my-new-feature`)
84
85
  9. Create a new pull request.
85
86
 
86
-
87
87
  ## Author & Contributors
88
88
 
89
89
  ### Author
data/docs/events.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # @title Vedeu Events
2
2
  # Vedeu Events
3
3
 
4
+ ## Application Events
5
+
6
+ See {Vedeu::Bindings::Application}
7
+
4
8
  ## System Events
5
9
 
6
10
  See {Vedeu::Bindings::System}
@@ -30,7 +30,7 @@ class VedeuBordersApp
30
30
  height 4
31
31
  width 10
32
32
  end
33
- colour foreground: '#ffffff', background: '#ff0000'
33
+ colour foreground: '#ffffff', background: '#f44336'
34
34
  end
35
35
 
36
36
  Vedeu.interface 'border_off' do
@@ -40,7 +40,7 @@ class VedeuBordersApp
40
40
  height 4
41
41
  width 10
42
42
  end
43
- colour foreground: '#ffffff', background: '#ff0000'
43
+ colour foreground: '#ffffff', background: '#e91e63'
44
44
  end
45
45
 
46
46
  Vedeu.interface 'no_top' do
@@ -50,7 +50,7 @@ class VedeuBordersApp
50
50
  height 4
51
51
  width 10
52
52
  end
53
- colour foreground: '#000000', background: '#ff5500'
53
+ colour foreground: '#000000', background: '#9c27b0'
54
54
  end
55
55
 
56
56
  Vedeu.interface 'no_bottom' do
@@ -60,7 +60,7 @@ class VedeuBordersApp
60
60
  height 4
61
61
  width 10
62
62
  end
63
- colour foreground: '#000000', background: '#ff5500'
63
+ colour foreground: '#000000', background: '#673ab7'
64
64
  end
65
65
 
66
66
  Vedeu.interface 'no_left' do
@@ -70,7 +70,7 @@ class VedeuBordersApp
70
70
  height 4
71
71
  width 10
72
72
  end
73
- colour foreground: '#000000', background: '#ff5500'
73
+ colour foreground: '#000000', background: '#3f51b5'
74
74
  end
75
75
 
76
76
  Vedeu.interface 'no_right' do
@@ -80,7 +80,7 @@ class VedeuBordersApp
80
80
  height 4
81
81
  width 10
82
82
  end
83
- colour foreground: '#000000', background: '#ff5500'
83
+ colour foreground: '#000000', background: '#2196f3'
84
84
  end
85
85
 
86
86
  Vedeu.interface 'custom_corners' do
@@ -90,7 +90,7 @@ class VedeuBordersApp
90
90
  height 4
91
91
  width 10
92
92
  end
93
- colour foreground: '#ffffff', background: '#ff0000'
93
+ colour foreground: '#000000', background: '#03a9f4'
94
94
  end
95
95
 
96
96
  Vedeu.interface 'custom_sides' do
@@ -100,47 +100,72 @@ class VedeuBordersApp
100
100
  height 4
101
101
  width 10
102
102
  end
103
- colour foreground: '#ffffff', background: '#ff0000'
103
+ colour foreground: '#000000', background: '#00bcd4'
104
104
  end
105
105
 
106
+ # Borders can be defined as part of the interface definition.
106
107
  Vedeu.interface 'only_top' do
108
+ border do
109
+ foreground '#ffffff'
110
+ show_right false
111
+ show_bottom false
112
+ show_left false
113
+ end
107
114
  geometry do
108
115
  x 26
109
116
  y 8
110
117
  height 4
111
118
  width 10
112
119
  end
113
- colour foreground: '#ffffff', background: '#0000ff'
120
+ colour foreground: '#ffffff', background: '#009688'
114
121
  end
115
122
 
116
123
  Vedeu.interface 'only_bottom' do
124
+ border do
125
+ foreground '#000000'
126
+ show_top false
127
+ show_right false
128
+ show_left false
129
+ end
117
130
  geometry do
118
131
  x 38
119
132
  y 8
120
133
  height 4
121
134
  width 10
122
135
  end
123
- colour foreground: '#ffffff', background: '#0000ff'
136
+ colour foreground: '#000000', background: '#8bc34a'
124
137
  end
125
138
 
126
139
  Vedeu.interface 'only_left' do
140
+ border do
141
+ foreground '#000000'
142
+ show_top false
143
+ show_bottom false
144
+ show_right false
145
+ end
127
146
  geometry do
128
147
  x 50
129
148
  y 8
130
149
  height 4
131
150
  width 10
132
151
  end
133
- colour foreground: '#ffffff', background: '#0000ff'
152
+ colour foreground: '#000000', background: '#cddc39'
134
153
  end
135
154
 
136
155
  Vedeu.interface 'only_right' do
156
+ border do
157
+ foreground '#000000'
158
+ show_top false
159
+ show_bottom false
160
+ show_left false
161
+ end
137
162
  geometry do
138
163
  x 62
139
164
  y 8
140
165
  height 4
141
166
  width 10
142
167
  end
143
- colour foreground: '#ffffff', background: '#0000ff'
168
+ colour foreground: '#000000', background: '#ffeb3b'
144
169
  end
145
170
 
146
171
  Vedeu.interface 'custom_colour' do
@@ -150,7 +175,7 @@ class VedeuBordersApp
150
175
  height 4
151
176
  width 10
152
177
  end
153
- colour foreground: '#ffffff', background: '#ff0000'
178
+ colour foreground: '#000000', background: '#ffc107'
154
179
  end
155
180
 
156
181
  Vedeu.interface 'negative' do
@@ -160,7 +185,7 @@ class VedeuBordersApp
160
185
  height 4
161
186
  width 10
162
187
  end
163
- colour foreground: '#000000', background: '#00ff00'
188
+ colour foreground: '#000000', background: '#ff9800'
164
189
  style 'normal'
165
190
  end
166
191
 
@@ -173,7 +198,7 @@ class VedeuBordersApp
173
198
  key(:tab) { Vedeu.trigger(:_focus_next_) }
174
199
  end
175
200
 
176
- # Borders can be defined as part of a view (see below), or standalone.
201
+ # Borders can be defined as standalone declarations.
177
202
  Vedeu.border 'no_bottom' do
178
203
  foreground '#ffffff'
179
204
  show_bottom false
@@ -191,6 +216,7 @@ class VedeuBordersApp
191
216
  show_top false
192
217
  end
193
218
 
219
+ # Borders can be defined as part of a view.
194
220
  Vedeu.renders do
195
221
  view('default_border') do
196
222
  border do
@@ -228,6 +254,7 @@ class VedeuBordersApp
228
254
  end
229
255
  view('custom_corners') do
230
256
  border do
257
+ foreground '#ffffff'
231
258
  top_right 'B'
232
259
  top_left 'A'
233
260
  bottom_right 'D'
@@ -240,6 +267,7 @@ class VedeuBordersApp
240
267
  end
241
268
  view('custom_sides') do
242
269
  border do
270
+ background '#ff5722'
243
271
  horizontal '*'
244
272
  vertical '$'
245
273
  end
@@ -249,48 +277,24 @@ class VedeuBordersApp
249
277
  end
250
278
  end
251
279
  view('only_top') do
252
- border do
253
- foreground '#ffffff'
254
- show_right false
255
- show_bottom false
256
- show_left false
257
- end
258
280
  lines do
259
281
  line 'only'
260
282
  line 'top'
261
283
  end
262
284
  end
263
285
  view('only_bottom') do
264
- border do
265
- foreground '#ffffff'
266
- show_top false
267
- show_right false
268
- show_left false
269
- end
270
286
  lines do
271
287
  line 'only'
272
288
  line 'bottom'
273
289
  end
274
290
  end
275
291
  view('only_left') do
276
- border do
277
- foreground '#ffffff'
278
- show_top false
279
- show_bottom false
280
- show_right false
281
- end
282
292
  lines do
283
293
  line 'only'
284
294
  line 'left'
285
295
  end
286
296
  end
287
297
  view('only_right') do
288
- border do
289
- foreground '#ffffff'
290
- show_top false
291
- show_bottom false
292
- show_left false
293
- end
294
298
  lines do
295
299
  line 'only'
296
300
  line 'right'
@@ -33,6 +33,10 @@ class VedeuFocusApp
33
33
  Vedeu.renders { view('status') { lines { line(Vedeu.focus) } } }
34
34
  end
35
35
 
36
+ Vedeu.keymap('_global_') do
37
+ key('q') { Vedeu.exit }
38
+ end
39
+
36
40
  Vedeu.interface 'aluminium' do
37
41
  colour foreground: '#ffffff', background: '#330000'
38
42
  cursor true
@@ -26,17 +26,24 @@ class HelloWorldApp
26
26
  foreground '#00ff00'
27
27
  geometry do
28
28
  centred!
29
- height 3
29
+ height 5
30
30
  width 20
31
31
  end
32
+ keymap do
33
+ key('q') { Vedeu.exit }
34
+ end
32
35
  end
33
36
 
34
37
  Vedeu.renders do
35
38
  view 'messages' do
36
39
  lines do
37
- centre 'Hello World!', width: 20
40
+ line do
41
+ centre 'Hello World!', width: 20
42
+ end
38
43
  line
39
- centre "Press 'q' to exit.", width: 20
44
+ line do
45
+ centre "Press 'q' to exit.", width: 20
46
+ end
40
47
  end
41
48
  end
42
49
  end
data/lib/vedeu/all.rb CHANGED
@@ -16,6 +16,7 @@ require 'vedeu/configuration/configuration'
16
16
 
17
17
  require 'vedeu/terminal'
18
18
  require 'vedeu/runtime/main_loop'
19
+ require 'vedeu/runtime/flags'
19
20
  require 'vedeu/runtime/application'
20
21
 
21
22
  require 'vedeu/models/toggleable'
@@ -44,10 +45,8 @@ require 'vedeu/geometry/dimension'
44
45
  require 'vedeu/geometry/geometry'
45
46
  require 'vedeu/geometry/geometries'
46
47
  require 'vedeu/geometry/grid'
47
- require 'vedeu/geometry/index_position'
48
48
  require 'vedeu/geometry/position_index'
49
49
  require 'vedeu/geometry/position'
50
- require 'vedeu/geometry/position_validator'
51
50
 
52
51
  require 'vedeu/colours/escape_sequences'
53
52
  require 'vedeu/colours/colours'
data/lib/vedeu/api.rb CHANGED
@@ -98,7 +98,10 @@ module Vedeu
98
98
  # @see Vedeu::DSL::View.renders
99
99
  # @!method views
100
100
  # @see Vedeu::DSL::View.views
101
- def_delegators Vedeu::DSL::View, :interface, :renders, :render, :views
101
+ # @!method view
102
+ # @see Vedeu::DSL::View.view
103
+ def_delegators Vedeu::DSL::View, :interface, :renders, :render, :views,
104
+ :view
102
105
 
103
106
  # @example
104
107
  # Vedeu.bind(name) { }
@@ -8,6 +8,30 @@ module Vedeu
8
8
 
9
9
  include Vedeu::Controller
10
10
 
11
+ # @param params [Hash] The named parameters provided to the controller which
12
+ # will be used by the actions within the controller.
13
+ # @return [Vedeu::ApplicationController]
14
+ def initialize(**params)
15
+ @params = params
16
+ end
17
+
18
+ # @param controller [Symbol] The name of controller to be redirected to.
19
+ # @param action [Symbol] The name of the action within the controller to be
20
+ # called.
21
+ # @param params [Hash] Any named parameter which need to be passed to the
22
+ # action.
23
+ def redirect_to(controller, action, **params)
24
+ Vedeu.trigger(:_goto_, controller, action, params)
25
+ end
26
+ alias_method :redirect, :redirect_to
27
+ alias_method :goto, :redirect_to
28
+
29
+ protected
30
+
31
+ # @!attribute [rw] params
32
+ # @return [Hash] The named parameters passed to the controller.
33
+ attr_accessor :params
34
+
11
35
  end # ApplicationController
12
36
 
13
37
  end # Vedeu
@@ -9,18 +9,18 @@ module Vedeu
9
9
 
10
10
  # Renders the view.
11
11
  #
12
- # @param args [void]
12
+ # @param params [Hash]
13
13
  # @return [void]
14
- def self.render(*args)
15
- new(args).render
14
+ def self.render(**params)
15
+ new(params).render
16
16
  end
17
17
 
18
18
  # Returns a new instance of Vedeu::ApplicationView.
19
19
  #
20
- # @param args [void]
20
+ # @param params [Hash]
21
21
  # @return [Vedeu::ApplicationView]
22
- def initialize(*args)
23
- @args = args
22
+ def initialize(**params)
23
+ @params = params
24
24
  end
25
25
 
26
26
  # @raise [Vedeu::NotImplemented] Subclasses of this class must implement
@@ -33,9 +33,9 @@ module Vedeu
33
33
 
34
34
  protected
35
35
 
36
- # @!attribute [r] args
37
- # @return [void]
38
- attr_reader :args
36
+ # @!attribute [rw] params
37
+ # @return [Hash]
38
+ attr_accessor :params
39
39
 
40
40
  private
41
41