vedeu 0.6.53 → 0.6.54
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/events/system.md +1 -1
- data/lib/vedeu/borders/border.rb +7 -3
- data/lib/vedeu/buffers/refresh.rb +1 -1
- data/lib/vedeu/buffers/view.rb +16 -0
- data/lib/vedeu/colours/colour.rb +5 -2
- data/lib/vedeu/configuration/api.rb +21 -2
- data/lib/vedeu/configuration/configuration.rb +8 -8
- data/lib/vedeu/cursors/cursor.rb +7 -4
- data/lib/vedeu/distributed/test_application.rb +1 -1
- data/lib/vedeu/dsl/composition.rb +4 -4
- data/lib/vedeu/dsl/presentation.rb +2 -1
- data/lib/vedeu/dsl/stream.rb +1 -1
- data/lib/vedeu/dsl/text.rb +1 -1
- data/lib/vedeu/editor/capture.rb +4 -16
- data/lib/vedeu/editor/cursor.rb +1 -1
- data/lib/vedeu/editor/document.rb +2 -1
- data/lib/vedeu/events/event.rb +4 -4
- data/lib/vedeu/geometry/area.rb +1 -1
- data/lib/vedeu/geometry/coordinate.rb +2 -2
- data/lib/vedeu/geometry/geometry.rb +12 -4
- data/lib/vedeu/groups/group.rb +4 -2
- data/lib/vedeu/input/all.rb +1 -1
- data/lib/vedeu/input/keymap.rb +4 -3
- data/lib/vedeu/input/{keymaps.rb → repository.rb} +4 -4
- data/lib/vedeu/logging/clock_time.rb +5 -6
- data/lib/vedeu/runtime/application.rb +5 -7
- data/lib/vedeu/runtime/main_loop.rb +15 -6
- data/lib/vedeu/terminal/mode.rb +39 -10
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/input/{keymaps_test.rb → repository_test.rb} +3 -3
- data/test/lib/vedeu/terminal/mode_test.rb +45 -19
- data/test/support/examples/material_colours_app.rb +4 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9ec93e874a9c70bde34345200a2bb628af03e63
|
4
|
+
data.tar.gz: 1a5e51d11cdbaff802b4169f4a6cd3f854a84898
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43e8380fb175c457417c1fa586a0d0ae91d468118179d7965f2280544cfa0710858991de19c6cb34c14b192dd4959cb4da69fdaed462261b8011542cbf4629a9
|
7
|
+
data.tar.gz: 8315f1aca1e347d7c0de04ba0be011d42e4f1000c835e09efdf2fceed71aa6eecb42511002c45f9714cd5023b257a2d7aef6d98d6aade1fd81b0bc2702b27430
|
data/docs/events/system.md
CHANGED
data/lib/vedeu/borders/border.rb
CHANGED
@@ -109,7 +109,9 @@ module Vedeu
|
|
109
109
|
|
110
110
|
# Returns a new instance of Vedeu::Borders::Border.
|
111
111
|
#
|
112
|
-
# @param attributes [Hash
|
112
|
+
# @param attributes [Hash<Symbol => Boolean|Hash|NilClass|
|
113
|
+
# String|Symbol|Vedeu::Borders::Repository|
|
114
|
+
# Vedeu::Presentation::Style>]
|
113
115
|
# @option attributes bottom_left [String] The bottom left border
|
114
116
|
# character.
|
115
117
|
# @option attributes bottom_right [String] The bottom right
|
@@ -147,7 +149,8 @@ module Vedeu
|
|
147
149
|
end
|
148
150
|
end
|
149
151
|
|
150
|
-
# @return [Hash
|
152
|
+
# @return [Hash<Symbol => Boolean|Hash|NilClass|String|Symbol|
|
153
|
+
# Vedeu::Borders::Repository|Vedeu::Presentation::Style>]
|
151
154
|
def attributes
|
152
155
|
{
|
153
156
|
bottom_left: @bottom_left,
|
@@ -265,7 +268,8 @@ module Vedeu
|
|
265
268
|
|
266
269
|
# The default values for a new instance of this class.
|
267
270
|
#
|
268
|
-
# @return [Hash
|
271
|
+
# @return [Hash<Symbol => Boolean|Hash|NilClass|String|Symbol|
|
272
|
+
# Vedeu::Borders::Repository|Vedeu::Presentation::Style>]
|
269
273
|
# @see Vedeu::EscapeSequences::Borders
|
270
274
|
def defaults
|
271
275
|
{
|
@@ -34,7 +34,7 @@ module Vedeu
|
|
34
34
|
#
|
35
35
|
# @param name [String|Symbol] The name of the interface/view to
|
36
36
|
# be refreshed. Defaults to `Vedeu.focus`.
|
37
|
-
# @param options [Hash]
|
37
|
+
# @param options [Hash<Symbol => Boolean>]
|
38
38
|
# @option options content_only [Boolean]
|
39
39
|
# @return [Vedeu::Buffers::Refresh]
|
40
40
|
def initialize(name, options = {})
|
data/lib/vedeu/buffers/view.rb
CHANGED
@@ -2,8 +2,17 @@ module Vedeu
|
|
2
2
|
|
3
3
|
module Buffers
|
4
4
|
|
5
|
+
# Allow the creation of individual named buffers for views.
|
6
|
+
#
|
7
|
+
# @api private
|
8
|
+
#
|
5
9
|
class View
|
6
10
|
|
11
|
+
# Returns a new instance of Vedeu::Buffers::View.
|
12
|
+
#
|
13
|
+
# @param attributes [Hash<Symbol => NilClass|String|Symbol]
|
14
|
+
# @option attributes name [NilClass|String|Symbol]
|
15
|
+
# @return [Vedeu::Buffers::View]
|
7
16
|
def initialize(attributes = {})
|
8
17
|
defaults.merge!(attributes).each do |key, value|
|
9
18
|
instance_variable_set("@#{key}", value || defaults.fetch(key))
|
@@ -12,34 +21,41 @@ module Vedeu
|
|
12
21
|
|
13
22
|
private
|
14
23
|
|
24
|
+
# @return [Vedeu::Borders::Border]
|
15
25
|
def border
|
16
26
|
Vedeu.borders.by_name(name)
|
17
27
|
end
|
18
28
|
|
29
|
+
# @return [Vedeu::Buffers::Empty]
|
19
30
|
def buffer
|
20
31
|
@_buffer ||= Vedeu::Buffers::Empty.new(height: border.height,
|
21
32
|
name: name,
|
22
33
|
width: border.width).buffer
|
23
34
|
end
|
24
35
|
|
36
|
+
# @return [Vedeu::Buffers::Empty]
|
25
37
|
def current
|
26
38
|
@current ||= buffer
|
27
39
|
end
|
28
40
|
|
41
|
+
# @return [Vedeu::Buffers::Empty]
|
29
42
|
def current_reset!
|
30
43
|
@current = buffer
|
31
44
|
end
|
32
45
|
|
46
|
+
# @return [Hash<Symbol => NilClass|String|Symbol]
|
33
47
|
def defaults
|
34
48
|
{
|
35
49
|
name: ''
|
36
50
|
}
|
37
51
|
end
|
38
52
|
|
53
|
+
# @return [Vedeu::Buffers::Empty]
|
39
54
|
def dirty
|
40
55
|
@dirty ||= buffer
|
41
56
|
end
|
42
57
|
|
58
|
+
# @return [Vedeu::Buffers::Empty]
|
43
59
|
def dirty_reset!
|
44
60
|
@dirty = buffer
|
45
61
|
end
|
data/lib/vedeu/colours/colour.rb
CHANGED
@@ -65,7 +65,8 @@ module Vedeu
|
|
65
65
|
|
66
66
|
# Returns a new instance of Vedeu::Colours::Colour.
|
67
67
|
#
|
68
|
-
# @param attributes [Hash
|
68
|
+
# @param attributes [Hash<Symbol => String|
|
69
|
+
# Vedeu::Colours::Background|Vedeu::Colours:Foreground>]
|
69
70
|
# @option attributes background [String]
|
70
71
|
# @option attributes foreground [String]
|
71
72
|
# @return [Vedeu::Colours::Colour]
|
@@ -131,10 +132,12 @@ module Vedeu
|
|
131
132
|
|
132
133
|
private
|
133
134
|
|
135
|
+
# @return [Hash<Symbol => Vedeu::Colours::Background|
|
136
|
+
# Vedeu::Colours:Foreground]
|
134
137
|
def defaults
|
135
138
|
{
|
136
139
|
background: Vedeu::Colours::Background.new,
|
137
|
-
foreground: Vedeu::Colours::Foreground.new
|
140
|
+
foreground: Vedeu::Colours::Foreground.new,
|
138
141
|
}
|
139
142
|
end
|
140
143
|
|
@@ -275,6 +275,11 @@ module Vedeu
|
|
275
275
|
#
|
276
276
|
# Vedeu.configure do
|
277
277
|
# height 25
|
278
|
+
#
|
279
|
+
# # or...
|
280
|
+
#
|
281
|
+
# height = 25
|
282
|
+
#
|
278
283
|
# # ...
|
279
284
|
# end
|
280
285
|
#
|
@@ -283,6 +288,7 @@ module Vedeu
|
|
283
288
|
def height(height = 25)
|
284
289
|
options[:height] = height
|
285
290
|
end
|
291
|
+
alias_method :height=, :height
|
286
292
|
|
287
293
|
# Sets the location of the log file.
|
288
294
|
#
|
@@ -478,6 +484,12 @@ module Vedeu
|
|
478
484
|
#
|
479
485
|
# terminal_mode :raw
|
480
486
|
#
|
487
|
+
# # or...
|
488
|
+
#
|
489
|
+
# terminal_mode = :raw
|
490
|
+
# terminal_mode = :fake
|
491
|
+
# terminal_mode = :cooked
|
492
|
+
#
|
481
493
|
# # ... some code
|
482
494
|
# end
|
483
495
|
#
|
@@ -493,11 +505,17 @@ module Vedeu
|
|
493
505
|
|
494
506
|
options[:terminal_mode] = mode
|
495
507
|
end
|
508
|
+
alias_method :terminal_mode=, :terminal_mode
|
496
509
|
|
497
510
|
# Sets the width of the terminal.
|
498
511
|
#
|
499
512
|
# Vedeu.configure do
|
500
513
|
# width 80
|
514
|
+
#
|
515
|
+
# # or...
|
516
|
+
#
|
517
|
+
# width = 80
|
518
|
+
#
|
501
519
|
# # ...
|
502
520
|
# end
|
503
521
|
#
|
@@ -506,6 +524,7 @@ module Vedeu
|
|
506
524
|
def width(width = 80)
|
507
525
|
options[:width] = width
|
508
526
|
end
|
527
|
+
alias_method :width=, :width
|
509
528
|
|
510
529
|
# Sets the background of the terminal.
|
511
530
|
#
|
@@ -551,7 +570,7 @@ module Vedeu
|
|
551
570
|
# end
|
552
571
|
#
|
553
572
|
# @param attrs [Hash<Symbol => String>]
|
554
|
-
# @return [Hash]
|
573
|
+
# @return [Hash<Symbol => void>]
|
555
574
|
def colour(attrs = {})
|
556
575
|
options[:background] = background(attrs[:background])
|
557
576
|
options[:foreground] = foreground(attrs[:foreground])
|
@@ -600,7 +619,7 @@ module Vedeu
|
|
600
619
|
# Returns the options set via the configuration API DSL or an
|
601
620
|
# empty Hash when none were set.
|
602
621
|
#
|
603
|
-
# @return [Hash]
|
622
|
+
# @return [Hash<Symbol => void>]
|
604
623
|
def options
|
605
624
|
@options ||= {}
|
606
625
|
end
|
@@ -9,8 +9,8 @@ module Vedeu
|
|
9
9
|
# Custom log for configuration.
|
10
10
|
#
|
11
11
|
# @param from [String] Which configuration set the options.
|
12
|
-
# @param options [Hash] The configuration options set.
|
13
|
-
# @return [Hash] The options param.
|
12
|
+
# @param options [Hash<Symbol => void>] The configuration options set.
|
13
|
+
# @return [Hash<Symbol => void>] The options param.
|
14
14
|
def log(from, options)
|
15
15
|
options.each do |option, value|
|
16
16
|
Vedeu.log(type: :config,
|
@@ -65,14 +65,14 @@ module Vedeu
|
|
65
65
|
# # ...
|
66
66
|
# end
|
67
67
|
#
|
68
|
-
# @param opts [Hash]
|
68
|
+
# @param opts [Hash<Symbol => void>]
|
69
69
|
# @option opts stdin [File|IO]
|
70
70
|
# @option opts stdout [File|IO]
|
71
71
|
# @option opts stderr [File|IO]
|
72
72
|
# @param block [Proc]
|
73
73
|
# @raise [Vedeu::Error::InvalidSyntax]
|
74
74
|
# When the required block is not given.
|
75
|
-
# @return [Hash]
|
75
|
+
# @return [Hash<Symbol => void>]
|
76
76
|
def configure(opts = {}, &block)
|
77
77
|
instance.configure(opts, &block)
|
78
78
|
end
|
@@ -281,7 +281,7 @@ module Vedeu
|
|
281
281
|
|
282
282
|
# Reset the configuration to the default values.
|
283
283
|
#
|
284
|
-
# @return [Hash]
|
284
|
+
# @return [Hash<Symbol => void>]
|
285
285
|
def reset!
|
286
286
|
instance.reset!
|
287
287
|
end
|
@@ -289,7 +289,7 @@ module Vedeu
|
|
289
289
|
end # Eigenclass
|
290
290
|
|
291
291
|
# @!attribute [r] options
|
292
|
-
# @return [Hash]
|
292
|
+
# @return [Hash<Symbol => void>]
|
293
293
|
attr_reader :options
|
294
294
|
|
295
295
|
# Create a new singleton instance of Vedeu::Configuration.
|
@@ -303,7 +303,7 @@ module Vedeu
|
|
303
303
|
# application to modify it via the configuration API.
|
304
304
|
#
|
305
305
|
# @param block [Proc]
|
306
|
-
# @return [Hash]
|
306
|
+
# @return [Hash<Symbol => void>]
|
307
307
|
def configure(opts = {}, &block)
|
308
308
|
@options.merge!(opts)
|
309
309
|
|
@@ -316,7 +316,7 @@ module Vedeu
|
|
316
316
|
|
317
317
|
# Reset the configuration to the default values.
|
318
318
|
#
|
319
|
-
# @return [Hash]
|
319
|
+
# @return [Hash<Symbol => void>]
|
320
320
|
def reset!
|
321
321
|
@options = defaults
|
322
322
|
end
|
data/lib/vedeu/cursors/cursor.rb
CHANGED
@@ -47,7 +47,8 @@ module Vedeu
|
|
47
47
|
|
48
48
|
# Returns a new instance of Vedeu::Cursors::Cursor.
|
49
49
|
#
|
50
|
-
# @
|
50
|
+
# @params attributes [Hash<Symbol => Boolean|Fixnum|String|
|
51
|
+
# Vedeu::Cursors::Repository>]
|
51
52
|
# @option attributes name [String|Symbol] The name of the
|
52
53
|
# interface this cursor belongs to.
|
53
54
|
# @option attributes ox [Fixnum] The offset x coordinate.
|
@@ -67,7 +68,8 @@ module Vedeu
|
|
67
68
|
end
|
68
69
|
end
|
69
70
|
|
70
|
-
# @return [Hash
|
71
|
+
# @return [Hash<Symbol => Boolean|Fixnum|String|
|
72
|
+
# Vedeu::Cursors::Repository>]
|
71
73
|
def attributes
|
72
74
|
{
|
73
75
|
name: @name,
|
@@ -267,7 +269,8 @@ module Vedeu
|
|
267
269
|
|
268
270
|
# The default values for a new instance of this class.
|
269
271
|
#
|
270
|
-
# @return [Hash
|
272
|
+
# @return [Hash<Symbol => Boolean|Fixnum|String|
|
273
|
+
# Vedeu::Cursors::Repository>]
|
271
274
|
def defaults
|
272
275
|
{
|
273
276
|
name: '',
|
@@ -285,7 +288,7 @@ module Vedeu
|
|
285
288
|
Vedeu::Models::Escape.new(position: position, value: visibility)
|
286
289
|
end
|
287
290
|
|
288
|
-
# @return [Hash]
|
291
|
+
# @return [Hash<Symbol => Fixnum>]
|
289
292
|
def new_attributes(new_y = y, new_x = x, new_oy = oy, new_ox = ox)
|
290
293
|
attributes.merge!(x: new_x, y: new_y, ox: new_ox, oy: new_oy)
|
291
294
|
end
|
@@ -89,7 +89,7 @@ module Vedeu
|
|
89
89
|
# use relative paths.
|
90
90
|
# @param object [Object] The object for which the values of
|
91
91
|
# template's variables can be obtained.
|
92
|
-
# @param options [Hash] See {Vedeu::Output::Wordwrap}
|
92
|
+
# @param options [Hash<Symbol => void>] See {Vedeu::Output::Wordwrap}
|
93
93
|
# @raise [Vedeu::Error::MissingRequired]
|
94
94
|
# @return [Vedeu::Views::Views<Vedeu::Views::View>]
|
95
95
|
def template_for(name, filename, object = nil, options = {})
|
@@ -116,7 +116,7 @@ module Vedeu
|
|
116
116
|
|
117
117
|
# @param name [String|Symbol]
|
118
118
|
# @param lines [Vedeu::Views::Lines]
|
119
|
-
# @return [Hash]
|
119
|
+
# @return [Hash<Symbol => void>]
|
120
120
|
def template_attributes(name, lines)
|
121
121
|
new_attributes(name).merge!(value: lines)
|
122
122
|
end
|
@@ -125,7 +125,7 @@ module Vedeu
|
|
125
125
|
# interface attributes defined by the interface.
|
126
126
|
#
|
127
127
|
# @param name [String|Symbol] The name of the interface.
|
128
|
-
# @return [Hash]
|
128
|
+
# @return [Hash<Symbol => void>]
|
129
129
|
def new_attributes(name)
|
130
130
|
existing_attributes(name).merge!(attributes)
|
131
131
|
end
|
@@ -133,7 +133,7 @@ module Vedeu
|
|
133
133
|
# Retrieve the attributes of the interface by name.
|
134
134
|
#
|
135
135
|
# @param name [String|Symbol] The name of the interface.
|
136
|
-
# @return [Hash]
|
136
|
+
# @return [Hash<Symbol => void>]
|
137
137
|
def existing_attributes(name)
|
138
138
|
Vedeu.interfaces.by_name(name).attributes
|
139
139
|
end
|
@@ -66,7 +66,8 @@ module Vedeu
|
|
66
66
|
# stream overrides previously defined entries in the same
|
67
67
|
# block.
|
68
68
|
#
|
69
|
-
# @param attrs [Hash
|
69
|
+
# @param attrs [Hash<Symbol => void>]
|
70
|
+
# See {Vedeu::Colours::Colour}
|
70
71
|
#
|
71
72
|
# @example
|
72
73
|
# interface 'my_interface' do
|
data/lib/vedeu/dsl/stream.rb
CHANGED
data/lib/vedeu/dsl/text.rb
CHANGED
@@ -50,7 +50,7 @@ module Vedeu
|
|
50
50
|
#
|
51
51
|
# @param value [String|Object] A string or object that responds
|
52
52
|
# to `to_s`.
|
53
|
-
# @param options [Hash] Text options.
|
53
|
+
# @param options [Hash<Symbol => void>] Text options.
|
54
54
|
# @option options :anchor [Symbol] One of `:left`,
|
55
55
|
# `:centre`/`:center`, or `:right`.
|
56
56
|
# @option options :width [Integer|NilClass] The width of the
|
data/lib/vedeu/editor/capture.rb
CHANGED
@@ -34,22 +34,10 @@ module Vedeu
|
|
34
34
|
keys = console.getch
|
35
35
|
|
36
36
|
if keys.ord == ESCAPE_KEY_CODE
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
rescue IO::WaitReadable
|
43
|
-
IO.select([console])
|
44
|
-
@chars -= 1
|
45
|
-
retry
|
46
|
-
|
47
|
-
rescue IO::WaitWritable
|
48
|
-
IO.select(nil, [console])
|
49
|
-
@chars -= 1
|
50
|
-
retry
|
51
|
-
|
52
|
-
end
|
37
|
+
keys << console.read_nonblock(5) rescue nil
|
38
|
+
keys << console.read_nonblock(4) rescue nil
|
39
|
+
keys << console.read_nonblock(3) rescue nil
|
40
|
+
keys << console.read_nonblock(2) rescue nil
|
53
41
|
end
|
54
42
|
|
55
43
|
return Vedeu::Input::Mouse.click(keys) if click?(keys)
|
data/lib/vedeu/editor/cursor.rb
CHANGED
@@ -39,7 +39,7 @@ module Vedeu
|
|
39
39
|
|
40
40
|
# Returns a new instance of Vedeu::Editor::Cursor.
|
41
41
|
#
|
42
|
-
# @param attributes [Hash]
|
42
|
+
# @param attributes [Hash<Symbol => Fixnum|String|Symbol>]
|
43
43
|
# @option attributes y [Fixnum] The current line.
|
44
44
|
# @option attributes x [Fixnum] The current character with the
|
45
45
|
# line.
|
@@ -44,7 +44,8 @@ module Vedeu
|
|
44
44
|
# parameter, then it is added with the respective value from
|
45
45
|
# #defaults.
|
46
46
|
#
|
47
|
-
# @param attributes [Hash
|
47
|
+
# @param attributes [Hash<Symbol => String|Symbol|
|
48
|
+
# Vedeu::Repositories::Repository>]
|
48
49
|
# @option attributes data [String]
|
49
50
|
# @option attributes name [String|Symbol]
|
50
51
|
# @option attributes repository
|
data/lib/vedeu/events/event.rb
CHANGED
@@ -41,8 +41,8 @@ module Vedeu
|
|
41
41
|
#
|
42
42
|
# @param name [Symbol] The name of the event to be triggered
|
43
43
|
# later.
|
44
|
-
# @param options [Hash] The options to
|
45
|
-
# with.
|
44
|
+
# @param options [Hash<Symbol => void>] The options to
|
45
|
+
# register the event with.
|
46
46
|
# @option options :delay [Fixnum|Float] Limits the execution
|
47
47
|
# of the triggered event to only execute when first
|
48
48
|
# triggered, with subsequent triggering being ignored until
|
@@ -281,14 +281,14 @@ module Vedeu
|
|
281
281
|
# Combines the options provided at instantiation with the
|
282
282
|
# default values.
|
283
283
|
#
|
284
|
-
# @return [Hash]
|
284
|
+
# @return [Hash<Symbol => void>]
|
285
285
|
def options
|
286
286
|
defaults.merge!(@options)
|
287
287
|
end
|
288
288
|
|
289
289
|
# The default values for a new instance of this class.
|
290
290
|
#
|
291
|
-
# @return [Hash]
|
291
|
+
# @return [Hash<Symbol => void>]
|
292
292
|
def defaults
|
293
293
|
{
|
294
294
|
delay: 0.0,
|
data/lib/vedeu/geometry/area.rb
CHANGED
@@ -32,7 +32,7 @@ module Vedeu
|
|
32
32
|
attr_reader :xn
|
33
33
|
alias_method :right, :xn
|
34
34
|
|
35
|
-
# @param attributes [Hash]
|
35
|
+
# @param attributes [Hash<Symbol => Boolean|Fixnum|Symbol>]
|
36
36
|
# @option attributes y [Fixnum]
|
37
37
|
# @option attributes yn [Fixnum]
|
38
38
|
# @option attributes y_yn [Fixnum]
|
@@ -10,7 +10,7 @@ module Vedeu
|
|
10
10
|
|
11
11
|
# Return a new instance of Vedeu::Geometry::Coordinate.
|
12
12
|
#
|
13
|
-
# @param attributes [Hash]
|
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]
|
@@ -161,7 +161,7 @@ module Vedeu
|
|
161
161
|
|
162
162
|
# The default values for a new instance of this class.
|
163
163
|
#
|
164
|
-
# @return [Hash]
|
164
|
+
# @return [Hash<Symbol => Fixnum|String|Symbol>]
|
165
165
|
def defaults
|
166
166
|
{
|
167
167
|
name: '',
|
@@ -84,7 +84,8 @@ module Vedeu
|
|
84
84
|
|
85
85
|
# Returns a new instance of Vedeu::Geometry::Geometry.
|
86
86
|
#
|
87
|
-
# @param attributes [Hash
|
87
|
+
# @param attributes [Hash<Symbol => Boolean|Fixnum|String|
|
88
|
+
# Symbol|Vedeu::Geometry::Repository]
|
88
89
|
# @option attributes horizontal_alignment [Symbol]
|
89
90
|
# @option attributes vertical_alignment [Symbol]
|
90
91
|
# @option attributes maximised [Boolean]
|
@@ -103,7 +104,8 @@ module Vedeu
|
|
103
104
|
end
|
104
105
|
end
|
105
106
|
|
106
|
-
# @return [Hash
|
107
|
+
# @return [Hash<Symbol => Boolean|Fixnum|String|Symbol|
|
108
|
+
# Vedeu::Geometry::Repository]
|
107
109
|
def attributes
|
108
110
|
{
|
109
111
|
client: @client,
|
@@ -238,7 +240,7 @@ module Vedeu
|
|
238
240
|
@area = Vedeu::Geometry::Area.from_attributes(area_attributes)
|
239
241
|
end
|
240
242
|
|
241
|
-
# @return [Hash<Symbol => Boolean
|
243
|
+
# @return [Hash<Symbol => Boolean|Fixnum>]
|
242
244
|
def area_attributes
|
243
245
|
{
|
244
246
|
horizontal_alignment: @horizontal_alignment,
|
@@ -253,6 +255,11 @@ module Vedeu
|
|
253
255
|
}
|
254
256
|
end
|
255
257
|
|
258
|
+
# @return [Vedeu::Borders::Border]
|
259
|
+
def border
|
260
|
+
@border = Vedeu.borders.by_name(name)
|
261
|
+
end
|
262
|
+
|
256
263
|
# When moving an interface;
|
257
264
|
# 1) Reset the alignment and maximised states to false;
|
258
265
|
# it wont be aligned to a side if moved, and cannot be moved
|
@@ -281,7 +288,8 @@ module Vedeu
|
|
281
288
|
|
282
289
|
# Returns the default options/attributes for this class.
|
283
290
|
#
|
284
|
-
# @return [Hash
|
291
|
+
# @return [Hash<Symbol => Boolean|Fixnum|NilClass|String|Symbol|
|
292
|
+
# Vedeu::Geometry::Repository]
|
285
293
|
def defaults
|
286
294
|
{
|
287
295
|
client: nil,
|
data/lib/vedeu/groups/group.rb
CHANGED
@@ -26,7 +26,8 @@ module Vedeu
|
|
26
26
|
# A group being visible or not may not necessarily mean the
|
27
27
|
# members are of the same state.
|
28
28
|
#
|
29
|
-
# @param attributes [Hash
|
29
|
+
# @param attributes [Hash<Symbol => Boolean|Set|String|
|
30
|
+
# Vedeu::Groups::Repository]
|
30
31
|
# @option attributes members [Set] A collection of names of
|
31
32
|
# interfaces belonging to this group.
|
32
33
|
# @option attributes name [String|Symbol] The name of the group.
|
@@ -162,7 +163,8 @@ module Vedeu
|
|
162
163
|
|
163
164
|
# Returns the default options/attributes for this class.
|
164
165
|
#
|
165
|
-
# @return [Hash
|
166
|
+
# @return [Hash<Symbol => Boolean|Set|String|
|
167
|
+
# Vedeu::Groups::Repository]
|
166
168
|
def defaults
|
167
169
|
{
|
168
170
|
members: Set.new,
|
data/lib/vedeu/input/all.rb
CHANGED
@@ -13,8 +13,8 @@ require 'vedeu/input/capture'
|
|
13
13
|
require 'vedeu/input/dsl'
|
14
14
|
require 'vedeu/input/key'
|
15
15
|
require 'vedeu/input/keymap'
|
16
|
-
require 'vedeu/input/keymaps'
|
17
16
|
require 'vedeu/input/mapper'
|
18
17
|
require 'vedeu/input/mouse'
|
18
|
+
require 'vedeu/input/repository'
|
19
19
|
require 'vedeu/input/store'
|
20
20
|
require 'vedeu/input/translator'
|
data/lib/vedeu/input/keymap.rb
CHANGED
@@ -18,7 +18,8 @@ module Vedeu
|
|
18
18
|
|
19
19
|
# Returns a new instance of Vedeu::Input::Keymap.
|
20
20
|
#
|
21
|
-
# @param attributes [Hash
|
21
|
+
# @param attributes [Hash<Symbol => Array|String|Symbol|
|
22
|
+
# Vedeu::Input::Keys|Vedeu::Repositories::Repository>]
|
22
23
|
# @option attributes name [String|Symbol] The name of the
|
23
24
|
# keymap.
|
24
25
|
# @option attributes keys [Vedeu::Input::Keys|Array]
|
@@ -89,12 +90,12 @@ module Vedeu
|
|
89
90
|
|
90
91
|
# Returns the default options/attributes for this class.
|
91
92
|
#
|
92
|
-
# @return [Hash]
|
93
|
+
# @return [Hash<Symbol => Array|String|Vedeu::Input::Repository]
|
93
94
|
def defaults
|
94
95
|
{
|
95
96
|
name: '',
|
96
97
|
keys: [],
|
97
|
-
repository: Vedeu::Input::
|
98
|
+
repository: Vedeu::Input::Repository.keymaps,
|
98
99
|
}
|
99
100
|
end
|
100
101
|
|
@@ -4,13 +4,13 @@ module Vedeu
|
|
4
4
|
|
5
5
|
# Allows the storing of keymaps.
|
6
6
|
#
|
7
|
-
class
|
7
|
+
class Repository < Vedeu::Repositories::Repository
|
8
8
|
|
9
9
|
singleton_class.send(:alias_method, :keymaps, :repository)
|
10
10
|
|
11
11
|
real Vedeu::Input::Keymap
|
12
12
|
|
13
|
-
end #
|
13
|
+
end # Repository
|
14
14
|
|
15
15
|
end # Input
|
16
16
|
|
@@ -20,8 +20,8 @@ module Vedeu
|
|
20
20
|
# Vedeu.keymaps
|
21
21
|
#
|
22
22
|
# @!method keymaps
|
23
|
-
# @return [Vedeu::Input::
|
24
|
-
def_delegators Vedeu::Input::
|
23
|
+
# @return [Vedeu::Input::Repository]
|
24
|
+
def_delegators Vedeu::Input::Repository,
|
25
25
|
:keymaps
|
26
26
|
|
27
27
|
end # Vedeu
|
@@ -10,16 +10,15 @@ module Vedeu
|
|
10
10
|
#
|
11
11
|
module ClockTime
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
# @return [Float|Time]
|
14
|
+
def self.clock_time
|
15
|
+
if defined?(Process::CLOCK_MONOTONIC)
|
15
16
|
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
16
|
-
end
|
17
17
|
|
18
|
-
|
19
|
-
def self.clock_time
|
18
|
+
else
|
20
19
|
Time.now
|
21
|
-
end
|
22
20
|
|
21
|
+
end
|
23
22
|
end
|
24
23
|
|
25
24
|
end # ClockTime
|
@@ -44,7 +44,7 @@ module Vedeu
|
|
44
44
|
#
|
45
45
|
# @param configuration [Vedeu::Configuration]
|
46
46
|
# @return [Vedeu::Runtime::Application]
|
47
|
-
def initialize(configuration)
|
47
|
+
def initialize(configuration = Vedeu::Configuration)
|
48
48
|
@configuration = configuration
|
49
49
|
end
|
50
50
|
|
@@ -120,11 +120,7 @@ module Vedeu
|
|
120
120
|
Vedeu::Runtime::MainLoop.start! { yield }
|
121
121
|
|
122
122
|
rescue Vedeu::Error::ModeSwitch
|
123
|
-
Vedeu::
|
124
|
-
|
125
|
-
Vedeu.trigger(:_drb_restart_)
|
126
|
-
|
127
|
-
Vedeu::Runtime::Application.restart(configuration)
|
123
|
+
Vedeu::Runtime::Application.restart(Vedeu::Configuration)
|
128
124
|
end
|
129
125
|
|
130
126
|
# :nocov:
|
@@ -144,7 +140,9 @@ module Vedeu
|
|
144
140
|
Vedeu.bind(:_exit_) { Vedeu.exit }
|
145
141
|
|
146
142
|
# See {file:docs/events/system.md#\_mode_switch_}
|
147
|
-
Vedeu.bind(:_mode_switch_)
|
143
|
+
Vedeu.bind(:_mode_switch_) do |mode|
|
144
|
+
Vedeu::Runtime::MainLoop.mode_switch!(mode)
|
145
|
+
end
|
148
146
|
|
149
147
|
# See {file:docs/events/system.md#\_cleanup_}
|
150
148
|
Vedeu.bind(:_cleanup_) do
|
@@ -14,13 +14,26 @@ module Vedeu
|
|
14
14
|
|
15
15
|
# :nocov:
|
16
16
|
|
17
|
+
# @param mode [Symbol]
|
18
|
+
def mode_switch!(mode = nil)
|
19
|
+
@loop = false
|
20
|
+
@mode_switch = true
|
21
|
+
|
22
|
+
Vedeu::Terminal::Mode.switch_mode!(mode)
|
23
|
+
|
24
|
+
Vedeu.trigger(:_drb_restart_)
|
25
|
+
|
26
|
+
fail Vedeu::Error::ModeSwitch
|
27
|
+
end
|
28
|
+
|
17
29
|
# Start the main loop.
|
18
30
|
#
|
19
31
|
# @return [void]
|
20
32
|
# @yieldreturn [void] The client application.
|
21
33
|
def start!
|
22
|
-
@started
|
23
|
-
@loop
|
34
|
+
@started = true
|
35
|
+
@loop = true
|
36
|
+
@mode_switch = false
|
24
37
|
|
25
38
|
Vedeu.trigger(:_refresh_cursor_, Vedeu.focus)
|
26
39
|
|
@@ -35,8 +48,6 @@ module Vedeu
|
|
35
48
|
Vedeu.log(message: 'Vedeu execution interrupted, exiting.'.freeze)
|
36
49
|
end
|
37
50
|
|
38
|
-
# :nocov:
|
39
|
-
|
40
51
|
# Signal that we wish to terminate the running application.
|
41
52
|
#
|
42
53
|
# @return [void]
|
@@ -44,8 +55,6 @@ module Vedeu
|
|
44
55
|
@loop = false
|
45
56
|
end
|
46
57
|
|
47
|
-
# :nocov:
|
48
|
-
|
49
58
|
# Check the application has started and we wish to continue
|
50
59
|
# running.
|
51
60
|
#
|
data/lib/vedeu/terminal/mode.rb
CHANGED
@@ -6,6 +6,7 @@ module Vedeu
|
|
6
6
|
#
|
7
7
|
module Mode
|
8
8
|
|
9
|
+
include Vedeu::Common
|
9
10
|
extend self
|
10
11
|
|
11
12
|
# Returns a boolean indicating whether the terminal is currently
|
@@ -20,7 +21,7 @@ module Vedeu
|
|
20
21
|
#
|
21
22
|
# @return [Symbol]
|
22
23
|
def cooked_mode!
|
23
|
-
|
24
|
+
switch_mode!(:cooked)
|
24
25
|
end
|
25
26
|
|
26
27
|
# Returns a boolean indicating whether the terminal is currently
|
@@ -35,7 +36,7 @@ module Vedeu
|
|
35
36
|
#
|
36
37
|
# @return [Symbol]
|
37
38
|
def fake_mode!
|
38
|
-
|
39
|
+
switch_mode!(:fake)
|
39
40
|
end
|
40
41
|
|
41
42
|
# Returns a boolean indicating whether the terminal is currently
|
@@ -50,18 +51,26 @@ module Vedeu
|
|
50
51
|
#
|
51
52
|
# @return [Symbol]
|
52
53
|
def raw_mode!
|
53
|
-
|
54
|
+
switch_mode!(:raw)
|
54
55
|
end
|
55
56
|
|
56
|
-
#
|
57
|
-
# `
|
57
|
+
# Changes the mode of the terminal to the mode given or toggles
|
58
|
+
# the terminal mode between `cooked`, `fake` and `raw`,
|
59
|
+
# depending on the current mode.
|
58
60
|
#
|
61
|
+
# @param mode [NilClass|Symbol]
|
59
62
|
# @return [Symbol]
|
60
|
-
def switch_mode!
|
61
|
-
|
62
|
-
|
63
|
+
def switch_mode!(mode = nil)
|
64
|
+
if present?(mode) && valid_mode?(mode)
|
65
|
+
Vedeu.configure { |config| config.terminal_mode = mode }
|
63
66
|
|
64
|
-
|
67
|
+
else
|
68
|
+
return fake_mode! if raw_mode?
|
69
|
+
return cooked_mode! if fake_mode?
|
70
|
+
|
71
|
+
raw_mode!
|
72
|
+
|
73
|
+
end
|
65
74
|
end
|
66
75
|
|
67
76
|
# Returns the mode of the terminal, either `:cooked`, `:fake` or
|
@@ -70,7 +79,27 @@ module Vedeu
|
|
70
79
|
#
|
71
80
|
# @return [Symbol]
|
72
81
|
def mode
|
73
|
-
@mode
|
82
|
+
@mode = Vedeu::Configuration.terminal_mode
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
# Returns a boolean indicating whether the given mode is valid.
|
88
|
+
#
|
89
|
+
# @param mode [Symbol] Should be one of the modes listed in
|
90
|
+
# {#valid_modes}.
|
91
|
+
# @return [Boolean]
|
92
|
+
def valid_mode?(mode)
|
93
|
+
valid_modes.include?(mode)
|
94
|
+
end
|
95
|
+
|
96
|
+
# @return [Array<Symbol>]
|
97
|
+
def valid_modes
|
98
|
+
[
|
99
|
+
:cooked,
|
100
|
+
:fake,
|
101
|
+
:raw,
|
102
|
+
]
|
74
103
|
end
|
75
104
|
|
76
105
|
end # Mode
|
data/lib/vedeu/version.rb
CHANGED
@@ -4,13 +4,13 @@ module Vedeu
|
|
4
4
|
|
5
5
|
module Input
|
6
6
|
|
7
|
-
describe
|
7
|
+
describe Repository do
|
8
8
|
|
9
|
-
let(:described) { Vedeu::Input::
|
9
|
+
let(:described) { Vedeu::Input::Repository }
|
10
10
|
|
11
11
|
it { described.must_respond_to(:keymaps) }
|
12
12
|
|
13
|
-
end #
|
13
|
+
end # Repository
|
14
14
|
|
15
15
|
end # Input
|
16
16
|
|
@@ -51,41 +51,67 @@ module Vedeu
|
|
51
51
|
end
|
52
52
|
|
53
53
|
describe '.switch_mode!' do
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
let(:mode) {}
|
55
|
+
|
56
|
+
subject { described.switch_mode!(mode) }
|
57
|
+
|
58
|
+
context 'when the mode is not given' do
|
59
|
+
it 'returns :fake if previously :raw' do
|
60
|
+
described.raw_mode!
|
61
|
+
subject
|
62
|
+
Vedeu::Configuration.terminal_mode.must_equal(:fake)
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'returns :cooked if previously :fake' do
|
66
|
+
described.fake_mode!
|
67
|
+
subject
|
68
|
+
Vedeu::Configuration.terminal_mode.must_equal(:cooked)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'returns :raw if previously :cooked' do
|
72
|
+
described.cooked_mode!
|
73
|
+
subject
|
74
|
+
Vedeu::Configuration.terminal_mode.must_equal(:raw)
|
75
|
+
end
|
58
76
|
end
|
59
77
|
|
60
|
-
|
61
|
-
|
62
|
-
subject.must_equal(:fake)
|
63
|
-
end
|
78
|
+
context 'when the mode is given' do
|
79
|
+
let(:mode) { :cooked }
|
64
80
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
81
|
+
it {
|
82
|
+
subject
|
83
|
+
Vedeu::Configuration.terminal_mode.must_equal(:cooked)
|
84
|
+
}
|
69
85
|
|
70
|
-
|
71
|
-
|
72
|
-
|
86
|
+
context 'when the mode given is not valid' do
|
87
|
+
let(:mode) { :invalid }
|
88
|
+
|
89
|
+
before { described.cooked_mode! }
|
90
|
+
|
91
|
+
it {
|
92
|
+
subject
|
93
|
+
Vedeu::Configuration.terminal_mode.must_equal(:raw)
|
94
|
+
}
|
95
|
+
end
|
73
96
|
end
|
74
97
|
end
|
75
98
|
|
76
99
|
describe '.mode' do
|
77
100
|
subject { described.mode }
|
78
101
|
|
79
|
-
before
|
80
|
-
described.raw_mode!
|
81
|
-
Vedeu::Configuration.stubs(:terminal_mode).returns(:raw)
|
82
|
-
end
|
102
|
+
before { described.raw_mode! }
|
83
103
|
|
84
104
|
it { subject.must_be_instance_of(Symbol) }
|
85
105
|
|
86
106
|
it 'returns the configured terminal mode' do
|
87
107
|
subject.must_equal(:raw)
|
88
108
|
end
|
109
|
+
|
110
|
+
context 'when the mode has been changed' do
|
111
|
+
before { described.fake_mode! }
|
112
|
+
|
113
|
+
it { subject.must_equal(:fake) }
|
114
|
+
end
|
89
115
|
end
|
90
116
|
|
91
117
|
end # Mode
|
@@ -120,7 +120,10 @@ class VedeuMaterialColoursApp
|
|
120
120
|
end
|
121
121
|
|
122
122
|
key('q') { Vedeu.trigger(:_exit_) }
|
123
|
-
key(:escape) { Vedeu.trigger(:_mode_switch_) }
|
123
|
+
# key(:escape) { Vedeu.trigger(:_mode_switch_, :fake) }
|
124
|
+
key(:f1) { Vedeu.trigger(:_mode_switch_, :fake) }
|
125
|
+
key(:f2) { Vedeu.trigger(:_mode_switch_, :raw) }
|
126
|
+
key(:f3) { Vedeu.trigger(:_mode_switch_, :cooked) }
|
124
127
|
key(:shift_tab) { Vedeu.trigger(:_focus_prev_) }
|
125
128
|
key(:tab) { Vedeu.trigger(:_focus_next_) }
|
126
129
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vedeu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.54
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Laking
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|
@@ -436,9 +436,9 @@ files:
|
|
436
436
|
- lib/vedeu/input/dsl.rb
|
437
437
|
- lib/vedeu/input/key.rb
|
438
438
|
- lib/vedeu/input/keymap.rb
|
439
|
-
- lib/vedeu/input/keymaps.rb
|
440
439
|
- lib/vedeu/input/mapper.rb
|
441
440
|
- lib/vedeu/input/mouse.rb
|
441
|
+
- lib/vedeu/input/repository.rb
|
442
442
|
- lib/vedeu/input/store.rb
|
443
443
|
- lib/vedeu/input/translator.rb
|
444
444
|
- lib/vedeu/interfaces/all.rb
|
@@ -617,9 +617,9 @@ files:
|
|
617
617
|
- test/lib/vedeu/input/dsl_test.rb
|
618
618
|
- test/lib/vedeu/input/key_test.rb
|
619
619
|
- test/lib/vedeu/input/keymap_test.rb
|
620
|
-
- test/lib/vedeu/input/keymaps_test.rb
|
621
620
|
- test/lib/vedeu/input/mapper_test.rb
|
622
621
|
- test/lib/vedeu/input/mouse_test.rb
|
622
|
+
- test/lib/vedeu/input/repository_test.rb
|
623
623
|
- test/lib/vedeu/input/store_test.rb
|
624
624
|
- test/lib/vedeu/input/translator_test.rb
|
625
625
|
- test/lib/vedeu/interfaces/clear_test.rb
|
@@ -828,9 +828,9 @@ test_files:
|
|
828
828
|
- test/lib/vedeu/input/dsl_test.rb
|
829
829
|
- test/lib/vedeu/input/key_test.rb
|
830
830
|
- test/lib/vedeu/input/keymap_test.rb
|
831
|
-
- test/lib/vedeu/input/keymaps_test.rb
|
832
831
|
- test/lib/vedeu/input/mapper_test.rb
|
833
832
|
- test/lib/vedeu/input/mouse_test.rb
|
833
|
+
- test/lib/vedeu/input/repository_test.rb
|
834
834
|
- test/lib/vedeu/input/store_test.rb
|
835
835
|
- test/lib/vedeu/input/translator_test.rb
|
836
836
|
- test/lib/vedeu/interfaces/clear_test.rb
|