vedeu 0.8.16 → 0.8.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/TODO.md +8 -0
  3. data/examples/dsl_alignment.rb +5 -2
  4. data/examples/dsl_horizontal_alignment.rb +5 -2
  5. data/examples/dsl_vertical_alignment.rb +5 -2
  6. data/integrations/test_runner.sh +2 -3
  7. data/lib/vedeu.rb +31 -1
  8. data/lib/vedeu/borders/all.rb +19 -0
  9. data/lib/vedeu/borders/border.rb +1 -2
  10. data/lib/vedeu/borders/caption.rb +2 -0
  11. data/lib/vedeu/borders/refresh.rb +4 -17
  12. data/lib/vedeu/borders/repository.rb +0 -14
  13. data/lib/vedeu/borders/title.rb +9 -3
  14. data/lib/vedeu/buffers/all.rb +25 -0
  15. data/lib/vedeu/buffers/buffer.rb +2 -2
  16. data/lib/vedeu/buffers/refresh.rb +1 -15
  17. data/lib/vedeu/buffers/terminal.rb +0 -15
  18. data/lib/vedeu/buffers/view.rb +2 -2
  19. data/lib/vedeu/cells/empty.rb +4 -5
  20. data/lib/vedeu/coercers/all.rb +0 -5
  21. data/lib/vedeu/cursors/all.rb +88 -0
  22. data/lib/vedeu/cursors/cursor.rb +7 -92
  23. data/lib/vedeu/cursors/move.rb +44 -14
  24. data/lib/vedeu/cursors/refresh.rb +5 -17
  25. data/lib/vedeu/cursors/reposition.rb +2 -2
  26. data/lib/vedeu/distributed/all.rb +16 -0
  27. data/lib/vedeu/distributed/server.rb +0 -16
  28. data/lib/vedeu/dsl/dsl.rb +2 -2
  29. data/lib/vedeu/dsl/helpers/align.rb +1 -1
  30. data/lib/vedeu/dsl/helpers/attributes.rb +1 -1
  31. data/lib/vedeu/dsl/helpers/truncate.rb +1 -1
  32. data/lib/vedeu/dsl/helpers/wordwrap.rb +1 -1
  33. data/lib/vedeu/dsl/view.rb +1 -1
  34. data/lib/vedeu/dsl/views.rb +22 -6
  35. data/lib/vedeu/editor/all.rb +54 -0
  36. data/lib/vedeu/editor/cropper.rb +3 -5
  37. data/lib/vedeu/editor/cursor.rb +2 -4
  38. data/lib/vedeu/editor/document.rb +1 -1
  39. data/lib/vedeu/editor/editor.rb +2 -17
  40. data/lib/vedeu/editor/repository.rb +0 -45
  41. data/lib/vedeu/events/event.rb +1 -1
  42. data/lib/vedeu/geometries/all.rb +46 -1
  43. data/lib/vedeu/geometries/area/area.rb +2 -2
  44. data/lib/vedeu/geometries/dsl/grid.rb +16 -20
  45. data/lib/vedeu/geometries/geometry.rb +1 -1
  46. data/lib/vedeu/geometries/move.rb +2 -38
  47. data/lib/vedeu/geometries/repository.rb +0 -14
  48. data/lib/vedeu/groups/all.rb +23 -0
  49. data/lib/vedeu/groups/clear.rb +1 -10
  50. data/lib/vedeu/groups/group.rb +0 -12
  51. data/lib/vedeu/groups/refresh.rb +2 -11
  52. data/lib/vedeu/input/all.rb +35 -0
  53. data/lib/vedeu/input/capture.rb +2 -2
  54. data/lib/vedeu/input/mapper.rb +0 -35
  55. data/lib/vedeu/input/raw.rb +1 -1
  56. data/lib/vedeu/input/read.rb +1 -1
  57. data/lib/vedeu/interfaces/all.rb +24 -0
  58. data/lib/vedeu/interfaces/clear.rb +32 -46
  59. data/lib/vedeu/interfaces/interface.rb +0 -16
  60. data/lib/vedeu/menus/all.rb +44 -0
  61. data/lib/vedeu/menus/menu.rb +13 -8
  62. data/lib/vedeu/menus/repository.rb +0 -44
  63. data/lib/vedeu/models/all.rb +13 -0
  64. data/lib/vedeu/models/focus.rb +0 -13
  65. data/lib/vedeu/models/toggleable.rb +1 -1
  66. data/lib/vedeu/null/generic.rb +1 -1
  67. data/lib/vedeu/output/all.rb +7 -0
  68. data/lib/vedeu/output/compressor.rb +11 -6
  69. data/lib/vedeu/output/compressors/character.rb +2 -0
  70. data/lib/vedeu/output/refresh.rb +0 -7
  71. data/lib/vedeu/output/viewport.rb +2 -5
  72. data/lib/vedeu/plugins/plugin.rb +1 -1
  73. data/lib/vedeu/presentation/colour.rb +6 -1
  74. data/lib/vedeu/renderers/all.rb +1 -1
  75. data/lib/vedeu/repositories/repositories.rb +1 -1
  76. data/lib/vedeu/runtime/all.rb +28 -0
  77. data/lib/vedeu/runtime/application.rb +0 -18
  78. data/lib/vedeu/runtime/flags.rb +0 -7
  79. data/lib/vedeu/runtime/router.rb +0 -11
  80. data/lib/vedeu/runtime/traps.rb +2 -0
  81. data/lib/vedeu/templating/view_template.rb +2 -4
  82. data/lib/vedeu/terminal/all.rb +7 -0
  83. data/lib/vedeu/terminal/terminal.rb +0 -7
  84. data/lib/vedeu/version.rb +1 -1
  85. data/lib/vedeu/views/view.rb +3 -3
  86. data/test/lib/vedeu/cursors/cursor_test.rb +4 -4
  87. data/test/lib/vedeu/cursors/move_test.rb +2 -2
  88. data/test/lib/vedeu/presentation/colour_test.rb +26 -0
  89. data/test/support/colour_support.sh +3 -1
  90. data/test/support/examples/material_colours_app.rb +2 -28
  91. data/test/support/stats.sh +1 -1
  92. data/test/test_helper.rb +0 -1
  93. data/vedeu.gemspec +1 -1
  94. metadata +4 -6
  95. data/test/support/helpers/presentation_colour_test_class.rb +0 -31
@@ -14,19 +14,14 @@ module Vedeu
14
14
  end # Vedeu
15
15
 
16
16
  require 'vedeu/coercers/coercer'
17
-
18
17
  require 'vedeu/coercers/alignment'
19
18
  require 'vedeu/coercers/horizontal_alignment'
20
19
  require 'vedeu/coercers/vertical_alignment'
21
-
22
20
  require 'vedeu/coercers/chars'
23
-
24
21
  require 'vedeu/coercers/colour'
25
22
  require 'vedeu/coercers/colour_attributes'
26
-
27
23
  require 'vedeu/coercers/editor_line'
28
24
  require 'vedeu/coercers/editor_lines'
29
-
30
25
  require 'vedeu/coercers/lines'
31
26
  require 'vedeu/coercers/page'
32
27
  require 'vedeu/coercers/position'
@@ -15,6 +15,94 @@ module Vedeu
15
15
 
16
16
  end # Cursors
17
17
 
18
+ # :nocov:
19
+
20
+ # See {file:docs/cursors.md}
21
+ Vedeu.bind(:_cursor_bottom_) do |name|
22
+ name ||= Vedeu.focus
23
+ count = Vedeu.buffers.by_name(name).size
24
+
25
+ Vedeu::Cursors::Reposition.new(name: name,
26
+ y: count,
27
+ x: 0,
28
+ mode: :relative).reposition
29
+
30
+ Vedeu.trigger(:_clear_view_, name)
31
+ Vedeu.trigger(:_refresh_view_, name)
32
+ end
33
+
34
+ # See {file:docs/events/by_name/cursor_down.md}
35
+ Vedeu.bind(:_cursor_down_) do |name, offset|
36
+ Vedeu::Cursors::Move.move(name, :move_down, offset)
37
+ end
38
+
39
+ # See {file:docs/events/by_name/cursor_left.md}
40
+ Vedeu.bind(:_cursor_left_) do |name, offset|
41
+ Vedeu::Cursors::Move.move(name, :move_left, offset)
42
+ end
43
+
44
+ # See {file:docs/cursors.md}
45
+ Vedeu.bind(:_cursor_origin_) do |name|
46
+ Vedeu.cursors.by_name(name).move_origin
47
+
48
+ Vedeu.trigger(:_refresh_cursor_, name)
49
+ end
50
+ Vedeu.bind_alias(:_cursor_reset_, :_cursor_origin_)
51
+
52
+ # See {file:docs/cursors.md}
53
+ Vedeu.bind(:_cursor_position_) do |name|
54
+ Vedeu.cursors.by_name(name).inspect
55
+ end
56
+
57
+ # See {file:docs/cursors.md}
58
+ Vedeu.bind(:_cursor_reposition_) do |name, y, x|
59
+ Vedeu::Cursors::Reposition.new(name: name,
60
+ y: y,
61
+ x: x,
62
+ mode: :absolute).reposition
63
+ end
64
+
65
+ # See {file:docs/events/by_name/cursor_right.md}
66
+ Vedeu.bind(:_cursor_right_) do |name, offset|
67
+ Vedeu::Cursors::Move.move(name, :move_right, offset)
68
+ end
69
+
70
+ # See {file:docs/events/by_name/cursor_up.md}
71
+ Vedeu.bind(:_cursor_up_) do |name, offset|
72
+ Vedeu::Cursors::Move.move(name, :move_up, offset)
73
+ end
74
+
75
+ # See {file:docs/cursors.md}
76
+ Vedeu.bind(:_cursor_top_) do |name|
77
+ name ||= Vedeu.focus
78
+
79
+ Vedeu::Cursors::Reposition.new(name: name,
80
+ y: 0,
81
+ x: 0,
82
+ mode: :relative).reposition
83
+
84
+ Vedeu.trigger(:_clear_view_, name)
85
+ Vedeu.trigger(:_refresh_view_, name)
86
+ end
87
+
88
+ # See {file:docs/cursors.md#vedeuhide_cursor__}
89
+ Vedeu.bind(:_hide_cursor_) { |name| Vedeu.hide_cursor(name) }
90
+ Vedeu.bind_alias(:_cursor_hide_, :_hide_cursor_)
91
+
92
+ # See {file:docs/events/refresh.md#\_refresh_cursor_}
93
+ Vedeu.bind(:_refresh_cursor_) do |name|
94
+ Vedeu::Cursors::Refresh.by_name(name) if Vedeu.ready?
95
+ end
96
+
97
+ # See {file:docs/cursors.md#vedeushow_cursor__}
98
+ Vedeu.bind(:_show_cursor_) { |name| Vedeu.show_cursor(name) }
99
+ Vedeu.bind_alias(:_cursor_show_, :_show_cursor_)
100
+
101
+ # See {file:docs/cursors.md#vedeutoggle_cursor__}
102
+ Vedeu.bind(:_toggle_cursor_) { |name| Vedeu.toggle_cursor(name) }
103
+
104
+ # :nocov:
105
+
18
106
  end # Vedeu
19
107
 
20
108
  require 'vedeu/cursors/move'
@@ -22,7 +22,7 @@ module Vedeu
22
22
  :byn
23
23
 
24
24
  # @!attribute [r] name
25
- # @return [String|Symbol]
25
+ # @macro return_name
26
26
  attr_reader :name
27
27
 
28
28
  # @!attribute [w] ox
@@ -177,12 +177,12 @@ module Vedeu
177
177
 
178
178
  # @return [Fixnum]
179
179
  def ox
180
- @ox = @ox < 0 ? 0 : @ox
180
+ @ox = @ox < 1 ? 1 : @ox
181
181
  end
182
182
 
183
183
  # @return [Fixnum]
184
184
  def oy
185
- @oy = @oy < 0 ? 0 : @oy
185
+ @oy = @oy < 1 ? 1 : @oy
186
186
  end
187
187
 
188
188
  # Return the position of this cursor.
@@ -214,11 +214,9 @@ module Vedeu
214
214
 
215
215
  private
216
216
 
217
- # Returns the geometry for the interface.
218
- #
219
- # @return (see Vedeu::Geometries::Repository#by_name)
217
+ # @macro geometry_by_name
220
218
  def geometry
221
- @geometry ||= Vedeu.geometries.by_name(name)
219
+ @_geometry ||= Vedeu.geometries.by_name(name)
222
220
  end
223
221
 
224
222
  # Determine correct x and y related coordinates.
@@ -234,8 +232,8 @@ module Vedeu
234
232
  def defaults
235
233
  {
236
234
  name: '',
237
- ox: 0,
238
- oy: 0,
235
+ ox: 1,
236
+ oy: 1,
239
237
  repository: Vedeu.cursors,
240
238
  visible: false,
241
239
  x: 1,
@@ -281,87 +279,4 @@ module Vedeu
281
279
  :show_cursor,
282
280
  :toggle_cursor
283
281
 
284
- # :nocov:
285
-
286
- # See {file:docs/cursors.md#vedeuhide_cursor__}
287
- Vedeu.bind(:_hide_cursor_) { |name| Vedeu.hide_cursor(name) }
288
- Vedeu.bind_alias(:_cursor_hide_, :_hide_cursor_)
289
-
290
- # See {file:docs/cursors.md#vedeushow_cursor__}
291
- Vedeu.bind(:_show_cursor_) { |name| Vedeu.show_cursor(name) }
292
- Vedeu.bind_alias(:_cursor_show_, :_show_cursor_)
293
-
294
- # See {file:docs/cursors.md#vedeutoggle_cursor__}
295
- Vedeu.bind(:_toggle_cursor_) { |name| Vedeu.toggle_cursor(name) }
296
-
297
- # See {file:docs/events/by_name/cursor_left.md}
298
- Vedeu.bind(:_cursor_left_) do |name, offset|
299
- Vedeu::Cursors::Move.move(name, :move_left, offset)
300
- end
301
-
302
- # See {file:docs/events/by_name/cursor_down.md}
303
- Vedeu.bind(:_cursor_down_) do |name, offset|
304
- Vedeu::Cursors::Move.move(name, :move_down, offset)
305
- end
306
-
307
- # See {file:docs/events/by_name/cursor_up.md}
308
- Vedeu.bind(:_cursor_up_) do |name, offset|
309
- Vedeu::Cursors::Move.move(name, :move_up, offset)
310
- end
311
-
312
- # See {file:docs/events/by_name/cursor_right.md}
313
- Vedeu.bind(:_cursor_right_) do |name, offset|
314
- Vedeu::Cursors::Move.move(name, :move_right, offset)
315
- end
316
-
317
- # See {file:docs/cursors.md}
318
- Vedeu.bind(:_cursor_origin_) do |name|
319
- Vedeu.cursors.by_name(name).move_origin
320
-
321
- Vedeu.trigger(:_refresh_cursor_, name)
322
- end
323
- Vedeu.bind_alias(:_cursor_reset_, :_cursor_origin_)
324
-
325
- # See {file:docs/cursors.md}
326
- Vedeu.bind(:_cursor_position_) do |name|
327
- Vedeu.cursors.by_name(name).inspect
328
- end
329
-
330
- # See {file:docs/cursors.md}
331
- Vedeu.bind(:_cursor_reposition_) do |name, y, x|
332
- Vedeu::Cursors::Reposition.new(name: name,
333
- y: y,
334
- x: x,
335
- mode: :absolute).reposition
336
- end
337
-
338
- # See {file:docs/cursors.md}
339
- Vedeu.bind(:_cursor_top_) do |name|
340
- name ||= Vedeu.focus
341
-
342
- Vedeu::Cursors::Reposition.new(name: name,
343
- y: 0,
344
- x: 0,
345
- mode: :relative).reposition
346
-
347
- Vedeu.trigger(:_clear_view_, name)
348
- Vedeu.trigger(:_refresh_view_, name)
349
- end
350
-
351
- # See {file:docs/cursors.md}
352
- Vedeu.bind(:_cursor_bottom_) do |name|
353
- name ||= Vedeu.focus
354
- count = Vedeu.buffers.by_name(name).size
355
-
356
- Vedeu::Cursors::Reposition.new(name: name,
357
- y: count,
358
- x: 0,
359
- mode: :relative).reposition
360
-
361
- Vedeu.trigger(:_clear_view_, name)
362
- Vedeu.trigger(:_refresh_view_, name)
363
- end
364
-
365
- # :nocov:
366
-
367
282
  end # Vedeu
@@ -29,22 +29,22 @@ module Vedeu
29
29
  def initialize(name, direction, offset)
30
30
  @name = name
31
31
  @direction = direction
32
- @offset = offset
32
+ @offset = offset || 1
33
33
  end
34
34
 
35
35
  # @return [NilClass|Vedeu::Cursors::Cursor]
36
36
  def move
37
- return nil unless visible? && valid_direction?
38
-
39
- cursor.public_send(direction, offset)
40
- cursor.store { Vedeu.trigger(:_refresh_cursor_, name) }
41
- cursor
37
+ if visible? && valid?
38
+ cursor.public_send(direction, offset)
39
+ cursor.store { Vedeu.trigger(:_refresh_cursor_, name) }
40
+ cursor
41
+ end
42
42
  end
43
43
 
44
44
  protected
45
45
 
46
46
  # @!attribute [r] name
47
- # @return [String|Symbol] The name of the cursor.
47
+ # @macro return_name
48
48
  attr_reader :name
49
49
 
50
50
  # @!attribute [r] direction
@@ -58,19 +58,49 @@ module Vedeu
58
58
 
59
59
  private
60
60
 
61
- # @return [Vedeu::Cursors::Cursor]
61
+ # @macro cursor_by_name
62
62
  def cursor
63
63
  @_cursor ||= Vedeu.cursors.by_name(name)
64
64
  end
65
65
 
66
+ # @return [Hash<Symbol => Proc>]
67
+ def directions
68
+ {
69
+ move_down: proc { valid_down? },
70
+ move_left: proc { valid_left? },
71
+ move_right: proc { valid_right? },
72
+ move_up: proc { valid_up? },
73
+ }
74
+ end
75
+
76
+ # @return [Boolean]
77
+ def valid?
78
+ valid_direction? && directions.fetch(direction).call
79
+ end
80
+
66
81
  # @return [Boolean]
67
82
  def valid_direction?
68
- [
69
- :move_down,
70
- :move_left,
71
- :move_right,
72
- :move_up,
73
- ].include?(direction)
83
+ directions.keys.include?(direction)
84
+ end
85
+
86
+ # @return [Boolean]
87
+ def valid_down?
88
+ true
89
+ end
90
+
91
+ # @return [Boolean]
92
+ def valid_left?
93
+ (cursor.ox - offset) > 0
94
+ end
95
+
96
+ # @return [Boolean]
97
+ def valid_right?
98
+ true
99
+ end
100
+
101
+ # @return [Boolean]
102
+ def valid_up?
103
+ (cursor.oy - offset) > 0
74
104
  end
75
105
 
76
106
  end # Move
@@ -63,7 +63,7 @@ module Vedeu
63
63
 
64
64
  private
65
65
 
66
- # @return [String|Symbol]
66
+ # @macro return_name
67
67
  def name
68
68
  present?(@name) ? @name : Vedeu.focus
69
69
  end
@@ -78,30 +78,18 @@ module Vedeu
78
78
  visible? && (ox >= bordered_width || oy >= bordered_height)
79
79
  end
80
80
 
81
- # @return [Vedeu::Cursors::Cursor]
82
- # @see Vedeu::Cursors::Repository#by_name
81
+ # @macro cursor_by_name
83
82
  def cursor
84
- @cursor ||= Vedeu.cursors.by_name(name)
83
+ @_cursor ||= Vedeu.cursors.by_name(name)
85
84
  end
86
85
 
87
- # Fetch the geometry by name.
88
- #
89
- # @return (see Vedeu::Geometries::Repository#by_name)
86
+ # @macro geometry_by_name
90
87
  def geometry
91
- @geometry ||= Vedeu.geometries.by_name(name)
88
+ @_geometry ||= Vedeu.geometries.by_name(name)
92
89
  end
93
90
 
94
91
  end # Refresh
95
92
 
96
93
  end # Cursors
97
94
 
98
- # :nocov:
99
-
100
- # See {file:docs/events/refresh.md#\_refresh_cursor_}
101
- Vedeu.bind(:_refresh_cursor_) do |name|
102
- Vedeu::Cursors::Refresh.by_name(name) if Vedeu.ready?
103
- end
104
-
105
- # :nocov:
106
-
107
95
  end # Vedeu
@@ -37,7 +37,7 @@ module Vedeu
37
37
  protected
38
38
 
39
39
  # @!attribute [r] name
40
- # @return [String|Symbol]
40
+ # @macro return_name
41
41
  attr_reader :name
42
42
 
43
43
  # @!attribute [r] x
@@ -91,7 +91,7 @@ module Vedeu
91
91
  }
92
92
  end
93
93
 
94
- # @return [Vedeu::Geometries::Geometry]
94
+ # @macro geometry_by_name
95
95
  def geometry
96
96
  Vedeu.geometries.by_name(name)
97
97
  end
@@ -9,6 +9,22 @@ module Vedeu
9
9
 
10
10
  end # Distributed
11
11
 
12
+ # :nocov:
13
+
14
+ # See {file:docs/events/drb.md#\_drb_restart_}
15
+ Vedeu.bind(:_drb_restart_) { Vedeu::Distributed::Server.restart }
16
+
17
+ # See {file:docs/events/drb.md#\_drb_start_}
18
+ Vedeu.bind(:_drb_start_) { Vedeu::Distributed::Server.start }
19
+
20
+ # See {file:docs/events/drb.md#\_drb_status_}
21
+ Vedeu.bind(:_drb_status_) { Vedeu::Distributed::Server.status }
22
+
23
+ # See {file:docs/events/drb.md#\_drb_stop_}
24
+ Vedeu.bind(:_drb_stop_) { Vedeu::Distributed::Server.stop }
25
+
26
+ # :nocov:
27
+
12
28
  end # Vedeu
13
29
 
14
30
  require 'vedeu/distributed/uri'
@@ -256,20 +256,4 @@ module Vedeu
256
256
  :drb_status,
257
257
  :drb_stop
258
258
 
259
- # :nocov:
260
-
261
- # See {file:docs/events/drb.md#\_drb_restart_}
262
- Vedeu.bind(:_drb_restart_) { Vedeu::Distributed::Server.restart }
263
-
264
- # See {file:docs/events/drb.md#\_drb_start_}
265
- Vedeu.bind(:_drb_start_) { Vedeu::Distributed::Server.start }
266
-
267
- # See {file:docs/events/drb.md#\_drb_status_}
268
- Vedeu.bind(:_drb_status_) { Vedeu::Distributed::Server.status }
269
-
270
- # See {file:docs/events/drb.md#\_drb_stop_}
271
- Vedeu.bind(:_drb_stop_) { Vedeu::Distributed::Server.stop }
272
-
273
- # :nocov:
274
-
275
259
  end # Vedeu
data/lib/vedeu/dsl/dsl.rb CHANGED
@@ -65,8 +65,8 @@ module Vedeu
65
65
  # @return [void]
66
66
  def method_missing(method, *args, &block)
67
67
  Vedeu.log(type: :debug,
68
- message: "!!!method_missing '#{method}' " \
69
- "(#{client.inspect})")
68
+ message: "!!!method_missing '#{method}' sending to " \
69
+ "#{client.inspect}")
70
70
 
71
71
  client.send(method, *args, &block) if client
72
72
  end