vedeu 0.6.50 → 0.6.51

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/docs/events/view.md +20 -0
  3. data/docs/output.md +2 -0
  4. data/lib/vedeu/borders/null.rb +2 -0
  5. data/lib/vedeu/borders/refresh.rb +2 -0
  6. data/lib/vedeu/borders/title.rb +4 -0
  7. data/lib/vedeu/buffers/null.rb +2 -0
  8. data/lib/vedeu/colours/background.rb +2 -0
  9. data/lib/vedeu/colours/foreground.rb +2 -0
  10. data/lib/vedeu/colours/translator.rb +2 -0
  11. data/lib/vedeu/common.rb +2 -0
  12. data/lib/vedeu/configuration/api.rb +9 -6
  13. data/lib/vedeu/cursors/cursor.rb +2 -0
  14. data/lib/vedeu/cursors/refresh.rb +2 -0
  15. data/lib/vedeu/cursors/reposition.rb +2 -0
  16. data/lib/vedeu/editor/capture.rb +10 -17
  17. data/lib/vedeu/editor/cropper.rb +2 -0
  18. data/lib/vedeu/editor/cursor.rb +2 -0
  19. data/lib/vedeu/editor/delete.rb +2 -0
  20. data/lib/vedeu/editor/document.rb +7 -0
  21. data/lib/vedeu/editor/insert.rb +2 -0
  22. data/lib/vedeu/editor/item.rb +2 -0
  23. data/lib/vedeu/editor/line.rb +2 -0
  24. data/lib/vedeu/editor/lines.rb +2 -0
  25. data/lib/vedeu/error.rb +2 -0
  26. data/lib/vedeu/events/trigger.rb +3 -0
  27. data/lib/vedeu/geometry/alignment.rb +2 -0
  28. data/lib/vedeu/geometry/area.rb +2 -0
  29. data/lib/vedeu/geometry/coordinate.rb +2 -0
  30. data/lib/vedeu/geometry/dimension.rb +2 -0
  31. data/lib/vedeu/geometry/grid.rb +2 -0
  32. data/lib/vedeu/geometry/horizontal_alignment.rb +2 -0
  33. data/lib/vedeu/geometry/null.rb +2 -0
  34. data/lib/vedeu/geometry/position.rb +2 -0
  35. data/lib/vedeu/geometry/repository.rb +1 -0
  36. data/lib/vedeu/geometry/validator.rb +2 -0
  37. data/lib/vedeu/geometry/vertical_alignment.rb +2 -0
  38. data/lib/vedeu/geometry/x_dimension.rb +2 -0
  39. data/lib/vedeu/geometry/y_dimension.rb +2 -0
  40. data/lib/vedeu/input/all.rb +1 -0
  41. data/lib/vedeu/input/capture.rb +16 -2
  42. data/lib/vedeu/input/mouse.rb +96 -0
  43. data/lib/vedeu/logging/lockless_log_device.rb +2 -0
  44. data/lib/vedeu/logging/mono_logger.rb +2 -0
  45. data/lib/vedeu/menus/null.rb +2 -0
  46. data/lib/vedeu/models/cell.rb +7 -0
  47. data/lib/vedeu/models/escape.rb +2 -0
  48. data/lib/vedeu/models/views/char.rb +1 -0
  49. data/lib/vedeu/models/views/line.rb +1 -0
  50. data/lib/vedeu/models/views/stream.rb +1 -0
  51. data/lib/vedeu/models/views/view.rb +1 -0
  52. data/lib/vedeu/null/all.rb +2 -0
  53. data/lib/vedeu/output/compressor.rb +2 -0
  54. data/lib/vedeu/output/renderers/options.rb +4 -2
  55. data/lib/vedeu/output/viewport.rb +2 -0
  56. data/lib/vedeu/repositories/collection.rb +2 -0
  57. data/lib/vedeu/repositories/store.rb +2 -0
  58. data/lib/vedeu/templating/decoder.rb +2 -0
  59. data/lib/vedeu/templating/encoder.rb +2 -0
  60. data/lib/vedeu/version.rb +1 -1
  61. data/test/lib/vedeu/input/mouse_test.rb +69 -0
  62. metadata +5 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3656fd2ea030549ea6a2a7b436f3d4e0b30b4cae
4
- data.tar.gz: 7d1ae15fec3a67bda3e62bd0777c9e38c69dc35f
3
+ metadata.gz: 08eb61b65bd7020344202d3002defb0dc0d50c13
4
+ data.tar.gz: 560d43d002cf41c62bcb74b9964534071f33e941
5
5
  SHA512:
6
- metadata.gz: 828e104fc823104f930edbcea3e8dfff7f66b485fc07abc2124fe543a8ebc4d78ac491b3ba7119322417bb7b44c383e31cbd6a83cd6f96daef055a231a53638f
7
- data.tar.gz: 1d8398ed1312cd0da093e3ba370904bf05e34cd6fee2e6d49b633890d4691e6cb73f546458721bd6648ebb829a743aeb14f36be40963bac5d93a57aa79b80ab3
6
+ metadata.gz: ad2ece537d1197ef06bce653d9a063dae0a43abd7fd42989fe090451b346be4a4a36685c56d4794366b64b474d1dc5fed2be4bb44e15f4cce02b7bbb51051b6c
7
+ data.tar.gz: 2e660fa55283d844fbe6e5fa9f2a74ae8ba26489059a57ca8975fc1073c3a9afb91aefa6ea3bf8d0b52e7fc168bf23e9897895e876e0a58fe00b0ec976815f7b
data/docs/events/view.md CHANGED
@@ -11,6 +11,26 @@ Maximising an interface.
11
11
 
12
12
  See {Vedeu::Geometry::Geometry#maximise}
13
13
 
14
+ ### `:\_movement_refresh\_`
15
+ When triggered, triggers additional events which aid the updating of
16
+ the output. Used when moving an interface/view.
17
+
18
+ Vedeu.trigger(:_movement_refresh_, name)
19
+
20
+ At this time, triggering this event will:
21
+
22
+ - Clear the entire terminal (assuming at least one renderer is the
23
+ default (Vedeu::Renderer::Terminal)). This action is performed when
24
+ moving an interface/view so that there are no 'artefacts' left
25
+ behind.
26
+ - Refresh the entire terminal (as above). This means all visible
27
+ interfaces are re-rendered. This action is performed to ensure other
28
+ views currently visible are rendered in their current position.
29
+ - Clears the named view. This action removes the named view from the
30
+ terminal (or output).
31
+ - Refreshes the named view. This action adds the named view to the
32
+ terminal (or output); in the new position.
33
+
14
34
  ### `:\_resize\_`
15
35
  When triggered will cause Vedeu to trigger the `:_clear_` and
16
36
  `:_refresh_` events. Please see those events for their behaviour.
data/docs/output.md CHANGED
@@ -1,2 +1,4 @@
1
1
  # @title Vedeu Output
2
2
  # Vedeu Output
3
+
4
+ More coming soon.
@@ -5,6 +5,8 @@ module Vedeu
5
5
  # Provides a non-existent Vedeu::Borders::Border that acts like
6
6
  # the real thing, but does nothing.
7
7
  #
8
+ # @api private
9
+ #
8
10
  class Null
9
11
 
10
12
  # @!attribute [r] name
@@ -4,6 +4,8 @@ module Vedeu
4
4
 
5
5
  # Renders and refreshes the named border.
6
6
  #
7
+ # @api private
8
+ #
7
9
  class Refresh
8
10
 
9
11
  extend Forwardable
@@ -6,6 +6,8 @@ module Vedeu
6
6
  # title is longer than the interface is wide, and pad with a space
7
7
  # either side.
8
8
  #
9
+ # @api private
10
+ #
9
11
  class Title
10
12
 
11
13
  # @param value [String|Vedeu::Borders::Title|
@@ -129,6 +131,8 @@ module Vedeu
129
131
  # the caption is longer than the interface is wide, and pad with a
130
132
  # space either side.
131
133
  #
134
+ # @api private
135
+ #
132
136
  class Caption < Title
133
137
 
134
138
  end # Caption
@@ -5,6 +5,8 @@ module Vedeu
5
5
  # Provides a non-existent Vedeu::Buffers::Buffer that acts like
6
6
  # the real thing, but does nothing.
7
7
  #
8
+ # @api private
9
+ #
8
10
  class Null < Vedeu::Null::Generic
9
11
 
10
12
  end # Null
@@ -6,6 +6,8 @@ module Vedeu
6
6
  # {Vedeu::Colours::Foreground}) of a terminal colour escape
7
7
  # sequence.
8
8
  #
9
+ # @api private
10
+ #
9
11
  class Background < Vedeu::Colours::Translator
10
12
 
11
13
  private
@@ -6,6 +6,8 @@ module Vedeu
6
6
  # {Vedeu::Colours::Background}) of a terminal colour escape
7
7
  # sequence.
8
8
  #
9
+ # @api private
10
+ #
9
11
  class Foreground < Vedeu::Colours::Translator
10
12
 
11
13
  private
@@ -26,6 +26,8 @@ module Vedeu
26
26
  #
27
27
  # @todo More documentation required (create a fancy chart!)
28
28
  #
29
+ # @api private
30
+ #
29
31
  class Translator
30
32
 
31
33
  # @!attribute [r] colour
data/lib/vedeu/common.rb CHANGED
@@ -2,6 +2,8 @@ module Vedeu
2
2
 
3
3
  # A module for common methods used throughout Vedeu.
4
4
  #
5
+ # @api private
6
+ #
5
7
  module Common
6
8
 
7
9
  # Returns a boolean indicating whether a variable is nil or empty.
@@ -221,8 +221,11 @@ module Vedeu
221
221
  # setting is for debugging to be disabled. Using `debug!` or
222
222
  # setting `debug` to true will enable debugging.
223
223
  #
224
- # At this time, debugging only toggles between viewing a full
225
- # backtrace (true) upon exception or only its top line (false).
224
+ # Enabling debugging will:
225
+ # - Enable `Vedeu::Logging::Timer` meaning various timing
226
+ # information is output to the log file.
227
+ # - Produce a full a backtrace to STDOUT and the log file upon
228
+ # unrecoverable error or unhandled exception.
226
229
  #
227
230
  # Vedeu.configure do
228
231
  # debug!
@@ -516,9 +519,9 @@ module Vedeu
516
519
  def background(value = nil)
517
520
  return options[:background] unless value
518
521
 
519
- new_background = Vedeu::Colours::Background.coerce(value)
522
+ bg = Vedeu::Colours::Background.coerce(value)
520
523
 
521
- options[:background] = colour_attributes(background: new_background)
524
+ options[:background] = colour_attributes(background: bg)
522
525
  .fetch(:background)
523
526
  end
524
527
 
@@ -534,9 +537,9 @@ module Vedeu
534
537
  def foreground(value = nil)
535
538
  return options[:foreground] unless value
536
539
 
537
- new_foreground = Vedeu::Colours::Foreground.coerce(value)
540
+ fg = Vedeu::Colours::Foreground.coerce(value)
538
541
 
539
- options[:foreground] = colour_attributes(foreground: new_foreground)
542
+ options[:foreground] = colour_attributes(foreground: fg)
540
543
  .fetch(:foreground)
541
544
  end
542
545
 
@@ -5,6 +5,8 @@ module Vedeu
5
5
  # Each interface has its own Cursor which maintains the position
6
6
  # and visibility of the cursor within that interface.
7
7
  #
8
+ # @api private
9
+ #
8
10
  class Cursor
9
11
 
10
12
  include Vedeu::Repositories::Model
@@ -6,6 +6,8 @@ module Vedeu
6
6
  # the whole interface; unless the cursor's offset has caused the
7
7
  # view to change.
8
8
  #
9
+ # @api private
10
+ #
9
11
  class Refresh
10
12
 
11
13
  extend Forwardable
@@ -4,6 +4,8 @@ module Vedeu
4
4
 
5
5
  # Arbitrarily move the cursor to a given position.
6
6
  #
7
+ # @api private
8
+ #
7
9
  class Reposition
8
10
 
9
11
  # Returns a new instance of Vedeu::Cursors::Reposition.
@@ -52,27 +52,20 @@ module Vedeu
52
52
  end
53
53
  end
54
54
 
55
- if keys.start_with?("\e[M")
56
- button, x, y = keys.chars[3..-1].map { |c| c.ord - 32 }
57
-
58
- Vedeu.log(type: :input,
59
- message: "Mouse pressed: '#{button}' (x: #{x}, y: #{y})")
60
-
61
- if button == 0 # left mouse button
62
- Vedeu.trigger(:_cursor_reposition_, Vedeu.focus, y, x)
63
-
64
- elsif button == 64 # scroll wheel up
65
- Vedeu.trigger(:_cursor_up_, Vedeu.focus)
66
-
67
- elsif button == 65 # scroll wheel down
68
- Vedeu.trigger(:_cursor_down_, Vedeu.focus)
69
-
70
- end
71
- end
55
+ return Vedeu::Input::Mouse.click(keys) if click?(keys)
72
56
 
73
57
  keys
74
58
  end
75
59
 
60
+ # Returns a boolean indicating whether a mouse click was
61
+ # received.
62
+ #
63
+ # @param keys [String]
64
+ # @return [Boolean]
65
+ def click?(keys)
66
+ keys.start_with?("\e[M")
67
+ end
68
+
76
69
  # @return [IO]
77
70
  def console
78
71
  @console || Vedeu::Terminal.console
@@ -5,6 +5,8 @@ module Vedeu
5
5
  # Crop the lines to the visible area of the document, as defined
6
6
  # by the geometry provided.
7
7
  #
8
+ # @api private
9
+ #
8
10
  class Cropper
9
11
 
10
12
  extend Forwardable
@@ -5,6 +5,8 @@ module Vedeu
5
5
  # Maintains a cursor position within the {Vedeu::Editor::Document}
6
6
  # class.
7
7
  #
8
+ # @api private
9
+ #
8
10
  class Cursor
9
11
 
10
12
  extend Forwardable
@@ -4,6 +4,8 @@ module Vedeu
4
4
 
5
5
  # Manipulate the lines of an Vedeu::Editor::Document.
6
6
  #
7
+ # @api private
8
+ #
7
9
  class Delete
8
10
 
9
11
  # @param (see #initialize)
@@ -4,6 +4,8 @@ module Vedeu
4
4
 
5
5
  # A collection of keypresses ordered by input.
6
6
  #
7
+ # @api private
8
+ #
7
9
  class Document
8
10
 
9
11
  include Vedeu::Repositories::Model
@@ -37,6 +39,11 @@ module Vedeu
37
39
 
38
40
  # Returns a new instance of Vedeu::Editor::Document.
39
41
  #
42
+ # @note
43
+ # If a particular key is missing from the attributes
44
+ # parameter, then it is added with the respective value from
45
+ # #defaults.
46
+ #
40
47
  # @param attributes [Hash]
41
48
  # @option attributes data [String]
42
49
  # @option attributes name [String|Symbol]
@@ -4,6 +4,8 @@ module Vedeu
4
4
 
5
5
  # Manipulate the lines of an Vedeu::Editor::Document.
6
6
  #
7
+ # @api private
8
+ #
7
9
  class Insert
8
10
 
9
11
  # @param (see #initialize)
@@ -4,6 +4,8 @@ module Vedeu
4
4
 
5
5
  # Fetches an item from a collection.
6
6
  #
7
+ # @api private
8
+ #
7
9
  class Item
8
10
 
9
11
  # @param collection [Vedeu::Editor::Line|Vedeu::Editor::Lines]
@@ -4,6 +4,8 @@ module Vedeu
4
4
 
5
5
  # Manipulate a single line of an Vedeu::Editor::Document.
6
6
  #
7
+ # @api private
8
+ #
7
9
  class Line
8
10
 
9
11
  # @!attribute [rw] line
@@ -4,6 +4,8 @@ module Vedeu
4
4
 
5
5
  # Manipulate the lines of an Vedeu::Editor::Document.
6
6
  #
7
+ # @api private
8
+ #
7
9
  class Lines
8
10
 
9
11
  include Enumerable
data/lib/vedeu/error.rb CHANGED
@@ -3,6 +3,8 @@ module Vedeu
3
3
  # Custom exceptions/errors which Vedeu will raise in certain
4
4
  # circumstances.
5
5
  #
6
+ # @api private
7
+ #
6
8
  module Error
7
9
 
8
10
  # Raised with Vedeu attempts to access a client application
@@ -38,6 +38,9 @@ module Vedeu
38
38
  #
39
39
  # @return [Array]
40
40
  def trigger
41
+ Vedeu.log(type: :event,
42
+ message: "No action for: '#{name.inspect}'") if results.empty?
43
+
41
44
  return results[0] if results.one?
42
45
 
43
46
  results
@@ -10,6 +10,8 @@ module Vedeu
10
10
  # @see Vedeu::Geometry::HorizontalAlignment
11
11
  # @see Vedeu::Geometry::VerticalAlignment
12
12
  #
13
+ # @api private
14
+ #
13
15
  class Alignment
14
16
 
15
17
  # @param (see #initialize)
@@ -4,6 +4,8 @@ module Vedeu
4
4
 
5
5
  # Define an area from dimensions or points.
6
6
  #
7
+ # @api private
8
+ #
7
9
  class Area
8
10
 
9
11
  # @!attribute [r] y
@@ -4,6 +4,8 @@ module Vedeu
4
4
 
5
5
  # Crudely corrects out of range values.
6
6
  #
7
+ # @api private
8
+ #
7
9
  class Coordinate
8
10
 
9
11
  # Return a new instance of Vedeu::Geometry::Coordinate.
@@ -4,6 +4,8 @@ module Vedeu
4
4
 
5
5
  # A Dimension is either the height or width of an entity.
6
6
  #
7
+ # @api private
8
+ #
7
9
  class Dimension
8
10
 
9
11
  extend Forwardable
@@ -7,6 +7,8 @@ module Vedeu
7
7
  # If the terminal height or width is not a multiple of 12, then
8
8
  # Grid chooses the maximum value which will fit.
9
9
  #
10
+ # @api private
11
+ #
10
12
  class Grid
11
13
 
12
14
  # @see #initialize
@@ -5,6 +5,8 @@ module Vedeu
5
5
  # Provides the mechanism to align an interface/view horizontally
6
6
  # within the available terminal space.
7
7
  #
8
+ # @api private
9
+ #
8
10
  class HorizontalAlignment < Vedeu::Geometry::Alignment
9
11
 
10
12
  # @raise [Vedeu::Error::InvalidSyntax] When the value is not one
@@ -4,6 +4,8 @@ module Vedeu
4
4
 
5
5
  # Provides a non-existent model to swallow messages.
6
6
  #
7
+ # @api private
8
+ #
7
9
  class Null < Vedeu::Null::Generic
8
10
 
9
11
  extend Forwardable
@@ -5,6 +5,8 @@ module Vedeu
5
5
  # Change coordinates into an escape sequence to set the cursor
6
6
  # position.
7
7
  #
8
+ # @api private
9
+ #
8
10
  class Position
9
11
 
10
12
  # @!attribute [r] y
@@ -33,6 +33,7 @@ module Vedeu
33
33
  Vedeu.geometries.by_name(name).maximise
34
34
  end
35
35
 
36
+ # See {file:docs/events/view.md#\_movement_refresh_}
36
37
  Vedeu.bind(:_movement_refresh_) do |name|
37
38
  Vedeu.trigger(:_clear_)
38
39
  Vedeu.trigger(:_refresh_)
@@ -4,6 +4,8 @@ module Vedeu
4
4
 
5
5
  # Validate values given to {Vedeu::Geometry::DSL}.
6
6
  #
7
+ # @api private
8
+ #
7
9
  module Validator
8
10
 
9
11
  include Vedeu::Common
@@ -5,6 +5,8 @@ module Vedeu
5
5
  # Provides the mechanism to align an interface/view vertically
6
6
  # within the available terminal space.
7
7
  #
8
+ # @api private
9
+ #
8
10
  class VerticalAlignment < Vedeu::Geometry::Alignment
9
11
 
10
12
  # @raise [Vedeu::Error::InvalidSyntax] When the value is not one
@@ -4,6 +4,8 @@ module Vedeu
4
4
 
5
5
  # The X Dimension provides the width of an entity.
6
6
  #
7
+ # @api private
8
+ #
7
9
  class XDimension < Vedeu::Geometry::Dimension
8
10
 
9
11
  private
@@ -4,6 +4,8 @@ module Vedeu
4
4
 
5
5
  # The Y Dimension provides the height of an entity.
6
6
  #
7
+ # @api private
8
+ #
7
9
  class YDimension < Vedeu::Geometry::Dimension
8
10
 
9
11
  private
@@ -15,5 +15,6 @@ require 'vedeu/input/key'
15
15
  require 'vedeu/input/keymap'
16
16
  require 'vedeu/input/keymaps'
17
17
  require 'vedeu/input/mapper'
18
+ require 'vedeu/input/mouse'
18
19
  require 'vedeu/input/store'
19
20
  require 'vedeu/input/translator'
@@ -42,7 +42,10 @@ module Vedeu
42
42
  #
43
43
  # @return [Array|String|Symbol]
44
44
  def read
45
- if reader.raw_mode?
45
+ if click?(keypress)
46
+ Vedeu.trigger(:_mouse_event_, keypress)
47
+
48
+ elsif reader.raw_mode?
46
49
  Vedeu.trigger(:_keypress_, keypress)
47
50
 
48
51
  elsif reader.fake_mode?
@@ -74,13 +77,24 @@ module Vedeu
74
77
 
75
78
  private
76
79
 
80
+ # Returns a boolean indicating whether a mouse click was
81
+ # received.
82
+ #
83
+ # @param key [String]
84
+ # @return [Boolean]
85
+ def click?(key)
86
+ return false if key.is_a?(Symbol)
87
+
88
+ key.is_a?(Vedeu::Cursors::Cursor) || key.start_with?("\e[M")
89
+ end
90
+
77
91
  # Returns the translated (when possible) keypress(es).
78
92
  #
79
93
  # @return [String|Symbol]
80
94
  def keypress
81
95
  key = input
82
96
 
83
- Vedeu::Input::Translator.translate(key)
97
+ @keypress ||= Vedeu::Input::Translator.translate(key)
84
98
  end
85
99
 
86
100
  # Returns the input from the terminal.
@@ -0,0 +1,96 @@
1
+ module Vedeu
2
+
3
+ module Input
4
+
5
+ # Rudimentary support for mouse interactions.
6
+ #
7
+ class Mouse
8
+
9
+ # Trigger an event depending on which button was pressed.
10
+ #
11
+ # @param input [String]
12
+ # @return [void]
13
+ def self.click(input)
14
+ new(input).click
15
+ end
16
+
17
+ # Return an instance of Vedeu::Input::Mouse.
18
+ #
19
+ # @param input [String]
20
+ # @return [Vedeu::Input::Mouse]
21
+ def initialize(input)
22
+ @input = input
23
+ end
24
+
25
+ # Trigger an event depending on which button was pressed.
26
+ #
27
+ # @return [void]
28
+ def click
29
+ Vedeu.log(type: :input,
30
+ message: "Mouse pressed: '#{button}' (x: #{x}, y: #{y})")
31
+
32
+ if left_click?
33
+ Vedeu.trigger(:_cursor_reposition_, Vedeu.focus, y, x)
34
+
35
+ elsif wheel_up?
36
+ Vedeu.trigger(:_cursor_up_, Vedeu.focus)
37
+
38
+ elsif wheel_down?
39
+ Vedeu.trigger(:_cursor_down_, Vedeu.focus)
40
+
41
+ else
42
+ Vedeu.log(type: :input,
43
+ message: 'Vedeu does not support mouse button ' \
44
+ "'#{button}' yet.")
45
+
46
+ end
47
+ end
48
+
49
+ protected
50
+
51
+ # @!attribute [r] input
52
+ # @return [String]
53
+ attr_reader :input
54
+
55
+ private
56
+
57
+ # @return [Fixnum]
58
+ def button
59
+ mouse[0]
60
+ end
61
+
62
+ # @return [Array<Fixnum>]
63
+ def mouse
64
+ @_input ||= input.chars[3..-1].map { |character| character.ord - 32 }
65
+ end
66
+
67
+ # @return [Boolean]
68
+ def left_click?
69
+ button == 0
70
+ end
71
+
72
+ # @return [Boolean]
73
+ def wheel_up?
74
+ button == 64
75
+ end
76
+
77
+ # @return [Boolean]
78
+ def wheel_down?
79
+ button == 65
80
+ end
81
+
82
+ # @return [Fixnum]
83
+ def x
84
+ mouse[1]
85
+ end
86
+
87
+ # @return [Fixnum]
88
+ def y
89
+ mouse[2]
90
+ end
91
+
92
+ end # Mouse
93
+
94
+ end # Input
95
+
96
+ end # Vedeu
@@ -5,6 +5,8 @@ module Vedeu
5
5
  # Ensures we can always write to the log file by creating a
6
6
  # lock-less log device.
7
7
  #
8
+ # @api private
9
+ #
8
10
  class LocklessLogDevice < ::Logger::LogDevice
9
11
 
10
12
  # Returns a new instance of Vedeu::Logging::LocklessLogDevice.
@@ -4,6 +4,8 @@ module Vedeu
4
4
 
5
5
  # Allows the creation of a lock-less log device.
6
6
  #
7
+ # @api private
8
+ #
7
9
  class MonoLogger < ::Logger
8
10
 
9
11
  # Create a trappable Logger instance.
@@ -4,6 +4,8 @@ module Vedeu
4
4
 
5
5
  # Provides a non-existent model to swallow messages.
6
6
  #
7
+ # @api private
8
+ #
7
9
  class Null < Vedeu::Null::Generic
8
10
 
9
11
  # Returns an instance of the Vedeu::Menus::Null class.
@@ -4,6 +4,8 @@ module Vedeu
4
4
 
5
5
  # A Cell represents a single square of the terminal.
6
6
  #
7
+ # @api private
8
+ #
7
9
  class Cell
8
10
 
9
11
  # @!attribute [r] colour
@@ -20,6 +22,11 @@ module Vedeu
20
22
 
21
23
  # Returns a new instance of Vedeu::Models::Cell.
22
24
  #
25
+ # @note
26
+ # If a particular key is missing from the attributes
27
+ # parameter, then it is added with the respective value from
28
+ # #defaults.
29
+ #
23
30
  # @param attributes [Hash<Symbol => Array<Symbol|String>,
24
31
  # Fixnum, String, Symbol]
25
32
  # @option attributes colour [NilClass|String]
@@ -4,6 +4,8 @@ module Vedeu
4
4
 
5
5
  # Represents an invisible escape character sequence.
6
6
  #
7
+ # @api private
8
+ #
7
9
  class Escape
8
10
 
9
11
  # @!attribute [r] value
@@ -5,6 +5,7 @@ module Vedeu
5
5
  # A collection of {Vedeu::Views::Char} instances.
6
6
  #
7
7
  # @api private
8
+ #
8
9
  class Chars < Vedeu::Repositories::Collection
9
10
 
10
11
  end # Chars
@@ -5,6 +5,7 @@ module Vedeu
5
5
  # A collection of {Vedeu::Views::Line} instances.
6
6
  #
7
7
  # @api private
8
+ #
8
9
  class Lines < Vedeu::Repositories::Collection
9
10
 
10
11
  end # Lines
@@ -5,6 +5,7 @@ module Vedeu
5
5
  # A collection of {Vedeu::Views::Stream} instances.
6
6
  #
7
7
  # @api private
8
+ #
8
9
  class Streams < Vedeu::Repositories::Collection
9
10
 
10
11
  end # Streams
@@ -5,6 +5,7 @@ module Vedeu
5
5
  # A collection of {Vedeu::Views::View} instances.
6
6
  #
7
7
  # @api private
8
+ #
8
9
  class ViewCollection < Vedeu::Repositories::Collection
9
10
 
10
11
  end # ViewCollection
@@ -4,6 +4,8 @@ module Vedeu
4
4
  # their real counterpart. In most cases the call is muted or returns
5
5
  # a generic value that does not halt processing.
6
6
  #
7
+ # @api private
8
+ #
7
9
  module Null
8
10
 
9
11
  end # Null
@@ -7,6 +7,8 @@ module Vedeu
7
7
  # occurences of the same escape sequence, resulting in a smaller
8
8
  # payload being sent to the renderer.
9
9
  #
10
+ # @api private
11
+ #
10
12
  class Compressor
11
13
 
12
14
  include Vedeu::Common
@@ -4,9 +4,10 @@ module Vedeu
4
4
 
5
5
  # Provides shared functionality to Vedeu::Renderer classes.
6
6
  #
7
- # :nocov:
8
7
  module Options
9
8
 
9
+ # :nocov:
10
+
10
11
  # @!attribute [w] options
11
12
  # @return [Hash<Symbol => void>]
12
13
  attr_writer :options
@@ -32,8 +33,9 @@ module Vedeu
32
33
  {}
33
34
  end
34
35
 
36
+ # :nocov:
37
+
35
38
  end # Options
36
- # :nocov:
37
39
 
38
40
  end # Renderers
39
41
 
@@ -9,6 +9,8 @@ module Vedeu
9
9
  # columns than the defined width of the interface, this class
10
10
  # provides 'scrolling' via the cursor's position.
11
11
  #
12
+ # @api private
13
+ #
12
14
  class Viewport
13
15
 
14
16
  extend Forwardable
@@ -5,6 +5,8 @@ module Vedeu
5
5
  # Convert an Array into an object which has some meaning in the
6
6
  # context it is being used.
7
7
  #
8
+ # @api private
9
+ #
8
10
  class Collection
9
11
 
10
12
  include Enumerable
@@ -4,6 +4,8 @@ module Vedeu
4
4
 
5
5
  # Provides generic repository related behaviour.
6
6
  #
7
+ # @api private
8
+ #
7
9
  module Store
8
10
 
9
11
  include Enumerable
@@ -5,6 +5,8 @@ module Vedeu
5
5
  # Converts an encoded string back into an object or collection of
6
6
  # objects.
7
7
  #
8
+ # @api private
9
+ #
8
10
  class Decoder
9
11
 
10
12
  # @param (see #initialize)
@@ -5,6 +5,8 @@ module Vedeu
5
5
  # Converts an object or collection of objects into an encoded
6
6
  # String.
7
7
  #
8
+ # @api private
9
+ #
8
10
  class Encoder
9
11
 
10
12
  # @param (see #initialize)
data/lib/vedeu/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # The current version of Vedeu.
4
- VERSION = '0.6.50'.freeze
4
+ VERSION = '0.6.51'.freeze
5
5
 
6
6
  end
@@ -0,0 +1,69 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ module Input
6
+
7
+ describe Mouse do
8
+
9
+ let(:described) { Vedeu::Input::Mouse }
10
+ let(:instance) { described.new(input) }
11
+ let(:input) {}
12
+
13
+ describe '#initialize' do
14
+ it { instance.must_be_instance_of(described) }
15
+ it { instance.instance_variable_get('@input').must_equal(input) }
16
+ end
17
+
18
+ describe '.click' do
19
+ before { Vedeu.interface(:mouse_test) {} }
20
+ after { Vedeu.interfaces.reset! }
21
+
22
+ subject { described.click(input) }
23
+
24
+ context 'when the left mouse button was pressed' do
25
+ let(:input) { "\e[M ,%" }
26
+
27
+ it {
28
+ Vedeu.expects(:trigger).with(:_cursor_reposition_, Vedeu.focus, 5, 12)
29
+ subject
30
+ }
31
+ end
32
+
33
+ context 'when the mouse scroll wheel was moved upwards' do
34
+ let(:input) { "\e[M`6E" }
35
+
36
+ it {
37
+ Vedeu.expects(:trigger).with(:_cursor_up_, Vedeu.focus)
38
+ subject
39
+ }
40
+ end
41
+
42
+ context 'when the mouse scroll wheel was moved downwards' do
43
+ let(:input) { "\e[MaN5" }
44
+
45
+ it {
46
+ Vedeu.expects(:trigger).with(:_cursor_down_, Vedeu.focus)
47
+ subject
48
+ }
49
+ end
50
+
51
+ context 'when the mouse input was not recognised' do
52
+ let(:input) { "\e[Mb0(" }
53
+
54
+ it {
55
+ subject.must_equal("\e[93m[input] \e[39m\e[33mVedeu does not " \
56
+ "support mouse button '66' yet.\e[39m")
57
+ }
58
+ end
59
+ end
60
+
61
+ describe '#click' do
62
+ it { instance.must_respond_to(:click) }
63
+ end
64
+
65
+ end # Mouse
66
+
67
+ end # Input
68
+
69
+ end # Vedeu
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vedeu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.50
4
+ version: 0.6.51
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-08 00:00:00.000000000 Z
11
+ date: 2015-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard
@@ -436,6 +436,7 @@ files:
436
436
  - lib/vedeu/input/keymap.rb
437
437
  - lib/vedeu/input/keymaps.rb
438
438
  - lib/vedeu/input/mapper.rb
439
+ - lib/vedeu/input/mouse.rb
439
440
  - lib/vedeu/input/store.rb
440
441
  - lib/vedeu/input/translator.rb
441
442
  - lib/vedeu/interfaces/all.rb
@@ -613,6 +614,7 @@ files:
613
614
  - test/lib/vedeu/input/keymap_test.rb
614
615
  - test/lib/vedeu/input/keymaps_test.rb
615
616
  - test/lib/vedeu/input/mapper_test.rb
617
+ - test/lib/vedeu/input/mouse_test.rb
616
618
  - test/lib/vedeu/input/store_test.rb
617
619
  - test/lib/vedeu/input/translator_test.rb
618
620
  - test/lib/vedeu/interfaces/clear_test.rb
@@ -820,6 +822,7 @@ test_files:
820
822
  - test/lib/vedeu/input/keymap_test.rb
821
823
  - test/lib/vedeu/input/keymaps_test.rb
822
824
  - test/lib/vedeu/input/mapper_test.rb
825
+ - test/lib/vedeu/input/mouse_test.rb
823
826
  - test/lib/vedeu/input/store_test.rb
824
827
  - test/lib/vedeu/input/translator_test.rb
825
828
  - test/lib/vedeu/interfaces/clear_test.rb