Skip to content

Commit

Permalink
Don't use the ECMA standard SGR way of using bold for bright.
Browse files Browse the repository at this point in the history
Working to address both fish-shell#2951 and fish-shell#3176.
  • Loading branch information
floam committed Jul 21, 2016
1 parent 232d419 commit a79a6ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
8 changes: 2 additions & 6 deletions src/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,9 @@ static bool write_color_escape(char *todo, unsigned char idx, bool is_fg) {
return true;
} else {
// We are attempting to bypass the term here. Generate the ANSI escape sequence ourself.
char buff[64] = "";
char buff[16] = "";
if (idx < 16) {
// 30-37 select foreground color, 40-47 background. \e%d for dim, \e%d;1 for bright
snprintf(buff, sizeof buff, "\x1b[%d%sm",
is_fg ? 30 + ((idx > 8) ? idx - 8 : idx) :
40 + ((idx > 8) ? idx - 8 : idx),
idx < 8 ? "" : ";1");
snprintf(buff, sizeof buff, "\x1b[%dm", ((idx > 8) ? 90 : 22) + is_fg * 10);
} else {
snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx);
}
Expand Down
20 changes: 10 additions & 10 deletions src/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@

/// Constants for various colors as used by the set_color function.
enum {
FISH_COLOR_BLACK,
FISH_COLOR_RED,
FISH_COLOR_GREEN,
FISH_COLOR_YELLOW,
FISH_COLOR_BLUE,
FISH_COLOR_MAGENTA,
FISH_COLOR_CYAN,
FISH_COLOR_WHITE,
FISH_COLOR_NORMAL, // the default fg color of the terminal
FISH_COLOR_RESET
FISH_COLOR_BLACK, // 0
FISH_COLOR_RED, // 1
FISH_COLOR_GREEN, // 2
FISH_COLOR_YELLOW, // 3
FISH_COLOR_BLUE, // 4
FISH_COLOR_MAGENTA, // 5
FISH_COLOR_CYAN, // 6
FISH_COLOR_WHITE, // 7
FISH_COLOR_NORMAL, // 8 terminal default
FISH_COLOR_RESET // 9
};

void set_color(rgb_color_t c, rgb_color_t c2);
Expand Down

0 comments on commit a79a6ed

Please sign in to comment.