tadzik/perl6-Term-ANSIColor/lib/Term/ANSIColor
perl6-Term-ANSIColor src
NAME
Term::ANSIColor - Color screen output using ANSI escape sequences
SYNOPSIS
use Term::ANSIColor;
say color('bold'), "this is in bold", color('reset');
say colored('underline red on_green', 'what a lovely colours!');
say BOLD, 'good to be fat!', BOLD_OFF;
say 'ok' if colorvalid('magenta', 'on_black', 'inverse');
say '\e[36m is ', uncolor('\e36m');
say colorstrip("\e[1mThis is bold\e[0m");
DESCRIPTION
Term::ANSIColor provides an interface for using colored output
in terminals. The following functions are available:
(head2) C
Given a string with color names, the output produced by color()
sets the terminal output so the text printed after it will be colored
as specified. The following color names are recognised:
reset bold underline inverse black red green yellow blue
magenta cyan white default on_black on_red on_green on_yellow
on_blue on_magenta on_cyan on_white on_default
The on_* family of colors correspond to the background colors.
(head2) C
colored() is similar to color() . It takes two Str arguments,
where the first is the colors to be used, and the second is the string
to be colored. The reset sequence is automagically placed after
the string.
(head2) C
colorvalid() gets an array of color specifications (like those
passed to color() ) and returns true if all of them are valid,
false otherwise.
(head2) C
colorstrip , given a string, removes all the escape sequences
in it, leaving the plain text without effects.
(head2) C
Given escape sequences, uncolor() returns a string with readable
color names. E.g. passing "\e[36;44m" will result in "cyan on_blue".
Constants
Term::ANSIColor provides constants which are just strings of
appropriate escape sequences. The following constants are available:
RESET BOLD UNDERLINE INVERSE BOLD_OFF UNDERLINE_OFF INVERSE_OFF