# Term::ANSIColor -- Color screen output using ANSI escape sequences.
-# $Id: ANSIColor.pm,v 1.9 2004/12/04 01:29:12 eagle Exp $
+# $Id: ANSIColor.pm,v 1.10 2005/08/21 18:31:58 eagle Exp $
#
-# Copyright 1996, 1997, 1998, 2000, 2001, 2002
-# by Russ Allbery <rra@stanford.edu> and Zenin <zenin@bawdycaste.com>
+# Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2005
+# by 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.
# Don't use the CVS revision as the version, since this module is also in Perl
# core and too many things could munge CVS magic revision strings.
-$VERSION = 1.09;
+$VERSION = '1.10';
##############################################################################
# Internal data structures
if (defined $EACHLINE) {
my $attr = color (@codes);
join '',
- map { $_ && $_ ne $EACHLINE ? $attr . $_ . "\e[0m" : $_ }
- split (/(\Q$EACHLINE\E)/, $string);
+ map { $_ ne $EACHLINE ? $attr . $_ . "\e[0m" : $_ }
+ grep { length ($_) > 0 }
+ split (/(\Q$EACHLINE\E)/, $string);
} else {
color (@codes) . $string . "\e[0m";
}
=head1 COPYRIGHT AND LICENSE
Copyright 1996, 1997, 1998, 2000, 2001, 2002 Russ Allbery <rra@stanford.edu>
-and Zenin <zenin@bawdycaste.org>. This program is free software; you may
-redistribute it and/or modify it under the same terms as Perl itself.
+and Zenin. This program is free software; you may redistribute it and/or
+modify it under the same terms as Perl itself.
=cut
+2005-08-21 Russ Allbery <rra@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@stanford.edu>
* ANSIColor.pm: Version 1.09 released.
- Term::ANSIColor version 1.09
+ Term::ANSIColor version 1.10
(A simple ANSI text attribute control module)
- Copyright 1996, 1997, 1998, 2000, 2001, 2002
- Russ Allbery <rra@stanford.edu> and Zenin <zenin@bawdycaste.org>. 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 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.
-
INTRODUCTION
This module grew out of a thread on comp.lang.perl.misc where several 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
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
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.
#!/usr/bin/perl
-# $Id: test.pl,v 1.4 2004/02/20 21:50:10 eagle Exp $
+# $Id: test.pl,v 1.5 2005/08/21 18:31:58 eagle 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..13\n" }
+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") {
} 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";
+}