paint 0.8.5 → 0.8.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +3 -0
- data/LICENSE.txt +1 -1
- data/README.rdoc +15 -21
- data/lib/paint/util.rb +2 -0
- data/lib/paint/version.rb +1 -1
- metadata +12 -10
data/CHANGELOG.rdoc
CHANGED
data/LICENSE.txt
CHANGED
data/README.rdoc
CHANGED
@@ -1,14 +1,15 @@
|
|
1
|
-
|
1
|
+
{<img src="https://travis-ci.org/janlelis/paint.png" />}[https://travis-ci.org/janlelis/paint]
|
2
2
|
|
3
|
-
|
3
|
+
Paint manages terminal colors and effects for you. It combines the strengths of *term-ansicolor*, *rainbow* and other similar projects into a simple to use, however still flexible terminal colorization gem with no core extensions by default.
|
4
4
|
|
5
5
|
== Features
|
6
|
+
|
6
7
|
* No string extensions (suitable for library development)
|
7
8
|
* Supports setting 256 colors (for capable terminals)
|
8
9
|
* Supports setting any effects (although most terminals won't support it)
|
9
10
|
* Simple to use
|
10
11
|
* Custom shortcuts can be defined and flexibly mixed in
|
11
|
-
* Fall-back modes for non-256-color terminals (Paint.mode), supported modes:
|
12
|
+
* Fall-back modes for non-256-color terminals (<tt>Paint.mode</tt>), supported modes:
|
12
13
|
* 256 colors
|
13
14
|
* 16 colors (only ansi colors, combined with bright effect)
|
14
15
|
* 8 colors (only ansi colors)
|
@@ -28,7 +29,7 @@ In Ruby do:
|
|
28
29
|
|
29
30
|
The only method you need to know to get started is: <tt>Paint.[]</tt>
|
30
31
|
|
31
|
-
The first argument given to Paint.[] is the string to colorize (if the object is not a string, to_s will be called on the object). The other arguments describe how to modify/colorize the string. Let's learn by example:
|
32
|
+
The first argument given to <tt>Paint.[]</tt> is the string to colorize (if the object is not a string, <tt>to_s</tt> will be called on the object). The other arguments describe how to modify/colorize the string. Let's learn by example:
|
32
33
|
|
33
34
|
Paint['Ruby', :red] # sets ansi color red
|
34
35
|
Paint['Ruby', :red, :bright] # also applies bright/bold effect
|
@@ -47,10 +48,11 @@ The first argument given to Paint.[] is the string to colorize (if the object is
|
|
47
48
|
|
48
49
|
If you pass multiple colors, the first one is taken as foreground color and the second one defines the background color (all others will be ignored). To only change the background color, you have to pass a <tt>nil</tt> first. Effects can be passed in any order.
|
49
50
|
|
50
|
-
|
51
|
+
You can find more examples in the specs.
|
51
52
|
|
52
53
|
== Windows Support
|
53
|
-
|
54
|
+
|
55
|
+
For ANSI support in Windows OS, you can use {ansicon}[https://github.com/adoxa/ansicon] or {ConEmu}[http://code.google.com/p/conemu-maximus5/].
|
54
56
|
|
55
57
|
== More details about terminal colors and effects
|
56
58
|
|
@@ -62,9 +64,9 @@ When combined with the <tt>:bright</tt> (= <tt>:bold</tt>) effect, the color in
|
|
62
64
|
|
63
65
|
Through special sequences it's also possible to set 256-colors, instead of 8, which is also supported by many - but not all - terminals. Paint automatically translates given rgb colors to a suitable color of the 256 available colors.
|
64
66
|
|
65
|
-
When using the <tt>Paint.[]</tt> method, Paint wraps the given string between the calculated escape sequence and an reset sequence (<tt>"\e[0m"</tt>). You can
|
67
|
+
When using the <tt>Paint.[]</tt> method, Paint wraps the given string between the calculated escape sequence and an reset sequence (<tt>"\e[0m"</tt>). You can get the raw escape sequence by using the <tt>Paint.color</tt> method.
|
66
68
|
|
67
|
-
=== Effects
|
69
|
+
=== Effects
|
68
70
|
|
69
71
|
Also see {en.wikipedia.org/wiki/ANSI_escape_code}[http://en.wikipedia.org/wiki/ANSI_escape_code]:
|
70
72
|
|
@@ -102,17 +104,17 @@ Also see {en.wikipedia.org/wiki/ANSI_escape_code}[http://en.wikipedia.org/wiki/A
|
|
102
104
|
|
103
105
|
== Paint.mode
|
104
106
|
|
105
|
-
You can choose between
|
107
|
+
You can choose between four ways to use <tt>Paint.[]</tt> by setting <tt>Paint.mode</tt> to one of the following:
|
106
108
|
* 256: full support
|
107
109
|
* 16: don't use 256 colors, but the ansi eight ones (combined with bright effect)
|
108
110
|
* 8: don't use 256 colors, but the ansi eight ones
|
109
111
|
* 0: don't colorize at all
|
110
112
|
|
111
|
-
Paint tries to detect
|
113
|
+
Paint tries to automatically detect the proper value, please open an issue if <tt>Paint.detect_mode</tt> yields a wrong value for you.
|
112
114
|
|
113
115
|
== Advanced Usage: Shortcuts
|
114
116
|
|
115
|
-
Now for the fancy part:
|
117
|
+
Now for the fancy part: You can create color shortcuts for your gems and scripts! Note: You don't have to use this feature (and only stick to <tt>Paint.[]</tt> instead) ;)
|
116
118
|
|
117
119
|
It's easy: Just setup a hash of symbol keys and escape string values at: <tt>Paint::SHORTCUTS[:your_namespace]</tt>. They are stored directly as escape sequences for performance reasons (this also means, you need different namespaces for different <tt>Paint.mode</tt>s). Example:
|
118
120
|
|
@@ -161,15 +163,9 @@ Another helper method is <tt>Paint.unpaint</tt>, which removes any ansi colors:
|
|
161
163
|
|
162
164
|
Paint.unpaint( Paint['J-_-L', :red, :bright] ).should == 'J-_-L'
|
163
165
|
|
164
|
-
==
|
165
|
-
=== Maybe
|
166
|
-
|
167
|
-
* 24-bit color support (konsole), see http://www.reddit.com/r/programming/comments/6gxnp/making_the_most_of_colour_on_text_consoles/c03t8k8
|
168
|
-
* Complete the few missing specs
|
169
|
-
|
170
|
-
== Credits
|
166
|
+
== J-_-L
|
171
167
|
|
172
|
-
Copyright (c) 2011-
|
168
|
+
Copyright (c) 2011-2013 Jan Lelis, http://rbjl.net, released under the MIT license.
|
173
169
|
|
174
170
|
Mainly influenced by rainbow[https://github.com/sickill/rainbow] and {term-ansicolor}[https://github.com/flori/term-ansicolor].
|
175
171
|
|
@@ -177,5 +173,3 @@ Contributions[https://github.com/janlelis/paint/contributors] by and thanks to:
|
|
177
173
|
* {murphy}[https://github.com/rubychan]
|
178
174
|
* {CyberShadow}[https://github.com/CyberShadow]
|
179
175
|
|
180
|
-
== J-_-L
|
181
|
-
|
data/lib/paint/util.rb
CHANGED
data/lib/paint/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-04-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -100,21 +100,21 @@ extra_rdoc_files:
|
|
100
100
|
- README.rdoc
|
101
101
|
- LICENSE.txt
|
102
102
|
files:
|
103
|
-
- lib/paint/rgb_colors_ansi.rb
|
104
|
-
- lib/paint/pa.rb
|
105
103
|
- lib/paint/version.rb
|
106
|
-
- lib/paint/rgb_colors.rb
|
107
104
|
- lib/paint/shortcuts.rb
|
105
|
+
- lib/paint/rgb_colors_ansi.rb
|
106
|
+
- lib/paint/pa.rb
|
108
107
|
- lib/paint/util.rb
|
108
|
+
- lib/paint/rgb_colors.rb
|
109
109
|
- lib/paint.rb
|
110
|
-
- spec/spec_helper.rb
|
111
|
-
- spec/paint_spec.rb
|
112
110
|
- spec/paint_shortcuts_spec.rb
|
111
|
+
- spec/spec_helper.rb
|
113
112
|
- spec/paint_mode_spec.rb
|
113
|
+
- spec/paint_spec.rb
|
114
114
|
- spec/paint_methods_spec.rb
|
115
115
|
- LICENSE.txt
|
116
|
-
- CHANGELOG.rdoc
|
117
116
|
- README.rdoc
|
117
|
+
- CHANGELOG.rdoc
|
118
118
|
- Rakefile
|
119
119
|
- paint.gemspec
|
120
120
|
- .gemtest
|
@@ -139,11 +139,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
139
|
- - ! '>='
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '0'
|
142
|
+
segments:
|
143
|
+
- 0
|
144
|
+
hash: -2257675358826790756
|
142
145
|
requirements: []
|
143
146
|
rubyforge_project:
|
144
|
-
rubygems_version: 1.8.
|
147
|
+
rubygems_version: 1.8.25
|
145
148
|
signing_key:
|
146
149
|
specification_version: 3
|
147
150
|
summary: Terminal painter!
|
148
151
|
test_files: []
|
149
|
-
has_rdoc:
|