Top Level Namespace
Defined Under Namespace
Modules: BasicLogging
Classes: Body, Configuration, Headers, Newsgroups, OverrideDlg, PostProcessor, String
Constant Summary
collapse
- WRAP_LENGTH =
65
- PROGNAME =
/***************************************************************************
* 2023-2025, Michael Uplawski <michael.uplawski@uplawski.eu> *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the WTFPL 2.0 or later, see *
* http://www.wtfpl.net/about/ *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* *
***************************************************************************/
'flnews_post_proc'
- PROGVERSION =
"1.97"
- AUTHORS =
"Michael Uplawski"
- EMAIL =
"michael.uplawski@uplawski.eu"
- YEARS =
"2023 - 2026"
- SUMMARY =
"Custom headers are rfc2047 encoded, if need be"
- COLORS =
Functions to apply colors to terminal output. This is stolen from the Internet and I have lost track of my own additions and modifications.
{:default => 9, :black => 0, :red => 1, :green => 2, :yellow => 3, :blue => 4, :purple => 5, :cyan => 6, :white => 7 }
- BG =
4
- FG =
3
- REGULAR =
0
- BOLD =
1
- UNDERLINE =
4
- BLINK =
5
- SWAP =
7
- NEUTRAL =
0
- STYLES =
{:regular => REGULAR, :bold => BOLD, :underline => UNDERLINE, :blink => BLINK, :swap => SWAP, :neutral => NEUTRAL}
Instance Method Summary
collapse
-
#background_RGB(text, r, g, b) ⇒ Object
-
#black(text) ⇒ Object
-
#black_on_white(text) ⇒ Object
-
#blue(text) ⇒ Object
-
#bold(text) ⇒ Object
-
#brown(text) ⇒ Object
-
#colored_output(output_text, fg_color = :default, bg_color = :default, style = :regular, mode = :neutral) ⇒ Object
a function which allows to manipulate every known aspect of the ansi-output.
-
#colorize(text, color_code) ⇒ Object
Colorizes the given text.
-
#colorize_RGB(text, r, g, b) ⇒ Object
-
#crimson(text) ⇒ Object
-
#cyan(text) ⇒ Object
-
#green(text) ⇒ Object
-
#lightgreen(text) ⇒ Object
-
#lightred(text) ⇒ Object
-
#orange(text) ⇒ Object
RGB TODO: Fallbacks from the 256 color palette.
-
#pink(text) ⇒ Object
-
#purple(text) ⇒ Object
-
#red(text) ⇒ Object
-
#style(text, style_code) ⇒ Object
duplicate code without much intelligence.
-
#underline(text) ⇒ Object
-
#white(text) ⇒ Object
-
#white_on_black(text) ⇒ Object
-
#yellow(text) ⇒ Object
Instance Method Details
#background_RGB(text, r, g, b) ⇒ Object
56
57
58
59
|
# File 'lib/color_output.rb', line 56
def background_RGB(text, r, g, b)
code = "%s;%s;%s" %[r, g, b]
"\033[48;2;#{code}m#{text}\033[0m"
end
|
#black(text) ⇒ Object
77
|
# File 'lib/color_output.rb', line 77
def black(text); colorize(text, "\033[30m"); end
|
#black_on_white(text) ⇒ Object
96
|
# File 'lib/color_output.rb', line 96
def black_on_white(text); colorize(colorize(text, "\033[30m"), "\033[47m");end
|
#blue(text) ⇒ Object
83
|
# File 'lib/color_output.rb', line 83
def blue(text); colorize(text, "\033[34m"); end
|
#bold(text) ⇒ Object
100
|
# File 'lib/color_output.rb', line 100
def bold(text); style(text, "\033[01m");end
|
#brown(text) ⇒ Object
92
|
# File 'lib/color_output.rb', line 92
def brown(text); colorize(text, "\033[38;2;153;76;0m"); end
|
#colored_output(output_text, fg_color = :default, bg_color = :default, style = :regular, mode = :neutral) ⇒ Object
a function which allows to manipulate every known aspect of the ansi-output.
67
68
69
70
71
72
73
74
|
# File 'lib/color_output.rb', line 67
def colored_output(output_text, fg_color = :default, bg_color = :default, style = :regular , mode = :neutral )
if $stdout.tty? && ENV['TERM'] != 'dumb'
"\033[%i;%i;%i%i;%i%im%s\033[0m" %[STYLES[mode.to_sym], STYLES[style.to_sym], FG, COLORS[fg_color.to_sym], BG, COLORS[bg_color.to_sym], output_text]
else
output_text
end
end
|
#colorize(text, color_code) ⇒ Object
Colorizes the given text. Color-code is either an escape-sequence or one of the symbols representing color-names in the COLORS hash.
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/color_output.rb', line 35
def colorize(text, color_code)
if $stdout.tty? && ENV['TERM'] != 'dumb'
if (COLORS.keys.include?(color_code) )
"\033[3#{COLORS[color_code]}m#{text}\033[0m"
else
"#{color_code}#{text}\033[0m"
end
else
text
end
end
|
#colorize_RGB(text, r, g, b) ⇒ Object
50
51
52
53
|
# File 'lib/color_output.rb', line 50
def colorize_RGB(text, r, g, b)
code = "%s;%s;%s" %[r, g, b]
"\033[38;2;#{code}m#{text}\033[0m"
end
|
#crimson(text) ⇒ Object
93
|
# File 'lib/color_output.rb', line 93
def crimson(text); colorize(text, "\033[38;2;220;20;60m"); end
|
#cyan(text) ⇒ Object
82
|
# File 'lib/color_output.rb', line 82
def cyan(text); colorize(text, "\033[36m"); end
|
#green(text) ⇒ Object
79
|
# File 'lib/color_output.rb', line 79
def green(text); colorize(text, "\033[32m"); end
|
#lightgreen(text) ⇒ Object
91
|
# File 'lib/color_output.rb', line 91
def lightgreen(text); colorize(text, "\033[38;2;100;255;100m"); end
|
#lightred(text) ⇒ Object
90
|
# File 'lib/color_output.rb', line 90
def lightred(text); colorize(text, "\033[38;2;255;100;100m"); end
|
#orange(text) ⇒ Object
RGB TODO: Fallbacks from the 256 color palette
88
|
# File 'lib/color_output.rb', line 88
def orange(text); colorize(text, "\033[38;2;255;165;0m"); end
|
#pink(text) ⇒ Object
89
|
# File 'lib/color_output.rb', line 89
def pink(text); colorize(text, "\033[38;2;255;0;165m"); end
|
#purple(text) ⇒ Object
81
|
# File 'lib/color_output.rb', line 81
def purple(text); colorize(text, "\033[35m"); end
|
#red(text) ⇒ Object
78
|
# File 'lib/color_output.rb', line 78
def red(text); colorize(text, "\033[31m"); end
|
#style(text, style_code) ⇒ Object
duplicate code without much intelligence
62
63
64
|
# File 'lib/color_output.rb', line 62
def style(text, style_code)
"#{style_code}#{text}\033[0m"
end
|
#underline(text) ⇒ Object
101
|
# File 'lib/color_output.rb', line 101
def underline(text); style(text, "\033[04m");end
|
#white(text) ⇒ Object
84
|
# File 'lib/color_output.rb', line 84
def white(text); colorize(text, "\033[37m"); end
|
#white_on_black(text) ⇒ Object
97
|
# File 'lib/color_output.rb', line 97
def white_on_black(text); colorize(colorize(text, "\033[37m"), "\033[40m");end
|
#yellow(text) ⇒ Object
80
|
# File 'lib/color_output.rb', line 80
def yellow(text); colorize(text, "\033[33m"); end
|