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
@@ -183,20 +183,4 @@ module Vedeu
183
183
  :show_interface,
184
184
  :toggle_interface
185
185
 
186
- # :nocov:
187
-
188
- # See {file:docs/events/visibility.md#\_hide_interface_}
189
- Vedeu.bind(:_hide_interface_) { |name| Vedeu.hide_interface(name) }
190
- Vedeu.bind_alias(:_hide_view_, :_hide_interface_)
191
-
192
- # See {file:docs/events/visibility.md#\_show_interface_}
193
- Vedeu.bind(:_show_interface_) { |name| Vedeu.show_interface(name) }
194
- Vedeu.bind_alias(:_show_view_, :_show_interface_)
195
-
196
- # See {file:docs/events/visibility.md#\_toggle_interface_}
197
- Vedeu.bind(:_toggle_interface_) { |name| Vedeu.toggle_interface(name) }
198
- Vedeu.bind_alias(:_toggle_view_, :_toggle_interface_)
199
-
200
- # :nocov:
201
-
202
186
  end # Vedeu
@@ -9,6 +9,50 @@ module Vedeu
9
9
 
10
10
  end # Menus
11
11
 
12
+ # :nocov:
13
+
14
+ # See {file:docs/events/menu.md#\_menu_bottom_}
15
+ Vedeu.bind(:_menu_bottom_) do |name|
16
+ Vedeu.menus.by_name(name).bottom_item
17
+ end
18
+
19
+ # See {file:docs/events/menu.md#\_menu_current_}
20
+ Vedeu.bind(:_menu_current_) do |name|
21
+ Vedeu.menus.by_name(name).current_item
22
+ end
23
+
24
+ # See {file:docs/events/menu.md#\_menu_deselect_}
25
+ Vedeu.bind(:_menu_deselect_) do |name|
26
+ Vedeu.menus.by_name(name).deselect_item
27
+ end
28
+
29
+ # See {file:docs/events/menu.md#\_menu_items_}
30
+ Vedeu.bind(:_menu_items_) { |name| Vedeu.menus.by_name(name).items }
31
+
32
+ # See {file:docs/events/menu.md#\_menu_next_}
33
+ Vedeu.bind(:_menu_next_) { |name| Vedeu.menus.by_name(name).next_item }
34
+
35
+ # See {file:docs/events/menu.md#\_menu_prev_}
36
+ Vedeu.bind(:_menu_prev_) { |name| Vedeu.menus.by_name(name).prev_item }
37
+
38
+ # See {file:docs/events/menu.md#\_menu_selected_}
39
+ Vedeu.bind(:_menu_selected_) do |name|
40
+ Vedeu.menus.by_name(name).selected_item
41
+ end
42
+
43
+ # See {file:docs/events/menu.md#\_menu_select_}
44
+ Vedeu.bind(:_menu_select_) do |name|
45
+ Vedeu.menus.by_name(name).select_item
46
+ end
47
+
48
+ # See {file:docs/events/menu.md#\_menu_top_}
49
+ Vedeu.bind(:_menu_top_) { |name| Vedeu.menus.by_name(name).top_item }
50
+
51
+ # See {file:docs/events/menu.md#\_menu_view_}
52
+ Vedeu.bind(:_menu_view_) { |name| Vedeu.menus.by_name(name).view }
53
+
54
+ # :nocov:
55
+
12
56
  end # Vedeu
13
57
 
14
58
  require 'vedeu/menus/dsl'
@@ -11,9 +11,9 @@ module Vedeu
11
11
 
12
12
  include Vedeu::Repositories::Model
13
13
 
14
- # @!attribute [rw] collection
14
+ # @!attribute [w] collection
15
15
  # @return [Array]
16
- attr_accessor :collection
16
+ attr_writer :collection
17
17
 
18
18
  # Returns the index of the value in the collection which is
19
19
  # current.
@@ -50,12 +50,17 @@ module Vedeu
50
50
  end
51
51
  end
52
52
 
53
+ # @return [Array]
54
+ def collection
55
+ @collection || []
56
+ end
57
+
53
58
  # Returns the item from the collection which shares the same
54
59
  # index as the value of {Vedeu::Menus::Menu#current}.
55
60
  #
56
61
  # @return [void]
57
62
  def current_item
58
- @collection[@current]
63
+ collection[@current]
59
64
  end
60
65
 
61
66
  # Returns a DSL instance responsible for defining the DSL
@@ -77,7 +82,7 @@ module Vedeu
77
82
  def selected_item
78
83
  return nil unless @selected
79
84
 
80
- @collection[@selected]
85
+ collection[@selected]
81
86
  end
82
87
 
83
88
  # Returns a new collection of items.
@@ -94,7 +99,7 @@ module Vedeu
94
99
  # @return [Array]
95
100
  def items
96
101
  items = []
97
- @collection.each_with_index do |item, index|
102
+ collection.each_with_index do |item, index|
98
103
  items << if index == @current && index == @selected
99
104
  [true, true, item]
100
105
 
@@ -116,7 +121,7 @@ module Vedeu
116
121
  #
117
122
  # @return [Array]
118
123
  def view
119
- items[@current, @collection.size]
124
+ items[@current, collection.size]
120
125
  end
121
126
 
122
127
  # Sets the value of current to be the first item of the
@@ -183,14 +188,14 @@ module Vedeu
183
188
  #
184
189
  # @return [Fixnum]
185
190
  def last
186
- @collection.size - 1
191
+ collection.size - 1
187
192
  end
188
193
 
189
194
  # Returns the size of the collection.
190
195
  #
191
196
  # @return [Fixnum]
192
197
  def size
193
- @collection.size
198
+ collection.size
194
199
  end
195
200
 
196
201
  private
@@ -28,48 +28,4 @@ module Vedeu
28
28
  def_delegators Vedeu::Menus::Repository,
29
29
  :menus
30
30
 
31
- # :nocov:
32
-
33
- # See {file:docs/events/menu.md#\_menu_bottom_}
34
- Vedeu.bind(:_menu_bottom_) do |name|
35
- Vedeu.menus.by_name(name).bottom_item
36
- end
37
-
38
- # See {file:docs/events/menu.md#\_menu_current_}
39
- Vedeu.bind(:_menu_current_) do |name|
40
- Vedeu.menus.by_name(name).current_item
41
- end
42
-
43
- # See {file:docs/events/menu.md#\_menu_deselect_}
44
- Vedeu.bind(:_menu_deselect_) do |name|
45
- Vedeu.menus.by_name(name).deselect_item
46
- end
47
-
48
- # See {file:docs/events/menu.md#\_menu_items_}
49
- Vedeu.bind(:_menu_items_) { |name| Vedeu.menus.by_name(name).items }
50
-
51
- # See {file:docs/events/menu.md#\_menu_next_}
52
- Vedeu.bind(:_menu_next_) { |name| Vedeu.menus.by_name(name).next_item }
53
-
54
- # See {file:docs/events/menu.md#\_menu_prev_}
55
- Vedeu.bind(:_menu_prev_) { |name| Vedeu.menus.by_name(name).prev_item }
56
-
57
- # See {file:docs/events/menu.md#\_menu_selected_}
58
- Vedeu.bind(:_menu_selected_) do |name|
59
- Vedeu.menus.by_name(name).selected_item
60
- end
61
-
62
- # See {file:docs/events/menu.md#\_menu_select_}
63
- Vedeu.bind(:_menu_select_) do |name|
64
- Vedeu.menus.by_name(name).select_item
65
- end
66
-
67
- # See {file:docs/events/menu.md#\_menu_top_}
68
- Vedeu.bind(:_menu_top_) { |name| Vedeu.menus.by_name(name).top_item }
69
-
70
- # See {file:docs/events/menu.md#\_menu_view_}
71
- Vedeu.bind(:_menu_view_) { |name| Vedeu.menus.by_name(name).view }
72
-
73
- # :nocov:
74
-
75
31
  end # Vedeu
@@ -8,6 +8,19 @@ module Vedeu
8
8
 
9
9
  end # Models
10
10
 
11
+ # :nocov:
12
+
13
+ # See {file:docs/events/focus.md#\_focus_by_name_}
14
+ Vedeu.bind(:_focus_by_name_) { |name| Vedeu.focus_by_name(name) }
15
+
16
+ # See {file:docs/events/focus.md#\_focus_next_}
17
+ Vedeu.bind(:_focus_next_) { Vedeu.focus_next }
18
+
19
+ # See {file:docs/events/focus.md#\_focus_prev_}
20
+ Vedeu.bind(:_focus_prev_) { Vedeu.focus_previous }
21
+
22
+ # :nocov:
23
+
11
24
  end # Vedeu
12
25
 
13
26
  require 'vedeu/models/toggleable'
@@ -271,17 +271,4 @@ module Vedeu
271
271
  :focus_next,
272
272
  :focus_previous
273
273
 
274
- # :nocov:
275
-
276
- # See {file:docs/events/focus.md#\_focus_by_name_}
277
- Vedeu.bind(:_focus_by_name_) { |name| Vedeu.focus_by_name(name) }
278
-
279
- # See {file:docs/events/focus.md#\_focus_next_}
280
- Vedeu.bind(:_focus_next_) { Vedeu.focus_next }
281
-
282
- # See {file:docs/events/focus.md#\_focus_prev_}
283
- Vedeu.bind(:_focus_prev_) { Vedeu.focus_previous }
284
-
285
- # :nocov:
286
-
287
274
  end # Vedeu
@@ -138,7 +138,7 @@ module Vedeu
138
138
  end
139
139
 
140
140
  # @macro param_name
141
- # @return [Vedeu::Buffers::Buffer]
141
+ # @macro buffer_by_name
142
142
  def buffer(name)
143
143
  Vedeu.buffers.by_name(name)
144
144
  end
@@ -13,7 +13,7 @@ module Vedeu
13
13
  attr_reader :attributes
14
14
 
15
15
  # @!attribute [r] name
16
- # @return [String|Symbol]
16
+ # @macro return_name
17
17
  attr_reader :name
18
18
 
19
19
  # Returns a new instance of the Vedeu::Null::Generic class.
@@ -9,6 +9,13 @@ module Vedeu
9
9
 
10
10
  end # Output
11
11
 
12
+ # :nocov:
13
+
14
+ # See {file:docs/events/refresh.md}
15
+ Vedeu.bind(:_refresh_) { Vedeu::Output::Refresh.all if Vedeu.ready? }
16
+
17
+ # :nocov:
18
+
12
19
  end # Vedeu
13
20
 
14
21
  require 'vedeu/output/compressors/all'
@@ -24,7 +24,7 @@ module Vedeu
24
24
 
25
25
  # Returns a new instance of Vedeu::Output::Compressor.
26
26
  #
27
- # @param output [Array<Array<Vedeu::Cells::Char>>]
27
+ # @param output [Vedeu::Models::Page]
28
28
  # @param options [Hash]
29
29
  # @option options compression [Boolean]
30
30
  # @return [Vedeu::Output::Compressor]
@@ -41,6 +41,10 @@ module Vedeu
41
41
  def render
42
42
  return [] unless output?
43
43
 
44
+ Vedeu.log(type: :compress,
45
+ message: "Original size: #{original_size} / " \
46
+ "New size: #{content_size}")
47
+
44
48
  Vedeu::Output::CompressorCache.cache(content, compression?)
45
49
  end
46
50
 
@@ -57,17 +61,18 @@ module Vedeu
57
61
  #
58
62
  # @return [Array]
59
63
  def content
60
- output.content.reject do |cell|
64
+ @_content ||= output.content.reject do |cell|
61
65
  cell.class == Vedeu::Cells::Empty
62
- end.tap do |cells|
63
- Vedeu.log(type: :compress,
64
- message: "Orignal size: #{content_size} / " \
65
- "New size: #{cells.size}")
66
66
  end
67
67
  end
68
68
 
69
69
  # @return [Fixnum]
70
70
  def content_size
71
+ content.size
72
+ end
73
+
74
+ # @return [Fixnum]
75
+ def original_size
71
76
  output.content.size
72
77
  end
73
78
 
@@ -60,6 +60,8 @@ module Vedeu
60
60
  # @return [void]
61
61
  attr_reader :content
62
62
 
63
+ private
64
+
63
65
  # Compress by not repeatedly sending the same colours for each
64
66
  # character which has the same colours as the last character
65
67
  # output.
@@ -32,11 +32,4 @@ module Vedeu
32
32
 
33
33
  end # Output
34
34
 
35
- # :nocov:
36
-
37
- # See {file:docs/events/refresh.md}
38
- Vedeu.bind(:_refresh_) { Vedeu::Output::Refresh.all if Vedeu.ready? }
39
-
40
- # :nocov:
41
-
42
35
  end # Vedeu
@@ -97,15 +97,12 @@ module Vedeu
97
97
  offset - dimension
98
98
  end
99
99
 
100
- # @return [Vedeu::Cursors::Cursor]
101
- # @see Vedeu::Cursors::Repository#by_name
100
+ # @macro cursor_by_name
102
101
  def cursor
103
102
  Vedeu.cursors.by_name(name)
104
103
  end
105
104
 
106
- # Returns the geometry for the interface.
107
- #
108
- # @return (see Vedeu::Geometries::Repository#by_name)
105
+ # @macro geometry_by_name
109
106
  def geometry
110
107
  Vedeu.geometries.by_name(name)
111
108
  end
@@ -7,7 +7,7 @@ module Vedeu
7
7
  class Plugin
8
8
 
9
9
  # @!attribute [r] name
10
- # @return [String|Symbol]
10
+ # @macro return_name
11
11
  attr_reader :name
12
12
 
13
13
  # @!attribute [r] gem
@@ -118,9 +118,14 @@ module Vedeu
118
118
 
119
119
  private
120
120
 
121
+ # @macro interface_by_name
122
+ def interface
123
+ Vedeu.interfaces.by_name(name)
124
+ end
125
+
121
126
  # @return [Vedeu::Colours::Colour]
122
127
  def named_colour
123
- Vedeu.interfaces.by_name(name).colour
128
+ interface.colour
124
129
  end
125
130
 
126
131
  # @return [Boolean]
@@ -86,7 +86,7 @@ module Vedeu
86
86
 
87
87
  # @return [Mutex]
88
88
  def mutex
89
- @mutex ||= Mutex.new
89
+ @_mutex ||= Mutex.new
90
90
  end
91
91
 
92
92
  # @param block [Proc]
@@ -65,7 +65,7 @@ module Vedeu
65
65
  #
66
66
  # @return [Array]
67
67
  def storage
68
- @storage ||= Set.new
68
+ @_storage ||= Set.new
69
69
  end
70
70
 
71
71
  end # Repositories
@@ -8,6 +8,34 @@ module Vedeu
8
8
 
9
9
  end # Runtime
10
10
 
11
+ # :nocov:
12
+
13
+ # See {file:docs/events/system.md#\_cleanup_}
14
+ Vedeu.bind(:_cleanup_) do
15
+ Vedeu.trigger(:_drb_stop_)
16
+ Vedeu.trigger(:cleanup)
17
+ end
18
+
19
+ # See {file:docs/events/system.md#\_exit_}
20
+ Vedeu.bind(:_exit_) { Vedeu.exit }
21
+
22
+ # See {file:docs/events/application.md#\_goto_}
23
+ Vedeu.bind(:_goto_) do |controller, action, **args|
24
+ Vedeu::Runtime::Router.goto(controller, action, **args)
25
+ end
26
+
27
+ # Vedeu.bind_alias(:_action_, :_goto_)
28
+
29
+ # See {file:docs/events/system.md#\_initialize_}
30
+ Vedeu.bind(:_initialize_) { Vedeu.ready! }
31
+
32
+ # See {file:docs/events/system.md#\_mode_switch_}
33
+ Vedeu.bind(:_mode_switch_) do |mode|
34
+ Vedeu::Runtime::MainLoop.mode_switch!(mode)
35
+ end
36
+
37
+ # :nocov:
38
+
11
39
  end # Vedeu
12
40
 
13
41
  require 'vedeu/runtime/traps'
@@ -144,22 +144,4 @@ module Vedeu
144
144
  def_delegators Vedeu::Runtime::Application,
145
145
  :exit
146
146
 
147
- # :nocov:
148
-
149
- # See {file:docs/events/system.md#\_exit_}
150
- Vedeu.bind(:_exit_) { Vedeu.exit }
151
-
152
- # See {file:docs/events/system.md#\_mode_switch_}
153
- Vedeu.bind(:_mode_switch_) do |mode|
154
- Vedeu::Runtime::MainLoop.mode_switch!(mode)
155
- end
156
-
157
- # See {file:docs/events/system.md#\_cleanup_}
158
- Vedeu.bind(:_cleanup_) do
159
- Vedeu.trigger(:_drb_stop_)
160
- Vedeu.trigger(:cleanup)
161
- end
162
-
163
- # :nocov:
164
-
165
147
  end # Vedeu