in reply to In Term::ANSIColor grey color is present or not.
# # 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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: In Term::ANSIColor grey color is present or not.
by soonix (Chancellor) on Apr 02, 2022 at 08:42 UTC |