dslinux/user/perl/lib/Term/ANSIColor ChangeLog README test.pl
cayenne
dslinux_cayenne at user.in-berlin.de
Mon Dec 4 18:01:02 CET 2006
Update of /cvsroot/dslinux/dslinux/user/perl/lib/Term/ANSIColor
In directory antilope:/tmp/cvs-serv17422/lib/Term/ANSIColor
Added Files:
ChangeLog README test.pl
Log Message:
Adding fresh perl source to HEAD to branch from
--- NEW FILE: README ---
Term::ANSIColor version 1.10
(A simple ANSI text attribute control module)
Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2005 Russ Allbery
<rra at stanford.edu> and Zenin. This program is free software; you may
redistribute it and/or modify it under the same terms as Perl itself.
I welcome bug reports and patches for this package at rra at stanford.edu.
However, please be aware that I tend to be extremely busy and to get a
lot of mail. I'll save your mail and get to it as soon as I can, but
depending on how busy I am it may take me a couple of months.
INTRODUCTION
This module grew out of a thread on comp.lang.perl.misc where several of
us were throwing around different ways to print colored text from Perl
scripts and Zenin posted his old library to do that. I (Russ) disagreed
with the implementation and offered my own (the color() and colored()
functions implemented in this package), Zenin convinced me that the
constants had their place as well, and we started figuring out the best
ways of implementing both.
While ANSI color escape codes are fairly simple, it can be hard to
remember the codes for all of the attributes and the code resulting from
hard-coding them into your script is definitely difficult to read. This
module is designed to fix those problems, as well as provide a
convenient interface to do a few things for you automatically (like
resetting attributes after the text you print out so that you don't
accidentally leave attributes set).
Despite its name, this module can also handle non-color ANSI text
attributes (bold, underline, reverse video, and blink). It uses either
of two interfaces, one of which uses "constants" for each different
attribute and the other of which uses two subs which take strings of
attributes as arguments.
The most recent version of this module is available at its web site:
<http://www.eyrie.org/~eagle/software/ansicolor/>
See the POD documentation for complete details, features, and usage.
This module is distributed as part of the Perl core distribution as of
Perl 5.6.0. You only need to install this module if you want a newer
version than came with Perl or if you have an old version of Perl.
INSTALLATION
Follow the standard installation procedure for Perl modules, which is to
type the following commands:
perl Makefile.PL
make
make test
make install
You'll probably need to do the last as root. If instead you wish to
install the module by hand, simply copy it into a directory named Term
in your Perl library directory.
Note that make install, for Perl 5.6.0 or later, will replace the
Term::ANSIColor that came with Perl. You may wan to save a backup copy
of the standard version first.
THANKS
To Jon Lennox for looking at early versions of this module, providing
feedback, and offering suggestions for improvement.
To Jesse Taylor for writing the first significant script to use this
module (colorized calsplit), thus offering innumerable opportunities to
test and debug.
To Jean Delvare for providing documentation of what the various
attributes do on various different terminal emulators, and for noting
that attribute 2 is dark.
To Edward Avis for the implementation of uncolor.
To Rani Pinchuk for the idea of ANSI_COLORS_DISABLED and an initial
implementation.
To ATricket for the information about what PuTTY, Windows telnet, and
OpenSSH under Cygwin support.
To Richard Maus for pointing out DARK was missing from the exported
constants list and CYAN and WHITE were missing from the documentation.
To Autrijus Tang for noticing a problem with string comparisons in the
test suite.
To Daniel Lindsley for the information about what Mac OS X Terminal
supports.
To Joe Smith for the test files that exercise a wide variety of VT100
escape sequences including the ECMA-48 color control codes.
To James Bowlin for catching a bug in colored when $EACHLINE is set that
caused it to not color lines consisting solely of 0.
To Larry Wall, as always, for Perl.
--- NEW FILE: test.pl ---
#!/usr/bin/perl
# $Id: test.pl,v 1.1 2006-12-04 17:01:00 dslinux_cayenne Exp $
#
# test.pl -- Test suite for the Term::ANSIColor Perl module.
#
# Before "make install" is performed this script should be runnable with "make
# test". After "make install" it should work as "perl test.pl".
##############################################################################
# Ensure module can be loaded
##############################################################################
BEGIN { $| = 1; print "1..16\n" }
END { print "not ok 1\n" unless $loaded }
delete $ENV{ANSI_COLORS_DISABLED};
use Term::ANSIColor qw(:constants color colored uncolor);
$loaded = 1;
print "ok 1\n";
##############################################################################
# Test suite
##############################################################################
# Test simple color attributes.
if (color ('blue on_green', 'bold') eq "\e[34;42;1m") {
print "ok 2\n";
} else {
print "not ok 2\n";
}
# Test colored.
if (colored ("testing", 'blue', 'bold') eq "\e[34;1mtesting\e[0m") {
print "ok 3\n";
} else {
print "not ok 3\n";
}
# Test the constants.
if (BLUE BOLD "testing" eq "\e[34m\e[1mtesting") {
print "ok 4\n";
} else {
print "not ok 4\n";
}
# Test AUTORESET.
$Term::ANSIColor::AUTORESET = 1;
if (BLUE BOLD "testing" eq "\e[34m\e[1mtesting\e[0m\e[0m") {
print "ok 5\n";
} else {
print "not ok 5\n";
}
# Test EACHLINE.
$Term::ANSIColor::EACHLINE = "\n";
if (colored ("test\n\ntest", 'bold')
eq "\e[1mtest\e[0m\n\n\e[1mtest\e[0m") {
print "ok 6\n";
} else {
print colored ("test\n\ntest", 'bold'), "\n";
print "not ok 6\n";
}
# Test EACHLINE with multiple trailing delimiters.
$Term::ANSIColor::EACHLINE = "\r\n";
if (colored ("test\ntest\r\r\n\r\n", 'bold')
eq "\e[1mtest\ntest\r\e[0m\r\n\r\n") {
print "ok 7\n";
} else {
print "not ok 7\n";
}
# Test the array ref form.
$Term::ANSIColor::EACHLINE = "\n";
if (colored (['bold', 'on_green'], "test\n", "\n", "test")
eq "\e[1;42mtest\e[0m\n\n\e[1;42mtest\e[0m") {
print "ok 8\n";
} else {
print colored (['bold', 'on_green'], "test\n", "\n", "test");
print "not ok 8\n";
}
# Test uncolor.
my @names = uncolor ('1;42', "\e[m", '', "\e[0m");
if (join ('|', @names) eq 'bold|on_green|clear') {
print "ok 9\n";
} else {
print join ('|', @names), "\n";
print "not ok 9\n";
}
# Test ANSI_COLORS_DISABLED.
$ENV{ANSI_COLORS_DISABLED} = 1;
if (color ('blue') eq '') {
print "ok 10\n";
} else {
print "not ok 10\n";
}
if (colored ('testing', 'blue', 'on_red') eq 'testing') {
print "ok 11\n";
} else {
print "not ok 11\n";
}
if (GREEN 'testing' eq 'testing') {
print "ok 12\n";
} else {
print "not ok 12\n";
}
delete $ENV{ANSI_COLORS_DISABLED};
# Make sure DARK is exported. This was omitted in versions prior to 1.07.
if (DARK "testing" eq "\e[2mtesting\e[0m") {
print "ok 13\n";
} else {
print "not ok 13\n";
}
# Test colored with 0 and EACHLINE.
$Term::ANSIColor::EACHLINE = "\n";
if (colored ('0', 'blue', 'bold') eq "\e[34;1m0\e[0m") {
print "ok 14\n";
} else {
print "not ok 14\n";
}
if (colored ("0\n0\n\n", 'blue', 'bold')
eq "\e[34;1m0\e[0m\n\e[34;1m0\e[0m\n\n") {
print "ok 15\n";
} else {
print "not ok 15\n";
}
# Test colored with the empty string and EACHLINE.
if (colored ('', 'blue', 'bold') eq '') {
print "ok 16\n";
} else {
print "not ok 16\n";
}
--- NEW FILE: ChangeLog ---
2005-08-21 Russ Allbery <rra at stanford.edu>
* ANSIColor.pm: Version 1.10 released.
* ANSIColor.pm (colored): Fix the $EACHLINE support to work
properly with a line consisting solely of "0". Remove Zenin's
now-defunct e-mail address from the documentation.
* test.pl: Test 0 and the empty string in combination with
$EACHLINE.
* tests/ansicolor: Add terminal test file from Joe Smith.
* tests/vt100-torture: Likewise.
* tests/README: Add an explanation of the test files.
2004-12-03 Russ Allbery <rra at stanford.edu>
* ANSIColor.pm: Version 1.09 released.
* ANSIColor.pm: Add compatibility information for Mac OS X
Terminal from Daniel Lindsley.
2004-02-20 Russ Allbery <rra at stanford.edu>
* test.pl: Always use eq, not ==, for string comparisons.
2004-02-19 Russ Allbery <rra at stanford.edu>
* ANSIColor.pm: Version 1.08 released.
* ANSIColor.pm: Add DARK to %EXPORT_TAGS and add CYAN and WHITE to
the list of documented constants.
* test.pl: Add a test for DARK. Redo the leading comment.
2003-03-25 Russ Allbery <rra at stanford.edu>
* ANSIColor.pm: Version 1.07 released.
* ANSIColor.pm: Add PuTTY, Windows telnet, and Cygwin OpenSSH
information to the terminal emulators table, and update the URL to
the ECMA standard.
2002-12-09 Russ Allbery <rra at stanford.edu>
* ANSIColor.pm: Version 1.06 released to synchronize the version
on CPAN with the version in Perl core.
* ANSIColor.pm: Fix typo in L<> link in documentation.
2002-06-28 Russ Allbery <rra at stanford.edu>
* ANSIColor.pm: Version 1.05 released.
* ANSIColor.pm: Update the formatting style, add a pointer to the
module web site, use L<> for URLs, and use naked <>s where
permissible rather than E<lt> and E<gt>. Renamed LICENSE to
COPYRIGHT AND LICENSE.
2002-02-14 Russ Allbery <rra at stanford.edu>
* ANSIColor.pm: Added a mention of the specific Windows consoles
that don't work with this module.
2001-07-10 Russ Allbery <rra at stanford.edu>
* ANSIColor.pm: Version 1.04 released.
* ANSIColor.pm: Add documentation, examples, and diagnostics for
uncolor. Document ANSI_COLORS_DISABLED. Add information about
the relevant standards for these escape sequences and the
additional ones that aren't supported by this module. Add a
pointer to the relevant standards. Add a LICENSE section. Update
Zenin's e-mail address.
* ANSIColor.pm (AUTOLOAD): Add support for ANSI_COLORS_DISABLED.
(color): Likewise.
(colored): Likewise.
* test.pl: Add tests for ANSI_COLORS_DISABLED.
* ANSIColor.pm (uncolor): New function.
* test.pl: Add a test for it.
2000-08-06 Russ Allbery <rra at stanford.edu>
* ANSIColor.pm: Version 1.03 released.
* Makefile.PL: Install in the Perl library directory for Perl
versions >= 5.6.0.
* test.pl: Added a new test for the array reference syntax for
colored.
* ANSIColor.pm: Changed $VERSION to a static string. Added dark
to the attributes. Updated the documentation to include a table
of supported attributes on different terminal emulators, to add
dark, to document the new optional way to call colored, and to
mark the diagnostics as fatal errors or warnings.
(colored): Allow the attributes to be passed as an initial array
reference as well as a final list, and for that calling syntax
take the rest of the arguments as text to be colored.
1998-11-27 Russ Allbery <rra at stanford.edu>
* ANSIColor.pm: Version 1.02 released.
* Makefile.PL: Added a 5.005-only section giving ABSTRACT and
AUTHOR settings for generating a PPD to go with a binary
distribution or the Perl Resource Kits.
1998-04-14 Russ Allbery <rra at stanford.edu>
* ANSIColor.pm: croak() instead of die() on AUTOLOAD failure to
get the right error text, fixed a bunch of typos in the
documentation, added a quote.
1997-12-10 Russ Allbery <rra at stanford.edu>
* ANSIColor.pm: Version 1.01 released.
* ANSIColor.pm (color): Carp::croak() isn't predeclared, so it
needs parens around its argument. This bug will only show up in
versions of Perl >5.004_04 since up until then strict.pm imports
Carp which predeclares the function.
1997-11-29 Russ Allbery <rra at stanford.edu>
* ANSIColor.pm: Version 1.00 released.
* Makefile.PL: Now gets version information from the module, has
the correct rules to build a distribution.
* test.pl: Comments trimmed, minor test modifications.
* ANSIColor.pm: Changed my e-mail address, fixed to deal correctly
with trailing delimiters when EACHLINE is being used, die()
changed to croak() if the caller uses an invalid attribute name,
getting $VERSION from RCS updated to my current method, source
detabified.
* test.pl: Added test for EACHLINE with trailing delimiters.
1997-02-17 Russ Allbery <rra at stanford.edu>
* ANSIColor.pm: Version 0.9 released.
* ANSIColor.pm: Changed the runtime error message to start with an
uppercase letter, reworked the documentation considerably
including adding more comparison between the two interfaces,
fixing some formatting bugs, fixing a typo, adding more
diagnostics, and generally being more verbose.
1997-01-08 Russ Allbery <rra at stanford.edu>
* ANSIColor.pm: Version 0.8 released.
* test.pl: Fixed the test numbering in the BEGIN block.
* test.pl: Reformatted and commented to fit my programming style.
* ANSIColor.pm: Changed the method by which $VERSION is set so
that it will always have two digits after the decimal point.
* test.pl: New file.
* ANSIColor.pm: [Revision 0.7] Changed the codes so that reset is
always consistantly "\e[0m".
* ANSIColor.pm: [Revision 0.6] Added $EACHLINE and support to
colored() for it so that attributes can be reset around every
newline (or other line delimiter -- we're flexible). Documented
this as well.
* ANSIColor.pm: [Revision 0.5] Changed implementation of the
constants to autoloaded subs, added the $AUTORESET variable for
use with the constants, and documented this.
1996-12-07 Russ Allbery <rra at stanford.edu>
* ANSIColor.pm: [Revision 0.4] Added POD documentation.
* ANSIColor.pm: [Revision 0.3] Added constant forms, modified to
allow a space-separated string of attributes to be passed to
color() and colored(), added Zenin to the credits.
1996-12-04 Russ Allbery <rra at stanford.edu>
* ANSIColor.pm: [Revision 0.2] Changed return syntax and check for
the null attribute string.
* ANSIColor.pm: New file.
More information about the dslinux-commit
mailing list