FreeBSD Manual Pages
Text::Colorizer(3) User Contributed Perl Documentation Text::Colorizer(3) NAME Text::Colorizer - Create colored text from text and color descrition. An ANSI to HTML tranformation is provided SYNOPSIS my $c= Text::Colorizer->new ( NAME => '' , INTERACTION => { INFO => sub {print @_}, WARN => \&Carp::carp, DIE => \&Carp::confess, } FORMAT => 'HTML' | 'ANSI' |'ASCII', DEFAULT_COLOR => 'bright_white on_black', COLOR_NAMES => { HTML => { white => "color:#888;", black => "color:#000;", ... } ANSI => ... ASCII => ... } ) ; # or my $c= Text::Colorizer->new() ; my $colored_text = $c->color ( 'red on_black' => 'string', $color => [... many strings..], 'user_defined_color_name' => 'string' ) ; DESCRIPTION This module defined methods to produce colored html from ANSI color description. The generated code use pre tags. The generated HTML can be embeded in your pod documentation. DOCUMENTATION Valid colors: black red green yellow blue magenta cyan white bright_black bright_red bright_green bright_yellow bright_blue bright_magenta bright_cyan bright_white on_black on_red on_green on yellow on_blue on_magenta on_cyan on_white on_bright_black on_bright_red on_bright_green on_bright_yellow on_bright_blue on_bright_magenta on_bright_cyan on_bright_white Default background color bright_white on_black SUBROUTINES/METHODS new(NAMED_ARGUMENTS) Create a Text::Colorizer object. my $c= Text::Colorizer->new() ; Arguments - a list of pairs - Option => Value o NAME - String - Name of the Data::HexDump::Range object, set to 'Anonymous' by default o INTERACTION - Hash reference - Set of subs that are used to display information to the user Useful if you use Data::HexDump::Range in an application without terminal. o VERBOSE - Boolean - Display information about the creation of the object. Default is false o JOIN - String - string used to join colored elements. Default is an empty string. o JOIN_FLAT - String - string used to join colored elements passed in array references. Default is an empty string. o FORMAT - String - format of the dump string generated by Data::HexDump::Range. Default is ANSI which allows for colors. Other formats are 'ASCII' and 'HTML'. o DEFAULT_COLOR - the color used if no color is defined DEFAULT_COLOR => {ANSI => 'bright_white', HTML => 'color:#aaa; '} ; o COLOR - String 'bw' or 'cycle'. Ranges for which no color has been defined, in 'ANSI' or 'HTML' format mode, will be rendered in black and white or with a color picked from a cyclic color list. Default is 'bw'. o COLOR_NAMES - A hash reference or a file name { HTML => { white => "color:#888;", black => "color:#000;", ... } ANSI => ... ASCII => ... } Returns - Text::Colorizer Exceptions - Dies if the color description are not valid Setup Helper sub called by new. This is a private sub. CheckOptionNames Verifies the named options passed to the members of this class. Calls {INTERACTION}{DIE} in case of error. This shall not be used directly. get_colors( ) Returns the colors defined in the object my $colors = $c->get_colors( ) ; Arguments - None Returns - A hash reference Exceptions - None set_colors(\%colors) Copies my %colors = ( HTML => { white => "style='color:#888;'", black => "style='color:#000;'", ... bright_white => "style='color:#fff;'", bright_black => "style='color:#000;'", bright_green => "style='color:#0f0;'", ... } ) ; $c->set_color(\%colors) ; Arguments o \%colors - A hash reference Returns - Nothing Exceptions - dies if the color definitions are invalid [P] flatten($scalar || \@array) Transforms array references to a flat list Arguments - o $scalar - Returns - a lsit of scalars color($color_name, $text, $color_name, \@many_text_strings, ...) ; Returns colored text. according to the object setting. Default is HTML color coded. my $colored_text = $c->color ( 'red on_black' => 'string', $color => [... many strings..] 'user_defined_color_name' => 'string' ) ; Arguments - A list of colors and text pairs o $color - o $text - Returns - A single string Exceptions - Dies if the color is invalid color_all($color, $string, \@many_text_strings, ...) Uses a single color to colorize all the strings my $colored_text = $c->color_all($color, $string, \@many_text_strings, ...) ; Arguments o $xxx - Returns - Nothing Exceptions color_with(\%color_definitions, 'color' => 'text', $color => \@many_text_strings, ...) ; Colors a text, temporarely overridding the colors defined in the object. my %colors = { HTML => { white => "style='color:#888;'", black => "style='color:#000;'", ... bright_white => "style='color:#fff;'", bright_black => "style='color:#000;'", bright_green => "style='color:#0f0;'", ... } }, my $colored_text = $c->color ( 'red on_black' => 'string', 'blue on_yellow' => [... many strings..] 'user_defined_color_name' => 'string' ) ; Arguments o $ - o $color - o $xxx - Returns - Nothing Exceptions - Dies if any argument is invalid color_all_with($temporary_colors, $color, $text | \@many_text_string, ...) ; Uses a single color to colorize all the strings, using a temporary color definition my $temporary_colors = { HTML => { white => "style='color:#888;'", black => "style='color:#000;'", ... bright_white => "style='color:#fff;'", bright_black => "style='color:#000;'", bright_green => "style='color:#0f0;'", ... } }, my $colored_text = $c->color_all_with($temporary_colors, $color, 'string', [... many strings..], ...) ; Arguments o $xxx - Returns - A colorized string Exceptions Dies if invalid input is received BUGS AND LIMITATIONS None so far. AUTHOR Nadim ibn hamouda el Khemir CPAN ID: NKH mailto: nadim@cpan.org COPYRIGHT AND LICENSE Copyright 2010 Nadim Khemir. This program is free software; you can redistribute it and/or modify it under the terms of either: o the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or o the Artistic License version 2.0. SUPPORT You can find documentation for this module with the perldoc command. perldoc Text::Colorizer You can also look for information at: o AnnoCPAN: Annotated CPAN documentation <http://annocpan.org/dist/Color::ANSI-ToHTML> o RT: CPAN's request tracker Please report any bugs or feature requests to L <bug-Color::ANSI-tohtml@rt.cpan.org>. We will be notified, and then you'll automatically be notified of progress on your bug as we make changes. o Search CPAN <http://search.cpan.org/dist/Color::ANSI-ToHTML> SEE ALSO "HTML::FromANSI first" perl v5.24.1 2017-07-02 Text::Colorizer(3)
NAME | SYNOPSIS | DESCRIPTION | DOCUMENTATION | SUBROUTINES/METHODS | BUGS AND LIMITATIONS | AUTHOR | COPYRIGHT AND LICENSE | SUPPORT | SEE ALSO
Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=Text::Colorizer&sektion=3&manpath=FreeBSD+12.0-RELEASE+and+Ports>