vedeu 0.6.6 → 0.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +0 -30
  3. data/lib/vedeu/all.rb +0 -1
  4. data/lib/vedeu/api.rb +5 -139
  5. data/lib/vedeu/application/application_controller.rb +12 -10
  6. data/lib/vedeu/application/application_helper.rb +3 -3
  7. data/lib/vedeu/application/application_view.rb +7 -6
  8. data/lib/vedeu/application/controller.rb +16 -10
  9. data/lib/vedeu/bindings/application.rb +6 -3
  10. data/lib/vedeu/bindings/bindings.rb +7 -6
  11. data/lib/vedeu/bindings/document.rb +18 -18
  12. data/lib/vedeu/bindings/drb.rb +12 -8
  13. data/lib/vedeu/bindings/focus.rb +12 -9
  14. data/lib/vedeu/bindings/menus.rb +12 -11
  15. data/lib/vedeu/bindings/movement.rb +23 -22
  16. data/lib/vedeu/bindings/refresh.rb +13 -10
  17. data/lib/vedeu/bindings/visibility.rb +10 -8
  18. data/lib/vedeu/borders/all.rb +26 -0
  19. data/lib/vedeu/borders/dsl.rb +1 -23
  20. data/lib/vedeu/buffers/all.rb +12 -0
  21. data/lib/vedeu/buffers/buffer.rb +1 -10
  22. data/lib/vedeu/buffers/refresh.rb +57 -0
  23. data/lib/vedeu/buffers/virtual_buffer.rb +1 -1
  24. data/lib/vedeu/cursors/all.rb +9 -0
  25. data/lib/vedeu/cursors/cursor.rb +16 -0
  26. data/lib/vedeu/dsl/interface.rb +4 -4
  27. data/lib/vedeu/events/aliases.rb +28 -9
  28. data/lib/vedeu/events/collection.rb +1 -0
  29. data/lib/vedeu/events/trigger.rb +5 -3
  30. data/lib/vedeu/geometry/all.rb +7 -0
  31. data/lib/vedeu/geometry/position.rb +2 -2
  32. data/lib/vedeu/input/editor/editor.rb +1 -1
  33. data/lib/vedeu/log/log.rb +6 -0
  34. data/lib/vedeu/log/timer.rb +2 -2
  35. data/lib/vedeu/models/focus.rb +3 -0
  36. data/lib/vedeu/models/group.rb +13 -0
  37. data/lib/vedeu/models/interface.rb +17 -1
  38. data/lib/vedeu/models/toggleable.rb +2 -1
  39. data/lib/vedeu/models/views/collections/chars.rb +1 -0
  40. data/lib/vedeu/models/views/collections/lines.rb +1 -0
  41. data/lib/vedeu/models/views/collections/streams.rb +1 -0
  42. data/lib/vedeu/models/views/collections/view_collection.rb +1 -0
  43. data/lib/vedeu/models/views/line.rb +2 -2
  44. data/lib/vedeu/null/generic.rb +27 -4
  45. data/lib/vedeu/null/interface.rb +1 -32
  46. data/lib/vedeu/null/menu.rb +1 -16
  47. data/lib/vedeu/null/view.rb +1 -33
  48. data/lib/vedeu/options.rb +3 -0
  49. data/lib/vedeu/output/clear/named_group.rb +5 -0
  50. data/lib/vedeu/output/clear/named_interface.rb +5 -0
  51. data/lib/vedeu/output/direct.rb +2 -2
  52. data/lib/vedeu/output/viewport.rb +1 -1
  53. data/lib/vedeu/refresh/refresh_group.rb +1 -1
  54. data/lib/vedeu/runtime/application.rb +3 -0
  55. data/lib/vedeu/terminal/terminal.rb +3 -0
  56. data/lib/vedeu/version.rb +1 -1
  57. data/test/lib/vedeu/buffers/refresh_test.rb +54 -0
  58. data/test/lib/vedeu/null/generic_test.rb +18 -0
  59. data/test/lib/vedeu/null/interface_test.rb +4 -30
  60. data/test/lib/vedeu/null/menu_test.rb +1 -18
  61. data/test/lib/vedeu/null/view_test.rb +6 -31
  62. data/{examples → test/support}/colour_support.sh +0 -0
  63. data/{examples → test/support/examples}/borders_app.rb +0 -0
  64. data/{examples → test/support/examples}/configuration_app.rb +0 -0
  65. data/{examples → test/support/examples}/drb_app.rb +0 -0
  66. data/{examples → test/support/examples}/editor_app.rb +0 -0
  67. data/{examples → test/support/examples}/focus_app.rb +0 -0
  68. data/{examples → test/support/examples}/hello_world.rb +0 -0
  69. data/{examples → test/support/examples}/material_colours_app.rb +0 -0
  70. data/{examples → test/support/examples}/material_colours_app_20150721.svg +0 -0
  71. data/{examples → test/support/examples}/typed_commands/command.erb +0 -0
  72. data/{examples → test/support/examples}/typed_commands/output.erb +0 -0
  73. data/{examples → test/support/examples}/typed_commands/status.erb +0 -0
  74. data/{examples → test/support/examples}/typed_commands/typed_commands_app.rb +0 -0
  75. data/{examples → test/support/examples}/view_templates_app/default.erb +0 -0
  76. data/{examples → test/support/examples}/view_templates_app/prune.erb +0 -0
  77. data/{examples → test/support/examples}/view_templates_app/view_templates_app.rb +0 -0
  78. data/{examples → test/support/examples}/view_templates_app/wrap.erb +0 -0
  79. metadata +38 -21
  80. data/lib/vedeu/refresh/refresh_buffer.rb +0 -53
  81. data/test/lib/vedeu/refresh/refresh_buffer_test.rb +0 -50
@@ -2,14 +2,16 @@ module Vedeu
2
2
 
3
3
  module Bindings
4
4
 
5
- # System events relating to the visibility of cursors or interfaces.
5
+ # System events relating to the visibility of cursors or
6
+ # interfaces.
6
7
  #
7
8
  # :nocov:
8
9
  module Visibility
9
10
 
10
11
  extend self
11
12
 
12
- # Setup events relating to visibility. This method is called by Vedeu.
13
+ # Setup events relating to visibility. This method is called by
14
+ # Vedeu.
13
15
  #
14
16
  # @return [TrueClass]
15
17
  def setup!
@@ -27,8 +29,8 @@ module Vedeu
27
29
 
28
30
  private
29
31
 
30
- # Clears the spaces occupied by the interfaces belonging to the named
31
- # group.
32
+ # Clears the spaces occupied by the interfaces belonging to the
33
+ # named group.
32
34
  #
33
35
  # @example
34
36
  # Vedeu.trigger(:_clear_group_, name)
@@ -41,8 +43,8 @@ module Vedeu
41
43
  end
42
44
  end
43
45
 
44
- # Hide the cursor of the named interface or when a name is not given, the
45
- # interface currently in focus.
46
+ # Hide the cursor of the named interface or when a name is not
47
+ # given, the interface currently in focus.
46
48
  #
47
49
  # @example
48
50
  # Vedeu.trigger(:_hide_cursor_, name)
@@ -76,8 +78,8 @@ module Vedeu
76
78
  end
77
79
  end
78
80
 
79
- # Show the cursor of the named interface or when a name is not given, the
80
- # interface currently in focus.
81
+ # Show the cursor of the named interface or when a name is not
82
+ # given, the interface currently in focus.
81
83
  #
82
84
  # @example
83
85
  # Vedeu.trigger(:_show_cursor_, name)
@@ -1,5 +1,31 @@
1
1
  module Vedeu
2
2
 
3
+ # Borders are defined by name for each of the client application's
4
+ # interfaces or views. They can be enabled or disabled (which controls
5
+ # whether they are rendered or not), they have their own colours and styles,
6
+ # and each aspect of the border can be controlled.
7
+ #
8
+ # @example
9
+ # # Borders can be defined when defining your interface...
10
+ # Vedeu.interface 'my_interface' do
11
+ # border do
12
+ # # ...
13
+ # end
14
+ #
15
+ # # ...or as part of a view definition...
16
+ # Vedeu.renders do
17
+ # view 'border_demo' do
18
+ # border do
19
+ # # ...
20
+ # end
21
+ #
22
+ # # ...or standalone; referencing the target interface or view.
23
+ # Vedeu.border 'some_interface' do
24
+ # # ...
25
+ # end
26
+ #
27
+ # See {Vedeu::Borders::DSL} for DSL methods for defining borders.
28
+ #
3
29
  module Borders
4
30
 
5
31
  end # Borders
@@ -2,29 +2,7 @@ module Vedeu
2
2
 
3
3
  module Borders
4
4
 
5
- # Borders are defined by name for each of the client application's
6
- # interfaces or views. They can be enabled or disabled (which controls
7
- # whether they are rendered or not), they have their own colours and styles,
8
- # and each aspect of the border can be controlled.
9
- #
10
- # @example
11
- # # Borders can be defined when defining your interface...
12
- # Vedeu.interface 'my_interface' do
13
- # border do
14
- # # ...
15
- # end
16
- #
17
- # # ...or as part of a view definition...
18
- # Vedeu.renders do
19
- # view 'border_demo' do
20
- # border do
21
- # # ...
22
- # end
23
- #
24
- # # ...or standalone; referencing the target interface or view.
25
- # Vedeu.border 'some_interface' do
26
- # # ...
27
- # end
5
+ # Provides a mechanism to help configure borders in Vedeu.
28
6
  #
29
7
  class DSL
30
8
 
@@ -1,5 +1,16 @@
1
1
  module Vedeu
2
2
 
3
+ # The Buffer object represents the states of display for an interface. The
4
+ # states are 'front', 'back' and 'previous'.
5
+ #
6
+ # [Back] -> [Front] -> [Previous]
7
+ #
8
+ # The content on the screen, or last output will always be the 'Front'
9
+ # buffer. Content due to be displayed on next refresh will come from the
10
+ # 'Back' buffer when available, otherwise from the current 'Front' buffer.
11
+ # When new content is copied to the 'Front' buffer, the current 'Front'
12
+ # buffer is also copied to the 'Previous' buffer.
13
+ #
3
14
  module Buffers
4
15
 
5
16
  end # Buffers
@@ -9,5 +20,6 @@ end # Vedeu
9
20
  require 'vedeu/buffers/buffer'
10
21
  require 'vedeu/buffers/null'
11
22
  require 'vedeu/buffers/repository'
23
+ require 'vedeu/buffers/refresh'
12
24
  require 'vedeu/buffers/virtual_buffer'
13
25
  require 'vedeu/buffers/virtual_buffers'
@@ -2,16 +2,7 @@ module Vedeu
2
2
 
3
3
  module Buffers
4
4
 
5
- # The Buffer object represents the states of display for an interface. The
6
- # states are 'front', 'back' and 'previous'.
7
- #
8
- # [Back] -> [Front] -> [Previous]
9
- #
10
- # The content on the screen, or last output will always be the 'Front'
11
- # buffer. Content due to be displayed on next refresh will come from the
12
- # 'Back' buffer when available, otherwise from the current 'Front' buffer.
13
- # When new content is copied to the 'Front' buffer, the current 'Front'
14
- # buffer is also copied to the 'Previous' buffer.
5
+ # Used by Vedeu internally to manage the buffers of each interface defined.
15
6
  #
16
7
  class Buffer
17
8
 
@@ -0,0 +1,57 @@
1
+ module Vedeu
2
+
3
+ module Buffers
4
+
5
+ # Refreshes the given named interface.
6
+ #
7
+ # @example
8
+ # Vedeu.trigger(:_refresh_, name)
9
+ #
10
+ class Refresh
11
+
12
+ include Vedeu::Common
13
+
14
+ # @param name [String] The name of the interface to be refreshed using the
15
+ # named buffer.
16
+ # @return [Array|Vedeu::Error::ModelNotFound]
17
+ def self.by_name(name)
18
+ new(name).by_name
19
+ end
20
+
21
+ # Return a new instance of Vedeu::Buffers::Refresh.
22
+ #
23
+ # @param name [String]
24
+ # @return [Vedeu::Buffers::Refresh]
25
+ def initialize(name)
26
+ @name = name
27
+ end
28
+
29
+ # @return [void]
30
+ def by_name
31
+ Vedeu.timer("Refresh Buffer: '#{buffer_name}'") do
32
+ Vedeu.buffers.by_name(buffer_name).render
33
+ end
34
+ end
35
+
36
+ protected
37
+
38
+ # # @!attribute [r] name
39
+ # @return [String]
40
+ attr_reader :name
41
+
42
+ private
43
+
44
+ # @raise [Vedeu::Error::MissingRequired] When the name is empty or nil.
45
+ # @return [String]
46
+ def buffer_name
47
+ return name if present?(name)
48
+
49
+ fail Vedeu::Error::MissingRequired,
50
+ 'Cannot refresh interface with an empty interface name.'
51
+ end
52
+
53
+ end # Refresh
54
+
55
+ end # Buffers
56
+
57
+ end # Vedeu
@@ -120,7 +120,7 @@ module Vedeu
120
120
  end
121
121
 
122
122
  # @return [Array<Array<Vedeu::Cell>>]
123
- # @see {Vedeu::VirtualBuffer#cells}
123
+ # @see Vedeu::VirtualBuffer#cells
124
124
  def new_virtual_buffer
125
125
  Array.new(height) { Array.new(width) { Vedeu::Cell.new } }
126
126
  end
@@ -1,5 +1,14 @@
1
1
  module Vedeu
2
2
 
3
+ # Vedeu creates an individual cursor for each interface defined,
4
+ # these take their name from the interface, which means that your
5
+ # position within the view for each interface is maintained.
6
+ #
7
+ # The cursor also manages the content offset for a particular view.
8
+ # For example, if the user has moved around within the content and
9
+ # then moved to another interface, when they return their position
10
+ # will be restored.
11
+ #
3
12
  module Cursors
4
13
 
5
14
  end # Cursors
@@ -213,6 +213,22 @@ module Vedeu
213
213
  render
214
214
  end
215
215
 
216
+ # Toggle the visibility of the cursor with the given name.
217
+ #
218
+ # @example
219
+ # Vedeu.toggle_cursor(name)
220
+ #
221
+ # @return [Vedeu::Escape]
222
+ def toggle
223
+ if visible?
224
+ hide
225
+
226
+ else
227
+ show
228
+
229
+ end
230
+ end
231
+
216
232
  # @return [Fixnum] The column/character coordinate.
217
233
  def x
218
234
  @x = bx if @x < bx
@@ -228,7 +228,7 @@ module Vedeu
228
228
  # # ... some code
229
229
  # end
230
230
  #
231
- # @return [void]
231
+ # @return [Boolean]
232
232
  def show!
233
233
  visible(true)
234
234
  end
@@ -240,7 +240,7 @@ module Vedeu
240
240
  # # ... some code
241
241
  # end
242
242
  #
243
- # @return [void]
243
+ # @return [Boolean]
244
244
  def hide!
245
245
  visible(false)
246
246
  end
@@ -279,7 +279,7 @@ module Vedeu
279
279
  # # ... some code
280
280
  # end
281
281
  #
282
- # @return [void]
282
+ # @return [Boolean]
283
283
  def visible(value = true)
284
284
  boolean = value ? true : false
285
285
 
@@ -302,7 +302,7 @@ module Vedeu
302
302
  # end
303
303
  #
304
304
  # @param value [Fixnum]
305
- # @return [void]
305
+ # @return [Fixnum]
306
306
  def zindex(value)
307
307
  model.zindex = value
308
308
  end
@@ -2,20 +2,33 @@ module Vedeu
2
2
 
3
3
  module Events
4
4
 
5
- # Allows the storing of event aliases. Each alias can contain multiple event
6
- # names.
5
+ # Allows the storing of event aliases. Each alias can contain
6
+ # multiple event names.
7
+ #
8
+ # @note
9
+ #
7
10
  #
8
11
  module Aliases
9
12
 
10
13
  extend self
11
14
 
12
- # @param alias_name [Symbol]
13
- # @param event_name [Symbol]
15
+ # Add events by name to the alias name group. When an alias is
16
+ # triggered, all the events stored in the group are also
17
+ # triggered.
18
+ #
19
+ # @example
20
+ # Vedeu.bind_alias(alias_name, event_name)
21
+ #
22
+ # @param alias_name [Symbol] The name of the alias. This can
23
+ # represent a single event or group of events.
24
+ # @param event_name [Symbol] The name of the event to bind to
25
+ # the alias. When the alias is triggered, all events bound
26
+ # will also be triggered.
14
27
  # @return [Hash<Symbol => Array<Symbol>>]
15
- def add(alias_name, event_name)
28
+ def bind_alias(alias_name, event_name)
16
29
  storage[alias_name] << event_name
17
30
  end
18
- alias_method :bind_alias, :add
31
+ alias_method :add, :bind_alias
19
32
 
20
33
  # Return a boolean indicating whether the storage is empty.
21
34
  #
@@ -41,16 +54,22 @@ module Vedeu
41
54
  storage.include?(alias_name)
42
55
  end
43
56
 
44
- # @param alias_name [Symbol]
57
+ # Remove an alias by name. The alias name group is destroyed,
58
+ # but events stored within this alias are not.
59
+ #
60
+ # @example
61
+ # Vedeu.unbind_alias(alias_name)
62
+ #
63
+ # @param alias_name [Symbol] The name of the alias.
45
64
  # @return [FalseClass|Hash<Symbol => Array<Symbol>>]
46
- def remove(alias_name)
65
+ def unbind_alias(alias_name)
47
66
  return false if empty?
48
67
  return false unless registered?(alias_name)
49
68
 
50
69
  storage.delete(alias_name)
51
70
  storage
52
71
  end
53
- alias_method :unbind_alias, :remove
72
+ alias_method :remove, :unbind_alias
54
73
 
55
74
  # @return [Hash<Symbol => Array<Symbol>>]
56
75
  def reset
@@ -4,6 +4,7 @@ module Vedeu
4
4
 
5
5
  # A collection of {Vedeu::Events::Event} instances.
6
6
  #
7
+ # @api private
7
8
  class Collection < Vedeu::Collection
8
9
 
9
10
  end # Collection
@@ -7,11 +7,13 @@ module Vedeu
7
7
  # registered for a name, then the result of each event will be returned as
8
8
  # part of a collection.
9
9
  #
10
- # @example
11
- # Vedeu.trigger(:my_event, :oxidize, 'nitrogen')
12
- #
13
10
  class Trigger
14
11
 
12
+ # Trigger an event by name.
13
+ #
14
+ # @example
15
+ # Vedeu.trigger(:my_event, :oxidize, 'nitrogen')
16
+ #
15
17
  # @param name [Symbol] The name of the event you wish to trigger. The
16
18
  # event does not have to exist.
17
19
  # @param args [Array] Any arguments the event needs to execute correctly.
@@ -1,5 +1,12 @@
1
1
  module Vedeu
2
2
 
3
+ # The Geometry group of classes all handle the size of interfaces in
4
+ # relation to the current size of the terminal. This helps Vedeu to
5
+ # draw content in a consistent way.
6
+ #
7
+ # You can define the geometry of your interfaces using the
8
+ # {Vedeu::Geometry::DSL}.
9
+ #
3
10
  module Geometry
4
11
 
5
12
  end # Geometry
@@ -24,7 +24,7 @@ module Vedeu
24
24
  end
25
25
 
26
26
  # @param value [Array<Fixnum>|Vedeu::Position]
27
- # @return [void]
27
+ # @return [Vedeu::Geometry::Position]
28
28
  def self.coerce(value)
29
29
  if value.is_a?(self)
30
30
  value
@@ -97,7 +97,7 @@ module Vedeu
97
97
  # aforementioned, call the block and then reposition to this location.
98
98
  #
99
99
  # @return [String]
100
- # @yieldreturn [void] Returns the block wrapped in position escape
100
+ # @yieldreturn [String] Returns the block wrapped in position escape
101
101
  # sequences.
102
102
  def to_s
103
103
  return "#{sequence}#{yield}" if block_given?
@@ -27,7 +27,7 @@ module Vedeu
27
27
  #
28
28
  # @param name [String]
29
29
  # @param input [String|Symbol]
30
- # @return [void]
30
+ # @return [String|Symbol]
31
31
  def self.keypress(input:, name:)
32
32
  new(input: input, name: name).keypress
33
33
  end
data/lib/vedeu/log/log.rb CHANGED
@@ -32,6 +32,9 @@ module Vedeu
32
32
 
33
33
  # Write a message to STDOUT.
34
34
  #
35
+ # @example
36
+ # Vedeu.log_stdout
37
+ #
35
38
  # @return [TrueClass]
36
39
  def log_stdout(type: :info, message:)
37
40
  $stdout.puts log_entry(type, message)
@@ -39,6 +42,9 @@ module Vedeu
39
42
 
40
43
  # Write a message to STDERR.
41
44
  #
45
+ # @example
46
+ # Vedeu.log_stderr
47
+ #
42
48
  # @return [TrueClass]
43
49
  def log_stderr(type: :info, message:)
44
50
  $stderr.puts log_entry(type, message)