term-ansicolor 1.7.1 → 1.10.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.all_images.yml +27 -0
- data/.gitignore +1 -0
- data/.utilsrc +26 -0
- data/README.md +5 -3
- data/Rakefile +4 -4
- data/VERSION +1 -1
- data/bin/term_colortab +27 -1
- data/bin/term_display +5 -3
- data/bin/term_mandel +30 -24
- data/bin/term_snow +13 -13
- data/examples/example.rb +31 -1
- data/lib/term/ansicolor/attribute/color256.rb +38 -36
- data/lib/term/ansicolor/attribute/color8.rb +16 -16
- data/lib/term/ansicolor/attribute/intense_color8.rb +32 -34
- data/lib/term/ansicolor/attribute/text.rb +18 -15
- data/lib/term/ansicolor/attribute/underline.rb +34 -0
- data/lib/term/ansicolor/attribute.rb +86 -45
- data/lib/term/ansicolor/hsl_triple.rb +2 -2
- data/lib/term/ansicolor/hyperlink.rb +34 -0
- data/lib/term/ansicolor/ppm_reader.rb +9 -4
- data/lib/term/ansicolor/rgb_triple.rb +1 -3
- data/lib/term/ansicolor/version.rb +1 -1
- data/lib/term/ansicolor.rb +46 -42
- data/term-ansicolor.gemspec +16 -29
- data/tests/ansicolor_test.rb +69 -2
- data/tests/attribute_test.rb +45 -6
- data/tests/hsl_triple_test.rb +2 -2
- data/tests/hyperlink_test.rb +58 -0
- data/tests/ppm_reader_test.rb +8 -0
- data/tests/rgb_triple_test.rb +1 -1
- metadata +50 -15
- data/.travis.yml +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d75f19d115fdee4233a120ece01a38b75c7f0cff14243e477def07b314f55b42
|
4
|
+
data.tar.gz: 9a3c5f4ac0abbd01a552ce2e5358bd1d3b2825c392495c941209e71cdbfb8e07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '015294663f0738e6cbeed73b3aa34d7ff6a19a9bc13be6ab683a750956cc854dae0d7630e606ff298252142f35f10b3a4cd02592761d72403bfd2d3de845be82'
|
7
|
+
data.tar.gz: 18741931918cf7c07192263ea683c69c7b6074d44572267e0d01d84d27a0f00ea66a0ae2d95ed2b96eee0e176bdf5f791f92d5aefb78a806ede47f2cc2a3b0ae
|
data/.all_images.yml
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
dockerfile: |-
|
2
|
+
RUN apk add --no-cache build-base git bash
|
3
|
+
RUN bash <<NUR
|
4
|
+
if [[ "$(ruby -e 'print RUBY_VERSION')" > '3' ]]
|
5
|
+
then
|
6
|
+
gem update --system
|
7
|
+
gem install gem_hadar bundler
|
8
|
+
else
|
9
|
+
gem install gem_hadar
|
10
|
+
gem install bundler -v 2.4.22
|
11
|
+
fi
|
12
|
+
NUR
|
13
|
+
|
14
|
+
script: &script |-
|
15
|
+
echo -e "\e[1m"
|
16
|
+
ruby -v
|
17
|
+
echo -e "\e[0m"
|
18
|
+
bundle
|
19
|
+
rake test
|
20
|
+
|
21
|
+
images:
|
22
|
+
ruby:3.3-alpine: *script
|
23
|
+
ruby:3.2-alpine: *script
|
24
|
+
ruby:3.1-alpine: *script
|
25
|
+
ruby:3.0-alpine: *script
|
26
|
+
ruby:2.7-alpine: *script
|
27
|
+
ruby:2.6-alpine: *script
|
data/.gitignore
CHANGED
data/.utilsrc
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# vim: set ft=ruby:
|
2
|
+
|
3
|
+
search do
|
4
|
+
prune_dirs /\A(\.svn|\.git|CVS|tmp|tags|coverage|pkg)\z/
|
5
|
+
skip_files /(\A\.|\.sw[pon]\z|\.(log|fnm|jpg|jpeg|png|pdf|svg)\z|tags|~\z)/i
|
6
|
+
end
|
7
|
+
|
8
|
+
discover do
|
9
|
+
prune_dirs /\A(\.svn|\.git|CVS|tmp|tags|coverage|pkg)\z/
|
10
|
+
skip_files /(\A\.|\.sw[pon]\z|\.log\z|~\z)/
|
11
|
+
binary false
|
12
|
+
end
|
13
|
+
|
14
|
+
strip_spaces do
|
15
|
+
prune_dirs /\A(\..*|CVS|pkg)\z/
|
16
|
+
skip_files /(\A\.|\.sw[pon]\z|\.log\z|~\z)/
|
17
|
+
end
|
18
|
+
|
19
|
+
probe do
|
20
|
+
test_framework :"test-unit"
|
21
|
+
end
|
22
|
+
|
23
|
+
ssh_tunnel do
|
24
|
+
terminal_multiplexer :tmux
|
25
|
+
end
|
26
|
+
|
data/README.md
CHANGED
@@ -22,13 +22,15 @@ The homepage of this library is located at
|
|
22
22
|
|
23
23
|
The following executables are provided with Term::ANSIColor:
|
24
24
|
|
25
|
-
* `
|
26
|
-
* `
|
27
|
-
* `colortab`: Displays a table of the 256 terminal colors with their indices and
|
25
|
+
* `term_cdiff`: colors a diff patch
|
26
|
+
* `term_colortab`: Displays a table of the 256 terminal colors with their indices and
|
28
27
|
nearest html equivalents.
|
29
28
|
* `term_display`: displays a ppm3 or ppm6 image file in the terminal. If the netpbm
|
30
29
|
programs are installed it can handle a lot of other image file formats.
|
30
|
+
* `term_decolor`: decolors any text file that was colored with ANSI escape sequences
|
31
31
|
* `term_mandel`: displays the mandelbrot set in the terminal
|
32
|
+
* `term_snow`: displays falling snow in the terminal using ANSI movement
|
33
|
+
sequences.
|
32
34
|
|
33
35
|
Additionally the file examples/example.rb in the source/gem-distribution shows
|
34
36
|
how this library can be used.
|
data/Rakefile
CHANGED
@@ -8,21 +8,21 @@ GemHadar do
|
|
8
8
|
path_module 'Term::ANSIColor'
|
9
9
|
author 'Florian Frank'
|
10
10
|
email 'flori@ping.de'
|
11
|
-
homepage "
|
11
|
+
homepage "https://github.com/flori/#{name}"
|
12
12
|
summary 'Ruby library that colors strings using ANSI escape sequences'
|
13
13
|
description 'This library uses ANSI escape sequences to control the attributes of terminal output'
|
14
14
|
licenses << 'Apache-2.0'
|
15
15
|
|
16
16
|
test_dir 'tests'
|
17
17
|
ignore '.*.sw[pon]', 'pkg', 'Gemfile.lock', '.rvmrc', 'coverage',
|
18
|
-
'tags', '.bundle', '.byebug_history'
|
18
|
+
'tags', '.bundle', '.byebug_history', 'errors.lst'
|
19
19
|
|
20
20
|
readme 'README.md'
|
21
21
|
executables.merge Dir['bin/*'].map { |x| File.basename(x) }
|
22
22
|
|
23
23
|
dependency 'tins', '~>1.0'
|
24
|
+
dependency 'mize', '~>0.5'
|
24
25
|
development_dependency 'simplecov'
|
25
26
|
development_dependency 'test-unit'
|
26
|
-
|
27
|
-
required_ruby_version '>= 2.0'
|
27
|
+
development_dependency 'utils'
|
28
28
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.10.4
|
data/bin/term_colortab
CHANGED
@@ -15,6 +15,32 @@ def print_color(c)
|
|
15
15
|
print ("%3u #{color.rgb.html} " % c).on_color(color.name).color(text.name)
|
16
16
|
end
|
17
17
|
|
18
|
+
if Term::ANSIColor.true_coloring = ENV['COLORTERM'] =~ /\A(truecolor|24bit)\z/
|
19
|
+
|
20
|
+
puts "True colors".bold, ""
|
21
|
+
step = 36
|
22
|
+
(0..255).step(step) do |g|
|
23
|
+
(0..255).step(step) do |r|
|
24
|
+
(0..255).step(step) do |b|
|
25
|
+
print Term::ANSIColor.on_color(Term::ANSIColor::RGBTriple.new(r, g, b)) { ' ' }
|
26
|
+
end
|
27
|
+
print ' '
|
28
|
+
end
|
29
|
+
puts
|
30
|
+
end
|
31
|
+
|
32
|
+
puts
|
33
|
+
(0..255).step(4) do |g|
|
34
|
+
print Term::ANSIColor.on_color(Term::ANSIColor::RGBTriple.new(g, g, g)) { ' ' }
|
35
|
+
end
|
36
|
+
puts
|
37
|
+
puts
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
Term::ANSIColor.true_coloring = false
|
42
|
+
|
43
|
+
puts "256 colors".bold, ""
|
18
44
|
for c in 0..3
|
19
45
|
print_color c
|
20
46
|
end
|
@@ -40,10 +66,10 @@ for c in 16..231
|
|
40
66
|
(c - 16) % 36 == 0 and puts
|
41
67
|
print_color c
|
42
68
|
end
|
69
|
+
puts
|
43
70
|
|
44
71
|
for c in 232..255
|
45
72
|
(c - 16) % 6 == 0 and puts
|
46
|
-
(c - 16) % 12 == 0 and puts
|
47
73
|
print_color c
|
48
74
|
end
|
49
75
|
puts
|
data/bin/term_display
CHANGED
@@ -65,13 +65,14 @@ Options are
|
|
65
65
|
-a ASPECT x:y aspect, defaults to 2.2
|
66
66
|
-C COLS number of columns for rendering with aspect, defaults to max
|
67
67
|
-R ROWS number of rows for rendering with aspect, defaults to max - 1
|
68
|
+
-t use true colors
|
68
69
|
-h this help
|
69
70
|
|
70
71
|
EOT
|
71
72
|
exit rc
|
72
73
|
end
|
73
74
|
|
74
|
-
opts = go 'hm:g:s:a:C:R:'
|
75
|
+
opts = go 'hm:g:s:a:C:R:t'
|
75
76
|
opts['h'] and usage
|
76
77
|
filename = ARGV.shift or usage 1
|
77
78
|
metric = Term::ANSIColor::RGBColorMetrics.metric(opts['m'] || 'CIELab')
|
@@ -84,8 +85,9 @@ opts['R'] ||= [ Tins::Terminal.rows - 1, 0 ].max
|
|
84
85
|
file = provide_ppm_file(filename, opts)
|
85
86
|
ppm = Term::ANSIColor::PPMReader.new(
|
86
87
|
file,
|
87
|
-
:metric
|
88
|
-
:gray
|
88
|
+
metric: metric,
|
89
|
+
gray: gray,
|
90
|
+
true_coloring: opts[?t]
|
89
91
|
)
|
90
92
|
|
91
93
|
puts ppm
|
data/bin/term_mandel
CHANGED
@@ -1,35 +1,32 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'term/ansicolor'
|
4
|
+
include Term::ANSIColor
|
4
5
|
require 'tins/xt'
|
5
|
-
require "complex"
|
6
6
|
include Tins::GO
|
7
|
+
require "complex"
|
7
8
|
|
8
|
-
|
9
|
+
$width, $height = Tins::Terminal.cols, Tins::Terminal.lines
|
10
|
+
$height *= 2
|
9
11
|
|
10
12
|
def color_random
|
11
13
|
(1..3).map { rand(255) }
|
12
14
|
end
|
13
15
|
|
14
16
|
def draw_set(rx, ry)
|
15
|
-
sx = (rx.end - rx.begin).abs /
|
16
|
-
sy = (ry.end - ry.begin).abs /
|
17
|
-
|
18
|
-
|
19
|
-
color =
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
ac::Attribute[ color_random ].gradient_to(ac::Attribute[ color_random ], :steps => 16) +
|
24
|
-
ac::Attribute[ color_random ].gradient_to(ac::Attribute[ color_random ], :steps => 16) +
|
25
|
-
ac::Attribute[ color_random ].gradient_to(ac::Attribute[ color_random ], :steps => 16) +
|
26
|
-
ac::Attribute[ color_random ].gradient_to(ac::Attribute[ color_random ], :steps => 16) +
|
27
|
-
ac::Attribute[ color_random ].gradient_to(ac::Attribute['#000'], :steps => 16)
|
17
|
+
sx = (rx.end - rx.begin).abs / $width
|
18
|
+
sy = (ry.end - ry.begin).abs / $height
|
19
|
+
|
20
|
+
steps = 16
|
21
|
+
color = (5.times.map { color_random } + [ 0, 0, 0 ]).map { Attribute[_1] }
|
22
|
+
color = color[1..-1].inject(color[0,1]) { |c, x|
|
23
|
+
c + c.last.gradient_to(x, steps:)
|
24
|
+
}
|
28
25
|
iters = color.size - 2
|
29
26
|
|
30
|
-
|
31
|
-
for j in 0
|
32
|
-
for i in 0
|
27
|
+
data = [ [] ]
|
28
|
+
for j in 0...$height
|
29
|
+
for i in 0...$width
|
33
30
|
n, z_n = 0, Complex(0, 0)
|
34
31
|
c = Complex(sx * i + rx.begin, sy * j + ry.begin)
|
35
32
|
while n <= iters
|
@@ -37,16 +34,25 @@ def draw_set(rx, ry)
|
|
37
34
|
z_n = z_n ** 2 + c
|
38
35
|
n += 1
|
39
36
|
end
|
40
|
-
|
37
|
+
data.last << n
|
41
38
|
end
|
42
|
-
|
39
|
+
data << []
|
43
40
|
end
|
44
|
-
|
41
|
+
screen = ''
|
42
|
+
(0...$height).step(2) do |j|
|
43
|
+
(0...$width).each do |i|
|
44
|
+
screen << color(color[data[j][i]]) <<
|
45
|
+
on_color(color[data[j + 1][i]]) << ?▀
|
46
|
+
end
|
47
|
+
end
|
48
|
+
print move_home, screen, reset
|
45
49
|
end
|
46
50
|
|
47
|
-
opts = go 'x:y
|
51
|
+
opts = go 'x:y'
|
52
|
+
|
53
|
+
Term::ANSIColor.true_coloring = ENV['COLORTERM'] =~ /\A(truecolor|24bit)\z/
|
48
54
|
|
49
|
-
rx = opts[
|
50
|
-
ry = opts[
|
55
|
+
rx = opts[?x].full? { |r| Range.new(*(r.split('..', 2).map(&:to_f))) } || (-2.0..1.0)
|
56
|
+
ry = opts[?y].full? { |r| Range.new(*(r.split('..', 2).map(&:to_f))) } || (-1.0..1.0)
|
51
57
|
|
52
58
|
draw_set rx, ry
|
data/bin/term_snow
CHANGED
@@ -9,23 +9,23 @@ class SnowFlake
|
|
9
9
|
extend Term::ANSIColor
|
10
10
|
|
11
11
|
def initialize(x, y, shape: %w[ ❄ ❅ ❆ • • · · . . ])
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
@x, @y, @shape = x, y, Array(shape).sample
|
13
|
+
@shape.size != 1 and raise ArgumentError, "#@shape needs to be a character"
|
14
|
+
end
|
15
15
|
|
16
|
-
|
16
|
+
attr_accessor :x
|
17
17
|
|
18
|
-
|
18
|
+
attr_accessor :y
|
19
19
|
|
20
|
-
|
20
|
+
attr_accessor :shape
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
def to_s
|
23
|
+
move_to(y, x) { white on_black @shape }
|
24
|
+
end
|
25
25
|
end
|
26
26
|
|
27
|
-
opts
|
28
|
-
new_snowflakes
|
27
|
+
opts = go 'n:s:'
|
28
|
+
new_snowflakes = (opts[?n] || 3).to_i
|
29
29
|
sleep_duration = (opts[?s] || 0.2).to_f
|
30
30
|
|
31
31
|
flakes = []
|
@@ -51,7 +51,7 @@ loop do
|
|
51
51
|
sf.x = SnowFlake.terminal_columns
|
52
52
|
end
|
53
53
|
else
|
54
|
-
sf.x
|
54
|
+
sf.x += 1
|
55
55
|
if sf.x > SnowFlake.terminal_columns
|
56
56
|
sf.x = 1
|
57
57
|
end
|
@@ -64,7 +64,7 @@ loop do
|
|
64
64
|
flakes << SnowFlake.new(rand(1..SnowFlake.terminal_columns), 1)
|
65
65
|
end
|
66
66
|
|
67
|
-
print
|
67
|
+
print(*flakes)
|
68
68
|
|
69
69
|
sleep sleep_duration
|
70
70
|
rescue Interrupt
|
data/examples/example.rb
CHANGED
@@ -76,11 +76,39 @@ print "clear".clear, "reset".reset, "bold".bold, "dark".dark,
|
|
76
76
|
|
77
77
|
symbols = Term::ANSIColor::attributes
|
78
78
|
print red { bold { "All supported attributes = " } },
|
79
|
-
symbols.map { |s| __send__(s, s.inspect) } *
|
79
|
+
symbols.map { |s| __send__(s, s.inspect) } * ",\n", "\n\n"
|
80
80
|
|
81
81
|
print "Send symbols to strings:".send(:red).send(:bold), "\n"
|
82
82
|
print symbols[12, 8].map { |c| c.to_s.send(c) } * '', "\n\n"
|
83
83
|
|
84
|
+
print red { bold { "Use true colors if supported" } }, "\n"
|
85
|
+
|
86
|
+
colors = Term::ANSIColor::Attribute['#ff0000'].gradient_to(
|
87
|
+
Term::ANSIColor::Attribute['#ffff00'],
|
88
|
+
true_coloring: true,
|
89
|
+
step: 16
|
90
|
+
)
|
91
|
+
colors += Term::ANSIColor::Attribute[colors.last].gradient_to(
|
92
|
+
Term::ANSIColor::Attribute['#00ff00'],
|
93
|
+
true_coloring: true,
|
94
|
+
step: 16
|
95
|
+
)
|
96
|
+
colors += Term::ANSIColor::Attribute[colors.last].gradient_to(
|
97
|
+
Term::ANSIColor::Attribute['#00ffff'],
|
98
|
+
true_coloring: true,
|
99
|
+
step: 16
|
100
|
+
)
|
101
|
+
colors += Term::ANSIColor::Attribute[colors.last].gradient_to(
|
102
|
+
Term::ANSIColor::Attribute['#0000ff'],
|
103
|
+
true_coloring: true,
|
104
|
+
step: 16
|
105
|
+
)
|
106
|
+
|
107
|
+
chars = %w[ ⣾ ⣽ ⣻ ⢿ ⡿ ⣟ ⣯ ⣷ ]
|
108
|
+
colors.each_with_index { |c, i| print c.apply { chars[i % chars.size] } }
|
109
|
+
puts
|
110
|
+
puts
|
111
|
+
|
84
112
|
print red { bold { "Make strings monochromatic again:" } }, "\n"
|
85
113
|
print [
|
86
114
|
"red".red,
|
@@ -88,3 +116,5 @@ print [
|
|
88
116
|
uncolored { "not red anymore".red },
|
89
117
|
uncolored("not red anymore".red)
|
90
118
|
].map { |x| x + "\n" } * ''
|
119
|
+
|
120
|
+
puts "Use the " + "Source".hyperlink("https://github.com/flori/term-ansicolor") + ", Luke!"
|
@@ -2,65 +2,67 @@ module Term
|
|
2
2
|
module ANSIColor
|
3
3
|
class Attribute
|
4
4
|
class Color256
|
5
|
-
Attribute.set :color0, 0, :
|
6
|
-
Attribute.set :color1, 1, :
|
7
|
-
Attribute.set :color2, 2, :
|
8
|
-
Attribute.set :color3, 3, :
|
9
|
-
Attribute.set :color4, 4, :
|
10
|
-
Attribute.set :color5, 5, :
|
11
|
-
Attribute.set :color6, 6, :
|
12
|
-
Attribute.set :color7, 7, :
|
5
|
+
Attribute.set :color0, 0, html: '#000000'
|
6
|
+
Attribute.set :color1, 1, html: '#800000'
|
7
|
+
Attribute.set :color2, 2, html: '#008000'
|
8
|
+
Attribute.set :color3, 3, html: '#808000'
|
9
|
+
Attribute.set :color4, 4, html: '#000080'
|
10
|
+
Attribute.set :color5, 5, html: '#800080'
|
11
|
+
Attribute.set :color6, 6, html: '#008080'
|
12
|
+
Attribute.set :color7, 7, html: '#c0c0c0'
|
13
13
|
|
14
|
-
Attribute.set :color8, 8, :
|
15
|
-
Attribute.set :color9, 9, :
|
16
|
-
Attribute.set :color10, 10, :
|
17
|
-
Attribute.set :color11, 11, :
|
18
|
-
Attribute.set :color12, 12, :
|
19
|
-
Attribute.set :color13, 13, :
|
20
|
-
Attribute.set :color14, 14, :
|
21
|
-
Attribute.set :color15, 15, :
|
14
|
+
Attribute.set :color8, 8, html: '#808080'
|
15
|
+
Attribute.set :color9, 9, html: '#ff0000'
|
16
|
+
Attribute.set :color10, 10, html: '#00ff00'
|
17
|
+
Attribute.set :color11, 11, html: '#ffff00'
|
18
|
+
Attribute.set :color12, 12, html: '#0000ff'
|
19
|
+
Attribute.set :color13, 13, html: '#ff00ff'
|
20
|
+
Attribute.set :color14, 14, html: '#00ffff'
|
21
|
+
Attribute.set :color15, 15, html: '#ffffff'
|
22
22
|
|
23
23
|
steps = [ 0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff ]
|
24
24
|
|
25
25
|
for i in 16..231
|
26
26
|
red, green, blue = (i - 16).to_s(6).rjust(3, '0').each_char.map { |c| steps[c.to_i] }
|
27
|
-
Attribute.set "color#{i}", i, :
|
27
|
+
Attribute.set "color#{i}", i, red: red, green: green, blue: blue
|
28
28
|
end
|
29
29
|
|
30
30
|
grey = 8
|
31
31
|
for i in 232..255
|
32
|
-
Attribute.set "color#{i}", i, :
|
32
|
+
Attribute.set "color#{i}", i, red: grey, green: grey, blue: grey
|
33
33
|
grey += 10
|
34
34
|
end
|
35
35
|
|
36
|
-
Attribute.set :on_color0, 0, :
|
37
|
-
Attribute.set :on_color1, 1, :
|
38
|
-
Attribute.set :on_color2, 2, :
|
39
|
-
Attribute.set :on_color3, 3, :
|
40
|
-
Attribute.set :on_color4, 4, :
|
41
|
-
Attribute.set :on_color5, 5, :
|
42
|
-
Attribute.set :on_color6, 6, :
|
43
|
-
Attribute.set :on_color7, 7, :
|
36
|
+
Attribute.set :on_color0, 0, html: '#000000', background: true
|
37
|
+
Attribute.set :on_color1, 1, html: '#800000', background: true
|
38
|
+
Attribute.set :on_color2, 2, html: '#808000', background: true
|
39
|
+
Attribute.set :on_color3, 3, html: '#808000', background: true
|
40
|
+
Attribute.set :on_color4, 4, html: '#000080', background: true
|
41
|
+
Attribute.set :on_color5, 5, html: '#800080', background: true
|
42
|
+
Attribute.set :on_color6, 6, html: '#008080', background: true
|
43
|
+
Attribute.set :on_color7, 7, html: '#c0c0c0'
|
44
44
|
|
45
|
-
Attribute.set :on_color8, 8, :
|
46
|
-
Attribute.set :on_color9, 9, :
|
47
|
-
Attribute.set :on_color10, 10, :
|
48
|
-
Attribute.set :on_color11, 11, :
|
49
|
-
Attribute.set :on_color12, 12, :
|
50
|
-
Attribute.set :on_color13, 13, :
|
51
|
-
Attribute.set :on_color14, 14, :
|
52
|
-
Attribute.set :on_color15, 15, :
|
45
|
+
Attribute.set :on_color8, 8, html: '#808080', background: true
|
46
|
+
Attribute.set :on_color9, 9, html: '#ff0000', background: true
|
47
|
+
Attribute.set :on_color10, 10, html: '#00ff00', background: true
|
48
|
+
Attribute.set :on_color11, 11, html: '#ffff00', background: true
|
49
|
+
Attribute.set :on_color12, 12, html: '#0000ff', background: true
|
50
|
+
Attribute.set :on_color13, 13, html: '#ff00ff', background: true
|
51
|
+
Attribute.set :on_color14, 14, html: '#00ffff', background: true
|
52
|
+
Attribute.set :on_color15, 15, html: '#ffffff', background: true
|
53
53
|
|
54
54
|
steps = [ 0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff ]
|
55
55
|
|
56
56
|
for i in 16..231
|
57
57
|
red, green, blue = (i - 16).to_s(6).rjust(3, '0').each_char.map { |c| steps[c.to_i] }
|
58
|
-
Attribute.set "on_color#{i}", i,
|
58
|
+
Attribute.set "on_color#{i}", i,
|
59
|
+
red: red, green: green, blue: blue, background: true
|
59
60
|
end
|
60
61
|
|
61
62
|
grey = 8
|
62
63
|
for i in 232..255
|
63
|
-
Attribute.set "on_color#{i}", i,
|
64
|
+
Attribute.set "on_color#{i}", i,
|
65
|
+
red: grey, green: grey, blue: grey, background: true
|
64
66
|
grey += 10
|
65
67
|
end
|
66
68
|
end
|
@@ -2,23 +2,23 @@ module Term
|
|
2
2
|
module ANSIColor
|
3
3
|
class Attribute
|
4
4
|
class Color8
|
5
|
-
Attribute.set :black, 30
|
6
|
-
Attribute.set :red, 31
|
7
|
-
Attribute.set :green, 32
|
8
|
-
Attribute.set :yellow, 33
|
9
|
-
Attribute.set :blue, 34
|
10
|
-
Attribute.set :magenta, 35
|
11
|
-
Attribute.set :cyan, 36
|
12
|
-
Attribute.set :white, 37
|
5
|
+
Attribute.set :black, 30, direct: '#000000'
|
6
|
+
Attribute.set :red, 31, direct: '#800000'
|
7
|
+
Attribute.set :green, 32, direct: '#008000'
|
8
|
+
Attribute.set :yellow, 33, direct: '#808000'
|
9
|
+
Attribute.set :blue, 34, direct: '#000080'
|
10
|
+
Attribute.set :magenta, 35, direct: '#800080'
|
11
|
+
Attribute.set :cyan, 36, direct: '#008080'
|
12
|
+
Attribute.set :white, 37, direct: '#c0c0c0'
|
13
13
|
|
14
|
-
Attribute.set :on_black, 40
|
15
|
-
Attribute.set :on_red, 41
|
16
|
-
Attribute.set :on_green, 42
|
17
|
-
Attribute.set :on_yellow, 43
|
18
|
-
Attribute.set :on_blue, 44
|
19
|
-
Attribute.set :on_magenta, 45
|
20
|
-
Attribute.set :on_cyan, 46
|
21
|
-
Attribute.set :on_white, 47
|
14
|
+
Attribute.set :on_black, 40, direct: '#000000'
|
15
|
+
Attribute.set :on_red, 41, direct: '#800000'
|
16
|
+
Attribute.set :on_green, 42, direct: '#008000'
|
17
|
+
Attribute.set :on_yellow, 43, direct: '#808000'
|
18
|
+
Attribute.set :on_blue, 44, direct: '#000080'
|
19
|
+
Attribute.set :on_magenta, 45, direct: '#800080'
|
20
|
+
Attribute.set :on_cyan, 46, direct: '#008080'
|
21
|
+
Attribute.set :on_white, 47, direct: '#808080'
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -2,41 +2,39 @@ module Term
|
|
2
2
|
module ANSIColor
|
3
3
|
class Attribute
|
4
4
|
class IntenseColor8
|
5
|
-
|
6
|
-
Attribute.set :
|
7
|
-
Attribute.set :
|
8
|
-
Attribute.set :
|
9
|
-
Attribute.set :
|
10
|
-
Attribute.set :
|
11
|
-
Attribute.set :
|
12
|
-
Attribute.set :
|
13
|
-
Attribute.set :
|
14
|
-
Attribute.set :
|
15
|
-
Attribute.set :
|
16
|
-
Attribute.set :
|
17
|
-
Attribute.set :
|
18
|
-
Attribute.set :
|
19
|
-
Attribute.set :
|
20
|
-
Attribute.set :
|
21
|
-
Attribute.set :bright_white, 97
|
5
|
+
Attribute.set :intense_black, 90, direct: '#808080'
|
6
|
+
Attribute.set :bright_black, 90, direct: '#808080'
|
7
|
+
Attribute.set :intense_red, 91, direct: '#ff0000'
|
8
|
+
Attribute.set :bright_red, 91, direct: '#ff0000'
|
9
|
+
Attribute.set :intense_green, 92, direct: '#00ff00'
|
10
|
+
Attribute.set :bright_green, 92, direct: '#00ff00'
|
11
|
+
Attribute.set :intense_yellow, 93, direct: '#ffff00'
|
12
|
+
Attribute.set :bright_yellow, 93, direct: '#ffff00'
|
13
|
+
Attribute.set :intense_blue, 94, direct: '#0000ff'
|
14
|
+
Attribute.set :bright_blue, 94, direct: '#0000ff'
|
15
|
+
Attribute.set :intense_magenta, 95, direct: '#ff00ff'
|
16
|
+
Attribute.set :bright_magenta, 95, direct: '#ff00ff'
|
17
|
+
Attribute.set :intense_cyan, 96, direct: '#00ffff'
|
18
|
+
Attribute.set :bright_cyan, 96, direct: '#00ffff'
|
19
|
+
Attribute.set :intense_white, 97, direct: '#ffffff'
|
20
|
+
Attribute.set :bright_white, 97, direct: '#ffffff'
|
22
21
|
|
23
|
-
|
24
|
-
Attribute.set :
|
25
|
-
Attribute.set :
|
26
|
-
Attribute.set :
|
27
|
-
Attribute.set :
|
28
|
-
Attribute.set :
|
29
|
-
Attribute.set :
|
30
|
-
Attribute.set :
|
31
|
-
Attribute.set :
|
32
|
-
Attribute.set :
|
33
|
-
Attribute.set :
|
34
|
-
Attribute.set :
|
35
|
-
Attribute.set :
|
36
|
-
Attribute.set :
|
37
|
-
Attribute.set :
|
38
|
-
Attribute.set :
|
39
|
-
Attribute.set :on_bright_white, 107
|
22
|
+
Attribute.set :on_intense_black, 100, direct: '#808080'
|
23
|
+
Attribute.set :on_bright_black, 100, direct: '#808080'
|
24
|
+
Attribute.set :on_intense_red, 101, direct: '#ff0000'
|
25
|
+
Attribute.set :on_bright_red, 101, direct: '#ff0000'
|
26
|
+
Attribute.set :on_intense_green, 102, direct: '#00ff00'
|
27
|
+
Attribute.set :on_bright_green, 102, direct: '#00ff00'
|
28
|
+
Attribute.set :on_intense_yellow, 103, direct: '#ffff00'
|
29
|
+
Attribute.set :on_bright_yellow, 103, direct: '#ffff00'
|
30
|
+
Attribute.set :on_intense_blue, 104, direct: '#0000ff'
|
31
|
+
Attribute.set :on_bright_blue, 104, direct: '#0000ff'
|
32
|
+
Attribute.set :on_intense_magenta, 105, direct: '#ff00ff'
|
33
|
+
Attribute.set :on_bright_magenta, 105, direct: '#ff00ff'
|
34
|
+
Attribute.set :on_intense_cyan, 106, direct: '#00ffff'
|
35
|
+
Attribute.set :on_bright_cyan, 106, direct: '#00ffff'
|
36
|
+
Attribute.set :on_intense_white, 107, direct: '#ffffff'
|
37
|
+
Attribute.set :on_bright_white, 107, direct: '#ffffff'
|
40
38
|
end
|
41
39
|
end
|
42
40
|
end
|
@@ -1,22 +1,25 @@
|
|
1
|
+
require 'term/ansicolor/attribute/underline'
|
2
|
+
|
1
3
|
module Term
|
2
4
|
module ANSIColor
|
3
5
|
class Attribute
|
4
6
|
class Text
|
5
|
-
Attribute.set :clear,
|
6
|
-
Attribute.set :reset,
|
7
|
-
Attribute.set :bold,
|
8
|
-
Attribute.set :dark,
|
9
|
-
Attribute.set :faint,
|
10
|
-
Attribute.set :italic,
|
11
|
-
Attribute.set :
|
12
|
-
Attribute.set :
|
13
|
-
Attribute.set :
|
14
|
-
Attribute.set :
|
15
|
-
Attribute.set :
|
16
|
-
Attribute.set :
|
17
|
-
Attribute.set :
|
18
|
-
Attribute.set :
|
19
|
-
|
7
|
+
Attribute.set :clear, 0 # String#clear already used in String
|
8
|
+
Attribute.set :reset, 0 # synonym for :clear
|
9
|
+
Attribute.set :bold, 1
|
10
|
+
Attribute.set :dark, 2
|
11
|
+
Attribute.set :faint, 2
|
12
|
+
Attribute.set :italic, 3 # not widely implemented
|
13
|
+
Attribute.set :blink, 5
|
14
|
+
Attribute.set :rapid_blink, 6 # not widely implemented
|
15
|
+
Attribute.set :reverse, 7 # String#reverse already used in String
|
16
|
+
Attribute.set :negative, 7 # synonym for :reverse
|
17
|
+
Attribute.set :concealed, 8
|
18
|
+
Attribute.set :conceal, 8 # synonym for :concealed
|
19
|
+
Attribute.set :strikethrough, 9 # not widely implemented
|
20
|
+
Attribute.set :overline, 53
|
21
|
+
|
22
|
+
include Term::ANSIColor::Attribute::Underline
|
20
23
|
end
|
21
24
|
end
|
22
25
|
end
|