vedeu 0.6.60 → 0.6.61

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/docs/dsl.md +18 -18
  3. data/docs/events/drb.md +2 -8
  4. data/docs/events/view.md +2 -2
  5. data/docs/events/visibility.md +1 -4
  6. data/lib/vedeu/all.rb +1 -1
  7. data/lib/vedeu/borders/border.rb +1 -1
  8. data/lib/vedeu/borders/refresh.rb +1 -1
  9. data/lib/vedeu/buffers/empty.rb +6 -4
  10. data/lib/vedeu/buffers/view.rb +78 -7
  11. data/lib/vedeu/cursors/cursor.rb +7 -5
  12. data/lib/vedeu/cursors/refresh.rb +1 -1
  13. data/lib/vedeu/cursors/reposition.rb +5 -3
  14. data/lib/vedeu/cursors/repository.rb +4 -6
  15. data/lib/vedeu/dsl/shared.rb +5 -5
  16. data/lib/vedeu/editor/cropper.rb +1 -1
  17. data/lib/vedeu/editor/cursor.rb +2 -2
  18. data/lib/vedeu/editor/item.rb +3 -3
  19. data/lib/vedeu/error.rb +1 -1
  20. data/lib/vedeu/esc/esc.rb +1 -1
  21. data/lib/vedeu/events/aliases.rb +2 -2
  22. data/lib/vedeu/{geometry → geometries}/alignment.rb +8 -8
  23. data/lib/vedeu/geometries/all.rb +31 -0
  24. data/lib/vedeu/{geometry → geometries}/area.rb +8 -8
  25. data/lib/vedeu/{geometry → geometries}/coordinate.rb +5 -5
  26. data/lib/vedeu/{geometry → geometries}/dimension.rb +6 -6
  27. data/lib/vedeu/{geometry → geometries}/dsl.rb +22 -22
  28. data/lib/vedeu/{geometry → geometries}/geometry.rb +15 -15
  29. data/lib/vedeu/{geometry → geometries}/grid.rb +6 -6
  30. data/lib/vedeu/{geometry → geometries}/horizontal_alignment.rb +3 -3
  31. data/lib/vedeu/{geometry → geometries}/move.rb +5 -5
  32. data/lib/vedeu/{geometry → geometries}/position.rb +18 -18
  33. data/lib/vedeu/{geometry → geometries}/repository.rb +9 -9
  34. data/lib/vedeu/{geometry → geometries}/validator.rb +3 -3
  35. data/lib/vedeu/{geometry → geometries}/vertical_alignment.rb +3 -3
  36. data/lib/vedeu/{geometry → geometries}/x_dimension.rb +4 -4
  37. data/lib/vedeu/{geometry → geometries}/y_dimension.rb +4 -4
  38. data/lib/vedeu/groups/group.rb +2 -1
  39. data/lib/vedeu/input/store.rb +2 -1
  40. data/lib/vedeu/interfaces/clear.rb +8 -6
  41. data/lib/vedeu/interfaces/interface.rb +1 -1
  42. data/lib/vedeu/models/cell.rb +2 -2
  43. data/lib/vedeu/models/escape.rb +2 -2
  44. data/lib/vedeu/models/focus.rb +2 -1
  45. data/lib/vedeu/models/page.rb +3 -2
  46. data/lib/vedeu/models/row.rb +10 -1
  47. data/lib/vedeu/models/views/char.rb +6 -6
  48. data/lib/vedeu/models/views/line.rb +1 -1
  49. data/lib/vedeu/output/compressor.rb +10 -15
  50. data/lib/vedeu/output/presentation/presentation.rb +1 -1
  51. data/lib/vedeu/output/renderers/all.rb +7 -8
  52. data/lib/vedeu/output/viewport.rb +1 -1
  53. data/lib/vedeu/repositories/store.rb +2 -2
  54. data/lib/vedeu/terminal/buffer.rb +46 -102
  55. data/lib/vedeu/terminal/terminal.rb +10 -2
  56. data/lib/vedeu/version.rb +1 -1
  57. data/test/lib/vedeu/borders/refresh_test.rb +1 -1
  58. data/test/lib/vedeu/buffers/empty_test.rb +3 -3
  59. data/test/lib/vedeu/buffers/view_test.rb +48 -1
  60. data/test/lib/vedeu/cursors/cursor_test.rb +2 -2
  61. data/test/lib/vedeu/editor/cropper_test.rb +1 -1
  62. data/test/lib/vedeu/editor/cursor_test.rb +1 -1
  63. data/test/lib/vedeu/editor/document_test.rb +2 -2
  64. data/test/lib/vedeu/{geometry → geometries}/alignment_test.rb +5 -5
  65. data/test/lib/vedeu/{geometry → geometries}/area_test.rb +4 -4
  66. data/test/lib/vedeu/{geometry → geometries}/coordinate.rb +5 -5
  67. data/test/lib/vedeu/{geometry → geometries}/dimension_test.rb +7 -5
  68. data/test/lib/vedeu/{geometry → geometries}/dsl_test.rb +31 -27
  69. data/test/lib/vedeu/{geometry → geometries}/geometry_test.rb +10 -7
  70. data/test/lib/vedeu/{geometry → geometries}/grid_test.rb +13 -9
  71. data/test/lib/vedeu/{geometry → geometries}/horizontal_alignment_test.rb +3 -3
  72. data/test/lib/vedeu/{geometry → geometries}/move_test.rb +10 -10
  73. data/test/lib/vedeu/{geometry → geometries}/position_test.rb +16 -15
  74. data/test/lib/vedeu/{geometry → geometries}/repository_test.rb +3 -3
  75. data/test/lib/vedeu/{geometry → geometries}/validator_test.rb +4 -4
  76. data/test/lib/vedeu/{geometry → geometries}/vertical_alignment_test.rb +3 -3
  77. data/test/lib/vedeu/{geometry → geometries}/x_dimension_test.rb +3 -3
  78. data/test/lib/vedeu/{geometry → geometries}/y_dimension_test.rb +3 -3
  79. data/test/lib/vedeu/interfaces/clear_test.rb +1 -1
  80. data/test/lib/vedeu/models/cell_test.rb +1 -1
  81. data/test/lib/vedeu/models/escape_test.rb +2 -2
  82. data/test/lib/vedeu/models/page_test.rb +18 -2
  83. data/test/lib/vedeu/models/views/char_test.rb +3 -3
  84. data/test/lib/vedeu/output/compressor_test.rb +30 -16
  85. data/test/lib/vedeu/output/renderers/html_test.rb +1 -1
  86. data/test/lib/vedeu/output/renderers/json_test.rb +17 -1
  87. data/test/lib/vedeu/output/viewport_test.rb +1 -1
  88. data/test/lib/vedeu/terminal/buffer_test.rb +6 -18
  89. data/test/lib/vedeu/terminal/terminal_test.rb +1 -1
  90. data/test/support/examples/material_colours_app.rb +2 -0
  91. data/test/test_helper.rb +1 -1
  92. metadata +48 -48
  93. data/lib/vedeu/geometry/all.rb +0 -31
@@ -1,6 +1,6 @@
1
1
  module Vedeu
2
2
 
3
- module Geometry
3
+ module Geometries
4
4
 
5
5
  # The grid system splits the terminal height and width into 12
6
6
  # equal parts, by dividing the available height and width by 12.
@@ -23,22 +23,22 @@ module Vedeu
23
23
  new(value).rows
24
24
  end
25
25
 
26
- # Returns a new instance of Vedeu::Geometry::Grid.
26
+ # Returns a new instance of Vedeu::Geometries::Grid.
27
27
  #
28
28
  # @param value [Fixnum]
29
- # @return [Vedeu::Geometry::Grid]
29
+ # @return [Vedeu::Geometries::Grid]
30
30
  def initialize(value)
31
31
  @value = value
32
32
  end
33
33
 
34
- # @see Vedeu::Geometry::DSL#columns
34
+ # @see Vedeu::Geometries::DSL#columns
35
35
  def columns
36
36
  fail Vedeu::Error::OutOfRange if out_of_range?
37
37
 
38
38
  column * value
39
39
  end
40
40
 
41
- # @see Vedeu::Geometry::DSL#rows
41
+ # @see Vedeu::Geometries::DSL#rows
42
42
  def rows
43
43
  fail Vedeu::Error::OutOfRange if out_of_range?
44
44
 
@@ -77,6 +77,6 @@ module Vedeu
77
77
 
78
78
  end # Grid
79
79
 
80
- end # Geometry
80
+ end # Geometries
81
81
 
82
82
  end # Vedeu
@@ -1,13 +1,13 @@
1
1
  module Vedeu
2
2
 
3
- module Geometry
3
+ module Geometries
4
4
 
5
5
  # Provides the mechanism to align an interface/view horizontally
6
6
  # within the available terminal space.
7
7
  #
8
8
  # @api private
9
9
  #
10
- class HorizontalAlignment < Vedeu::Geometry::Alignment
10
+ class HorizontalAlignment < Vedeu::Geometries::Alignment
11
11
 
12
12
  # @raise [Vedeu::Error::InvalidSyntax] When the value is not one
13
13
  # of :bottom, :centre, :left, :middle, :right, :top.
@@ -22,6 +22,6 @@ module Vedeu
22
22
 
23
23
  end # HorizontalAlignment
24
24
 
25
- end # Geometry
25
+ end # Geometries
26
26
 
27
27
  end # Vedeu
@@ -1,6 +1,6 @@
1
1
  module Vedeu
2
2
 
3
- module Geometry
3
+ module Geometries
4
4
 
5
5
  # Move an interface/view via changing its geometry.
6
6
  #
@@ -33,11 +33,11 @@ module Vedeu
33
33
  new(attributes).move
34
34
  end
35
35
 
36
- # @return [FalseClass|Vedeu::Geometry::Geometry]
36
+ # @return [FalseClass|Vedeu::Geometries::Geometry]
37
37
  def move
38
38
  return false unless valid?
39
39
 
40
- Vedeu::Geometry::Geometry.store(new_attributes) do
40
+ Vedeu::Geometries::Geometry.store(new_attributes) do
41
41
  update_cursor!
42
42
  refresh!
43
43
  end
@@ -95,7 +95,7 @@ module Vedeu
95
95
  }[direction]
96
96
  end
97
97
 
98
- # @return [Vedeu::Geometry::Geometry]
98
+ # @return [Vedeu::Geometries::Geometry]
99
99
  def geometry
100
100
  Vedeu.geometries.by_name(name)
101
101
  end
@@ -203,6 +203,6 @@ module Vedeu
203
203
 
204
204
  end # Move
205
205
 
206
- end # Geometry
206
+ end # Geometries
207
207
 
208
208
  end # Vedeu
@@ -1,6 +1,6 @@
1
1
  module Vedeu
2
2
 
3
- module Geometry
3
+ module Geometries
4
4
 
5
5
  # Change coordinates into an escape sequence to set the cursor
6
6
  # position.
@@ -19,15 +19,15 @@ module Vedeu
19
19
  attr_reader :x
20
20
  alias_method :last, :x
21
21
 
22
- # Convenience constructor for Vedeu::Geometry::Position.
22
+ # Convenience constructor for Vedeu::Geometries::Position.
23
23
  #
24
24
  # @param (see #initialize)
25
25
  def self.[](y, x)
26
26
  new(y, x)
27
27
  end
28
28
 
29
- # @param value [Array<Fixnum>|Vedeu::Geometry::Position]
30
- # @return [Vedeu::Geometry::Position]
29
+ # @param value [Array<Fixnum>|Vedeu::Geometries::Position]
30
+ # @return [Vedeu::Geometries::Position]
31
31
  def self.coerce(value)
32
32
  if value.is_a?(self)
33
33
  value
@@ -41,11 +41,11 @@ module Vedeu
41
41
  end
42
42
  end
43
43
 
44
- # Initializes a new instance of Vedeu::Geometry::Position.
44
+ # Initializes a new instance of Vedeu::Geometries::Position.
45
45
  #
46
46
  # @param y [Fixnum] The row/line position.
47
47
  # @param x [Fixnum] The column/character position.
48
- # @return [Vedeu::Geometry::Position]
48
+ # @return [Vedeu::Geometries::Position]
49
49
  def initialize(y = 1, x = 1)
50
50
  @y = (y.nil? || y < 1) ? 1 : y
51
51
  @x = (x.nil? || x < 1) ? 1 : x
@@ -64,7 +64,7 @@ module Vedeu
64
64
  [yi, xi]
65
65
  end
66
66
 
67
- # @param other [Vedeu::Geometry::Position]
67
+ # @param other [Vedeu::Geometries::Position]
68
68
  # @return [Fixnum]
69
69
  def <=>(other)
70
70
  if y == other.y
@@ -78,7 +78,7 @@ module Vedeu
78
78
 
79
79
  # An object is equal when its values are the same.
80
80
  #
81
- # @param other [Vedeu::Geometry::Position]
81
+ # @param other [Vedeu::Geometries::Position]
82
82
  # @return [Boolean]
83
83
  def eql?(other)
84
84
  self.class == other.class && (x == other.x && y == other.y)
@@ -92,7 +92,7 @@ module Vedeu
92
92
  [y, x]
93
93
  end
94
94
 
95
- # @return [Vedeu::Geometry::Position]
95
+ # @return [Vedeu::Geometries::Position]
96
96
  def to_position
97
97
  self
98
98
  end
@@ -114,30 +114,30 @@ module Vedeu
114
114
 
115
115
  # Increase y coordinate; moves down.
116
116
  #
117
- # @return [Vedeu::Geometry::Position]
117
+ # @return [Vedeu::Geometries::Position]
118
118
  def down
119
- Vedeu::Geometry::Position.new(y + 1, x)
119
+ Vedeu::Geometries::Position.new(y + 1, x)
120
120
  end
121
121
 
122
122
  # Decrease x coordinate; moves left.
123
123
  #
124
- # @return [Vedeu::Geometry::Position]
124
+ # @return [Vedeu::Geometries::Position]
125
125
  def left
126
- Vedeu::Geometry::Position.new(y, x - 1)
126
+ Vedeu::Geometries::Position.new(y, x - 1)
127
127
  end
128
128
 
129
129
  # Increase x coordinate; moves right.
130
130
  #
131
- # @return [Vedeu::Geometry::Position]
131
+ # @return [Vedeu::Geometries::Position]
132
132
  def right
133
- Vedeu::Geometry::Position.new(y, x + 1)
133
+ Vedeu::Geometries::Position.new(y, x + 1)
134
134
  end
135
135
 
136
136
  # Decrease y coordinate; moves up.
137
137
  #
138
- # @return [Vedeu::Geometry::Position]
138
+ # @return [Vedeu::Geometries::Position]
139
139
  def up
140
- Vedeu::Geometry::Position.new(y - 1, x)
140
+ Vedeu::Geometries::Position.new(y - 1, x)
141
141
  end
142
142
 
143
143
  private
@@ -152,6 +152,6 @@ module Vedeu
152
152
 
153
153
  end # Position
154
154
 
155
- end # Geometry
155
+ end # Geometries
156
156
 
157
157
  end # Vedeu
@@ -1,6 +1,6 @@
1
1
  module Vedeu
2
2
 
3
- module Geometry
3
+ module Geometries
4
4
 
5
5
  # Allows the storing of interface/view geometry independent of the
6
6
  # interface instance.
@@ -9,12 +9,12 @@ module Vedeu
9
9
 
10
10
  singleton_class.send(:alias_method, :geometries, :repository)
11
11
 
12
- null Vedeu::Geometry::Geometry, height: Vedeu.height, width: Vedeu.width
13
- real Vedeu::Geometry::Geometry
12
+ null Vedeu::Geometries::Geometry, height: Vedeu.height, width: Vedeu.width
13
+ real Vedeu::Geometries::Geometry
14
14
 
15
15
  end # Repository
16
16
 
17
- end # Geometry
17
+ end # Geometries
18
18
 
19
19
  # Manipulate the repository of geometries.
20
20
  #
@@ -22,8 +22,8 @@ module Vedeu
22
22
  # Vedeu.geometries
23
23
  #
24
24
  # @!method geometries
25
- # @return [Vedeu::Geometry::Repository]
26
- def_delegators Vedeu::Geometry::Repository,
25
+ # @return [Vedeu::Geometries::Repository]
26
+ def_delegators Vedeu::Geometries::Repository,
27
27
  :geometries
28
28
 
29
29
  # :nocov:
@@ -48,9 +48,9 @@ module Vedeu
48
48
 
49
49
  [:down, :left, :right, :up].each do |direction|
50
50
  Vedeu.bind(:"_view_#{direction}_") do |name, offset|
51
- Vedeu::Geometry::Move.move(direction: direction,
52
- name: name,
53
- offset: offset)
51
+ Vedeu::Geometries::Move.move(direction: direction,
52
+ name: name,
53
+ offset: offset)
54
54
  end
55
55
  end
56
56
 
@@ -1,8 +1,8 @@
1
1
  module Vedeu
2
2
 
3
- module Geometry
3
+ module Geometries
4
4
 
5
- # Validate values given to {Vedeu::Geometry::DSL}.
5
+ # Validate values given to {Vedeu::Geometries::DSL}.
6
6
  #
7
7
  # @api private
8
8
  #
@@ -55,6 +55,6 @@ module Vedeu
55
55
 
56
56
  end # Validator
57
57
 
58
- end # Geometry
58
+ end # Geometries
59
59
 
60
60
  end # Vedeu
@@ -1,13 +1,13 @@
1
1
  module Vedeu
2
2
 
3
- module Geometry
3
+ module Geometries
4
4
 
5
5
  # Provides the mechanism to align an interface/view vertically
6
6
  # within the available terminal space.
7
7
  #
8
8
  # @api private
9
9
  #
10
- class VerticalAlignment < Vedeu::Geometry::Alignment
10
+ class VerticalAlignment < Vedeu::Geometries::Alignment
11
11
 
12
12
  # @raise [Vedeu::Error::InvalidSyntax] When the value is not one
13
13
  # of :bottom, :centre, :left, :middle, :right, :top.
@@ -22,6 +22,6 @@ module Vedeu
22
22
 
23
23
  end # VerticalAlignment
24
24
 
25
- end # Geometry
25
+ end # Geometries
26
26
 
27
27
  end # Vedeu
@@ -1,22 +1,22 @@
1
1
  module Vedeu
2
2
 
3
- module Geometry
3
+ module Geometries
4
4
 
5
5
  # The X Dimension provides the width of an entity.
6
6
  #
7
7
  # @api private
8
8
  #
9
- class XDimension < Vedeu::Geometry::Dimension
9
+ class XDimension < Vedeu::Geometries::Dimension
10
10
 
11
11
  private
12
12
 
13
- # @see Vedeu::Geometry::Dimension#defaults
13
+ # @see Vedeu::Geometries::Dimension#defaults
14
14
  def defaults
15
15
  super.merge!(default: Vedeu.width)
16
16
  end
17
17
 
18
18
  end # XDimension
19
19
 
20
- end # Geometry
20
+ end # Geometries
21
21
 
22
22
  end # Vedeu
@@ -1,22 +1,22 @@
1
1
  module Vedeu
2
2
 
3
- module Geometry
3
+ module Geometries
4
4
 
5
5
  # The Y Dimension provides the height of an entity.
6
6
  #
7
7
  # @api private
8
8
  #
9
- class YDimension < Vedeu::Geometry::Dimension
9
+ class YDimension < Vedeu::Geometries::Dimension
10
10
 
11
11
  private
12
12
 
13
- # @see Vedeu::Geometry::Dimension#defaults
13
+ # @see Vedeu::Geometries::Dimension#defaults
14
14
  def defaults
15
15
  super.merge!(default: Vedeu.height)
16
16
  end
17
17
 
18
18
  end # YDimension
19
19
 
20
- end # Geometry
20
+ end # Geometries
21
21
 
22
22
  end # Vedeu
@@ -137,11 +137,12 @@ module Vedeu
137
137
  # Remove all members from the group.
138
138
  #
139
139
  # @return [Vedeu::Groups::Group]
140
- def reset
140
+ def reset!
141
141
  attrs = defaults.merge!(name: name)
142
142
 
143
143
  Vedeu::Groups::Group.store(attrs)
144
144
  end
145
+ alias_method :reset, :reset!
145
146
 
146
147
  # Show the named group of interfaces, or without a name, the
147
148
  # group of the currently focussed interface.
@@ -88,9 +88,10 @@ module Vedeu
88
88
  # before calling this method will be removed.
89
89
  #
90
90
  # @return [Hash<Symbol => Array<Symbol|String>>]
91
- def reset
91
+ def reset!
92
92
  @storage = in_memory
93
93
  end
94
+ alias_method :reset, :reset!
94
95
 
95
96
  private
96
97
 
@@ -111,7 +111,7 @@ module Vedeu
111
111
 
112
112
  # Returns the geometry for the interface.
113
113
  #
114
- # @return (see Vedeu::Geometry::Repository#by_name)
114
+ # @return (see Vedeu::Geometries::Repository#by_name)
115
115
  def geometry
116
116
  @geometry ||= Vedeu.geometries.by_name(name)
117
117
  end
@@ -143,8 +143,12 @@ module Vedeu
143
143
  def optimised_output
144
144
  Vedeu.timer("Optimised clearing #{clearing}: '#{name}'".freeze) do
145
145
  height.times.map do |iy|
146
- Vedeu::Geometry::Position.new(y + iy, x).to_s + colour.to_s + chars
147
- end.join + Vedeu::Geometry::Position.new(y, x).to_s
146
+ [
147
+ Vedeu::Geometries::Position.new(y + iy, x).to_s,
148
+ colour.to_s,
149
+ chars,
150
+ ].join
151
+ end.join + Vedeu::Geometries::Position.new(y, x).to_s
148
152
  end
149
153
  end
150
154
 
@@ -217,12 +221,10 @@ module Vedeu
217
221
 
218
222
  # @!method clear_by_name
219
223
  # @see Vedeu::Interfaces::Clear.clear_by_name
220
- def_delegators Vedeu::Interfaces::Clear,
221
- :clear_by_name
222
-
223
224
  # @!method clear_content_by_name
224
225
  # @see Vedeu::Interfaces.Clear.clear_content_by_name
225
226
  def_delegators Vedeu::Interfaces::Clear,
227
+ :clear_by_name,
226
228
  :clear_content_by_name
227
229
 
228
230
  # :nocov:
@@ -3,7 +3,7 @@ module Vedeu
3
3
  module Interfaces
4
4
 
5
5
  # An Interface represents a portion of the terminal defined by
6
- # {Vedeu::Geometry::Geometry}.
6
+ # {Vedeu::Geometries::Geometry}.
7
7
  #
8
8
  class Interface
9
9
 
@@ -46,9 +46,9 @@ module Vedeu
46
46
  @interface ||= Vedeu.interfaces.by_name(name)
47
47
  end
48
48
 
49
- # @return [Vedeu::Geometry::Position]
49
+ # @return [Vedeu::Geometries::Position]
50
50
  def position
51
- Vedeu::Geometry::Position.coerce(@position)
51
+ Vedeu::Geometries::Position.coerce(@position)
52
52
  end
53
53
 
54
54
  # @return [Hash]