From: Witold Filipczyk Date: Sat, 7 Feb 2009 00:16:35 +0000 (+0100) Subject: Add support for 256 colors by allowing "colorN" names similar to Mutt X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d270e1f14a7a4ce58f70f865730673359e5f3294;p=tig.git Add support for 256 colors by allowing "colorN" names similar to Mutt Signed-off-by: Jonas Fonseca --- diff --git a/NEWS b/NEWS index 25be947..39ad784 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ Improvements: - Status view: improve "on branch" information inspired by the prompt code in git's bash completion script. + - Colors for 256-capable terminals can be specified as colorN. tig-0.14 -------- diff --git a/tig.c b/tig.c index e25ba68..79afdb1 100644 --- a/tig.c +++ b/tig.c @@ -1388,9 +1388,28 @@ static struct enum_map attr_map[] = { ATTR_MAP(UNDERLINE), }; -#define set_color(color, name) map_enum(color, color_map, name) #define set_attribute(attr, name) map_enum(attr, attr_map, name) +static int +parse_int(int *opt, const char *arg, int min, int max) +{ + int value = atoi(arg); + + if (min <= value && value <= max) + *opt = value; + return OK; +} + +static bool +set_color(int *color, const char *name) +{ + if (map_enum(color, color_map, name)) + return TRUE; + if (!prefixcmp(name, "color")) + return parse_int(color, name + 5, 0, 255) == OK; + return FALSE; +} + static int config_lineno; static bool config_errors; static const char *config_msg; @@ -1443,16 +1462,6 @@ static int parse_bool(bool *opt, const char *arg) return OK; } -static int -parse_int(int *opt, const char *arg, int min, int max) -{ - int value = atoi(arg); - - if (min <= value && value <= max) - *opt = value; - return OK; -} - static int parse_string(char *opt, const char *arg, size_t optsize) { diff --git a/tigrc.5.txt b/tigrc.5.txt index 6f11102..d37b8b8 100644 --- a/tigrc.5.txt +++ b/tigrc.5.txt @@ -361,8 +361,13 @@ Color names:: Valid colors include: *white*, *black*, *green*, *magenta*, *blue*, *cyan*, *yellow*, *red*, *default*. Use *default* to refer to the - default terminal colors. This is recommended for background colors - if you are using a terminal with a transparent background. + default terminal colors. This is recommended for background colors if + you are using a terminal with a transparent background. ++ +Colors can also be specified using the keywords color0, color1, ..., colorN-1 +(N being the number of colors supported by your terminal). This is useful when +you remap the colors for your display or want to enable colors supported by +256-color terminals. Attribute names::