add support for ANSI "bright" colors

This adds support for the ANSI x3.64 "bright" colors in the basic sixteen
color palette. This is especially useful when trying to use the base colors
as a background color. The "bright" variants tend to be more useful as
background colors compared to the non-bright variants.

This also fixes a bug in so far as palette number 7 is actually grey and
not white whereas palette number 15 is white. At least on the terminal
emulators on which I've tested this change (Ubuntu xterm & uxterm, Mac
OS X Terminal & iTerm2).

Resolves issue #1464.
This commit is contained in:
Kurtis Rader 2015-11-24 12:36:35 -08:00 committed by ridiculousfish
parent ef67fc7ba0
commit 0a0acc8a2e
2 changed files with 16 additions and 6 deletions

View file

@ -7,9 +7,9 @@ set_color [OPTIONS] [COLOR]
\subsection set_color-description Description
`set_color` changes the foreground and/or background color of the terminal. `COLOR` is one of black, red, green, brown, yellow, blue, magenta, purple, cyan, white and normal.
`set_color` changes the foreground and/or background color of the terminal. `COLOR` is one of `black`, `red`, `green`, `brown`, `yellow`, `blue`, `magenta`, `purple`, `cyan`, `brred`, `brgreen`, `brbrown`, `bryellow`, `brblue`, `brmagenta`, `brpurple`, `brcyan`, `white` and `normal`. The `br`, bright, forms are most useful as background colors.
If your terminal supports term256 (modern xterms and OS X Lion), you can specify an RGB value with three or six hex digits, such as A0FF33 or f2f. `fish` will choose the closest supported color.
If your terminal supports term256 (modern xterms and OS X Terminal and iTerm2), you can specify an RGB value with three or six hex digits, such as A0FF33 or f2f. `fish` will choose the closest supported color. A three digit value is equivalent to specifying each digit twice; e.g., `#2BC` is the same as `#22BBCC`. Hex RGB values can be in lower or uppercase, optionally prefixed with the pound-sign character.
The following options are available:
@ -24,7 +24,7 @@ The following options are available:
Calling `set_color normal` will set the terminal color to the default color of the terminal.
Some terminals use the `--bold` escape sequence to switch to a brighter color set. On such terminals, `set_color white` will result in a grey font color, while `set_color --bold white` will result in a white font color.
Some terminals use the `--bold` escape sequence to switch to a brighter color set rather than bolding the characters.
Not all terminal emulators support all these features.

View file

@ -160,7 +160,7 @@ struct named_color_t
unsigned char rgb[3];
};
static const named_color_t named_colors[11] =
static const named_color_t named_colors[] =
{
{L"black", 0, {0, 0, 0}},
{L"red", 1, {0xFF, 0, 0}},
@ -171,8 +171,18 @@ static const named_color_t named_colors[11] =
{L"magenta", 5, {0xFF, 0, 0xFF}},
{L"purple", 5, {0xFF, 0, 0xFF}},
{L"cyan", 6, {0, 0xFF, 0xFF}},
{L"white", 7, {0xFF, 0xFF, 0xFF}},
{L"normal", 8, {0xFF, 0xFF, 0XFF}}
{L"grey", 7, {0xE5, 0xE5, 0xE5}},
{L"normal", 7, {0xE5, 0xE5, 0XE5}},
{L"brgrey", 8, {0x55, 0x55, 0x55}},
{L"brred", 9, {0xFF, 0x55, 0x55}},
{L"brgreen", 10, {0x55, 0xFF, 0x55}},
{L"brbrown", 11, {0xFF, 0xFF, 0x55}},
{L"bryellow", 11, {0xFF, 0xFF, 0x55}},
{L"brblue", 12, {0x55, 0x55, 0xFF}},
{L"brmagenta", 13, {0xFF, 0x55, 0xFF}},
{L"brpurple", 13, {0xFF, 0x55, 0xFF}},
{L"brcyan", 14, {0x55, 0xFF, 0xFF}},
{L"white", 15, {0xFF, 0xFF, 0xFF}},
};
wcstring_list_t rgb_color_t::named_color_names(void)