term-ansicolor 1.10.2 → 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/README.md +5 -3
- data/Rakefile +1 -1
- 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 +5 -5
- 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 +8 -8
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/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
@@ -21,7 +21,7 @@ GemHadar do
|
|
21
21
|
executables.merge Dir['bin/*'].map { |x| File.basename(x) }
|
22
22
|
|
23
23
|
dependency 'tins', '~>1.0'
|
24
|
-
dependency 'mize'
|
24
|
+
dependency 'mize', '~>0.5'
|
25
25
|
development_dependency 'simplecov'
|
26
26
|
development_dependency 'test-unit'
|
27
27
|
development_dependency 'utils'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.10.
|
1
|
+
1.10.4
|
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.4 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.4".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-15"
|
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]
|
@@ -23,10 +23,10 @@ Gem::Specification.new do |s|
|
|
23
23
|
|
24
24
|
s.specification_version = 4
|
25
25
|
|
26
|
-
s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.
|
26
|
+
s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.16.0".freeze])
|
27
27
|
s.add_development_dependency(%q<simplecov>.freeze, [">= 0".freeze])
|
28
28
|
s.add_development_dependency(%q<test-unit>.freeze, [">= 0".freeze])
|
29
29
|
s.add_development_dependency(%q<utils>.freeze, [">= 0".freeze])
|
30
30
|
s.add_runtime_dependency(%q<tins>.freeze, ["~> 1.0".freeze])
|
31
|
-
s.add_runtime_dependency(%q<mize>.freeze, ["
|
31
|
+
s.add_runtime_dependency(%q<mize>.freeze, ["~> 0.5".freeze])
|
32
32
|
end
|
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.4
|
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-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_hadar
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.16.0
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.16.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: simplecov
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,16 +84,16 @@ dependencies:
|
|
84
84
|
name: mize
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
89
|
+
version: '0.5'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
96
|
+
version: '0.5'
|
97
97
|
description: This library uses ANSI escape sequences to control the attributes of
|
98
98
|
terminal output
|
99
99
|
email: flori@ping.de
|