logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Badger::Rainbow - colour functionality

Author

       Andy Wardley <http://wardley.org/>

Description

       This module implements colour-related functionality.  It is currently only used for debugging purposes
       but may be extended in the future.

Exportable Items

ANSI_escape($code,$line1,$line2,...)
       This function applies an ANSI escape code to each line of text, with the effect of colouring output on
       compatible terminals.

           use Badger::Rainbow 'ANSI_escape';
           print ANSI_escape(31, 'Hello World');     # 31 is red

   strip_ANSI_escapes($text)
       This function removes any ANSI escapes from the text passed as an argument.

   ANSI
       This is an export hook which allows you to import subroutines which apply the correct ANSI escape codes
       to render text in colour on compatible terminals.

           use Badger::Rainbox ANSI => 'red green blue';

           print red("This is red");
           print green("This is green");
           print blue("This is blue");

       Available colours are: "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white" and "grey".
       The "bold" and "dark" styles can also be specified.

           use Badger::Rainbox ANSI => 'dark bold red green blue';

           print bold red "Hello World\n";
           print dark blue "Hello Badger\n";

       Colours and styles can be specified as a single whitespace-delimited string or as a reference to a list
       of individual items.

           use Badger::Rainbox ANSI => 'red green blue';
           use Badger::Rainbox ANSI => ['red', 'green', 'blue'];

       All ANSI colours can be loaded by specifying "all".

           use Badger::Rainbox ANSI => 'all';

Name

       Badger::Rainbow - colour functionality

Synopsis

           use Badger::Rainbow ANSI => 'red green blue';

           print red("This is red");
           print green("This is green");
           print blue("This is blue");

See Also