vedeu 0.6.68 → 0.6.69

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +34 -66
  3. data/docs/api.md +3 -3
  4. data/docs/borders.md +3 -3
  5. data/docs/cursors.md +109 -10
  6. data/docs/debugging.md +2 -2
  7. data/docs/dsl.md +2 -2
  8. data/docs/events/application.md +1 -1
  9. data/docs/events/document.md +9 -9
  10. data/docs/events/drb.md +7 -7
  11. data/docs/events/focus.md +3 -3
  12. data/docs/events/menu.md +10 -10
  13. data/docs/events/movement.md +5 -3
  14. data/docs/events/refresh.md +5 -5
  15. data/docs/events/system.md +8 -8
  16. data/docs/events/view.md +4 -4
  17. data/docs/events/visibility.md +10 -32
  18. data/docs/input.md +1 -1
  19. data/lib/vedeu/colours/background.rb +4 -9
  20. data/lib/vedeu/colours/foreground.rb +4 -9
  21. data/lib/vedeu/colours/translator.rb +8 -3
  22. data/lib/vedeu/cursors/all.rb +1 -0
  23. data/lib/vedeu/{geometries → cursors}/coordinate.rb +4 -4
  24. data/lib/vedeu/cursors/cursor.rb +10 -10
  25. data/lib/vedeu/cursors/dsl.rb +3 -27
  26. data/lib/vedeu/cursors/reposition.rb +4 -4
  27. data/lib/vedeu/esc/esc.rb +13 -17
  28. data/lib/vedeu/geometries/{alignment.rb → alignment/alignment.rb} +0 -0
  29. data/lib/vedeu/geometries/alignment/all.rb +11 -0
  30. data/lib/vedeu/geometries/{horizontal_alignment.rb → alignment/horizontal_alignment.rb} +0 -0
  31. data/lib/vedeu/geometries/{vertical_alignment.rb → alignment/vertical_alignment.rb} +0 -0
  32. data/lib/vedeu/geometries/all.rb +4 -12
  33. data/lib/vedeu/geometries/area/all.rb +12 -0
  34. data/lib/vedeu/geometries/{area.rb → area/area.rb} +0 -0
  35. data/lib/vedeu/geometries/{dimension.rb → area/dimension.rb} +0 -0
  36. data/lib/vedeu/geometries/{x_dimension.rb → area/x_dimension.rb} +0 -0
  37. data/lib/vedeu/geometries/{y_dimension.rb → area/y_dimension.rb} +0 -0
  38. data/lib/vedeu/geometries/dsl/all.rb +11 -0
  39. data/lib/vedeu/geometries/{dsl.rb → dsl/dsl.rb} +0 -0
  40. data/lib/vedeu/geometries/{grid.rb → dsl/grid.rb} +0 -0
  41. data/lib/vedeu/geometries/{validator.rb → dsl/validator.rb} +0 -0
  42. data/lib/vedeu/input/raw.rb +5 -0
  43. data/lib/vedeu/input/read.rb +2 -2
  44. data/lib/vedeu/output/compressor.rb +1 -1
  45. data/lib/vedeu/output/compressor_cache.rb +7 -0
  46. data/lib/vedeu/terminal/terminal.rb +4 -4
  47. data/lib/vedeu/version.rb +1 -1
  48. data/test/lib/vedeu/{geometries/coordinate.rb → cursors/coordinate_test.rb} +4 -4
  49. data/test/lib/vedeu/esc/esc_test.rb +18 -0
  50. data/test/lib/vedeu/geometries/{alignment_test.rb → alignment/alignment_test.rb} +0 -0
  51. data/test/lib/vedeu/geometries/{horizontal_alignment_test.rb → alignment/horizontal_alignment_test.rb} +0 -0
  52. data/test/lib/vedeu/geometries/{vertical_alignment_test.rb → alignment/vertical_alignment_test.rb} +0 -0
  53. data/test/lib/vedeu/geometries/{area_test.rb → area/area_test.rb} +0 -0
  54. data/test/lib/vedeu/geometries/{dimension_test.rb → area/dimension_test.rb} +0 -0
  55. data/test/lib/vedeu/geometries/{x_dimension_test.rb → area/x_dimension_test.rb} +0 -0
  56. data/test/lib/vedeu/geometries/{y_dimension_test.rb → area/y_dimension_test.rb} +0 -0
  57. data/test/lib/vedeu/geometries/{dsl_test.rb → dsl/dsl_test.rb} +0 -0
  58. data/test/lib/vedeu/geometries/{grid_test.rb → dsl/grid_test.rb} +0 -0
  59. data/test/lib/vedeu/geometries/{validator_test.rb → dsl/validator_test.rb} +0 -0
  60. data/vedeu.gemspec +2 -2
  61. metadata +42 -39
@@ -168,7 +168,7 @@ module Vedeu
168
168
  #
169
169
  # @return [String]
170
170
  def numbered
171
- "#{numbered_prefix}#{css_to_numbered}m".freeze
171
+ "#{prefix}5;#{css_to_numbered}m".freeze
172
172
  end
173
173
 
174
174
  # Returns a boolean indicated whether the colour is a valid
@@ -200,6 +200,13 @@ module Vedeu
200
200
  end
201
201
  end
202
202
 
203
+ # Returns part of an escape sequence.
204
+ #
205
+ # @return [String]
206
+ def rgb_prefix
207
+ "#{prefix}2;%s;%s;%sm".freeze
208
+ end
209
+
203
210
  # Returns a boolean indicating whether the numbered colour is
204
211
  # within the range of valid terminal numbered colours.
205
212
  #
@@ -266,9 +273,7 @@ module Vedeu
266
273
  fail Vedeu::Error::NotImplemented, 'Subclasses implement this.'.freeze
267
274
  end
268
275
  alias_method :named_codes, :not_implemented
269
- alias_method :numbered_prefix, :not_implemented
270
276
  alias_method :repository, :not_implemented
271
- alias_method :rgb_prefix, :not_implemented
272
277
 
273
278
  end # Translator
274
279
 
@@ -15,6 +15,7 @@ module Vedeu
15
15
 
16
16
  end # Vedeu
17
17
 
18
+ require 'vedeu/cursors/coordinate'
18
19
  require 'vedeu/cursors/cursor'
19
20
  require 'vedeu/cursors/dsl'
20
21
  require 'vedeu/cursors/refresh'
@@ -1,6 +1,6 @@
1
1
  module Vedeu
2
2
 
3
- module Geometries
3
+ module Cursors
4
4
 
5
5
  # Crudely corrects out of range values.
6
6
  #
@@ -8,13 +8,13 @@ module Vedeu
8
8
  #
9
9
  class Coordinate
10
10
 
11
- # Return a new instance of Vedeu::Geometries::Coordinate.
11
+ # Return a new instance of Vedeu::Cursors::Coordinate.
12
12
  #
13
13
  # @param attributes [Hash<Symbol => Fixnum|String|Symbol>]
14
14
  # @option attributes name [String|Symbol]
15
15
  # @option attributes type [Symbol]
16
16
  # @option attributes offset [Fixnum]
17
- # @return [Vedeu::Geometries::Coordinate]
17
+ # @return [Vedeu::Cursors::Coordinate]
18
18
  def initialize(attributes = {})
19
19
  defaults.merge!(attributes).each do |key, value|
20
20
  instance_variable_set("@#{key}", value)
@@ -172,6 +172,6 @@ module Vedeu
172
172
 
173
173
  end # Coordinate
174
174
 
175
- end # Geometries
175
+ end # Cursors
176
176
 
177
177
  end # Vedeu
@@ -264,11 +264,11 @@ module Vedeu
264
264
 
265
265
  # Determine correct x and y related coordinates.
266
266
  #
267
- # @return [Vedeu::Geometries::Coordinate]
267
+ # @return [Vedeu::Cursors::Coordinate]
268
268
  def coordinate(offset, type)
269
- Vedeu::Geometries::Coordinate.new(name: name,
270
- offset: offset,
271
- type: type)
269
+ Vedeu::Cursors::Coordinate.new(name: name,
270
+ offset: offset,
271
+ type: type)
272
272
  end
273
273
 
274
274
  # The default values for a new instance of this class.
@@ -335,15 +335,15 @@ module Vedeu
335
335
 
336
336
  # :nocov:
337
337
 
338
- # See {file:docs/events/visibility.md#\_hide_cursor_}
338
+ # See {file:docs/cursors.md#vedeuhide_cursor__}
339
339
  Vedeu.bind(:_hide_cursor_) { |name| Vedeu.hide_cursor(name) }
340
- # Vedeu.bind_alias(:_cursor_hide_, :_hide_cursor_)
340
+ Vedeu.bind_alias(:_cursor_hide_, :_hide_cursor_)
341
341
 
342
- # See {file:docs/events/visibility.md#\_show_cursor_}
342
+ # See {file:docs/cursors.md#vedeushow_cursor__}
343
343
  Vedeu.bind(:_show_cursor_) { |name| Vedeu.show_cursor(name) }
344
- # Vedeu.bind_alias(:_cursor_show_, :_show_cursor_)
344
+ Vedeu.bind_alias(:_cursor_show_, :_show_cursor_)
345
345
 
346
- # See {file:docs/events/visibility.md#\_toggle_cursor_}
346
+ # See {file:docs/cursors.md#vedeutoggle_cursor__}
347
347
  Vedeu.bind(:_toggle_cursor_) { |name| Vedeu.toggle_cursor(name) }
348
348
 
349
349
  # See {file:docs/cursors.md}
@@ -380,7 +380,7 @@ module Vedeu
380
380
 
381
381
  Vedeu.trigger(:_refresh_cursor_, name)
382
382
  end
383
- # Vedeu.bind_alias(:_cursor_reset_, :_cursor_origin_)
383
+ Vedeu.bind_alias(:_cursor_reset_, :_cursor_origin_)
384
384
 
385
385
  # See {file:docs/cursors.md}
386
386
  Vedeu.bind(:_cursor_position_) do |name|
@@ -4,38 +4,14 @@ module Vedeu
4
4
 
5
5
  # Control the visibility of the cursor for each interface/view.
6
6
  #
7
+ # See {file:docs/cursors.md#interface_cursors}
8
+ # See {file:docs/cursors.md#view_cursors}
7
9
  module DSL
8
10
 
9
11
  # Set the cursor visibility on an interface.
10
12
  #
11
13
  # @param value [Boolean] Any value other than nil or false will
12
- # evaluate
13
- # to true.
14
- #
15
- # @example
16
- # Vedeu.interface :my_interface do
17
- # cursor true # => show the cursor for this interface
18
- # # or...
19
- # cursor :show # => both of these are equivalent to line
20
- # # above
21
- # # or...
22
- # cursor! #
23
- # # ...
24
- # end
25
- #
26
- # Vedeu.interface :my_interface do
27
- # cursor false # => hide the cursor for this interface
28
- # # or...
29
- # cursor nil # => as above
30
- # # ...
31
- # end
32
- #
33
- # Vedeu.view :my_interface do
34
- # cursor true # => Specify the visibility of the cursor when
35
- # # the view is rendered.
36
- # # ...
37
- # end
38
- #
14
+ # evaluate to true.
39
15
  # @return [Vedeu::Cursors::Cursor]
40
16
  def cursor(value = true)
41
17
  boolean = value ? true : false
@@ -67,11 +67,11 @@ module Vedeu
67
67
  #
68
68
  # @param offset []
69
69
  # @param type []
70
- # @return [Vedeu::Geometries::Coordinate]
70
+ # @return [Vedeu::Cursors::Coordinate]
71
71
  def coordinate(offset, type)
72
- Vedeu::Geometries::Coordinate.new(name: name,
73
- offset: offset,
74
- type: type)
72
+ Vedeu::Cursors::Coordinate.new(name: name,
73
+ offset: offset,
74
+ type: type)
75
75
  end
76
76
 
77
77
  # @return [Vedeu::Cursors::Cursor]
data/lib/vedeu/esc/esc.rb CHANGED
@@ -1,7 +1,3 @@
1
- require 'vedeu/esc/actions'
2
- require 'vedeu/esc/borders'
3
- require 'vedeu/esc/colours'
4
-
5
1
  module Vedeu
6
2
 
7
3
  module EscapeSequences
@@ -57,13 +53,24 @@ module Vedeu
57
53
  "#{border_on}#{yield}#{border_off}".freeze
58
54
  end
59
55
 
60
- private
61
-
62
56
  # @return [String]
63
57
  def clear
64
58
  "#{colour_reset}\e[2J".freeze
65
59
  end
66
60
 
61
+ # @return [String]
62
+ def screen_init
63
+ "#{reset}#{clear}#{hide_cursor}#{enable_mouse}".freeze
64
+ end
65
+
66
+ # @return [String]
67
+ def screen_exit
68
+ "#{disable_mouse}#{show_cursor}#{screen_colour_reset}#{reset}" \
69
+ "#{last_character_position}\n".freeze
70
+ end
71
+
72
+ private
73
+
67
74
  # @return [String]
68
75
  def clear_line
69
76
  "#{colour_reset}\e[2K".freeze
@@ -101,22 +108,11 @@ module Vedeu
101
108
  "#{underline_off}#{bold_off}#{positive}".freeze
102
109
  end
103
110
 
104
- # @return [String]
105
- def screen_init
106
- "#{reset}#{clear}#{hide_cursor}#{enable_mouse}".freeze
107
- end
108
-
109
111
  # @return [String]
110
112
  def screen_colour_reset
111
113
  "#{fg_reset}#{bg_reset}".freeze
112
114
  end
113
115
 
114
- # @return [String]
115
- def screen_exit
116
- "#{disable_mouse}#{show_cursor}#{screen_colour_reset}#{reset}" \
117
- "#{last_character_position}\n".freeze
118
- end
119
-
120
116
  # @return [String]
121
117
  def last_character_position
122
118
  Vedeu::Geometries::Position[Vedeu.height, Vedeu.width].to_s
@@ -0,0 +1,11 @@
1
+ module Vedeu
2
+
3
+ module Geometries
4
+
5
+ end # Geometries
6
+
7
+ end # Vedeu
8
+
9
+ require 'vedeu/geometries/alignment/alignment'
10
+ require 'vedeu/geometries/alignment/horizontal_alignment'
11
+ require 'vedeu/geometries/alignment/vertical_alignment'
@@ -13,19 +13,11 @@ module Vedeu
13
13
 
14
14
  end # Vedeu
15
15
 
16
- require 'vedeu/geometries/alignment'
17
- require 'vedeu/geometries/horizontal_alignment'
18
- require 'vedeu/geometries/vertical_alignment'
19
- require 'vedeu/geometries/area'
20
- require 'vedeu/geometries/coordinate'
21
- require 'vedeu/geometries/dimension'
22
- require 'vedeu/geometries/x_dimension'
23
- require 'vedeu/geometries/y_dimension'
24
- require 'vedeu/geometries/validator'
25
- require 'vedeu/geometries/dsl'
26
- require 'vedeu/geometries/coordinate'
16
+ require 'vedeu/geometries/alignment/all'
17
+ require 'vedeu/geometries/area/all'
18
+ require 'vedeu/geometries/dsl/all'
19
+
27
20
  require 'vedeu/geometries/geometry'
28
- require 'vedeu/geometries/grid'
29
21
  require 'vedeu/geometries/move'
30
22
  require 'vedeu/geometries/position'
31
23
  require 'vedeu/geometries/repository'
@@ -0,0 +1,12 @@
1
+ module Vedeu
2
+
3
+ module Geometries
4
+
5
+ end # Geometries
6
+
7
+ end # Vedeu
8
+
9
+ require 'vedeu/geometries/area/area'
10
+ require 'vedeu/geometries/area/dimension'
11
+ require 'vedeu/geometries/area/x_dimension'
12
+ require 'vedeu/geometries/area/y_dimension'
File without changes
@@ -0,0 +1,11 @@
1
+ module Vedeu
2
+
3
+ module Geometries
4
+
5
+ end # Geometries
6
+
7
+ end # Vedeu
8
+
9
+ require 'vedeu/geometries/dsl/grid'
10
+ require 'vedeu/geometries/dsl/validator'
11
+ require 'vedeu/geometries/dsl/dsl'
File without changes
File without changes
@@ -2,6 +2,11 @@ module Vedeu
2
2
 
3
3
  module Input
4
4
 
5
+ # Handle input when terminal is in :raw (character at a time)
6
+ # mode.
7
+ #
8
+ # @api private
9
+ #
5
10
  class Raw
6
11
 
7
12
  # @see Vedeu::Input::Raw#initialize
@@ -78,12 +78,12 @@ module Vedeu
78
78
 
79
79
  # @return [String]
80
80
  def mouse_off
81
- Vedeu::EscapeSequences::Esc.string('mouse_x10_off')
81
+ Vedeu::EscapeSequences::Esc.mouse_x10_off
82
82
  end
83
83
 
84
84
  # @return [String]
85
85
  def show_cursor
86
- Vedeu::EscapeSequences::Esc.string('show_cursor')
86
+ Vedeu::EscapeSequences::Esc.show_cursor
87
87
  end
88
88
 
89
89
  # @return [String]
@@ -61,6 +61,7 @@ module Vedeu
61
61
  end
62
62
  end
63
63
 
64
+ # @return [Array<void>|String]
64
65
  def cached
65
66
  cached_original = Vedeu::Output::CompressorCache.read(:original)
66
67
  cached_compressed = Vedeu::Output::CompressorCache.read(:compressed)
@@ -91,7 +92,6 @@ module Vedeu
91
92
  ].join
92
93
  end.join
93
94
 
94
-
95
95
  Vedeu.log(type: :compress,
96
96
  message: "#{message} -> #{out.size} characters".freeze)
97
97
 
@@ -2,6 +2,13 @@ module Vedeu
2
2
 
3
3
  module Output
4
4
 
5
+ # Store a copy of the data last processed by
6
+ # {Vedeu::Output::Compressor}. Both the original content and the
7
+ # compressed versions are kept (unless modified) to speed up the
8
+ # rendering of the display.
9
+ #
10
+ # @api private
11
+ #
5
12
  module CompressorCache
6
13
 
7
14
  extend self
@@ -60,7 +60,7 @@ module Vedeu
60
60
  def initialize_screen(mode)
61
61
  Vedeu.log(message: "Terminal entering '#{mode}' mode".freeze)
62
62
 
63
- output(Vedeu::EscapeSequences::Esc.string('screen_init'))
63
+ output(Vedeu::EscapeSequences::Esc.screen_init)
64
64
 
65
65
  yield if block_given?
66
66
  end
@@ -72,7 +72,7 @@ module Vedeu
72
72
  #
73
73
  # @return [String]
74
74
  def clear
75
- output(Vedeu::EscapeSequences::Esc.string('clear'))
75
+ output(Vedeu::EscapeSequences::Esc.clear)
76
76
  end
77
77
 
78
78
  # Attempts to tidy up the screen just before the application
@@ -82,7 +82,7 @@ module Vedeu
82
82
  #
83
83
  # @return [String]
84
84
  def restore_screen
85
- output(Vedeu::EscapeSequences::Esc.string('screen_exit'))
85
+ output(Vedeu::EscapeSequences::Esc.screen_exit)
86
86
  end
87
87
 
88
88
  # Sets the cursor to be visible unless in raw mode, whereby it
@@ -90,7 +90,7 @@ module Vedeu
90
90
  #
91
91
  # @return [String]
92
92
  def set_cursor_mode
93
- output(Vedeu::EscapeSequences::Esc.string('show_cursor')) unless raw_mode?
93
+ output(Vedeu::EscapeSequences::Esc.show_cursor) unless raw_mode?
94
94
  end
95
95
 
96
96
  # Returns a coordinate tuple of the format [y, x], where `y` is
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.68'.freeze
4
+ VERSION = '0.6.69'.freeze
5
5
 
6
6
  end
@@ -2,11 +2,11 @@ require 'test_helper'
2
2
 
3
3
  module Vedeu
4
4
 
5
- module Geometries
5
+ module Cursors
6
6
 
7
7
  describe Coordinate do
8
8
 
9
- let(:described) { Vedeu::Geometries::Coordinate }
9
+ let(:described) { Vedeu::Cursors::Coordinate }
10
10
  let(:instance) { described.new(attributes) }
11
11
  let(:attributes) {
12
12
  {
@@ -38,7 +38,7 @@ module Vedeu
38
38
  # it { skip }
39
39
  end
40
40
 
41
- # let(:described) { Vedeu::Geometries::Coordinate }
41
+ # let(:described) { Vedeu::Cursors::Coordinate }
42
42
  # let(:instance) { described.new(_name, oy, ox) }
43
43
  # let(:_name) { 'coordinate' }
44
44
  # let(:oy) { 0 }
@@ -162,6 +162,6 @@ module Vedeu
162
162
 
163
163
  end # Coordinate
164
164
 
165
- end # Geometries
165
+ end # Cursors
166
166
 
167
167
  end # Vedeu