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
@@ -57,7 +57,7 @@ module Vedeu
57
57
  alias maximised? maximised
58
58
 
59
59
  # @!attribute [rw] name
60
- # @return [String|Symbol]
60
+ # @macro return_name
61
61
  attr_accessor :name
62
62
 
63
63
  # @!attribute [rw] vertical_alignment
@@ -53,7 +53,7 @@ module Vedeu
53
53
  attr_reader :direction
54
54
 
55
55
  # @!attribute [r] name
56
- # @return [String|Symbol] The name of the interface/view.
56
+ # @macro return_name
57
57
  attr_reader :name
58
58
 
59
59
  # @!attribute [r] offset
@@ -97,7 +97,7 @@ module Vedeu
97
97
  }[direction]
98
98
  end
99
99
 
100
- # @return [Vedeu::Geometries::Geometry]
100
+ # @macro geometry_by_name
101
101
  def geometry
102
102
  @geometry ||= Vedeu.geometries.by_name(name)
103
103
  end
@@ -207,40 +207,4 @@ module Vedeu
207
207
 
208
208
  end # Geometries
209
209
 
210
- # :nocov:
211
-
212
- # {include:file:docs/events/by_name/movement_refresh.md}
213
- Vedeu.bind(:_movement_refresh_) do |name|
214
- Vedeu.trigger(:_clear_)
215
- Vedeu.trigger(:_refresh_)
216
- Vedeu.trigger(:_clear_view_, name)
217
- Vedeu.trigger(:_refresh_view_, name)
218
- end
219
-
220
- # {include:file:docs/events/by_name/view_down.md}
221
- Vedeu.bind(:_view_down_) do |name, offset|
222
- Vedeu::Geometries::Move.move(name: name, offset: offset, direction: :down)
223
- end
224
-
225
- # {include:file:docs/events/by_name/view_left.md}
226
- Vedeu.bind(:_view_left_) do |name, offset|
227
- Vedeu::Geometries::Move.move(name: name, offset: offset, direction: :left)
228
- end
229
-
230
- # {include:file:docs/events/by_name/view_right.md}
231
- Vedeu.bind(:_view_right_) do |name, offset|
232
- Vedeu::Geometries::Move.move(name: name, offset: offset, direction: :right)
233
- end
234
-
235
- # {include:file:docs/events/by_name/view_up.md}
236
- Vedeu.bind(:_view_up_) do |name, offset|
237
- Vedeu::Geometries::Move.move(name: name, offset: offset, direction: :up)
238
- end
239
-
240
- [:down, :left, :right, :up].each do |direction|
241
- Vedeu.bind_alias(:"_geometry_#{direction}_", :"_view_#{direction}_")
242
- end
243
-
244
- # :nocov:
245
-
246
210
  end # Vedeu
@@ -29,18 +29,4 @@ module Vedeu
29
29
  def_delegators Vedeu::Geometries::Repository,
30
30
  :geometries
31
31
 
32
- # :nocov:
33
-
34
- # See {file:docs/events/view.md#\_maximise_}
35
- Vedeu.bind(:_maximise_) do |name|
36
- Vedeu.geometries.by_name(name).maximise
37
- end
38
-
39
- # See {file:docs/events/view.md#\_unmaximise_}
40
- Vedeu.bind(:_unmaximise_) do |name|
41
- Vedeu.geometries.by_name(name).unmaximise
42
- end
43
-
44
- # :nocov:
45
-
46
32
  end # Vedeu
@@ -9,6 +9,29 @@ module Vedeu
9
9
 
10
10
  end # Groups
11
11
 
12
+ # :nocov:
13
+
14
+ # See {file:docs/events/visibility.md#\_clear_group_}
15
+ Vedeu.bind(:_clear_group_) do |name|
16
+ Vedeu.clear_by_group(name) if Vedeu.ready?
17
+ end
18
+
19
+ # See {file:docs/events/visibility.md#\_hide_group_}
20
+ Vedeu.bind(:_hide_group_) { |name| Vedeu.hide_group(name) }
21
+
22
+ # See {file:docs/events/refresh.md}
23
+ Vedeu.bind(:_refresh_group_) do |name|
24
+ Vedeu::Groups::Refresh.by_name(name) if Vedeu.ready?
25
+ end
26
+
27
+ # See {file:docs/events/visibility.md#\_show_group_}
28
+ Vedeu.bind(:_show_group_) { |name| Vedeu.show_group(name) }
29
+
30
+ # See {file:docs/events/visibility.md#\_toggle_group_}
31
+ Vedeu.bind(:_toggle_group_) { |name| Vedeu.toggle_group(name) }
32
+
33
+ # :nocov:
34
+
12
35
  end # Vedeu
13
36
 
14
37
  require 'vedeu/groups/clear'
@@ -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
  private
@@ -62,13 +62,4 @@ module Vedeu
62
62
  def_delegators Vedeu::Groups::Clear,
63
63
  :clear_by_group
64
64
 
65
- # :nocov:
66
-
67
- # See {file:docs/events/visibility.md#\_clear_group_}
68
- Vedeu.bind(:_clear_group_) do |name|
69
- Vedeu.clear_by_group(name) if Vedeu.ready?
70
- end
71
-
72
- # :nocov:
73
-
74
65
  end # Vedeu
@@ -193,17 +193,5 @@ module Vedeu
193
193
  :show_group,
194
194
  :toggle_group
195
195
 
196
- # :nocov:
197
-
198
- # See {file:docs/events/visibility.md#\_hide_group_}
199
- Vedeu.bind(:_hide_group_) { |name| Vedeu.hide_group(name) }
200
-
201
- # See {file:docs/events/visibility.md#\_show_group_}
202
- Vedeu.bind(:_show_group_) { |name| Vedeu.show_group(name) }
203
-
204
- # See {file:docs/events/visibility.md#\_toggle_group_}
205
- Vedeu.bind(:_toggle_group_) { |name| Vedeu.toggle_group(name) }
206
-
207
- # :nocov:
208
196
 
209
197
  end # Vedeu
@@ -46,7 +46,7 @@ module Vedeu
46
46
  protected
47
47
 
48
48
  # @!attribute [r] name
49
- # @return [String|Symbol]
49
+ # @macro return_name
50
50
  attr_reader :name
51
51
 
52
52
  private
@@ -66,7 +66,7 @@ module Vedeu
66
66
  @_group_name ||= interface.group
67
67
  end
68
68
 
69
- # @return [Vedeu::Interfaces::Interface]
69
+ # @macro interface_by_name
70
70
  def interface
71
71
  Vedeu.interfaces.by_name(name)
72
72
  end
@@ -75,13 +75,4 @@ module Vedeu
75
75
 
76
76
  end # Groups
77
77
 
78
- # :nocov:
79
-
80
- # See {file:docs/events/refresh.md}
81
- Vedeu.bind(:_refresh_group_) do |name|
82
- Vedeu::Groups::Refresh.by_name(name) if Vedeu.ready?
83
- end
84
-
85
- # :nocov:
86
-
87
78
  end # Vedeu
@@ -9,6 +9,41 @@ module Vedeu
9
9
 
10
10
  end # Input
11
11
 
12
+ # :nocov:
13
+
14
+ # See {file:docs/events/system.md#\_keypress_}
15
+ Vedeu.bind(:_keypress_) do |key, name|
16
+ Vedeu.timer('Executing keypress') do
17
+ Vedeu.add_keypress(key)
18
+
19
+ Vedeu.keypress(key, name)
20
+ end
21
+ end
22
+
23
+ # See {file:docs/events/drb.md#\_drb_input_}
24
+ Vedeu.bind(:_drb_input_) do |data, type|
25
+ Vedeu.log(type: :drb, message: "Sending input (#{type})")
26
+
27
+ if type == :command
28
+ Vedeu.trigger(:_command_, data)
29
+
30
+ else
31
+ Vedeu.trigger(:_keypress_, data)
32
+
33
+ end
34
+ end
35
+
36
+ # See {file:docs/events/system.md#\_command_}
37
+ Vedeu.bind(:_command_) do |command|
38
+ Vedeu.timer('Executing command') do
39
+ Vedeu.add_command(command)
40
+
41
+ Vedeu.trigger(:command, command)
42
+ end
43
+ end
44
+
45
+ # :nocov:
46
+
12
47
  end # Vedeu
13
48
 
14
49
  require 'vedeu/input/raw'
@@ -106,7 +106,7 @@ module Vedeu
106
106
  end
107
107
  end
108
108
 
109
- # @return [Vedeu::Interfaces::Interface]
109
+ # @macro interface_by_name
110
110
  def interface
111
111
  Vedeu.interfaces.by_name(name)
112
112
  end
@@ -135,7 +135,7 @@ module Vedeu
135
135
  console.gets.chomp
136
136
  end
137
137
 
138
- # @return [String|Symbol]
138
+ # @macro return_name
139
139
  def name
140
140
  Vedeu.focus
141
141
  end
@@ -172,39 +172,4 @@ module Vedeu
172
172
  def_delegators Vedeu::Input::Mapper,
173
173
  :keypress
174
174
 
175
- # :nocov:
176
-
177
- # See {file:docs/events/system.md#\_keypress_}
178
- Vedeu.bind(:_keypress_) do |key, name|
179
- Vedeu.timer('Executing keypress') do
180
- Vedeu.add_keypress(key)
181
-
182
- Vedeu.keypress(key, name)
183
- end
184
- end
185
-
186
- # See {file:docs/events/drb.md#\_drb_input_}
187
- Vedeu.bind(:_drb_input_) do |data, type|
188
- Vedeu.log(type: :drb, message: "Sending input (#{type})")
189
-
190
- if type == :command
191
- Vedeu.trigger(:_command_, data)
192
-
193
- else
194
- Vedeu.trigger(:_keypress_, data)
195
-
196
- end
197
- end
198
-
199
- # See {file:docs/events/system.md#\_command_}
200
- Vedeu.bind(:_command_) do |command|
201
- Vedeu.timer('Executing command') do
202
- Vedeu.add_command(command)
203
-
204
- Vedeu.trigger(:command, command)
205
- end
206
- end
207
-
208
- # :nocov:
209
-
210
175
  end # Vedeu
@@ -38,7 +38,7 @@ module Vedeu
38
38
 
39
39
  # @return [IO]
40
40
  def console
41
- @console ||= Vedeu::Terminal.console
41
+ @_console ||= Vedeu::Terminal.console
42
42
  end
43
43
 
44
44
  end # Raw
@@ -52,7 +52,7 @@ module Vedeu
52
52
 
53
53
  # @return [IO]
54
54
  def console
55
- @console ||= Vedeu::Terminal.console
55
+ @_console ||= Vedeu::Terminal.console
56
56
  end
57
57
 
58
58
  # @return [Boolean]
@@ -7,6 +7,30 @@ module Vedeu
7
7
 
8
8
  end # Interfaces
9
9
 
10
+ # :nocov:
11
+
12
+ # See {file:docs/events/visibility.md#\_clear_view_}
13
+ Vedeu.bind(:_clear_view_) { |name| Vedeu.clear_by_name(name) if Vedeu.ready? }
14
+
15
+ # See {file:docs/events/visibility.md#\_clear_view_content_}
16
+ Vedeu.bind(:_clear_view_content_) do |name|
17
+ Vedeu.clear_content_by_name(name) if Vedeu.ready?
18
+ end
19
+
20
+ # See {file:docs/events/visibility.md#\_hide_interface_}
21
+ Vedeu.bind(:_hide_interface_) { |name| Vedeu.hide_interface(name) }
22
+ Vedeu.bind_alias(:_hide_view_, :_hide_interface_)
23
+
24
+ # See {file:docs/events/visibility.md#\_show_interface_}
25
+ Vedeu.bind(:_show_interface_) { |name| Vedeu.show_interface(name) }
26
+ Vedeu.bind_alias(:_show_view_, :_show_interface_)
27
+
28
+ # See {file:docs/events/visibility.md#\_toggle_interface_}
29
+ Vedeu.bind(:_toggle_interface_) { |name| Vedeu.toggle_interface(name) }
30
+ Vedeu.bind_alias(:_toggle_view_, :_toggle_interface_)
31
+
32
+ # :nocov:
33
+
10
34
  end # Vedeu
11
35
 
12
36
  require 'vedeu/interfaces/interface'
@@ -67,19 +67,19 @@ module Vedeu
67
67
  protected
68
68
 
69
69
  # @!attribute [r] name
70
- # @return [String|Symbol]
70
+ # @macro return_name
71
71
  attr_reader :name
72
72
 
73
73
  private
74
74
 
75
75
  # @return [String] A string of blank characters.
76
76
  def chars
77
- @chars ||= (' ' * width)
77
+ @_chars ||= (' ' * width)
78
78
  end
79
79
 
80
80
  # @return [Vedeu::Colours::Colour]
81
81
  def colour
82
- @colour ||= interface.colour
82
+ @_colour ||= interface.colour
83
83
  end
84
84
 
85
85
  # @return [Boolean]
@@ -100,25 +100,23 @@ module Vedeu
100
100
  options[:direct]
101
101
  end
102
102
 
103
- # Returns the geometry for the interface.
104
- #
105
- # @return (see Vedeu::Geometries::Repository#by_name)
103
+ # @macro geometry_by_name
106
104
  def geometry
107
- @geometry ||= Vedeu.geometries.by_name(name)
105
+ @_geometry ||= Vedeu.geometries.by_name(name)
108
106
  end
109
107
 
110
108
  # @return [Fixnum]
111
109
  def height
112
- @height ||= if content_only?
113
- geometry.bordered_height
110
+ @_height ||= if content_only?
111
+ geometry.bordered_height
114
112
 
115
- else
116
- geometry.height
113
+ else
114
+ geometry.height
117
115
 
118
- end
116
+ end
119
117
  end
120
118
 
121
- # @return [Vedeu::Interfaces::Interface]
119
+ # @macro interface_by_name
122
120
  def interface
123
121
  Vedeu.interfaces.by_name(name)
124
122
  end
@@ -149,7 +147,7 @@ module Vedeu
149
147
  # @return [Array<Array<Vedeu::Cells::Char>>]
150
148
  def output
151
149
  Vedeu.timer("Clearing #{clearing}: '#{name}'") do
152
- @clear ||= Array.new(height) do |iy|
150
+ @_clear ||= Array.new(height) do |iy|
153
151
  Array.new(width) do |ix|
154
152
  position = Vedeu::Geometries::Position.new((y + iy), (x + ix))
155
153
  Vedeu::Cells::Clear.new(colour: colour,
@@ -162,13 +160,13 @@ module Vedeu
162
160
 
163
161
  # @return [String]
164
162
  def clearing
165
- @clearing ||= if content_only?
166
- 'content'
163
+ @_clearing ||= if content_only?
164
+ 'content'
167
165
 
168
- else
169
- 'interface'
166
+ else
167
+ 'interface'
170
168
 
171
- end
169
+ end
172
170
  end
173
171
 
174
172
  # @param pos_y [Fixnum]
@@ -181,35 +179,35 @@ module Vedeu
181
179
 
182
180
  # @return [Fixnum]
183
181
  def width
184
- @width ||= if content_only?
185
- geometry.bordered_width
182
+ @_width ||= if content_only?
183
+ geometry.bordered_width
186
184
 
187
- else
188
- geometry.width
185
+ else
186
+ geometry.width
189
187
 
190
- end
188
+ end
191
189
  end
192
190
 
193
191
  # @return [Fixnum]
194
192
  def y
195
- @y ||= if content_only?
196
- geometry.by
193
+ @_y ||= if content_only?
194
+ geometry.by
197
195
 
198
- else
199
- geometry.y
196
+ else
197
+ geometry.y
200
198
 
201
- end
199
+ end
202
200
  end
203
201
 
204
202
  # @return [Fixnum]
205
203
  def x
206
- @x ||= if content_only?
207
- geometry.bx
204
+ @_x ||= if content_only?
205
+ geometry.bx
208
206
 
209
- else
210
- geometry.x
207
+ else
208
+ geometry.x
211
209
 
212
- end
210
+ end
213
211
  end
214
212
 
215
213
  end # Clear
@@ -226,16 +224,4 @@ module Vedeu
226
224
  :clear_by_name,
227
225
  :clear_content_by_name
228
226
 
229
- # :nocov:
230
-
231
- # See {file:docs/events/visibility.md#\_clear_view_}
232
- Vedeu.bind(:_clear_view_) { |name| Vedeu.clear_by_name(name) if Vedeu.ready? }
233
-
234
- # See {file:docs/events/visibility.md#\_clear_view_content_}
235
- Vedeu.bind(:_clear_view_content_) do |name|
236
- Vedeu.clear_content_by_name(name) if Vedeu.ready?
237
- end
238
-
239
- # :nocov:
240
-
241
227
  end # Vedeu