colours 0.8.12 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +331 -200
  3. data/bin/colours +2 -2
  4. data/bin/show_basic_colour_palette +7 -0
  5. data/colours.gemspec +1 -2
  6. data/doc/README.gen +294 -178
  7. data/doc/how_to_pick_your_own_colours/how_to_pick_your_own_colours.md +33 -0
  8. data/lib/colours/autoalias_e.rb +4 -1
  9. data/lib/colours/autogenerated/256_colours_instance_methods.rb +1429 -0
  10. data/lib/colours/autogenerated/256_colours_methods.rb +1429 -0
  11. data/lib/colours/autogenerated/html_colours_instance_methods.rb +1191 -0
  12. data/lib/colours/autogenerated/html_colours_methods.rb +1191 -0
  13. data/lib/colours/base/base.rb +61 -13
  14. data/lib/colours/class/colours.rb +8 -6
  15. data/lib/colours/{toplevel_methods/use_colours.rb → colour/colour.rb} +4 -125
  16. data/lib/colours/commandline/README.md +2 -1
  17. data/lib/colours/commandline/commandline.rb +177 -34
  18. data/lib/colours/constants/constants.rb +752 -6
  19. data/lib/colours/e/README.md +6 -6
  20. data/lib/colours/eparse/eparse.rb +2 -1
  21. data/lib/colours/essentials/README.md +5 -0
  22. data/lib/colours/{basic_colours/basic_colours.rb → essentials/essentials.rb} +87 -85
  23. data/lib/colours/html_colours/README.md +2 -1
  24. data/lib/colours/html_colours/hash_html_colours.rb +168 -0
  25. data/lib/colours/html_colours/html_colours.rb +226 -244
  26. data/lib/colours/html_colours/push_the_html_colours_methods_onto_the_toplevel_namespace.rb +30 -0
  27. data/lib/colours/html_colours/random_html_colour.rb +67 -0
  28. data/lib/colours/{requires/require_the_basic_colours.rb → html_colours.rb} +4 -2
  29. data/lib/colours/map_symbol_to_corresponding_colour/map_symbol_to_corresponding_colour.rb +12 -10
  30. data/lib/colours/module_256_colours/module_256_colours.rb +465 -0
  31. data/lib/colours/project/project.rb +3 -1
  32. data/lib/colours/rainbow_colours/check_for_trollop_being_available_or_exit.rb +4 -0
  33. data/lib/colours/rainbow_colours/constants.rb +3 -3
  34. data/lib/colours/rainbow_colours/do_parse_via_rainbow_colours.rb +9 -10
  35. data/lib/colours/rainbow_colours/print_rainbow_line.rb +4 -4
  36. data/lib/colours/rainbow_colours/println_ani.rb +7 -7
  37. data/lib/colours/rainbow_colours/println_plain.rb +2 -2
  38. data/lib/colours/rainbow_colours/rainbow.rb +31 -1
  39. data/lib/colours/rainbow_colours/report_errors.rb +7 -7
  40. data/lib/colours/rainbow_colours/returnln_plain.rb +3 -3
  41. data/lib/colours/replace_tokens_with_colour_code/replace_tokens_with_colour_code.rb +409 -0
  42. data/lib/colours/requires/require_autogenerated_colour_methods.rb +4 -1
  43. data/lib/colours/requires/{require_the_colour_table.rb → require_essentials.rb} +2 -2
  44. data/lib/colours/requires/require_save_file.rb +11 -0
  45. data/lib/colours/requires/require_the_256_colours_module.rb +1 -3
  46. data/lib/colours/requires/require_the_colour_methods.rb +1 -22
  47. data/lib/colours/requires/require_the_project.rb +31 -29
  48. data/lib/colours/requires/require_the_toplevel_methods.rb +2 -20
  49. data/lib/colours/rgb/rgb.rb +107 -89
  50. 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
  51. data/lib/colours/testing/testing.rb +1 -3
  52. data/lib/colours/toplevel_methods/e.rb +9 -13
  53. data/lib/colours/toplevel_methods/map_this_symbol_to_that_html_colour.rb +57 -0
  54. data/lib/colours/toplevel_methods/{revert.rb → rev.rb} +5 -48
  55. data/lib/colours/toplevel_methods/toplevel_methods.rb +1204 -0
  56. data/lib/colours/version/version.rb +2 -2
  57. data/lib/colours/yaml/256_colours.yml +776 -257
  58. data/lib/colours/yaml/html_colours.yml +1 -1
  59. data/lib/colours/yaml/prefer_this_colour_schemata.yml +1 -1
  60. data/lib/colours/yaml/use_these_values_for_the_colour_methods.yml +5 -1
  61. data/lib/colours.rb +1 -1
  62. data/test/testing_256_colours_support.rb +10 -1
  63. data/test/testing_replace_number_words_with_the_corresponding_html_colour.rb +15 -9
  64. data/test/testing_the_colour_methods_such_as_simp_sdir_sfile_swarn_sfancy_sargument_and_ssymlink.rb +53 -0
  65. metadata +30 -57
  66. data/doc/HOW_TO_PICK_YOUR_OWN_COLOURS.md +0 -28
  67. data/lib/colours/256_colours/support_for_256_colours.rb +0 -196
  68. data/lib/colours/autogenerated/support_for_256_colours.rb +0 -2235
  69. data/lib/colours/autogenerated/support_for_html_colours.rb +0 -1778
  70. data/lib/colours/autogenerated/toplevel_basic_colour_methods.rb +0 -7001
  71. data/lib/colours/basic_colours/README.md +0 -4
  72. data/lib/colours/colour_methods/README.md +0 -11
  73. data/lib/colours/colour_table/README.md +0 -2
  74. data/lib/colours/colour_table/colour_table.rb +0 -282
  75. data/lib/colours/commandline/menu.rb +0 -122
  76. data/lib/colours/constants/escape.rb +0 -22
  77. data/lib/colours/constants/file_constants.rb +0 -73
  78. data/lib/colours/constants/hash_ansi_colours.rb +0 -39
  79. data/lib/colours/constants/hash_simple_colours.rb +0 -148
  80. data/lib/colours/constants/misc.rb +0 -361
  81. data/lib/colours/constants/newline.rb +0 -14
  82. data/lib/colours/constants/registered_colour_methods.rb +0 -53
  83. data/lib/colours/html_colours/add_html_colours_onto_the_toplevel_namespace.rb +0 -22
  84. data/lib/colours/toplevel_methods/autogenerate.rb +0 -310
  85. data/lib/colours/toplevel_methods/bold.rb +0 -41
  86. data/lib/colours/toplevel_methods/bold_and_italic.rb +0 -38
  87. data/lib/colours/toplevel_methods/cat.rb +0 -39
  88. data/lib/colours/toplevel_methods/clear_screen.rb +0 -18
  89. data/lib/colours/toplevel_methods/cliner.rb +0 -17
  90. data/lib/colours/toplevel_methods/col.rb +0 -54
  91. data/lib/colours/toplevel_methods/esystem.rb +0 -19
  92. data/lib/colours/toplevel_methods/html_colour_to_hex_value.rb +0 -41
  93. data/lib/colours/toplevel_methods/html_colourize.rb +0 -69
  94. data/lib/colours/toplevel_methods/is_on_roebe.rb +0 -16
  95. data/lib/colours/toplevel_methods/italic.rb +0 -110
  96. data/lib/colours/toplevel_methods/make_colour.rb +0 -28
  97. data/lib/colours/toplevel_methods/methods_related_to_html_colours.rb +0 -336
  98. data/lib/colours/toplevel_methods/misc.rb +0 -226
  99. data/lib/colours/toplevel_methods/open_this_file.rb +0 -26
  100. data/lib/colours/toplevel_methods/prefer_this_colour_schemata.rb +0 -88
  101. data/lib/colours/toplevel_methods/random_value.rb +0 -37
  102. data/lib/colours/toplevel_methods/remove_escape_sequence.rb +0 -112
  103. data/lib/colours/toplevel_methods/set_last_colour_used.rb +0 -32
  104. data/lib/colours/toplevel_methods/shell_file_containing_the_html_colours.sh +0 -148
  105. data/lib/colours/toplevel_methods/show_basic_colour_palette.rb +0 -36
  106. data/lib/colours/toplevel_methods/underline.rb +0 -130
  107. data/test/testing_the_colour_methods.rb +0 -36
  108. /data/doc/{COLOUR_CODES_CHART.md → colour_codes_chart/colour_codes_chart.md} +0 -0
data/bin/colours CHANGED
@@ -2,6 +2,6 @@
2
2
  # Encoding: UTF-8
3
3
  # frozen_string_literal: true
4
4
  # =========================================================================== #
5
- require 'colours'
5
+ require 'colours/commandline/commandline.rb'
6
6
 
7
- Colours.menu(ARGV)
7
+ Colours::Commandline.new(ARGV)
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'colours/toplevel_methods/toplevel_methods.rb'
6
+
7
+ Colours.show_basic_colour_palette
data/colours.gemspec CHANGED
@@ -22,8 +22,7 @@ display text on the terminal with colours.
22
22
 
23
23
  For more information about this project, have a look at the online
24
24
  documentation for this gem at the link called "documentation", at
25
- the bottom right side of the colours
26
- gem homepage:
25
+ the bottom right side of the colours gem homepage:
27
26
 
28
27
  #{::Colours::URL_TO_THE_DOCUMENTATION}
29
28
 
data/doc/README.gen CHANGED
@@ -6,52 +6,69 @@ Making colours great again! \o/
6
6
 
7
7
  ## Goals, Scope and the History of the colours project
8
8
 
9
- The Colours project originated from a requirement to have to support **colours**
10
- on the commandline. Colours can be immensely helpful, so it makes sense
11
- to make use of them on the commandline. The modern www also makes use of
12
- colours - just look at any random webpage; you may find lots of
13
- different colours in use there.
14
-
15
- If you do happen to take a look on the projects offered on rubygems.org then
16
- you may be able to find **lots** of different colour-related projects, written
9
+ The Colours project originated from a distinct requirement to have to support
10
+ <b>colours</b> on the commandline, such as for commandline-oriented
11
+ scripts.
12
+
13
+ Colours can be immensely helpful for use in computer programs, so it appears
14
+ to be a logical conclusion to make use of them on the commandline as well.
15
+ The modern www also makes use of colours - just look at any random webpage;
16
+ you may find lots of different colours in use there, for various reasons
17
+ and purposes.
18
+
19
+ If you do happen to take a look on different projects offered on <b>rubygems.org</b>
20
+ then you may be able to find **lots** of different colour-related projects, written
17
21
  in ruby. The primary reason as to why I created a new colour-centric project
18
- was because I needed certain functionality that was not provided by any of
19
- the other projects; at the least not in a way as I thought it should be
20
- available (and used in downstream projects). For example, some terminals
21
- support **RGB values** and other terminals do not. I did not want to have
22
- to spend time thinking about this much at all, so I wanted to have a
23
- colours-related project that could abstract this away for me.
22
+ was because I needed certain functionality made available that was not provided by
23
+ any of the other projects; at the least not in a way as I thought it should be
24
+ available (and used in downstream projects).
24
25
 
25
- ![alt text][screenshot1]
26
- [screenshot1]: https://i.imgur.com/F6kac8W.png
26
+ For example, some terminals support **RGB values** and other terminals do not.
27
+ I did not want to have to spend time thinking about this much at all, so I wanted
28
+ to have a <b>colours-related project</b> that could abstract this away for me.
29
+ That way I can focus on other problems, and delegate the colour-specific issues
30
+ to this gem here.
27
31
 
28
- The **main goal** of the **colours project** is to collect colour-related
32
+ Let's next show how this may then look on the commandline:
33
+
34
+ <img src="https://i.imgur.com/F6kac8W.png" style="margin: 1em">
35
+
36
+ The <b>main goal</b> of the **colours project** is to collect colour-related
29
37
  code and make this code available to other projects, so that these projects
30
- can benefit from colour support.
38
+ can benefit from colour support via one project: the <b>colours gem</b>.
39
+
40
+ The primary goal herein lies on **commandline applications**, but there
41
+ are some <b>HTML components</b> as part of this project that could be used
42
+ as well, such as for when you wish to make use of **HTML colours** (slateblue,
43
+ royalblue, teal, tomato, steelblue and names such as these) in a webpage.
44
+
45
+ Elements such as:
31
46
 
32
- The primary goal herein is for **commandline applications**, but there
33
- are some HTML components as part of this project that could be used,
34
- such as for when you wish to make use of **HTML colours** (slateblue,
35
- royalblue, teal, tomato, steelblue and names such as these). The
36
- partial screenshot above indicates this, on a black **KDE konsole**
37
- background. (I tend to prefer dark backgrounds for my terminals.)
47
+ <span class="dodgerblue">This is in dodgerblue.</span>
38
48
 
39
- Note that many **terminals** support the **display of HTML colours**, via
49
+ The partial screenshot that was shown above indicates this situation, on a
50
+ black <b>KDE konsole</b> background. (I tend to prefer dark backgrounds
51
+ for my terminals.)
52
+
53
+ Note that many **terminals** support the <b>display of HTML colours</b>, via
40
54
  their **corresponding RGB values**. Since I wanted to use good terminals,
41
55
  such as the **KDE konsole**, the colours project also had to support
42
- these names (such as **slateblue** or **royalblue**) directly. This is
43
- why method calls such as **Colours.royalblue()** will also work - see
44
- for a later subsection how to customize (and control) this.
45
-
46
- The **Colours gem** has other, older projects, such as AnsiColours,
47
- ColourE, AliasE and several other smaller sub-projects that I have
48
- used over the years, integrated. It is thus a **bundled project**. This
49
- is specifically mentioned in the event that you may wish to look at
50
- the code, and wonder a little why it is structured the way it is.
56
+ these names directly, as method calls as well - names such as <b>slateblue</b>
57
+ or <b>royalblue</b>). This is the reason why method calls such as
58
+ <b>Colours.royalblue()</b> or <b>Colours.darkgreen</b> will also work - see
59
+ for a later subsection how to customize (and control) this behaviour.
60
+
61
+ Historically the **Colours gem** was inspired by other, older projects, such
62
+ as <b>AnsiColours</b>, ColourE, AliasE and several other smaller sub-projects
63
+ that I have used over the years. These projects were eventually integrated
64
+ into one namespace - <b>module Colours</b>. This gem is thus a <b>bundled
65
+ project</b>. This is specifically mentioned in the event that you may wish
66
+ to peek at the code, and wonder a little why it is structured the way it
67
+ is.
51
68
 
52
69
  ## Requiring the colours project
53
70
 
54
- To require the colours project, do:
71
+ To require the colours project, simply do:
55
72
 
56
73
  require 'colours'
57
74
 
@@ -62,13 +79,144 @@ You can also **autoinclude** this module into your project, at
62
79
 
63
80
  This will make the **Colours namespace** and the
64
81
  **Colours::HtmlColours namespace** available, via
65
- **include Colours** ultimately.
82
+ <b>include Colours</b> ultimately.
66
83
 
67
84
  If you need more control over the include-action then you should
68
85
  just use the first variant, require 'colours', and then do the
69
86
  include action specifically onto whatever class/module you need
70
87
  that functionality.
71
88
 
89
+ The project was partially rewritten in November 2023. If you
90
+ want to autoinclude the project still then I recommend you
91
+ use this:
92
+
93
+ require 'colours/html_colours'
94
+
95
+ After that methods such as <b>Colours.steelblue()</b> will
96
+ work.
97
+
98
+ ## ASCII Escape Characters
99
+
100
+ The code in the colours gem makes use of elements such as \033 or
101
+ \x1b. These are basically the same ASCII escape characters, as the
102
+ following table shows:
103
+
104
+ |-------------|------------|
105
+ | octal | \033 |
106
+ |-------------|------------|
107
+ | hexadecimal | \x1b |
108
+ |-------------|------------|
109
+ | Unicode | \u1b, \U1b |
110
+ |-------------|------------|
111
+ | literal | \e, \E |
112
+ |-------------|------------|
113
+
114
+ The last variant can often be found in <b>Bash scripts</b>.
115
+
116
+ The semicolon <b>;</b> serves as the delimiter if multiple instructions
117
+ are given.
118
+
119
+ The 8 actual colours defined by the ANSI standard are as follows:
120
+
121
+ 0 black
122
+ 1 red
123
+ 2 green
124
+ 3 yellow
125
+ 4 blue
126
+ 5 magenta
127
+ 6 cyan
128
+ 7 white
129
+
130
+ ## Linux terminals and colour support
131
+
132
+ The general syntax rules for colours is in the form of <b>fg_bg</b> values,
133
+ where a value of <b>38</b> stands for the foreground, and <b>48</b> stands
134
+ for the background.
135
+
136
+ For instance, the ANSI colour for red is 196 and the ANSI colour for
137
+ black is 0.
138
+
139
+ To use the colour red, you could issue this command in Bash:
140
+
141
+ printf "\e[38;5;196m Hello world in red\n"
142
+
143
+ To use the colour black as background, you could issue this command:
144
+
145
+ printf "\e[48;5;0m Hello world in black\n"
146
+
147
+ Do note that the same can be accomplished via RGB values rather than
148
+ ANSI color codes, as long as the terminal supports this (KDE Konsole
149
+ does).
150
+
151
+ Depending on whether you want to apply the colour to the foreground
152
+ or to the background, use an **fg_bg** value of <b>38</b> or <b>48</b>
153
+ (respectively).
154
+
155
+ Examples for this:
156
+
157
+ # printf "\e[<fg_bg>;2;<R>;<G>;<B>m" # General syntax example.
158
+ printf "\e[38;2;255;0;0m Foreground color: red\n"
159
+ printf "\e[48;2;0;0;0m Background color: black\n"
160
+ printf "\033[91m\033[107mThis is red text on a white background\033[0m" # As this example shows, \e is the same as \033.
161
+
162
+ This may be the better variant altogether, as it is quite easy to convert
163
+ into (and from) **RGB values**, but your mileage may vary.
164
+
165
+ Of course you can use this in plain ruby just as well - let's show this
166
+ via puts:
167
+
168
+ puts "\e[38;2;#{222};#{131};#{141}m Hello world!"
169
+ puts "\e[38;2;#{122};#{56};#{141}m Hello world!"
170
+ puts "\e[38;2;122;156;141m Hello world!"
171
+ puts "\x1b[3mHello world!\x1b[0m"
172
+ puts "\e[38;3mHello world!\x1b[0m"
173
+
174
+ In bash the ESC code can be either of the following:
175
+
176
+ \e
177
+ \033 (octal)
178
+ \x1B (hexadecimal)
179
+
180
+ The "\e[0m" sequence removes all attributes, including formatting and colors.
181
+ It may be useful to add it to the end of each colour text - and this is
182
+ what the **Colours** project is essentially doing.
183
+
184
+ To see which colours are supported/supportable, for each terminal,
185
+ have a look at the following **link**:
186
+
187
+ https://misc.flogisoft.com/bash/tip_colors_and_formatting#terminals_compatibility
188
+
189
+ To set both the foreground and background colours at once, you can use:
190
+
191
+ printf "\e[S;FG;BGm"
192
+ echo -e "\e[S;FG;BGm"
193
+
194
+ For example, bold white foreground on a red background:
195
+
196
+ printf "\e[1;97;41mHello world!"
197
+ printf "\e[1;97;41mHello world!\n"
198
+
199
+ Thus, if you would like to use red colour on black background,
200
+ you could do this:
201
+
202
+ printf '\e[38;5;196m;\e[48;5;0m Hello world!\n'
203
+
204
+ Specifically, the background colours are:
205
+
206
+ 40 black
207
+ 41 red
208
+ 42 green
209
+ 43 yellow
210
+ 44 blue
211
+ 45 magenta
212
+ 46 cyan
213
+ 47 white
214
+
215
+ The following command will use red background:
216
+
217
+ echo -e '\e[0;41m'
218
+ echo -e '\e[0;41m hello world\n\n ok\e[0;m'
219
+
72
220
  ## Introduction and Overview
73
221
 
74
222
  The toplevel module name is **Colours** and you can include
@@ -161,93 +309,17 @@ my opinion.
161
309
  In general, the html component can be used to convert the trivial
162
310
  <b>html colours</b> into <b>corresponding R,G,B values</b>.
163
311
 
164
- ## Linux terminals and colour support
165
-
166
- The general syntax rules for colours is in the form of **fg_bg** values,
167
- where a value of 38 stands for the foreground, and 48 stands for
168
- the background.
312
+ Note that in November 2023 I rewrote parts of the gem. This also
313
+ led to a re-evaluation of methods such as sdir() or sfancy().
169
314
 
170
- The ANSI colour for red is 196 and the ANSI colour for black is
171
- 0.
172
-
173
- To use the colour red, you could issue this command:
174
-
175
- printf "\e[38;5;196m Hello world in red\n"
176
-
177
- To use the colour black as background, you could issue this command:
178
-
179
- printf "\e[48;5;0m Hello world in black\n"
180
-
181
- Do note that the same can be accomplished via RGB values rather than
182
- ANSI color codes, as long as the terminal supports this (KDE Konsole
183
- does).
184
-
185
- Depending on whether you want to apply the color to the foreground or
186
- to the background, use an **fg_bg** value of 38 or 48 (respectively).
187
-
188
- Example:
189
-
190
- printf "\e[<fg_bg>;2;<R>;<G>;<B>m"
191
- printf "\e[38;2;255;0;0m Foreground color: red\n"
192
- printf "\e[48;2;0;0;0m Background color: black\n"
193
-
194
- This may be the better variant altogether, as it is quite easy to convert
195
- into (and from) **RGB values**, but your mileage may vary.
196
-
197
- Of course you can use this in plain ruby just as well - let's show this
198
- via puts:
199
-
200
- puts "\e[38;2;#{222};#{131};#{141}m Hello world!"
201
- puts "\e[38;2;#{122};#{56};#{141}m Hello world!"
202
- puts "\e[38;2;122;156;141m Hello world!"
203
- puts "\x1b[3mHello world!\x1b[0m"
204
- puts "\e[38;3mHello world!\x1b[0m"
205
-
206
- In bash the ESC code can be either of the following:
207
-
208
- \e
209
- \033 (octal)
210
- \x1B (hexadecimal)
211
-
212
- The "\e[0m" sequence removes all attributes, including formatting and colors.
213
- It may be useful to add it to the end of each colour text - and this is
214
- what the **Colours** project is essentially doing.
215
-
216
- To see which colours are supported/supportable, for each terminal,
217
- have a look at the following **link**:
218
-
219
- https://misc.flogisoft.com/bash/tip_colors_and_formatting#terminals_compatibility
220
-
221
- To set both the foreground and background colours at once, you can use:
222
-
223
- printf "\e[S;FG;BGm"
224
- echo -e "\e[S;FG;BGm"
225
-
226
- For example, bold white foreground on a red background:
227
-
228
- printf "\e[1;97;41mHello world!"
229
- printf "\e[1;97;41mHello world!\n"
230
-
231
- Thus, if you would like to use red colour on black background,
232
- you could do this:
233
-
234
- printf '\e[38;5;196m;\e[48;5;0m Hello world!\n'
235
-
236
- Specifically, the background colours are:
237
-
238
- 40 black
239
- 41 red
240
- 42 green
241
- 43 yellow
242
- 44 blue
243
- 45 magenta
244
- 46 cyan
245
- 47 white
246
-
247
- The following command will use red background:
248
-
249
- echo -e '\e[0;41m'
250
- echo -e '\e[0;41m hello world\n\n ok\e[0;m'
315
+ I use sfile(), sdir() and sfancy() a lot. I also use simp(),
316
+ as abbreviation for simportant(), sometimes. However had, other
317
+ methods, such as ssymlink(), I rarely use; and I never used
318
+ sarguments(), yet the project still carried code that supported
319
+ such a use case. During the partial rewrite in November 2023
320
+ I decided to deprecate and remove sarguments() aka Colours.sarguments().
321
+ I also deprecated snormal(), aka Colours.snormal(), as I also have
322
+ not ever used that method actually.
251
323
 
252
324
  ## Obtain all available HTML colours
253
325
 
@@ -347,45 +419,6 @@ Use code similar to the following variant for this:
347
419
  class Foobar < Colours::Base # Or whatever the name of your class is
348
420
  end
349
421
 
350
- ## KDE Konsole support
351
-
352
- The **Colours gem** used to have a submodule called **Konsole**,
353
- in particular the <b>KDE Konsole</b>. In May 2019 this submodule
354
- was removed; the functionality is now available in the form of
355
- an autogenerated .rb file instead.
356
-
357
- You can **use RGB colours** in the KDE konsole (but also in
358
- other terminal-types such as vte-based ones, like
359
- **mate-terminal**).
360
-
361
- For an example, have a look at the file **bin/colours**
362
- that is distributed with this gem here (the colours gem). That file
363
- will output all the HTML colour variants (via their RGB values).
364
- Best shown on a black background in your terminal.
365
-
366
- To **view all RGB colours** based on their HTML names, such
367
- as <b>palegreen</b> or <b>slateblue</b>, do this:
368
-
369
- colours
370
-
371
- Also note that since as of **May 2018**, you can invoke the
372
- HTML colours on the Konsole namespace directly, including
373
- text-output, via code like this:
374
-
375
- Colours.edarkgreen 'yo there'
376
- Colours.eslateblue 'yo there'
377
- Colours.eroyalblue 'yo there'
378
- Colours.edarkgreen 'Hello world!'
379
-
380
- The leading 'e' of these methods stands for "echo", aka
381
- puts-related output. In other words, to print the text
382
- that comes afterwards.
383
-
384
- To print something in bold, you can use **Colours.bold()**
385
- like in this way:
386
-
387
- Colours.bold
388
-
389
422
  ## Showing the colour palette on the commandline
390
423
 
391
424
  You can show the "classical" ASCII colours on the commandline by
@@ -601,11 +634,11 @@ then you can require the module, and include it into your class.
601
634
 
602
635
  Example for this:
603
636
 
604
- require 'new_colours/autogenerated/support_for_256_colours.rb'
637
+ require 'colours/autogenerated/support_for_256_colours.rb'
605
638
 
606
639
  class Foobar
607
640
 
608
- include NewColours::SupportFor256Colours
641
+ include Colours::SupportFor256Colours
609
642
 
610
643
  def initialize
611
644
  puts darkturquoise('HELLO ')+
@@ -1033,28 +1066,28 @@ Here is example code that shows this functionality:
1033
1066
 
1034
1067
  ## Colours.new
1035
1068
 
1036
- Since as of November 2022 <b>Colours.new</b> can be used to
1037
- build up a String that should be colourized.
1069
+ Since as of <b>November 2022</b>, <b>Colours.new</b> can be used
1070
+ to build up a String that should be colourized.
1038
1071
 
1039
1072
  This will internally delegate towards:
1040
1073
 
1041
1074
  ::Colours::Colours.new(i)
1042
1075
 
1043
- This may need some modifications in the future; the code is
1044
- also a bit confusing right now.
1076
+ This may need some modifications in the future; the code is also
1077
+ a bit confusing right now.
1045
1078
 
1046
1079
  ## Licence
1047
1080
 
1048
1081
  The colours project used to be under the **GPL-2.0 licence** (no later clause),
1049
- until **August 2019** (**26.08.2019**, in dd.mm.yyyy notation).
1082
+ until **August 2019** (**26.08.2019**, in <b>dd.mm.yyyy notation</b>).
1050
1083
 
1051
1084
  However had, I have changed my mind for various reasons (including the
1052
1085
  situation that different projects, with different licenses, may make
1053
1086
  use of the **colours gem**) and thus re-published the colours
1054
1087
  project under the less stringent **MIT licence**. Both licences, GPL and
1055
- MIT, are perfectly fine licences, but I feel that for the basic building
1056
- blocks, such as the colours gem, a less stringent licence makes a lot
1057
- more sense.
1088
+ MIT, are perfectly fine licences, but I feel that for the <b>basic building
1089
+ blocks</b>, such as the colours gem, a less stringent licence makes a
1090
+ lot more sense.
1058
1091
 
1059
1092
  See the file **LICENCE.md** for this licence, or just have look at
1060
1093
  the following URL here:
@@ -1081,12 +1114,14 @@ on something IF the no-warranty clause would not be mentioned).
1081
1114
  https://ss64.com/nt/syntax-ansi.html
1082
1115
 
1083
1116
  https://www.lihaoyi.com/post/BuildyourownCommandLinewithANSIescapecodes.html
1084
- ^^^ This one shows how to build a progress-indicator in python. The equivalent
1085
- ruby code is very similar.
1117
+
1118
+ ^^^ This webpage one shows how to build a progress-indicator in python. The
1119
+ equivalent ruby code is very similar.
1086
1120
 
1087
1121
  ## Commandline executables for individual colours
1088
1122
 
1089
- In March 2023 I decided to add files such as bin/orange.
1123
+ In <b>March 2023</b> I decided to add files such as
1124
+ <b>bin/orange</b>.
1090
1125
 
1091
1126
  The idea here is that you can chain this via a pipe, such as:
1092
1127
 
@@ -1097,9 +1132,90 @@ Or simply:
1097
1132
  orange Hello world!
1098
1133
  orange foobar.md # This variant should read the file, and read its content.
1099
1134
 
1100
- My idea is to add this for each HTML colour. However had, I am not yet
1101
- certain whether this should be done. So for now, I may add single
1102
- individual files. Perhaps in the future all HTML colours will have a
1103
- corresponding bin/ executable file.
1135
+ The idea here is to add this for each HTML colour. However had, I am not yet
1136
+ certain whether this should be done, as it would lead to many more files
1137
+ added to the colours gem. So for now, I may add single individual files
1138
+ but probably not all HTML colours, as executables. Perhaps in the future
1139
+ all HTML colours will have a corresponding bin/ executable file or I may
1140
+ add the option to autogenerate these files - we'll see.
1141
+
1142
+ ## KDE Konsole support
1143
+
1144
+ The **Colours gem** used to have a submodule called **Konsole**,
1145
+ in particular the <b>KDE Konsole</b>. In <b>May 2019</b> this submodule
1146
+ was removed; the functionality is now available in the form of
1147
+ an autogenerated .rb file instead.
1148
+
1149
+ You can **use RGB colours** in the KDE konsole (but also in
1150
+ other terminal-types such as vte-based ones, like
1151
+ <b>mate-terminal</b>). gnome-terminal also supports true
1152
+ 24 bit colours, which means that 16 millions colours are supported.
1153
+
1154
+ For an example, have a look at the file **bin/colours**
1155
+ that is distributed with this gem here (the colours gem). That file
1156
+ will output all the HTML colour variants (via their RGB values).
1157
+ Best shown on a black background in your terminal though.
1158
+
1159
+ To **view all RGB colours** based on their HTML names, such
1160
+ as <b>palegreen</b> or <b>slateblue</b>, do this:
1161
+
1162
+ colours
1163
+
1164
+ Also note that since as of **May 2018**, you can invoke the
1165
+ HTML colours on the Konsole namespace directly, including
1166
+ text-output, via <b>code like this</b>:
1167
+
1168
+ Colours.edarkgreen 'yo there'
1169
+ Colours.eslateblue 'yo there'
1170
+ Colours.eroyalblue 'yo there'
1171
+ Colours.edarkgreen 'Hello world!'
1172
+
1173
+ The leading 'e' of these methods stands for "echo", aka
1174
+ <b>puts-related output</b> (display onto the commandline).
1175
+ In other words, <b>to print the text that comes afterwards</b>.
1176
+
1177
+ To print something in bold, you can use **Colours.bold()**
1178
+ like in this way:
1179
+
1180
+ Colours.bold
1181
+
1182
+ How to use this in raw KDE konsole, if ruby is not available?
1183
+
1184
+ You need to make use of the corresponding R, G and B
1185
+ values.
1186
+
1187
+ Example for this:
1188
+
1189
+ printf "\e[38;2;100;200;200mTesting this output\e[0m\n"
1190
+
1191
+ ## class Colours::ReplaceTokensWithColourCode
1192
+
1193
+ class Colours::ReplaceTokensWithColourCode can be used to
1194
+ replace HTML-like tokens, such as <one>, in a given String.
1195
+
1196
+ The use case for this is to be able to easily colourize
1197
+ words on the commandline, as well as sentences, in different
1198
+ colours. The studium-gem makes use of this, for instance,
1199
+ where exam-questions are colourized based on the more important
1200
+ parts of the question at hand.
1201
+
1202
+ ## Colours::HtmlColoursMethods
1203
+
1204
+ class Colours::HtmlColoursMethods will hold code for making
1205
+ use of HTML-colours as method names, such as:
1206
+
1207
+ Colours.royalblue()
1208
+ Colours.royalblue('Hello World!')
1209
+
1210
+ To require this file do:
1211
+
1212
+ require 'colours/autogenerated/html_colours_methods.rb'
1213
+
1214
+ Note that depending on how you require the colours gem,
1215
+ this may also be automatically pulled in if you do:
1216
+
1217
+ include Colours
1218
+
1219
+ And then use methods such as Colours.sfancy().
1104
1220
 
1105
1221
  ADD_CONTACT_INFORMATION
@@ -0,0 +1,33 @@
1
+ This file describes how to pick your own colours - or how to use
2
+ the Colours gem in general.
3
+
4
+ The colours-centric Hash will contain entries such as the following:
5
+
6
+ sdir: :olivedrab
7
+
8
+ Now, what does this mean?
9
+
10
+ This is ultimately a hash entry, a key->value pair, with the key being
11
+ called :sdir (a Symbol), and the value being :olivedrab (also a
12
+ Symbol).
13
+
14
+ "sdir" in turn is an abbreviation for "string_dir", which is short for
15
+ "string_directory". This means a String that keeps the colour stored
16
+ for when we wish to colourize a directory, such as /tmp/. So, when
17
+ such a directory is shown, the HTML colour "olivedrab" will be used.
18
+
19
+ :olivedrab is thus a HTML colour (== "olivedrab"), which is a beige-green
20
+ variant.
21
+
22
+ What this thus does means, in english, is basically to "use the colour
23
+ olivedrab, in order to display all directories in a coloured fashion".
24
+
25
+ If you wish to use another colour, simply change the Symbol on the
26
+ right hand side, aka :olivedrab, to another name, such as :steelblue
27
+ or :orange. The names that should be chosen here are HTML Colour
28
+ names.
29
+
30
+ If you wish to get an overview over all available HTML colours, via
31
+ ruby, you can do this via the Colours namespace like this:
32
+
33
+ Colours.show_html_colours
@@ -2,9 +2,12 @@
2
2
  # Encoding: UTF-8
3
3
  # frozen_string_literal: true
4
4
  # =========================================================================== #
5
- # This file is deliberately not included by default.
5
+ # This file is deliberately not included by default. It simply aliases
6
+ # e onto puts.
6
7
  # =========================================================================== #
7
8
  # Usage example:
9
+ #
8
10
  # require 'colours/autoalias_e'
11
+ #
9
12
  # =========================================================================== #
10
13
  alias e puts