ansi 1.4.3 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/{HISTORY.rdoc → HISTORY.md} +52 -15
- data/LICENSE.txt +23 -0
- data/NOTICE.md +170 -0
- data/{README.rdoc → README.md} +34 -34
- data/demo/01_ansicode.md +65 -0
- data/demo/{02_core.rdoc → 02_core.md} +4 -4
- data/demo/03_logger.md +30 -0
- data/demo/04_progressbar.md +62 -0
- data/demo/{05_mixin.rdoc → 05_mixin.md} +11 -11
- data/demo/{06_string.rdoc → 06_string.md} +18 -18
- data/demo/07_columns.md +89 -0
- data/demo/08_table.md +28 -0
- data/demo/09_diff.md +47 -0
- data/demo/10_bbcode.md +24 -0
- data/demo/11_terminal.md +8 -0
- data/lib/ansi/chart.rb +12 -10
- data/lib/ansi/code.rb +78 -82
- data/lib/ansi/columns.rb +0 -1
- data/lib/ansi/terminal/curses.rb +1 -2
- data/lib/ansi/terminal/stty.rb +2 -2
- data/lib/ansi/terminal.rb +1 -1
- data/lib/ansi/version.rb +1 -13
- metadata +48 -77
- data/.ruby +0 -63
- data/.yardopts +0 -8
- data/COPYING.rdoc +0 -612
- data/Config.rb +0 -13
- data/DEMO.rdoc +0 -455
- data/demo/01_ansicode.rdoc +0 -49
- data/demo/03_logger.rdoc +0 -31
- data/demo/04_progressbar.rdoc +0 -63
- data/demo/07_columns.rdoc +0 -90
- data/demo/08_table.rdoc +0 -28
- data/demo/09_diff.rdoc +0 -47
- data/demo/10_bbcode.rdoc +0 -24
- data/demo/11_terminal.rdoc +0 -8
- data/lib/ansi.yml +0 -63
- data/test/case_ansicode.rb +0 -31
- data/test/case_bbcode.rb +0 -35
- data/test/case_mixin.rb +0 -29
- data/test/case_progressbar.rb +0 -19
- data/test/test_helper.rb +0 -3
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: f64bee2019769713b2ac4762b94be9f6c2346eb4ae4baa0b0645e7a2f2371286
|
|
4
|
+
data.tar.gz: 8fdba321ec78907d1109046af0656ee9c3a0c2342f5aaff7c3611ba3ea4d2976
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: cb67809ddcbb4ddc3e527081a4c65ab4445c116d7eb17c0da6a31837d4cfc943c123724dd63e18ecf7812a43f5bfae6292899da2b8b2a1a6f77c70e1d336d0f8
|
|
7
|
+
data.tar.gz: da85dad4be00c385f5c019b61ea1ae358ef0208bb5c7c9d17713e64e710f72098fe7798b1e04e76c9e2030c440a7558202510a382ec3aa72a2d9f4c9d9911cb5
|
data/{HISTORY.rdoc → HISTORY.md}
RENAMED
|
@@ -1,6 +1,42 @@
|
|
|
1
|
-
|
|
1
|
+
# RELEASE HISTORY
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## 1.6.0 | 2026-03-30
|
|
4
|
+
|
|
5
|
+
Maintenance release. Modernized project tooling and cleaned up documentation.
|
|
6
|
+
|
|
7
|
+
Changes:
|
|
8
|
+
|
|
9
|
+
* Replace custom Indexer system with standard gemspec.
|
|
10
|
+
* Replace Travis CI with GitHub Actions.
|
|
11
|
+
* Replace Assembly/detroit/ergo with Rakefile.
|
|
12
|
+
* Simplify version.rb to use a plain constant.
|
|
13
|
+
* Fix Fixnum reference for Ruby 3+ compatibility.
|
|
14
|
+
* Fix typos and update URLs to HTTPS.
|
|
15
|
+
* Move site from gh-pages to docs/.
|
|
16
|
+
* Remove obsolete files.
|
|
17
|
+
* Clean up .gitignore.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## 1.5.0 | 2015-01-16
|
|
21
|
+
|
|
22
|
+
ANSI 1.5 introduces one change that is not backward compatiable. The
|
|
23
|
+
`:clear_line` code no longer clears to the end of the line. Instead it
|
|
24
|
+
clears the entire line. If you have used this in the past you
|
|
25
|
+
will need to update your code to use `:clear_eol` or `:clear_right`
|
|
26
|
+
instead. In addition this release finally fixes some long time issues
|
|
27
|
+
with Windows compatability, and a few other bugs. Yeah!
|
|
28
|
+
|
|
29
|
+
Changes:
|
|
30
|
+
|
|
31
|
+
* Alias `:right` and `:left` as `:forward` and `:back` respectively.
|
|
32
|
+
* Change `:clear_line` to clear whole line, not just to the end of line.
|
|
33
|
+
* Add `:cursor_hide` and `:cursor_show` codes.
|
|
34
|
+
* Fix and adjust #rgb method to work as one would expect.
|
|
35
|
+
* Fix Windows compatability (old code was alwasy using stty).
|
|
36
|
+
* Fix duplicated hash key in chart.rb.
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## 1.4.3 | 2012-06-26
|
|
4
40
|
|
|
5
41
|
This release bring two small changes. The first improves support
|
|
6
42
|
for Windows by only rescuing LoadError when 'win32console' fails
|
|
@@ -13,7 +49,7 @@ Changes:
|
|
|
13
49
|
* Improvements for getting proper screen width.
|
|
14
50
|
|
|
15
51
|
|
|
16
|
-
|
|
52
|
+
## 1.4.2 | 2012-01-29
|
|
17
53
|
|
|
18
54
|
ANSI chains are a new feature inspired by Kazuyoshi Tlacaelel's Isna project.
|
|
19
55
|
It is a fluid notation for the String#ansi method, e.g. `"foo".red.on_white`.
|
|
@@ -34,7 +70,7 @@ Changes:
|
|
|
34
70
|
* Support custom padding for Columns.
|
|
35
71
|
|
|
36
72
|
|
|
37
|
-
|
|
73
|
+
## 1.4.1 | 2011-11-09
|
|
38
74
|
|
|
39
75
|
This release simply fixes a documentation issue, to make sure
|
|
40
76
|
QED.rdoc appears in the YARD docs. And a shout-out to Chad Perrin
|
|
@@ -47,7 +83,7 @@ Changes:
|
|
|
47
83
|
* Documentation fixes.
|
|
48
84
|
|
|
49
85
|
|
|
50
|
-
|
|
86
|
+
## 1.4.0 | 2011-11-05
|
|
51
87
|
|
|
52
88
|
New release adds a HexDump class for colorized byte string dumps
|
|
53
89
|
and fixes some minor cell size issues with the Table class.
|
|
@@ -63,7 +99,7 @@ Changes:
|
|
|
63
99
|
* Switch to BSD-2-Clause license.
|
|
64
100
|
|
|
65
101
|
|
|
66
|
-
|
|
102
|
+
## 1.3.0 | 2011-06-30
|
|
67
103
|
|
|
68
104
|
This release cleans up the Code module. It adds support for x-term
|
|
69
105
|
256 color codes. Also, the Diff class is now awesome, making use of
|
|
@@ -81,7 +117,7 @@ Changes:
|
|
|
81
117
|
* Improved Diff class with LCS algorithm.
|
|
82
118
|
|
|
83
119
|
|
|
84
|
-
|
|
120
|
+
## 1.2.5 | 2011-05-03
|
|
85
121
|
|
|
86
122
|
This release introduces a preliminary rendition of a Diff class
|
|
87
123
|
for getting colorized comparisons of strings and other objects.
|
|
@@ -93,7 +129,7 @@ Changes:
|
|
|
93
129
|
* Fixed minor issue with Columns format block; col comes before row.
|
|
94
130
|
|
|
95
131
|
|
|
96
|
-
|
|
132
|
+
## 1.2.4 | 2011-04-29
|
|
97
133
|
|
|
98
134
|
This release improves to the ANSI::Columns class. In particular the
|
|
99
135
|
layout is more consistent with intended functionality.
|
|
@@ -105,7 +141,7 @@ Changes:
|
|
|
105
141
|
* ANSI::Columns can take a String or Array list.
|
|
106
142
|
|
|
107
143
|
|
|
108
|
-
|
|
144
|
+
## 1.2.3 | 2011-04-08
|
|
109
145
|
|
|
110
146
|
Minor release to add #clear method to ProgressBar and provide bug
|
|
111
147
|
fix to BBCode.ansi_to_bbcode. Big thanks goes to Junegunn Choi
|
|
@@ -117,7 +153,7 @@ Changes:
|
|
|
117
153
|
* Fixed ANSI::BBCode.ansi_to_bbcode and ansi_to_html from omitting lines
|
|
118
154
|
without any ansi code (Junegunn Choi).
|
|
119
155
|
|
|
120
|
-
|
|
156
|
+
## 1.2.2 | 2010-06-12
|
|
121
157
|
|
|
122
158
|
This release removes warnings about string arguments for certain
|
|
123
159
|
ANSI::Code methods. While the string form is considered deprecated,
|
|
@@ -133,13 +169,13 @@ Changes:
|
|
|
133
169
|
* Add ANSI::Mixin#display.
|
|
134
170
|
|
|
135
171
|
|
|
136
|
-
|
|
172
|
+
## 1.2.1 | 2010-05-10
|
|
137
173
|
|
|
138
174
|
This release was simply a quick fix to remove the incorrect embedded
|
|
139
175
|
version number, until it gets fixed.
|
|
140
176
|
|
|
141
177
|
|
|
142
|
-
|
|
178
|
+
## 1.2.0 | 2010-05-10
|
|
143
179
|
|
|
144
180
|
This release entails numerous improvements. First and foremost
|
|
145
181
|
the Code module is transitioning to a block interface only
|
|
@@ -165,7 +201,7 @@ Changes:
|
|
|
165
201
|
* Many new tests and QED documents.
|
|
166
202
|
|
|
167
203
|
|
|
168
|
-
|
|
204
|
+
## 1.1.0 | 2009-10-04
|
|
169
205
|
|
|
170
206
|
This release is the first toward making the ANSI library
|
|
171
207
|
more widely usable.
|
|
@@ -177,7 +213,7 @@ Changes:
|
|
|
177
213
|
* Other minor underthehood improvements.
|
|
178
214
|
|
|
179
215
|
|
|
180
|
-
|
|
216
|
+
## 1.0.1 | 2009-08-15
|
|
181
217
|
|
|
182
218
|
The release fixes a single bug that should allow Ruby 1.9
|
|
183
219
|
to use the ANSI library.
|
|
@@ -187,7 +223,7 @@ Changes:
|
|
|
187
223
|
* Renamed PLATFORM to RUBY_PLATFORM
|
|
188
224
|
|
|
189
225
|
|
|
190
|
-
|
|
226
|
+
## 1.0.0 | 2009-08-15
|
|
191
227
|
|
|
192
228
|
This is the initial stand-alone release of ANSI, a collection
|
|
193
229
|
of ANSI based classes spun-off from Ruby Facets.
|
|
@@ -195,3 +231,4 @@ of ANSI based classes spun-off from Ruby Facets.
|
|
|
195
231
|
Changes:
|
|
196
232
|
|
|
197
233
|
* Happy Birthday!
|
|
234
|
+
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
BSD-2-Clause License (http://spdx.org/licenses/BSD-2-Clause)
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without modification, are
|
|
4
|
+
permitted provided that the following conditions are met:
|
|
5
|
+
|
|
6
|
+
1. Redistributions of source code must retain the above copyright notice, this list of
|
|
7
|
+
conditions and the following disclaimer.
|
|
8
|
+
|
|
9
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
10
|
+
of conditions and the following disclaimer in the documentation and/or other materials
|
|
11
|
+
provided with the distribution.
|
|
12
|
+
|
|
13
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
14
|
+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
|
|
16
|
+
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
17
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
18
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
19
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
20
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
21
|
+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
22
|
+
|
|
23
|
+
|
data/NOTICE.md
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# COPYRIGHT NOTICES
|
|
2
|
+
|
|
3
|
+
## ANSI
|
|
4
|
+
|
|
5
|
+
Copyright © 2009 [Rubyworks](http://rubyworks.github.com) ·
|
|
6
|
+
License [BSD-2-Clause](http://spdx.org/licenses/BSD-2-Clause) ·
|
|
7
|
+
Website http://rubyworks.github.com/ansi
|
|
8
|
+
|
|
9
|
+
Copyright 2009 Rubyworks.
|
|
10
|
+
|
|
11
|
+
All rights reserved.
|
|
12
|
+
|
|
13
|
+
Redistribution and use in source and binary forms, with or without modification, are
|
|
14
|
+
permitted provided that the following conditions are met:
|
|
15
|
+
|
|
16
|
+
1. Redistributions of source code must retain the above copyright notice, this list of
|
|
17
|
+
conditions and the following disclaimer.
|
|
18
|
+
|
|
19
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
20
|
+
of conditions and the following disclaimer in the documentation and/or other materials
|
|
21
|
+
provided with the distribution.
|
|
22
|
+
|
|
23
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
24
|
+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
|
|
26
|
+
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
27
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
28
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
29
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
30
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
31
|
+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
32
|
+
|
|
33
|
+
(https://raw.github.com/rubyworks/ansi/master/LICENSE.txt)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## ProgressBar
|
|
37
|
+
|
|
38
|
+
Copyright © 2001 *Satoru Takabayashi* ·
|
|
39
|
+
License [Ruby](http://spdx.org/licenses/Ruby) ·
|
|
40
|
+
Website http://0xcc.net/ruby-progressbar
|
|
41
|
+
|
|
42
|
+
ProgressBar class is based on the original ProgressBar by Satoru Takabayashi.
|
|
43
|
+
|
|
44
|
+
Ruby/ProgressBar - a text progress bar library
|
|
45
|
+
|
|
46
|
+
Copyright (C) 2001-2005 Satoru Takabayashi <satoru@namazu.org>
|
|
47
|
+
All rights reserved.
|
|
48
|
+
This is free software with ABSOLUTELY NO WARRANTY.
|
|
49
|
+
|
|
50
|
+
You can redistribute it and/or modify it under the terms
|
|
51
|
+
of Ruby's license.
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## HighLine (Terminal Extensions)
|
|
55
|
+
|
|
56
|
+
Copyright © 2006 *Gray Productions* ·
|
|
57
|
+
License [Ruby](http://spdx.org/licenses/Ruby) ·
|
|
58
|
+
Website http://highline.rubyforge.org
|
|
59
|
+
|
|
60
|
+
The terminal extensions are based on HighLine's SystemExtensions
|
|
61
|
+
by James Edward Gray II.
|
|
62
|
+
|
|
63
|
+
Copyright 2006 Gray Productions
|
|
64
|
+
|
|
65
|
+
Distributed under the user's choice of the {GPL Version 2}[http://www.gnu.org/licenses/old-licenses/gpl-2.0.html]
|
|
66
|
+
(see GPL-2.0.txt for details) or the {Ruby software license}[http://www.ruby-lang.org/en/LICENSE.txt]
|
|
67
|
+
by James Edward Gray II and Greg Brown.
|
|
68
|
+
|
|
69
|
+
Please email James[mailto:james@grayproductions.net] with any questions.
|
|
70
|
+
|
|
71
|
+
(https://github.com/JEG2/highline/blob/master/LICENSE)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## BBCode
|
|
75
|
+
|
|
76
|
+
Copyright © 2002 *Thomas-Ivo Heinen* ·
|
|
77
|
+
License [Ruby](http://spdx.org/licenses/Ruby)
|
|
78
|
+
|
|
79
|
+
BBCode module is a derivative of BBCode by Thomas-Ivo Heinen.
|
|
80
|
+
|
|
81
|
+
Copyright (c) 2002 Thomas-Ivo Heinen
|
|
82
|
+
|
|
83
|
+
This module is free software. You may use, modify, and/or redistribute this
|
|
84
|
+
software under the same terms as Ruby.
|
|
85
|
+
|
|
86
|
+
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
87
|
+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
88
|
+
FOR A PARTICULAR PURPOSE.
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
## Rainbow (XTerm Color Support)
|
|
92
|
+
|
|
93
|
+
Copyright © *Marcin Kulik* ·
|
|
94
|
+
License [MIT](http://spdx.org/licenses/MIT) ·
|
|
95
|
+
Website http://github.com/sickill/rainbow
|
|
96
|
+
|
|
97
|
+
Rainbox provided the bases for building the XTerm 256 color code
|
|
98
|
+
support into the ANSI::Code module.
|
|
99
|
+
|
|
100
|
+
Copyright (c) Marcin Kulik
|
|
101
|
+
|
|
102
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
103
|
+
a copy of this software and associated documentation files (the
|
|
104
|
+
"Software"), to deal in the Software without restriction, including
|
|
105
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
106
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
107
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
108
|
+
the following conditions:
|
|
109
|
+
|
|
110
|
+
The above copyright notice and this permission notice shall be
|
|
111
|
+
included in all copies or substantial portions of the Software.
|
|
112
|
+
|
|
113
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
114
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
115
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
116
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
117
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
118
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
119
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
120
|
+
|
|
121
|
+
(https://raw.github.com/sickill/rainbow/master/LICENSE)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
## Paint (ANSI Code Names)
|
|
125
|
+
|
|
126
|
+
Copyright © 2011 *Jan Lelis* ·
|
|
127
|
+
License [MIT](http://spdx.org/licenses/MIT) ·
|
|
128
|
+
Website https://github.com/janlelis/paint
|
|
129
|
+
|
|
130
|
+
Some of the latest ANSI code names, and inspiration to check out Rainbow
|
|
131
|
+
and include XTerm 256 color codes, came from Paint.
|
|
132
|
+
|
|
133
|
+
Copyright (c) 2011 Jan Lelis
|
|
134
|
+
|
|
135
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
136
|
+
a copy of this software and associated documentation files (the
|
|
137
|
+
"Software"), to deal in the Software without restriction, including
|
|
138
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
139
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
140
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
141
|
+
the following conditions:
|
|
142
|
+
|
|
143
|
+
The above copyright notice and this permission notice shall be
|
|
144
|
+
included in all copies or substantial portions of the Software.
|
|
145
|
+
|
|
146
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
147
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
148
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
149
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
150
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
151
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
152
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
153
|
+
|
|
154
|
+
(https://raw.github.com/janlelis/paint/master/LICENSE.txt)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
## ANSIColor
|
|
158
|
+
|
|
159
|
+
_Acknowlegement_
|
|
160
|
+
|
|
161
|
+
Copyright © 2002 *Florian Frank* ·
|
|
162
|
+
Website http://flori.github.com/term-ansicolor
|
|
163
|
+
|
|
164
|
+
Albeit the code no long bares much, if any, resemblance to it, the ANSI Code
|
|
165
|
+
module (and subsequently the Constants module) originated with the
|
|
166
|
+
ANSIColor library by Florian Frank.
|
|
167
|
+
|
|
168
|
+
Copyright (c) 2002 Florian Frank
|
|
169
|
+
|
|
170
|
+
|
data/{README.rdoc → README.md}
RENAMED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
# ANSI
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
[HOME](https://rubyworks.github.io/ansi) ·
|
|
4
|
+
[API](https://rubydoc.info/gems/ansi) ·
|
|
5
|
+
[ISSUES](https://github.com/rubyworks/ansi/issues) ·
|
|
6
|
+
[SOURCE](https://github.com/rubyworks/ansi)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
[](https://rubygems.org/gems/ansi)
|
|
9
|
+
[](https://github.com/rubyworks/ansi/actions/workflows/test.yml)
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
== DESCRIPTION
|
|
11
|
+
<br/>
|
|
12
12
|
|
|
13
13
|
The ANSI project is a collection of ANSI escape code related libraries
|
|
14
14
|
enabling ANSI code based colorization and stylization of output.
|
|
@@ -21,7 +21,7 @@ Terminal which provides information about the current output
|
|
|
21
21
|
device.
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
## Features
|
|
25
25
|
|
|
26
26
|
* ANSI::Code provides ANSI codes as module functions.
|
|
27
27
|
* String#ansi makes common usage very easy and elegant.
|
|
@@ -30,58 +30,58 @@ device.
|
|
|
30
30
|
* Additional clases for colorized columns, tables, loggers and more.
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
Please see HISTORY file.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
== SYNOPSIS
|
|
33
|
+
## Synopsis
|
|
39
34
|
|
|
40
35
|
There are a number of modules and classes provided by the ANSI
|
|
41
36
|
package. To get a good understanding of them it is best to pursue
|
|
42
|
-
the QED documents
|
|
43
|
-
or the API documentation
|
|
37
|
+
the [QED documents](https://github.com/rubyworks/ansi/tree/master/demo/)
|
|
38
|
+
or the [API documentation](https://rubydoc.info/gems/ansi).
|
|
44
39
|
|
|
45
40
|
At the heart of all the provided libraries lies the ANSI::Code module
|
|
46
41
|
which defines ANSI codes as constants and methods. For example:
|
|
47
42
|
|
|
48
|
-
|
|
43
|
+
require 'ansi/code'
|
|
49
44
|
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
ANSI.red + "Hello" + ANSI.blue + "World"
|
|
46
|
+
=> "\e[31mHello\e[34mWorld"
|
|
52
47
|
|
|
53
48
|
Or in block form.
|
|
54
49
|
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
ANSI.red{ "Hello" } + ANSI.blue{ "World" }
|
|
51
|
+
=> "\e[31mHello\e[0m\e[34mWorld\e[0m"
|
|
57
52
|
|
|
58
53
|
The methods defined by this module are used throughout the rest of
|
|
59
54
|
the system.
|
|
60
55
|
|
|
61
56
|
|
|
62
|
-
|
|
57
|
+
## Installation
|
|
63
58
|
|
|
64
|
-
|
|
59
|
+
### Bundler
|
|
65
60
|
|
|
66
|
-
|
|
61
|
+
Add the usual `gem` line to your project's `Gemfile`.
|
|
62
|
+
|
|
63
|
+
gem 'ansi'
|
|
64
|
+
|
|
65
|
+
And run then `bundle` command.
|
|
66
|
+
|
|
67
|
+
### RubyGems
|
|
68
|
+
|
|
69
|
+
To install with RubyGems simply open a console and type:
|
|
67
70
|
|
|
68
|
-
|
|
69
|
-
then download[http://github.com/rubyworks/ansi/download] the tarball package and type:
|
|
71
|
+
$ sudo gem install ansi
|
|
70
72
|
|
|
71
|
-
|
|
72
|
-
$ cd ansi-1.0.0
|
|
73
|
-
$ sudo setup.rb all
|
|
73
|
+
## Release Notes
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
Please see HISTORY.md file.
|
|
76
76
|
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
## License & Copyrights
|
|
79
79
|
|
|
80
80
|
Copyright (c) 2009 Rubyworks
|
|
81
81
|
|
|
82
|
-
This program is redistributable under the terms of the *
|
|
82
|
+
This program is redistributable under the terms of the *BSD-2-Clause* license.
|
|
83
83
|
|
|
84
84
|
Some pieces of the code are copyrighted by others.
|
|
85
85
|
|
|
86
|
-
See
|
|
86
|
+
See LICENSE.txt and NOTICE.md files for details.
|
|
87
87
|
|
data/demo/01_ansicode.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# ANSI::Code
|
|
2
|
+
|
|
3
|
+
Require the library.
|
|
4
|
+
|
|
5
|
+
require 'ansi/code'
|
|
6
|
+
|
|
7
|
+
ANSI::Code can be used as a functions module.
|
|
8
|
+
|
|
9
|
+
str = ANSI::Code.red + "Hello" + ANSI::Code.blue + "World"
|
|
10
|
+
str.assert == "\e[31mHello\e[34mWorld"
|
|
11
|
+
|
|
12
|
+
If a block is supplied to each method then yielded value will
|
|
13
|
+
be wrapped in the ANSI code and clear code.
|
|
14
|
+
|
|
15
|
+
str = ANSI::Code.red{ "Hello" } + ANSI::Code.blue{ "World" }
|
|
16
|
+
str.assert == "\e[31mHello\e[0m\e[34mWorld\e[0m"
|
|
17
|
+
|
|
18
|
+
More conveniently the ANSI::Code module extends ANSI itself.
|
|
19
|
+
|
|
20
|
+
str = ANSI.red + "Hello" + ANSI.blue + "World"
|
|
21
|
+
str.assert == "\e[31mHello\e[34mWorld"
|
|
22
|
+
|
|
23
|
+
str = ANSI.red{ "Hello" } + ANSI.blue{ "World" }
|
|
24
|
+
str.assert == "\e[31mHello\e[0m\e[34mWorld\e[0m"
|
|
25
|
+
|
|
26
|
+
ANSI also supports XTerm 256 color mode using red, blue and green values
|
|
27
|
+
with the `#rgb` method.
|
|
28
|
+
|
|
29
|
+
str = ANSI::Code.rgb(0, 255, 0)
|
|
30
|
+
str.assert == "\e[38;5;46m"
|
|
31
|
+
|
|
32
|
+
Or using CSS style hex codes as well.
|
|
33
|
+
|
|
34
|
+
str = ANSI::Code.rgb("#00FF00")
|
|
35
|
+
str.assert == "\e[38;5;46m"
|
|
36
|
+
|
|
37
|
+
Both of these methods can take blocks to wrap text in the color and clear codes.
|
|
38
|
+
|
|
39
|
+
str = ANSI::Code.rgb("#00FF00"){ "Hello" }
|
|
40
|
+
str.assert == "\e[38;5;46mHello\e[0m"
|
|
41
|
+
|
|
42
|
+
In the appropriate context the ANSI::Code module can also be
|
|
43
|
+
included, making its methods directly accessible.
|
|
44
|
+
|
|
45
|
+
include ANSI::Code
|
|
46
|
+
|
|
47
|
+
str = red + "Hello" + blue + "World"
|
|
48
|
+
str.assert == "\e[31mHello\e[34mWorld"
|
|
49
|
+
|
|
50
|
+
str = red{ "Hello" } + blue{ "World" }
|
|
51
|
+
str.assert == "\e[31mHello\e[0m\e[34mWorld\e[0m"
|
|
52
|
+
|
|
53
|
+
Along with the single font colors, the library include background colors.
|
|
54
|
+
|
|
55
|
+
str = on_red + "Hello"
|
|
56
|
+
str.assert == "\e[41mHello"
|
|
57
|
+
|
|
58
|
+
As well as combined color methods.
|
|
59
|
+
|
|
60
|
+
str = white_on_red + "Hello"
|
|
61
|
+
str.assert == "\e[37m\e[41mHello"
|
|
62
|
+
|
|
63
|
+
The ANSI::Code module supports most standard ANSI codes, though
|
|
64
|
+
not all platforms support every code, so YMMV.
|
|
65
|
+
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
# String Extensions
|
|
2
2
|
|
|
3
3
|
In addition the library offers an extension to String class
|
|
4
4
|
called #ansi, which allows some of the ANSI::Code methods
|
|
5
5
|
to be called in a more object-oriented fashion.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
require 'ansi/core'
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
str = "Hello".ansi(:red) + "World".ansi(:blue)
|
|
10
|
+
str.assert == "\e[31mHello\e[0m\e[34mWorld\e[0m"
|
|
11
11
|
|
data/demo/03_logger.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# ANSI::Logger
|
|
2
|
+
|
|
3
|
+
Require the ANSI::Logger library.
|
|
4
|
+
|
|
5
|
+
require 'ansi/logger'
|
|
6
|
+
|
|
7
|
+
Create a new ANSI::Logger
|
|
8
|
+
|
|
9
|
+
log = ANSI::Logger.new(STDOUT)
|
|
10
|
+
|
|
11
|
+
Info logging appears normal.
|
|
12
|
+
|
|
13
|
+
log.info{"Info logs are green.\n"}
|
|
14
|
+
|
|
15
|
+
Warn logging appears yellow.
|
|
16
|
+
|
|
17
|
+
log.warn{"Warn logs are yellow.\n"}
|
|
18
|
+
|
|
19
|
+
Debug logging appears cyan.
|
|
20
|
+
|
|
21
|
+
log.debug{"Debug logs are cyan.\n"}
|
|
22
|
+
|
|
23
|
+
Error logging appears red.
|
|
24
|
+
|
|
25
|
+
log.error{"Error logs are red.\n"}
|
|
26
|
+
|
|
27
|
+
Fatal logging appears bright red.
|
|
28
|
+
|
|
29
|
+
log.fatal{"Fatal logs are bold red!\n"}
|
|
30
|
+
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# ANSI::Progressbar
|
|
2
|
+
|
|
3
|
+
Pretty progress bars are easy to construct.
|
|
4
|
+
|
|
5
|
+
require 'ansi/progressbar'
|
|
6
|
+
|
|
7
|
+
pbar = ANSI::Progressbar.new("Test Bar", 100)
|
|
8
|
+
|
|
9
|
+
Running the bar simply requires calling the #inc method during
|
|
10
|
+
a loop and calling `#finish` when done.
|
|
11
|
+
|
|
12
|
+
100.times do |i|
|
|
13
|
+
sleep 0.01
|
|
14
|
+
pbar.inc
|
|
15
|
+
end
|
|
16
|
+
pbar.finish
|
|
17
|
+
|
|
18
|
+
We will use this same rountine in all the examples below, so lets
|
|
19
|
+
make a quick macro for it. Notice we have to use `#reset` first
|
|
20
|
+
before reusing the same progress bar.
|
|
21
|
+
|
|
22
|
+
def run(pbar)
|
|
23
|
+
pbar.reset
|
|
24
|
+
100.times do |i|
|
|
25
|
+
sleep 0.01
|
|
26
|
+
pbar.inc
|
|
27
|
+
end
|
|
28
|
+
pbar.finish
|
|
29
|
+
puts
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
The progress bar can be stylized in almost any way.
|
|
33
|
+
The `#format` setter provides control over the parts
|
|
34
|
+
that appear on the line. For example, by default the
|
|
35
|
+
format is:
|
|
36
|
+
|
|
37
|
+
pbar.format("%-14s %3d%% %s %s", :title, :percentage, :bar, :stat)
|
|
38
|
+
|
|
39
|
+
So lets vary it up to demonstrate the case.
|
|
40
|
+
|
|
41
|
+
pbar.format("%-14s %3d%% %s %s", :title, :percentage, :stat, :bar)
|
|
42
|
+
run(pbar)
|
|
43
|
+
|
|
44
|
+
The progress bar has an extra build in format intended for use with
|
|
45
|
+
file downloads called `#transer_mode`.
|
|
46
|
+
|
|
47
|
+
pbar.transfer_mode
|
|
48
|
+
run(pbar)
|
|
49
|
+
|
|
50
|
+
Calling this methods is the same as calling:
|
|
51
|
+
|
|
52
|
+
pbar.format("%-14s %3d%% %s %s",:title, :percentage, :bar, :stat_for_file_transfer)
|
|
53
|
+
run(pbar)
|
|
54
|
+
|
|
55
|
+
The `#style` setter allows each part of the line be modified with ANSI codes.
|
|
56
|
+
And the `#bar_mark` writer can be used to change the character used to make the bar.
|
|
57
|
+
|
|
58
|
+
pbar.standard_mode
|
|
59
|
+
pbar.style(:title => [:red], :bar=>[:blue])
|
|
60
|
+
pbar.bar_mark = "="
|
|
61
|
+
run(pbar)
|
|
62
|
+
|