vedeu 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/api.md +2 -0
- data/docs/events.md +0 -4
- data/examples/cursor_app/cursor_app.rb +56 -44
- data/lib/vedeu/api/api.rb +4 -6
- data/lib/vedeu/api/composition.rb +3 -7
- data/lib/vedeu/api/interface.rb +2 -3
- data/lib/vedeu/api/menu.rb +5 -3
- data/lib/vedeu/api/stream.rb +34 -0
- data/lib/vedeu/application.rb +4 -7
- data/lib/vedeu/configuration/api.rb +0 -5
- data/lib/vedeu/configuration/cli.rb +0 -1
- data/lib/vedeu/configuration/configuration.rb +0 -12
- data/lib/vedeu/input/input.rb +0 -3
- data/lib/vedeu/launcher.rb +0 -1
- data/lib/vedeu/models/{attributes/background.rb → background.rb} +0 -4
- data/lib/vedeu/models/char.rb +43 -0
- data/lib/vedeu/models/colour.rb +0 -1
- data/lib/vedeu/models/composition.rb +4 -3
- data/lib/vedeu/models/cursor.rb +70 -146
- data/lib/vedeu/models/{attributes/foreground.rb → foreground.rb} +0 -4
- data/lib/vedeu/models/geometry.rb +19 -20
- data/lib/vedeu/models/interface.rb +36 -5
- data/lib/vedeu/models/keymap.rb +7 -4
- data/lib/vedeu/models/line.rb +31 -11
- data/lib/vedeu/models/offset.rb +84 -0
- data/lib/vedeu/models/stream.rb +37 -13
- data/lib/vedeu/models/style.rb +0 -1
- data/lib/vedeu/output/area.rb +284 -0
- data/lib/vedeu/output/clear.rb +2 -4
- data/lib/vedeu/output/compositor.rb +0 -4
- data/lib/vedeu/output/refresh.rb +1 -2
- data/lib/vedeu/output/render.rb +12 -163
- data/lib/vedeu/output/view.rb +0 -2
- data/lib/vedeu/output/viewport.rb +132 -0
- data/lib/vedeu/repositories/buffers.rb +11 -22
- data/lib/vedeu/repositories/cursors.rb +20 -47
- data/lib/vedeu/repositories/events.rb +2 -1
- data/lib/vedeu/repositories/focus.rb +16 -16
- data/lib/vedeu/repositories/groups.rb +1 -4
- data/lib/vedeu/repositories/interfaces.rb +10 -3
- data/lib/vedeu/repositories/keymaps.rb +0 -3
- data/lib/vedeu/repositories/menus.rb +0 -2
- data/lib/vedeu/repositories/offsets.rb +47 -0
- data/lib/vedeu/{models/attributes → support}/coercions.rb +0 -0
- data/lib/vedeu/{models/attributes → support}/colour_translator.rb +0 -16
- data/lib/vedeu/support/esc.rb +0 -22
- data/lib/vedeu/support/event.rb +1 -17
- data/lib/vedeu/support/exceptions.rb +0 -3
- data/lib/vedeu/support/grid.rb +0 -3
- data/lib/vedeu/support/log.rb +13 -14
- data/lib/vedeu/support/move.rb +50 -0
- data/lib/vedeu/support/position.rb +17 -9
- data/lib/vedeu/{models/attributes → support}/presentation.rb +1 -4
- data/lib/vedeu/support/registrar.rb +2 -2
- data/lib/vedeu/support/repository.rb +23 -2
- data/lib/vedeu/support/terminal.rb +0 -2
- data/lib/vedeu/support/trace.rb +0 -11
- data/lib/vedeu.rb +11 -5
- data/test/lib/vedeu/api/api_test.rb +14 -5
- data/test/lib/vedeu/api/composition_test.rb +9 -26
- data/test/lib/vedeu/api/keymap_test.rb +1 -1
- data/test/lib/vedeu/api/menu_test.rb +6 -0
- data/test/lib/vedeu/api/stream_test.rb +32 -0
- data/test/lib/vedeu/models/{attributes/background_test.rb → background_test.rb} +0 -0
- data/test/lib/vedeu/models/char_test.rb +46 -0
- data/test/lib/vedeu/models/composition_test.rb +7 -0
- data/test/lib/vedeu/models/cursor_test.rb +63 -80
- data/test/lib/vedeu/models/{attributes/foreground_test.rb → foreground_test.rb} +0 -0
- data/test/lib/vedeu/models/geometry_test.rb +8 -10
- data/test/lib/vedeu/models/interface_test.rb +26 -21
- data/test/lib/vedeu/models/keymap_test.rb +6 -0
- data/test/lib/vedeu/models/line_test.rb +82 -3
- data/test/lib/vedeu/models/offset_test.rb +121 -0
- data/test/lib/vedeu/models/stream_test.rb +107 -8
- data/test/lib/vedeu/output/area_test.rb +242 -0
- data/test/lib/vedeu/output/compositor_test.rb +12 -3
- data/test/lib/vedeu/output/render_test.rb +34 -39
- data/test/lib/vedeu/output/viewport_test.rb +36 -0
- data/test/lib/vedeu/repositories/cursors_test.rb +32 -9
- data/test/lib/vedeu/repositories/focus_test.rb +8 -0
- data/test/lib/vedeu/repositories/offsets_test.rb +32 -0
- data/test/lib/vedeu/{models/attributes → support}/coercions_test.rb +0 -0
- data/test/lib/vedeu/{models/attributes → support}/colour_translator_test.rb +0 -0
- data/test/lib/vedeu/support/move_test.rb +35 -0
- data/test/lib/vedeu/{models/attributes → support}/presentation_test.rb +0 -0
- data/test/lib/vedeu/support/registrar_test.rb +6 -0
- data/test/lib/vedeu_test.rb +5 -0
- data/vedeu.gemspec +1 -1
- metadata +37 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ab3b3e107a170520a384cb15529a6cb087b6aae
|
4
|
+
data.tar.gz: 96170b0362f0584f7ce527290cf3068bb2fe26bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 08584d6388fbac9ee09e678a22362aaff1028cbd547b3583dad82c67ae8cfb790989066412bc9de4ca0ff800127f7c5fd7a3f36281ee7329c0c04e6eec1ff574
|
7
|
+
data.tar.gz: 96a95d7eca4e92b3794eb96e3183fb75b908e74ea77aff7f561051ee37aac9ec2dd057e128c27e4acec3815c0c3bf0079cf4c8fc6fe312b59845cf639730a9a5
|
data/docs/api.md
CHANGED
data/docs/events.md
CHANGED
@@ -43,10 +43,6 @@ Hides the cursor for the focussed interface.
|
|
43
43
|
|
44
44
|
Shows the cursor for the focussed interface.
|
45
45
|
|
46
|
-
### `:_cursor_refresh_`
|
47
|
-
|
48
|
-
Refreshes the cursor for the focussed interface.
|
49
|
-
|
50
46
|
### `:_exit_`
|
51
47
|
|
52
48
|
When triggered, Vedeu will trigger a `:_cleanup_` event which you can define (to save files, etc) and attempt to exit.
|
@@ -17,34 +17,15 @@ class VedeuCursorApp
|
|
17
17
|
centred true
|
18
18
|
colour foreground: '#ff0000', background: '#000000'
|
19
19
|
height 4
|
20
|
-
width
|
20
|
+
width 15
|
21
21
|
end
|
22
22
|
|
23
|
-
interface '
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
y
|
29
|
-
x { use('iron').east(1) }
|
30
|
-
end
|
31
|
-
|
32
|
-
interface 'francium' do
|
33
|
-
centred false
|
34
|
-
colour foreground: '#ff00ff', background: '#000000'
|
35
|
-
height 4
|
36
|
-
width 12
|
37
|
-
y { use('iron').north(5) }
|
38
|
-
x { use('iron').west(13) }
|
39
|
-
end
|
40
|
-
|
41
|
-
interface 'argon' do
|
42
|
-
centred false
|
43
|
-
colour foreground: '#00ff00', background: '#000000'
|
44
|
-
height 4
|
45
|
-
width 12
|
46
|
-
y { use('iron').south }
|
47
|
-
x { use('iron').west(13) }
|
23
|
+
interface 'gold' do
|
24
|
+
colour foreground: '#00ff00', background: '#001100'
|
25
|
+
height 4
|
26
|
+
width 15
|
27
|
+
x use('iron').left
|
28
|
+
y use('iron').south
|
48
29
|
end
|
49
30
|
|
50
31
|
keys do
|
@@ -54,26 +35,57 @@ class VedeuCursorApp
|
|
54
35
|
key(:left) { trigger(:_cursor_left_) }
|
55
36
|
end
|
56
37
|
|
38
|
+
focus('iron')
|
39
|
+
|
57
40
|
render do
|
58
41
|
view 'iron' do
|
59
|
-
line
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
line '
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
42
|
+
line do
|
43
|
+
stream do
|
44
|
+
text 'A 23456789 '
|
45
|
+
end
|
46
|
+
stream do
|
47
|
+
background '#550000'
|
48
|
+
foreground '#ffff00'
|
49
|
+
text 'hydrogen'
|
50
|
+
end
|
51
|
+
stream do
|
52
|
+
text ' helium'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
line 'B 23456789 lithium beryllium boron nitrogen'
|
56
|
+
line do
|
57
|
+
stream do
|
58
|
+
text 'C 23456789'
|
59
|
+
end
|
60
|
+
stream do
|
61
|
+
text ' carbon oxygen '
|
62
|
+
end
|
63
|
+
stream do
|
64
|
+
background '#aadd00'
|
65
|
+
foreground '#000000'
|
66
|
+
text 'fluorine'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
line 'D 23456789'
|
70
|
+
line
|
71
|
+
line 'E 23456789 neon sodium'
|
72
|
+
line do
|
73
|
+
stream do
|
74
|
+
text 'F 23456789 magnesium '
|
75
|
+
end
|
76
|
+
stream do
|
77
|
+
foreground '#00aaff'
|
78
|
+
text 'aluminium'
|
79
|
+
end
|
80
|
+
end
|
81
|
+
line 'G 23456789 silicon'
|
82
|
+
line do
|
83
|
+
stream do
|
84
|
+
background '#550000'
|
85
|
+
foreground '#ff00ff'
|
86
|
+
text 'H 234'
|
87
|
+
end
|
88
|
+
end
|
77
89
|
end
|
78
90
|
end
|
79
91
|
|
data/lib/vedeu/api/api.rb
CHANGED
@@ -214,7 +214,10 @@ module Vedeu
|
|
214
214
|
# view 'my_interface' do
|
215
215
|
# ...
|
216
216
|
#
|
217
|
-
# @
|
217
|
+
# @raise [InvalidSyntax] When the required block is not given.
|
218
|
+
# @return [Array] A collection of strings, each defining containing the
|
219
|
+
# escape sequences and content. This data has already been sent to the
|
220
|
+
# terminal to be output.
|
218
221
|
def render(&block)
|
219
222
|
API::Composition.render(&block)
|
220
223
|
end
|
@@ -223,19 +226,14 @@ module Vedeu
|
|
223
226
|
# and attempt to redraw the current interface with varying degrees of
|
224
227
|
# success. Can also be used to simulate a terminal resize.
|
225
228
|
#
|
226
|
-
# @api private
|
227
229
|
# @return [TrueClass]
|
228
|
-
# :nocov:
|
229
230
|
def resize
|
230
231
|
trigger(:_clear_)
|
231
232
|
|
232
233
|
trigger(:_refresh_)
|
233
234
|
|
234
|
-
trigger(:_cursor_refresh_)
|
235
|
-
|
236
235
|
true
|
237
236
|
end
|
238
|
-
# :nocov:
|
239
237
|
|
240
238
|
# Trigger a registered or system event by name with arguments. If the
|
241
239
|
# event stored returns a value, that is returned.
|
@@ -7,13 +7,9 @@ module Vedeu
|
|
7
7
|
# @api public
|
8
8
|
class Composition < Vedeu::Composition
|
9
9
|
|
10
|
-
# Directly write a view buffer to the terminal.
|
11
|
-
#
|
12
10
|
# @param block [Proc]
|
13
|
-
# @
|
14
|
-
# @
|
15
|
-
# escape sequences and content. This data has already been sent to the
|
16
|
-
# terminal to be output.
|
11
|
+
# @return [Array]
|
12
|
+
# @see Vedeu::API#render
|
17
13
|
def self.render(&block)
|
18
14
|
fail InvalidSyntax, '`render` requires a block.' unless block_given?
|
19
15
|
|
@@ -28,7 +24,7 @@ module Vedeu
|
|
28
24
|
|
29
25
|
# @param name [String]
|
30
26
|
# @param block [Proc]
|
31
|
-
# @return []
|
27
|
+
# @return [Hash]
|
32
28
|
# @see Vedeu::API#view
|
33
29
|
def view(name, &block)
|
34
30
|
attributes[:interfaces] << API::Interface
|
data/lib/vedeu/api/interface.rb
CHANGED
@@ -193,7 +193,6 @@ module Vedeu
|
|
193
193
|
|
194
194
|
# Returns the out of bounds error message for the given named attribute.
|
195
195
|
#
|
196
|
-
# @api private
|
197
196
|
# @param name [String]
|
198
197
|
# @return [String]
|
199
198
|
def out_of_bounds(name)
|
@@ -203,7 +202,7 @@ module Vedeu
|
|
203
202
|
|
204
203
|
# Checks the value is within the terminal's confines.
|
205
204
|
#
|
206
|
-
# @
|
205
|
+
# @param value [Fixnum]
|
207
206
|
# @return [Boolean]
|
208
207
|
def y_out_of_bounds?(value)
|
209
208
|
value < 1 || value > Terminal.height
|
@@ -211,7 +210,7 @@ module Vedeu
|
|
211
210
|
|
212
211
|
# Checks the value is within the terminal's confines.
|
213
212
|
#
|
214
|
-
# @
|
213
|
+
# @param value [Fixnum]
|
215
214
|
# @return [Boolean]
|
216
215
|
def x_out_of_bounds?(value)
|
217
216
|
value < 1 || value > Terminal.width
|
data/lib/vedeu/api/menu.rb
CHANGED
@@ -83,7 +83,6 @@ module Vedeu
|
|
83
83
|
|
84
84
|
# The default values for a new instance of Menu.
|
85
85
|
#
|
86
|
-
# @api private
|
87
86
|
# @return [Hash]
|
88
87
|
def defaults
|
89
88
|
{
|
@@ -92,12 +91,15 @@ module Vedeu
|
|
92
91
|
}
|
93
92
|
end
|
94
93
|
|
95
|
-
# @
|
94
|
+
# @param method [Symbol] The name of the method sought.
|
95
|
+
# @param args [Array] The arguments which the method was to be invoked
|
96
|
+
# with.
|
97
|
+
# @param block [Proc] The optional block provided to the method.
|
96
98
|
# @return []
|
97
99
|
def method_missing(method, *args, &block)
|
98
100
|
Vedeu.log("API::Menu#method_missing '#{method.to_s}' (args: #{args.inspect})")
|
99
101
|
|
100
|
-
@self_before_instance_eval.send(method, *args, &block)
|
102
|
+
@self_before_instance_eval.send(method, *args, &block) if @self_before_instance_eval
|
101
103
|
end
|
102
104
|
|
103
105
|
end # Menu
|
data/lib/vedeu/api/stream.rb
CHANGED
@@ -34,6 +34,40 @@ module Vedeu
|
|
34
34
|
attributes[:align] = value.to_sym
|
35
35
|
end
|
36
36
|
|
37
|
+
# Specify the background colour for a stream.
|
38
|
+
#
|
39
|
+
# @param value [String]
|
40
|
+
#
|
41
|
+
# @example
|
42
|
+
# ...
|
43
|
+
# stream do
|
44
|
+
# background '#0022ff'
|
45
|
+
# ... other stream directives ...
|
46
|
+
#
|
47
|
+
# @return [Hash]
|
48
|
+
def background(value = '')
|
49
|
+
fail InvalidSyntax, '`background` requires a value.' unless defined_value?(value)
|
50
|
+
|
51
|
+
attributes[:colour].merge!({ background: value })
|
52
|
+
end
|
53
|
+
|
54
|
+
# Specify the foreground colour for a stream.
|
55
|
+
#
|
56
|
+
# @param value [String]
|
57
|
+
#
|
58
|
+
# @example
|
59
|
+
# ...
|
60
|
+
# stream do
|
61
|
+
# foreground '#0022ff'
|
62
|
+
# ... other stream directives ...
|
63
|
+
#
|
64
|
+
# @return [Hash]
|
65
|
+
def foreground(value = '')
|
66
|
+
fail InvalidSyntax, '`foreground` requires a value.' unless defined_value?(value)
|
67
|
+
|
68
|
+
attributes[:colour].merge!({ foreground: value })
|
69
|
+
end
|
70
|
+
|
37
71
|
# Syntactic sugar used with {#align} to left align content.
|
38
72
|
#
|
39
73
|
# @return [Symbol]
|
data/lib/vedeu/application.rb
CHANGED
@@ -4,7 +4,7 @@ module Vedeu
|
|
4
4
|
#
|
5
5
|
# @api private
|
6
6
|
class Application
|
7
|
-
|
7
|
+
|
8
8
|
class << self
|
9
9
|
|
10
10
|
# @return []
|
@@ -19,7 +19,6 @@ module Vedeu
|
|
19
19
|
# is about to terminate. Client applications are encouraged to use this
|
20
20
|
# event to close any open buffers, save files, empty trash, etc.
|
21
21
|
#
|
22
|
-
# @api private
|
23
22
|
# @raise [StopIteration] Will cause {#start} to exit its loop and
|
24
23
|
# terminate the application.
|
25
24
|
# @return [StopIteration]
|
@@ -28,7 +27,8 @@ module Vedeu
|
|
28
27
|
|
29
28
|
fail StopIteration
|
30
29
|
end
|
31
|
-
|
30
|
+
|
31
|
+
end # self
|
32
32
|
|
33
33
|
# @return [Application]
|
34
34
|
def initialize; end
|
@@ -60,7 +60,6 @@ module Vedeu
|
|
60
60
|
# Runs the application loop either once, or forever (exceptions and signals
|
61
61
|
# permitting).
|
62
62
|
#
|
63
|
-
# @api private
|
64
63
|
# @return []
|
65
64
|
def runner
|
66
65
|
if Configuration.once?
|
@@ -79,7 +78,6 @@ module Vedeu
|
|
79
78
|
# and 'do something useful'. When the client application has finished, it
|
80
79
|
# should trigger the `:_exit_` event.
|
81
80
|
#
|
82
|
-
# @api private
|
83
81
|
# @return []
|
84
82
|
def main_sequence
|
85
83
|
if Configuration.interactive?
|
@@ -95,7 +93,6 @@ module Vedeu
|
|
95
93
|
# uncaught exception occurs or when either the `:_mode_switch_` or `:_exit_`
|
96
94
|
# event is triggered.
|
97
95
|
#
|
98
|
-
# @api private
|
99
96
|
# @return []
|
100
97
|
def run_many
|
101
98
|
loop { yield }
|
@@ -108,5 +105,5 @@ module Vedeu
|
|
108
105
|
end
|
109
106
|
|
110
107
|
end # Application
|
111
|
-
|
108
|
+
|
112
109
|
end # Vedeu
|
@@ -298,7 +298,6 @@ module Vedeu
|
|
298
298
|
# Returns the options set via the configuration API DSL or an empty Hash
|
299
299
|
# if none were set.
|
300
300
|
#
|
301
|
-
# @api private
|
302
301
|
# @return [Hash]
|
303
302
|
def options
|
304
303
|
@_options ||= {}
|
@@ -307,7 +306,6 @@ module Vedeu
|
|
307
306
|
# Returns the system keys set via the configuration API DSL or an empty
|
308
307
|
# hash if none were redefined.
|
309
308
|
#
|
310
|
-
# @api private
|
311
309
|
# @return [Hash]
|
312
310
|
def system_key_options
|
313
311
|
@_system_key_options ||= Configuration.default_system_keys
|
@@ -315,7 +313,6 @@ module Vedeu
|
|
315
313
|
|
316
314
|
# Checks that the value provided to {#colour_mode} is valid.
|
317
315
|
#
|
318
|
-
# @api private
|
319
316
|
# @param value [Fixnum]
|
320
317
|
# @return [Boolean]
|
321
318
|
def valid_colour_mode?(value)
|
@@ -326,7 +323,6 @@ module Vedeu
|
|
326
323
|
# {#focus_prev_key} and {#mode_switch_key} is valid. Must be a Symbol or a
|
327
324
|
# non-empty String.
|
328
325
|
#
|
329
|
-
# @api private
|
330
326
|
# @param value [String|Symbol]
|
331
327
|
# @return [Boolean]
|
332
328
|
def valid_key?(value)
|
@@ -340,7 +336,6 @@ module Vedeu
|
|
340
336
|
# Raises an exception on behalf of the calling method to report that the
|
341
337
|
# value provided is not valid.
|
342
338
|
#
|
343
|
-
# @api private
|
344
339
|
# @param system_key [String] The calling method wishing to raise an
|
345
340
|
# exception.
|
346
341
|
# @raise [InvalidSyntax] When the system_key parameter is not a String or
|
@@ -98,7 +98,6 @@ module Vedeu
|
|
98
98
|
|
99
99
|
# Vedeu's default system keys. Use {#system_keys}.
|
100
100
|
#
|
101
|
-
# @api private
|
102
101
|
# @return [Hash]
|
103
102
|
def default_system_keys
|
104
103
|
{
|
@@ -113,7 +112,6 @@ module Vedeu
|
|
113
112
|
|
114
113
|
# Returns all the options current configured.
|
115
114
|
#
|
116
|
-
# @api private
|
117
115
|
# @return [Hash]
|
118
116
|
def options
|
119
117
|
@options ||= defaults
|
@@ -122,7 +120,6 @@ module Vedeu
|
|
122
120
|
# The Vedeu default options, which of course are influenced by environment
|
123
121
|
# variables also.
|
124
122
|
#
|
125
|
-
# @api private
|
126
123
|
# @return [Hash]
|
127
124
|
def defaults
|
128
125
|
{
|
@@ -139,9 +136,7 @@ module Vedeu
|
|
139
136
|
# Attempt to determine the terminal colour mode via environment variables,
|
140
137
|
# or be optimistic and settle for 256 colours.
|
141
138
|
#
|
142
|
-
# @api private
|
143
139
|
# @return [Fixnum]
|
144
|
-
# :nocov:
|
145
140
|
def detect_colour_mode
|
146
141
|
return 16777216 if ENV['VEDEU_TESTMODE']
|
147
142
|
|
@@ -164,13 +159,10 @@ module Vedeu
|
|
164
159
|
|
165
160
|
end
|
166
161
|
end
|
167
|
-
# :nocov:
|
168
162
|
|
169
163
|
# Determine the debug mode via an environment variable.
|
170
164
|
#
|
171
|
-
# @api private
|
172
165
|
# @return [Boolean]
|
173
|
-
# :nocov:
|
174
166
|
def detect_debug_mode
|
175
167
|
return false if ENV['VEDEU_TESTMODE']
|
176
168
|
|
@@ -178,13 +170,10 @@ module Vedeu
|
|
178
170
|
|
179
171
|
false
|
180
172
|
end
|
181
|
-
# :nocov:
|
182
173
|
|
183
174
|
# Determine the trace mode via an environment variable.
|
184
175
|
#
|
185
|
-
# @api private
|
186
176
|
# @return [Boolean]
|
187
|
-
# :nocov:
|
188
177
|
def detect_trace_mode
|
189
178
|
return false if ENV['VEDEU_TESTMODE']
|
190
179
|
|
@@ -192,7 +181,6 @@ module Vedeu
|
|
192
181
|
|
193
182
|
false
|
194
183
|
end
|
195
|
-
# :nocov:
|
196
184
|
|
197
185
|
end # Configuration
|
198
186
|
|
data/lib/vedeu/input/input.rb
CHANGED
@@ -23,13 +23,11 @@ module Vedeu
|
|
23
23
|
|
24
24
|
private
|
25
25
|
|
26
|
-
# @api private
|
27
26
|
# @return [String]
|
28
27
|
def input
|
29
28
|
@_input ||= Terminal.input
|
30
29
|
end
|
31
30
|
|
32
|
-
# @api private
|
33
31
|
# @return [String|Symbol]
|
34
32
|
def keypress
|
35
33
|
key = input
|
@@ -40,7 +38,6 @@ module Vedeu
|
|
40
38
|
# Translates (if possible) entered escape sequences into symbols
|
41
39
|
# representing the key which was pressed.
|
42
40
|
#
|
43
|
-
# @api private
|
44
41
|
# @return [Hash]
|
45
42
|
def specials
|
46
43
|
{
|
data/lib/vedeu/launcher.rb
CHANGED
@@ -13,19 +13,16 @@ module Vedeu
|
|
13
13
|
# Valid names are: `:black`, `:red`, `:green`, `:yellow`, `:blue`,
|
14
14
|
# `:magenta`, `:cyan`, `:white` and `:default`.
|
15
15
|
#
|
16
|
-
# @api private
|
17
16
|
# @return [String]
|
18
17
|
def named
|
19
18
|
["\e[", background_codes[colour], 'm'].join
|
20
19
|
end
|
21
20
|
|
22
|
-
# @api private
|
23
21
|
# @return [String]
|
24
22
|
def numbered
|
25
23
|
["\e[48;5;", css_to_numbered, 'm'].join
|
26
24
|
end
|
27
25
|
|
28
|
-
# @api private
|
29
26
|
# @return [String]
|
30
27
|
def rgb
|
31
28
|
if Configuration.colour_mode == 16777216
|
@@ -40,7 +37,6 @@ module Vedeu
|
|
40
37
|
# Produces the background named colour escape sequence hash from the
|
41
38
|
# foreground escape sequence hash.
|
42
39
|
#
|
43
|
-
# @api private
|
44
40
|
# @return [Hash]
|
45
41
|
def background_codes
|
46
42
|
codes.inject({}){ |h, (k, v)| h.merge(k => v + 10) }
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# A Char represents a single character of the terminal. It is a container for
|
4
|
+
# the a single character in a {Vedeu::Stream}.
|
5
|
+
#
|
6
|
+
# @note The parent of a Char is a Line.
|
7
|
+
# @todo Colour and style is not being correctly reset. (GL 2014-10-19)
|
8
|
+
#
|
9
|
+
# @api private
|
10
|
+
class Char
|
11
|
+
|
12
|
+
include Presentation
|
13
|
+
|
14
|
+
attr_reader :attributes, :parent, :value
|
15
|
+
alias_method :data, :value
|
16
|
+
|
17
|
+
# Returns a new instance of Char.
|
18
|
+
#
|
19
|
+
# @param attributes [Hash]
|
20
|
+
# @return [Char]
|
21
|
+
def initialize(attributes = {})
|
22
|
+
@attributes = defaults.merge!(attributes)
|
23
|
+
@parent = @attributes[:parent]
|
24
|
+
@value = @attributes[:value]
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
# The default values for a new instance of Char.
|
30
|
+
#
|
31
|
+
# @return [Hash]
|
32
|
+
def defaults
|
33
|
+
{
|
34
|
+
colour: {},
|
35
|
+
parent: nil,
|
36
|
+
style: [],
|
37
|
+
value: '',
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
end # Char
|
42
|
+
|
43
|
+
end # Vedeu
|
data/lib/vedeu/models/colour.rb
CHANGED
@@ -50,7 +50,6 @@ module Vedeu
|
|
50
50
|
|
51
51
|
# The default values for a new instance of Composition.
|
52
52
|
#
|
53
|
-
# @api private
|
54
53
|
# @return [Hash]
|
55
54
|
def defaults
|
56
55
|
{
|
@@ -58,12 +57,14 @@ module Vedeu
|
|
58
57
|
}
|
59
58
|
end
|
60
59
|
|
61
|
-
# @
|
60
|
+
# @param method [Symbol] The name of the method sought.
|
61
|
+
# @param args [Array] The arguments which the method was to be invoked with.
|
62
|
+
# @param block [Proc] The optional block provided to the method.
|
62
63
|
# @return []
|
63
64
|
def method_missing(method, *args, &block)
|
64
65
|
Vedeu.log("Composition#method_missing '#{method.to_s}' (args: #{args.inspect})")
|
65
66
|
|
66
|
-
@self_before_instance_eval.send(method, *args, &block)
|
67
|
+
@self_before_instance_eval.send(method, *args, &block) if @self_before_instance_eval
|
67
68
|
end
|
68
69
|
|
69
70
|
end # Composition
|