vedeu 0.6.42 → 0.6.43

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b62ee246d1c9de2ac2eb6550b9fde097a68fcefd
4
- data.tar.gz: 6d5d120d36d610b98760645417b5f40b85efcec8
3
+ metadata.gz: 76cf0490e2ade62f367af8687bd0c3405cb50576
4
+ data.tar.gz: 22ead63f283a82e549c1473f894818d605e20c56
5
5
  SHA512:
6
- metadata.gz: 459e560a74dc825caaca7d05cc0ceb1b786ddbe6e8b8eaeb3bd9bb7fdc7b0777cb5e8fc3491dcb55a574bf2a1e97f7207a2c81e4648b75fcc437952349dab18b
7
- data.tar.gz: 0b24360813d018af3acd34282867274f8c835727da8411f2410e71e88a7fea98ea03c5979a4938b8ee6adfcae9da69736d53868cd3fa3a25d565d1910d28c349
6
+ metadata.gz: 1303f2563550fdf5fdcffe76e105d8841ed1b9e45ba7f8bfdaecdaab1215b1c4faa91dc19b0647f74262dd0631d669dc9a5c19c4ad194511c81dc74aeb2ace23
7
+ data.tar.gz: 98b5280ad56de99846f43bda276d3abb5dc55c94cf1cba0079042a2b1f89174d7a5b947583554d9217fb3b58f67ec7373d7f6cfec772ad7d8b03daf2345e9962
data/README.md CHANGED
@@ -25,6 +25,7 @@ have any problems with either of these operating systems.
25
25
  Vedeu relies on the following gems, these will be automatically
26
26
  installed when you install Vedeu (as documented below).
27
27
 
28
+ - benchmark-ips
28
29
  - bundler
29
30
  - rake
30
31
  - ruby-prof
data/lib/vedeu/all.rb CHANGED
@@ -27,11 +27,11 @@ require 'vedeu/null/all'
27
27
  require 'vedeu/models/views/all'
28
28
  require 'vedeu/models/all'
29
29
  require 'vedeu/application/all'
30
+ require 'vedeu/cursors/all'
30
31
  require 'vedeu/dsl/all'
31
32
  require 'vedeu/borders/all'
32
33
  require 'vedeu/buffers/all'
33
34
  require 'vedeu/colours/all'
34
- require 'vedeu/cursors/all'
35
35
  require 'vedeu/distributed/all'
36
36
  require 'vedeu/editor/all'
37
37
  require 'vedeu/geometry/all'
@@ -74,6 +74,34 @@ module Vedeu
74
74
  true
75
75
  end
76
76
 
77
+ # Return a boolean indicating whether the cursor should be
78
+ # visible for this view.
79
+ #
80
+ # On a per-view (and per-interface) basis, the cursor can be
81
+ # set to be visible or not visible.
82
+ #
83
+ # - If the cursor is visible, then refresh actions or events
84
+ # involving the cursor will act as normal; hiding and showing
85
+ # as the view is rendered or as events are triggered to change
86
+ # the visibility state.
87
+ # - If the cursor is not visible, then refresh actions and
88
+ # events involving the cursor will be ignored- the cursor is
89
+ # not shown, so do no work.
90
+ #
91
+ # @return [Boolean]
92
+ def cursor_visible?
93
+ if front?
94
+ front.cursor_visible?
95
+
96
+ elsif previous?
97
+ previous.cursor_visible?
98
+
99
+ else
100
+ Vedeu.interfaces.by_name(name).cursor_visible?
101
+
102
+ end
103
+ end
104
+
77
105
  # Return a boolean indicating content presence on the buffer
78
106
  # type.
79
107
  #
@@ -66,6 +66,11 @@ module Vedeu
66
66
  end
67
67
  end
68
68
 
69
+ # @return [Vedeu::Colours::Colour]
70
+ def self.default
71
+ new(background: :default, foreground: :default)
72
+ end
73
+
69
74
  # Returns a new instance of Vedeu::Colours::Colour.
70
75
  #
71
76
  # @param attributes [Hash]
@@ -16,5 +16,6 @@ module Vedeu
16
16
  end # Vedeu
17
17
 
18
18
  require 'vedeu/cursors/cursor'
19
+ require 'vedeu/cursors/dsl'
19
20
  require 'vedeu/cursors/refresh'
20
21
  require 'vedeu/cursors/repository'
@@ -200,8 +200,10 @@ module Vedeu
200
200
  # @example
201
201
  # Vedeu.trigger(:_hide_cursor_, name)
202
202
  # Vedeu.trigger(:_hide_cursor_, Vedeu.focus)
203
+ # Vedeu.trigger(:_hide_cursor_)
203
204
  # Vedeu.hide_cursor(name)
204
205
  # Vedeu.hide_cursor(Vedeu.focus)
206
+ # Vedeu.hide_cursor
205
207
  #
206
208
  # @return [Vedeu::Models::Escape]
207
209
  def hide
@@ -233,8 +235,10 @@ module Vedeu
233
235
  # @example
234
236
  # Vedeu.trigger(:_show_cursor_, name)
235
237
  # Vedeu.trigger(:_show_cursor_, Vedeu.focus)
238
+ # Vedeu.trigger(:_show_cursor_)
236
239
  # Vedeu.show_cursor(name)
237
240
  # Vedeu.show_cursor(Vedeu.focus)
241
+ # Vedeu.show_cursor
238
242
  #
239
243
  # @return [Vedeu::Models::Escape]
240
244
  def show
@@ -336,30 +340,46 @@ module Vedeu
336
340
 
337
341
  # See {file:docs/cursors.md}
338
342
  Vedeu.bind(:_cursor_left_) do |name|
339
- Vedeu.cursors.by_name(name).move_left
343
+ cursor = Vedeu.cursors.by_name(name)
340
344
 
341
- Vedeu.trigger(:_refresh_cursor_, name)
345
+ if cursor.visible?
346
+ cursor.move_left
347
+
348
+ Vedeu.trigger(:_refresh_cursor_, name)
349
+ end
342
350
  end
343
351
 
344
352
  # See {file:docs/cursors.md}
345
353
  Vedeu.bind(:_cursor_down_) do |name|
346
- Vedeu.cursors.by_name(name).move_down
354
+ cursor = Vedeu.cursors.by_name(name)
347
355
 
348
- Vedeu.trigger(:_refresh_cursor_, name)
356
+ if cursor.visible?
357
+ cursor.move_down
358
+
359
+ Vedeu.trigger(:_refresh_cursor_, name)
360
+ end
349
361
  end
350
362
 
351
363
  # See {file:docs/cursors.md}
352
364
  Vedeu.bind(:_cursor_up_) do |name|
353
- Vedeu.cursors.by_name(name).move_up
365
+ cursor = Vedeu.cursors.by_name(name)
354
366
 
355
- Vedeu.trigger(:_refresh_cursor_, name)
367
+ if cursor.visible?
368
+ cursor.move_up
369
+
370
+ Vedeu.trigger(:_refresh_cursor_, name)
371
+ end
356
372
  end
357
373
 
358
374
  # See {file:docs/cursors.md}
359
375
  Vedeu.bind(:_cursor_right_) do |name|
360
- Vedeu.cursors.by_name(name).move_right
376
+ cursor = Vedeu.cursors.by_name(name)
361
377
 
362
- Vedeu.trigger(:_refresh_cursor_, name)
378
+ if cursor.visible?
379
+ cursor.move_right
380
+
381
+ Vedeu.trigger(:_refresh_cursor_, name)
382
+ end
363
383
  end
364
384
 
365
385
  # See {file:docs/cursors.md}
@@ -0,0 +1,68 @@
1
+ module Vedeu
2
+
3
+ module Cursors
4
+
5
+ # Control the visibility of the cursor for each interface/view.
6
+ #
7
+ module DSL
8
+
9
+ # Set the cursor visibility on an interface.
10
+ #
11
+ # @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
+ #
39
+ # @return [Vedeu::Cursors::Cursor]
40
+ def cursor(value = true)
41
+ boolean = value ? true : false
42
+
43
+ model.cursor_visible = boolean
44
+
45
+ Vedeu::Cursors::Cursor.store(name: model.name, visible: boolean)
46
+ end
47
+
48
+ # Set the cursor to visible for the interface or view.
49
+ #
50
+ # @return [Vedeu::Cursors::Cursor]
51
+ def cursor!
52
+ cursor(true)
53
+ end
54
+ alias_method :show_cursor!, :cursor!
55
+
56
+ # Set the cursor to invisible for the interface or view.
57
+ #
58
+ # @return [Vedeu::Cursors::Cursor]
59
+ def no_cursor!
60
+ cursor(false)
61
+ end
62
+ alias_method :hide_cursor!, :no_cursor!
63
+
64
+ end # DSL
65
+
66
+ end # Cursors
67
+
68
+ end # Vedeu
@@ -21,8 +21,6 @@ module Vedeu
21
21
  # @param (see #initialize)
22
22
  # @return (see #by_name)
23
23
  def self.by_name(name = Vedeu.focus)
24
- name || Vedeu.focus
25
-
26
24
  new(name).by_name
27
25
  end
28
26
 
@@ -32,7 +30,7 @@ module Vedeu
32
30
  # cursor to be refreshed. Defaults to `Vedeu.focus`.
33
31
  # @return [Vedeu::Cursors::Refresh]
34
32
  def initialize(name)
35
- @name = present?(name) ? name : Vedeu.focus
33
+ @name = name
36
34
  end
37
35
 
38
36
  # Renders the cursor in the terminal. If the cursor's x or y
@@ -42,18 +40,22 @@ module Vedeu
42
40
  #
43
41
  # @return [Array]
44
42
  def by_name
45
- Vedeu.trigger(:_refresh_view_content_, name) if refresh_view?
43
+ refresh_view if refresh_view?
46
44
 
47
45
  cursor.render
48
46
  end
49
47
 
50
- protected
48
+ private
51
49
 
52
- # @!attribute [r] name
53
50
  # @return [String|Symbol]
54
- attr_reader :name
51
+ def name
52
+ present?(@name) ? @name : Vedeu.focus
53
+ end
55
54
 
56
- private
55
+ # @return [void]
56
+ def refresh_view
57
+ Vedeu.trigger(:_refresh_view_content_, name)
58
+ end
57
59
 
58
60
  # Returns true when the view should be refreshed. This is
59
61
  # determined by checking that the offsets for x and y are
@@ -61,7 +63,7 @@ module Vedeu
61
63
  #
62
64
  # @return [Boolean]
63
65
  def refresh_view?
64
- cursor.ox >= width || cursor.oy >= height
66
+ cursor.visible? && cursor.ox >= width || cursor.oy >= height
65
67
  end
66
68
 
67
69
  # @return [Vedeu::Cursors::Cursor]
@@ -84,6 +84,7 @@ module Vedeu
84
84
 
85
85
  include Vedeu::Common
86
86
  include Vedeu::DSL
87
+ include Vedeu::Cursors::DSL
87
88
  include Vedeu::DSL::Presentation
88
89
  include Vedeu::DSL::Shared
89
90
  include Vedeu::DSL::Text
@@ -8,6 +8,7 @@ module Vedeu
8
8
 
9
9
  include Vedeu::Common
10
10
  include Vedeu::DSL
11
+ include Vedeu::Cursors::DSL
11
12
  include Vedeu::DSL::Presentation
12
13
  include Vedeu::DSL::Shared
13
14
  include Vedeu::DSL::Text
@@ -101,49 +102,6 @@ module Vedeu
101
102
 
102
103
  end # Eigenclass
103
104
 
104
- # Set the cursor visibility on an interface.
105
- #
106
- # @param value [Boolean] Any value other than nil or false will
107
- # evaluate to true.
108
- #
109
- # @example
110
- # Vedeu.interface :my_interface do
111
- # cursor true # => show the cursor for this interface
112
- # # or...
113
- # cursor :show # => both of these are equivalent to line
114
- # # above
115
- # # or...
116
- # cursor! #
117
- # # ...
118
- # end
119
- #
120
- # Vedeu.interface :my_interface do
121
- # cursor false # => hide the cursor for this interface
122
- # # or...
123
- # cursor nil # => as above
124
- # # ...
125
- # end
126
- #
127
- # Vedeu.view :my_interface do
128
- # cursor true # => Specify the visibility of the cursor when
129
- # # the view is rendered.
130
- # # ...
131
- # end
132
- #
133
- # @return [Vedeu::Cursors::Cursor]
134
- def cursor(value = true)
135
- boolean = value ? true : false
136
-
137
- Vedeu::Cursors::Cursor.store(name: model.name, visible: boolean)
138
- end
139
-
140
- # Set the cursor to visible for the interface.
141
- #
142
- # @return [Vedeu::Cursors::Cursor]
143
- def cursor!
144
- cursor(true)
145
- end
146
-
147
105
  # To maintain performance interfaces can be delayed from
148
106
  # refreshing too often, the reduces artefacts particularly when
149
107
  # resizing the terminal screen.
@@ -271,13 +229,6 @@ module Vedeu
271
229
  model.name = value
272
230
  end
273
231
 
274
- # Set the cursor to invisible for the interface.
275
- #
276
- # @return [Vedeu::Cursors::Cursor]
277
- def no_cursor!
278
- cursor(false)
279
- end
280
-
281
232
  # Set the interface to visible.
282
233
  #
283
234
  # @example
@@ -19,6 +19,11 @@ module Vedeu
19
19
  # @return [Fixnum|Float]
20
20
  attr_accessor :client
21
21
 
22
+ # @!attribute [rw] cursor_visible
23
+ # @return [Boolean]
24
+ attr_accessor :cursor_visible
25
+ alias_method :cursor_visible?, :cursor_visible
26
+
22
27
  # @!attribute [rw] delay
23
28
  # @return [Fixnum|Float]
24
29
  attr_accessor :delay
@@ -49,6 +54,7 @@ module Vedeu
49
54
  # @param attributes [Hash]
50
55
  # @option attributes client [Vedeu::Client]
51
56
  # @option attributes colour [Vedeu::Colours::Colour]
57
+ # @option attributes cursor_visible [Boolean]
52
58
  # @option attributes delay [Float]
53
59
  # @option attributes group [String]
54
60
  # @option attributes name [String|Symbol]
@@ -112,18 +118,18 @@ module Vedeu
112
118
  # @return [Hash]
113
119
  def defaults
114
120
  {
115
- client: nil,
116
- colour: Vedeu::Colours::Colour.coerce(background: :default,
117
- foreground: :default),
118
- delay: 0.0,
119
- editable: false,
120
- group: '',
121
- name: '',
122
- parent: nil,
123
- repository: Vedeu.interfaces,
124
- style: :normal,
125
- visible: true,
126
- zindex: 0,
121
+ client: nil,
122
+ colour: Vedeu::Colours::Colour.default,
123
+ cursor_visible: true,
124
+ delay: 0.0,
125
+ editable: false,
126
+ group: '',
127
+ name: '',
128
+ parent: nil,
129
+ repository: Vedeu.interfaces,
130
+ style: :normal,
131
+ visible: true,
132
+ zindex: 0,
127
133
  }
128
134
  end
129
135
 
@@ -46,10 +46,10 @@ module Vedeu
46
46
  #
47
47
  module ClassMethods
48
48
 
49
- # Hides the model.
49
+ # Hides the named model, or without a name, the model with same
50
+ # name as the currently focussed interface.
50
51
  #
51
52
  # @example
52
- # Vedeu.hide_cursor(name)
53
53
  # Vedeu.hide_group(name)
54
54
  # Vedeu.hide_interface(name)
55
55
  #
@@ -58,14 +58,13 @@ module Vedeu
58
58
  def hide(name = Vedeu.focus)
59
59
  repository.by_name(name).hide
60
60
  end
61
- alias_method :hide_cursor, :hide
62
61
  alias_method :hide_group, :hide
63
62
  alias_method :hide_interface, :hide
64
63
 
65
- # Shows the model.
64
+ # Shows the named model, or without a name, the model with same
65
+ # name as the currently focussed interface.
66
66
  #
67
67
  # @example
68
- # Vedeu.show_cursor(name)
69
68
  # Vedeu.show_group(name)
70
69
  # Vedeu.show_interface(name)
71
70
  #
@@ -74,14 +73,13 @@ module Vedeu
74
73
  def show(name = Vedeu.focus)
75
74
  repository.by_name(name).show
76
75
  end
77
- alias_method :show_cursor, :show
78
76
  alias_method :show_group, :show
79
77
  alias_method :show_interface, :show
80
78
 
81
- # Toggles the visibility of the model.
79
+ # Toggles the visibility of the named model, or without a name,
80
+ # the model with same name as the currently focussed interface.
82
81
  #
83
82
  # @example
84
- # Vedeu.toggle_cursor(name)
85
83
  # Vedeu.toggle_group(name)
86
84
  # Vedeu.toggle_interface(name)
87
85
  #
@@ -90,10 +88,47 @@ module Vedeu
90
88
  def toggle(name = Vedeu.focus)
91
89
  repository.by_name(name).toggle
92
90
  end
93
- alias_method :toggle_cursor, :toggle
94
91
  alias_method :toggle_group, :toggle
95
92
  alias_method :toggle_interface, :toggle
96
93
 
94
+ # @example
95
+ # Vedeu.hide_cursor(name)
96
+ #
97
+ # @param name [String|Symbol]
98
+ # @return [void]
99
+ # @see Vedeu::Toggleable#hide
100
+ def hide_cursor(name = Vedeu.focus)
101
+ hide(name) if cursor_visible?(name)
102
+ end
103
+
104
+ # @example
105
+ # Vedeu.show_cursor(name)
106
+ #
107
+ # @param name [String|Symbol]
108
+ # @return [void]
109
+ # @see Vedeu::Toggleable#show
110
+ def show_cursor(name = Vedeu.focus)
111
+ show(name) if cursor_visible?(name)
112
+ end
113
+
114
+ # @example
115
+ # Vedeu.toggle_cursor(name)
116
+ #
117
+ # @param name [String|Symbol]
118
+ # @return [void]
119
+ # @see Vedeu::Toggleable#toggle
120
+ def toggle_cursor(name = Vedeu.focus)
121
+ toggle(name) if cursor_visible?(name)
122
+ end
123
+
124
+ private
125
+
126
+ # @param name [String|Symbol]
127
+ # @return [Boolean]
128
+ def cursor_visible?(name)
129
+ Vedeu.buffers.by_name(name).cursor_visible?
130
+ end
131
+
97
132
  end # ClassMethods
98
133
 
99
134
  # When this module is included in a class, provide ClassMethods as