From: Rafael Garcia-Suarez Date: Mon, 22 Aug 2005 13:41:10 +0000 (+0000) Subject: Upgrade to Term::ANSIColor 1.10 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=51da1d85ebd387728f88fa79405a8e8eed318078;p=p5sagit%2Fp5-mst-13.2.git Upgrade to Term::ANSIColor 1.10 p4raw-id: //depot/perl@25318 --- diff --git a/lib/Term/ANSIColor.pm b/lib/Term/ANSIColor.pm index 68955ce..ef27ae9 100644 --- a/lib/Term/ANSIColor.pm +++ b/lib/Term/ANSIColor.pm @@ -1,8 +1,8 @@ # 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 and Zenin +# Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2005 +# by Russ Allbery and Zenin # # This program is free software; you may redistribute it and/or modify it # under the same terms as Perl itself. @@ -34,7 +34,7 @@ Exporter::export_ok_tags ('constants'); # 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 @@ -182,8 +182,9 @@ sub colored { 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"; } @@ -465,7 +466,7 @@ with input from Zenin. Russ Allbery now maintains this module. =head1 COPYRIGHT AND LICENSE Copyright 1996, 1997, 1998, 2000, 2001, 2002 Russ Allbery -and Zenin . 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 diff --git a/lib/Term/ANSIColor/ChangeLog b/lib/Term/ANSIColor/ChangeLog index c98596e..6012ee1 100644 --- a/lib/Term/ANSIColor/ChangeLog +++ b/lib/Term/ANSIColor/ChangeLog @@ -1,3 +1,17 @@ +2005-08-21 Russ Allbery + + * 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 * ANSIColor.pm: Version 1.09 released. diff --git a/lib/Term/ANSIColor/README b/lib/Term/ANSIColor/README index 016df9f..443c499 100644 --- a/lib/Term/ANSIColor/README +++ b/lib/Term/ANSIColor/README @@ -1,17 +1,15 @@ - 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 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 Russ Allbery + 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 @@ -46,7 +44,6 @@ INTRODUCTION 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 @@ -65,7 +62,6 @@ INSTALLATION 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 @@ -96,4 +92,10 @@ THANKS 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. diff --git a/lib/Term/ANSIColor/test.pl b/lib/Term/ANSIColor/test.pl index 123a353..ddf34df 100755 --- a/lib/Term/ANSIColor/test.pl +++ b/lib/Term/ANSIColor/test.pl @@ -1,26 +1,25 @@ #!/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") { @@ -114,3 +113,24 @@ if (DARK "testing" eq "\e[2mtesting\e[0m") { } 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"; +}