term-ansicolor 1.10.2 → 1.10.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -3
- data/VERSION +1 -1
- data/bin/term_mandel +20 -12
- data/lib/term/ansicolor/attribute/underline.rb +4 -4
- data/lib/term/ansicolor/hsl_triple.rb +2 -2
- data/lib/term/ansicolor/rgb_triple.rb +1 -3
- data/lib/term/ansicolor/version.rb +1 -1
- data/lib/term/ansicolor.rb +1 -0
- data/term-ansicolor.gemspec +3 -3
- data/tests/ansicolor_test.rb +8 -0
- data/tests/hsl_triple_test.rb +1 -1
- data/tests/hyperlink_test.rb +1 -1
- data/tests/rgb_triple_test.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ec4bd5406d6a919febb9444a996f99a153a18562d1728bc94483b2a1ac32f8a
|
4
|
+
data.tar.gz: 48e114e79275436a11dc3db76a2308a0ad804125195196ff24ace6cbe4e2354d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9013380ea29dd3b95d46d878c033a7f1e0d686b9f37d117dd2794fea5262122074685bf064bec5277116089f8b6b747e2e12a8daf33045ef0a501a3cd16c59f8
|
7
|
+
data.tar.gz: fd371c1dc99443dd49c30406930a2f1c687d6584f364b01505192746d851dacae619502c00ce90731812b148eab22de4f245e1256a2fc5dd7eb3980b520c3190
|
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/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.10.
|
1
|
+
1.10.3
|
data/bin/term_mandel
CHANGED
@@ -1,31 +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
|
+
sx = (rx.end - rx.begin).abs / $width
|
18
|
+
sy = (ry.end - ry.begin).abs / $height
|
17
19
|
|
18
|
-
ac = Term::ANSIColor
|
19
20
|
steps = 16
|
20
|
-
color = (5.times.map { color_random } + [ 0, 0, 0 ]).map {
|
21
|
+
color = (5.times.map { color_random } + [ 0, 0, 0 ]).map { Attribute[_1] }
|
21
22
|
color = color[1..-1].inject(color[0,1]) { |c, x|
|
22
23
|
c + c.last.gradient_to(x, steps:)
|
23
24
|
}
|
24
25
|
iters = color.size - 2
|
25
26
|
|
26
|
-
|
27
|
-
for j in 0
|
28
|
-
for i in 0
|
27
|
+
data = [ [] ]
|
28
|
+
for j in 0...$height
|
29
|
+
for i in 0...$width
|
29
30
|
n, z_n = 0, Complex(0, 0)
|
30
31
|
c = Complex(sx * i + rx.begin, sy * j + ry.begin)
|
31
32
|
while n <= iters
|
@@ -33,11 +34,18 @@ def draw_set(rx, ry)
|
|
33
34
|
z_n = z_n ** 2 + c
|
34
35
|
n += 1
|
35
36
|
end
|
36
|
-
|
37
|
+
data.last << n
|
38
|
+
end
|
39
|
+
data << []
|
40
|
+
end
|
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]]) << ?▀
|
37
46
|
end
|
38
|
-
text << ac.reset << "\n"
|
39
47
|
end
|
40
|
-
|
48
|
+
print move_home, screen, reset
|
41
49
|
end
|
42
50
|
|
43
51
|
opts = go 'x:y'
|
@@ -15,12 +15,12 @@ module Term
|
|
15
15
|
dashed: '4:5',
|
16
16
|
}.fetch(type) { raise ArgumentError, "invalid line type" }
|
17
17
|
if color
|
18
|
-
a
|
18
|
+
a = Term::ANSIColor::Attribute[color]
|
19
19
|
color_code =
|
20
|
-
if
|
21
|
-
|
20
|
+
if rgb = a.ask_and_send(:to_rgb_triple).full?(:to_a)
|
21
|
+
"\e[58;2;#{rgb * ?;}"
|
22
22
|
else
|
23
|
-
raise ArgumentError, "invalid color #{a
|
23
|
+
raise ArgumentError, "invalid color #{a&.name.inspect}"
|
24
24
|
end
|
25
25
|
code = "#{code}m#{color_code}"
|
26
26
|
end
|
@@ -72,8 +72,8 @@ module Term
|
|
72
72
|
|
73
73
|
def initialize(hue, saturation, lightness)
|
74
74
|
@hue = Float(hue) % 360
|
75
|
-
@saturation =
|
76
|
-
@lightness =
|
75
|
+
@saturation = Float(saturation).clamp(0, 100)
|
76
|
+
@lightness = Float(lightness).clamp(0, 100)
|
77
77
|
end
|
78
78
|
|
79
79
|
attr_reader :hue
|
data/lib/term/ansicolor.rb
CHANGED
data/term-ansicolor.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: term-ansicolor 1.10.
|
2
|
+
# stub: term-ansicolor 1.10.3 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "term-ansicolor".freeze
|
6
|
-
s.version = "1.10.
|
6
|
+
s.version = "1.10.3".freeze
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
10
10
|
s.authors = ["Florian Frank".freeze]
|
11
|
-
s.date = "2024-
|
11
|
+
s.date = "2024-07-14"
|
12
12
|
s.description = "This library uses ANSI escape sequences to control the attributes of terminal output".freeze
|
13
13
|
s.email = "flori@ping.de".freeze
|
14
14
|
s.executables = ["term_cdiff".freeze, "term_colortab".freeze, "term_decolor".freeze, "term_display".freeze, "term_mandel".freeze, "term_snow".freeze]
|
data/tests/ansicolor_test.rb
CHANGED
@@ -134,6 +134,14 @@ class ANSIColorTest < Test::Unit::TestCase
|
|
134
134
|
assert_equal Term::ANSIColor.attributes, 'foo'.attributes
|
135
135
|
end
|
136
136
|
|
137
|
+
def test_underline_invalid_type
|
138
|
+
assert_raises(ArgumentError) { Term::ANSIColor.underline(type: :nix) { 'foo' } }
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_underline_invalid_color
|
142
|
+
assert_raises(ArgumentError) { Term::ANSIColor.underline(color: :nix) { 'foo' } }
|
143
|
+
end
|
144
|
+
|
137
145
|
def test_underline
|
138
146
|
foo = 'foo'
|
139
147
|
assert_equal "\e[4mfoo\e[0m", Term::ANSIColor.underline { foo }
|
data/tests/hsl_triple_test.rb
CHANGED
data/tests/hyperlink_test.rb
CHANGED
@@ -43,7 +43,7 @@ class HyperlinkTest < Test::Unit::TestCase
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def test_hyperlink_block_arg
|
46
|
-
|
46
|
+
assert_raises(ArgumentError) { hyperlink(@link, 'bar') { 'baz' } }
|
47
47
|
assert_equal(
|
48
48
|
"\e]8;;#@link\e\\foo\e]8;;\e\\",
|
49
49
|
hyperlink(@link) { 'foo' }
|
data/tests/rgb_triple_test.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: term-ansicolor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.10.
|
4
|
+
version: 1.10.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_hadar
|