colours 0.8.12

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.
Files changed (143) hide show
  1. checksums.yaml +7 -0
  2. data/LICENCE.md +22 -0
  3. data/README.md +1152 -0
  4. data/bin/colours +7 -0
  5. data/bin/egreen +7 -0
  6. data/bin/fancy_parse +7 -0
  7. data/bin/html_colour_to_hex_value +7 -0
  8. data/bin/html_colourize +7 -0
  9. data/bin/orange +7 -0
  10. data/bin/print_rainbow_line +7 -0
  11. data/bin/rainbow_colours +7 -0
  12. data/bin/remove_ansii_escape_sequences +7 -0
  13. data/bin/steelblue +7 -0
  14. data/colours.gemspec +74 -0
  15. data/doc/COLOUR_CODES_CHART.md +27 -0
  16. data/doc/HOW_TO_PICK_YOUR_OWN_COLOURS.md +28 -0
  17. data/doc/README.gen +1105 -0
  18. data/doc/todo/todo.md +25 -0
  19. data/lib/colours/256_colours/support_for_256_colours.rb +196 -0
  20. data/lib/colours/autoalias_e.rb +10 -0
  21. data/lib/colours/autogenerated/README.md +2 -0
  22. data/lib/colours/autogenerated/support_for_256_colours.rb +2235 -0
  23. data/lib/colours/autogenerated/support_for_html_colours.rb +1778 -0
  24. data/lib/colours/autogenerated/toplevel_basic_colour_methods.rb +7001 -0
  25. data/lib/colours/autoinclude.rb +14 -0
  26. data/lib/colours/base/base.rb +29 -0
  27. data/lib/colours/basic_colours/README.md +4 -0
  28. data/lib/colours/basic_colours/basic_colours.rb +334 -0
  29. data/lib/colours/class/colours.rb +537 -0
  30. data/lib/colours/colour_methods/README.md +11 -0
  31. data/lib/colours/colour_methods/colour_methods.rb +685 -0
  32. data/lib/colours/colour_table/README.md +2 -0
  33. data/lib/colours/colour_table/colour_table.rb +282 -0
  34. data/lib/colours/colours_e_autoinclude.rb +9 -0
  35. data/lib/colours/commandline/README.md +2 -0
  36. data/lib/colours/commandline/commandline.rb +58 -0
  37. data/lib/colours/commandline/menu.rb +122 -0
  38. data/lib/colours/constants/constants.rb +9 -0
  39. data/lib/colours/constants/escape.rb +22 -0
  40. data/lib/colours/constants/file_constants.rb +73 -0
  41. data/lib/colours/constants/hash_ansi_colours.rb +39 -0
  42. data/lib/colours/constants/hash_simple_colours.rb +148 -0
  43. data/lib/colours/constants/misc.rb +361 -0
  44. data/lib/colours/constants/newline.rb +14 -0
  45. data/lib/colours/constants/registered_colour_methods.rb +53 -0
  46. data/lib/colours/e/README.md +13 -0
  47. data/lib/colours/e/autoinclude.rb +11 -0
  48. data/lib/colours/e/e.rb +35 -0
  49. data/lib/colours/e.rb +5 -0
  50. data/lib/colours/eparse/eparse.rb +114 -0
  51. data/lib/colours/everything/autoinclude.rb +11 -0
  52. data/lib/colours/html_colours/README.md +1 -0
  53. data/lib/colours/html_colours/add_html_colours_onto_the_toplevel_namespace.rb +22 -0
  54. data/lib/colours/html_colours/html_colours.rb +424 -0
  55. data/lib/colours/kde_colour_palette/kde_colour_palette.rb +132 -0
  56. data/lib/colours/map_symbol_to_corresponding_colour/map_symbol_to_corresponding_colour.rb +224 -0
  57. data/lib/colours/module.rb +11 -0
  58. data/lib/colours/project/project.rb +22 -0
  59. data/lib/colours/rainbow_colours/README.md +2 -0
  60. data/lib/colours/rainbow_colours/check_for_trollop_being_available_or_exit.rb +26 -0
  61. data/lib/colours/rainbow_colours/constants.rb +30 -0
  62. data/lib/colours/rainbow_colours/do_parse_via_rainbow_colours.rb +164 -0
  63. data/lib/colours/rainbow_colours/paint_detected_mode.rb +20 -0
  64. data/lib/colours/rainbow_colours/print_rainbow_line.rb +68 -0
  65. data/lib/colours/rainbow_colours/println_ani.rb +32 -0
  66. data/lib/colours/rainbow_colours/println_plain.rb +36 -0
  67. data/lib/colours/rainbow_colours/rainbow.rb +38 -0
  68. data/lib/colours/rainbow_colours/report_errors.rb +32 -0
  69. data/lib/colours/rainbow_colours/returnln_plain.rb +63 -0
  70. data/lib/colours/rainbow_colours/set_mode.rb +24 -0
  71. data/lib/colours/requires/require_autogenerated_colour_methods.rb +5 -0
  72. data/lib/colours/requires/require_commandline.rb +7 -0
  73. data/lib/colours/requires/require_eparse.rb +11 -0
  74. data/lib/colours/requires/require_rgb.rb +5 -0
  75. data/lib/colours/requires/require_the_256_colours_module.rb +16 -0
  76. data/lib/colours/requires/require_the_basic_colours.rb +7 -0
  77. data/lib/colours/requires/require_the_colour_methods.rb +34 -0
  78. data/lib/colours/requires/require_the_colour_table.rb +7 -0
  79. data/lib/colours/requires/require_the_constants.rb +5 -0
  80. data/lib/colours/requires/require_the_html_colours.rb +11 -0
  81. data/lib/colours/requires/require_the_kde_colour_palette.rb +7 -0
  82. data/lib/colours/requires/require_the_project.rb +53 -0
  83. data/lib/colours/requires/require_the_toplevel_methods.rb +42 -0
  84. data/lib/colours/requires/require_yaml.rb +9 -0
  85. data/lib/colours/rgb/rgb.rb +550 -0
  86. data/lib/colours/testing/README.md +2 -0
  87. data/lib/colours/testing/testing.rb +168 -0
  88. data/lib/colours/toplevel_methods/autogenerate.rb +310 -0
  89. data/lib/colours/toplevel_methods/bold.rb +41 -0
  90. data/lib/colours/toplevel_methods/bold_and_italic.rb +38 -0
  91. data/lib/colours/toplevel_methods/cat.rb +39 -0
  92. data/lib/colours/toplevel_methods/clear_screen.rb +18 -0
  93. data/lib/colours/toplevel_methods/cliner.rb +17 -0
  94. data/lib/colours/toplevel_methods/col.rb +54 -0
  95. data/lib/colours/toplevel_methods/e.rb +69 -0
  96. data/lib/colours/toplevel_methods/esystem.rb +19 -0
  97. data/lib/colours/toplevel_methods/html_colour_to_hex_value.rb +41 -0
  98. data/lib/colours/toplevel_methods/html_colourize.rb +69 -0
  99. data/lib/colours/toplevel_methods/is_on_roebe.rb +16 -0
  100. data/lib/colours/toplevel_methods/italic.rb +110 -0
  101. data/lib/colours/toplevel_methods/make_colour.rb +28 -0
  102. data/lib/colours/toplevel_methods/methods_related_to_html_colours.rb +336 -0
  103. data/lib/colours/toplevel_methods/misc.rb +226 -0
  104. data/lib/colours/toplevel_methods/open_this_file.rb +26 -0
  105. data/lib/colours/toplevel_methods/prefer_this_colour_schemata.rb +88 -0
  106. data/lib/colours/toplevel_methods/random_value.rb +37 -0
  107. data/lib/colours/toplevel_methods/remove_escape_sequence.rb +112 -0
  108. data/lib/colours/toplevel_methods/revert.rb +104 -0
  109. data/lib/colours/toplevel_methods/set_last_colour_used.rb +32 -0
  110. data/lib/colours/toplevel_methods/shell_file_containing_the_html_colours.sh +148 -0
  111. data/lib/colours/toplevel_methods/show_basic_colour_palette.rb +36 -0
  112. data/lib/colours/toplevel_methods/underline.rb +130 -0
  113. data/lib/colours/toplevel_methods/use_colours.rb +290 -0
  114. data/lib/colours/version/version.rb +25 -0
  115. data/lib/colours/yaml/256_colours.yml +279 -0
  116. data/lib/colours/yaml/basic_colours.yml +25 -0
  117. data/lib/colours/yaml/html_colours.yml +837 -0
  118. data/lib/colours/yaml/kde_colour_palette.yml +183 -0
  119. data/lib/colours/yaml/prefer_this_colour_schemata.yml +17 -0
  120. data/lib/colours/yaml/use_these_values_for_the_colour_methods.yml +15 -0
  121. data/lib/colours.rb +1 -0
  122. data/test/test.html +18 -0
  123. data/test/testing_256_colours_support.rb +29 -0
  124. data/test/testing_bold_italic_underline.rb +26 -0
  125. data/test/testing_class_colours.rb +46 -0
  126. data/test/testing_col.rb +10 -0
  127. data/test/testing_colours.rb +96 -0
  128. data/test/testing_colours_e.rb +13 -0
  129. data/test/testing_eparse.rb +13 -0
  130. data/test/testing_italic.rb +28 -0
  131. data/test/testing_kde_colour_palette.rb +30 -0
  132. data/test/testing_konsole_submodule.rb +226 -0
  133. data/test/testing_map_symbol_to_corresponding_colour.rb +14 -0
  134. data/test/testing_replace_number_words_with_the_corresponding_html_colour.rb +39 -0
  135. data/test/testing_rgb_to_hex.rb +32 -0
  136. data/test/testing_the_basic_colours_of_the_colours_project.rb +62 -0
  137. data/test/testing_the_colour_methods.rb +36 -0
  138. data/test/testing_the_constants_of_the_colours_project.rb +9 -0
  139. data/test/testing_the_ecomment_method.rb +11 -0
  140. data/test/testing_the_html_colours_of_the_colours_project.rb +37 -0
  141. data/test/testing_the_regex_for_capturing_the_commandline_coloured_content.rb +112 -0
  142. data/test/testing_whether_colours_will_be_used.rb +7 -0
  143. metadata +225 -0
@@ -0,0 +1,685 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'colours/colour_methods/colour_methods.rb'
6
+ # =========================================================================== #
7
+ module Colours
8
+
9
+ require 'colours/toplevel_methods/revert.rb'
10
+ require 'colours/colour_table/colour_table.rb'
11
+ require 'colours/map_symbol_to_corresponding_colour/map_symbol_to_corresponding_colour.rb'
12
+ require 'colours/autogenerated/support_for_html_colours.rb'
13
+
14
+ # ========================================================================= #
15
+ # === Colours.ecomment
16
+ #
17
+ # This method was added on Nov 2013.
18
+ #
19
+ # In April 2014, the ability to split at any arbitrary character was
20
+ # added, which can be controlled via the second argument given to
21
+ # that method. By default it will split on the token '#'.
22
+ # ========================================================================= #
23
+ def self.ecomment(
24
+ i,
25
+ optional_split_at_this_character = '#', # ← Specify which character to split at.
26
+ first_colour_to_use = :steelblue,
27
+ second_colour_to_use = :seagreen,
28
+ colour_to_use_for_the_token = :slategray
29
+ )
30
+ _ = i.to_s
31
+ if optional_split_at_this_character.is_a? Hash
32
+ # ===================================================================== #
33
+ # === :token
34
+ # ===================================================================== #
35
+ if optional_split_at_this_character.has_key? :token
36
+ optional_split_at_this_character = optional_split_at_this_character.delete :token
37
+ end
38
+ end
39
+ optional_split_at_this_character = optional_split_at_this_character.to_s
40
+ # ======================================================================= #
41
+ # === If we can find a token to split at
42
+ # ======================================================================= #
43
+ if _.include? optional_split_at_this_character
44
+ _ = _.dup if _.frozen?
45
+ splitted = _.split(optional_split_at_this_character)
46
+ first_part = ::Colours::SupportForHTMLColours.send(first_colour_to_use, splitted.first)
47
+ middle_part = ::Colours::SupportForHTMLColours.send(colour_to_use_for_the_token, optional_split_at_this_character)
48
+ second_part = ::Colours::SupportForHTMLColours.send(second_colour_to_use, splitted.last)
49
+ _ = first_part+
50
+ middle_part+
51
+ second_part+
52
+ ::Colours.rev
53
+ end
54
+ e _
55
+ end
56
+
57
+ # ========================================================================= #
58
+ # === Colours.default_colour
59
+ #
60
+ # Invocation example:
61
+ #
62
+ # puts Colours.default_colour('Hello world!')
63
+ #
64
+ # ========================================================================= #
65
+ def self.default_colour(
66
+ i = '',
67
+ make_newline = false
68
+ )
69
+ if @use_colours
70
+ if make_newline
71
+ i = "#{i}#{N}"
72
+ end
73
+ if @use_html_colours
74
+ i = SupportForHTMLColours.send(@colour_table[__method__.to_sym], i)
75
+ elsif @use_256_colours
76
+ use_this_colour = map_this_symbol_to_that_256_colour(@colour_table[__method__.to_sym])
77
+ i = SupportFor256Colours.send(use_this_colour, i)
78
+ else
79
+ i = "#{corresponding_colour?(@colour_table[__method__.to_sym])}"\
80
+ "#{i}"\
81
+ "#{rev}"
82
+ end
83
+ end
84
+ return i
85
+ end
86
+
87
+ # ========================================================================= #
88
+ # === edir
89
+ # ========================================================================= #
90
+ def edefault_colour(
91
+ i = '',
92
+ make_newline = false
93
+ )
94
+ e ::Colours.default_colour(i, make_newline)
95
+ end
96
+
97
+ # ========================================================================= #
98
+ # === default_colour
99
+ # ========================================================================= #
100
+ def default_colour(i = '')
101
+ ::Colours.default_colour(i)
102
+ end
103
+
104
+ # ========================================================================= #
105
+ # === edir
106
+ # ========================================================================= #
107
+ def edir(
108
+ i = '',
109
+ make_newline = false
110
+ )
111
+ e ::Colours.sdir(i, make_newline)
112
+ end
113
+
114
+ # ========================================================================= #
115
+ # === sdir
116
+ # ========================================================================= #
117
+ def sdir(
118
+ i = '', make_newline = false
119
+ )
120
+ ::Colours::sdir(i, make_newline)
121
+ end
122
+
123
+ # ========================================================================= #
124
+ # === Colours.sargument
125
+ #
126
+ # Invocation example:
127
+ #
128
+ # Colours.sargument('Hello world!')
129
+ #
130
+ # ========================================================================= #
131
+ def self.sargument(
132
+ i = '',
133
+ make_newline = false
134
+ )
135
+ if make_newline
136
+ i = "#{i}#{N}"
137
+ end
138
+ if @use_colours
139
+ if @use_html_colours
140
+ i = SupportForHTMLColours.send(@colour_table[__method__.to_sym], i)
141
+ elsif @use_256_colours
142
+ use_this_colour = map_this_symbol_to_that_256_colour(@colour_table[__method__.to_sym])
143
+ i = SupportFor256Colours.send(use_this_colour, i)
144
+ else
145
+ i = "#{corresponding_colour?(@colour_table[__method__.to_sym])}"\
146
+ "#{i}"\
147
+ "#{rev}"
148
+ end
149
+ end
150
+ i
151
+ end; self.instance_eval { alias argument sargument } # === Colours.argument
152
+ self.instance_eval { alias sarg sargument } # === Colours.sarg
153
+
154
+ # ========================================================================= #
155
+ # === sargument
156
+ # ========================================================================= #
157
+ def sargument(
158
+ i = '',
159
+ make_newline = false
160
+ )
161
+ ::Colours.sargument(i, make_newline)
162
+ end; alias sarg sargument # === sarg
163
+
164
+ # ========================================================================= #
165
+ # === eargument
166
+ #
167
+ # The various simple colourize methods.
168
+ # ========================================================================= #
169
+ def eargument(
170
+ i = '',
171
+ make_newline = false
172
+ )
173
+ e ::Colours.sargument(i, make_newline)
174
+ end
175
+
176
+ # ========================================================================= #
177
+ # === Colours.sdir
178
+ #
179
+ # Invocation example:
180
+ #
181
+ # puts Colours.sdir('Hello world!')
182
+ #
183
+ # ========================================================================= #
184
+ def self.sdir(
185
+ i = '',
186
+ make_newline = false
187
+ )
188
+ if make_newline
189
+ i = "#{i}#{N}"
190
+ end
191
+ if @use_colours
192
+ if @use_html_colours
193
+ i = SupportForHTMLColours.send(@colour_table[__method__.to_sym], i)
194
+ elsif @use_256_colours
195
+ use_this_colour = map_this_symbol_to_that_256_colour(@colour_table[__method__.to_sym])
196
+ i = SupportFor256Colours.send(use_this_colour, i)
197
+ else
198
+ i = "#{corresponding_colour?(@colour_table[__method__.to_sym])}"\
199
+ "#{i}"\
200
+ "#{rev}"
201
+ end
202
+ end
203
+ i
204
+ end
205
+
206
+ # ========================================================================= #
207
+ # === Colours.sfile_or_sdir
208
+ #
209
+ # This method will directly delegate to either Colours.sfile() or
210
+ # Colours.sdir().
211
+ #
212
+ # Usage example:
213
+ #
214
+ # Colours.sfile_or_sdir('/home/x/Temp/MyGems/')
215
+ # Colours.sfile_or_sdir('/home/x/Temp/opened_files.yml')
216
+ #
217
+ # ========================================================================= #
218
+ def self.sfile_or_sdir(
219
+ i = '',
220
+ make_newline = false
221
+ )
222
+ if File.exist?(i) and File.file?(i)
223
+ return ::Colours.sfile(i, make_newline)
224
+ elsif File.directory?(i)
225
+ return ::Colours.sdir(i, make_newline)
226
+ end
227
+ end; self.instance_eval { alias sdir_or_sfile sfile_or_sdir } # === Colours.sdir_or_sfile
228
+
229
+ # ========================================================================= #
230
+ # === Colours.sfile
231
+ #
232
+ # This method can be explicitely used to colour files, such as
233
+ # '/opt/foobar.rb'.
234
+ #
235
+ # Invocation examples:
236
+ #
237
+ # Colours.sfile('/opt/foobar.rb')
238
+ # Colours.sfile('/tmp/test.md')
239
+ # Colours.sfile('Hello world!')
240
+ #
241
+ # ========================================================================= #
242
+ def self.sfile(
243
+ i = '',
244
+ make_newline = false
245
+ )
246
+ if @use_colours
247
+ if @use_html_colours
248
+ i = SupportForHTMLColours.send(
249
+ map_this_symbol_to_that_html_colour(@colour_table[__method__.to_sym]), i
250
+ )
251
+ elsif @use_256_colours
252
+ use_this_colour = map_this_symbol_to_that_256_colour(@colour_table[__method__.to_sym])
253
+ i = SupportFor256Colours.send(use_this_colour, i)
254
+ else
255
+ i = "#{corresponding_colour?(@colour_table[__method__.to_sym])}"\
256
+ "#{i}"\
257
+ "#{rev}"
258
+ end
259
+ end
260
+ i
261
+ end
262
+
263
+ # ========================================================================= #
264
+ # === sfile
265
+ # ========================================================================= #
266
+ def sfile(
267
+ i = '', make_newline = false
268
+ )
269
+ ::Colours.sfile(i, make_newline)
270
+ end
271
+
272
+ # ========================================================================= #
273
+ # === efile
274
+ # ========================================================================= #
275
+ def efile(
276
+ i = '',
277
+ make_newline = false
278
+ )
279
+ e sfile(i, make_newline)
280
+ end
281
+
282
+ # ========================================================================= #
283
+ # === Colours.snormal
284
+ #
285
+ # Invocation example:
286
+ #
287
+ # Colours.snormal('Hello world!')
288
+ #
289
+ # ========================================================================= #
290
+ def self.snormal(
291
+ i = '',
292
+ make_newline = false
293
+ )
294
+ if @use_colours
295
+ if @use_html_colours
296
+ i = SupportForHTMLColours.send(
297
+ map_this_symbol_to_that_html_colour(@colour_table[__method__.to_sym]), i
298
+ )
299
+ elsif @use_256_colours
300
+ use_this_colour = map_this_symbol_to_that_256_colour(@colour_table[__method__.to_sym])
301
+ i = SupportFor256Colours.send(use_this_colour, i)
302
+ else
303
+ i = "#{corresponding_colour?(@colour_table[__method__.to_sym])}"\
304
+ "#{i}"\
305
+ "#{rev}"
306
+ end
307
+ end
308
+ i
309
+ end
310
+
311
+ # ========================================================================= #
312
+ # === snormal
313
+ # ========================================================================= #
314
+ def snormal(
315
+ i = '',
316
+ make_newline = false
317
+ )
318
+ ::Colours.snormal(i, make_newline)
319
+ end
320
+
321
+ # ========================================================================= #
322
+ # === enormal
323
+ # ========================================================================= #
324
+ def enormal(
325
+ i = '',
326
+ make_newline = false
327
+ )
328
+ e snormal(i, make_newline)
329
+ end
330
+
331
+ # ========================================================================= #
332
+ # === Colours.simportant
333
+ #
334
+ #This method is the one to denote "important" text components.
335
+ #
336
+ # Invocation examples:
337
+ #
338
+ # Colours.simportant('Hello world!')
339
+ # Colours.simportant('yo there')
340
+ #
341
+ # ========================================================================= #
342
+ def self.simportant(
343
+ i = '',
344
+ make_newline = false
345
+ )
346
+ if @use_colours
347
+ if @use_html_colours
348
+ i = SupportForHTMLColours.send(
349
+ map_this_symbol_to_that_html_colour(@colour_table[__method__.to_sym]), i
350
+ )
351
+ elsif @use_256_colours
352
+ use_this_colour = map_this_symbol_to_that_256_colour(@colour_table[__method__.to_sym])
353
+ i = SupportFor256Colours.send(use_this_colour, i)
354
+ else
355
+ i = "#{corresponding_colour?(@colour_table[__method__.to_sym])}"\
356
+ "#{i}"\
357
+ "#{rev}"
358
+ end
359
+ end
360
+ i
361
+ end; self.instance_eval { alias simp simportant } # === Colours.simp
362
+
363
+ # ========================================================================= #
364
+ # === simportant
365
+ #
366
+ # Delegate towards Colours.simportant() here.
367
+ # ========================================================================= #
368
+ def simportant(
369
+ i = '',
370
+ make_newline = false
371
+ )
372
+ ::Colours.simportant(i, make_newline)
373
+ end; alias simp simportant # === simp
374
+ alias si simportant # === si
375
+
376
+ # ========================================================================= #
377
+ # === ciif
378
+ # ========================================================================= #
379
+ def ciif(i)
380
+ eimportant(i, false)
381
+ end # Alias to the above, basically.
382
+
383
+ # ========================================================================= #
384
+ # === Colours.eimp
385
+ # ========================================================================= #
386
+ def self.eimp(
387
+ i = '',
388
+ make_newline = false
389
+ )
390
+ e simp(i, make_newline)
391
+ end
392
+
393
+ # ========================================================================= #
394
+ # === eimportant
395
+ # ========================================================================= #
396
+ def eimportant(
397
+ i = '',
398
+ make_newline = false
399
+ )
400
+ ::Colours.eimp(i, make_newline)
401
+ end; alias eimp eimportant # === eimp
402
+ alias cii eimportant # === cii
403
+
404
+ # ========================================================================= #
405
+ # === Colours.swarn
406
+ #
407
+ # Invocation example:
408
+ #
409
+ # Colours.swarn('Hello world!')
410
+ #
411
+ # ========================================================================= #
412
+ def self.swarn(
413
+ i = '',
414
+ make_newline = false
415
+ )
416
+ if @use_colours
417
+ if @use_html_colours
418
+ i = SupportForHTMLColours.send(
419
+ map_this_symbol_to_that_html_colour(@colour_table[__method__.to_sym]), i
420
+ )
421
+ elsif @use_256_colours
422
+ use_this_colour = map_this_symbol_to_that_256_colour(@colour_table[__method__.to_sym])
423
+ i = SupportFor256Colours.send(use_this_colour, i)
424
+ else
425
+ i = "#{corresponding_colour?(@colour_table[__method__.to_sym])}"\
426
+ "#{i}"\
427
+ "#{rev}"
428
+ end
429
+ end
430
+ i
431
+ end
432
+
433
+ # ========================================================================= #
434
+ # === swarn
435
+ # ========================================================================= #
436
+ def swarn(
437
+ i = '',
438
+ make_newline = false
439
+ )
440
+ ::Colours.swarn(i, make_newline)
441
+ end
442
+
443
+ # ========================================================================= #
444
+ # === Colours.ewarn
445
+ # ========================================================================= #
446
+ def self.ewarn(
447
+ i = '',
448
+ make_newline = false
449
+ )
450
+ e swarn(i, make_newline)
451
+ end
452
+
453
+ # ========================================================================= #
454
+ # === ewarn
455
+ # ========================================================================= #
456
+ def ewarn(
457
+ i = '',
458
+ make_newline = false
459
+ )
460
+ ::Colours.ewarn(i, make_newline)
461
+ end
462
+
463
+ # ========================================================================= #
464
+ # === Colours.ssymlink
465
+ #
466
+ # Invocation example:
467
+ #
468
+ # Colours.ssymlink('Hello world!')
469
+ #
470
+ # ========================================================================= #
471
+ def self.ssymlink(
472
+ i = '',
473
+ make_newline = false
474
+ )
475
+ if @use_colours
476
+ if @use_html_colours
477
+ i = SupportForHTMLColours.send(
478
+ map_this_symbol_to_that_html_colour(@colour_table[__method__.to_sym]), i
479
+ )
480
+ elsif @use_256_colours
481
+ use_this_colour = map_this_symbol_to_that_256_colour(@colour_table[__method__.to_sym])
482
+ i = SupportFor256Colours.send(use_this_colour, i)
483
+ else
484
+ i = "#{corresponding_colour?(@colour_table[__method__.to_sym])}"\
485
+ "#{i}"\
486
+ "#{rev}"
487
+ end
488
+ end
489
+ i
490
+ end; self.instance_eval { alias sym ssymlink } # === Colours.sym
491
+ self.instance_eval { alias ssym ssymlink } # === Colours.ssym
492
+
493
+ # ========================================================================= #
494
+ # === Colours.colour_for_symlinks
495
+ #
496
+ # This method will simply return the colour for symlinks.
497
+ # ========================================================================= #
498
+ def self.colour_for_symlinks
499
+ result = ''.dup
500
+ if @use_colours
501
+ if @use_html_colours
502
+ result = SupportForHTMLColours.send(
503
+ map_this_symbol_to_that_html_colour(@colour_table[:ssymlink])
504
+ )
505
+ elsif @use_256_colours
506
+ use_this_colour = map_this_symbol_to_that_256_colour(@colour_table[__method__.to_sym])
507
+ result = SupportFor256Colours.send(use_this_colour)
508
+ else
509
+ result = "#{corresponding_colour?(@colour_table[__method__.to_sym])}"
510
+ end
511
+ end
512
+ result
513
+ end
514
+
515
+ # ========================================================================= #
516
+ # === ssymlink
517
+ #
518
+ # Note that a symlink called symlink() exists to this method, but it
519
+ # is not exactly clear whether this alias will be kept, as it may
520
+ # interfere with some other methods when we do an include-action.
521
+ # ========================================================================= #
522
+ def ssymlink(i = '')
523
+ ::Colours.ssymlink(i)
524
+ end; alias symlink ssymlink # === symlink
525
+ alias ssym ssymlink # === ssym
526
+ alias slink ssymlink # === slink
527
+
528
+ # ========================================================================= #
529
+ # === Colours.esymlink
530
+ # ========================================================================= #
531
+ def self.esymlink(
532
+ i = '',
533
+ make_newline = false
534
+ )
535
+ e ::Colours.ssymlink(i, make_newline)
536
+ end
537
+
538
+ # ========================================================================= #
539
+ # === esymlink
540
+ # ========================================================================= #
541
+ def esymlink(
542
+ i = '',
543
+ make_newline = false
544
+ )
545
+ ::Colours.esymlink(i, make_newline)
546
+ end
547
+
548
+ # ========================================================================= #
549
+ # === Colours.sfancy
550
+ #
551
+ # Invocation example:
552
+ #
553
+ # Colours.sfancy('Hello world!')
554
+ #
555
+ # ========================================================================= #
556
+ def self.sfancy(
557
+ i = '',
558
+ make_newline = false
559
+ )
560
+ if @use_colours
561
+ if @use_html_colours
562
+ i = SupportForHTMLColours.send(
563
+ map_this_symbol_to_that_html_colour(@colour_table[__method__.to_sym]), i
564
+ )
565
+ elsif @use_256_colours
566
+ use_this_colour = map_this_symbol_to_that_256_colour(@colour_table[__method__.to_sym])
567
+ i = SupportFor256Colours.send(use_this_colour, i)
568
+ else
569
+ i = "#{corresponding_colour?(@colour_table[__method__.to_sym])}"\
570
+ "#{i}"\
571
+ "#{rev}"
572
+ end
573
+ end
574
+ i
575
+ end
576
+
577
+ # ========================================================================= #
578
+ # === Colours.efancy
579
+ #
580
+ # This simply will output the result from sfancy(), defined above.
581
+ # ========================================================================= #
582
+ def self.efancy(
583
+ i = '',
584
+ make_newline = false
585
+ )
586
+ e sfancy(i, make_newline)
587
+ end
588
+
589
+ # ========================================================================= #
590
+ # === efancy
591
+ # ========================================================================= #
592
+ def efancy(
593
+ i = '',
594
+ make_newline = false
595
+ )
596
+ ::Colours.efancy(i, make_newline)
597
+ end; alias f efancy # === f (f tag)
598
+
599
+ # ========================================================================= #
600
+ # === sfancy
601
+ # ========================================================================= #
602
+ def sfancy(i = '')
603
+ ::Colours.sfancy(i)
604
+ end
605
+
606
+ # ========================================================================= #
607
+ # === cif
608
+ #
609
+ # This is efancy, but we won't use newlines.
610
+ # ========================================================================= #
611
+ def cif(i)
612
+ efancy(i, false)
613
+ end; alias ff cif # === ff (alias to the above ^^^)
614
+
615
+ # ========================================================================= #
616
+ # === Colours.scomments
617
+ #
618
+ # Invocation example:
619
+ #
620
+ # Colours.scomments('Hello world!')
621
+ #
622
+ # ========================================================================= #
623
+ def self.scomments(
624
+ i = '',
625
+ make_newline = false
626
+ )
627
+ if @use_colours
628
+ if @use_html_colours
629
+ i = SupportForHTMLColours.send(@colour_table[__method__.to_sym], i)
630
+ elsif @use_256_colours
631
+ use_this_colour = map_this_symbol_to_that_256_colour(@colour_table[__method__.to_sym])
632
+ i = SupportFor256Colours.send(use_this_colour, i)
633
+ else
634
+ i = "#{corresponding_colour?(@colour_table[__method__.to_sym])}"\
635
+ "#{i}"\
636
+ "#{rev}"
637
+ end
638
+ end
639
+ i
640
+ end; self.instance_eval { alias comment scomments } # === Colours.comment
641
+
642
+ # ========================================================================= #
643
+ # === scomments
644
+ # ========================================================================= #
645
+ def scomments(i = '')
646
+ ::Colours.scomments(i) # Delegate towards Colours.scomments? here.
647
+ end; alias scomment scomments # === scomment
648
+
649
+ # ========================================================================= #
650
+ # === Colours.scomments?
651
+ #
652
+ # This method will usually return :grey.
653
+ # ========================================================================= #
654
+ def self.scomments?
655
+ colour_table?[:scomments]
656
+ end
657
+
658
+ # ========================================================================= #
659
+ # === ecomment
660
+ #
661
+ # Just a wrapper over the Colours.ecomment() functionality.
662
+ # ========================================================================= #
663
+ def ecomment(
664
+ i,
665
+ optional_split_at_this_character = '#'
666
+ )
667
+ ::Colours.ecomment(i, optional_split_at_this_character)
668
+ end
669
+
670
+ end
671
+
672
+ if __FILE__ == $PROGRAM_NAME
673
+ alias e puts
674
+ e ::Colours.sargument('Hello world!')
675
+ e ::Colours.sfile('Hello world!')+' And this should appear in another colour.'
676
+ e ::Colours.snormal('Hello world!')
677
+ e ::Colours.simportant('Hello world!')
678
+ e ::Colours.swarn('Hello world!')
679
+ e ::Colours.ssymlink('Hello world!')
680
+ e ::Colours.sfancy('Hello world!')
681
+ e ::Colours.default_colour('Hello world!')
682
+ e ::Colours.sdir('Hello world!')
683
+ e ::Colours.scomments('Hello world!')
684
+ ::Colours.ecomment('Hello world! # this is the associated comment')
685
+ end
@@ -0,0 +1,2 @@
1
+ This directory will contain code for the colour-table, that is a table that
2
+ maps from e. g. sfancy() to the corresponding colour at hand.