Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/util.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,14 @@ char const* ansi_color( Replxx::Color color_ ) {
} else if ( fg <= static_cast<int unsigned>( Replxx::Color::LIGHTGRAY ) ) {
pos = snprintf( colorBuffer, MAX_COLOR_CODE_SIZE, "\033[0;22;3%d%s%sm", fg, underline, bold );
} else if ( fg <= static_cast<int unsigned>( Replxx::Color::WHITE ) ) {
#ifdef _WIN32
static bool const has256colorDefault( true );
#else
static bool const has256colorDefault( false );
#endif
static char const* TERM( getenv( "TERM" ) );
static bool const has256color( TERM ? ( strstr( TERM, "256" ) != nullptr ) : has256colorDefault );
static char const* ansiEscapeCodeTemplate = has256color ? "\033[0;9%d%s%sm" : "\033[0;1;3%d%s%sm";
pos = snprintf( colorBuffer, MAX_COLOR_CODE_SIZE, ansiEscapeCodeTemplate, fg - static_cast<int>( Replxx::Color::GRAY ), underline, bold );
/* Aixterm bright color codes (90-97) belong to the basic 16-color set and are supported
* by virtually every terminal in use. Previously they were emitted only when TERM
* contained "256" (they are unrelated to 256-color support), with a fallback to
* bold + dark color otherwise. That broke bright colors on terminals with TERM values
* like xterm-ghostty, xterm-kitty, alacritty or foot: modern terminals do not render
* bold as bright by default, so e.g. GRAY (bold black) degraded to plain black,
* invisible on a dark background. */
pos = snprintf( colorBuffer, MAX_COLOR_CODE_SIZE, "\033[0;9%d%s%sm", fg - static_cast<int>( Replxx::Color::GRAY ), underline, bold );
} else {
pos = snprintf( colorBuffer, MAX_COLOR_CODE_SIZE, "\033[0;38;5;%d%s%sm", fg, underline, bold );
}
Expand Down
18 changes: 9 additions & 9 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,20 +148,20 @@
"\x1b[0;22;35m": "<magenta>",
"\x1b[0;22;36m": "<cyan>",
"\x1b[0;22;37m": "<lightgray>",
"\x1b[0;1;30m": "<gray>",
"\x1b[0;1;31m": "<brightred>",
"\x1b[0;1;32m": "<brightgreen>",
"\x1b[0;1;33m": "<yellow>",
"\x1b[0;1;34m": "<brightblue>",
"\x1b[0;1;35m": "<brightmagenta>",
"\x1b[0;1;36m": "<brightcyan>",
"\x1b[0;1;37m": "<white>",
"\x1b[0;90m": "<gray>",
"\x1b[0;91m": "<brightred>",
"\x1b[0;92m": "<brightgreen>",
"\x1b[0;93m": "<yellow>",
"\x1b[0;94m": "<brightblue>",
"\x1b[0;95m": "<brightmagenta>",
"\x1b[0;96m": "<brightcyan>",
"\x1b[0;97m": "<white>",
"\x1b[0;1m": "<bold>",
"\x1b[0;4m": "<underline>",
"\x1b[0;4;1m": "<bold_underline>",
"\x1b[0;22;31;1m": "<bold_red>",
"\x1b[0;22;31;4m": "<underline_red>",
"\x1b[0;1;31;1m": "<bold_brightred>",
"\x1b[0;91;1m": "<bold_brightred>",
"\x1b[0;22;31;4;1m": "<bold_underline_red>",
"\x1b[40m": "<bgblack>",
"\x1b[41m": "<bgred>",
Expand Down
Loading