vedeu 0.4.46 → 0.4.47

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vedeu/api.rb +3 -3
  3. data/lib/vedeu/bindings/bindings.rb +14 -4
  4. data/lib/vedeu/bindings/drb.rb +2 -0
  5. data/lib/vedeu/bindings/menus.rb +2 -0
  6. data/lib/vedeu/bindings/movement.rb +2 -0
  7. data/lib/vedeu/bindings/visibility.rb +2 -0
  8. data/lib/vedeu/buffers/buffer.rb +1 -1
  9. data/lib/vedeu/cursor/cursor.rb +2 -2
  10. data/lib/vedeu/geometry/dimension.rb +16 -13
  11. data/lib/vedeu/geometry/geometry.rb +3 -1
  12. data/lib/vedeu/geometry/index_position.rb +1 -1
  13. data/lib/vedeu/geometry/position_index.rb +1 -1
  14. data/lib/vedeu/input/input.rb +2 -1
  15. data/lib/vedeu/input/keymap.rb +1 -0
  16. data/lib/vedeu/models/char.rb +7 -6
  17. data/lib/vedeu/models/interface.rb +2 -12
  18. data/lib/vedeu/models/line.rb +2 -2
  19. data/lib/vedeu/models/stream.rb +2 -2
  20. data/lib/vedeu/null/geometry.rb +3 -6
  21. data/lib/vedeu/output/all.rb +1 -1
  22. data/lib/vedeu/output/border.rb +5 -5
  23. data/lib/vedeu/output/clear/all.rb +2 -0
  24. data/lib/vedeu/output/clear/named_group.rb +52 -0
  25. data/lib/vedeu/output/clear/named_interface.rb +99 -0
  26. data/lib/vedeu/output/esc.rb +1 -1
  27. data/lib/vedeu/output/viewport.rb +10 -2
  28. data/lib/vedeu/repositories/registerable.rb +9 -1
  29. data/lib/vedeu/repositories/repositories/borders.rb +0 -11
  30. data/lib/vedeu/repositories/repositories/buffers.rb +0 -11
  31. data/lib/vedeu/repositories/repositories/cursors.rb +4 -11
  32. data/lib/vedeu/repositories/repositories/geometries.rb +0 -11
  33. data/lib/vedeu/repositories/repositories/groups.rb +4 -11
  34. data/lib/vedeu/repositories/repositories/interfaces.rb +0 -11
  35. data/lib/vedeu/repositories/repositories/keymaps.rb +4 -11
  36. data/lib/vedeu/repositories/repositories/menus.rb +4 -11
  37. data/lib/vedeu/repositories/repository.rb +1 -11
  38. data/lib/vedeu/storage/store.rb +15 -0
  39. data/lib/vedeu/support/log.rb +1 -0
  40. data/lib/vedeu/support/terminal.rb +1 -10
  41. data/lib/vedeu/support/visibility.rb +0 -1
  42. data/lib/vedeu/version.rb +1 -1
  43. data/test/lib/vedeu/geometry/geometry_test.rb +4 -0
  44. data/test/lib/vedeu/geometry/position_test.rb +25 -8
  45. data/test/lib/vedeu/models/char_test.rb +4 -4
  46. data/test/lib/vedeu/models/interface_test.rb +7 -2
  47. data/test/lib/vedeu/output/clear/named_group_test.rb +41 -0
  48. data/test/lib/vedeu/output/clear/named_interface_test.rb +68 -0
  49. data/test/lib/vedeu/output/render_border_test.rb +47 -5
  50. data/test/lib/vedeu/repositories/registerable_test.rb +30 -3
  51. data/test/lib/vedeu/repositories/repositories/borders_test.rb +0 -13
  52. data/test/lib/vedeu/repositories/repositories/buffers_test.rb +0 -11
  53. data/test/lib/vedeu/repositories/repositories/cursors_test.rb +0 -11
  54. data/test/lib/vedeu/repositories/repositories/geometries_test.rb +0 -11
  55. data/test/lib/vedeu/repositories/repositories/groups_test.rb +0 -11
  56. data/test/lib/vedeu/repositories/repositories/interfaces_test.rb +0 -11
  57. data/test/lib/vedeu/repositories/repositories/keymaps_test.rb +0 -11
  58. data/test/lib/vedeu/repositories/repositories/menus_test.rb +0 -11
  59. data/test/lib/vedeu/repositories/repository_test.rb +0 -37
  60. data/test/lib/vedeu/storage/store_test.rb +41 -0
  61. data/test/test_helper.rb +3 -1
  62. metadata +9 -5
  63. data/lib/vedeu/output/clear.rb +0 -207
  64. data/test/lib/vedeu/output/clear_test.rb +0 -105
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea321b7c3e36486983857a9d6ceeeecb333a17fd
4
- data.tar.gz: 5e52ca03e9336ced28a58cc062d680f2dab4b0fc
3
+ metadata.gz: 32f9ff175fb990493d886e0e0b121b50d45e8829
4
+ data.tar.gz: 78f1802b9c3c208a08947d4ea91a6c393f17214f
5
5
  SHA512:
6
- metadata.gz: f1097844c65d4242aa77ac45844005483b2a9f425a2e0a7469371c89126882a386c8cf708b96c42a8046762366249530aedbb19a7056132c0129f6ef824be583
7
- data.tar.gz: 83dc5668eacf4c40b1384345ba34ef0ac2845be750be21d94b7480666239eeda748e619e767139d967e1506ec425f34b8e7a0840d3e52e07b330539a9b5cca05
6
+ metadata.gz: 883b22230cf46167bb986ee49549dfe151ab43108f9d1bdd71fc77a2cc9de0fa9d819b9f6365dd059c443ab09ca3da01a43c01b6c5d21599e399f92073dd342f
7
+ data.tar.gz: aefa345c4db2d5123ce8c54569f301a3e812cf3b3109ece81d47d86dcb857baf761450fe49a5ad7cd3a3561f4ed74e600a9be5ea61f4a640ba0ca8f5951574c0
@@ -8,7 +8,7 @@ require 'vedeu/models/all'
8
8
  require 'vedeu/input/all'
9
9
  require 'vedeu/dsl/all'
10
10
  require 'vedeu/application'
11
- require 'vedeu/output/clear'
11
+ require 'vedeu/output/clear/all'
12
12
 
13
13
  module Vedeu
14
14
 
@@ -239,11 +239,11 @@ module Vedeu
239
239
 
240
240
  # @!method clear_by_name
241
241
  # @see Vedeu::Clear.by_name
242
- def_delegators Vedeu::Clear, :clear_by_name
242
+ def_delegators Vedeu::Clear::NamedInterface, :clear_by_name
243
243
 
244
244
  # @!method clear_by_group
245
245
  # @see Vedeu::Clear.by_group
246
- def_delegators Vedeu::Clear, :clear_by_group
246
+ def_delegators Vedeu::Clear::NamedGroup, :clear_by_group
247
247
 
248
248
  # @!method hide_cursor
249
249
  # @see Vedeu::Visibility.hide_cursor
@@ -15,6 +15,7 @@ module Vedeu
15
15
  #
16
16
  # @api public
17
17
  # {include:file:docs/events/main.md}
18
+ # :nocov:
18
19
  module Bindings
19
20
 
20
21
  include Vedeu::Bindings::DRB
@@ -30,6 +31,16 @@ module Vedeu
30
31
  Vedeu.trigger(:cleanup)
31
32
  end
32
33
 
34
+ Vedeu.bind(:_clear_) do |name|
35
+ if name
36
+ Vedeu::Clear::NamedInterface.render(name)
37
+
38
+ else
39
+ Vedeu::Terminal.clear
40
+
41
+ end
42
+ end
43
+ Vedeu.bind(:_clear_group_) { |name| Vedeu::Clear::NamedGroup.render(name) }
33
44
 
34
45
  Vedeu.bind(:_exit_) { Vedeu::Application.stop }
35
46
 
@@ -43,6 +54,8 @@ module Vedeu
43
54
  Vedeu.bind(:_command_) { |command| Vedeu.trigger(:command, command) }
44
55
  Vedeu.bind(:_log_) { |msg| Vedeu.log(type: :debug, message: msg) }
45
56
 
57
+ Vedeu.bind(:_maximise_) { |name| Vedeu.geometries.by_name(name).maximise }
58
+
46
59
  # When triggered (after the user presses `escape`), Vedeu switches from a
47
60
  # "raw mode" terminal to a "cooked mode" terminal. The idea here being that
48
61
  # the raw mode is for single keypress actions, whilst cooked mode allows the
@@ -56,21 +69,18 @@ module Vedeu
56
69
  Vedeu.bind(:_focus_by_name_) { |name| Vedeu.focus_by_name(name) }
57
70
  Vedeu.bind(:_focus_next_) { Vedeu.focus_next }
58
71
  Vedeu.bind(:_focus_prev_) { Vedeu.focus_previous }
59
- Vedeu.bind(:_clear_) { |name| Vedeu::Clear.by_name(name) }
60
72
 
61
73
  Vedeu.bind(:_refresh_) do |name|
62
74
  name ? Vedeu::Refresh.by_name(name) : Vedeu::Refresh.all
63
75
  end
64
-
65
76
  Vedeu.bind(:_refresh_cursor_) { |name| Vedeu::RefreshCursor.render(name) }
66
77
  Vedeu.bind(:_refresh_group_) { |name| Vedeu::Refresh.by_group(name) }
67
- Vedeu.bind(:_clear_group_) { |name| Vedeu::Clear.by_group(name) }
68
- Vedeu.bind(:_maximise_) { |name| Vedeu.geometries.by_name(name).maximise }
69
78
 
70
79
  Vedeu.bind(:_unmaximise_) do |name|
71
80
  Vedeu.geometries.by_name(name).unmaximise
72
81
  end
73
82
 
74
83
  end # Bindings
84
+ # :nocov:
75
85
 
76
86
  end # Vedeu
@@ -6,6 +6,7 @@ module Vedeu
6
6
  #
7
7
  # @api public
8
8
  # {include:file:docs/events/drb.md}
9
+ # :nocov:
9
10
  module DRB
10
11
 
11
12
  Vedeu.bind(:_drb_input_) do |data, type|
@@ -30,6 +31,7 @@ module Vedeu
30
31
  Vedeu.bind(:_drb_stop_) { Vedeu::Distributed::Server.stop }
31
32
 
32
33
  end # DRB
34
+ # :nocov:
33
35
 
34
36
  end # Bindings
35
37
 
@@ -7,6 +7,7 @@ module Vedeu
7
7
  #
8
8
  # @api public
9
9
  # {include:file:docs/events/menus.md}
10
+ # :nocov:
10
11
  module Menus
11
12
 
12
13
  Vedeu.bind(:_menu_bottom_) { |name| Vedeu.menus.find(name).bottom_item }
@@ -29,6 +30,7 @@ module Vedeu
29
30
  Vedeu.bind(:_menu_view_) { |name| Vedeu.menus.find(name).view }
30
31
 
31
32
  end # Menus
33
+ # :nocov:
32
34
 
33
35
  end # Bindings
34
36
 
@@ -6,6 +6,7 @@ module Vedeu
6
6
  #
7
7
  # @api public
8
8
  # {include:file:docs/events/movement.md}
9
+ # :nocov:
9
10
  module Movement
10
11
 
11
12
  Vedeu.bind(:_cursor_down_) do |name|
@@ -58,6 +59,7 @@ module Vedeu
58
59
  end
59
60
 
60
61
  end # Movement
62
+ # :nocov:
61
63
 
62
64
  end # Bindings
63
65
 
@@ -6,6 +6,7 @@ module Vedeu
6
6
  #
7
7
  # @api public
8
8
  # {include:file:docs/events/visibility.md}
9
+ # :nocov:
9
10
  module Visibility
10
11
 
11
12
  Vedeu.bind(:_hide_cursor_) { |name| Vedeu::Visibility.hide_cursor(name) }
@@ -26,6 +27,7 @@ module Vedeu
26
27
  end
27
28
 
28
29
  end # Visibility
30
+ # :nocov:
29
31
 
30
32
  end # Bindings
31
33
 
@@ -214,7 +214,7 @@ module Vedeu
214
214
  #
215
215
  # @return [void]
216
216
  def clear_buffer
217
- @clear_buffer ||= Vedeu::Clear.new(view).clear
217
+ @clear_buffer ||= Vedeu::Clear::NamedInterface.render(name)
218
218
  end
219
219
 
220
220
  # Returns the default options/attributes for this class.
@@ -63,7 +63,7 @@ module Vedeu
63
63
 
64
64
  @attributes.each { |key, value| instance_variable_set("@#{key}", value) }
65
65
 
66
- @position = Vedeu::Position.new(@y, @x)
66
+ @position = Vedeu::Position[@y, @x]
67
67
  end
68
68
 
69
69
  # Override Ruby's Object#inspect method to provide a more helpful output.
@@ -103,7 +103,7 @@ module Vedeu
103
103
  #
104
104
  # @return [Vedeu::Position]
105
105
  def position
106
- @position ||= Vedeu::Position.new(y, x)
106
+ @position ||= Vedeu::Position[y, x]
107
107
  end
108
108
 
109
109
  # @return [Vedeu::EscapeChar]
@@ -21,11 +21,9 @@ module Vedeu
21
21
  # @option attributes options [Hash]
22
22
  # @return [Vedeu::Dimension]
23
23
  def initialize(attributes = {})
24
- @d = attributes[:d]
25
- @dn = attributes[:dn]
26
- @d_dn = attributes[:d_dn]
27
- @default = attributes[:default]
28
- @options = attributes.fetch(:options, {})
24
+ @attributes = defaults.merge!(attributes)
25
+
26
+ @attributes.each { |key, value| instance_variable_set("@#{key}", value) }
29
27
  end
30
28
 
31
29
  # @return [Fixnum]
@@ -61,6 +59,10 @@ module Vedeu
61
59
  # @return [Fixnum|NilClass]
62
60
  attr_reader :default
63
61
 
62
+ # @!attribute [r] options
63
+ # @return [Hash<Symbol => Boolean]
64
+ attr_reader :options
65
+
64
66
  private
65
67
 
66
68
  # @return [Array<Fixnum>]
@@ -138,18 +140,19 @@ module Vedeu
138
140
  options[:maximised]
139
141
  end
140
142
 
141
- # @return [Hash<Symbol => Boolean>]
142
- def options
143
- defaults.merge!(@options)
144
- end
145
-
146
143
  # Returns the default options/attributes for this class.
147
144
  #
148
- # @return [Hash<Symbol => Boolean>]
145
+ # @return [Hash<Symbol => NilClass,Boolean>]
149
146
  def defaults
150
147
  {
151
- centred: false,
152
- maximised: false,
148
+ d: nil,
149
+ dn: nil,
150
+ d_dn: nil,
151
+ default: nil,
152
+ options: {
153
+ centred: false,
154
+ maximised: false,
155
+ },
153
156
  }
154
157
  end
155
158
 
@@ -115,6 +115,8 @@ module Vedeu
115
115
  def maximise
116
116
  return self if maximised?
117
117
 
118
+ Vedeu.trigger(:_clear_)
119
+
118
120
  @maximised = true
119
121
 
120
122
  work = store
@@ -136,7 +138,7 @@ module Vedeu
136
138
  def unmaximise
137
139
  return self unless maximised?
138
140
 
139
- Vedeu.trigger(:_clear_, name)
141
+ Vedeu.trigger(:_clear_)
140
142
 
141
143
  @maximised = false
142
144
 
@@ -30,7 +30,7 @@ module Vedeu
30
30
 
31
31
  # @return [Vedeu::Position]
32
32
  def []
33
- Vedeu::Position.new(y, x)
33
+ Vedeu::Position[y, x]
34
34
  end
35
35
  alias_method :to_position, :[]
36
36
 
@@ -43,7 +43,7 @@ module Vedeu
43
43
  #
44
44
  # @return [Vedeu::Position]
45
45
  def to_position
46
- Vedeu::Position.new(y, x)
46
+ Vedeu::Position[y, x]
47
47
  end
48
48
 
49
49
  # Returns the x index.
@@ -70,6 +70,7 @@ module Vedeu
70
70
  def specials
71
71
  {
72
72
  "\r" => :enter,
73
+ "\n" => :enter,
73
74
  "\t" => :tab,
74
75
  "\e" => :escape,
75
76
  "\e[A" => :up,
@@ -95,7 +96,7 @@ module Vedeu
95
96
  "\u0007" => :ctrl_g,
96
97
  "\u0008" => :ctrl_h,
97
98
  # "\u0009" => :ctrl_i, # duplicates tab
98
- "\u0010" => :ctrl_j,
99
+ "\u0010" => :ctrl_j, # produces "\n"
99
100
  "\u0011" => :ctrl_k,
100
101
  "\u0012" => :ctrl_l,
101
102
  "\u0013" => :ctrl_m,
@@ -1,3 +1,4 @@
1
+ require 'vedeu/input/key'
1
2
  require 'vedeu/dsl/keymap'
2
3
 
3
4
  module Vedeu
@@ -29,6 +29,10 @@ module Vedeu
29
29
  # @return [Hash]
30
30
  attr_reader :attributes
31
31
 
32
+ # @!attribute [r] position
33
+ # @return [Vedeu::Position]
34
+ attr_reader :position
35
+
32
36
  # @!attribute [w] value
33
37
  # @return [String]
34
38
  attr_writer :value
@@ -50,6 +54,7 @@ module Vedeu
50
54
  @border = @attributes[:border]
51
55
  @parent = @attributes[:parent]
52
56
  @value = @attributes[:value]
57
+ @position = Vedeu::Position.coerce(@attributes[:position])
53
58
  end
54
59
 
55
60
  # When {Vedeu::Viewport#padded_lines} has less lines that required to fill
@@ -68,7 +73,8 @@ module Vedeu
68
73
  # @param other [Vedeu::Char]
69
74
  # @return [Boolean]
70
75
  def eql?(other)
71
- self.class == other.class && value == other.value
76
+ self.class == other.class && value == other.value &&
77
+ position == other.position
72
78
  end
73
79
  alias_method :==, :eql?
74
80
 
@@ -79,11 +85,6 @@ module Vedeu
79
85
  "<Vedeu::Char '#{Vedeu::Esc.escape(to_s)}'>"
80
86
  end
81
87
 
82
- # @return [Vedeu::Position]
83
- def position
84
- @position ||= Vedeu::Position.coerce(@attributes[:position])
85
- end
86
-
87
88
  # Sets the position of the Char.
88
89
  #
89
90
  # @param value [Vedeu::Position]
@@ -12,8 +12,6 @@ module Vedeu
12
12
  # @api private
13
13
  class Interface
14
14
 
15
- extend Forwardable
16
-
17
15
  include Vedeu::Model
18
16
  include Vedeu::Presentation
19
17
  include Vedeu::DisplayBuffer
@@ -76,15 +74,7 @@ module Vedeu
76
74
  def initialize(attributes = {})
77
75
  @attributes = defaults.merge!(attributes)
78
76
 
79
- @client = @attributes[:client]
80
- @delay = @attributes[:delay]
81
- @group = @attributes[:group]
82
- @lines = @attributes[:lines]
83
- @name = @attributes[:name]
84
- @parent = @attributes[:parent]
85
- @repository = @attributes[:repository]
86
- @visible = @attributes[:visible]
87
- @zindex = @attributes[:zindex]
77
+ @attributes.each { |key, value| instance_variable_set("@#{key}", value) }
88
78
  end
89
79
 
90
80
  # @param child [Vedeu::Line]
@@ -121,7 +111,7 @@ module Vedeu
121
111
  Vedeu.trigger(:_cursor_hide_, name)
122
112
 
123
113
  output = [
124
- Vedeu::Clear.new(self).render,
114
+ Vedeu::Clear::NamedInterface.render(name),
125
115
  Vedeu.borders.by_name(name).render,
126
116
  Vedeu::Viewport.render(self),
127
117
  ]
@@ -31,8 +31,8 @@ module Vedeu
31
31
  # @return [Vedeu::Line]
32
32
  def initialize(attributes = {})
33
33
  @attributes = defaults.merge!(attributes)
34
- @parent = @attributes[:parent]
35
- @streams = @attributes[:streams]
34
+
35
+ @attributes.each { |key, value| instance_variable_set("@#{key}", value) }
36
36
  end
37
37
 
38
38
  # @param child []
@@ -38,8 +38,8 @@ module Vedeu
38
38
  # @return [Vedeu::Stream]
39
39
  def initialize(attributes = {})
40
40
  @attributes = defaults.merge!(attributes)
41
- @parent = @attributes[:parent]
42
- @value = @attributes[:value]
41
+
42
+ @attributes.each { |key, value| instance_variable_set("@#{key}", value) }
43
43
  end
44
44
 
45
45
  # @param child [Vedeu::Stream]
@@ -48,20 +48,17 @@ module Vedeu
48
48
  end
49
49
 
50
50
  # @return [FalseClass]
51
- def maximise
51
+ def maximised?
52
52
  false
53
53
  end
54
+ alias_method :maximise, :maximised?
55
+ alias_method :unmaximise, :maximised?
54
56
 
55
57
  # @return [Vedeu::Null::Geometry]
56
58
  def store
57
59
  self
58
60
  end
59
61
 
60
- # @return [FalseClass]
61
- def unmaximise
62
- false
63
- end
64
-
65
62
  private
66
63
 
67
64
  # @return [Vedeu::Area]
@@ -6,7 +6,7 @@ require_relative 'presentation'
6
6
  require_relative 'border'
7
7
  require_relative 'colour'
8
8
  require_relative 'compressor'
9
- require_relative 'clear'
9
+ require_relative 'clear/all'
10
10
  require_relative 'style'
11
11
  require_relative 'text'
12
12
  require_relative 'virtual_buffer'
@@ -122,22 +122,22 @@ module Vedeu
122
122
 
123
123
  # @return [Fixnum]
124
124
  def bx
125
- @bx ||= (enabled? && left?) ? x + 1 : x
125
+ (enabled? && left?) ? x + 1 : x
126
126
  end
127
127
 
128
128
  # @return [Fixnum]
129
129
  def bxn
130
- @bxn ||= (enabled? && right?) ? xn - 1 : xn
130
+ (enabled? && right?) ? xn - 1 : xn
131
131
  end
132
132
 
133
133
  # @return [Fixnum]
134
134
  def by
135
- @by ||= (enabled? && top?) ? y + 1 : y
135
+ (enabled? && top?) ? y + 1 : y
136
136
  end
137
137
 
138
138
  # @return [Fixnum]
139
139
  def byn
140
- @byn ||= (enabled? && bottom?) ? yn - 1 : yn
140
+ (enabled? && bottom?) ? yn - 1 : yn
141
141
  end
142
142
 
143
143
  # Returns the width of the interface determined by whether a left, right,
@@ -158,7 +158,7 @@ module Vedeu
158
158
 
159
159
  # @return [Array<Array<Vedeu::Char>>]
160
160
  def render
161
- @render ||= Vedeu::RenderBorder.with(self)
161
+ Vedeu::RenderBorder.with(self)
162
162
  end
163
163
 
164
164
  # @return [String]