vedeu 0.8.7 → 0.8.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/TODO.md +8 -0
  3. data/docs/dsl/by_method/buffer_update.md +3 -1
  4. data/docs/dsl/by_method/buffer_write.md +3 -1
  5. data/docs/dsl/by_method/cursor.md +3 -1
  6. data/docs/dsl/by_method/cursors.md +3 -1
  7. data/docs/dsl/by_method/direct_write.md +3 -1
  8. data/docs/dsl/by_method/log_stderr.md +4 -1
  9. data/docs/dsl/by_method/log_stdout.md +4 -1
  10. data/docs/dsl/by_method/log_timestamp.md +7 -1
  11. data/docs/dsl/by_method/render_output.md +3 -1
  12. data/docs/events/by_name/{geometry_down.md → aliases/geometry_down.md} +0 -0
  13. data/docs/events/by_name/{geometry_left.md → aliases/geometry_left.md} +0 -0
  14. data/docs/events/by_name/{geometry_right.md → aliases/geometry_right.md} +0 -0
  15. data/docs/events/by_name/{geometry_up.md → aliases/geometry_up.md} +0 -0
  16. data/docs/events/by_name/cursor_down.md +5 -0
  17. data/docs/events/by_name/cursor_left.md +3 -0
  18. data/docs/events/by_name/cursor_origin.md +3 -0
  19. data/docs/events/by_name/cursor_right.md +5 -0
  20. data/docs/events/by_name/cursor_top.md +3 -0
  21. data/docs/events/by_name/cursor_up.md +3 -0
  22. data/docs/events/by_name/hide_cursor.md +6 -1
  23. data/docs/events/by_name/maximise.md +2 -3
  24. data/docs/events/by_name/show_cursor.md +6 -1
  25. data/docs/events/by_name/unmaximise.md +5 -3
  26. data/docs/events/by_name/view_down.md +8 -0
  27. data/docs/events/by_name/view_left.md +8 -0
  28. data/docs/events/by_name/view_right.md +8 -0
  29. data/docs/events/by_name/view_up.md +8 -0
  30. data/docs/events/document.md +2 -1
  31. data/docs/events/focus.md +2 -1
  32. data/docs/events/menu.md +2 -1
  33. data/docs/events/movement.md +2 -1
  34. data/docs/events/refresh.md +2 -1
  35. data/docs/events/view.md +2 -1
  36. data/docs/events/visibility.md +2 -1
  37. data/examples/dsl_horizontal_alignment.rb +1 -1
  38. data/examples/dsl_vertical_alignment.rb +1 -1
  39. data/integrations/dsl_app_border_001.rb +63 -0
  40. data/integrations/dsl_app_border_002.rb +63 -0
  41. data/integrations/dsl_app_border_003.rb +63 -0
  42. data/integrations/dsl_app_border_004.rb +63 -0
  43. data/integrations/dsl_app_border_005.rb +63 -0
  44. data/integrations/expected/dsl_app_border_001.out +1 -0
  45. data/integrations/expected/dsl_app_border_002.out +1 -0
  46. data/integrations/expected/dsl_app_border_003.out +1 -0
  47. data/integrations/expected/dsl_app_border_004.out +1 -0
  48. data/integrations/expected/dsl_app_border_005.out +1 -0
  49. data/integrations/test_runner.sh +7 -0
  50. data/lib/vedeu.rb +2 -1
  51. data/lib/vedeu/borders/repository.rb +1 -5
  52. data/lib/vedeu/cursors/cursor.rb +29 -70
  53. data/lib/vedeu/cursors/move.rb +11 -4
  54. data/lib/vedeu/cursors/reposition.rb +2 -2
  55. data/lib/vedeu/cursors/repository.rb +7 -12
  56. data/lib/vedeu/dsl/elements.rb +0 -1
  57. data/lib/vedeu/error.rb +17 -5
  58. data/lib/vedeu/geometries/dsl/dsl.rb +2 -28
  59. data/lib/vedeu/geometries/dsl/grid.rb +2 -0
  60. data/lib/vedeu/geometries/geometry.rb +2 -22
  61. data/lib/vedeu/geometries/move.rb +45 -10
  62. data/lib/vedeu/geometries/repository.rb +0 -20
  63. data/lib/vedeu/input/capture.rb +2 -1
  64. data/lib/vedeu/logging/log.rb +25 -25
  65. data/lib/vedeu/renderers/file.rb +0 -5
  66. data/lib/vedeu/renderers/json.rb +1 -1
  67. data/lib/vedeu/renderers/options.rb +3 -1
  68. data/lib/vedeu/renderers/text.rb +0 -7
  69. data/lib/vedeu/runtime/bootstrap.rb +1 -1
  70. data/lib/vedeu/runtime/launcher.rb +8 -5
  71. data/lib/vedeu/version.rb +1 -1
  72. data/test/lib/vedeu/application/application_controller_test.rb +2 -4
  73. data/test/lib/vedeu/cursors/cursor_test.rb +9 -12
  74. data/test/lib/vedeu/cursors/move_test.rb +7 -3
  75. data/test/lib/vedeu/geometries/move_test.rb +22 -9
  76. data/test/lib/vedeu/interfaces/interface_test.rb +71 -73
  77. data/test/lib/vedeu/logging/log_test.rb +1 -1
  78. data/test/lib/vedeu/runtime/launcher_test.rb +5 -4
  79. data/test/support/examples/material_colours_app.rb +59 -8
  80. data/test/test_helper.rb +1 -0
  81. metadata +16 -6
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # frozen_string_literal: true
4
+
5
+ require 'bundler/setup'
6
+ require 'vedeu'
7
+
8
+ class DSLApp
9
+
10
+ Vedeu.bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
11
+
12
+ Vedeu.configure do
13
+ debug!
14
+ log '/tmp/vedeu_views_dsl.log'
15
+ renderers [
16
+ Vedeu::Renderers::Terminal.new(
17
+ filename: '/tmp/dsl_app_border_003.out',
18
+ write_file: true),
19
+ # Vedeu::Renderers::JSON.new(filename: '/tmp/dsl_app_border_003.json'),
20
+ # Vedeu::Renderers::HTML.new(filename: '/tmp/dsl_app_border_003.html'),
21
+ # Vedeu::Renderers::Text.new(filename: '/tmp/dsl_app_border_003.txt'),
22
+ ]
23
+ run_once!
24
+ standalone!
25
+ end
26
+
27
+ load './support/test_interface.rb'
28
+
29
+ Vedeu.border :test_interface do
30
+ show_right false
31
+ end
32
+
33
+ Vedeu.render do
34
+ view(:test_interface) do
35
+ lines do
36
+ line 'no right'
37
+ end
38
+ end
39
+ end
40
+
41
+ def self.actual
42
+ File.read('/tmp/dsl_app_border_003.out')
43
+ end
44
+
45
+ def self.expected
46
+ File.read(File.expand_path('../expected/dsl_app_border_003.out', __FILE__))
47
+ end
48
+
49
+ def self.start(argv = ARGV)
50
+ Vedeu::Launcher.execute!(argv)
51
+ end
52
+
53
+ end # DSLApp
54
+
55
+ DSLApp.start
56
+
57
+ if DSLApp.expected == DSLApp.actual
58
+ puts "#{__FILE__} \e[32mPassed.\e[39m"
59
+ exit 0;
60
+ else
61
+ puts "#{__FILE__} \e[31mFailed.\e[39m"
62
+ exit 1;
63
+ end
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # frozen_string_literal: true
4
+
5
+ require 'bundler/setup'
6
+ require 'vedeu'
7
+
8
+ class DSLApp
9
+
10
+ Vedeu.bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
11
+
12
+ Vedeu.configure do
13
+ debug!
14
+ log '/tmp/vedeu_views_dsl.log'
15
+ renderers [
16
+ Vedeu::Renderers::Terminal.new(
17
+ filename: '/tmp/dsl_app_border_004.out',
18
+ write_file: true),
19
+ # Vedeu::Renderers::JSON.new(filename: '/tmp/dsl_app_border_004.json'),
20
+ # Vedeu::Renderers::HTML.new(filename: '/tmp/dsl_app_border_004.html'),
21
+ # Vedeu::Renderers::Text.new(filename: '/tmp/dsl_app_border_004.txt'),
22
+ ]
23
+ run_once!
24
+ standalone!
25
+ end
26
+
27
+ load './support/test_interface.rb'
28
+
29
+ Vedeu.border :test_interface do
30
+ show_bottom false
31
+ end
32
+
33
+ Vedeu.render do
34
+ view(:test_interface) do
35
+ lines do
36
+ line 'no bottom'
37
+ end
38
+ end
39
+ end
40
+
41
+ def self.actual
42
+ File.read('/tmp/dsl_app_border_004.out')
43
+ end
44
+
45
+ def self.expected
46
+ File.read(File.expand_path('../expected/dsl_app_border_004.out', __FILE__))
47
+ end
48
+
49
+ def self.start(argv = ARGV)
50
+ Vedeu::Launcher.execute!(argv)
51
+ end
52
+
53
+ end # DSLApp
54
+
55
+ DSLApp.start
56
+
57
+ if DSLApp.expected == DSLApp.actual
58
+ puts "#{__FILE__} \e[32mPassed.\e[39m"
59
+ exit 0;
60
+ else
61
+ puts "#{__FILE__} \e[31mFailed.\e[39m"
62
+ exit 1;
63
+ end
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # frozen_string_literal: true
4
+
5
+ require 'bundler/setup'
6
+ require 'vedeu'
7
+
8
+ class DSLApp
9
+
10
+ Vedeu.bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
11
+
12
+ Vedeu.configure do
13
+ debug!
14
+ log '/tmp/vedeu_views_dsl.log'
15
+ renderers [
16
+ Vedeu::Renderers::Terminal.new(
17
+ filename: '/tmp/dsl_app_border_005.out',
18
+ write_file: true),
19
+ # Vedeu::Renderers::JSON.new(filename: '/tmp/dsl_app_border_005.json'),
20
+ # Vedeu::Renderers::HTML.new(filename: '/tmp/dsl_app_border_005.html'),
21
+ # Vedeu::Renderers::Text.new(filename: '/tmp/dsl_app_border_005.txt'),
22
+ ]
23
+ run_once!
24
+ standalone!
25
+ end
26
+
27
+ load './support/test_interface.rb'
28
+
29
+ Vedeu.border :test_interface do
30
+ show_left false
31
+ end
32
+
33
+ Vedeu.render do
34
+ view(:test_interface) do
35
+ lines do
36
+ line 'no left'
37
+ end
38
+ end
39
+ end
40
+
41
+ def self.actual
42
+ File.read('/tmp/dsl_app_border_005.out')
43
+ end
44
+
45
+ def self.expected
46
+ File.read(File.expand_path('../expected/dsl_app_border_005.out', __FILE__))
47
+ end
48
+
49
+ def self.start(argv = ARGV)
50
+ Vedeu::Launcher.execute!(argv)
51
+ end
52
+
53
+ end # DSLApp
54
+
55
+ DSLApp.start
56
+
57
+ if DSLApp.expected == DSLApp.actual
58
+ puts "#{__FILE__} \e[32mPassed.\e[39m"
59
+ exit 0;
60
+ else
61
+ puts "#{__FILE__} \e[31mFailed.\e[39m"
62
+ exit 1;
63
+ end
@@ -0,0 +1 @@
1
+ border off                                                                                                                                                 
@@ -0,0 +1 @@
1
+ (0x(Bno top                       (0x(B(0x(B                             (0x(B(0x(B                             (0x(B(0x(B                             (0x(B(0m(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0j(B
@@ -0,0 +1 @@
1
+ (0l(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0x(Bno right                      (0x(B                              (0x(B                              (0m(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B
@@ -0,0 +1 @@
1
+ (0l(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0k(B(0x(Bno bottom                    (0x(B(0x(B                             (0x(B(0x(B                             (0x(B(0x(B                             (0x(B
@@ -0,0 +1 @@
1
+ (0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0k(Bno left                       (0x(B                              (0x(B                              (0x(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0q(B(0j(B
@@ -32,3 +32,10 @@ cd "$(dirname "$0")"
32
32
  ./dsl_app_016.rb
33
33
  ./dsl_app_021.rb
34
34
  ./dsl_app_022.rb
35
+
36
+ # Test some border functionality
37
+ ./dsl_app_border_001.rb
38
+ ./dsl_app_border_002.rb
39
+ ./dsl_app_border_003.rb
40
+ ./dsl_app_border_004.rb
41
+ ./dsl_app_border_005.rb
@@ -38,7 +38,8 @@ module Vedeu
38
38
 
39
39
  rescue Gem::LoadError
40
40
  raise Vedeu::Error::Fatal,
41
- "Vedeu requires '#{gem_name}' for this functionality."
41
+ "Vedeu requires '#{gem_name}' for this functionality. " \
42
+ "Please add this to your project 'Gemfile' or '*.gemspec'."
42
43
  end
43
44
 
44
45
  end # Vedeu
@@ -18,11 +18,7 @@ module Vedeu
18
18
 
19
19
  end # Borders
20
20
 
21
- # Manipulate the repository of borders.
22
- #
23
- # @example
24
- # Vedeu.borders
25
- #
21
+ # {include:file:docs/dsl/by_method/borders.md}
26
22
  # @!method borders
27
23
  # @return [Vedeu::Borders::Repository]
28
24
  def_delegators Vedeu::Borders::Repository,
@@ -89,41 +89,28 @@ module Vedeu
89
89
 
90
90
  # @return [String]
91
91
  def inspect
92
- "<#{self.class.name} name:'#{name}', x:#{x}, y:#{y}, ox:#{ox}, " \
93
- "oy:#{oy}, visible:#{visible}>"
92
+ "name:'#{name}' x:#{x} y:#{y} ox:#{ox} oy:#{oy} visible:#{visible}"
94
93
  end
95
94
 
96
- # Moves the cursor down by one row.
97
- #
98
- # Vedeu.trigger(:_cursor_down_, name)
99
- # Vedeu.trigger(:_cursor_down_, Vedeu.focus)
100
- #
95
+ # {include:file:docs/events/by_name/cursor_down.md}
101
96
  # @return [Vedeu::Cursors::Cursor]
102
- def move_down
103
- @oy += 1
97
+ def move_down(offset = 1)
98
+ @oy += offset || 1
104
99
  @y = coordinate(oy, :y).y
105
100
 
106
101
  self
107
102
  end
108
103
 
109
- # Moves the cursor left by one column.
110
- #
111
- # Vedeu.trigger(:_cursor_left_, name)
112
- # Vedeu.trigger(:_cursor_left_, Vedeu.focus)
113
- #
104
+ # {include:file:docs/events/by_name/cursor_left.md}
114
105
  # @return [Vedeu::Cursors::Cursor]
115
- def move_left
116
- @ox -= 1
106
+ def move_left(offset = 1)
107
+ @ox -= offset || 1
117
108
  @x = coordinate(ox, :x).x
118
109
 
119
110
  self
120
111
  end
121
112
 
122
- # Moves the cursor to the top left of the named interface.
123
- #
124
- # Vedeu.trigger(:_cursor_origin_, name)
125
- # Vedeu.trigger(:_cursor_origin_, Vedeu.focus)
126
- #
113
+ # {include:file:docs/events/by_name/cursor_origin.md}
127
114
  # @return [Vedeu::Cursors::Cursor]
128
115
  def move_origin
129
116
  @x = bx
@@ -134,27 +121,19 @@ module Vedeu
134
121
  store
135
122
  end
136
123
 
137
- # Moves the cursor right by one column.
138
- #
139
- # Vedeu.trigger(:_cursor_right_, name)
140
- # Vedeu.trigger(:_cursor_right_, Vedeu.focus)
141
- #
124
+ # {include:file:docs/events/by_name/cursor_right.md}
142
125
  # @return [Vedeu::Cursors::Cursor]
143
- def move_right
144
- @ox += 1
126
+ def move_right(offset = 1)
127
+ @ox += offset || 1
145
128
  @x = coordinate(ox, :x).x
146
129
 
147
130
  self
148
131
  end
149
132
 
150
- # Moves the cursor up by one row.
151
- #
152
- # Vedeu.trigger(:_cursor_up_, name)
153
- # Vedeu.trigger(:_cursor_up_, Vedeu.focus)
154
- #
133
+ # {include:file:docs/events/by_name/cursor_up.md}
155
134
  # @return [Vedeu::Cursors::Cursor]
156
- def move_up
157
- @oy -= 1
135
+ def move_up(offset = 1)
136
+ @oy -= offset || 1
158
137
  @y = coordinate(oy, :y).y
159
138
 
160
139
  self
@@ -185,17 +164,7 @@ module Vedeu
185
164
  end
186
165
  alias to_str to_s
187
166
 
188
- # Hide a named cursor, or without a name, the cursor of the
189
- # currently focussed interface.
190
- #
191
- # @example
192
- # Vedeu.trigger(:_hide_cursor_, name)
193
- # Vedeu.trigger(:_hide_cursor_, Vedeu.focus)
194
- # Vedeu.trigger(:_hide_cursor_)
195
- # Vedeu.hide_cursor(name)
196
- # Vedeu.hide_cursor(Vedeu.focus)
197
- # Vedeu.hide_cursor
198
- #
167
+ # {include:file:docs/events/by_name/hide_cursor.md}
199
168
  # @return [Vedeu::Cells::Cursor]
200
169
  def hide
201
170
  super
@@ -222,17 +191,7 @@ module Vedeu
222
191
  @position = Vedeu::Geometries::Position.coerce([y, x])
223
192
  end
224
193
 
225
- # Show a named cursor, or without a name, the cursor of the
226
- # currently focussed interface.
227
- #
228
- # @example
229
- # Vedeu.trigger(:_show_cursor_, name)
230
- # Vedeu.trigger(:_show_cursor_, Vedeu.focus)
231
- # Vedeu.trigger(:_show_cursor_)
232
- # Vedeu.show_cursor(name)
233
- # Vedeu.show_cursor(Vedeu.focus)
234
- # Vedeu.show_cursor
235
- #
194
+ # {include:file:docs/events/by_name/show_cursor.md}
236
195
  # @return [Vedeu::Cells::Cursor]
237
196
  def show
238
197
  super
@@ -334,24 +293,24 @@ module Vedeu
334
293
  # See {file:docs/cursors.md#vedeutoggle_cursor__}
335
294
  Vedeu.bind(:_toggle_cursor_) { |name| Vedeu.toggle_cursor(name) }
336
295
 
337
- # See {file:docs/cursors.md}
338
- Vedeu.bind(:_cursor_left_) do |name|
339
- Vedeu::Cursors::Move.move(name, :move_left)
296
+ # See {file:docs/events/by_name/cursor_left.md}
297
+ Vedeu.bind(:_cursor_left_) do |name, offset|
298
+ Vedeu::Cursors::Move.move(name, :move_left, offset)
340
299
  end
341
300
 
342
- # See {file:docs/cursors.md}
343
- Vedeu.bind(:_cursor_down_) do |name|
344
- Vedeu::Cursors::Move.move(name, :move_down)
301
+ # See {file:docs/events/by_name/cursor_down.md}
302
+ Vedeu.bind(:_cursor_down_) do |name, offset|
303
+ Vedeu::Cursors::Move.move(name, :move_down, offset)
345
304
  end
346
305
 
347
- # See {file:docs/cursors.md}
348
- Vedeu.bind(:_cursor_up_) do |name|
349
- Vedeu::Cursors::Move.move(name, :move_up)
306
+ # See {file:docs/events/by_name/cursor_up.md}
307
+ Vedeu.bind(:_cursor_up_) do |name, offset|
308
+ Vedeu::Cursors::Move.move(name, :move_up, offset)
350
309
  end
351
310
 
352
- # See {file:docs/cursors.md}
353
- Vedeu.bind(:_cursor_right_) do |name|
354
- Vedeu::Cursors::Move.move(name, :move_right)
311
+ # See {file:docs/events/by_name/cursor_right.md}
312
+ Vedeu.bind(:_cursor_right_) do |name, offset|
313
+ Vedeu::Cursors::Move.move(name, :move_right, offset)
355
314
  end
356
315
 
357
316
  # See {file:docs/cursors.md}
@@ -364,7 +323,7 @@ module Vedeu
364
323
 
365
324
  # See {file:docs/cursors.md}
366
325
  Vedeu.bind(:_cursor_position_) do |name|
367
- Vedeu.cursors.by_name(name).to_a
326
+ Vedeu.cursors.by_name(name).inspect
368
327
  end
369
328
 
370
329
  # See {file:docs/cursors.md}
@@ -18,23 +18,25 @@ module Vedeu
18
18
 
19
19
  # @param (see #initialize)
20
20
  # @return (see #move)
21
- def self.move(name, direction)
22
- new(name, direction).move
21
+ def self.move(name, direction, offset)
22
+ new(name, direction, offset).move
23
23
  end
24
24
 
25
25
  # @param name [String|Symbol]
26
26
  # @param direction [Symbol]
27
+ # @param offset [Fixnum]
27
28
  # @return [Vedeu::Cursors::Move]
28
- def initialize(name, direction)
29
+ def initialize(name, direction, offset)
29
30
  @name = name
30
31
  @direction = direction
32
+ @offset = offset
31
33
  end
32
34
 
33
35
  # @return [NilClass|Vedeu::Cursors::Cursor]
34
36
  def move
35
37
  return nil unless visible? && valid_direction?
36
38
 
37
- cursor.public_send(direction)
39
+ cursor.public_send(direction, offset)
38
40
  cursor.store { Vedeu.trigger(:_refresh_cursor_, name) }
39
41
  cursor
40
42
  end
@@ -49,6 +51,11 @@ module Vedeu
49
51
  # @return [Symbol] The direction to move the cursor.
50
52
  attr_reader :direction
51
53
 
54
+ # @!attribute [r] offset
55
+ # @return [Symbol] The number of characters to move the cursor
56
+ # in the given direction.
57
+ attr_reader :offset
58
+
52
59
  private
53
60
 
54
61
  # @return [Vedeu::Cursors::Cursor]