colours 0.8.12 → 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +331 -200
- data/bin/colours +2 -2
- data/bin/show_basic_colour_palette +7 -0
- data/colours.gemspec +1 -2
- data/doc/README.gen +294 -178
- data/doc/how_to_pick_your_own_colours/how_to_pick_your_own_colours.md +33 -0
- data/lib/colours/autoalias_e.rb +4 -1
- data/lib/colours/autogenerated/256_colours_instance_methods.rb +1429 -0
- data/lib/colours/autogenerated/256_colours_methods.rb +1429 -0
- data/lib/colours/autogenerated/html_colours_instance_methods.rb +1191 -0
- data/lib/colours/autogenerated/html_colours_methods.rb +1191 -0
- data/lib/colours/base/base.rb +61 -13
- data/lib/colours/class/colours.rb +8 -6
- data/lib/colours/{toplevel_methods/use_colours.rb → colour/colour.rb} +4 -125
- data/lib/colours/commandline/README.md +2 -1
- data/lib/colours/commandline/commandline.rb +177 -34
- data/lib/colours/constants/constants.rb +752 -6
- data/lib/colours/e/README.md +6 -6
- data/lib/colours/eparse/eparse.rb +2 -1
- data/lib/colours/essentials/README.md +5 -0
- data/lib/colours/{basic_colours/basic_colours.rb → essentials/essentials.rb} +87 -85
- data/lib/colours/html_colours/README.md +2 -1
- data/lib/colours/html_colours/hash_html_colours.rb +168 -0
- data/lib/colours/html_colours/html_colours.rb +226 -244
- data/lib/colours/html_colours/push_the_html_colours_methods_onto_the_toplevel_namespace.rb +30 -0
- data/lib/colours/html_colours/random_html_colour.rb +67 -0
- data/lib/colours/{requires/require_the_basic_colours.rb → html_colours.rb} +4 -2
- data/lib/colours/map_symbol_to_corresponding_colour/map_symbol_to_corresponding_colour.rb +12 -10
- data/lib/colours/module_256_colours/module_256_colours.rb +465 -0
- data/lib/colours/project/project.rb +3 -1
- data/lib/colours/rainbow_colours/check_for_trollop_being_available_or_exit.rb +4 -0
- data/lib/colours/rainbow_colours/constants.rb +3 -3
- data/lib/colours/rainbow_colours/do_parse_via_rainbow_colours.rb +9 -10
- data/lib/colours/rainbow_colours/print_rainbow_line.rb +4 -4
- data/lib/colours/rainbow_colours/println_ani.rb +7 -7
- data/lib/colours/rainbow_colours/println_plain.rb +2 -2
- data/lib/colours/rainbow_colours/rainbow.rb +31 -1
- data/lib/colours/rainbow_colours/report_errors.rb +7 -7
- data/lib/colours/rainbow_colours/returnln_plain.rb +3 -3
- data/lib/colours/replace_tokens_with_colour_code/replace_tokens_with_colour_code.rb +409 -0
- data/lib/colours/requires/require_autogenerated_colour_methods.rb +4 -1
- data/lib/colours/requires/{require_the_colour_table.rb → require_essentials.rb} +2 -2
- data/lib/colours/requires/require_save_file.rb +11 -0
- data/lib/colours/requires/require_the_256_colours_module.rb +1 -3
- data/lib/colours/requires/require_the_colour_methods.rb +1 -22
- data/lib/colours/requires/require_the_project.rb +31 -29
- data/lib/colours/requires/require_the_toplevel_methods.rb +2 -20
- data/lib/colours/rgb/rgb.rb +107 -89
- data/lib/colours/{colour_methods/colour_methods.rb → sfile_sdir_sfancy_swarn_simp_scomments_and_ssymlink/sfile_sdir_sfancy_swarn_simp_scomments_and_ssymlink.rb} +467 -405
- data/lib/colours/testing/testing.rb +1 -3
- data/lib/colours/toplevel_methods/e.rb +9 -13
- data/lib/colours/toplevel_methods/map_this_symbol_to_that_html_colour.rb +57 -0
- data/lib/colours/toplevel_methods/{revert.rb → rev.rb} +5 -48
- data/lib/colours/toplevel_methods/toplevel_methods.rb +1204 -0
- data/lib/colours/version/version.rb +2 -2
- data/lib/colours/yaml/256_colours.yml +776 -257
- data/lib/colours/yaml/html_colours.yml +1 -1
- data/lib/colours/yaml/prefer_this_colour_schemata.yml +1 -1
- data/lib/colours/yaml/use_these_values_for_the_colour_methods.yml +5 -1
- data/lib/colours.rb +1 -1
- data/test/testing_256_colours_support.rb +10 -1
- data/test/testing_replace_number_words_with_the_corresponding_html_colour.rb +15 -9
- data/test/testing_the_colour_methods_such_as_simp_sdir_sfile_swarn_sfancy_sargument_and_ssymlink.rb +53 -0
- metadata +30 -57
- data/doc/HOW_TO_PICK_YOUR_OWN_COLOURS.md +0 -28
- data/lib/colours/256_colours/support_for_256_colours.rb +0 -196
- data/lib/colours/autogenerated/support_for_256_colours.rb +0 -2235
- data/lib/colours/autogenerated/support_for_html_colours.rb +0 -1778
- data/lib/colours/autogenerated/toplevel_basic_colour_methods.rb +0 -7001
- data/lib/colours/basic_colours/README.md +0 -4
- data/lib/colours/colour_methods/README.md +0 -11
- data/lib/colours/colour_table/README.md +0 -2
- data/lib/colours/colour_table/colour_table.rb +0 -282
- data/lib/colours/commandline/menu.rb +0 -122
- data/lib/colours/constants/escape.rb +0 -22
- data/lib/colours/constants/file_constants.rb +0 -73
- data/lib/colours/constants/hash_ansi_colours.rb +0 -39
- data/lib/colours/constants/hash_simple_colours.rb +0 -148
- data/lib/colours/constants/misc.rb +0 -361
- data/lib/colours/constants/newline.rb +0 -14
- data/lib/colours/constants/registered_colour_methods.rb +0 -53
- data/lib/colours/html_colours/add_html_colours_onto_the_toplevel_namespace.rb +0 -22
- data/lib/colours/toplevel_methods/autogenerate.rb +0 -310
- data/lib/colours/toplevel_methods/bold.rb +0 -41
- data/lib/colours/toplevel_methods/bold_and_italic.rb +0 -38
- data/lib/colours/toplevel_methods/cat.rb +0 -39
- data/lib/colours/toplevel_methods/clear_screen.rb +0 -18
- data/lib/colours/toplevel_methods/cliner.rb +0 -17
- data/lib/colours/toplevel_methods/col.rb +0 -54
- data/lib/colours/toplevel_methods/esystem.rb +0 -19
- data/lib/colours/toplevel_methods/html_colour_to_hex_value.rb +0 -41
- data/lib/colours/toplevel_methods/html_colourize.rb +0 -69
- data/lib/colours/toplevel_methods/is_on_roebe.rb +0 -16
- data/lib/colours/toplevel_methods/italic.rb +0 -110
- data/lib/colours/toplevel_methods/make_colour.rb +0 -28
- data/lib/colours/toplevel_methods/methods_related_to_html_colours.rb +0 -336
- data/lib/colours/toplevel_methods/misc.rb +0 -226
- data/lib/colours/toplevel_methods/open_this_file.rb +0 -26
- data/lib/colours/toplevel_methods/prefer_this_colour_schemata.rb +0 -88
- data/lib/colours/toplevel_methods/random_value.rb +0 -37
- data/lib/colours/toplevel_methods/remove_escape_sequence.rb +0 -112
- data/lib/colours/toplevel_methods/set_last_colour_used.rb +0 -32
- data/lib/colours/toplevel_methods/shell_file_containing_the_html_colours.sh +0 -148
- data/lib/colours/toplevel_methods/show_basic_colour_palette.rb +0 -36
- data/lib/colours/toplevel_methods/underline.rb +0 -130
- data/test/testing_the_colour_methods.rb +0 -36
- /data/doc/{COLOUR_CODES_CHART.md → colour_codes_chart/colour_codes_chart.md} +0 -0
@@ -1,310 +0,0 @@
|
|
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/toplevel_methods/autogenerate.rb'
|
10
|
-
# =========================================================================== #
|
11
|
-
module Colours
|
12
|
-
|
13
|
-
require 'yaml'
|
14
|
-
require 'colours/constants/newline.rb'
|
15
|
-
require 'colours/constants/file_constants.rb'
|
16
|
-
require 'colours/toplevel_methods/is_on_roebe.rb'
|
17
|
-
require 'colours/256_colours/support_for_256_colours.rb'
|
18
|
-
require 'colours/html_colours/html_colours.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.autogenerate_the_module_for_the_html_colours
|
30
|
-
#
|
31
|
-
# This method will autogenerate the module that will support
|
32
|
-
# the html colours.
|
33
|
-
# ========================================================================= #
|
34
|
-
def self.autogenerate_the_module_for_the_html_colours(
|
35
|
-
into = HOME_DIRECTORY_OF_USER_X+'programming/ruby/src/'\
|
36
|
-
'colours/lib/colours/autogenerated/support_for_html_colours.rb'
|
37
|
-
)
|
38
|
-
_ = ''.dup
|
39
|
-
_ << GENERIC_RUBY_HEADER+"
|
40
|
-
# require 'colours/autogenerated/support_for_html_colours.rb'
|
41
|
-
# =========================================================================== #
|
42
|
-
"
|
43
|
-
_ << "module Colours\n\n"
|
44
|
-
_ << "module SupportForHTMLColours # include Colours::SupportForHTMLColours\n\n".dup
|
45
|
-
_ << " require 'colours/toplevel_methods/html_colourize.rb'\n"
|
46
|
-
_ << " require 'colours/toplevel_methods/use_colours.rb'\n\n"
|
47
|
-
comment_line = ' # '+('='*73)+' #'+N
|
48
|
-
available_html_colours?.each {|name_of_the_html_colour|
|
49
|
-
_ << comment_line
|
50
|
-
_ << ' # === Colours::SupportForHTMLColours.'+name_of_the_html_colour+N
|
51
|
-
_ << comment_line
|
52
|
-
_ << " def self.#{name_of_the_html_colour}(i = '', &block)\n"
|
53
|
-
_ << " if ::Colours.use_html_colours?\n"
|
54
|
-
_ << " return ::Colours.html_colourize(__method__, i, &block)\n"
|
55
|
-
_ << " else\n"
|
56
|
-
_ << " return i\n"
|
57
|
-
_ << " end\n"
|
58
|
-
_ << " end; def #{name_of_the_html_colour}(i = '', &block); SupportForHTMLColours.#{name_of_the_html_colour}(i, &block); end#{N}"
|
59
|
-
# ===================================================================== #
|
60
|
-
# Next, due to several reasons, we add a prepended "konsole_colour_"
|
61
|
-
# as name to this method.
|
62
|
-
# ===================================================================== #
|
63
|
-
_ << " def konsole_colour_#{name_of_the_html_colour}(i = '', &block); SupportForHTMLColours.#{name_of_the_html_colour}(i, &block); end#{N}#{N}"
|
64
|
-
}
|
65
|
-
_ << 'end; end'
|
66
|
-
what = _
|
67
|
-
# ======================================================================= #
|
68
|
-
# This is only useful on my home system really:
|
69
|
-
# ======================================================================= #
|
70
|
-
puts 'Storing into:'
|
71
|
-
puts
|
72
|
-
puts ' '+into
|
73
|
-
puts
|
74
|
-
require 'save_file'
|
75
|
-
SaveFile.write_what_into(what, into)
|
76
|
-
end
|
77
|
-
|
78
|
-
# ========================================================================= #
|
79
|
-
# === Colours.autogenerate_toplevel_basic_colour_methods
|
80
|
-
#
|
81
|
-
# The code in this method will autogenerate the toplevel colour
|
82
|
-
# methods, such as Colours.yellow().
|
83
|
-
#
|
84
|
-
# The code needs to respect several settings. For example, whether colours
|
85
|
-
# are used or not. Additionally, for methods such as Colours.yellow(),
|
86
|
-
# we need to find out whether we use the basic colours, the 256-colours or
|
87
|
-
# the HTML colours, and call the corresponding method in these cases.
|
88
|
-
# ========================================================================= #
|
89
|
-
def self.autogenerate_toplevel_basic_colour_methods(
|
90
|
-
into = HOME_DIRECTORY_OF_USER_X+'programming/ruby/src/'\
|
91
|
-
'colours/lib/colours/autogenerated/'\
|
92
|
-
'toplevel_basic_colour_methods.rb'
|
93
|
-
)
|
94
|
-
comment_line = " # ======================================================================== \n"
|
95
|
-
store_this_string = ''.dup
|
96
|
-
header = <<-EOF
|
97
|
-
#{GENERIC_RUBY_HEADER}
|
98
|
-
# This file contains the code that will call the corresponding colour method
|
99
|
-
# depending on which colour-mode the user prefers.
|
100
|
-
# =========================================================================== #
|
101
|
-
# require 'colours/autogenerated/toplevel_basic_colour_methods.rb'
|
102
|
-
# =========================================================================== #
|
103
|
-
module Colours
|
104
|
-
|
105
|
-
require 'colours/toplevel_methods/use_colours.rb'
|
106
|
-
require 'colours/basic_colours/basic_colours.rb'
|
107
|
-
require 'colours/256_colours/support_for_256_colours.rb'
|
108
|
-
require 'colours/autogenerated/support_for_html_colours.rb'
|
109
|
-
require 'colours/html_colours/html_colours.rb'
|
110
|
-
|
111
|
-
module AllColourMethods # include Colours::AllColourMethods
|
112
|
-
|
113
|
-
EOF
|
114
|
-
|
115
|
-
store_this_string << header
|
116
|
-
# ======================================================================= #
|
117
|
-
# First define the methods for the basic colours:
|
118
|
-
# ======================================================================= #
|
119
|
-
array = return_a_unique_array_containing_all_available_colours
|
120
|
-
array.each {|this_basic_colour| # <- e. g. "yellow".
|
121
|
-
this_basic_colour = this_basic_colour.dup
|
122
|
-
if this_basic_colour.include?(' ') and
|
123
|
-
array.include?(this_basic_colour.delete(' '))
|
124
|
-
# =================================================================== #
|
125
|
-
# === This must be an alias
|
126
|
-
#
|
127
|
-
# In this case we will also add an alias containing the '_' part.
|
128
|
-
# We will only add this as an alias for include-actions, though.
|
129
|
-
# (This may change at a later point in the future - not sure yet.)
|
130
|
-
# =================================================================== #
|
131
|
-
store_this_string << " def #{this_basic_colour.tr(' ','_')}(i = ARGV)
|
132
|
-
if i.is_a? Array
|
133
|
-
i = i.join(' ').strip
|
134
|
-
end
|
135
|
-
AllColourMethods.#{this_basic_colour.delete(' ')}(i)
|
136
|
-
end\n\n"
|
137
|
-
else
|
138
|
-
name_of_the_method = this_basic_colour.downcase.delete(' ').dup
|
139
|
-
store_this_string << comment_line
|
140
|
-
store_this_string << " # === Colours::AllColourMethods.#{name_of_the_method}\n"
|
141
|
-
store_this_string << comment_line
|
142
|
-
store_this_string << " def self.#{name_of_the_method}(i = '', &block)\n"
|
143
|
-
store_this_string << " if ::Colours.use_colours?\n"
|
144
|
-
# =================================================================== #
|
145
|
-
# Ok, so we determine what to do with this colour-method:
|
146
|
-
# =================================================================== #
|
147
|
-
store_this_string << " if ::Colours.is_this_a_html_colour?(__method__)\n"
|
148
|
-
store_this_string << " return ::Colours::SupportForHTMLColours.#{name_of_the_method}(i, &block)\n"
|
149
|
-
store_this_string << " elsif ::Colours.is_this_a_256_colour?(__method__)\n"
|
150
|
-
store_this_string << " return ::Colours::SupportFor256Colours.#{name_of_the_method}(i, &block)\n"
|
151
|
-
store_this_string << " else\n"
|
152
|
-
store_this_string << " return ::Colours::BasicColours.#{name_of_the_method}(i, &block)\n"
|
153
|
-
store_this_string << " end\n"
|
154
|
-
store_this_string << " else\n"
|
155
|
-
store_this_string << " return i\n"
|
156
|
-
store_this_string << " end\n"
|
157
|
-
store_this_string << " end; def #{name_of_the_method}(i = '', &block); AllColourMethods.#{name_of_the_method}(i, &block); end\n"
|
158
|
-
# =================================================================== #
|
159
|
-
# Next, due to several reasons, we add a prepended "konsole_colour_"
|
160
|
-
# as name to this method.
|
161
|
-
# =================================================================== #
|
162
|
-
store_this_string << " def konsole_colour_#{name_of_the_method}(i = ''); AllColourMethods.#{name_of_the_method}(i); end\n"
|
163
|
-
store_this_string << " def konsole_#{name_of_the_method}(i = ''); AllColourMethods.#{name_of_the_method}(i); end\n"
|
164
|
-
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"
|
165
|
-
# =================================================================== #
|
166
|
-
# The next line adds something like: Colours.egreen(), as a method.
|
167
|
-
# =================================================================== #
|
168
|
-
store_this_string << " def Colours.e#{name_of_the_method}(i = ARGV); i = i.join(' ') if i.is_a? Array; puts AllColourMethods.#{name_of_the_method}(i); end\n"
|
169
|
-
store_this_string << " def e#{name_of_the_method}(i = ''); puts AllColourMethods.#{name_of_the_method}(i); end\n"
|
170
|
-
store_this_string << " alias ekonsole_colour_#{name_of_the_method} e#{name_of_the_method}\n"
|
171
|
-
store_this_string << "\n"
|
172
|
-
end
|
173
|
-
}
|
174
|
-
store_this_string << "end; end\n"
|
175
|
-
what = store_this_string .dup
|
176
|
-
# ======================================================================= #
|
177
|
-
# This is only useful on my home system really:
|
178
|
-
# ======================================================================= #
|
179
|
-
puts 'Storing into the file:'
|
180
|
-
puts
|
181
|
-
puts " #{into}"
|
182
|
-
puts
|
183
|
-
File.delete(into) if File.exist? into # Get rid of the old file.
|
184
|
-
begin
|
185
|
-
require 'save_file'
|
186
|
-
SaveFile.write_what_into(what, into)
|
187
|
-
rescue LoadError
|
188
|
-
puts 'save_file gem is not available/installed.'
|
189
|
-
end
|
190
|
-
end; self.instance_eval { alias define_colour_methods autogenerate_toplevel_basic_colour_methods } # === Colours.define_colour_methods
|
191
|
-
|
192
|
-
# ========================================================================= #
|
193
|
-
# === Colours.autogenerate_the_module_for_the_256_colours
|
194
|
-
#
|
195
|
-
# This method will autogenerate the module that will support
|
196
|
-
# the 256 colours.
|
197
|
-
# ========================================================================= #
|
198
|
-
def self.autogenerate_the_module_for_the_256_colours
|
199
|
-
_ = ''.dup
|
200
|
-
_ << GENERIC_RUBY_HEADER+"
|
201
|
-
# require 'colours/autogenerated/support_for_256_colours.rb'
|
202
|
-
# =========================================================================== #
|
203
|
-
"
|
204
|
-
_ << "module Colours\n\n"
|
205
|
-
_ << "module SupportFor256Colours # include Colours::SupportFor256Colours\n\n".dup
|
206
|
-
_ << " require 'colours/256_colours/support_for_256_colours.rb'\n\n"
|
207
|
-
comment_line = ' # '+('='*73)+' #'+N
|
208
|
-
@dataset_for_the_256_colours.each {|name_of_the_colour, id|
|
209
|
-
use_this_name = name_of_the_colour.downcase
|
210
|
-
_ << comment_line
|
211
|
-
_ << ' # === Colours::SupportFor256Colours.'+use_this_name+N
|
212
|
-
_ << comment_line
|
213
|
-
_ << " def self.#{use_this_name}(i = '')#{N}"
|
214
|
-
_ << " if Colours.use_colours?\n"
|
215
|
-
_ << " return Colours.return_this_256_colour(__method__, i)\n"
|
216
|
-
_ << " else\n"
|
217
|
-
_ << " return i\n"
|
218
|
-
_ << " end\n"
|
219
|
-
_ << " end; def #{use_this_name}(i = ''); SupportFor256Colours.#{use_this_name}(i); end#{N}#{N}"
|
220
|
-
}
|
221
|
-
_ << 'end; end'
|
222
|
-
what = _
|
223
|
-
# ======================================================================= #
|
224
|
-
# This is only useful on my home system really:
|
225
|
-
# ======================================================================= #
|
226
|
-
into = HOME_DIRECTORY_OF_USER_X+'programming/ruby/src/'\
|
227
|
-
'colours/lib/colours/autogenerated/support_for_256_colours.rb'
|
228
|
-
puts 'Storing into:'
|
229
|
-
puts
|
230
|
-
puts ' '+into
|
231
|
-
puts
|
232
|
-
require 'save_file'
|
233
|
-
SaveFile.write_what_into(what, into)
|
234
|
-
end
|
235
|
-
|
236
|
-
require 'colours/toplevel_methods/html_colourize.rb'
|
237
|
-
# ========================================================================= #
|
238
|
-
# === Colours.generate_shell_file_containing_the_html_colours
|
239
|
-
#
|
240
|
-
# This method will generate a shell file into the current directory
|
241
|
-
# by default.
|
242
|
-
#
|
243
|
-
# The code in that file will generate a shell script that holds all
|
244
|
-
# the HTML-colours, via UPCASED names.
|
245
|
-
#
|
246
|
-
# These entries will then look like this:
|
247
|
-
#
|
248
|
-
# SADDLEBROWN: "\e[38;2;139;69;19m"
|
249
|
-
# PERU: "\e[38;2;205;133;63m"
|
250
|
-
# CHOCOLATE: "\e[38;2;210;105;30m"
|
251
|
-
#
|
252
|
-
# ========================================================================= #
|
253
|
-
def self.generate_shell_file_containing_the_html_colours(
|
254
|
-
generate_the_shell_file_into_this_directory = Dir.pwd
|
255
|
-
)
|
256
|
-
require 'save_file/module'
|
257
|
-
unless generate_the_shell_file_into_this_directory.end_with? '/'
|
258
|
-
if generate_the_shell_file_into_this_directory.frozen?
|
259
|
-
generate_the_shell_file_into_this_directory = generate_the_shell_file_into_this_directory.dup
|
260
|
-
end
|
261
|
-
generate_the_shell_file_into_this_directory << '/'
|
262
|
-
end
|
263
|
-
result = ''.dup
|
264
|
-
result << "# This is a shell file that contains the HTML colours\n"
|
265
|
-
available_html_colours?.each {|this_colour|
|
266
|
-
colour_code_to_use = ::Colours.html_colourize(this_colour.to_sym,'',false).inspect
|
267
|
-
result << "export #{this_colour.upcase}=#{colour_code_to_use}\n"
|
268
|
-
}
|
269
|
-
generate_the_shell_file_into_this_directory << 'shell_file_containing_the_html_colours.sh'
|
270
|
-
into = generate_the_shell_file_into_this_directory
|
271
|
-
e "Now creating a shell file at `#{into}`."
|
272
|
-
SaveFile.write_what_into(result, into)
|
273
|
-
# ======================================================================= #
|
274
|
-
# Generate files on my home system as well:
|
275
|
-
# ======================================================================= #
|
276
|
-
if is_on_roebe?
|
277
|
-
into = '/home/x/programming/ruby/src/'\
|
278
|
-
'roebe/lib/roebe/shell_scripts/'+
|
279
|
-
File.basename(generate_the_shell_file_into_this_directory)
|
280
|
-
puts "And also saving into `#{into}`."
|
281
|
-
SaveFile.write_what_into(result, into)
|
282
|
-
end
|
283
|
-
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
|
284
|
-
|
285
|
-
# ========================================================================= #
|
286
|
-
# === Colours.return_a_unique_array_containing_all_available_colours
|
287
|
-
# ========================================================================= #
|
288
|
-
def self.return_a_unique_array_containing_all_available_colours
|
289
|
-
array = []
|
290
|
-
array << YAML.load_file(FILE_HTML_COLOURS).keys # (1) First the HTML colours
|
291
|
-
array << YAML.load_file(FILE_256_COLOURS).keys.map(&:downcase) # (2) Then the basic colours
|
292
|
-
array << YAML.load_file(FILE_BASIC_COLOURS) # (3) And finally the basic colours
|
293
|
-
array.flatten!
|
294
|
-
array.uniq!
|
295
|
-
array.map!(&:strip)
|
296
|
-
array.sort
|
297
|
-
end; self.instance_eval { alias all_available_colour_methods? return_a_unique_array_containing_all_available_colours } # === Colours.all_available_colour_methods?
|
298
|
-
|
299
|
-
end
|
300
|
-
|
301
|
-
if __FILE__ == $PROGRAM_NAME
|
302
|
-
alias e puts
|
303
|
-
e
|
304
|
-
# pp Colours.return_a_unique_array_containing_all_available_colours
|
305
|
-
# e
|
306
|
-
Colours.autogenerate_the_module_for_the_html_colours
|
307
|
-
Colours.autogenerate_shell_file_containing_the_html_colours
|
308
|
-
Colours.autogenerate_the_module_for_the_256_colours
|
309
|
-
Colours.autogenerate_toplevel_basic_colour_methods
|
310
|
-
end # autogeneratecolours
|
@@ -1,41 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'colours/toplevel_methods/bold.rb'
|
6
|
-
# Colours.bold
|
7
|
-
# =========================================================================== #
|
8
|
-
module Colours
|
9
|
-
|
10
|
-
require 'colours/toplevel_methods/revert.rb'
|
11
|
-
|
12
|
-
# ========================================================================= #
|
13
|
-
# === Colours.bold
|
14
|
-
#
|
15
|
-
# ANSI colour escape code for bold is "1".
|
16
|
-
#
|
17
|
-
# The method has to call Colours.rev() at the end, because that way
|
18
|
-
# downstream users can modify the default rev-colour in use.
|
19
|
-
#
|
20
|
-
# Usage example:
|
21
|
-
#
|
22
|
-
# puts ' ok | '+Colours.bold('Hello world!')+' | ok'
|
23
|
-
#
|
24
|
-
# ========================================================================= #
|
25
|
-
def self.bold(
|
26
|
-
show_this_text = 'This must be bold.'
|
27
|
-
)
|
28
|
-
return "\x1b[1m#{show_this_text}#{::Colours.rev}"
|
29
|
-
end; self.instance_eval { alias return_bold bold } # === Colours.return_bold
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
if __FILE__ == $PROGRAM_NAME
|
34
|
-
alias e puts
|
35
|
-
if ARGV.empty?
|
36
|
-
e Colours.bold('Hello world!')
|
37
|
-
e 'Hello world!'
|
38
|
-
else
|
39
|
-
e Colours.bold(ARGV.join(' ').strip)
|
40
|
-
end
|
41
|
-
end # colours_bold hello there how do you do
|
@@ -1,38 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'colours/toplevel_methods/bold_and_italic.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module Colours
|
8
|
-
|
9
|
-
require 'colours/toplevel_methods/bold.rb'
|
10
|
-
require 'colours/toplevel_methods/italic.rb'
|
11
|
-
require 'colours/toplevel_methods/revert.rb'
|
12
|
-
|
13
|
-
# ========================================================================= #
|
14
|
-
# === Colours.bold_and_italic
|
15
|
-
#
|
16
|
-
# Usage example:
|
17
|
-
#
|
18
|
-
# puts Colours.bold_and_italic 'Hello world!'
|
19
|
-
#
|
20
|
-
# ========================================================================= #
|
21
|
-
def self.bold_and_italic(
|
22
|
-
i = 'This must be bold.'
|
23
|
-
)
|
24
|
-
if i.is_a? Array
|
25
|
-
i = i.join(' ')
|
26
|
-
end
|
27
|
-
italic(bold(i))
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
if __FILE__ == $PROGRAM_NAME
|
33
|
-
if ARGV.empty?
|
34
|
-
puts Colours.bold_and_italic('Hello world!')+' All is fine.'
|
35
|
-
else
|
36
|
-
puts Colours.bold_and_italic(ARGV)
|
37
|
-
end
|
38
|
-
end # boldanditalic yo there yoda
|
@@ -1,39 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'colours/toplevel_methods/cat.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module Colours
|
8
|
-
|
9
|
-
require 'colours/rainbow_colours/print_rainbow_line.rb'
|
10
|
-
|
11
|
-
# ========================================================================= #
|
12
|
-
# === Colours.cat
|
13
|
-
#
|
14
|
-
# The first argument may be ARGF. It ought to respond to .each anyway.
|
15
|
-
#
|
16
|
-
# Note that .cat() will delegate towards print_line().
|
17
|
-
# ========================================================================= #
|
18
|
-
def self.cat(
|
19
|
-
file_descriptor, hash_options = {}
|
20
|
-
)
|
21
|
-
print "\e[?25l" if hash_options[:animate] # Print this if we animate (enabling psychedelics).
|
22
|
-
# ======================================================================= #
|
23
|
-
# Iterate over the file_descriptor passed.
|
24
|
-
# ======================================================================= #
|
25
|
-
file_descriptor.each { |line|
|
26
|
-
hash_options[:os] += 1 # Increase the output-count.
|
27
|
-
# ===================================================================== #
|
28
|
-
# Next, colourize the line. This depends on the method called
|
29
|
-
# print_rainbow_line().
|
30
|
-
# ===================================================================== #
|
31
|
-
RainbowColours.print_rainbow_line(
|
32
|
-
line, hash_options
|
33
|
-
) # Delegate towards print_line.
|
34
|
-
}
|
35
|
-
ensure
|
36
|
-
print "\e[?25h" if hash_options[:animate]
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'colours/toplevel_methods/clear_screen.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module Colours
|
8
|
-
|
9
|
-
# ========================================================================= #
|
10
|
-
# === Colours.clear_screen
|
11
|
-
#
|
12
|
-
# Simply perform 'clear' here.
|
13
|
-
# ========================================================================= #
|
14
|
-
def self.clear_screen
|
15
|
-
system 'clear'
|
16
|
-
end; self.instance_eval { alias clear clear_screen } # === Colours.clear_screen
|
17
|
-
|
18
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'colours/toplevel_methods/cliner.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module Colours
|
8
|
-
|
9
|
-
# ========================================================================= #
|
10
|
-
# === Colours.cliner
|
11
|
-
# ========================================================================= #
|
12
|
-
def self.cliner(i = 78, &block)
|
13
|
-
yield if block_given?
|
14
|
-
puts '=' * i
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'colours/toplevel_methods/col.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module Colours
|
8
|
-
|
9
|
-
require 'colours/colour_methods/colour_methods.rb'
|
10
|
-
|
11
|
-
# ========================================================================= #
|
12
|
-
# === Colours.col (col tag)
|
13
|
-
#
|
14
|
-
# Careful - this method may collide with other methods named col().
|
15
|
-
#
|
16
|
-
# Usage examples:
|
17
|
-
#
|
18
|
-
# Colours.col '/Depot/j/geojgirjh'
|
19
|
-
# Colours.col '/Users/x/AUDIO/'
|
20
|
-
# Colours.col '/Users/x/AUDIO/Westbam_Sunshine.mp3'
|
21
|
-
#
|
22
|
-
# ========================================================================= #
|
23
|
-
def self.col(
|
24
|
-
i,
|
25
|
-
optional_arg_not_in_use_right_now = ''
|
26
|
-
)
|
27
|
-
if File.exist? i
|
28
|
-
ftype = File.ftype(i)
|
29
|
-
# e 'The ftype is: '+ftype # <- This could be used for debugging.
|
30
|
-
case ftype
|
31
|
-
# ===================================================================== #
|
32
|
-
# === file
|
33
|
-
# ===================================================================== #
|
34
|
-
when 'file'
|
35
|
-
return sfile(i)
|
36
|
-
# ===================================================================== #
|
37
|
-
# === directory
|
38
|
-
# ===================================================================== #
|
39
|
-
when 'directory'
|
40
|
-
return sdir(i)
|
41
|
-
# ===================================================================== #
|
42
|
-
# === link
|
43
|
-
# ===================================================================== #
|
44
|
-
when 'link'
|
45
|
-
return ssymlink(i)
|
46
|
-
else
|
47
|
-
e "module Colours: We do not know the filetype `#{ftype}`"
|
48
|
-
end
|
49
|
-
else # Else return the input a bit changed.
|
50
|
-
return sfile(i) # We modify it because that is better.
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'colours/toplevel_methods/esystem.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module Colours
|
8
|
-
|
9
|
-
require 'colours/toplevel_methods/e.rb'
|
10
|
-
|
11
|
-
# ========================================================================= #
|
12
|
-
# === esystem
|
13
|
-
# ========================================================================= #
|
14
|
-
def self.esystem(i)
|
15
|
-
e i
|
16
|
-
system i
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'colours/toplevel_methods/html_colour_to_hex_value.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module Colours
|
8
|
-
|
9
|
-
require 'yaml'
|
10
|
-
require 'colours/constants/file_constants.rb'
|
11
|
-
|
12
|
-
# ========================================================================= #
|
13
|
-
# === Colours.html_colour_to_hex_value
|
14
|
-
# ========================================================================= #
|
15
|
-
def self.html_colour_to_hex_value(
|
16
|
-
this_html_colour,
|
17
|
-
return_with_hash_key = true
|
18
|
-
)
|
19
|
-
if this_html_colour.is_a? Array
|
20
|
-
this_html_colour = this_html_colour.first
|
21
|
-
end
|
22
|
-
_ = file_html_colours_to_rgb?
|
23
|
-
if File.exist? _
|
24
|
-
# ===================================================================== #
|
25
|
-
# Load the yaml-file next:
|
26
|
-
# ===================================================================== #
|
27
|
-
dataset = YAML.load_file(_)
|
28
|
-
if dataset.has_key? this_html_colour
|
29
|
-
_ = dataset[this_html_colour].last
|
30
|
-
if return_with_hash_key
|
31
|
-
_ = _.dup if _.frozen?
|
32
|
-
_ = _.to_s unless _.is_a? String
|
33
|
-
_[0,0] = '#' if _.respond_to? :[]=
|
34
|
-
end
|
35
|
-
return _
|
36
|
-
end
|
37
|
-
end
|
38
|
-
return this_html_colour
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'colours/toplevel_methods/html_colourize.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module Colours
|
8
|
-
|
9
|
-
require 'colours/toplevel_methods/revert.rb'
|
10
|
-
|
11
|
-
# ========================================================================= #
|
12
|
-
# === Colours.html_colourize
|
13
|
-
#
|
14
|
-
# This method will simply return the colour-code + text.
|
15
|
-
#
|
16
|
-
# The third argument, called `append_revert`, can be used to determine
|
17
|
-
# whether we will append the revert code to the generated output String
|
18
|
-
# or whether we will not. By default we will, but there are examples
|
19
|
-
# where we may wish to assemble our own colour string, and in these
|
20
|
-
# cases we do not yet know which text is to be shown - hence, this
|
21
|
-
# must become an optional argument.
|
22
|
-
#
|
23
|
-
# A block can be passed to this method. If the block has, as content,
|
24
|
-
# the Symbol :omit_end then the end-part of the ANSI code will not
|
25
|
-
# be used.
|
26
|
-
#
|
27
|
-
# Usage examples:
|
28
|
-
#
|
29
|
-
# x = Colours.colourize('slateblue', 'Hello world!'); pp x
|
30
|
-
# y = Colours.colourize('slateblue', 'Hello world!') { :omit_end }; pp y
|
31
|
-
#
|
32
|
-
# ========================================================================= #
|
33
|
-
def self.html_colourize(
|
34
|
-
colour_to_use = return_random_html_colour,
|
35
|
-
this_text = nil,
|
36
|
-
append_revert = true,
|
37
|
-
&block
|
38
|
-
)
|
39
|
-
require 'colours/html_colours/html_colours.rb'
|
40
|
-
require 'colours/rgb/rgb.rb'
|
41
|
-
if block_given?
|
42
|
-
yielded = yield
|
43
|
-
case yielded
|
44
|
-
# ===================================================================== #
|
45
|
-
# === :omit_end
|
46
|
-
# ===================================================================== #
|
47
|
-
when :omit_end
|
48
|
-
append_revert = false
|
49
|
-
end
|
50
|
-
end
|
51
|
-
if this_text.nil?
|
52
|
-
this_text = colour_to_use.to_s.dup
|
53
|
-
end
|
54
|
-
if append_revert
|
55
|
-
"#{rgb_value_as_escape_code_string(colour_to_use)}#{this_text}#{revert}"
|
56
|
-
else
|
57
|
-
"#{rgb_value_as_escape_code_string(colour_to_use)}#{this_text}"
|
58
|
-
end
|
59
|
-
end; self.instance_eval { alias colourize html_colourize } # === Colours.colourize
|
60
|
-
self.instance_eval { alias kde_colour html_colourize } # === Colours.kde_colour
|
61
|
-
self.instance_eval { alias konsole_colours html_colourize } # === Colours.konsole_colours
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
if __FILE__ == $PROGRAM_NAME
|
66
|
-
alias e puts
|
67
|
-
e Colours.html_colourize('slateblue', 'Hello world 1!')
|
68
|
-
e Colours.html_colourize(:crimson, 'Hello world 2!')
|
69
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# Encoding: UTF-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
# =========================================================================== #
|
5
|
-
# require 'colours/toplevel_methods/is_on_roebe.rb'
|
6
|
-
# =========================================================================== #
|
7
|
-
module Colours
|
8
|
-
|
9
|
-
# ========================================================================= #
|
10
|
-
# === Colours.is_on_roebe?
|
11
|
-
# ========================================================================= #
|
12
|
-
def self.is_on_roebe?
|
13
|
-
ENV['IS_ROEBE'].to_s == '1'
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|