mirror of
https://github.com/moparisthebest/pacman
synced 2025-03-01 09:51:50 -05:00
pacsearch: colors are portable (ANSI) and have natural variable names
Signed-off-by: Pierre Neidhardt <ambrevar@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
15f4144e12
commit
fe19a0c58d
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
use Term::ANSIColor;
|
||||||
|
|
||||||
my $myname = 'pacsearch';
|
my $myname = 'pacsearch';
|
||||||
my $myver = '@PACKAGE_VERSION@';
|
my $myver = '@PACKAGE_VERSION@';
|
||||||
@ -55,15 +56,15 @@ if ($ARGV[0] eq "--version" || $ARGV[0] eq "-V") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# define our colors to use when printing
|
# define our colors to use when printing
|
||||||
my $CLR1 = "\e[0;34m";
|
my($BLUE, $CYAN, $GREEN, $MAGENTA, $RED, $YELLOW, $BOLD, $RESET);
|
||||||
my $CLR2 = "\e[0;32m";
|
$BLUE = color('blue');
|
||||||
my $CLR3 = "\e[0;35m";
|
$CYAN = color('cyan');
|
||||||
my $CLR4 = "\e[0;36m";
|
$GREEN = color('green');
|
||||||
my $CLR5 = "\e[0;31m";
|
$MAGENTA = color('magenta');
|
||||||
my $CLR6 = "\e[0;33m";
|
$RED = color('red');
|
||||||
my $CLR7 = "\e[1;36m";
|
$YELLOW = color('yellow');
|
||||||
my $INST = "\e[1;31m";
|
$BOLD = color('bold');
|
||||||
my $BASE = "\e[0m";
|
$RESET = color('reset');
|
||||||
|
|
||||||
# localization
|
# localization
|
||||||
my $LC_INSTALLED = `gettext pacman installed`;
|
my $LC_INSTALLED = `gettext pacman installed`;
|
||||||
@ -72,17 +73,17 @@ my $LC_INSTALLED = `gettext pacman installed`;
|
|||||||
sub to_color {
|
sub to_color {
|
||||||
my $line = shift;
|
my $line = shift;
|
||||||
# get the installed text colored first
|
# get the installed text colored first
|
||||||
$line =~ s/(\[.*\]$)/$INST$1$BASE/;
|
$line =~ s/(\[.*\]$)/$CYAN$1$RESET/;
|
||||||
# and now the repo and dealings
|
# and now the repo and dealings
|
||||||
$line =~ s/(^core\/.*)/$CLR1$1$BASE/;
|
$line =~ s/(^core\/.*)/$MAGENTA$1$RESET/;
|
||||||
$line =~ s/(^extra\/.*)/$CLR2$1$BASE/;
|
$line =~ s/(^extra\/.*)/$MAGENTA$1$RESET/;
|
||||||
$line =~ s/(^community\/.*)/$CLR3$1$BASE/;
|
$line =~ s/(^community\/.*)/$MAGENTA$1$RESET/;
|
||||||
$line =~ s/(^testing\/.*)/$CLR4$1$BASE/;
|
$line =~ s/(^testing\/.*)/$MAGENTA$1$RESET/;
|
||||||
$line =~ s/(^community-testing\/.*)/$CLR5$1$BASE/;
|
$line =~ s/(^community-testing\/.*)/$MAGENTA$1$RESET/;
|
||||||
$line =~ s/(^multilib\/.*)/$CLR6$1$BASE/;
|
$line =~ s/(^multilib\/.*)/$MAGENTA$1$RESET/;
|
||||||
$line =~ s/(^local\/.*)/$CLR7$1$BASE/;
|
$line =~ s/(^local\/.*)/$RED$1$RESET/;
|
||||||
# any other unknown repository
|
# any other unknown repository
|
||||||
$line =~ s/(^[\w-]*\/.*)/$CLR6$1$BASE/;
|
$line =~ s/(^[\w-]*\/.*)/$RED$1$RESET/;
|
||||||
return $line;
|
return $line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user