[pacman-dev] [PATCH 07/16] introduce colstr for colourizing

Andrew Gregory andrew.gregory.8 at gmail.com
Fri Mar 1 23:42:45 EST 2013


On 03/01/13 at 04:32pm, Simon Gomizelj wrote:
> colstr_t colstr will hold the colourizing agents.
> 
> Signed-off-by: Simon Gomizelj <simongmzlj at gmail.com>
> ---
>  src/pacman/conf.c | 36 ++++++++++++++++++++++++++++++++++++
>  src/pacman/conf.h |  7 +++++++
>  2 files changed, 43 insertions(+)
> 
> diff --git a/src/pacman/conf.c b/src/pacman/conf.c
> index dca6e3e..34b4199 100644
> --- a/src/pacman/conf.c
> +++ b/src/pacman/conf.c
> @@ -38,6 +38,40 @@
>  
>  /* global config variable */
>  config_t *config = NULL;
> +colstr_t colstr;

Why not add colstr as a member of config instead of adding another
global variable?

> +
> +#define NC            "\033[0m"
> +
> +#define BLACK         "\033[0;30m"
> +#define RED           "\033[0;31m"
> +#define GREEN         "\033[0;32m"
> +#define YELLOW        "\033[0;33m"
> +#define BLUE          "\033[0;34m"
> +#define MAGENTA       "\033[0;35m"
> +#define CYAN          "\033[0;36m"
> +#define WHITE         "\033[0;37m"
> +
> +#define BOLDBLACK     "\033[1;30m"
> +#define BOLDRED       "\033[1;31m"
> +#define BOLDGREEN     "\033[1;32m"
> +#define BOLDYELLOW    "\033[1;33m"
> +#define BOLDBLUE      "\033[1;34m"
> +#define BOLDMAGENTA   "\033[1;35m"
> +#define BOLDCYAN      "\033[1;36m"
> +#define BOLDWHITE     "\033[1;37m"
> +
> +static void init_colors(int colors)
> +{
> +	if(colors == PM_COLOR_ON) {
> +		colstr.colon = BOLDBLUE "::" BOLDWHITE;

Why add "::" here instead of making this a plain color like all of the
other members and adding "::" in colon_printf?

> +		colstr.title = BOLDWHITE;
> +		colstr.nc    = NC;
> +	} else {
> +		colstr.colon = "::";
> +		colstr.title = "";
> +		colstr.nc    = "";
> +	}
> +}
>  

apg


More information about the pacman-dev mailing list