The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

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

SYNOPSIS

  use Term::ANSIColor::Print;

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

  my $string = Term::ANSIColor::Print->new(
      pad => $pad->on_dark_red(' '),
  );

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

  # concatenate padded with spaces on dark red background
  my $colorful_text = $string->green_on_dark_red(
      '',
      'one',
      $string->bold_underline_yellow_on_dark_cyan('two'),
      $string->white_on_dark_green('three'),
      'four',
      '',
  );

  # print to STDOUT
  $print->black_on_white( ' zero ' . $colorful_text . ' five ' );

  # HTML approximation
 zero   one  two   three  four   five 

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.