I don’t use this module, but just looking through the documentation, it seems you have to specify a shade of grey in the range grey0 .. grey23. For example, print colored(['grey12'], "Text on grey color\n"); should work.
Hope that helps,
| [reply] [d/l] [select] |
| [reply] |
Ok, I dusted off my old Cygwin terminal and got Term::ANSIColor working. grey0 looks the same as black, but prints fine with no error message. grey with no number gives the error message you reported first.
I don’t know what to suggest. Maybe if you detail your setup (OS, Perl version, Term::ANSIColor version, terminal type) some of the other monks will be able to shed some light.
Cheers,
| [reply] [d/l] [select] |
$ perl -MTerm::ANSIColor -e 'print color("grey0"), "foo\n", color("res
+et")'
foo
$
| [reply] [d/l] |
Hello,
well technically speaking grey is not a color but a shade.. Anyway tell us if you are on windows because it vary a lot between old and earlier versions. If on old windows look at ansicon which enables proper ansi escape on neanderthalian cmd.exe
Here you have all available ansi colors by category: Grey0 is in the 256Colors category and does not work in older cmd.exe.
If you import :constants256 then you can try using the constant GREY0
The following works for me
perl -e "use Term::ANSIColor qw(colored); print colored(['grey0'],'gre
+y0 text on default background',$/);"
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
| [reply] [d/l] [select] |
Keep in mind, this is sort of what's happening in the background. This function takes a three-digit hexadecimal number as the first argument. The first digit is the style, second digit is the bg color and the third digit is the text color. The bg color goes from 0 to 7, I think. Then the text color goes from 0 to F. cprintf(0x07F, 'Hello World') will print on grey background using white letters. Why do you insist using color names instead of numbers?
#
# Usage: cprintf(COLOR, TEXT, [ARGS])
#
sub cprintf
{
@_ > 1 or return;
my $E = shift;
my $A = ($E & 0xF00) >> 8; # Get font style
my $B = ($E & 0x0F0) >> 4; # Get background color
my $C = ($E & 0x00F); # Get text color
# Linux/OSX cprintf solution using ANSI codes:
$E = '2648375vnrptosqu'; # Color code translation table
$E = "\x1B[" . (vec($E, $C, 8) - 20) . "m\x1B[" . (vec($E, $B, 8) -
+10) . 'm';
if ($A & 1) { $E .= "\x1B[05m"; } # BLINKING
if ($A & 2) { $E .= "\x1B[04m"; } # UNDERLINE
if ($A & 4) { $E .= "\x1B[03m"; } # ITALIC
if ($A & 8) { $E .= "\x1B[01m"; } # BOLD
print $E; # Set color
printf(@_);
print "\x1B[0m"; # Reset color
return;
}
| [reply] [d/l] |
On a system with 8 colors (don't know how seldom they are, but probably not extinct) your example would depict what I know as "east frisian war flag (white eagle on white background)". And there seems to be difficulty to programmatically find out how many colors are available (or at least distinguish between 8 and 16).
| [reply] |