index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | src/pacman/conf.c | 48 |
diff --git a/src/pacman/conf.c b/src/pacman/conf.c index dca6e3e1..815df95f 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -39,6 +39,43 @@ /* global config variable */ config_t *config = NULL; +#define NOCOLOR "\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" + +void enable_colors(int colors) +{ + colstr_t *colstr = &config->colstr; + + if(colors == PM_COLOR_ON) { + 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->nocolor = NOCOLOR; + } +} + config_t *config_new(void) { config_t *newconfig = calloc(1, sizeof(config_t)); @@ -60,6 +97,16 @@ config_t *config_new(void) newconfig->remotefilesiglevel = ALPM_SIG_USE_DEFAULT; } + 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.nocolor = ""; + return newconfig; } @@ -439,6 +486,7 @@ static int _parse_options(const char *key, char *value, } else if(strcmp(key, "Color") == 0) { if(config->color == PM_COLOR_UNSET) { config->color = isatty(fileno(stdout)) ? PM_COLOR_ON : PM_COLOR_OFF; + enable_colors(config->color); } } else { pm_printf(ALPM_LOG_WARNING, |