vedeu 0.4.53 → 0.4.54
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vedeu/api.rb +68 -5
- data/lib/vedeu/bindings/system.rb +0 -15
- data/lib/vedeu/bindings/visibility.rb +57 -13
- data/lib/vedeu/buffers/buffer.rb +5 -56
- data/lib/vedeu/cursor/cursor.rb +24 -16
- data/lib/vedeu/exceptions.rb +1 -1
- data/lib/vedeu/models/group.rb +39 -4
- data/lib/vedeu/models/interface.rb +41 -5
- data/lib/vedeu/null/buffer.rb +5 -0
- data/lib/vedeu/null/interface.rb +15 -0
- data/lib/vedeu/output/all.rb +1 -1
- data/lib/vedeu/output/background.rb +1 -1
- data/lib/vedeu/output/clear/named_interface.rb +0 -2
- data/lib/vedeu/output/{translator.rb → colour_translator.rb} +5 -5
- data/lib/vedeu/output/foreground.rb +1 -1
- data/lib/vedeu/output/render_border.rb +0 -1
- data/lib/vedeu/repositories/model.rb +15 -6
- data/lib/vedeu/repositories/repositories/buffers.rb +6 -0
- data/lib/vedeu/repositories/repositories/cursors.rb +6 -0
- data/lib/vedeu/repositories/repositories/groups.rb +6 -0
- data/lib/vedeu/repositories/repositories/interfaces.rb +6 -0
- data/lib/vedeu/support/all.rb +1 -2
- data/lib/vedeu/support/template.rb +7 -0
- data/lib/vedeu/support/toggleable.rb +98 -0
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/api_test.rb +7 -1
- data/test/lib/vedeu/bindings/system_test.rb +5 -16
- data/test/lib/vedeu/bindings/visibility_test.rb +4 -0
- data/test/lib/vedeu/buffers/buffer_test.rb +9 -91
- data/test/lib/vedeu/cursor/cursor_test.rb +4 -6
- data/test/lib/vedeu/dsl/geometry_test.rb +24 -0
- data/test/lib/vedeu/models/group_test.rb +16 -14
- data/test/lib/vedeu/models/interface_test.rb +1 -1
- data/test/lib/vedeu/null/buffer_test.rb +6 -0
- data/test/lib/vedeu/null/interface_test.rb +18 -0
- data/test/lib/vedeu/output/clear/named_interface_test.rb +10 -19
- data/test/lib/vedeu/output/{translator_test.rb → colour_translator_test.rb} +5 -5
- data/test/lib/vedeu/support/toggleable_test.rb +69 -0
- data/vedeu.gemspec +1 -1
- metadata +10 -13
- data/lib/vedeu/support/options.rb +0 -70
- data/lib/vedeu/support/visibility.rb +0 -122
- data/test/lib/vedeu/support/options_test.rb +0 -70
- data/test/lib/vedeu/support/visibility_test.rb +0 -95
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 144b0ad6061194dfc5cb20651b818ed2512df6a0
|
4
|
+
data.tar.gz: 22ce31896daf7963b207766b655f41d31b8aa68d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0327fe74a67980d3db9b0f96479fd32e9cc32590b70dbabf52c8db7ad667df9948fcd280b5b417e21cde5d5a1ef1f72d96f5861a1d957447f03f5218ac8ed17
|
7
|
+
data.tar.gz: 2e8a1974fb367819b03a0b9baab9e341b8ec1a44ac20a44da22f091bd60e1fea47cdcb5ad1fb4bf27252b4544d44a265cbfd67f5f62f3ea5b494c5f316d3e178
|
data/lib/vedeu/api.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'vedeu/support/common'
|
2
2
|
require 'vedeu/support/terminal'
|
3
3
|
require 'vedeu/support/timer'
|
4
|
-
require 'vedeu/support/visibility'
|
5
4
|
require 'vedeu/output/renderers/all'
|
6
5
|
require 'vedeu/events/all'
|
7
6
|
require 'vedeu/models/all'
|
@@ -354,8 +353,8 @@ module Vedeu
|
|
354
353
|
# Vedeu.hide_cursor(name)
|
355
354
|
#
|
356
355
|
# @!method hide_cursor
|
357
|
-
# @see Vedeu::
|
358
|
-
def_delegators Vedeu::
|
356
|
+
# @see Vedeu::Cursor#hide
|
357
|
+
def_delegators Vedeu::Cursor, :hide_cursor
|
359
358
|
|
360
359
|
# Shows the cursor for the interface of the given name.
|
361
360
|
#
|
@@ -363,8 +362,72 @@ module Vedeu
|
|
363
362
|
# Vedeu.show_cursor(name)
|
364
363
|
#
|
365
364
|
# @!method show_cursor
|
366
|
-
# @see Vedeu::
|
367
|
-
def_delegators Vedeu::
|
365
|
+
# @see Vedeu::Cursor#show
|
366
|
+
def_delegators Vedeu::Cursor, :show_cursor
|
367
|
+
|
368
|
+
# Toggle the visibility of the cursor with the given name.
|
369
|
+
#
|
370
|
+
# @example
|
371
|
+
# Vedeu.toggle_cursor(name)
|
372
|
+
#
|
373
|
+
# @!method toggle_cursor
|
374
|
+
# @see Vedeu::Cursor#hide
|
375
|
+
# @see Vedeu::Cursor#show
|
376
|
+
def_delegators Vedeu::Cursor, :toggle_cursor
|
377
|
+
|
378
|
+
# Hide the group with the given name.
|
379
|
+
#
|
380
|
+
# @example
|
381
|
+
# Vedeu.hide_group(name)
|
382
|
+
#
|
383
|
+
# @!method hide_group
|
384
|
+
# @see Vedeu::Group#hide
|
385
|
+
def_delegators Vedeu::Group, :hide_group
|
386
|
+
|
387
|
+
# Shows the group with the given name.
|
388
|
+
#
|
389
|
+
# @example
|
390
|
+
# Vedeu.show_group(name)
|
391
|
+
#
|
392
|
+
# @!method show_group
|
393
|
+
# @see Vedeu::Group#show
|
394
|
+
def_delegators Vedeu::Group, :show_group
|
395
|
+
|
396
|
+
# Toggle the visibility of the group with the given name.
|
397
|
+
#
|
398
|
+
# @example
|
399
|
+
# Vedeu.toggle_group(name)
|
400
|
+
#
|
401
|
+
# @!method toggle_group
|
402
|
+
# @see Vedeu::Group#toggle
|
403
|
+
def_delegators Vedeu::Group, :toggle_group
|
404
|
+
|
405
|
+
# Hide the interface with the given name.
|
406
|
+
#
|
407
|
+
# @example
|
408
|
+
# Vedeu.hide_interface(name)
|
409
|
+
#
|
410
|
+
# @!method hide_interface
|
411
|
+
# @see Vedeu::Interface#hide
|
412
|
+
def_delegators Vedeu::Interface, :hide_interface
|
413
|
+
|
414
|
+
# Shows the interface with the given name.
|
415
|
+
#
|
416
|
+
# @example
|
417
|
+
# Vedeu.show_interface(name)
|
418
|
+
#
|
419
|
+
# @!method show_interface
|
420
|
+
# @see Vedeu::Interface#show
|
421
|
+
def_delegators Vedeu::Interface, :show_interface
|
422
|
+
|
423
|
+
# Toggle the visibility of the interface with the given name.
|
424
|
+
#
|
425
|
+
# @example
|
426
|
+
# Vedeu.toggle_interface(name)
|
427
|
+
#
|
428
|
+
# @!method toggle_interface
|
429
|
+
# @see Vedeu::Interface#toggle
|
430
|
+
def_delegators Vedeu::Interface, :toggle_interface
|
368
431
|
|
369
432
|
end # API
|
370
433
|
|
@@ -22,7 +22,6 @@ module Vedeu
|
|
22
22
|
def setup!
|
23
23
|
cleanup!
|
24
24
|
clear!
|
25
|
-
clear_group!
|
26
25
|
command!
|
27
26
|
exit!
|
28
27
|
focus_next!
|
@@ -78,20 +77,6 @@ module Vedeu
|
|
78
77
|
end
|
79
78
|
end
|
80
79
|
|
81
|
-
# Clears the spaces occupied by the interfaces belonging to the named
|
82
|
-
# group.
|
83
|
-
#
|
84
|
-
# @example
|
85
|
-
# Vedeu.trigger(:_clear_group_, name)
|
86
|
-
# Vedeu.clear_by_group(name)
|
87
|
-
#
|
88
|
-
# @return [void]
|
89
|
-
def clear_group!
|
90
|
-
Vedeu.bind(:_clear_group_) do |name|
|
91
|
-
Vedeu::Clear::NamedGroup.render(name)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
80
|
# Will cause the triggering of the `:command` event; which you should
|
96
81
|
# define to 'do things'
|
97
82
|
#
|
@@ -14,17 +14,34 @@ module Vedeu
|
|
14
14
|
#
|
15
15
|
# @return [void]
|
16
16
|
def setup!
|
17
|
+
clear_group!
|
17
18
|
hide_cursor!
|
18
19
|
hide_group!
|
19
20
|
hide_interface!
|
20
21
|
show_cursor!
|
21
22
|
show_group!
|
22
23
|
show_interface!
|
24
|
+
toggle_cursor!
|
25
|
+
toggle_group!
|
23
26
|
toggle_interface!
|
24
27
|
end
|
25
28
|
|
26
29
|
private
|
27
30
|
|
31
|
+
# Clears the spaces occupied by the interfaces belonging to the named
|
32
|
+
# group.
|
33
|
+
#
|
34
|
+
# @example
|
35
|
+
# Vedeu.trigger(:_clear_group_, name)
|
36
|
+
# Vedeu.clear_by_group(name)
|
37
|
+
#
|
38
|
+
# @return [void]
|
39
|
+
def clear_group!
|
40
|
+
Vedeu.bind(:_clear_group_) do |name|
|
41
|
+
Vedeu::Clear::NamedGroup.render(name)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
28
45
|
# Hide the cursor of the named interface or if a name is not given, the
|
29
46
|
# interface currently in focus.
|
30
47
|
#
|
@@ -36,7 +53,7 @@ module Vedeu
|
|
36
53
|
# @return [void]
|
37
54
|
def hide_cursor!
|
38
55
|
Vedeu.bind(:_hide_cursor_) do |name|
|
39
|
-
Vedeu::
|
56
|
+
Vedeu::Cursor.hide_cursor(name)
|
40
57
|
end
|
41
58
|
Vedeu.bind(:_cursor_hide_) do |name|
|
42
59
|
Vedeu.trigger(:_hide_cursor_, name)
|
@@ -50,12 +67,13 @@ module Vedeu
|
|
50
67
|
# effectively clear the terminal and show the new group.
|
51
68
|
#
|
52
69
|
# @example
|
53
|
-
# Vedeu.trigger(:_hide_group_,
|
70
|
+
# Vedeu.trigger(:_hide_group_, name)
|
71
|
+
# Vedeu.hide_group(name)
|
54
72
|
#
|
55
73
|
# @return [void]
|
56
74
|
def hide_group!
|
57
75
|
Vedeu.bind(:_hide_group_) do |name|
|
58
|
-
Vedeu.
|
76
|
+
Vedeu::Group.hide_group(name)
|
59
77
|
end
|
60
78
|
end
|
61
79
|
|
@@ -63,12 +81,12 @@ module Vedeu
|
|
63
81
|
#
|
64
82
|
# @example
|
65
83
|
# Vedeu.trigger(:_hide_interface_, name)
|
84
|
+
# Vedeu.hide_interface(name)
|
66
85
|
#
|
67
86
|
# @return [void]
|
68
|
-
# @see Vedeu::Buffer#hide
|
69
87
|
def hide_interface!
|
70
88
|
Vedeu.bind(:_hide_interface_) do |name|
|
71
|
-
Vedeu.
|
89
|
+
Vedeu::Interface.hide_interface(name)
|
72
90
|
end
|
73
91
|
end
|
74
92
|
|
@@ -83,7 +101,7 @@ module Vedeu
|
|
83
101
|
# @return [void]
|
84
102
|
def show_cursor!
|
85
103
|
Vedeu.bind(:_show_cursor_) do |name|
|
86
|
-
Vedeu::
|
104
|
+
Vedeu::Cursor.show_cursor(name)
|
87
105
|
end
|
88
106
|
Vedeu.bind(:_cursor_show_) do |name|
|
89
107
|
Vedeu.trigger(:_show_cursor_, name)
|
@@ -94,13 +112,13 @@ module Vedeu
|
|
94
112
|
# the named group.
|
95
113
|
#
|
96
114
|
# @example
|
97
|
-
# Vedeu.trigger(:_show_group_,
|
115
|
+
# Vedeu.trigger(:_show_group_, name)
|
116
|
+
# Vedeu.show_group(name)
|
98
117
|
#
|
99
118
|
# @return [void]
|
100
119
|
def show_group!
|
101
120
|
Vedeu.bind(:_show_group_) do |name|
|
102
|
-
Vedeu.
|
103
|
-
Vedeu.trigger(:_refresh_group_, name)
|
121
|
+
Vedeu::Group.show_group(name)
|
104
122
|
end
|
105
123
|
end
|
106
124
|
|
@@ -108,12 +126,38 @@ module Vedeu
|
|
108
126
|
#
|
109
127
|
# @example
|
110
128
|
# Vedeu.trigger(:_show_interface_, name)
|
129
|
+
# Vedeu.show_interface(name)
|
111
130
|
#
|
112
131
|
# @return [void]
|
113
|
-
# @see Vedeu::Buffer#show
|
114
132
|
def show_interface!
|
115
133
|
Vedeu.bind(:_show_interface_) do |name|
|
116
|
-
Vedeu.
|
134
|
+
Vedeu::Interface.show_interface(name)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
# Toggling a cursor.
|
139
|
+
#
|
140
|
+
# @example
|
141
|
+
# Vedeu.trigger(:_toggle_cursor_, name)
|
142
|
+
# Vedeu.toggle_cursor(name)
|
143
|
+
#
|
144
|
+
# @return [void]
|
145
|
+
def toggle_cursor!
|
146
|
+
Vedeu.bind(:_toggle_cursor_) do |name|
|
147
|
+
Vedeu::Cursor.toggle_cursor(name)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
# Toggling a group.
|
152
|
+
#
|
153
|
+
# @example
|
154
|
+
# Vedeu.trigger(:_toggle_group_, name)
|
155
|
+
# Vedeu.toggle_group(name)
|
156
|
+
#
|
157
|
+
# @return [void]
|
158
|
+
def toggle_group!
|
159
|
+
Vedeu.bind(:_toggle_group_) do |name|
|
160
|
+
Vedeu::Group.toggle_group(name)
|
117
161
|
end
|
118
162
|
end
|
119
163
|
|
@@ -121,12 +165,12 @@ module Vedeu
|
|
121
165
|
#
|
122
166
|
# @example
|
123
167
|
# Vedeu.trigger(:_toggle_interface_, name)
|
168
|
+
# Vedeu.toggle_interface(name)
|
124
169
|
#
|
125
170
|
# @return [void]
|
126
|
-
# @see Vedeu::Buffer#toggle
|
127
171
|
def toggle_interface!
|
128
172
|
Vedeu.bind(:_toggle_interface_) do |name|
|
129
|
-
Vedeu.
|
173
|
+
Vedeu::Interface.toggle_interface(name)
|
130
174
|
end
|
131
175
|
end
|
132
176
|
|
data/lib/vedeu/buffers/buffer.rb
CHANGED
@@ -79,13 +79,6 @@ module Vedeu
|
|
79
79
|
true
|
80
80
|
end
|
81
81
|
|
82
|
-
# Returns the front buffer or, if that is empty, the interface cleared.
|
83
|
-
#
|
84
|
-
# @return [void]
|
85
|
-
def clear
|
86
|
-
Vedeu::Output.render(clear_buffer)
|
87
|
-
end
|
88
|
-
|
89
82
|
# Return a boolean indicating content presence on the buffer type.
|
90
83
|
#
|
91
84
|
# @return [Boolean] Whether the buffer targetted has content.
|
@@ -108,6 +101,7 @@ module Vedeu
|
|
108
101
|
#
|
109
102
|
# @example
|
110
103
|
# Vedeu.trigger(:_hide_interface_, name)
|
104
|
+
# Vedeu.hide_interface(name)
|
111
105
|
#
|
112
106
|
# Will hide the named interface. If the interface is currently visible, it
|
113
107
|
# will be cleared- rendered blank. To show the interface, the
|
@@ -117,11 +111,7 @@ module Vedeu
|
|
117
111
|
#
|
118
112
|
# @return [void]
|
119
113
|
def hide
|
120
|
-
|
121
|
-
|
122
|
-
Vedeu::Visibility.hide(interface)
|
123
|
-
|
124
|
-
clear
|
114
|
+
Vedeu::Output.render(clear_buffer)
|
125
115
|
end
|
126
116
|
|
127
117
|
# Return the content for this buffer.
|
@@ -139,12 +129,12 @@ module Vedeu
|
|
139
129
|
def render
|
140
130
|
Vedeu::Output.render(buffer)
|
141
131
|
end
|
142
|
-
alias_method :content, :render
|
143
132
|
|
144
133
|
# Show this buffer.
|
145
134
|
#
|
146
135
|
# @example
|
147
136
|
# Vedeu.trigger(:_show_interface_, name)
|
137
|
+
# Vedeu.show_interface(name)
|
148
138
|
#
|
149
139
|
# Will show the named interface. If the interface is currently invisible, it
|
150
140
|
# will be shown- rendered with its latest content. To hide the interface,
|
@@ -154,37 +144,7 @@ module Vedeu
|
|
154
144
|
#
|
155
145
|
# @return [void]
|
156
146
|
def show
|
157
|
-
|
158
|
-
|
159
|
-
Vedeu::Visibility.show(interface)
|
160
|
-
|
161
|
-
render
|
162
|
-
end
|
163
|
-
|
164
|
-
# Toggles the visibility of this buffer.
|
165
|
-
#
|
166
|
-
# @example
|
167
|
-
# Vedeu.trigger(:_toggle_interface_, name)
|
168
|
-
#
|
169
|
-
# Will toggle the visibility of the named interface. If the interface is
|
170
|
-
# currently visible, the area it occupies will be clears and the interface
|
171
|
-
# will be marked invisible. If the interface is invisible, then the
|
172
|
-
# interface will be marked visible and rendered in the area it occupies.
|
173
|
-
#
|
174
|
-
# @note
|
175
|
-
# If an interface is marked visible whilst another view is occupying some
|
176
|
-
# or all of the interface's current position, the interface will overwrite
|
177
|
-
# this area- this may cause visual corruption.
|
178
|
-
#
|
179
|
-
# @return [void]
|
180
|
-
def toggle
|
181
|
-
if visible?
|
182
|
-
hide
|
183
|
-
|
184
|
-
else
|
185
|
-
show
|
186
|
-
|
187
|
-
end
|
147
|
+
Vedeu::Output.render(buffer)
|
188
148
|
end
|
189
149
|
|
190
150
|
private
|
@@ -249,18 +209,7 @@ module Vedeu
|
|
249
209
|
#
|
250
210
|
# @return [Vedeu::Interface]
|
251
211
|
def interface
|
252
|
-
|
253
|
-
end
|
254
|
-
|
255
|
-
# @return [Vedeu::Interface]
|
256
|
-
def view
|
257
|
-
if front?
|
258
|
-
front
|
259
|
-
|
260
|
-
else
|
261
|
-
interface
|
262
|
-
|
263
|
-
end
|
212
|
+
Vedeu.interfaces.by_name(name)
|
264
213
|
end
|
265
214
|
|
266
215
|
# @see Vedeu::Interface#visible
|
data/lib/vedeu/cursor/cursor.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'vedeu/support/toggleable'
|
2
|
+
|
1
3
|
module Vedeu
|
2
4
|
|
3
5
|
# Each interface has its own Cursor which maintains the position and
|
@@ -7,6 +9,7 @@ module Vedeu
|
|
7
9
|
class Cursor
|
8
10
|
|
9
11
|
include Vedeu::Model
|
12
|
+
include Vedeu::Toggleable
|
10
13
|
|
11
14
|
# @!attribute [r] attributes
|
12
15
|
# @return [Hash]
|
@@ -28,11 +31,6 @@ module Vedeu
|
|
28
31
|
# @return [Boolean|Symbol]
|
29
32
|
attr_reader :state
|
30
33
|
|
31
|
-
# @!attribute [r] visible
|
32
|
-
# @return [Boolean|Symbol]
|
33
|
-
attr_reader :visible
|
34
|
-
alias_method :visible?, :visible
|
35
|
-
|
36
34
|
# @!attribute [rw] x
|
37
35
|
# @return [Fixnum]
|
38
36
|
attr_accessor :x
|
@@ -94,9 +92,17 @@ module Vedeu
|
|
94
92
|
end
|
95
93
|
alias_method :to_str, :to_s
|
96
94
|
|
95
|
+
# Hide a named cursor, or without a name, the cursor of the currently
|
96
|
+
# focussed interface.
|
97
|
+
#
|
98
|
+
# @example
|
99
|
+
# Vedeu.hide_cursor(name)
|
100
|
+
#
|
97
101
|
# @return [Vedeu::EscapeChar]
|
98
|
-
def
|
99
|
-
|
102
|
+
def hide
|
103
|
+
super
|
104
|
+
|
105
|
+
visibility
|
100
106
|
end
|
101
107
|
|
102
108
|
# Return the position of this cursor.
|
@@ -106,15 +112,17 @@ module Vedeu
|
|
106
112
|
@position ||= Vedeu::Position[y, x]
|
107
113
|
end
|
108
114
|
|
115
|
+
# Show a named cursor, or without a name, the cursor of the currently
|
116
|
+
# focussed interface.
|
117
|
+
#
|
118
|
+
# @example
|
119
|
+
# Vedeu.show_cursor(name)
|
120
|
+
#
|
109
121
|
# @return [Vedeu::EscapeChar]
|
110
|
-
def
|
111
|
-
|
112
|
-
end
|
122
|
+
def show
|
123
|
+
super
|
113
124
|
|
114
|
-
|
115
|
-
# @return [void]
|
116
|
-
def visible=(value)
|
117
|
-
@visible = @attributes[:visible] = value
|
125
|
+
visibility
|
118
126
|
end
|
119
127
|
|
120
128
|
private
|
@@ -145,9 +153,9 @@ module Vedeu
|
|
145
153
|
#
|
146
154
|
# @return [String]
|
147
155
|
def visibility
|
148
|
-
return show_cursor if visible?
|
156
|
+
return Vedeu::EscapeChar.new(Vedeu::Esc.show_cursor) if visible?
|
149
157
|
|
150
|
-
hide_cursor
|
158
|
+
Vedeu::EscapeChar.new(Vedeu::Esc.hide_cursor)
|
151
159
|
end
|
152
160
|
|
153
161
|
end # Cursor
|