The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Term::ANSIColor::Print - Create and/or print strings with ANSI color markup.

SYNOPSIS

Checkers

  use Term::ANSIColor::Print;

  my $string = Term::ANSIColor::Print->new();

  my $red    = $string->on_red('  ');
  my $yellow = $string->on_yellow('  ');

  my $red_pad    = Term::ANSIColor::Print->new( pad => $red );
  my $yellow_pad = Term::ANSIColor::Print->new( pad => $yellow );

  my $checkers_a = $red_pad->on_blue( map { $yellow } ( 0 .. 5 ) );
  my $checkers_b = $yellow_pad->on_blue( map { $red } ( 0 .. 5 ) );

  my $checker_board = Term::ANSIColor::Print->new(
      pad    => "\n$checkers_a\n",
      output => \*STDOUT,
      eol    => "\n",
  );

  $checker_board->normal( map { $checkers_b } ( 0 .. 4 ) );

HTML approximation of the output

                                
                                
                                
                                
                                
                                
                                
                                
                                

Old Glory

  use Term::ANSIColor::Print;

  my $string = Term::ANSIColor::Print->new();

  my $star  = $string->bold_white_on_blue('*');
  my $blue  = $string->on_blue(' ');

  my $redbar   = $string->on_red( ' ' x 15 );
  my $whitebar = $string->on_white( ' ' x 15 );

  my $blue_pad = Term::ANSIColor::Print->new( pad => $blue );
  my $star_pad = Term::ANSIColor::Print->new( pad => $star );

  my $starbar_a = $blue_pad->on_blue( map { $star } ( 0 .. 5 ) );
  my $starbar_b = $star_pad->on_blue( map { $blue } ( 0 .. 5 ) );

  my $old_glory = join "$starbar_b$whitebar\n", map { "$starbar_a$redbar\n" } ( 0 .. 2 );

  $redbar   = $string->on_red( ' ' x 26 );
  $whitebar = $string->on_white( ' ' x 26 );

  $old_glory .= join "\n", map { "$whitebar\n$redbar" } ( 0 .. 1 );

  print "$old_glory\n";

HTML approximation of the output

*   *   *   *   *   *                                          
  *   *   *   *   *                                            
*   *   *   *   *   *                                          
  *   *   *   *   *                                            
*   *   *   *   *   *                                          
                                                               
                                                               
                                                               
                                                               

DESCRIPTION

This is a natural language way of indicating how you want your strings to look.

METHODS

Methods are all dynamic. The methods you invoke are underscore separated keywords which you take from this lexicon:

  • black

  • blink + slow or rapid

  • blue

  • bold

  • conceal

  • cyan

  • dark

  • double

  • faint

  • green

  • grey

  • intensity

  • italic

  • light_black

  • magenta

  • negative

  • no + underline or blink

  • normal + foreground or background

  • on - prefixes background spec

  • positive

  • red

  • reset

  • reveal

  • underline

  • white

  • yellow

LIMITATIONS

Not all combinations or codes may be supported on your Terminal application.

This is alpha code and is likely to have bugs. I'm happy to hear about them.

AUTHOR

Dylan Doxey, <dylan.doxey@gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2009 by Dylan Doxey

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.