diff options
author | Chris 'BinGOs' Williams <chris@bingosnet.co.uk> | 2011-07-21 11:52:47 +0100 |
---|---|---|
committer | Chris 'BinGOs' Williams <chris@bingosnet.co.uk> | 2011-07-21 12:44:53 +0100 |
commit | 5213914c3c1657d0a00ee5ddcb253e8ffa103f28 (patch) | |
tree | c24fa94c85ec876976c7cf70ca3dc91100cbefc8 /cpan | |
parent | 1ea085fc1217bcccd63fc6d8cc77d4547dbe84db (diff) | |
download | perl-5213914c3c1657d0a00ee5ddcb253e8ffa103f28.tar.gz |
Update Term-ANSIColor to CPAN version 3.01
[DELTA]
2011-07-20 Russ Allbery <rra@stanford.edu>
* ANSIColor.pm: Version 3.01 released.
* Makefile.PL: Change the DISTNAME to Term-ANSIColor.
* ANSIColor.pm (colored): Only interpret an initial array
reference as a list of colors, not any initial reference, allowing
the colored function to work properly on objects with
stringification defined. Thanks, Revilo Reegiles.
* t/stringify.t: New test for proper behavior with non-array
references in colored.
2011-03-13 Russ Allbery <rra@stanford.edu>
* ANSIColor.pm: Fix two syntax errors in the SYNOPSIS. Thanks,
Jan Hartung.
2010-10-08 Russ Allbery <rra@stanford.edu>
* ANSIColor.pm: Warn in the documentation that attributes are not
supported in and will not work with Perl formats.
2010-04-11 Russ Allbery <rra@stanford.edu>
* ANSIColor.pm: Update the URL for ECMA-048 in the documentation.
Diffstat (limited to 'cpan')
-rw-r--r-- | cpan/Term-ANSIColor/ANSIColor.pm | 32 | ||||
-rw-r--r-- | cpan/Term-ANSIColor/ChangeLog | 27 | ||||
-rw-r--r-- | cpan/Term-ANSIColor/README | 14 | ||||
-rw-r--r-- | cpan/Term-ANSIColor/t/stringify.t | 38 |
4 files changed, 95 insertions, 16 deletions
diff --git a/cpan/Term-ANSIColor/ANSIColor.pm b/cpan/Term-ANSIColor/ANSIColor.pm index 72b941f621..bc2fc7e483 100644 --- a/cpan/Term-ANSIColor/ANSIColor.pm +++ b/cpan/Term-ANSIColor/ANSIColor.pm @@ -1,7 +1,7 @@ # Term::ANSIColor -- Color screen output using ANSI escape sequences. # -# Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2005, 2006, 2008, 2009, 2010 -# Russ Allbery <rra@stanford.edu> and Zenin +# Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2005, 2006, 2008, 2009, 2010, +# 2011 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 @@ -17,7 +17,7 @@ package Term::ANSIColor; require 5.001; -$VERSION = '3.00'; +$VERSION = '3.01'; use strict; use vars qw($AUTOLOAD $AUTOLOCAL $AUTORESET @COLORLIST @COLORSTACK $EACHLINE @@ -226,7 +226,7 @@ sub uncolor { # piped to a pager or some other program). sub colored { my ($string, @codes); - if (ref $_[0]) { + if (ref ($_[0]) && ref ($_[0]) eq 'ARRAY') { @codes = @{+shift}; $string = join ('', @_); } else { @@ -296,8 +296,8 @@ grey ATTR print colored ("Yellow on magenta.", 'yellow on_magenta'), "\n"; print "This text is normal.\n"; print colored ['yellow on_magenta'], 'Yellow on magenta.', "\n"; - print colored ['red on_bright_yellow'] 'Red on bright yellow.', "\n"; - print colored ['bright_red on_black], 'Bright red on black.', "\n"; + print colored ['red on_bright_yellow'], 'Red on bright yellow.', "\n"; + print colored ['bright_red on_black'], 'Bright red on black.', "\n"; print "\n"; use Term::ANSIColor qw(uncolor); @@ -644,6 +644,16 @@ For easier debugging, you may prefer to always use the commas when not setting $Term::ANSIColor::AUTORESET or PUSHCOLOR/POPCOLOR so that you'll get a fatal compile error rather than a warning. +It's not possible to use this module to embed formatting and color +attributes using Perl formats. They replace the escape character with a +space (as documented in L<perlform(1)>), resulting in garbled output from +the unrecognized attribute. Even if there were a way around that problem, +the format doesn't know that the non-printing escape sequence is +zero-length and would incorrectly format the output. For formatted output +using color or other attributes, either use sprintf() instead or use +formline() and then add the color or other attributes after formatting and +before output. + =head1 NOTES The codes generated by this module are standard terminal control codes, @@ -695,7 +705,7 @@ currently supported by this module. =head1 SEE ALSO ECMA-048 is available on-line (at least at the time of this writing) at -L<http://www.ecma-international.org/publications/standards/ECMA-048.HTM>. +L<http://www.ecma-international.org/publications/standards/Ecma-048.htm>. ISO 6429 is available from ISO for a charge; the author of this module does not own a copy of it. Since the source material for ISO 6429 was @@ -714,10 +724,10 @@ Russ with input from Zenin. Russ Allbery now maintains this module. =head1 COPYRIGHT AND LICENSE -Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2005, 2006, 2008, 2009, 2010 -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 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. diff --git a/cpan/Term-ANSIColor/ChangeLog b/cpan/Term-ANSIColor/ChangeLog index 589496b1a6..77de255cd2 100644 --- a/cpan/Term-ANSIColor/ChangeLog +++ b/cpan/Term-ANSIColor/ChangeLog @@ -1,3 +1,30 @@ +2011-07-20 Russ Allbery <rra@stanford.edu> + + * ANSIColor.pm: Version 3.01 released. + + * Makefile.PL: Change the DISTNAME to Term-ANSIColor. + + * ANSIColor.pm (colored): Only interpret an initial array + reference as a list of colors, not any initial reference, allowing + the colored function to work properly on objects with + stringification defined. Thanks, Revilo Reegiles. + * t/stringify.t: New test for proper behavior with non-array + references in colored. + +2011-03-13 Russ Allbery <rra@stanford.edu> + + * ANSIColor.pm: Fix two syntax errors in the SYNOPSIS. Thanks, + Jan Hartung. + +2010-10-08 Russ Allbery <rra@stanford.edu> + + * ANSIColor.pm: Warn in the documentation that attributes are not + supported in and will not work with Perl formats. + +2010-04-11 Russ Allbery <rra@stanford.edu> + + * ANSIColor.pm: Update the URL for ECMA-048 in the documentation. + 2010-01-24 Russ Allbery <rra@stanford.edu> * ANSIColor.pm: Version 3.00 released. diff --git a/cpan/Term-ANSIColor/README b/cpan/Term-ANSIColor/README index ff575a107d..051c7c37e4 100644 --- a/cpan/Term-ANSIColor/README +++ b/cpan/Term-ANSIColor/README @@ -1,10 +1,10 @@ - Term::ANSIColor version 3.00 + Term::ANSIColor version 3.01 (A simple ANSI text attribute control module) - Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2005, 2006, 2007, 2009 - 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, 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. 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 @@ -155,4 +155,8 @@ THANKS To Jakob Ilves for sixteen-color support and the initial documentation of bright color issues. + To Revilo Reegiles for reporting problems with the colored function and + non-array references with stringification defined, and providing a test + case. + To Larry Wall, as always, for Perl. diff --git a/cpan/Term-ANSIColor/t/stringify.t b/cpan/Term-ANSIColor/t/stringify.t new file mode 100644 index 0000000000..a8eb44876f --- /dev/null +++ b/cpan/Term-ANSIColor/t/stringify.t @@ -0,0 +1,38 @@ +#!/usr/bin/perl -Tw +# +# t/stringify.t -- Test suite for stringify interaction. +# +# Copyright 2011 Revilo Reegiles +# Copyright 2011 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. + +# Create a dummy class that implements stringification. +package Test::Stringify; +use overload '""' => 'stringify'; +sub new { return bless {} } +sub stringify { return "Foo Bar\n" } +package main; + +use strict; +use Test::More tests => 6; + +BEGIN { + delete $ENV{ANSI_COLORS_DISABLED}; + use_ok ('Term::ANSIColor', + qw/:pushpop color colored uncolor colorstrip colorvalid/); +} + +is (colored ([ 'blue', 'bold' ], 'testing'), "\e[34;1mtesting\e[0m", + 'colored with an array reference'); +is (colored ("ok\n", 'bold blue'), "\e[1;34mok\n\e[0m", + 'colored with a following string'); +my $test = Test::Stringify->new; +is (colored ($test . "", 'bold blue'), "\e[1;34mFoo Bar\n\e[0m", + 'colored with forced stringification'); +is (colored ($test, 'bold blue'), "\e[1;34mFoo Bar\n\e[0m", + 'colored with a non-array reference'); +my %foo = (foo => 'bar'); +like (colored (\%foo, 'bold blue'), qr/\e\[1;34mHASH\(.*\)\e\[0m/, + 'colored with a hash reference'); |