|
Color::Output - Module to give color to the output |
Color::Output - Module to give color to the output
With this module you can color the output. It will color the output on both Windows and on Unix/Linux. On Windows it uses by default Win32::Console (unless overwritten with some options), on Unix/Linux it uses ANSI by default.
This module allows you to do:
By default it will use ANSI-Colors on Linux/Unix and Win32::Console on windows.
However, you can change this behaviour by changing the value of several variables, more about that in the Vars-Section
chr(3) (by default)
All params are joined into 1 string.
Examples:
cprint ("\x033Blue text\x030\n");
cprint ("\0035Red text\n");
cprint ("The text is still red, ", chr(3) ,"7and now it is green.\x030\n");
Note:
The text-color is set to the default one when the program ends.
If the first param is an objet then this param is ignored (not being outputed).
chr(3) (by default)
Examples:
cprintf ("\x033This is a %s string\x030\n", "blue");
cprintf ("\0035%s text\n", "red");
cprintf ("The text is still %s, ". chr(3) ."7and now it is %s.\x030\n", "red", "green");
Note1:
If you call cprintf, then it runs sprintf and that result is printed with cprint.
However, I'm not sure wheter or not this is very safe.. so you might want to pay attention when you use it.
Example:
clear();
By default ANSI-Colors will be used on Linux/Unix and Win32::Console on Win32.
If you change this var to 1 then ANSI-Colors will be used,
If you set it to 2 then Win32::Console will be used.
Examples: examples/ANSI.pl and examples/W32.pl
chr(3) will be used.
Example: examples/symbol.pl
use Color::Output;
Color::Output::Init;
for (my($i)=0;$i<16;$i++) {
cprint("Color=$i". (" " x (15 - length($i))) ."\x03" . $i . "Example $0, color $i\x030\n");
}
This code is also added as an example (examples/colors.pl)
the Term::ANSIColor manpage, the Win32::Console manpage, the Win32::Console::ANSI manpage
Animator <Animator@CQ-Empires.com>
Copyright (c) 2003 Animator. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|
Color::Output - Module to give color to the output |