colours 0.5.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +862 -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/colours.gemspec +75 -0
- data/doc/COLOUR_CODES_CHART.md +28 -0
- data/doc/HOW_TO_PICK_YOUR_OWN_COLOURS.md +29 -0
- data/doc/README.gen +845 -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 +538 -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 +65 -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 +314 -0
- data/lib/colours/toplevel_methods/misc.rb +95 -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 +107 -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 +311 -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 +224 -0
|
@@ -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
|
+
# === Colours::VERSION
|
|
11
|
+
# ========================================================================= #
|
|
12
|
+
VERSION = '0.5.41'
|
|
13
|
+
|
|
14
|
+
# ========================================================================= #
|
|
15
|
+
# === Colours::LAST_UPDATE
|
|
16
|
+
# ========================================================================= #
|
|
17
|
+
LAST_UPDATE = '23.10.2020'
|
|
18
|
+
|
|
19
|
+
# ========================================================================= #
|
|
20
|
+
# === URL_TO_THE_DOCUMENTATION
|
|
21
|
+
# ========================================================================= #
|
|
22
|
+
URL_TO_THE_DOCUMENTATION =
|
|
23
|
+
"http://www.rubydoc.info/gems/#{self.to_s.downcase}/#{VERSION}"
|
|
24
|
+
|
|
25
|
+
end
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
# =========================================================================== #
|
|
2
|
+
# This file will map the colour-names to the xterm-colour codes.
|
|
3
|
+
#
|
|
4
|
+
# For example, Gold1 will correspond to the number 220.
|
|
5
|
+
#
|
|
6
|
+
# The following list has been taken from:
|
|
7
|
+
#
|
|
8
|
+
# https://jonasjacek.github.io/colors/
|
|
9
|
+
#
|
|
10
|
+
# However had - that entry has duplicates, such as DeepSkyBlue3: 31
|
|
11
|
+
# and DeepSkyBlue3: 32. Other sites list this as well, though,
|
|
12
|
+
# such as http://0xff.jp/256color.html - so I have simply named it.
|
|
13
|
+
#
|
|
14
|
+
# A similar problem exists for Purple4, which has the numbers 54
|
|
15
|
+
# and 55. This means that, if we are going to use names for these
|
|
16
|
+
# colours then we will not be able to use all 256 colours. If you
|
|
17
|
+
# need all colours, thus, you should use the numbers instead.
|
|
18
|
+
# =========================================================================== #
|
|
19
|
+
# x = YAML.load_file(FILE_256_COLOURS)
|
|
20
|
+
# =========================================================================== #
|
|
21
|
+
|
|
22
|
+
Black: 0
|
|
23
|
+
Maroon: 1
|
|
24
|
+
Green: 2
|
|
25
|
+
Olive: 3
|
|
26
|
+
Navy: 4
|
|
27
|
+
Purple: 5
|
|
28
|
+
Teal: 6
|
|
29
|
+
Silver: 7
|
|
30
|
+
Grey: 8
|
|
31
|
+
Red: 9
|
|
32
|
+
Lime: 10
|
|
33
|
+
Yellow: 11
|
|
34
|
+
Blue: 12
|
|
35
|
+
Fuchsia: 13
|
|
36
|
+
Aqua: 14
|
|
37
|
+
White: 15
|
|
38
|
+
Grey0: 16
|
|
39
|
+
NavyBlue: 17
|
|
40
|
+
DarkBlue: 18
|
|
41
|
+
Blue3: 19
|
|
42
|
+
Blue3: 20
|
|
43
|
+
Blue1: 21
|
|
44
|
+
DarkGreen: 22
|
|
45
|
+
DeepSkyBlue4: 23
|
|
46
|
+
DeepSkyBlue4: 24
|
|
47
|
+
DeepSkyBlue4: 25
|
|
48
|
+
DodgerBlue3: 26
|
|
49
|
+
DodgerBlue2: 27
|
|
50
|
+
Green4: 28
|
|
51
|
+
SpringGreen4: 29
|
|
52
|
+
Turquoise4: 30
|
|
53
|
+
DeepSkyBlue3: 31
|
|
54
|
+
DeepSkyBlue3: 32
|
|
55
|
+
DodgerBlue1: 33
|
|
56
|
+
Green3: 34
|
|
57
|
+
SpringGreen3: 35
|
|
58
|
+
DarkCyan: 36
|
|
59
|
+
LightSeaGreen: 37
|
|
60
|
+
DeepSkyBlue2: 38
|
|
61
|
+
DeepSkyBlue1: 39
|
|
62
|
+
Green3: 40
|
|
63
|
+
SpringGreen3: 41
|
|
64
|
+
SpringGreen2: 42
|
|
65
|
+
Cyan3: 43
|
|
66
|
+
DarkTurquoise: 44
|
|
67
|
+
Turquoise2: 45
|
|
68
|
+
Green1: 46
|
|
69
|
+
SpringGreen2: 47
|
|
70
|
+
SpringGreen1: 48
|
|
71
|
+
MediumSpringGreen: 49
|
|
72
|
+
Cyan2: 50
|
|
73
|
+
Cyan1: 51
|
|
74
|
+
DarkRed: 52
|
|
75
|
+
DeepPink4: 53
|
|
76
|
+
Purple4: 54
|
|
77
|
+
Purple4: 55
|
|
78
|
+
Purple3: 56
|
|
79
|
+
BlueViolet: 57
|
|
80
|
+
Orange4: 58
|
|
81
|
+
Grey37: 59
|
|
82
|
+
MediumPurple4: 60
|
|
83
|
+
SlateBlue3: 61
|
|
84
|
+
SlateBlue3: 62
|
|
85
|
+
RoyalBlue1: 63
|
|
86
|
+
Chartreuse4: 64
|
|
87
|
+
DarkSeaGreen4: 65
|
|
88
|
+
PaleTurquoise4: 66
|
|
89
|
+
SteelBlue: 67
|
|
90
|
+
SteelBlue3: 68
|
|
91
|
+
CornflowerBlue: 69
|
|
92
|
+
Chartreuse3: 70
|
|
93
|
+
DarkSeaGreen4: 71
|
|
94
|
+
CadetBlue: 72
|
|
95
|
+
CadetBlue: 73
|
|
96
|
+
SkyBlue3: 74
|
|
97
|
+
SteelBlue1: 75
|
|
98
|
+
Chartreuse3: 76
|
|
99
|
+
PaleGreen3: 77
|
|
100
|
+
SeaGreen3: 78
|
|
101
|
+
Aquamarine3: 79
|
|
102
|
+
MediumTurquoise: 80
|
|
103
|
+
SteelBlue1: 81
|
|
104
|
+
Chartreuse2: 82
|
|
105
|
+
SeaGreen2: 83
|
|
106
|
+
SeaGreen1: 84
|
|
107
|
+
SeaGreen1: 85
|
|
108
|
+
Aquamarine1: 86
|
|
109
|
+
DarkSlateGray2: 87
|
|
110
|
+
DarkRed: 88
|
|
111
|
+
DeepPink4: 89
|
|
112
|
+
DarkMagenta: 90
|
|
113
|
+
DarkMagenta: 91
|
|
114
|
+
DarkViolet: 92
|
|
115
|
+
Purple: 93
|
|
116
|
+
Orange4: 94
|
|
117
|
+
LightPink4: 95
|
|
118
|
+
Plum4: 96
|
|
119
|
+
MediumPurple3: 97
|
|
120
|
+
MediumPurple3: 98
|
|
121
|
+
SlateBlue1: 99
|
|
122
|
+
Yellow4: 100
|
|
123
|
+
Wheat4: 101
|
|
124
|
+
Grey53: 102
|
|
125
|
+
LightSlateGrey: 103
|
|
126
|
+
MediumPurple: 104
|
|
127
|
+
LightSlateBlue: 105
|
|
128
|
+
Yellow4: 106
|
|
129
|
+
DarkOliveGreen3: 107
|
|
130
|
+
DarkSeaGreen: 108
|
|
131
|
+
LightSkyBlue3: 109
|
|
132
|
+
LightSkyBlue3: 110
|
|
133
|
+
SkyBlue2: 111
|
|
134
|
+
Chartreuse2: 112
|
|
135
|
+
DarkOliveGreen3: 113
|
|
136
|
+
PaleGreen3: 114
|
|
137
|
+
DarkSeaGreen3: 115
|
|
138
|
+
DarkSlateGray3: 116
|
|
139
|
+
SkyBlue1: 117
|
|
140
|
+
Chartreuse1: 118
|
|
141
|
+
LightGreen: 119
|
|
142
|
+
LightGreen: 120
|
|
143
|
+
PaleGreen1: 121
|
|
144
|
+
Aquamarine1: 122
|
|
145
|
+
DarkSlateGray1: 123
|
|
146
|
+
Red3: 124
|
|
147
|
+
DeepPink4: 125
|
|
148
|
+
MediumVioletRed: 126
|
|
149
|
+
Magenta3: 127
|
|
150
|
+
DarkViolet: 128
|
|
151
|
+
Purple: 129
|
|
152
|
+
DarkOrange3: 130
|
|
153
|
+
IndianRed: 131
|
|
154
|
+
HotPink3: 132
|
|
155
|
+
MediumOrchid3: 133
|
|
156
|
+
MediumOrchid: 134
|
|
157
|
+
MediumPurple2: 135
|
|
158
|
+
DarkGoldenrod: 136
|
|
159
|
+
LightSalmon3: 137
|
|
160
|
+
RosyBrown: 138
|
|
161
|
+
Grey63: 139
|
|
162
|
+
MediumPurple2: 140
|
|
163
|
+
MediumPurple1: 141
|
|
164
|
+
Gold3: 142
|
|
165
|
+
DarkKhaki: 143
|
|
166
|
+
NavajoWhite3: 144
|
|
167
|
+
Grey69: 145
|
|
168
|
+
LightSteelBlue3: 146
|
|
169
|
+
LightSteelBlue: 147
|
|
170
|
+
Yellow3: 148
|
|
171
|
+
DarkOliveGreen3: 149
|
|
172
|
+
DarkSeaGreen3: 150
|
|
173
|
+
DarkSeaGreen2: 151
|
|
174
|
+
LightCyan3: 152
|
|
175
|
+
LightSkyBlue1: 153
|
|
176
|
+
GreenYellow: 154
|
|
177
|
+
DarkOliveGreen2: 155
|
|
178
|
+
PaleGreen1: 156
|
|
179
|
+
DarkSeaGreen2: 157
|
|
180
|
+
DarkSeaGreen1: 158
|
|
181
|
+
PaleTurquoise1: 159
|
|
182
|
+
Red3: 160
|
|
183
|
+
DeepPink3: 161
|
|
184
|
+
DeepPink3: 162
|
|
185
|
+
Magenta3: 163
|
|
186
|
+
Magenta3: 164
|
|
187
|
+
Magenta2: 165
|
|
188
|
+
DarkOrange3: 166
|
|
189
|
+
IndianRed: 167
|
|
190
|
+
HotPink3: 168
|
|
191
|
+
HotPink2: 169
|
|
192
|
+
Orchid: 170
|
|
193
|
+
MediumOrchid1: 171
|
|
194
|
+
Orange3: 172
|
|
195
|
+
LightSalmon3: 173
|
|
196
|
+
LightPink3: 174
|
|
197
|
+
Pink3: 175
|
|
198
|
+
Plum3: 176
|
|
199
|
+
Violet: 177
|
|
200
|
+
Gold3: 178
|
|
201
|
+
LightGoldenrod3: 179
|
|
202
|
+
Tan: 180
|
|
203
|
+
MistyRose3: 181
|
|
204
|
+
Thistle3: 182
|
|
205
|
+
Plum2: 183
|
|
206
|
+
Yellow3: 184
|
|
207
|
+
Khaki3: 185
|
|
208
|
+
LightGoldenrod2: 186
|
|
209
|
+
LightYellow3: 187
|
|
210
|
+
Grey84: 188
|
|
211
|
+
LightSteelBlue1: 189
|
|
212
|
+
Yellow2: 190
|
|
213
|
+
DarkOliveGreen1: 191
|
|
214
|
+
DarkOliveGreen1: 192
|
|
215
|
+
DarkSeaGreen1: 193
|
|
216
|
+
Honeydew2: 194
|
|
217
|
+
LightCyan1: 195
|
|
218
|
+
Red1: 196
|
|
219
|
+
DeepPink2: 197
|
|
220
|
+
DeepPink1: 198
|
|
221
|
+
DeepPink1: 199
|
|
222
|
+
Magenta2: 200
|
|
223
|
+
Magenta1: 201
|
|
224
|
+
OrangeRed1: 202
|
|
225
|
+
IndianRed1: 203
|
|
226
|
+
IndianRed1: 204
|
|
227
|
+
HotPink: 205
|
|
228
|
+
HotPink: 206
|
|
229
|
+
MediumOrchid1: 207
|
|
230
|
+
DarkOrange: 208
|
|
231
|
+
Salmon1: 209
|
|
232
|
+
LightCoral: 210
|
|
233
|
+
PaleVioletRed1: 211
|
|
234
|
+
Orchid2: 212
|
|
235
|
+
Orchid1: 213
|
|
236
|
+
Orange1: 214
|
|
237
|
+
SandyBrown: 215
|
|
238
|
+
LightSalmon1: 216
|
|
239
|
+
LightPink1: 217
|
|
240
|
+
Pink1: 218
|
|
241
|
+
Plum1: 219
|
|
242
|
+
Gold1: 220
|
|
243
|
+
LightGoldenrod2: 221
|
|
244
|
+
LightGoldenrod2: 222
|
|
245
|
+
NavajoWhite1: 223
|
|
246
|
+
MistyRose1: 224
|
|
247
|
+
Thistle1: 225
|
|
248
|
+
Yellow1: 226
|
|
249
|
+
LightGoldenrod1: 227
|
|
250
|
+
Khaki1: 228
|
|
251
|
+
Wheat1: 229
|
|
252
|
+
Cornsilk1: 230
|
|
253
|
+
Grey100: 231
|
|
254
|
+
Grey3: 232
|
|
255
|
+
Grey7: 233
|
|
256
|
+
Grey11: 234
|
|
257
|
+
Grey15: 235
|
|
258
|
+
Grey19: 236
|
|
259
|
+
Grey23: 237
|
|
260
|
+
Grey27: 238
|
|
261
|
+
Grey30: 239
|
|
262
|
+
Grey35: 240
|
|
263
|
+
Grey39: 241
|
|
264
|
+
Grey42: 242
|
|
265
|
+
Grey46: 243
|
|
266
|
+
Grey50: 244
|
|
267
|
+
Grey54: 245
|
|
268
|
+
Grey58: 246
|
|
269
|
+
Grey62: 247
|
|
270
|
+
Grey66: 248
|
|
271
|
+
Grey70: 249
|
|
272
|
+
Grey74: 250
|
|
273
|
+
Grey78: 251
|
|
274
|
+
Grey82: 252
|
|
275
|
+
Grey85: 253
|
|
276
|
+
Grey89: 254
|
|
277
|
+
Grey93: 255
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# =========================================================================== #
|
|
2
|
+
# This is essentially an Array keeping track as to which methods are
|
|
3
|
+
# available via ANSI escape codes. Aliases will NOT be stored here -
|
|
4
|
+
# the Array may only list one name for each escape code.
|
|
5
|
+
# =========================================================================== #
|
|
6
|
+
|
|
7
|
+
- black # 0;30
|
|
8
|
+
- red # 0;31
|
|
9
|
+
- green # 0;32
|
|
10
|
+
- yellow # 0;33
|
|
11
|
+
- blue # 0;34
|
|
12
|
+
- magenta # 0;35
|
|
13
|
+
- cyan # 0;36
|
|
14
|
+
- light gray # 0;37
|
|
15
|
+
|
|
16
|
+
- dark gray # 1;30
|
|
17
|
+
- light red # 1;31
|
|
18
|
+
- light green # 1;32
|
|
19
|
+
- brown # 1;33
|
|
20
|
+
- light blue # 1;34
|
|
21
|
+
- light magenta # 1;35
|
|
22
|
+
- light cyan # 1;36
|
|
23
|
+
- white # 1;37
|