vedeu 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vedeu/all.rb +2 -13
- data/lib/vedeu/api.rb +9 -9
- data/lib/vedeu/application/application_view.rb +3 -5
- data/lib/vedeu/bindings/bindings.rb +5 -1
- data/lib/vedeu/bindings/focus.rb +0 -5
- data/lib/vedeu/bindings/refresh.rb +0 -5
- data/lib/vedeu/bindings/system.rb +1 -6
- data/lib/vedeu/colours/all.rb +17 -0
- data/lib/vedeu/colours/background.rb +32 -28
- data/lib/vedeu/colours/backgrounds.rb +13 -9
- data/lib/vedeu/colours/colour.rb +106 -102
- data/lib/vedeu/colours/foreground.rb +32 -28
- data/lib/vedeu/colours/foregrounds.rb +13 -9
- data/lib/vedeu/colours/repository.rb +70 -0
- data/lib/vedeu/colours/translator.rb +267 -0
- data/lib/vedeu/configuration/api.rb +10 -7
- data/lib/vedeu/configuration/configuration.rb +2 -1
- data/lib/vedeu/dsl/border.rb +15 -2
- data/lib/vedeu/dsl/composition.rb +6 -4
- data/lib/vedeu/dsl/geometry.rb +14 -7
- data/lib/vedeu/dsl/group.rb +2 -2
- data/lib/vedeu/dsl/interface.rb +5 -3
- data/lib/vedeu/dsl/keymap.rb +9 -7
- data/lib/vedeu/dsl/line.rb +7 -4
- data/lib/vedeu/dsl/menu.rb +3 -0
- data/lib/vedeu/dsl/presentation.rb +20 -10
- data/lib/vedeu/dsl/shared.rb +4 -4
- data/lib/vedeu/dsl/stream.rb +2 -2
- data/lib/vedeu/dsl/text.rb +11 -5
- data/lib/vedeu/dsl/use.rb +2 -2
- data/lib/vedeu/dsl/view.rb +8 -6
- data/lib/vedeu/events/aliases.rb +91 -0
- data/lib/vedeu/events/all.rb +15 -0
- data/lib/vedeu/events/collection.rb +13 -0
- data/lib/vedeu/events/event.rb +244 -239
- data/lib/vedeu/events/repository.rb +30 -0
- data/lib/vedeu/events/trigger.rb +68 -64
- data/lib/vedeu/exceptions.rb +65 -54
- data/lib/vedeu/geometry/coordinate.rb +3 -1
- data/lib/vedeu/geometry/grid.rb +2 -4
- data/lib/vedeu/input/editor/all.rb +2 -1
- data/lib/vedeu/input/editor/{virtual_cursor.rb → cursor.rb} +10 -10
- data/lib/vedeu/input/editor/document.rb +7 -7
- data/lib/vedeu/input/editor/insert.rb +70 -0
- data/lib/vedeu/input/editor/line.rb +4 -16
- data/lib/vedeu/input/editor/lines.rb +2 -16
- data/lib/vedeu/input/input_translator.rb +2 -2
- data/lib/vedeu/input/key.rb +2 -2
- data/lib/vedeu/internal_api.rb +6 -6
- data/lib/vedeu/log/lockless_log_device.rb +0 -74
- data/lib/vedeu/models/focus.rb +3 -3
- data/lib/vedeu/models/interface.rb +3 -3
- data/lib/vedeu/models/menu.rb +2 -2
- data/lib/vedeu/models/views/char.rb +1 -1
- data/lib/vedeu/models/views/composition.rb +1 -1
- data/lib/vedeu/models/views/line.rb +1 -1
- data/lib/vedeu/models/views/stream.rb +1 -1
- data/lib/vedeu/models/views/view.rb +6 -7
- data/lib/vedeu/output/presentation/colour.rb +23 -21
- data/lib/vedeu/output/renderers/renderer_options.rb +2 -4
- data/lib/vedeu/output/text.rb +1 -1
- data/lib/vedeu/output/wordwrap.rb +18 -7
- data/lib/vedeu/plugins/plugin.rb +2 -2
- data/lib/vedeu/refresh/refresh_buffer.rb +3 -3
- data/lib/vedeu/refresh/refresh_group.rb +3 -3
- data/lib/vedeu/repositories/repository.rb +7 -6
- data/lib/vedeu/runtime/application.rb +1 -1
- data/lib/vedeu/runtime/main_loop.rb +3 -3
- data/lib/vedeu/runtime/router.rb +14 -11
- data/lib/vedeu/templating/helpers.rb +5 -5
- data/lib/vedeu/templating/template.rb +4 -4
- data/lib/vedeu/templating/view_template.rb +1 -1
- data/lib/vedeu/terminal/terminal.rb +2 -2
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/application/application_view_test.rb +1 -1
- data/test/lib/vedeu/colours/background_test.rb +93 -89
- data/test/lib/vedeu/colours/backgrounds_test.rb +11 -7
- data/test/lib/vedeu/colours/colour_test.rb +155 -151
- data/test/lib/vedeu/colours/foreground_test.rb +93 -89
- data/test/lib/vedeu/colours/foregrounds_test.rb +11 -7
- data/test/lib/vedeu/colours/repository_test.rb +97 -0
- data/test/lib/vedeu/colours/translator_test.rb +173 -0
- data/test/lib/vedeu/configuration/api_test.rb +4 -4
- data/test/lib/vedeu/dsl/border_test.rb +12 -0
- data/test/lib/vedeu/dsl/composition_test.rb +3 -3
- data/test/lib/vedeu/dsl/geometry_test.rb +11 -0
- data/test/lib/vedeu/dsl/group_test.rb +2 -2
- data/test/lib/vedeu/dsl/interface_test.rb +4 -4
- data/test/lib/vedeu/dsl/keymap_test.rb +8 -4
- data/test/lib/vedeu/dsl/line_test.rb +6 -3
- data/test/lib/vedeu/dsl/menu_test.rb +6 -0
- data/test/lib/vedeu/dsl/presentation_test.rb +16 -3
- data/test/lib/vedeu/dsl/stream_test.rb +1 -1
- data/test/lib/vedeu/dsl/text_test.rb +7 -0
- data/test/lib/vedeu/dsl/view_test.rb +3 -3
- data/test/lib/vedeu/events/aliases_test.rb +144 -0
- data/test/lib/vedeu/events/collection_test.rb +22 -0
- data/test/lib/vedeu/events/event_test.rb +84 -80
- data/test/lib/vedeu/events/repository_test.rb +28 -0
- data/test/lib/vedeu/events/trigger_test.rb +41 -37
- data/test/lib/vedeu/geometry/grid_test.rb +4 -4
- data/test/lib/vedeu/input/editor/{virtual_cursor_test.rb → cursor_test.rb} +3 -3
- data/test/lib/vedeu/input/editor/insert_test.rb +36 -0
- data/test/lib/vedeu/input/key_test.rb +1 -1
- data/test/lib/vedeu/models/cell_test.rb +1 -1
- data/test/lib/vedeu/models/focus_test.rb +4 -2
- data/test/lib/vedeu/models/menu_test.rb +1 -1
- data/test/lib/vedeu/models/views/char_test.rb +8 -4
- data/test/lib/vedeu/models/views/line_test.rb +4 -4
- data/test/lib/vedeu/models/views/stream_test.rb +3 -3
- data/test/lib/vedeu/models/views/view_test.rb +1 -1
- data/test/lib/vedeu/output/html_char_test.rb +4 -2
- data/test/lib/vedeu/output/presentation/colour_test.rb +5 -5
- data/test/lib/vedeu/output/presentation_test.rb +4 -4
- data/test/lib/vedeu/output/renderers/json_test.rb +4 -2
- data/test/lib/vedeu/plugins/plugin_test.rb +1 -1
- data/test/lib/vedeu/refresh/refresh_buffer_test.rb +1 -1
- data/test/lib/vedeu/refresh/refresh_group_test.rb +1 -1
- data/test/lib/vedeu/repositories/repository_test.rb +2 -2
- data/test/lib/vedeu/runtime/router_test.rb +6 -6
- data/test/lib/vedeu/templating/decoder_test.rb +2 -3
- data/test/lib/vedeu/templating/encoder_test.rb +2 -3
- data/test/lib/vedeu/templating/helpers_test.rb +6 -6
- data/test/lib/vedeu/templating/template_test.rb +2 -2
- data/test/lib/vedeu/templating/view_template_test.rb +13 -7
- data/test/lib/vedeu/terminal/terminal_test.rb +3 -3
- metadata +24 -19
- data/lib/vedeu/colours/colour_translator.rb +0 -260
- data/lib/vedeu/colours/colours.rb +0 -66
- data/lib/vedeu/events/event_aliases.rb +0 -87
- data/lib/vedeu/events/event_collection.rb +0 -9
- data/lib/vedeu/events/events.rb +0 -26
- data/test/lib/vedeu/colours/colour_translator_test.rb +0 -169
- data/test/lib/vedeu/colours/colours_test.rb +0 -93
- data/test/lib/vedeu/events/event_aliases_test.rb +0 -140
- data/test/lib/vedeu/events/event_collection_test.rb +0 -18
- data/test/lib/vedeu/events/events_test.rb +0 -24
@@ -1,32 +1,36 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
Vedeu
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
3
|
+
module Colours
|
4
|
+
|
5
|
+
# The class represents one half (the other, can be found at
|
6
|
+
# {Vedeu::Colours::Background}) of a terminal colour escape sequence.
|
7
|
+
#
|
8
|
+
class Foreground < Vedeu::Colours::Translator
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
# @return [String]
|
13
|
+
def named_codes
|
14
|
+
Vedeu::Esc.foreground_codes[colour]
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [String]
|
18
|
+
def numbered_prefix
|
19
|
+
"\e[38;5;"
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Vedeu::Colours::Foregrounds]
|
23
|
+
def repository
|
24
|
+
Vedeu.foreground_colours
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [String]
|
28
|
+
def rgb_prefix
|
29
|
+
"\e[38;2;%s;%s;%sm"
|
30
|
+
end
|
31
|
+
|
32
|
+
end # Foreground
|
33
|
+
|
34
|
+
end # Colours
|
31
35
|
|
32
36
|
end # Vedeu
|
@@ -1,15 +1,19 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
|
4
|
-
#
|
5
|
-
class Foregrounds < Colours
|
3
|
+
module Colours
|
6
4
|
|
7
|
-
#
|
8
|
-
#
|
9
|
-
|
10
|
-
@foreground_colours ||= new
|
11
|
-
end
|
5
|
+
# Store foreground colour escape sequences by HTML/CSS code.
|
6
|
+
#
|
7
|
+
class Foregrounds < Vedeu::Colours::Repository
|
12
8
|
|
13
|
-
|
9
|
+
# @return [Vedeu::Colours::Foregrounds]
|
10
|
+
# @see Vedeu::Repository
|
11
|
+
def self.foreground_colours
|
12
|
+
@foreground_colours ||= new
|
13
|
+
end
|
14
|
+
|
15
|
+
end # Foregrounds
|
16
|
+
|
17
|
+
end # Colours
|
14
18
|
|
15
19
|
end # Vedeu
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
module Colours
|
4
|
+
|
5
|
+
# Allows the storing of HTML/CSS colours and their respective escape
|
6
|
+
# sequences.
|
7
|
+
#
|
8
|
+
class Repository
|
9
|
+
|
10
|
+
# @!attribute [r] storage
|
11
|
+
# @return [Hash<String => String>]
|
12
|
+
attr_reader :storage
|
13
|
+
|
14
|
+
# Returns a new instance of Vedeu::Colours::Repository.
|
15
|
+
#
|
16
|
+
# @return [Vedeu::Colours::Repository]
|
17
|
+
def initialize
|
18
|
+
@storage = {}
|
19
|
+
end
|
20
|
+
|
21
|
+
# Registers a colour with respective escape sequence.
|
22
|
+
#
|
23
|
+
# @return [String]
|
24
|
+
def register(colour, escape_sequence)
|
25
|
+
storage.store(colour, escape_sequence)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Returns a boolean indicating whether the colour has been registered.
|
29
|
+
#
|
30
|
+
# @param colour [String]
|
31
|
+
# @return [Boolean]
|
32
|
+
def registered?(colour)
|
33
|
+
return false unless colour
|
34
|
+
|
35
|
+
storage.key?(colour)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Removes all stored colours.
|
39
|
+
#
|
40
|
+
# @return [Hash]
|
41
|
+
def reset!
|
42
|
+
storage.clear
|
43
|
+
end
|
44
|
+
|
45
|
+
# Retrieves the escape sequence of a registered colour.
|
46
|
+
#
|
47
|
+
# @return [String]
|
48
|
+
def retrieve(colour)
|
49
|
+
storage.fetch(colour, '')
|
50
|
+
end
|
51
|
+
|
52
|
+
# Retrieves the escape sequence of a registered colour, or registers the
|
53
|
+
# colour with its respective escape sequence.
|
54
|
+
#
|
55
|
+
# @return [String]
|
56
|
+
def retrieve_or_register(colour, escape_sequence)
|
57
|
+
if registered?(colour)
|
58
|
+
retrieve(colour)
|
59
|
+
|
60
|
+
else
|
61
|
+
register(colour, escape_sequence)
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end # Repository
|
67
|
+
|
68
|
+
end # Colours
|
69
|
+
|
70
|
+
end # Vedeu
|
@@ -0,0 +1,267 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
module Colours
|
4
|
+
|
5
|
+
# Convert a CSS/HTML colour string into a terminal escape sequence.
|
6
|
+
#
|
7
|
+
# If provided with an empty value or a string it cannot convert, it will
|
8
|
+
# return an empty string.
|
9
|
+
#
|
10
|
+
# When provided with a named colour, uses the terminal's value for that
|
11
|
+
# colour. If a theme is being used with the terminal, which overrides the
|
12
|
+
# defaults, then the theme's colour will be used. The recognised names are:
|
13
|
+
# :black, :red, :green, :yellow, :blue, :magenta, :cyan, :white, :default.
|
14
|
+
#
|
15
|
+
# When a number between 0 and 255 is provided, Vedeu will use the terminal
|
16
|
+
# colour corresponding with that colour.
|
17
|
+
#
|
18
|
+
# Finally, when provided a CSS/HTML colour string e.g. '#ff0000', Vedeu will
|
19
|
+
# translate that to the 8-bit escape sequence or when you have a capable
|
20
|
+
# terminal and the `TERM=xterm-truecolor` environment variable set,
|
21
|
+
# a 24-bit representation.
|
22
|
+
#
|
23
|
+
# @todo More documentation required (create a fancy chart!)
|
24
|
+
#
|
25
|
+
class Translator
|
26
|
+
|
27
|
+
# @!attribute [r] colour
|
28
|
+
# @return [String]
|
29
|
+
attr_reader :colour
|
30
|
+
alias_method :value, :colour
|
31
|
+
|
32
|
+
# Produces new objects of the correct class from the value, ignores
|
33
|
+
# objects Colours::that have already been coerced.
|
34
|
+
#
|
35
|
+
# @param value [Object|NilClass]
|
36
|
+
# @return [Object]
|
37
|
+
def self.coerce(value)
|
38
|
+
if value.is_a?(self)
|
39
|
+
value
|
40
|
+
|
41
|
+
else
|
42
|
+
new(value)
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Return a new instance of Vedeu::Colours::Translator.
|
48
|
+
#
|
49
|
+
# @param colour [Fixnum|String|Symbol]
|
50
|
+
# @return [Vedeu::Colours::Translator]
|
51
|
+
def initialize(colour = '')
|
52
|
+
@colour = colour || ''
|
53
|
+
end
|
54
|
+
|
55
|
+
# @return [Boolean]
|
56
|
+
def empty?
|
57
|
+
colour.nil? || colour.to_s.empty?
|
58
|
+
end
|
59
|
+
|
60
|
+
# An object is equal when its values are the same.
|
61
|
+
#
|
62
|
+
# @param other [Vedeu::Views::Char]
|
63
|
+
# @return [Boolean]
|
64
|
+
def eql?(other)
|
65
|
+
self.class == other.class && colour == other.colour
|
66
|
+
end
|
67
|
+
alias_method :==, :eql?
|
68
|
+
|
69
|
+
# @return [String]
|
70
|
+
# @see Vedeu::Colours::Translator
|
71
|
+
def escape_sequence
|
72
|
+
if empty?
|
73
|
+
''
|
74
|
+
|
75
|
+
elsif registered?(colour)
|
76
|
+
retrieve(colour)
|
77
|
+
|
78
|
+
elsif rgb?
|
79
|
+
rgb
|
80
|
+
|
81
|
+
elsif numbered?
|
82
|
+
numbered
|
83
|
+
|
84
|
+
elsif named?
|
85
|
+
named
|
86
|
+
|
87
|
+
else
|
88
|
+
''
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
92
|
+
alias_method :to_s, :escape_sequence
|
93
|
+
alias_method :to_str, :escape_sequence
|
94
|
+
|
95
|
+
# @return [String]
|
96
|
+
def to_html
|
97
|
+
return colour if rgb?
|
98
|
+
|
99
|
+
''
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
# Retrieves the escape sequence for the HTML/CSS colour code.
|
105
|
+
#
|
106
|
+
# @param colour [String]
|
107
|
+
# @return [String]
|
108
|
+
def retrieve(colour)
|
109
|
+
repository.retrieve(colour)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Registers a HTML/CSS colour code and escape sequence to reduce
|
113
|
+
# processing.
|
114
|
+
#
|
115
|
+
# @param colour [String] A HTML/CSS colour code.
|
116
|
+
# @param escape_sequence [String] The HTML/CSS colour code as an escape
|
117
|
+
# sequence.
|
118
|
+
# @return [String]
|
119
|
+
def register(colour, escape_sequence)
|
120
|
+
repository.register(colour, escape_sequence)
|
121
|
+
end
|
122
|
+
|
123
|
+
# Returns a boolean indicating the HTML/CSS colour code has been
|
124
|
+
# registered.
|
125
|
+
#
|
126
|
+
# @param colour [String]
|
127
|
+
# @return [Boolean]
|
128
|
+
def registered?(colour)
|
129
|
+
repository.registered?(colour)
|
130
|
+
end
|
131
|
+
|
132
|
+
# @return [Boolean]
|
133
|
+
def named?
|
134
|
+
colour.is_a?(Symbol) && valid_name?
|
135
|
+
end
|
136
|
+
|
137
|
+
# Returns an escape sequence for a named background colour.
|
138
|
+
#
|
139
|
+
# @note
|
140
|
+
# Valid names can be found at {Vedeu::Esc#codes}
|
141
|
+
#
|
142
|
+
# @return [String]
|
143
|
+
def named
|
144
|
+
"\e[#{named_codes}m"
|
145
|
+
end
|
146
|
+
|
147
|
+
# Returns a boolean indicating whether the colour provided is a valid
|
148
|
+
# named colour.
|
149
|
+
#
|
150
|
+
# @return [Boolean]
|
151
|
+
def valid_name?
|
152
|
+
Vedeu::Esc.codes.keys.include?(colour)
|
153
|
+
end
|
154
|
+
|
155
|
+
# Returns a boolean indicating whether the colour provided is a terminal
|
156
|
+
# numbered colour.
|
157
|
+
#
|
158
|
+
# @return [Boolean]
|
159
|
+
def numbered?
|
160
|
+
colour.is_a?(Fixnum) && valid_range?
|
161
|
+
end
|
162
|
+
|
163
|
+
# Returns an escape sequence.
|
164
|
+
#
|
165
|
+
# @return [String]
|
166
|
+
def numbered
|
167
|
+
"#{numbered_prefix}#{css_to_numbered}m"
|
168
|
+
end
|
169
|
+
|
170
|
+
# Returns a boolean indicated whether the colour is a valid HTML/CSS
|
171
|
+
# colour.
|
172
|
+
#
|
173
|
+
# @return [Boolean]
|
174
|
+
def rgb?
|
175
|
+
return true if colour =~ /^#([A-Fa-f0-9]{6})$/
|
176
|
+
|
177
|
+
false
|
178
|
+
end
|
179
|
+
|
180
|
+
# Returns an escape sequence.
|
181
|
+
#
|
182
|
+
# @return [String]
|
183
|
+
def rgb
|
184
|
+
if Vedeu::Configuration.colour_mode == 16_777_216
|
185
|
+
register(colour, format(rgb_prefix, *css_to_rgb))
|
186
|
+
|
187
|
+
else
|
188
|
+
numbered
|
189
|
+
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
# Returns a boolean indicating whether the numbered colour is within the
|
194
|
+
# range of valid terminal numbered colours.
|
195
|
+
#
|
196
|
+
# @return [Boolean]
|
197
|
+
def valid_range?
|
198
|
+
colour >= 0 && colour <= 255
|
199
|
+
end
|
200
|
+
|
201
|
+
# Returns a collection of converted HTML/CSS octets as their decimal
|
202
|
+
# equivalents.
|
203
|
+
#
|
204
|
+
# @example
|
205
|
+
# colour = '#aadd55'
|
206
|
+
# css_to_rgb # => [170, 221, 85]
|
207
|
+
#
|
208
|
+
# @return [Array]
|
209
|
+
def css_to_rgb
|
210
|
+
[
|
211
|
+
colour[1..2].to_i(16),
|
212
|
+
colour[3..4].to_i(16),
|
213
|
+
colour[5..6].to_i(16),
|
214
|
+
]
|
215
|
+
end
|
216
|
+
|
217
|
+
# @return [Fixnum]
|
218
|
+
def css_to_numbered
|
219
|
+
if rgb?
|
220
|
+
[16, red, green, blue].inject(:+)
|
221
|
+
|
222
|
+
elsif numbered?
|
223
|
+
colour
|
224
|
+
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
# Takes the red component of {#css_to_rgb} and converts to the correct
|
229
|
+
# value for setting the terminal red value.
|
230
|
+
#
|
231
|
+
# @return [Fixnum]
|
232
|
+
def red
|
233
|
+
(css_to_rgb[0] / 51) * 36
|
234
|
+
end
|
235
|
+
|
236
|
+
# Takes the green component of {#css_to_rgb} and converts to the correct
|
237
|
+
# value for setting the terminal green value.
|
238
|
+
#
|
239
|
+
# @return [Fixnum]
|
240
|
+
def green
|
241
|
+
(css_to_rgb[1] / 51) * 6
|
242
|
+
end
|
243
|
+
|
244
|
+
# Takes the blue component of {#css_to_rgb} and converts to the correct
|
245
|
+
# value for setting the terminal blue value.
|
246
|
+
#
|
247
|
+
# @return [Fixnum]
|
248
|
+
def blue
|
249
|
+
(css_to_rgb[2] / 51) * 1
|
250
|
+
end
|
251
|
+
|
252
|
+
# @raise [Vedeu::Error::NotImplemented] Subclasses of this class must
|
253
|
+
# implement this method.
|
254
|
+
# @return [Vedeu::Error::NotImplemented]
|
255
|
+
def not_implemented
|
256
|
+
fail Vedeu::Error::NotImplemented, 'Subclasses implement this.'
|
257
|
+
end
|
258
|
+
alias_method :named_codes, :not_implemented
|
259
|
+
alias_method :numbered_prefix, :not_implemented
|
260
|
+
alias_method :repository, :not_implemented
|
261
|
+
alias_method :rgb_prefix, :not_implemented
|
262
|
+
|
263
|
+
end # Translator
|
264
|
+
|
265
|
+
end # Colours
|
266
|
+
|
267
|
+
end # Vedeu
|
@@ -250,12 +250,15 @@ module Vedeu
|
|
250
250
|
# the colour mode at all and allow it to be detected, or use 256 here.
|
251
251
|
#
|
252
252
|
# @param value [Fixnum]
|
253
|
-
# @raise [Vedeu::InvalidSyntax] When the value parameter is not one
|
254
|
-
# +8+, +16+, +256+ or +16777216+.
|
253
|
+
# @raise [Vedeu::Error::InvalidSyntax] When the value parameter is not one
|
254
|
+
# of +8+, +16+, +256+ or +16777216+.
|
255
255
|
# @return [Boolean]
|
256
256
|
def colour_mode(value = nil)
|
257
|
-
|
258
|
-
|
257
|
+
unless valid_colour_mode?(value)
|
258
|
+
fail Vedeu::Error::InvalidSyntax,
|
259
|
+
'`colour_mode` must be `8`, `16`, `256`, `16777216`.'
|
260
|
+
end
|
261
|
+
|
259
262
|
options[:colour_mode] = value
|
260
263
|
end
|
261
264
|
|
@@ -422,8 +425,8 @@ module Vedeu
|
|
422
425
|
# end
|
423
426
|
#
|
424
427
|
# @param mode [Symbol] Either ':cooked', ':fake' or ':raw'.
|
425
|
-
# @raise [Vedeu::InvalidSyntax] When the mode is not ':cooked',
|
426
|
-
# ':raw'.
|
428
|
+
# @raise [Vedeu::Error::InvalidSyntax] When the mode is not ':cooked',
|
429
|
+
# ':fake' or ':raw'.
|
427
430
|
# @return [Symbol]
|
428
431
|
# @see Vedeu::Config::API#cooked!
|
429
432
|
# @see Vedeu::Config::API#fake!
|
@@ -433,7 +436,7 @@ module Vedeu
|
|
433
436
|
options[:terminal_mode] = mode
|
434
437
|
|
435
438
|
else
|
436
|
-
fail Vedeu::InvalidSyntax,
|
439
|
+
fail Vedeu::Error::InvalidSyntax,
|
437
440
|
'Terminal mode can be set to either :cooked, :fake or :raw'
|
438
441
|
|
439
442
|
end
|