On 07/03/13 01:54, Allan McRae wrote:
> From: Simon Gomizelj <[email protected]>
> 
> Signed-off-by: Simon Gomizelj <[email protected]>
> ---
> 
> For review...
> 
>  src/pacman/conf.c    | 28 ++++++++++++++++++----------
>  src/pacman/conf.h    |  4 ++++
>  src/pacman/package.c | 27 +++++++++++++++++----------
>  src/pacman/util.c    |  8 ++++----
>  4 files changed, 43 insertions(+), 24 deletions(-)
> 
> diff --git a/src/pacman/conf.c b/src/pacman/conf.c
> index f488234..7ab8ec6 100644
> --- a/src/pacman/conf.c
> +++ b/src/pacman/conf.c
> @@ -62,11 +62,15 @@ config_t *config = NULL;
>  void enable_colors(int colors)
>  {
>       if(colors == PM_COLOR_ON) {
> -             config->colstr.colon = BOLDBLUE "::" BOLDWHITE " ";
> -             config->colstr.title = BOLDWHITE;
> -             config->colstr.warn  = BOLDYELLOW;
> -             config->colstr.err   = BOLDRED;
> -             config->colstr.nc    = NC;
> +             config->colstr.colon   = BOLDBLUE "::" BOLDWHITE " ";
> +             config->colstr.title   = BOLDWHITE;
> +             config->colstr.repo    = BOLDMAGENTA;
> +             config->colstr.version = BOLDGREEN;
> +             config->colstr.groups  = BOLDBLUE;
> +             config->colstr.meta    = BOLDCYAN;
> +             config->colstr.warn    = BOLDYELLOW;
> +             config->colstr.err     = BOLDRED;
> +             config->colstr.nc      = NC;

There is a lot of churn going on here over the patches.  Just add these
all at the start in the "introduce colstr for colourizing" patch.  All
the colours are defined then anyway.

>       }
>  }
>  
> @@ -91,11 +95,15 @@ config_t *config_new(void)
>               newconfig->remotefilesiglevel = ALPM_SIG_USE_DEFAULT;
>       }
>  
> -     newconfig->colstr.colon = ":: ";
> -     newconfig->colstr.title = "";
> -     newconfig->colstr.warn  = "",
> -     newconfig->colstr.err   = "",
> -     newconfig->colstr.nc    = "";
> +     newconfig->colstr.colon   = ":: ";
> +     newconfig->colstr.title   = "";
> +     newconfig->colstr.repo    = "";
> +     newconfig->colstr.version = "";
> +     newconfig->colstr.groups  = "";
> +     newconfig->colstr.meta    = "";
> +     newconfig->colstr.warn    = "";
> +     newconfig->colstr.err     = "";
> +     newconfig->colstr.nc      = "";

As above.

>  
>       return newconfig;
>  }
> diff --git a/src/pacman/conf.h b/src/pacman/conf.h
> index 18bfb02..d2702ed 100644
> --- a/src/pacman/conf.h
> +++ b/src/pacman/conf.h
> @@ -25,6 +25,10 @@
>  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 7deb3db..2abf39e 100644
> --- a/src/pacman/package.c
> +++ b/src/pacman/package.c
> @@ -167,13 +167,16 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra)
>  

-Qs/-Ss stuff here...  accidental merge?

(Incidentally, -Qs/-Ss is too coloured for me...  That might force me to
allow colours to be configured in the future)

>       size = humanize_size(alpm_pkg_get_size(pkg), 'K', 2, &label);
>       if(from == ALPM_PKG_FROM_SYNCDB) {
> -             printf(_("Download Size  : %6.2f %s\n"), size, label);
> +             printf("%s%s%s %6.2f %s\n", config->colstr.title, _("Download 
> Size  :"),

(as an aside... we should do something with the alignment here to stop
relying on translators to do it for us).

> +                     config->colstr.nc, size, label);
>       } else if(from == ALPM_PKG_FROM_FILE) {
> -             printf(_("Compressed Size: %6.2f %s\n"), size, label);
> +             printf("%s%s%s %6.2f %s\n", config->colstr.title, _("Compressed 
> Size:"),
> +                     config->colstr.nc, size, label);
>       }
>  
>       size = humanize_size(alpm_pkg_get_isize(pkg), 'K', 2, &label);
> -     printf(_("Installed Size : %6.2f %s\n"), size, label);
> +     printf("%s%s%s %6.2f %s\n", config->colstr.title, _("Installed Size :"),
> +                     config->colstr.nc, size, label);
>  
>       string_display(_("Packager       :"), alpm_pkg_get_packager(pkg), cols);
>       string_display(_("Build Date     :"), bdatestr, cols);
> @@ -267,7 +270,8 @@ void dump_pkg_backups(alpm_pkg_t *pkg)
>  {
>       alpm_list_t *i;
>       const char *root = alpm_option_get_root(config->handle);
> -     printf(_("Backup Files:\n"));
> +     printf("%s%s%s", config->colstr.title, _("Backup Files:\n"),
> +                              config->colstr.nc);
>       if(alpm_pkg_get_backup(pkg)) {
>               /* package has backup files, so print them */
>               for(i = alpm_pkg_get_backup(pkg); i; i = alpm_list_next(i)) {
> @@ -348,10 +352,11 @@ void print_installed(alpm_db_t *db_local, alpm_pkg_t 
> *pkg)
>       alpm_pkg_t *lpkg = alpm_db_get_pkg(db_local, pkgname);
>       if(lpkg) {
>               const char *lpkgver = alpm_pkg_get_version(lpkg);
> +             const colstr_t *colstr = &config->colstr;
>               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);
>               }
>       }
>  }
> @@ -362,6 +367,7 @@ int dump_pkg_search(alpm_db_t *db, alpm_list_t *targets, 
> alpm_db_t *installed_in
>       int freelist = 0;
>       alpm_list_t *i, *searchlist;
>       unsigned short cols;
> +     const colstr_t *colstr = &config->colstr;
>  
>       /* if we have a targets list, search for packages matching it */
>       if(targets) {
> @@ -383,12 +389,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 +404,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) {
> diff --git a/src/pacman/util.c b/src/pacman/util.c
> index 0b1b7b7..b0f4918 100644
> --- a/src/pacman/util.c
> +++ b/src/pacman/util.c
> @@ -427,7 +427,7 @@ static size_t string_length(const char *s)
>  void string_display(const char *title, const char *string, unsigned short 
> cols)
>  {
>       if(title) {
> -             printf("%s ", title);
> +             printf("%s%s%s ", config->colstr.title, title, 
> config->colstr.nc);
>       }
>       if(string == NULL || string[0] == '\0') {
>               printf(_("None"));
> @@ -620,7 +620,7 @@ void list_display(const char *title, const alpm_list_t 
> *list,
>  
>       if(title) {
>               len = string_length(title) + 1;
> -             printf("%s ", title);
> +             printf("%s%s%s ", config->colstr.title, title, 
> config->colstr.nc);
>       }
>  
>       if(!list) {
> @@ -660,7 +660,7 @@ void list_display_linebreak(const char *title, const 
> alpm_list_t *list,
>  
>       if(title) {
>               len = (unsigned short)string_length(title) + 1;
> -             printf("%s ", title);
> +             printf("%s%s%s ", config->colstr.title, title, 
> config->colstr.nc);
>       }
>  
>       if(!list) {
> @@ -1502,7 +1502,7 @@ static int question(short preset, const char *format, 
> va_list args)
>               fprintf(stream, " %s ", _("[y/N]"));
>       }
>  
> -     fputs(colstr.nc, stream);
> +     fputs(config->colstr.nc, stream);

Huh...  looks like a bad rebase or something...

>       fflush(stream);
>  
>       if(config->noconfirm) {
> 


Reply via email to