colours 0.5.55
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of colours might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/LICENCE.md +22 -0
- data/README.md +890 -0
- data/bin/colours +7 -0
- data/bin/html_colour_to_hex_value +7 -0
- data/bin/html_colourize +7 -0
- data/bin/print_rainbow_line +7 -0
- data/bin/rainbow_colours +7 -0
- data/bin/remove_ansii_escape_sequences +7 -0
- data/colours.gemspec +76 -0
- data/doc/COLOUR_CODES_CHART.md +28 -0
- data/doc/HOW_TO_PICK_YOUR_OWN_COLOURS.md +29 -0
- data/doc/README.gen +862 -0
- data/lib/colours/256_colours/support_for_256_colours.rb +180 -0
- data/lib/colours/autoalias_e.rb +10 -0
- data/lib/colours/autogenerated/README.md +2 -0
- data/lib/colours/autogenerated/support_for_256_colours.rb +2235 -0
- data/lib/colours/autogenerated/support_for_html_colours.rb +1778 -0
- data/lib/colours/autogenerated/toplevel_basic_colour_methods.rb +6366 -0
- data/lib/colours/autoinclude.rb +14 -0
- data/lib/colours/base/base.rb +23 -0
- data/lib/colours/basic_colours/README.md +4 -0
- data/lib/colours/basic_colours/basic_colours.rb +279 -0
- data/lib/colours/colour_methods/README.md +11 -0
- data/lib/colours/colour_methods/default_colour.rb +66 -0
- data/lib/colours/colour_methods/sargument.rb +70 -0
- data/lib/colours/colour_methods/scomments.rb +105 -0
- data/lib/colours/colour_methods/sdir.rb +66 -0
- data/lib/colours/colour_methods/sfancy.rb +84 -0
- data/lib/colours/colour_methods/sfile.rb +71 -0
- data/lib/colours/colour_methods/simportant.rb +92 -0
- data/lib/colours/colour_methods/snormal.rb +66 -0
- data/lib/colours/colour_methods/ssymlink.rb +102 -0
- data/lib/colours/colour_methods/swarn.rb +76 -0
- data/lib/colours/colour_table/README.md +3 -0
- data/lib/colours/colour_table/colour_table.rb +275 -0
- data/lib/colours/colours_e_autoinclude.rb +9 -0
- data/lib/colours/commandline/README.md +2 -0
- data/lib/colours/commandline/commandline.rb +44 -0
- data/lib/colours/commandline/menu.rb +111 -0
- data/lib/colours/constants/colour_constants.rb +299 -0
- data/lib/colours/constants/file_constants.rb +72 -0
- data/lib/colours/constants/hash_simple_colours.rb +146 -0
- data/lib/colours/constants/misc.rb +59 -0
- data/lib/colours/constants/newline.rb +14 -0
- data/lib/colours/constants/registered_colour_methods.rb +53 -0
- data/lib/colours/e/README.md +13 -0
- data/lib/colours/e/autoinclude.rb +11 -0
- data/lib/colours/e/e.rb +35 -0
- data/lib/colours/e.rb +5 -0
- data/lib/colours/eparse/eparse.rb +77 -0
- data/lib/colours/everything/autoinclude.rb +11 -0
- data/lib/colours/html_colours/README.md +1 -0
- data/lib/colours/html_colours/add_html_colours_onto_the_toplevel_namespace.rb +22 -0
- data/lib/colours/html_colours/hash_html_colours.rb +63 -0
- data/lib/colours/html_colours/html_colourize.rb +48 -0
- data/lib/colours/html_colours/is_this_html_colour_included.rb +64 -0
- data/lib/colours/html_colours/misc.rb +186 -0
- data/lib/colours/html_colours/show_html_colours.rb +85 -0
- data/lib/colours/kde_colour_palette/kde_colour_palette.rb +128 -0
- data/lib/colours/map_symbol_to_corresponding_colour/map_symbol_to_corresponding_colour.rb +219 -0
- data/lib/colours/module.rb +11 -0
- data/lib/colours/project/project_base_directory.rb +22 -0
- data/lib/colours/rainbow_colours/README.md +2 -0
- data/lib/colours/rainbow_colours/check_for_trollop_being_available_or_exit.rb +26 -0
- data/lib/colours/rainbow_colours/constants.rb +30 -0
- data/lib/colours/rainbow_colours/do_parse_via_rainbow_colours.rb +164 -0
- data/lib/colours/rainbow_colours/paint_detected_mode.rb +20 -0
- data/lib/colours/rainbow_colours/print_rainbow_line.rb +68 -0
- data/lib/colours/rainbow_colours/println_ani.rb +32 -0
- data/lib/colours/rainbow_colours/println_plain.rb +36 -0
- data/lib/colours/rainbow_colours/rainbow.rb +38 -0
- data/lib/colours/rainbow_colours/report_errors.rb +32 -0
- data/lib/colours/rainbow_colours/returnln_plain.rb +63 -0
- data/lib/colours/rainbow_colours/set_mode.rb +24 -0
- data/lib/colours/requires/require_all_colour_methods.rb +5 -0
- data/lib/colours/requires/require_commandline.rb +7 -0
- data/lib/colours/requires/require_eparse.rb +11 -0
- data/lib/colours/requires/require_rgb.rb +5 -0
- data/lib/colours/requires/require_sdir.rb +5 -0
- data/lib/colours/requires/require_sfile.rb +5 -0
- data/lib/colours/requires/require_the_256_colours_module.rb +16 -0
- data/lib/colours/requires/require_the_basic_colours.rb +7 -0
- data/lib/colours/requires/require_the_colour_methods.rb +34 -0
- data/lib/colours/requires/require_the_colour_table.rb +7 -0
- data/lib/colours/requires/require_the_colours_project.rb +52 -0
- data/lib/colours/requires/require_the_constants.rb +11 -0
- data/lib/colours/requires/require_the_html_colours.rb +11 -0
- data/lib/colours/requires/require_the_kde_colour_palette.rb +7 -0
- data/lib/colours/requires/require_the_toplevel_methods.rb +42 -0
- data/lib/colours/revert/revert.rb +106 -0
- data/lib/colours/rgb/rgb.rb +547 -0
- data/lib/colours/testing/README.md +2 -0
- data/lib/colours/testing/testing.rb +157 -0
- data/lib/colours/toplevel_methods/bold.rb +35 -0
- data/lib/colours/toplevel_methods/bold_and_italic.rb +36 -0
- data/lib/colours/toplevel_methods/cat.rb +39 -0
- data/lib/colours/toplevel_methods/clear_screen.rb +18 -0
- data/lib/colours/toplevel_methods/cliner.rb +19 -0
- data/lib/colours/toplevel_methods/col.rb +56 -0
- data/lib/colours/toplevel_methods/e.rb +63 -0
- data/lib/colours/toplevel_methods/esystem.rb +19 -0
- data/lib/colours/toplevel_methods/fancy_parse.rb +79 -0
- data/lib/colours/toplevel_methods/html_colourize.rb +64 -0
- data/lib/colours/toplevel_methods/is_on_roebe.rb +16 -0
- data/lib/colours/toplevel_methods/italic.rb +104 -0
- data/lib/colours/toplevel_methods/make_colour.rb +29 -0
- data/lib/colours/toplevel_methods/methods_related_to_html_colours.rb +325 -0
- data/lib/colours/toplevel_methods/misc.rb +129 -0
- data/lib/colours/toplevel_methods/open_this_file.rb +26 -0
- data/lib/colours/toplevel_methods/prefer_this_colour_schemata.rb +80 -0
- data/lib/colours/toplevel_methods/random_html_colour.rb +44 -0
- data/lib/colours/toplevel_methods/random_value.rb +37 -0
- data/lib/colours/toplevel_methods/remove_escape_sequence.rb +112 -0
- data/lib/colours/toplevel_methods/set_last_colour_used.rb +32 -0
- data/lib/colours/toplevel_methods/show_basic_colour_palette.rb +36 -0
- data/lib/colours/toplevel_methods/underline.rb +114 -0
- data/lib/colours/toplevel_methods/use_colours.rb +290 -0
- data/lib/colours/utility_scripts/README.md +2 -0
- data/lib/colours/utility_scripts/autogenerate.rb +291 -0
- data/lib/colours/version/version.rb +25 -0
- data/lib/colours/yaml/256_colours.yml +277 -0
- data/lib/colours/yaml/basic_colours.yml +23 -0
- data/lib/colours/yaml/html_colours.yml +835 -0
- data/lib/colours/yaml/kde_colour_palette.yml +183 -0
- data/lib/colours/yaml/prefer_this_colour_schemata.yml +15 -0
- data/lib/colours/yaml/use_these_values_for_the_colour_methods.yml +13 -0
- data/lib/colours.rb +5 -0
- data/test/test.html +18 -0
- data/test/testing_256_colours_support.rb +29 -0
- data/test/testing_col.rb +10 -0
- data/test/testing_colours.rb +95 -0
- data/test/testing_colours_e.rb +13 -0
- data/test/testing_eparse.rb +13 -0
- data/test/testing_kde_colour_palette.rb +30 -0
- data/test/testing_konsole_submodule.rb +226 -0
- data/test/testing_map_symbol_to_corresponding_colour.rb +14 -0
- data/test/testing_rgb_to_hex.rb +32 -0
- data/test/testing_the_basic_colours_of_the_colours_project.rb +58 -0
- data/test/testing_the_colour_methods.rb +36 -0
- data/test/testing_the_constants_of_the_colours_project.rb +9 -0
- data/test/testing_the_html_colours_of_the_colours_project.rb +37 -0
- data/test/testing_whether_colours_will_be_used.rb +7 -0
- metadata +226 -0
@@ -0,0 +1,290 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'colours/toplevel_methods/use_colours.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
module Colours
|
8
|
+
|
9
|
+
require 'colours/toplevel_methods/set_last_colour_used.rb'
|
10
|
+
|
11
|
+
# ========================================================================= #
|
12
|
+
# === @use_colours
|
13
|
+
#
|
14
|
+
# Whether we will use colours or whether we will not. This can be
|
15
|
+
# used to globally disable colours in every project using the
|
16
|
+
# Colours gem.
|
17
|
+
# ========================================================================= #
|
18
|
+
@use_colours = true
|
19
|
+
|
20
|
+
# ========================================================================= #
|
21
|
+
# === @use_html_colours
|
22
|
+
#
|
23
|
+
# This is a separate variable so that we can selectively disable or
|
24
|
+
# enable the colours for the Konsole submodule. Some terminals do
|
25
|
+
# not respond nicely to the R,G,B values that the Konsole submodule
|
26
|
+
# may require.
|
27
|
+
# ========================================================================= #
|
28
|
+
@use_html_colours = true
|
29
|
+
|
30
|
+
# ========================================================================= #
|
31
|
+
# === Colours.use_colours?
|
32
|
+
#
|
33
|
+
# Use this method to find out whether we wish to use colours or
|
34
|
+
# whether we do not.
|
35
|
+
# ========================================================================= #
|
36
|
+
def self.use_colours?
|
37
|
+
@use_colours
|
38
|
+
end
|
39
|
+
|
40
|
+
# ========================================================================= #
|
41
|
+
# === Colours.enable_html_colours
|
42
|
+
#
|
43
|
+
# Use this method to specifically enable konsole-colours.
|
44
|
+
# ========================================================================= #
|
45
|
+
def self.enable_html_colours
|
46
|
+
@use_html_colours = true
|
47
|
+
end; self.instance_eval { alias enable_konsole_colours enable_html_colours } # === Colours.enable_konsole_colours
|
48
|
+
|
49
|
+
# ========================================================================= #
|
50
|
+
# === Colours.disable_konsole_colours
|
51
|
+
#
|
52
|
+
# Disable the KDE-Konsole colours.
|
53
|
+
# ========================================================================= #
|
54
|
+
def self.disable_konsole_colours
|
55
|
+
@use_html_colours = false
|
56
|
+
end
|
57
|
+
|
58
|
+
# ========================================================================= #
|
59
|
+
# === Colours.use_html_colours?
|
60
|
+
#
|
61
|
+
# Query whether we will use the HTML colours or whether we will not.
|
62
|
+
# ========================================================================= #
|
63
|
+
def self.use_html_colours?
|
64
|
+
@use_html_colours
|
65
|
+
end; self.instance_eval { alias use_konsole? use_html_colours? } # === Colours.use_konsole?
|
66
|
+
self.instance_eval { alias use_konsole_colours? use_html_colours? } # === Colours.use_konsole_colours??
|
67
|
+
|
68
|
+
# ========================================================================= #
|
69
|
+
# === Colours.disable_colours
|
70
|
+
#
|
71
|
+
# This method can be used to disable the colours on the Colours
|
72
|
+
# namespace.
|
73
|
+
# ========================================================================= #
|
74
|
+
def self.disable_colours(
|
75
|
+
be_verbose = false
|
76
|
+
)
|
77
|
+
puts 'Disabling colours next.' if be_verbose
|
78
|
+
@use_colours = false
|
79
|
+
end; self.instance_eval { alias disable disable_colours } # === Colours.disable
|
80
|
+
|
81
|
+
# ========================================================================= #
|
82
|
+
# === Colours.enable_colours
|
83
|
+
#
|
84
|
+
# Use this method to enable colours for the whole Colours namespace.
|
85
|
+
# ========================================================================= #
|
86
|
+
def self.enable_colours(
|
87
|
+
be_verbose = false
|
88
|
+
)
|
89
|
+
puts 'Enabling colours next.' if be_verbose
|
90
|
+
@use_colours = true # Defined below.
|
91
|
+
end; self.instance_eval { alias enable enable_colours } # === Colours.enable
|
92
|
+
|
93
|
+
# ========================================================================= #
|
94
|
+
# === Colours.use_colours=
|
95
|
+
#
|
96
|
+
# Determine whether we will use colours or whether we will not.
|
97
|
+
#
|
98
|
+
# The first input argument to this method should be a Bool, such
|
99
|
+
# as true or false.
|
100
|
+
# ========================================================================= #
|
101
|
+
def self.use_colours=(
|
102
|
+
new_value = true
|
103
|
+
)
|
104
|
+
@use_colours = new_value
|
105
|
+
end; self.instance_eval { alias set_use_colours use_colours= } # === Colours.set_use_colours
|
106
|
+
|
107
|
+
# ========================================================================= #
|
108
|
+
# === use_colours?
|
109
|
+
#
|
110
|
+
# Delegate towards the class-method here. Unsure whether this method
|
111
|
+
# is really needed, but let's keep it for now. After all we can
|
112
|
+
# use "include Colours" to add that method.
|
113
|
+
# ========================================================================= #
|
114
|
+
def use_colours?
|
115
|
+
Colours.use_colours?
|
116
|
+
end
|
117
|
+
|
118
|
+
# ========================================================================= #
|
119
|
+
# === Colours.report_whether_colours_will_be_used
|
120
|
+
# ========================================================================= #
|
121
|
+
def self.report_whether_colours_will_be_used
|
122
|
+
if @use_colours
|
123
|
+
puts 'Yes, colours will be used.'
|
124
|
+
else
|
125
|
+
puts 'Colours are currently disabled.'
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# =========================================================================== #
|
130
|
+
# This file includes a standalone Colour class, as part of the
|
131
|
+
# Colours namespace.
|
132
|
+
# =========================================================================== #
|
133
|
+
class Colour # === Colours::Colour
|
134
|
+
|
135
|
+
# ========================================================================= #
|
136
|
+
# === initialize
|
137
|
+
# ========================================================================= #
|
138
|
+
def initialize(
|
139
|
+
optional_input = nil
|
140
|
+
)
|
141
|
+
reset
|
142
|
+
set_input(optional_input) if optional_input
|
143
|
+
end
|
144
|
+
|
145
|
+
# ========================================================================= #
|
146
|
+
# === set_r
|
147
|
+
# ========================================================================= #
|
148
|
+
def set_r(i = nil)
|
149
|
+
@r = i
|
150
|
+
end
|
151
|
+
|
152
|
+
# ========================================================================= #
|
153
|
+
# === set_g
|
154
|
+
# ========================================================================= #
|
155
|
+
def set_g(i = nil)
|
156
|
+
@g = i
|
157
|
+
end
|
158
|
+
|
159
|
+
# ========================================================================= #
|
160
|
+
# === set_b
|
161
|
+
# ========================================================================= #
|
162
|
+
def set_b(i = nil)
|
163
|
+
@b = i
|
164
|
+
end
|
165
|
+
|
166
|
+
# ========================================================================= #
|
167
|
+
# === random_colour?
|
168
|
+
# ========================================================================= #
|
169
|
+
def random_colour?(
|
170
|
+
optional_text = nil
|
171
|
+
)
|
172
|
+
if optional_text
|
173
|
+
write_this_in_random_colour(optional_text)
|
174
|
+
else
|
175
|
+
::Colours.random_colour?
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
# ========================================================================= #
|
180
|
+
# === set_rgb
|
181
|
+
# ========================================================================= #
|
182
|
+
def set_rgb(r,g,b)
|
183
|
+
set_r(r)
|
184
|
+
set_g(g)
|
185
|
+
set_b(b)
|
186
|
+
end
|
187
|
+
|
188
|
+
# ========================================================================= #
|
189
|
+
# === set_input
|
190
|
+
# ========================================================================= #
|
191
|
+
def set_input(i = nil)
|
192
|
+
@input = i
|
193
|
+
end
|
194
|
+
|
195
|
+
# ========================================================================= #
|
196
|
+
# === reset
|
197
|
+
# ========================================================================= #
|
198
|
+
def reset
|
199
|
+
set_r
|
200
|
+
set_g
|
201
|
+
set_b
|
202
|
+
end
|
203
|
+
|
204
|
+
# ========================================================================= #
|
205
|
+
# === r?
|
206
|
+
# ========================================================================= #
|
207
|
+
def r?
|
208
|
+
@r
|
209
|
+
end
|
210
|
+
|
211
|
+
# ========================================================================= #
|
212
|
+
# === g?
|
213
|
+
# ========================================================================= #
|
214
|
+
def g?
|
215
|
+
@g
|
216
|
+
end
|
217
|
+
|
218
|
+
# ========================================================================= #
|
219
|
+
# === b?
|
220
|
+
# ========================================================================= #
|
221
|
+
def b?
|
222
|
+
@b
|
223
|
+
end
|
224
|
+
|
225
|
+
# ========================================================================= #
|
226
|
+
# === output_this_string
|
227
|
+
# ========================================================================= #
|
228
|
+
def output_this_string(
|
229
|
+
i = DEFAULT_TEXT+N,
|
230
|
+
r = r?,
|
231
|
+
g = g?,
|
232
|
+
b = b?
|
233
|
+
)
|
234
|
+
result = return_this_string(i,r,g,b)
|
235
|
+
e result
|
236
|
+
end; alias output_this output_this_string # === output_this
|
237
|
+
alias output output_this_string # === output
|
238
|
+
alias write_this_in_random_colour output_this_string # === write_this_in_random_colour
|
239
|
+
|
240
|
+
# ========================================================================= #
|
241
|
+
# === return_this_string
|
242
|
+
# ========================================================================= #
|
243
|
+
def return_this_string(
|
244
|
+
i = DEFAULT_TEXT+N,
|
245
|
+
r = r?,
|
246
|
+
g = g?,
|
247
|
+
b = b?
|
248
|
+
)
|
249
|
+
i = DEFAULT_TEXT if i == :default
|
250
|
+
i = i.join(' ') if i.is_a? Array
|
251
|
+
i = i.to_s.dup
|
252
|
+
i = build_this_rgb_string(r, g, b)+i
|
253
|
+
return i
|
254
|
+
end
|
255
|
+
|
256
|
+
# ========================================================================= #
|
257
|
+
# === build_this_rgb_string
|
258
|
+
# ========================================================================= #
|
259
|
+
def build_this_rgb_string(r, g, b)
|
260
|
+
Colours.build_this_rgb_string(r,g,b)
|
261
|
+
end
|
262
|
+
|
263
|
+
# ========================================================================= #
|
264
|
+
# === random_colour
|
265
|
+
#
|
266
|
+
# Return a random colour here.
|
267
|
+
# ========================================================================= #
|
268
|
+
def random_colour(this_string_to_display = 'test')
|
269
|
+
return_this_string(
|
270
|
+
this_string_to_display, random_value, random_value, random_value
|
271
|
+
)
|
272
|
+
end; alias return_random_colour random_colour # === return_random_colour
|
273
|
+
|
274
|
+
# ========================================================================= #
|
275
|
+
# === seed_rgb_values
|
276
|
+
#
|
277
|
+
# Use this method to randomly obtain R,G,B values.
|
278
|
+
# ========================================================================= #
|
279
|
+
def seed_rgb_values
|
280
|
+
set_rgb(random_value, random_value, random_value)
|
281
|
+
end
|
282
|
+
|
283
|
+
# ========================================================================= #
|
284
|
+
# === random_value
|
285
|
+
# ========================================================================= #
|
286
|
+
def random_value
|
287
|
+
rand(255)
|
288
|
+
end
|
289
|
+
|
290
|
+
end; end
|
@@ -0,0 +1,291 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# This file contains code that can be used to autogenerate ruby code,
|
6
|
+
# and store this into a .rb file. That functionality is mostly useful
|
7
|
+
# on my home system, though.
|
8
|
+
# =========================================================================== #
|
9
|
+
# require 'colours/utility_scripts/autogenerate.rb'
|
10
|
+
# =========================================================================== #
|
11
|
+
module Colours
|
12
|
+
|
13
|
+
require 'colours/constants/file_constants.rb'
|
14
|
+
require 'colours/constants/newline.rb'
|
15
|
+
require 'colours/256_colours/support_for_256_colours.rb'
|
16
|
+
require 'colours/toplevel_methods/is_on_roebe.rb'
|
17
|
+
require 'colours/toplevel_methods/html_colourize.rb'
|
18
|
+
require 'colours/html_colours/misc.rb'
|
19
|
+
|
20
|
+
# ========================================================================= #
|
21
|
+
# === GENERIC_RUBY_HEADER
|
22
|
+
# ========================================================================= #
|
23
|
+
GENERIC_RUBY_HEADER = "#!/usr/bin/ruby -w
|
24
|
+
# Encoding: UTF-8
|
25
|
+
# frozen_string_literal: true
|
26
|
+
# =========================================================================== #"
|
27
|
+
|
28
|
+
# ========================================================================= #
|
29
|
+
# === Colours.return_a_unique_array_containing_all_available_colours
|
30
|
+
# ========================================================================= #
|
31
|
+
def self.return_a_unique_array_containing_all_available_colours
|
32
|
+
array = []
|
33
|
+
array << YAML.load_file(FILE_HTML_COLOURS).keys # (1) First the HTML colours
|
34
|
+
array << YAML.load_file(FILE_256_COLOURS).keys.map(&:downcase) # (2) Then the basic colours
|
35
|
+
array << YAML.load_file(FILE_BASIC_COLOURS) # (3) And finally the basic colours
|
36
|
+
array.flatten!
|
37
|
+
array.uniq!
|
38
|
+
array.map!(&:strip)
|
39
|
+
array.sort
|
40
|
+
end; self.instance_eval { alias all_available_colour_methods? return_a_unique_array_containing_all_available_colours } # === Colours.all_available_colour_methods?
|
41
|
+
|
42
|
+
# ========================================================================= #
|
43
|
+
# === Colours.generate_shell_file_containing_the_html_colours
|
44
|
+
#
|
45
|
+
# This method will generate a shell file into the current directory
|
46
|
+
# by default.
|
47
|
+
#
|
48
|
+
# The code in that file will generate a shell script that holds all
|
49
|
+
# the HTML-colours, via UPCASED names.
|
50
|
+
#
|
51
|
+
# These entries will then look like this:
|
52
|
+
#
|
53
|
+
# SADDLEBROWN: "\e[38;2;139;69;19m"
|
54
|
+
# PERU: "\e[38;2;205;133;63m"
|
55
|
+
# CHOCOLATE: "\e[38;2;210;105;30m"
|
56
|
+
#
|
57
|
+
# ========================================================================= #
|
58
|
+
def self.generate_shell_file_containing_the_html_colours(
|
59
|
+
generate_the_shell_file_into_this_directory = Dir.pwd
|
60
|
+
)
|
61
|
+
require 'save_file/module'
|
62
|
+
unless generate_the_shell_file_into_this_directory.end_with? '/'
|
63
|
+
if generate_the_shell_file_into_this_directory.frozen?
|
64
|
+
generate_the_shell_file_into_this_directory = generate_the_shell_file_into_this_directory.dup
|
65
|
+
end
|
66
|
+
generate_the_shell_file_into_this_directory << '/'
|
67
|
+
end
|
68
|
+
result = ''.dup
|
69
|
+
result << "# This is a shell file that contains the HTML colours\n"
|
70
|
+
::Colours.html_colours?.each {|this_colour|
|
71
|
+
colour_code_to_use = ::Colours.html_colourize(this_colour.to_sym,'',false).inspect
|
72
|
+
result << "export #{this_colour.upcase}=#{colour_code_to_use}\n"
|
73
|
+
}
|
74
|
+
generate_the_shell_file_into_this_directory << 'shell_file_containing_the_html_colours.sh'
|
75
|
+
into = generate_the_shell_file_into_this_directory
|
76
|
+
e "Now creating a shell file at `#{into}`."
|
77
|
+
SaveFile.write_what_into(result, into)
|
78
|
+
# ======================================================================= #
|
79
|
+
# Generate files on my home system as well:
|
80
|
+
# ======================================================================= #
|
81
|
+
if is_on_roebe?
|
82
|
+
into = '/home/x/DATA/PROGRAMMING_LANGUAGES/RUBY/src/'\
|
83
|
+
'roebe/lib/roebe/shell_scripts/'+
|
84
|
+
File.basename(generate_the_shell_file_into_this_directory)
|
85
|
+
puts "And also saving into `#{into}`."
|
86
|
+
SaveFile.write_what_into(result, into)
|
87
|
+
end
|
88
|
+
end; self.instance_eval { alias autogenerate_shell_file_containing_the_html_colours generate_shell_file_containing_the_html_colours } # === Colours.autogenerate_shell_file_containing_the_html_colours
|
89
|
+
|
90
|
+
# ========================================================================= #
|
91
|
+
# === Colours.autogenerate_the_module_for_the_256_colours
|
92
|
+
#
|
93
|
+
# This method will autogenerate the module that will support
|
94
|
+
# the 256 colours.
|
95
|
+
# ========================================================================= #
|
96
|
+
def self.autogenerate_the_module_for_the_256_colours
|
97
|
+
_ = ''.dup
|
98
|
+
_ << GENERIC_RUBY_HEADER+"
|
99
|
+
# require 'colours/autogenerated/support_for_256_colours.rb'
|
100
|
+
# =========================================================================== #
|
101
|
+
"
|
102
|
+
_ << "require 'colours/256_colours/support_for_256_colours.rb'\n\n"
|
103
|
+
_ << "module Colours\n\n"
|
104
|
+
_ << "module SupportFor256Colours # include Colours::SupportFor256Colours\n\n".dup
|
105
|
+
comment_line = ' # '+('='*73)+' #'+N
|
106
|
+
@dataset_for_the_256_colours.each {|name_of_the_colour, id|
|
107
|
+
use_this_name = name_of_the_colour.downcase
|
108
|
+
_ << comment_line
|
109
|
+
_ << ' # === Colours::SupportFor256Colours.'+use_this_name+N
|
110
|
+
_ << comment_line
|
111
|
+
_ << " def self.#{use_this_name}(i = '')#{N}"
|
112
|
+
_ << " if Colours.use_colours?\n"
|
113
|
+
_ << " Colours.return_this_256_colour(__method__, i)\n"
|
114
|
+
_ << " else\n"
|
115
|
+
_ << " i\n"
|
116
|
+
_ << " end\n"
|
117
|
+
_ << " end; def #{use_this_name}(i = ''); SupportFor256Colours.#{use_this_name}(i); end#{N}#{N}"
|
118
|
+
}
|
119
|
+
_ << 'end; end'
|
120
|
+
what = _
|
121
|
+
# ======================================================================= #
|
122
|
+
# This is only useful on my home system really:
|
123
|
+
# ======================================================================= #
|
124
|
+
into = HOME_DIRECTORY_OF_USER_X+'DATA/PROGRAMMING_LANGUAGES/RUBY/src/'\
|
125
|
+
'colours/lib/colours/autogenerated/support_for_256_colours.rb'
|
126
|
+
puts 'Storing into:'
|
127
|
+
puts
|
128
|
+
puts ' '+into
|
129
|
+
puts
|
130
|
+
require 'save_file'
|
131
|
+
SaveFile.write_what_into(what, into)
|
132
|
+
end
|
133
|
+
|
134
|
+
# ========================================================================= #
|
135
|
+
# === Colours.autogenerate_the_module_for_the_html_colours
|
136
|
+
#
|
137
|
+
# This method will autogenerate the module that will support
|
138
|
+
# the html colours.
|
139
|
+
# ========================================================================= #
|
140
|
+
def self.autogenerate_the_module_for_the_html_colours(
|
141
|
+
into = HOME_DIRECTORY_OF_USER_X+'DATA/PROGRAMMING_LANGUAGES/RUBY/src/'\
|
142
|
+
'colours/lib/colours/autogenerated/support_for_html_colours.rb'
|
143
|
+
)
|
144
|
+
_ = ''.dup
|
145
|
+
_ << GENERIC_RUBY_HEADER+"
|
146
|
+
# require 'colours/autogenerated/support_for_html_colours.rb'
|
147
|
+
# =========================================================================== #
|
148
|
+
"
|
149
|
+
_ << "require 'colours/toplevel_methods/html_colourize.rb'\n"
|
150
|
+
_ << "require 'colours/toplevel_methods/use_colours.rb'\n\n"
|
151
|
+
_ << "module Colours\n\n"
|
152
|
+
_ << "module SupportForHTMLColours # include Colours::SupportForHTMLColours\n\n".dup
|
153
|
+
comment_line = ' # '+('='*73)+' #'+N
|
154
|
+
available_html_colours?.each {|name_of_the_html_colour|
|
155
|
+
_ << comment_line
|
156
|
+
_ << ' # === Colours::SupportForHTMLColours.'+name_of_the_html_colour+N
|
157
|
+
_ << comment_line
|
158
|
+
_ << " def self.#{name_of_the_html_colour}(i = '', &block)\n"
|
159
|
+
_ << " if Colours.use_html_colours?\n"
|
160
|
+
_ << " Colours.html_colourize(__method__, i, &block)\n"
|
161
|
+
_ << " else\n"
|
162
|
+
_ << " i\n"
|
163
|
+
_ << " end\n"
|
164
|
+
_ << " end; def #{name_of_the_html_colour}(i = '', &block); SupportForHTMLColours.#{name_of_the_html_colour}(i, &block); end#{N}"
|
165
|
+
# ===================================================================== #
|
166
|
+
# Next, due to several reasons, we add a prepended "konsole_colour_"
|
167
|
+
# as name to this method.
|
168
|
+
# ===================================================================== #
|
169
|
+
_ << " def konsole_colour_#{name_of_the_html_colour}(i = '', &block); SupportForHTMLColours.#{name_of_the_html_colour}(i, &block); end#{N}#{N}"
|
170
|
+
}
|
171
|
+
_ << 'end; end'
|
172
|
+
what = _
|
173
|
+
# ======================================================================= #
|
174
|
+
# This is only useful on my home system really:
|
175
|
+
# ======================================================================= #
|
176
|
+
puts 'Storing into:'
|
177
|
+
puts
|
178
|
+
puts ' '+into
|
179
|
+
puts
|
180
|
+
require 'save_file'
|
181
|
+
SaveFile.write_what_into(what, into)
|
182
|
+
end
|
183
|
+
|
184
|
+
# ========================================================================= #
|
185
|
+
# === Colours.autogenerate_toplevel_basic_colour_methods
|
186
|
+
#
|
187
|
+
# The code in this method will autogenerate the toplevel colour
|
188
|
+
# methods, such as Colours.yellow().
|
189
|
+
#
|
190
|
+
# The code needs to respect several settings. For example, whether colours
|
191
|
+
# are used or not. Additionally, for methods such as Colours.yellow(),
|
192
|
+
# we need to find out whether we use the basic colours, the 256-colours or
|
193
|
+
# the HTML colours, and call the corresponding method in these cases.
|
194
|
+
# ========================================================================= #
|
195
|
+
def self.autogenerate_toplevel_basic_colour_methods(
|
196
|
+
into = HOME_DIRECTORY_OF_USER_X+'DATA/PROGRAMMING_LANGUAGES/RUBY/src/'\
|
197
|
+
'colours/lib/colours/autogenerated/toplevel_basic_colour_methods.rb'
|
198
|
+
)
|
199
|
+
comment_line = " # ======================================================================== \n"
|
200
|
+
store_this_string = ''.dup
|
201
|
+
header = <<-EOF
|
202
|
+
#{GENERIC_RUBY_HEADER}
|
203
|
+
# This file contains the code that will call the corresponding colour method
|
204
|
+
# depending on which colour-mode the user prefers.
|
205
|
+
# =========================================================================== #
|
206
|
+
# require 'colours/autogenerated/toplevel_basic_colour_methods.rb'
|
207
|
+
# =========================================================================== #
|
208
|
+
require 'colours/toplevel_methods/use_colours.rb'
|
209
|
+
require 'colours/basic_colours/basic_colours.rb'
|
210
|
+
require 'colours/256_colours/support_for_256_colours.rb'
|
211
|
+
require 'colours/autogenerated/support_for_html_colours.rb'
|
212
|
+
|
213
|
+
module Colours
|
214
|
+
|
215
|
+
module AllColourMethods # include Colours::AllColourMethods
|
216
|
+
|
217
|
+
EOF
|
218
|
+
|
219
|
+
store_this_string << header
|
220
|
+
# ======================================================================= #
|
221
|
+
# First define the methods for the basic colours:
|
222
|
+
# ======================================================================= #
|
223
|
+
array = return_a_unique_array_containing_all_available_colours
|
224
|
+
array.each {|this_basic_colour| # <- e. g. "yellow".
|
225
|
+
this_basic_colour = this_basic_colour.dup
|
226
|
+
if this_basic_colour.include?(' ') and
|
227
|
+
array.include?(this_basic_colour.delete(' '))
|
228
|
+
# =================================================================== #
|
229
|
+
# === This must be an alias
|
230
|
+
#
|
231
|
+
# In this case we will also add an alias containing the '_' part.
|
232
|
+
# We will only add this as an alias for include-actions, though.
|
233
|
+
# (This may change at a later point in the future - not sure yet.)
|
234
|
+
# =================================================================== #
|
235
|
+
store_this_string << " def #{this_basic_colour.tr(' ','_')}(i = ''); AllColourMethods.#{this_basic_colour.delete(' ')}(i); end\n"
|
236
|
+
else
|
237
|
+
name_of_the_method = this_basic_colour.downcase.delete(' ').dup
|
238
|
+
store_this_string << comment_line
|
239
|
+
store_this_string << " # === Colours::AllColourMethods.#{name_of_the_method}\n"
|
240
|
+
store_this_string << comment_line
|
241
|
+
store_this_string << " def self.#{name_of_the_method}(i = '', &block)\n"
|
242
|
+
store_this_string << " if Colours.use_colours?\n"
|
243
|
+
# =================================================================== #
|
244
|
+
# Ok, so we determine what to do with this colour-method:
|
245
|
+
# =================================================================== #
|
246
|
+
store_this_string << " if Colours.is_this_a_html_colour?(__method__)\n"
|
247
|
+
store_this_string << " Colours::SupportForHTMLColours.#{name_of_the_method}(i, &block)\n"
|
248
|
+
store_this_string << " elsif Colours.is_this_a_256_colour?(__method__)\n"
|
249
|
+
store_this_string << " Colours::SupportFor256Colours.#{name_of_the_method}(i, &block)\n"
|
250
|
+
store_this_string << " else\n"
|
251
|
+
store_this_string << " Colours::BasicColours.#{name_of_the_method}(i, &block)\n"
|
252
|
+
store_this_string << " end\n"
|
253
|
+
store_this_string << " else\n"
|
254
|
+
store_this_string << " i\n"
|
255
|
+
store_this_string << " end\n"
|
256
|
+
store_this_string << " end; def #{name_of_the_method}(i = '', &block); AllColourMethods.#{name_of_the_method}(i, &block); end\n"
|
257
|
+
# =================================================================== #
|
258
|
+
# Next, due to several reasons, we add a prepended "konsole_colour_"
|
259
|
+
# as name to this method.
|
260
|
+
# =================================================================== #
|
261
|
+
store_this_string << " def konsole_colour_#{name_of_the_method}(i = ''); AllColourMethods.#{name_of_the_method}(i); end\n"
|
262
|
+
store_this_string << " def konsole_#{name_of_the_method}(i = ''); AllColourMethods.#{name_of_the_method}(i); end\n"
|
263
|
+
store_this_string << " self.instance_eval { alias konsole_colour_#{name_of_the_method} #{name_of_the_method} } # === Colours::AllColourMethods.konsole_colour_#{name_of_the_method}\n"
|
264
|
+
store_this_string << " def Colours.e#{name_of_the_method}(i = ''); puts AllColourMethods.#{name_of_the_method}(i); end\n"
|
265
|
+
store_this_string << " def e#{name_of_the_method}(i = ''); puts AllColourMethods.#{name_of_the_method}(i); end\n"
|
266
|
+
store_this_string << " alias ekonsole_colour_#{name_of_the_method} e#{name_of_the_method}\n"
|
267
|
+
store_this_string << "\n"
|
268
|
+
end
|
269
|
+
}
|
270
|
+
store_this_string << "end; end\n"
|
271
|
+
what = store_this_string .dup
|
272
|
+
# ======================================================================= #
|
273
|
+
# This is only useful on my home system really:
|
274
|
+
# ======================================================================= #
|
275
|
+
puts 'Storing into the file:'
|
276
|
+
puts
|
277
|
+
puts " #{into}"
|
278
|
+
puts
|
279
|
+
require 'save_file'
|
280
|
+
File.delete(into) if File.exist? into # Get rid of the old file.
|
281
|
+
SaveFile.write_what_into(what, into)
|
282
|
+
end; self.instance_eval { alias define_colour_methods autogenerate_toplevel_basic_colour_methods } # === Colours.define_colour_methods
|
283
|
+
|
284
|
+
end
|
285
|
+
|
286
|
+
if __FILE__ == $PROGRAM_NAME
|
287
|
+
Colours.autogenerate_shell_file_containing_the_html_colours
|
288
|
+
Colours.autogenerate_the_module_for_the_256_colours
|
289
|
+
Colours.autogenerate_the_module_for_the_html_colours
|
290
|
+
Colours.autogenerate_toplevel_basic_colour_methods
|
291
|
+
end # autogenerate_colours
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'colours/version/version.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
module Colours
|
8
|
+
|
9
|
+
# ========================================================================= #
|
10
|
+
# === VERSION
|
11
|
+
# ========================================================================= #
|
12
|
+
VERSION = '0.5.55'
|
13
|
+
|
14
|
+
# ========================================================================= #
|
15
|
+
# === LAST_UPDATE
|
16
|
+
# ========================================================================= #
|
17
|
+
LAST_UPDATE = '15.08.2021'
|
18
|
+
|
19
|
+
# ========================================================================= #
|
20
|
+
# === URL_TO_THE_DOCUMENTATION
|
21
|
+
# ========================================================================= #
|
22
|
+
URL_TO_THE_DOCUMENTATION =
|
23
|
+
"https://www.rubydoc.info/gems/#{self.to_s.downcase}/#{VERSION}"
|
24
|
+
|
25
|
+
end
|