cpan/Term-ANSIColor/ChangeLog Term::ANSIColor
cpan/Term-ANSIColor/README Term::ANSIColor
cpan/Term-ANSIColor/t/basic.t Tests for Term::ANSIColor
+cpan/Term-ANSIColor/t/eval.t
cpan/Term-ANSIColor/t/stringify.t Tests for Term::ANSIColor
cpan/Term-Cap/Cap.pm Perl module supporting termcap usage
cpan/Term-Cap/test.pl See if Term::Cap works
'Term::ANSIColor' => {
'MAINTAINER' => 'rra',
- 'DISTRIBUTION' => 'RRA/Term-ANSIColor-3.01.tar.gz',
+ 'DISTRIBUTION' => 'RRA/Term-ANSIColor-3.02.tar.gz',
'FILES' => q[cpan/Term-ANSIColor],
'EXCLUDED' => [
qr{^tests/},
# Term::ANSIColor -- Color screen output using ANSI escape sequences.
#
# Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2005, 2006, 2008, 2009, 2010,
-# 2011 Russ Allbery <rra@stanford.edu> and Zenin
+# 2011, 2012 Russ Allbery <rra@stanford.edu> and Zenin
# PUSH/POP support submitted 2007 by openmethods.com voice solutions
#
# This program is free software; you may redistribute it and/or modify it
package Term::ANSIColor;
require 5.001;
-$VERSION = '3.01';
+$VERSION = '3.02';
use strict;
use vars qw($AUTOLOAD $AUTOLOCAL $AUTORESET @COLORLIST @COLORSTACK $EACHLINE
BEGIN {
@COLORLIST = qw(
CLEAR RESET BOLD DARK
- FAINT UNDERLINE UNDERSCORE BLINK
- REVERSE CONCEALED
+ FAINT ITALIC UNDERLINE UNDERSCORE
+ BLINK REVERSE CONCEALED
BLACK RED GREEN YELLOW
BLUE MAGENTA CYAN WHITE
'bold' => 1,
'dark' => 2,
'faint' => 2,
+ 'italic' => 3,
'underline' => 4,
'underscore' => 4,
'blink' => 5,
# write scripts that also work on systems without any ANSI support, like
# Windows consoles.
sub AUTOLOAD {
- if (defined $ENV{ANSI_COLORS_DISABLED}) {
- return join ('', @_);
- }
if ($AUTOLOAD =~ /^([\w:]*::([A-Z_]+))$/ and defined $ATTRIBUTES{lc $2}) {
+ if (defined $ENV{ANSI_COLORS_DISABLED}) {
+ return join ('', @_);
+ }
$AUTOLOAD = $1;
my $attr = "\e[" . $ATTRIBUTES{lc $2} . 'm';
+ my $saved = $@;
eval qq {
sub $AUTOLOAD {
if (\$AUTORESET && \@_) {
}
}
};
+ die "failed to generate constant $1" if $@;
+ $@ = $saved;
goto &$AUTOLOAD;
} else {
require Carp;
cyan colorize namespace runtime TMTOWTDI cmd.exe 4nt.exe command.com NT
ESC Delvare SSH OpenSSH aixterm ECMA-048 Fraktur overlining Zenin
reimplemented Allbery PUSHCOLOR POPCOLOR LOCALCOLOR openmethods.com
-grey ATTR
+grey ATTR urxvt mistyped
=head1 SYNOPSIS
The function interface uses attribute strings to describe the colors and
text attributes to assign to text. The recognized non-color attributes
-are clear, reset, bold, dark, faint, underline, underscore, blink,
+are clear, reset, bold, dark, faint, italic, underline, underscore, blink,
reverse, and concealed. Clear and reset (reset to default attributes),
dark and faint (dim and saturated), and underline and underscore are
equivalent, so use whichever is the most intuitive to you.
Note that not all attributes are supported by all terminal types, and some
-terminals may not support any of these sequences. Dark and faint, blink,
-and concealed in particular are frequently not implemented.
+terminals may not support any of these sequences. Dark and faint, italic,
+blink, and concealed in particular are frequently not implemented.
+
+Support for italic was added in Term::ANSIColor 3.02.
The recognized normal foreground color attributes (colors 0 to 7) are:
constants directly:
CLEAR RESET BOLD DARK
- FAINT UNDERLINE UNDERSCORE BLINK
- REVERSE CONCEALED
+ FAINT ITALIC UNDERLINE UNDERSCORE
+ BLINK REVERSE CONCEALED
BLACK RED GREEN YELLOW
BLUE MAGENTA CYAN WHITE
(Note that the newline is kept separate to avoid confusing the terminal as
described above since a background color is being used.)
+Support for C<ITALIC> was added in Term::ANSIColor 3.02.
+
When using the constants, if you don't want to have to remember to add the
C<, RESET> at the end of each print line, you can set
$Term::ANSIColor::AUTORESET to a true value. Then, the display mode will
doesn't reset colors; you have to explicitly set the colors back to what
you want. More entries in this table are welcome.
-Note that codes 3 (italic), 6 (rapid blink), and 9 (strike-through) are
-specified in ANSI X3.64 and ECMA-048 but are not commonly supported by
-most displays and emulators and therefore aren't supported by this module
-at the present time. ECMA-048 also specifies a large number of other
-attributes, including a sequence of attributes for font changes, Fraktur
-characters, double-underlining, framing, circling, and overlining. As
-none of these attributes are widely supported or useful, they also aren't
-currently supported by this module.
+Support for code 3 (italic) is rare and therefore not mentioned in that
+table. It is not believed to be fully supported by any of the terminals
+listed, although it's displayed as green in the Linux console, but it is
+reportedly supported by urxvt.
+
+Note that codes 6 (rapid blink) and 9 (strike-through) are specified in
+ANSI X3.64 and ECMA-048 but are not commonly supported by most displays
+and emulators and therefore aren't supported by this module at the present
+time. ECMA-048 also specifies a large number of other attributes,
+including a sequence of attributes for font changes, Fraktur characters,
+double-underlining, framing, circling, and overlining. As none of these
+attributes are widely supported or useful, they also aren't currently
+supported by this module.
=head1 SEE ALSO
=head1 COPYRIGHT AND LICENSE
-Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2005, 2006, 2008, 2009, 2010,
-2011 Russ Allbery <rra@stanford.edu> and Zenin. This program is free
-software; you may redistribute it and/or modify it under the same terms as
-Perl itself.
+Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2005, 2006, 2008, 2009,
+2010, 2011, 2012 Russ Allbery <rra@stanford.edu> and Zenin. This program
+is free software; you may redistribute it and/or modify it under the same
+terms as Perl itself.
PUSHCOLOR, POPCOLOR, and LOCALCOLOR were contributed by openmethods.com
voice solutions.
+2012-03-18 Russ Allbery <rra@stanford.edu>
+
+ * ANSIColor.pm: Version 3.02 released.
+
+ * ANSIColor.pm (AUTOLOAD): Only return pass-through behavior if
+ the function that was called was one of our constants, rather than
+ turning every unknown function in the Term::ANSIColor namespace
+ into a passthrough join function when colors are disabled.
+ * t/basic.t: Test proper error reporting with colors disabled.
+
+ * ANSIColor.pm (AUTOLOAD): Preserve an existing value of $@ when
+ generating a constant sub and restore it afterwards. Diagnose
+ errors in creating the constant sub and die instead of ignoring
+ them.
+ * t/eval.t: New test for $@ preservation.
+
+ * ANSIColor.pm: Add italic and the ITALIC constant. Document that
+ the support for it is rare.
+ * t/basic.t: Test italic and ITALIC support.
+
+ * ANSIColor.pm: Add "mistyped" as a stopword, required by the
+ latest aspell on Debian.
+
2011-07-20 Russ Allbery <rra@stanford.edu>
* ANSIColor.pm: Version 3.01 released.
- Term::ANSIColor version 3.01
+ Term::ANSIColor version 3.02
(A simple ANSI text attribute control module)
Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2005, 2006, 2007, 2009,
- 2010, 2011 Russ Allbery <rra@stanford.edu> and Zenin. This program is
- free software; you may redistribute it and/or modify it under the same
- terms as Perl itself.
+ 2010, 2011, 2012 Russ Allbery <rra@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@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.
+ I welcome bug reports and patches for this package at rra@stanford.edu
+ or via the CPAN bug tracker at <http://rt.cpan.org/>. 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.
BLURB
http://git.eyrie.org/?p=perl/ansicolor.git
+ For bug tracking, this package uses the CPAN bug tracker at:
+
+ https://rt.cpan.org/
+
+ Look for the Term-ANSIColor distribution.
+
THANKS
To Jon Lennox for looking at early versions of this module, providing
non-array references with stringification defined, and providing a test
case.
+ To Kent Fredric for the request for italic and the report of a terminal
+ emulator that supports it.
+
+ To Simon Wistow for reporting that Term::ANSIColor was inadvertantly
+ clobbering $@ when generating constant subs.
+
To Larry Wall, as always, for Perl.
#
# t/basic.t -- Test suite for the Term::ANSIColor Perl module.
#
-# Copyright 1997, 1998, 2000, 2001, 2002, 2005, 2006, 2009, 2010
+# Copyright 1997, 1998, 2000, 2001, 2002, 2005, 2006, 2009, 2010, 2012
# Russ Allbery <rra@stanford.edu>
#
# This program is free software; you may redistribute it and/or modify it
# under the same terms as Perl itself.
use strict;
-use Test::More tests => 51;
+use Test::More tests => 54;
BEGIN {
delete $ENV{ANSI_COLORS_DISABLED};
is (color ('on_bright_red'), "\e[101m", '...as is on bright red');
is ((ON_BRIGHT_RED "test"), "\e[101mtest\e[0m", '...and as a constant');
+# Test italic, which was added in 3.02.
+is (color ('italic'), "\e[3m", 'Italic is supported');
+is ((ITALIC 'test'), "\e[3mtest\e[0m", '...and as a constant');
+
# Test colored with 0 and EACHLINE.
$Term::ANSIColor::EACHLINE = "\n";
is (colored ('0', 'blue', 'bold'), "\e[34;1m0\e[0m",
eval { Term::ANSIColor::reset () };
like ($@, qr/^undefined subroutine \&Term::ANSIColor::reset called at /,
'Correct error from a lowercase attribute');
+
+# Ensure that we still get proper error reporting for unknown constants when
+# when colors are disabled.
+$ENV{ANSI_COLORS_DISABLED} = 1;
+eval { Term::ANSIColor::RSET () };
+like ($@, qr/^undefined subroutine \&Term::ANSIColor::RSET called at /,
+ 'Correct error from undefined attribute with disabled colors');
+delete $ENV{ANSI_COLORS_DISABLED};
--- /dev/null
+#!/usr/bin/perl -Tw
+#
+# t/eval.t -- Test suite for $@ preservation with constants.
+#
+# Copyright 2012 Russ Allbery <rra@stanford.edu>
+#
+# This program is free software; you may redistribute it and/or modify it
+# under the same terms as Perl itself.
+
+use strict;
+use Test::More tests => 5;
+
+BEGIN {
+ delete $ENV{ANSI_COLORS_DISABLED};
+ use_ok ('Term::ANSIColor', qw/:constants/);
+}
+
+# Ensure that using a constant doesn't leak anything in $@.
+is ((BOLD 'test'), "\e[1mtest", 'BOLD works');
+is ($@, '', '... and $@ is empty');
+
+# Store something in $@ and ensure it doesn't get clobbered.
+eval 'sub { syntax';
+is ((BLINK 'test'), "\e[5mtest", 'BLINK works after eval failure');
+isnt ($@, '', '... and $@ still contains something useful');