###############################################################################
# V E R S I O N S
###############################################################################
-my $VERSION = '0.0.2';
+my $VERSION = '0.0.3';
# english only - NB 07.02.14
# NB 23.11.01
# - creation !
# G L O B A L E
###############################################################################
my ($NAME) = $0 =~ m#([^/]+)$#;
-my %BG = (
- 'black' => 40,
- 'red' => 41,
- 'green' => 42,
- 'yellow' => 43,
- 'blue' => 44,
- 'magenta' => 45,
- 'cyan' => 46,
- 'white' => 47,
- 'default' => 49,
-);
-
-my %FG = (
- 'black' => 30,
- 'red' => 31,
- 'green' => 32,
- 'yellow' => 33,
- 'blue' => 34,
- 'magenta' => 35,
- 'cyan' => 36,
- 'white' => 37,
- 'default' => 39,
-);
-
-my %EFFECT = (
- 'none' => 0,
- 'bold' => 1,
- 'pale' => 2,
- 'evidence' => 3,
- 'underline' => 4,
- 'blink' => 5,
- 'invert' => 7,
- 'cache' => 8,
- 'normal' => 22,
- 'no_evidence' => 23,
- 'no_souligne' => 24,
- 'no_underline' => 24,
- 'no_clignotant' => 25,
- 'no_blink' => 25,
- 'no_inverse' => 27,
- 'no_invert' => 27,
-);
###############################################################################
# V A L E U R P A R D E F A U T
###############################################################################
###############################################################################
# P R O G R A M M E P R I N C I P A L
###############################################################################
+use NB::Color qw/color %BG %FG %EFFECT/;
my $input = join('',@ARGV) || 'My Text';
if ($Opt{all}) {
printf "%21s", "$e ($e_num) | ";
- print in_color($input,{
+ print color($input,{
effect => $e,
num => $PRINT_CODE,
}),"\n";
printf "%17s", "$fg ($fg_num) | ";
- print in_color($input,{
+ print color($input,{
fg => $fg,
bg => $BG,
effect => $EFFECT,
printf "%17s", "$bg ($bg_num) | ";
- print in_color($input,{
+ print color($input,{
fg => $FG,
bg => $bg,
effect => $EFFECT,
exit 0;
}
-print in_color($input,{
+print color($input,{
fg => $FG,
bg => $BG,
effect => $EFFECT,
###############################################################################
# F O N C T I O N S
###############################################################################
-sub in_color {
-#------------------------------------------------------------------------------
-# NB 18.11.01
-#------------------------------------------------------------------------------
-my ($txt,$hparam) = @_;
-
- my $new = "";
- $hparam->{bg} ||= 'default';
- $hparam->{fg} ||= 'default';
- $hparam->{effect} ||= 'normal';
- #die $hparam->{num};
-
- if (!$hparam->{num} or $hparam->{num} == 2) {
-
- $new .=
- "\e["
- . $BG{$hparam->{bg}}
- . ";".$FG{$hparam->{fg}}
- . ";".$EFFECT{$hparam->{effect}}
- . "m".$txt
- . "\e[0m"
- ;
- $new .= " | " if $hparam->{num} == 2;
-
- }
-
- if ($hparam->{num}) {
-
- $new .=
- '\e['
- . $BG{$hparam->{bg}}
- . ";".$FG{$hparam->{fg}}
- . ";".$EFFECT{$hparam->{effect}}
- . "m".$txt
- . '\e[0m'
- ;
-
- }
-
- return $new;
-}
-
sub version {
#------------------------------------------------------------------------------
# Affiche la version