[pacman-dev] [PATCH 13/16] colourize -Qs/-Ss

Simon Gomizelj simongmzlj at gmail.com
Fri Mar 1 16:32:42 EST 2013


Signed-off-by: Simon Gomizelj <simongmzlj at gmail.com>
---
 src/pacman/conf.c    | 28 ++++++++++++++++++----------
 src/pacman/conf.h    |  4 ++++
 src/pacman/package.c | 13 +++++++------
 3 files changed, 29 insertions(+), 16 deletions(-)

diff --git a/src/pacman/conf.c b/src/pacman/conf.c
index de0df76..165f021 100644
--- a/src/pacman/conf.c
+++ b/src/pacman/conf.c
@@ -63,17 +63,25 @@ colstr_t colstr;
 static void init_colors(int colors)
 {
 	if(colors == PM_COLOR_ON) {
-		colstr.colon = BOLDBLUE "::" BOLDWHITE;
-		colstr.title = BOLDWHITE;
-		colstr.warn  = BOLDYELLOW;
-		colstr.err   = BOLDRED;
-		colstr.nc    = NC;
+		colstr.colon   = BOLDBLUE "::" BOLDWHITE;
+		colstr.title   = BOLDWHITE;
+		colstr.repo    = BOLDMAGENTA;
+		colstr.version = BOLDGREEN;
+		colstr.groups  = BOLDBLUE;
+		colstr.meta    = BOLDCYAN;
+		colstr.warn    = BOLDYELLOW;
+		colstr.err     = BOLDRED;
+		colstr.nc      = NC;
 	} else {
-		colstr.colon = "::";
-		colstr.title = "";
-		colstr.warn  = "",
-		colstr.err   = "",
-		colstr.nc    = "";
+		colstr.colon   = "::";
+		colstr.title   = "";
+		colstr.repo    = "";
+		colstr.version = "";
+		colstr.groups  = "";
+		colstr.meta    = "";
+		colstr.warn    = "";
+		colstr.err     = "";
+		colstr.nc      = "";
 	}
 }
 
diff --git a/src/pacman/conf.h b/src/pacman/conf.h
index 0b015ef..ec70c3c 100644
--- a/src/pacman/conf.h
+++ b/src/pacman/conf.h
@@ -103,6 +103,10 @@ typedef struct __config_t {
 typedef struct __colstr_t {
 	const char *colon;
 	const char *title;
+	const char *repo;
+	const char *version;
+	const char *groups;
+	const char *meta;
 	const char *warn;
 	const char *err;
 	const char *nc;
diff --git a/src/pacman/package.c b/src/pacman/package.c
index 1486f41..db2cf76 100644
--- a/src/pacman/package.c
+++ b/src/pacman/package.c
@@ -349,9 +349,9 @@ void print_installed(alpm_db_t *db_local, alpm_pkg_t *pkg)
 	if(lpkg) {
 		const char *lpkgver = alpm_pkg_get_version(lpkg);
 		if(strcmp(lpkgver, pkgver) == 0) {
-			printf(" [%s]", _("installed"));
+			printf(" %s[%s]%s", colstr.meta, _("installed"), colstr.nc);
 		} else {
-			printf(" [%s: %s]", _("installed"), lpkgver);
+			printf(" %s[%s: %s]%s", colstr.meta, _("installed"), lpkgver, colstr.nc);
 		}
 	}
 }
@@ -383,12 +383,13 @@ int dump_pkg_search(alpm_db_t *db, alpm_list_t *targets, alpm_db_t *installed_in
 		if(config->quiet) {
 			fputs(alpm_pkg_get_name(pkg), stdout);
 		} else {
-			printf("%s/%s %s", alpm_db_get_name(db),
-					alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
+			printf("%s%s/%s%s %s%s%s", colstr.repo, alpm_db_get_name(db),
+					colstr.title, alpm_pkg_get_name(pkg),
+					colstr.version, alpm_pkg_get_version(pkg), colstr.nc);
 
 			if((grp = alpm_pkg_get_groups(pkg)) != NULL) {
 				alpm_list_t *k;
-				fputs(" (", stdout);
+				printf(" %s(", colstr.groups);
 				for(k = grp; k; k = alpm_list_next(k)) {
 					const char *group = k->data;
 					fputs(group, stdout);
@@ -397,7 +398,7 @@ int dump_pkg_search(alpm_db_t *db, alpm_list_t *targets, alpm_db_t *installed_in
 						putchar(' ');
 					}
 				}
-				putchar(')');
+				printf(")%s", colstr.nc);
 			}
 
 			if (installed_in)
-- 
1.8.1.4



More information about the pacman-dev mailing list