ansi 1.2.5 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
@@ -0,0 +1,60 @@
1
+ The Ruby License
2
+
3
+ Ruby is copyrighted free software by <COPYRIGHT HOLDER>.
4
+ You can redistribute it and/or modify it under either the terms of the GPL
5
+ (see COPYING.txt file), or the conditions below:
6
+
7
+ 1. You may make and give away verbatim copies of the source form of the
8
+ software without restriction, provided that you duplicate all of the
9
+ original copyright notices and associated disclaimers.
10
+
11
+ 2. You may modify your copy of the software in any way, provided that
12
+ you do at least ONE of the following:
13
+
14
+ a) place your modifications in the Public Domain or otherwise
15
+ make them Freely Available, such as by posting said
16
+ modifications to Usenet or an equivalent medium, or by allowing
17
+ the author to include your modifications in the software.
18
+
19
+ b) use the modified software only within your corporation or
20
+ organization.
21
+
22
+ c) rename any non-standard executables so the names do not conflict
23
+ with standard executables, which must also be provided.
24
+
25
+ d) make other distribution arrangements with the author.
26
+
27
+ 3. You may distribute the software in object code or executable
28
+ form, provided that you do at least ONE of the following:
29
+
30
+ a) distribute the executables and library files of the software,
31
+ together with instructions (in the manual page or equivalent)
32
+ on where to get the original distribution.
33
+
34
+ b) accompany the distribution with the machine-readable source of
35
+ the software.
36
+
37
+ c) give non-standard executables non-standard names, with
38
+ instructions on where to get the original software distribution.
39
+
40
+ d) make other distribution arrangements with the author.
41
+
42
+ 4. You may modify and include the part of the software into any other
43
+ software (possibly commercial). But some files in the distribution
44
+ are not written by the author, so that they are not under this terms.
45
+
46
+ They are gc.c(partly), utils.c(partly), regex.[ch], st.[ch] and some
47
+ files under the ./missing directory. See each file for the copying
48
+ condition.
49
+
50
+ 5. The scripts and library files supplied as input to or produced as
51
+ output from the software do not automatically fall under the
52
+ copyright of the software, but belong to whomever generated them,
53
+ and may be sold commercially, and may be aggregated with this
54
+ software.
55
+
56
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
57
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
58
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59
+ PURPOSE.
60
+
@@ -1,18 +1,130 @@
1
1
  = COPYRIGHT NOTICES
2
2
 
3
+ == ANSI
4
+
5
+ Copyright:: (c) 2004 Rubyworks, Thomas Sawyer
6
+ License:: BSD-2-Clause
7
+ Website:: http://rubyworks.github.com/ansi
8
+
9
+ Copyright 2004 Thomas Sawyer. All rights reserved.
10
+
11
+ Redistribution and use in source and binary forms, with or without modification, are
12
+ permitted provided that the following conditions are met:
13
+
14
+ 1. Redistributions of source code must retain the above copyright notice, this list of
15
+ conditions and the following disclaimer.
16
+
17
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list
18
+ of conditions and the following disclaimer in the documentation and/or other materials
19
+ provided with the distribution.
20
+
21
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY EXPRESS OR IMPLIED
22
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
23
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
24
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
27
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+
31
+ The views and conclusions contained in the software and documentation are those of the
32
+ authors and should not be interpreted as representing official policies, either expressed
33
+ or implied, of <copyright holder>.
34
+
35
+
3
36
  == ProgressBar
4
37
 
38
+ Copyright:: (C) 2001 Satoru Takabayashi
39
+ License:: Ruby License
40
+ Website:: http://0xcc.net/ruby-progressbar/
41
+
5
42
  ProgressBar class is based on the original ProgressBar by Satoru Takabayashi.
6
43
 
7
- Copyright (C) 2001 Satoru Takabayashi
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
+
8
53
 
54
+ == HighLine (Terminal Extensions)
9
55
 
10
- == Terminal Extensions
56
+ Copyright:: (c) 2006 Gray Productions
57
+ License:: Ruby License
58
+ Website:: http://highline.rubyforge.org/
11
59
 
12
60
  The terminal extensions are based on HighLine's SystemExtensions
13
61
  by James Edward Gray II.
14
62
 
15
- Copyright 2006 Gray Productions
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
+
72
+ == BBCode
73
+
74
+ Copyright:: (c) 2002 Thomas-Ivo Heinen
75
+ License:: Ruby License
76
+
77
+ BBCode module is a derivative of BBCode by Thomas-Ivo Heinen.
78
+
79
+ Copyright (c) 2002 Thomas-Ivo Heinen
80
+
81
+ This module is free software. You may use, modify, and/or redistribute this
82
+ software under the same terms as Ruby.
83
+
84
+ This program is distributed in the hope that it will be useful, but WITHOUT
85
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
86
+ FOR A PARTICULAR PURPOSE.
87
+
88
+
89
+ == Rainbow (XTerm Color Support)
90
+
91
+ Copyright:: (c) Marcin Kulik
92
+ License:: MIT
93
+ Website:: http://github.com/sickill/rainbow
94
+
95
+ Rainbox provided the bases for building the XTerm 256 color code
96
+ support into the ANSI::Code module.
97
+
98
+ Copyright (c) Marcin Kulik
99
+
100
+ Permission is hereby granted, free of charge, to any person obtaining
101
+ a copy of this software and associated documentation files (the
102
+ "Software"), to deal in the Software without restriction, including
103
+ without limitation the rights to use, copy, modify, merge, publish,
104
+ distribute, sublicense, and/or sell copies of the Software, and to
105
+ permit persons to whom the Software is furnished to do so, subject to
106
+ the following conditions:
107
+
108
+ The above copyright notice and this permission notice shall be
109
+ included in all copies or substantial portions of the Software.
110
+
111
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
112
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
113
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
114
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
115
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
116
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
117
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
118
+
119
+
120
+ = ACKNOWLEDGEMENTS
121
+
122
+ == ANSIColor
123
+
124
+ Copyright:: (c) 2002 Florian Frank
125
+ Website:: http://flori.github.com/term-ansicolor
16
126
 
17
- {Ruby software license}[http://www.ruby-lang.org/en/LICENSE.txt]
127
+ Albeit the code no long bares any resemblance to it, the ANSI Code module
128
+ (and subsequently the Constants module) originated with the ANSIColor
129
+ library by Florian Frank.
18
130
 
@@ -37,26 +37,21 @@ Please see HISTORY file.
37
37
  There are a number of modules and classes provided by the ANSI
38
38
  package. To get a good understanding of them it is best to pursue
39
39
  the QED documents[http://github.com/rubyworks/ansi/tree/master/qed/]
40
- or the API documentation[http://rubyworks.github.com/ansi/rdoc/].
40
+ or the API documentation[http://rubyworks.github.com/ansi/api/index.html].
41
41
 
42
42
  At the heart of all the provided libraries lies the ANSI::Code module
43
43
  which defines ANSI codes as constants and methods. For example:
44
44
 
45
45
  require 'ansi/code'
46
46
 
47
- include ANSI::Code
48
-
49
- red + "Hello" + blue + "World"
47
+ ANSI.red + "Hello" + ANSI.blue + "World"
50
48
  => "\e[31mHello\e[34mWorld"
51
49
 
52
50
  Or in block form.
53
51
 
54
- red{ "Hello" } + blue{ "World" }
52
+ ANSI.red{ "Hello" } + ANSI.blue{ "World" }
55
53
  => "\e[31mHello\e[0m\e[34mWorld\e[0m"
56
54
 
57
- Rather than include +ANSI::Code+, these methods can also be called as module
58
- methods. Either as <code>ANSI::Code.red</code> or just <code>ANSI.red</code>.
59
-
60
55
  The methods defined by this module are used throughout the rest of
61
56
  the system.
62
57
 
@@ -77,11 +72,10 @@ then download[http://github.com/rubyworks/ansi/download] the tarball package and
77
72
  Windows users use 'ruby setup.rb all'.
78
73
 
79
74
 
80
- == LICENSE/COPYRIGHT
75
+ == LICENSE & COPYRIGHT
81
76
 
82
77
  Copyright (c) 2004 Thomas Sawyer
83
78
 
84
- This program is distributed under the terms of the Apache 2 license.
85
-
86
- See LICENSE file for details.
79
+ This program is distributed under the terms of the BSD 2-clause license.
87
80
 
81
+ See NOTICE.rdoc file and LICENSE directory for details.
@@ -14,6 +14,7 @@ module ANSI
14
14
  end
15
15
  end
16
16
 
17
+ require 'ansi/core'
17
18
  require 'ansi/code'
18
19
  require 'ansi/bbcode'
19
20
  require 'ansi/columns'
@@ -25,3 +26,8 @@ require 'ansi/string'
25
26
  require 'ansi/table'
26
27
  require 'ansi/terminal'
27
28
 
29
+ # Kernel method
30
+ def ansi(string, *codes)
31
+ ANSI::Code.ansi(string, *codes)
32
+ end
33
+
@@ -0,0 +1,40 @@
1
+ # ANSI Module provides a Bezel interface as follows:
2
+ #
3
+ # ANSI = lib('ansi', '1.2.6')
4
+ #
5
+ # module MyAPP
6
+ # include ANSI
7
+ # end
8
+ #
9
+ # Examples
10
+ #
11
+ # def hello_world
12
+ # puts ansi("Hello World", :red)
13
+ # end
14
+ #
15
+ # # automatically included with ANSI 1.3.
16
+ # def ansi(string, *codes)
17
+ # ANSI::Code.ansi(string, *codes)
18
+ # end
19
+ #
20
+ # Or
21
+ #
22
+ # def hello_world
23
+ # puts "Hello World".ansi(:red)
24
+ # end
25
+ #
26
+ # NOTE: Core extensions need stable interfaces!
27
+ #
28
+ module ANSI; end
29
+
30
+ import 'ansi/code'
31
+ import 'ansi/bbcode'
32
+ import 'ansi/columns'
33
+ import 'ansi/diff'
34
+ import 'ansi/logger'
35
+ import 'ansi/mixin'
36
+ import 'ansi/progressbar'
37
+ import 'ansi/string'
38
+ import 'ansi/table'
39
+ import 'ansi/terminal'
40
+
@@ -1,44 +1,47 @@
1
1
  ---
2
- spec_version: 1.0.0
3
- replaces: []
4
-
5
- loadpath:
6
- - lib
7
2
  name: ansi
8
- repositories: {}
9
-
10
- conflicts: []
11
-
12
- engine_check: []
13
-
3
+ version: 1.3.0
14
4
  title: ANSI
15
- contact: rubyworks-mailinglist@googlegroups.com
16
- resources:
17
- repository: git://github.com/rubyworks/ansi.git
18
- api: http://rubyworks.github.com/ansi/rdoc
19
- mail: http://groups.google.com/group/rubyworks-mailinglist
20
- home: http://rubyworks.github.com/ansi
21
- work: http://github.com/rubyworks/ansi
22
- maintainers: []
23
-
5
+ summary: ANSI codes at your fingertips!
6
+ description: The ANSI project is a collection of ANSI escape code related libraries enabling ANSI code based colorization and stylization of output. It is very nice for beautifying shell output.
7
+ loadpath:
8
+ - lib
9
+ manifest: Manifest
24
10
  requires:
25
- - group:
11
+ - name: detroit
12
+ version: 0+
13
+ group:
26
14
  - build
27
- name: syckle
15
+ - name: qed
28
16
  version: 0+
29
- - group:
17
+ group:
30
18
  - test
31
- name: ko
19
+ - name: lemon
32
20
  version: 0+
33
- manifest: MANIFEST
34
- version: 1.2.5
21
+ group:
22
+ - test
23
+ conflicts: []
24
+
25
+ replaces: []
26
+
27
+ engine_check: []
28
+
29
+ organization: RubyWorks
30
+ contact: rubyworks-mailinglist@googlegroups.com
31
+ created: 2004-08-01
32
+ copyright: Copyright (c) 2009 Thomas Sawyer
35
33
  licenses:
36
34
  - Apache 2.0
37
- copyright: Copyright (c) 2009 Thomas Sawyer
38
35
  authors:
39
36
  - Thomas Sawyer
40
37
  - Florian Frank
41
- organization: RubyWorks
42
- description: The ANSI project is a collection of ANSI escape code related libraries enabling ANSI code based colorization and stylization of output. It is very nice for beautifying shell output.
43
- summary: ANSI codes at your fingertips!
44
- created: 2004-08-01
38
+ maintainers: []
39
+
40
+ resources:
41
+ home: http://rubyworks.github.com/ansi
42
+ work: http://github.com/rubyworks/ansi
43
+ api: http://rubyworks.github.com/ansi/rdoc
44
+ mail: http://groups.google.com/group/rubyworks-mailinglist
45
+ repositories:
46
+ public: git://github.com/rubyworks/ansi.git
47
+ spec_version: 1.0.0
@@ -31,6 +31,9 @@ module ANSI
31
31
  # print( BBCode.bbcode_to_ansi(str) )
32
32
  # print( BBCode.bbcode_to_html(str) )
33
33
  #
34
+ #--
35
+ # TODO: integrate with Code module.
36
+ #++
34
37
  module BBCode
35
38
 
36
39
  ## ANSIname => ANSIcode LUT
@@ -0,0 +1,95 @@
1
+ module ANSI
2
+
3
+ # Table of codes used throughout the system.
4
+ #
5
+ # @see http://en.wikipedia.org/wiki/ANSI_escape_code
6
+ CHART = {
7
+ :clear => 0,
8
+ :reset => 0,
9
+ :bright => 1,
10
+ :bold => 1,
11
+ :faint => 2,
12
+ :dark => 2,
13
+ :italic => 3,
14
+ :underline => 4,
15
+ :underscore => 4,
16
+ :blink => 5,
17
+ :slow_blink => 5,
18
+ :rapid => 6,
19
+ :rapid_blink => 6,
20
+ :inverse => 7,
21
+ :reverse => 7,
22
+ :negative => 7,
23
+ :concealed => 8,
24
+ :swap => 7,
25
+ :conceal => 8,
26
+ :concealed => 8,
27
+ :hide => 9,
28
+ :strike => 9,
29
+
30
+ :default_font => 10,
31
+ :font_default => 10,
32
+ :font0 => 10,
33
+ :font1 => 11,
34
+ :font2 => 12,
35
+ :font3 => 13,
36
+ :font4 => 14,
37
+ :font5 => 15,
38
+ :font6 => 16,
39
+ :font7 => 17,
40
+ :font8 => 18,
41
+ :font9 => 19,
42
+ :fraktur => 20,
43
+ :bright_off => 21,
44
+ :bold_off => 21,
45
+ :double_underline => 21,
46
+ :clean => 22,
47
+ :italic_off => 23,
48
+ :fraktur_off => 23,
49
+ :underline_off => 24,
50
+ :blink_off => 25,
51
+ :inverse_off => 26,
52
+ :positive => 26,
53
+ :conceal_off => 27,
54
+ :show => 27,
55
+ :reveal => 27,
56
+ :crossed_off => 29,
57
+ :crossed_out_off => 29,
58
+
59
+ :black => 30,
60
+ :red => 31,
61
+ :green => 32,
62
+ :yellow => 33,
63
+ :blue => 34,
64
+ :magenta => 35,
65
+ :cyan => 36,
66
+ :white => 37,
67
+
68
+ :on_black => 40,
69
+ :on_red => 41,
70
+ :on_green => 42,
71
+ :on_yellow => 43,
72
+ :on_blue => 44,
73
+ :on_magenta => 45,
74
+ :on_cyan => 46,
75
+ :on_white => 47,
76
+
77
+ :frame => 51,
78
+ :encircle => 52,
79
+ :overline => 53,
80
+ :frame_off => 54,
81
+ :encircle_off => 54,
82
+ :overline_off => 55,
83
+ }
84
+
85
+ #
86
+ SPECIAL_CHART = {
87
+ :save => "\e[s", # Save current cursor positon.
88
+ :restore => "\e[u", # Restore saved cursor positon.
89
+ :clear_line => "\e[K", # Clear to the end of the current line.
90
+ :clr => "\e[K", # Clear to the end of the current line.
91
+ :clear_screen => "\e[2J", # Clear the screen and move cursor to home.
92
+ :cls => "\e[2J", # Clear the screen and move cursor to home.
93
+ }
94
+
95
+ end