vedeu 0.6.45 → 0.6.46
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +34 -11
- data/docs/configuration.md +9 -0
- data/lib/vedeu/all.rb +1 -0
- data/lib/vedeu/borders/border.rb +41 -14
- data/lib/vedeu/borders/refresh.rb +11 -4
- data/lib/vedeu/colours/colour.rb +9 -0
- data/lib/vedeu/configuration/api.rb +63 -0
- data/lib/vedeu/configuration/configuration.rb +24 -0
- data/lib/vedeu/cursors/cursor.rb +3 -1
- data/lib/vedeu/dsl/view.rb +3 -1
- data/lib/vedeu/editor/cropper.rb +6 -2
- data/lib/vedeu/editor/cursor.rb +3 -1
- data/lib/vedeu/error.rb +4 -0
- data/lib/vedeu/esc/esc.rb +7 -2
- data/lib/vedeu/geometry/coordinate.rb +3 -1
- data/lib/vedeu/geometry/validator.rb +3 -1
- data/lib/vedeu/interfaces/clear.rb +9 -3
- data/lib/vedeu/interfaces/interface.rb +1 -1
- data/lib/vedeu/models/views/view.rb +1 -1
- data/lib/vedeu/output/viewport.rb +1 -2
- data/lib/vedeu/templating/view_template.rb +2 -2
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/colours/colour_test.rb +14 -0
- data/test/lib/vedeu/configuration/api_test.rb +70 -0
- data/test/lib/vedeu/configuration/configuration_test.rb +23 -11
- data/test/lib/vedeu/esc/esc_test.rb +1 -0
- data/test/support/examples/material_colours_app.rb +3 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ff740a5d8a382dc5f6e01353c52fc4c8785934d
|
4
|
+
data.tar.gz: fdf167026d1ab0633c6e7dbc17e4f13c6ead54c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecd1e62df7d6590cb80d159f749622495eab7984c34f3f880afdfa71ab1e790070915d09702e60d02778120d10c4b80cff864aced98e3cdf9882b922ea8a6d18
|
7
|
+
data.tar.gz: 8b72b7cf6dea8fb4c4343405f295c68f67b920ddf4574d95ba06cb2360066b4d6462d850c471804bdc15d96dba12c6fcc66b4ba624e9e6946d499b1059173734
|
data/README.md
CHANGED
@@ -56,23 +56,46 @@ to your project here.
|
|
56
56
|
|
57
57
|
Vedeu is documented using Yard. I hope to produce more 'General Usage'
|
58
58
|
documentation shortly. In the meantime, please browse the
|
59
|
-
[RubyDoc](http://rubydoc.info/gems/vedeu).
|
60
|
-
|
59
|
+
[RubyDoc](http://rubydoc.info/gems/vedeu). Finally, here is some
|
60
|
+
documentation for the various aspects of Vedeu (not comprehensive):
|
61
61
|
|
62
|
-
- [
|
63
|
-
- [Groups](http://rubydoc.info/gems/vedeu/file/docs/group.md)
|
64
|
-
- [Views](http://rubydoc.info/gems/vedeu/file/docs/view.md)
|
65
|
-
- [Buffers](http://rubydoc.info/gems/vedeu/file/docs/buffer.md)
|
66
|
-
- [Geometry](http://rubydoc.info/gems/vedeu/file/docs/geometry.md)
|
62
|
+
- [The Vedeu API](http://rubydoc.info/gems/vedeu/file/docs/api.md)
|
67
63
|
- [Borders](http://rubydoc.info/gems/vedeu/file/docs/borders.md)
|
64
|
+
- [Buffers](http://rubydoc.info/gems/vedeu/file/docs/buffer.md)
|
65
|
+
- [Cell](http://rubydoc.info/gems/vedeu/file/docs/cell.md)
|
66
|
+
- [Chars](http://rubydoc.info/gems/vedeu/file/docs/chars.md)
|
67
|
+
- [Colours & Styles](http://rubydoc.info/gems/vedeu/file/docs/colours_styles.md)
|
68
|
+
- [Configuration](http://rubydoc.info/gems/vedeu/file/docs/configuration.md)
|
68
69
|
- [Cursors](http://rubydoc.info/gems/vedeu/file/docs/cursors.md)
|
69
|
-
- [
|
70
|
+
- [Debugging](http://rubydoc.info/gems/vedeu/file/docs/debugging.md)
|
71
|
+
- [The Vedeu DSL](http://rubydoc.info/gems/vedeu/file/docs/dsl.md)
|
70
72
|
- [Events](http://rubydoc.info/gems/vedeu/file/docs/events.md)
|
71
|
-
- [
|
73
|
+
- [Application Events](http://rubydoc.info/gems/vedeu/file/docs/events/application.md)
|
74
|
+
- [Document Events](http://rubydoc.info/gems/vedeu/file/docs/events/document.md)
|
75
|
+
- [Focus Events](http://rubydoc.info/gems/vedeu/file/docs/events/focus.md)
|
76
|
+
- [Menu Events](http://rubydoc.info/gems/vedeu/file/docs/events/menu.md)
|
77
|
+
- [Movement Events](http://rubydoc.info/gems/vedeu/file/docs/events/movement.md)
|
78
|
+
- [Refresh Events](http://rubydoc.info/gems/vedeu/file/docs/events/refresh.md)
|
79
|
+
- [System Events](http://rubydoc.info/gems/vedeu/file/docs/events/system.md)
|
80
|
+
- [View Events](http://rubydoc.info/gems/vedeu/file/docs/events/view.md)
|
81
|
+
- [Visibility Events](http://rubydoc.info/gems/vedeu/file/docs/events/visibility.md)
|
82
|
+
- [Geometry](http://rubydoc.info/gems/vedeu/file/docs/geometry.md)
|
72
83
|
- [Getting Started](http://rubydoc.info/gems/vedeu/file/docs/getting_started.md)
|
73
|
-
- [
|
74
|
-
- [
|
84
|
+
- [Groups](http://rubydoc.info/gems/vedeu/file/docs/group.md)
|
85
|
+
- [Input](http://rubydoc.info/gems/vedeu/file/docs/input.md)
|
86
|
+
- [Interfaces](http://rubydoc.info/gems/vedeu/file/docs/.md)
|
87
|
+
- [Keymaps](http://rubydoc.info/gems/vedeu/file/docs/keymaps.md)
|
88
|
+
- [Lines](http://rubydoc.info/gems/vedeu/file/docs/lines.md)
|
75
89
|
- [Object Graphs](http://rubydoc.info/gems/vedeu/file/docs/object_graph.md)
|
90
|
+
- [Output](http://rubydoc.info/gems/vedeu/file/docs/output.md)
|
91
|
+
- [Streams](http://rubydoc.info/gems/vedeu/file/docs/streams.md)
|
92
|
+
- [Template](http://rubydoc.info/gems/vedeu/file/docs/template.md)
|
93
|
+
- [Views](http://rubydoc.info/gems/vedeu/file/docs/view.md)
|
94
|
+
|
95
|
+
There are also some small, simple applications in the
|
96
|
+
[examples/](https://github.com/gavinlaking/vedeu/blob/master/examples)
|
97
|
+
directory to show some concepts and basic functionality. This is not
|
98
|
+
exhaustive, but are being added to and improved fairly regularly.
|
76
99
|
|
77
100
|
## Development / Contributing
|
78
101
|
|
data/docs/configuration.md
CHANGED
@@ -18,9 +18,15 @@ reason, simply ask for it:
|
|
18
18
|
|
19
19
|
## Configuration Options
|
20
20
|
|
21
|
+
### background
|
22
|
+
{include:Vedeu::Config::API#background}
|
23
|
+
|
21
24
|
### base_path
|
22
25
|
{include:Vedeu::Config::API#base_path}
|
23
26
|
|
27
|
+
### colour
|
28
|
+
{include:Vedeu::Config::API#colour}
|
29
|
+
|
24
30
|
### colour_mode
|
25
31
|
{include:Vedeu::Config::API#colour_mode}
|
26
32
|
|
@@ -48,6 +54,9 @@ reason, simply ask for it:
|
|
48
54
|
### drb_width
|
49
55
|
{include:Vedeu::Config::API#drb_width}
|
50
56
|
|
57
|
+
### foreground
|
58
|
+
{include:Vedeu::Config::API#foreground}
|
59
|
+
|
51
60
|
### interactive / interactive!
|
52
61
|
{include:Vedeu::Config::API#interactive}
|
53
62
|
|
data/lib/vedeu/all.rb
CHANGED
data/lib/vedeu/borders/border.rb
CHANGED
@@ -28,34 +28,41 @@ module Vedeu
|
|
28
28
|
:yn
|
29
29
|
|
30
30
|
# @!attribute [rw] bottom_left
|
31
|
-
# @return [String]
|
31
|
+
# @return [String] The character to be used for the bottom left
|
32
|
+
# border if enabled.
|
32
33
|
attr_accessor :bottom_left
|
33
34
|
|
34
35
|
# @!attribute [rw] bottom_right
|
35
|
-
# @return [String]
|
36
|
+
# @return [String] The character to be used for the bottom right
|
37
|
+
# border if enabled.
|
36
38
|
attr_accessor :bottom_right
|
37
39
|
|
38
40
|
# @!attribute [rw] horizontal
|
39
|
-
# @return [String]
|
41
|
+
# @return [String] The character to be used for the horizontal
|
42
|
+
# side border.
|
40
43
|
attr_accessor :horizontal
|
41
44
|
|
42
45
|
# @!attribute [rw] show_bottom
|
43
|
-
# @return [Boolean]
|
46
|
+
# @return [Boolean] Determines whether the bottom border should
|
47
|
+
# be shown.
|
44
48
|
attr_accessor :show_bottom
|
45
49
|
alias_method :bottom?, :show_bottom
|
46
50
|
|
47
51
|
# @!attribute [rw] show_left
|
48
|
-
# @return [Boolean]
|
52
|
+
# @return [Boolean] Determines whether the left border should
|
53
|
+
# be shown.
|
49
54
|
attr_accessor :show_left
|
50
55
|
alias_method :left?, :show_left
|
51
56
|
|
52
57
|
# @!attribute [rw] show_right
|
53
|
-
# @return [Boolean]
|
58
|
+
# @return [Boolean] Determines whether the right border should
|
59
|
+
# be shown.
|
54
60
|
attr_accessor :show_right
|
55
61
|
alias_method :right?, :show_right
|
56
62
|
|
57
63
|
# @!attribute [rw] show_top
|
58
|
-
# @return [Boolean]
|
64
|
+
# @return [Boolean] Determines whether the top border should
|
65
|
+
# be shown.
|
59
66
|
attr_accessor :show_top
|
60
67
|
alias_method :top?, :show_top
|
61
68
|
|
@@ -70,27 +77,33 @@ module Vedeu
|
|
70
77
|
attr_accessor :title
|
71
78
|
|
72
79
|
# @!attribute [rw] top_left
|
73
|
-
# @return [String]
|
80
|
+
# @return [String] The character to be used for the top left
|
81
|
+
# border if enabled.
|
74
82
|
attr_accessor :top_left
|
75
83
|
|
76
84
|
# @!attribute [rw] top_right
|
77
|
-
# @return [String]
|
85
|
+
# @return [String] The character to be used for the top right
|
86
|
+
# border if enabled.
|
78
87
|
attr_accessor :top_right
|
79
88
|
|
80
89
|
# @!attribute [rw] vertical
|
81
|
-
# @return [String]
|
90
|
+
# @return [String] The character to be used for the vertical
|
91
|
+
# side border.
|
82
92
|
attr_accessor :vertical
|
83
93
|
|
84
94
|
# @!attribute [r] name
|
85
|
-
# @return [String]
|
95
|
+
# @return [String] Associates the border with the same-named
|
96
|
+
# interface/view.
|
86
97
|
attr_reader :name
|
87
98
|
|
88
99
|
# @!attribute [r] parent
|
89
|
-
# @return [Vedeu::Interfaces::Interface|NilClass]
|
100
|
+
# @return [Vedeu::Interfaces::Interface|NilClass] The interface/
|
101
|
+
# view associated with this border.
|
90
102
|
attr_reader :parent
|
91
103
|
|
92
104
|
# @!attribute [r] enabled
|
93
|
-
# @return [Boolean]
|
105
|
+
# @return [Boolean] Determines whether this border should be
|
106
|
+
# rendered.
|
94
107
|
attr_accessor :enabled
|
95
108
|
alias_method :enabled?, :enabled
|
96
109
|
|
@@ -159,21 +172,33 @@ module Vedeu
|
|
159
172
|
}
|
160
173
|
end
|
161
174
|
|
175
|
+
# Return the column position for 1 character right of the left
|
176
|
+
# border.
|
177
|
+
#
|
162
178
|
# @return [Fixnum]
|
163
179
|
def bx
|
164
180
|
(enabled? && left?) ? x + 1 : x
|
165
181
|
end
|
166
182
|
|
183
|
+
# Return the column position for 1 character left of the right
|
184
|
+
# border.
|
185
|
+
#
|
167
186
|
# @return [Fixnum]
|
168
187
|
def bxn
|
169
188
|
(enabled? && right?) ? xn - 1 : xn
|
170
189
|
end
|
171
190
|
|
191
|
+
# Return the row position for 1 character under of the top
|
192
|
+
# border.
|
193
|
+
#
|
172
194
|
# @return [Fixnum]
|
173
195
|
def by
|
174
196
|
(enabled? && top?) ? y + 1 : y
|
175
197
|
end
|
176
198
|
|
199
|
+
# Return the column position for 1 character above of the bottom
|
200
|
+
# border.
|
201
|
+
#
|
177
202
|
# @return [Fixnum]
|
178
203
|
def byn
|
179
204
|
(enabled? && bottom?) ? yn - 1 : yn
|
@@ -197,7 +222,9 @@ module Vedeu
|
|
197
222
|
|
198
223
|
private
|
199
224
|
|
200
|
-
#
|
225
|
+
# Returns the geometry for the interface.
|
226
|
+
#
|
227
|
+
# @return (see Vedeu::Geometry::Repository#by_name)
|
201
228
|
def geometry
|
202
229
|
Vedeu.geometries.by_name(name)
|
203
230
|
end
|
@@ -75,7 +75,9 @@ module Vedeu
|
|
75
75
|
|
76
76
|
private
|
77
77
|
|
78
|
-
#
|
78
|
+
# Returns the border for the interface.
|
79
|
+
#
|
80
|
+
# @return (see Vedeu::Borders::Repository#by_name)
|
79
81
|
def border
|
80
82
|
@border ||= Vedeu.borders.by_name(name)
|
81
83
|
end
|
@@ -161,7 +163,9 @@ module Vedeu
|
|
161
163
|
[build_bottom_left, captionbar, build_bottom_right].compact
|
162
164
|
end
|
163
165
|
|
164
|
-
#
|
166
|
+
# Returns the geometry for the interface.
|
167
|
+
#
|
168
|
+
# @return (see Vedeu::Geometry::Repository#by_name)
|
165
169
|
def geometry
|
166
170
|
Vedeu.geometries.by_name(name)
|
167
171
|
end
|
@@ -176,9 +180,12 @@ module Vedeu
|
|
176
180
|
end
|
177
181
|
end
|
178
182
|
|
179
|
-
#
|
183
|
+
# Returns the interface by name.
|
184
|
+
#
|
185
|
+
# @note
|
186
|
+
# The parent of a border is always an interface.
|
180
187
|
#
|
181
|
-
# @return
|
188
|
+
# @return (see Vedeu::Interfaces::Repository#by_name)
|
182
189
|
def interface
|
183
190
|
@interface ||= Vedeu.interfaces.by_name(name)
|
184
191
|
end
|
data/lib/vedeu/colours/colour.rb
CHANGED
@@ -82,6 +82,15 @@ module Vedeu
|
|
82
82
|
@foreground = Vedeu::Colours::Foreground.coerce(attributes[:foreground])
|
83
83
|
end
|
84
84
|
|
85
|
+
# @return [Hash<Symbol => Vedeu::Colours::Background,
|
86
|
+
# Vedeu::Colours::Foreground>]
|
87
|
+
def attributes
|
88
|
+
{
|
89
|
+
background: Vedeu::Colours::Background.coerce(@background),
|
90
|
+
foreground: Vedeu::Colours::Foreground.coerce(@foreground),
|
91
|
+
}
|
92
|
+
end
|
93
|
+
|
85
94
|
# Converts the value into a Vedeu::Colours::Background.
|
86
95
|
#
|
87
96
|
# @param value [String]
|
@@ -504,8 +504,71 @@ module Vedeu
|
|
504
504
|
options[:width] = width
|
505
505
|
end
|
506
506
|
|
507
|
+
# Sets the background of the terminal.
|
508
|
+
#
|
509
|
+
# Vedeu.configure do
|
510
|
+
# background '#ff0000'
|
511
|
+
# # ...
|
512
|
+
# end
|
513
|
+
#
|
514
|
+
# @param value [String]
|
515
|
+
# @return [Vedeu::Colours::Background]
|
516
|
+
def background(value = nil)
|
517
|
+
return options[:background] unless value
|
518
|
+
|
519
|
+
new_background = Vedeu::Colours::Background.coerce(value)
|
520
|
+
|
521
|
+
options[:background] = colour_attributes(background: new_background)
|
522
|
+
.fetch(:background)
|
523
|
+
end
|
524
|
+
|
525
|
+
# Sets the foreground of the terminal.
|
526
|
+
#
|
527
|
+
# Vedeu.configure do
|
528
|
+
# foreground '#ffff00'
|
529
|
+
# # ...
|
530
|
+
# end
|
531
|
+
#
|
532
|
+
# @param value [String]
|
533
|
+
# @return [Vedeu::Colours::Foreground]
|
534
|
+
def foreground(value = nil)
|
535
|
+
return options[:foreground] unless value
|
536
|
+
|
537
|
+
new_foreground = Vedeu::Colours::Foreground.coerce(value)
|
538
|
+
|
539
|
+
options[:foreground] = colour_attributes(foreground: new_foreground)
|
540
|
+
.fetch(:foreground)
|
541
|
+
end
|
542
|
+
|
543
|
+
# Sets the background and foreground of the terminal.
|
544
|
+
#
|
545
|
+
# Vedeu.configure do
|
546
|
+
# colour background: '#ff0000', foreground: '#ffff00'
|
547
|
+
# # ...
|
548
|
+
# end
|
549
|
+
#
|
550
|
+
# @param attrs [Hash<Symbol => String>]
|
551
|
+
# @return [Hash]
|
552
|
+
def colour(attrs = {})
|
553
|
+
options[:background] = background(attrs[:background])
|
554
|
+
options[:foreground] = foreground(attrs[:foreground])
|
555
|
+
options
|
556
|
+
end
|
557
|
+
|
507
558
|
private
|
508
559
|
|
560
|
+
# @params attrs [Hash<Symbol => Vedeu::Colours::Background,
|
561
|
+
# Vedeu::Colours::Foreground>]
|
562
|
+
# @options attrs background [Vedeu::Colours::Background]
|
563
|
+
# @options attrs foreground [Vedeu::Colours::Foreground]
|
564
|
+
# @return [Hash<Symbol => Symbol>]
|
565
|
+
def colour_attributes(attrs = {})
|
566
|
+
{
|
567
|
+
background: Vedeu::Configuration.background,
|
568
|
+
foreground: Vedeu::Configuration.foreground,
|
569
|
+
}.merge!(attrs)
|
570
|
+
end
|
571
|
+
|
509
572
|
# @raise [Vedeu::Error::InvalidSyntax]
|
510
573
|
def invalid_mode!
|
511
574
|
fail Vedeu::Error::InvalidSyntax,
|
@@ -34,6 +34,14 @@ module Vedeu
|
|
34
34
|
|
35
35
|
class << self
|
36
36
|
|
37
|
+
# Return the configured background colour for the client
|
38
|
+
# application.
|
39
|
+
#
|
40
|
+
# @return [Vedeu::Colours::Background]
|
41
|
+
def background
|
42
|
+
instance.options[:background]
|
43
|
+
end
|
44
|
+
|
37
45
|
# Returns the base_path value.
|
38
46
|
#
|
39
47
|
# @return [String]
|
@@ -81,6 +89,12 @@ module Vedeu
|
|
81
89
|
instance
|
82
90
|
end
|
83
91
|
|
92
|
+
# @return [Vedeu::Colours::Colour]
|
93
|
+
def colour
|
94
|
+
Vedeu::Colours::Colour.coerce(background: background,
|
95
|
+
foreground: foreground)
|
96
|
+
end
|
97
|
+
|
84
98
|
# Returns the chosen colour mode.
|
85
99
|
#
|
86
100
|
# @return [Fixnum]
|
@@ -135,6 +149,14 @@ module Vedeu
|
|
135
149
|
instance.options[:drb_width]
|
136
150
|
end
|
137
151
|
|
152
|
+
# Return the configured foreground colour for the client
|
153
|
+
# application.
|
154
|
+
#
|
155
|
+
# @return [Vedeu::Colours::Foreground]
|
156
|
+
def foreground
|
157
|
+
instance.options[:foreground]
|
158
|
+
end
|
159
|
+
|
138
160
|
# Returns the client defined height for the terminal.
|
139
161
|
#
|
140
162
|
# @return [Fixnum]
|
@@ -299,6 +321,7 @@ module Vedeu
|
|
299
321
|
# @return [Hash<Symbol => void>]
|
300
322
|
def defaults
|
301
323
|
{
|
324
|
+
background: Vedeu::Colours::Background.coerce(:default),
|
302
325
|
base_path: base_path,
|
303
326
|
colour_mode: detect_colour_mode,
|
304
327
|
compression: true,
|
@@ -308,6 +331,7 @@ module Vedeu
|
|
308
331
|
drb_port: nil,
|
309
332
|
drb_height: 25,
|
310
333
|
drb_width: 80,
|
334
|
+
foreground: Vedeu::Colours::Foreground.coerce(:default),
|
311
335
|
height: nil,
|
312
336
|
interactive: true,
|
313
337
|
log: nil,
|
data/lib/vedeu/cursors/cursor.rb
CHANGED
@@ -263,7 +263,9 @@ module Vedeu
|
|
263
263
|
|
264
264
|
private
|
265
265
|
|
266
|
-
#
|
266
|
+
# Returns the border for the interface.
|
267
|
+
#
|
268
|
+
# @return (see Vedeu::Borders::Repository#by_name)
|
267
269
|
def border
|
268
270
|
@border ||= Vedeu.borders.by_name(name)
|
269
271
|
end
|
data/lib/vedeu/dsl/view.rb
CHANGED
@@ -197,7 +197,9 @@ module Vedeu
|
|
197
197
|
# @param block [Proc]
|
198
198
|
# @return [Vedeu::Views::Composition]
|
199
199
|
def composition(client, &block)
|
200
|
-
|
200
|
+
attrs = { client: client, colour: Vedeu::Configuration.colour }
|
201
|
+
|
202
|
+
Vedeu::Views::Composition.build(attrs, &block)
|
201
203
|
end
|
202
204
|
|
203
205
|
# Stores each of the views defined in their respective buffers
|
data/lib/vedeu/editor/cropper.rb
CHANGED
@@ -88,7 +88,9 @@ module Vedeu
|
|
88
88
|
@lines[oy...(oy + height)] || []
|
89
89
|
end
|
90
90
|
|
91
|
-
#
|
91
|
+
# Returns the interface by name.
|
92
|
+
#
|
93
|
+
# @return (see Vedeu::Interfaces::Repository#by_name)
|
92
94
|
def interface
|
93
95
|
@interface ||= Vedeu.interfaces.by_name(name)
|
94
96
|
end
|
@@ -100,7 +102,9 @@ module Vedeu
|
|
100
102
|
line[ox...(ox + width)] || ''
|
101
103
|
end
|
102
104
|
|
103
|
-
#
|
105
|
+
# Returns the border for the interface.
|
106
|
+
#
|
107
|
+
# @return (see Vedeu::Borders::Repository#by_name)
|
104
108
|
def border
|
105
109
|
@border ||= Vedeu.borders.by_name(name)
|
106
110
|
end
|
data/lib/vedeu/editor/cursor.rb
CHANGED
data/lib/vedeu/error.rb
CHANGED
@@ -86,6 +86,8 @@ module Vedeu
|
|
86
86
|
#
|
87
87
|
class OutOfRange < StandardError
|
88
88
|
|
89
|
+
# Returns an error message.
|
90
|
+
#
|
89
91
|
# @return [String]
|
90
92
|
def message
|
91
93
|
'Valid value is between 1 and 12 inclusive.'.freeze
|
@@ -98,6 +100,8 @@ module Vedeu
|
|
98
100
|
#
|
99
101
|
class RequiresBlock < StandardError
|
100
102
|
|
103
|
+
# Returns an error message.
|
104
|
+
#
|
101
105
|
# @return [String]
|
102
106
|
def message
|
103
107
|
'The required block was not given.'.freeze
|
data/lib/vedeu/esc/esc.rb
CHANGED
@@ -70,7 +70,7 @@ module Vedeu
|
|
70
70
|
|
71
71
|
# @return [String]
|
72
72
|
def colour_reset
|
73
|
-
|
73
|
+
Vedeu::Configuration.colour.to_s
|
74
74
|
end
|
75
75
|
|
76
76
|
# @return [String]
|
@@ -83,9 +83,14 @@ module Vedeu
|
|
83
83
|
"#{reset}#{clear}#{hide_cursor}".freeze
|
84
84
|
end
|
85
85
|
|
86
|
+
# @return [String]
|
87
|
+
def screen_colour_reset
|
88
|
+
"#{fg_reset}#{bg_reset}".freeze
|
89
|
+
end
|
90
|
+
|
86
91
|
# @return [String]
|
87
92
|
def screen_exit
|
88
|
-
"#{show_cursor}#{
|
93
|
+
"#{show_cursor}#{screen_colour_reset}#{reset}" \
|
89
94
|
"#{last_character_position}\n".freeze
|
90
95
|
end
|
91
96
|
|
@@ -2,6 +2,8 @@ module Vedeu
|
|
2
2
|
|
3
3
|
module Geometry
|
4
4
|
|
5
|
+
# Validate values given to {Vedeu::Geometry::DSL}.
|
6
|
+
#
|
5
7
|
module Validator
|
6
8
|
|
7
9
|
include Vedeu::Common
|
@@ -28,7 +30,7 @@ module Vedeu
|
|
28
30
|
true
|
29
31
|
end
|
30
32
|
|
31
|
-
# @param
|
33
|
+
# @param value [Symbol] One of :bottom, :middle, :none, :top.
|
32
34
|
# @raise [Vedeu::Error::InvalidSyntax] When the value is nil.
|
33
35
|
# @return [TrueClass]
|
34
36
|
def validate_vertical_alignment!(value)
|
@@ -81,7 +81,9 @@ module Vedeu
|
|
81
81
|
|
82
82
|
private
|
83
83
|
|
84
|
-
#
|
84
|
+
# Returns the border for the interface.
|
85
|
+
#
|
86
|
+
# @return (see Vedeu::Borders::Repository#by_name)
|
85
87
|
def border
|
86
88
|
@border ||= Vedeu.borders.by_name(name)
|
87
89
|
end
|
@@ -109,7 +111,9 @@ module Vedeu
|
|
109
111
|
options[:direct]
|
110
112
|
end
|
111
113
|
|
112
|
-
#
|
114
|
+
# Returns the geometry for the interface.
|
115
|
+
#
|
116
|
+
# @return (see Vedeu::Geometry::Repository#by_name)
|
113
117
|
def geometry
|
114
118
|
@geometry ||= Vedeu.geometries.by_name(name)
|
115
119
|
end
|
@@ -121,7 +125,9 @@ module Vedeu
|
|
121
125
|
geometry.height
|
122
126
|
end
|
123
127
|
|
124
|
-
#
|
128
|
+
# Returns the interface by name.
|
129
|
+
#
|
130
|
+
# @return (see Vedeu::Interfaces::Repository#by_name)
|
125
131
|
def interface
|
126
132
|
@interface ||= Vedeu.interfaces.by_name(name)
|
127
133
|
end
|
@@ -72,9 +72,9 @@ module Vedeu
|
|
72
72
|
:normal
|
73
73
|
end
|
74
74
|
|
75
|
-
#
|
75
|
+
# Returns the interface by name.
|
76
76
|
#
|
77
|
-
# @return
|
77
|
+
# @return (see Vedeu::Interfaces::Repository#by_name)
|
78
78
|
def interface
|
79
79
|
Vedeu.interfaces.by_name(options[:name])
|
80
80
|
end
|
data/lib/vedeu/version.rb
CHANGED
@@ -173,6 +173,20 @@ module Vedeu
|
|
173
173
|
it { subject.must_be_instance_of(Vedeu::Colours::Colour) }
|
174
174
|
end
|
175
175
|
|
176
|
+
describe '#attributes' do
|
177
|
+
let(:expected) {
|
178
|
+
{
|
179
|
+
background: Vedeu::Colours::Background.new,
|
180
|
+
foreground: Vedeu::Colours::Foreground.new,
|
181
|
+
}
|
182
|
+
}
|
183
|
+
|
184
|
+
subject { instance.attributes }
|
185
|
+
|
186
|
+
it { subject.must_be_instance_of(Hash) }
|
187
|
+
it { subject.must_equal(expected) }
|
188
|
+
end
|
189
|
+
|
176
190
|
describe '#background=' do
|
177
191
|
let(:_value) { '#000000' }
|
178
192
|
|
@@ -356,6 +356,76 @@ module Vedeu
|
|
356
356
|
end
|
357
357
|
end
|
358
358
|
|
359
|
+
describe '#background' do
|
360
|
+
context 'when a value is given' do
|
361
|
+
it {
|
362
|
+
configuration = Vedeu.configure { background '#ff0000' }
|
363
|
+
configuration.background.must_be_instance_of(Vedeu::Colours::Background)
|
364
|
+
configuration.background.to_s.must_equal("\e[48;2;255;0;0m")
|
365
|
+
}
|
366
|
+
end
|
367
|
+
|
368
|
+
context 'when a value is not given' do
|
369
|
+
it {
|
370
|
+
configuration = Vedeu.configure { background nil }
|
371
|
+
configuration.background.must_be_instance_of(Vedeu::Colours::Background)
|
372
|
+
configuration.background.to_s.must_equal("\e[49m")
|
373
|
+
}
|
374
|
+
end
|
375
|
+
end
|
376
|
+
|
377
|
+
describe '#colour' do
|
378
|
+
context 'when a background and foreground is given' do
|
379
|
+
it {
|
380
|
+
configuration = Vedeu.configure { colour background: '#ff0000', foreground: '#ffff00' }
|
381
|
+
configuration.colour.must_be_instance_of(Vedeu::Colours::Colour)
|
382
|
+
configuration.colour.to_s.must_equal("\e[38;2;255;255;0m\e[48;2;255;0;0m")
|
383
|
+
}
|
384
|
+
end
|
385
|
+
|
386
|
+
context 'when only a background is given' do
|
387
|
+
it {
|
388
|
+
configuration = Vedeu.configure { colour background: '#ff0000' }
|
389
|
+
configuration.colour.must_be_instance_of(Vedeu::Colours::Colour)
|
390
|
+
configuration.colour.to_s.must_equal("\e[48;2;255;0;0m")
|
391
|
+
}
|
392
|
+
end
|
393
|
+
|
394
|
+
context 'when only a foreground is given' do
|
395
|
+
it {
|
396
|
+
configuration = Vedeu.configure { colour foreground: '#ffff00' }
|
397
|
+
configuration.colour.must_be_instance_of(Vedeu::Colours::Colour)
|
398
|
+
configuration.colour.to_s.must_equal("\e[38;2;255;255;0m")
|
399
|
+
}
|
400
|
+
end
|
401
|
+
|
402
|
+
context 'when neither a background nor foreground is given' do
|
403
|
+
it {
|
404
|
+
configuration = Vedeu.configure { colour background: nil, foreground: nil }
|
405
|
+
configuration.colour.must_be_instance_of(Vedeu::Colours::Colour)
|
406
|
+
configuration.colour.to_s.must_equal('')
|
407
|
+
}
|
408
|
+
end
|
409
|
+
end
|
410
|
+
|
411
|
+
describe '#foreground' do
|
412
|
+
context 'when a value is given' do
|
413
|
+
it {
|
414
|
+
configuration = Vedeu.configure { foreground '#ffff00' }
|
415
|
+
configuration.foreground.must_be_instance_of(Vedeu::Colours::Foreground)
|
416
|
+
configuration.foreground.to_s.must_equal("\e[38;2;255;255;0m")
|
417
|
+
}
|
418
|
+
end
|
419
|
+
|
420
|
+
context 'when a value is not given' do
|
421
|
+
it {
|
422
|
+
configuration = Vedeu.configure { background nil }
|
423
|
+
configuration.foreground.must_be_instance_of(Vedeu::Colours::Foreground)
|
424
|
+
configuration.foreground.to_s.must_equal("\e[39m")
|
425
|
+
}
|
426
|
+
end
|
427
|
+
end
|
428
|
+
|
359
429
|
end # API
|
360
430
|
|
361
431
|
end # Config
|
@@ -9,11 +9,17 @@ module Vedeu
|
|
9
9
|
before { Configuration.reset! }
|
10
10
|
after { test_configuration }
|
11
11
|
|
12
|
+
describe '.background' do
|
13
|
+
it 'returns the value of the background option' do
|
14
|
+
described.background.must_be_instance_of(Vedeu::Colours::Background)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
12
18
|
describe '.base_path' do
|
13
19
|
it { described.must_respond_to(:base_path) }
|
14
20
|
|
15
21
|
it 'returns the value of the base_path option' do
|
16
|
-
|
22
|
+
described.base_path.must_equal(Dir.pwd)
|
17
23
|
end
|
18
24
|
end
|
19
25
|
|
@@ -21,7 +27,7 @@ module Vedeu
|
|
21
27
|
it { described.must_respond_to(:compression) }
|
22
28
|
|
23
29
|
it 'returns the value of the compression option' do
|
24
|
-
|
30
|
+
described.compression?.must_equal(true)
|
25
31
|
end
|
26
32
|
end
|
27
33
|
|
@@ -29,7 +35,7 @@ module Vedeu
|
|
29
35
|
it { described.must_respond_to(:debug) }
|
30
36
|
|
31
37
|
it 'returns the value of the debug option' do
|
32
|
-
|
38
|
+
described.debug?.must_equal(false)
|
33
39
|
end
|
34
40
|
end
|
35
41
|
|
@@ -37,7 +43,13 @@ module Vedeu
|
|
37
43
|
it { described.must_respond_to(:drb) }
|
38
44
|
|
39
45
|
it 'returns the value of the drb option' do
|
40
|
-
|
46
|
+
described.drb?.must_equal(false)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '.foreground' do
|
51
|
+
it 'returns the value of the foreground option' do
|
52
|
+
described.foreground.must_be_instance_of(Vedeu::Colours::Foreground)
|
41
53
|
end
|
42
54
|
end
|
43
55
|
|
@@ -45,7 +57,7 @@ module Vedeu
|
|
45
57
|
it { described.must_respond_to(:interactive) }
|
46
58
|
|
47
59
|
it 'returns the value of the interactive option' do
|
48
|
-
|
60
|
+
described.interactive?.must_equal(true)
|
49
61
|
end
|
50
62
|
end
|
51
63
|
|
@@ -101,37 +113,37 @@ module Vedeu
|
|
101
113
|
it { described.must_respond_to(:once) }
|
102
114
|
|
103
115
|
it 'returns the value of the once option' do
|
104
|
-
|
116
|
+
described.once?.must_equal(false)
|
105
117
|
end
|
106
118
|
end
|
107
119
|
|
108
120
|
describe '.stdin' do
|
109
121
|
it 'returns the value of the redefined STDIN' do
|
110
|
-
|
122
|
+
described.stdin.must_equal(nil)
|
111
123
|
end
|
112
124
|
end
|
113
125
|
|
114
126
|
describe '.stdout' do
|
115
127
|
it 'returns the value of the redefined STDOUT' do
|
116
|
-
|
128
|
+
described.stdout.must_equal(nil)
|
117
129
|
end
|
118
130
|
end
|
119
131
|
|
120
132
|
describe '.stderr' do
|
121
133
|
it 'returns the value of the redefined STDERR' do
|
122
|
-
|
134
|
+
described.stderr.must_equal(nil)
|
123
135
|
end
|
124
136
|
end
|
125
137
|
|
126
138
|
describe '.terminal_mode' do
|
127
139
|
it 'returns the value of the mode option' do
|
128
|
-
|
140
|
+
described.terminal_mode.must_equal(:raw)
|
129
141
|
end
|
130
142
|
end
|
131
143
|
|
132
144
|
describe '.configure' do
|
133
145
|
it 'returns the options configured' do
|
134
|
-
|
146
|
+
described.configure do
|
135
147
|
# ...
|
136
148
|
end.must_equal(Vedeu::Configuration)
|
137
149
|
end
|
@@ -50,6 +50,7 @@ module Vedeu
|
|
50
50
|
it { described.string('clear').must_equal("\e[39m\e[49m\e[2J") }
|
51
51
|
it { described.string('clear_line').must_equal("\e[39m\e[49m\e[2K") }
|
52
52
|
it { described.string('colour_reset').must_equal("\e[39m\e[49m") }
|
53
|
+
it { described.string('screen_colour_reset').must_equal("\e[39m\e[49m") }
|
53
54
|
it { described.string('fg_reset').must_equal("\e[39m") }
|
54
55
|
it { described.string('hide_cursor').must_equal("\e[?25l") }
|
55
56
|
it { described.string('screen_init').
|
@@ -17,7 +17,10 @@ class VedeuMaterialColoursApp
|
|
17
17
|
# Be aware that running an application with debugging enabled will affect
|
18
18
|
# performance.
|
19
19
|
Vedeu.configure do
|
20
|
+
# background '#607d8b'
|
21
|
+
# colour background: '#607d8b', foreground: '#ffff00'
|
20
22
|
debug!
|
23
|
+
# foreground '#ffff00'
|
21
24
|
# profile!
|
22
25
|
log '/tmp/vedeu_material_colours_app.log'
|
23
26
|
# height 11
|
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.46
|
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-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|