mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-05 08:11:15 -03:00
Fix term_supports_color_natively() off-by-one
When max_colors is 16, we support up to color 15.
This commit is contained in:
@@ -49,7 +49,7 @@ void output_set_writer(int (*writer)(char)) {
|
|||||||
int (*output_get_writer())(char) { return out; }
|
int (*output_get_writer())(char) { return out; }
|
||||||
|
|
||||||
/// Returns true if we think tparm can handle outputting a color index
|
/// Returns true if we think tparm can handle outputting a color index
|
||||||
static bool term_supports_color_natively(unsigned int c) { return max_colors >= c; }
|
static bool term_supports_color_natively(unsigned int c) { return max_colors >= (c + 1); }
|
||||||
|
|
||||||
color_support_t output_get_color_support(void) { return color_support; }
|
color_support_t output_get_color_support(void) { return color_support; }
|
||||||
|
|
||||||
@@ -71,6 +71,7 @@ static bool write_color_escape(char *todo, unsigned char idx, bool is_fg) {
|
|||||||
// We are attempting to bypass the term here. Generate the ANSI escape sequence ourself.
|
// We are attempting to bypass the term here. Generate the ANSI escape sequence ourself.
|
||||||
char buff[16] = "";
|
char buff[16] = "";
|
||||||
if (idx < 16) {
|
if (idx < 16) {
|
||||||
|
if
|
||||||
snprintf(buff, sizeof buff, "\x1b[%dm", ((idx > 7) ? 82 : 30) + idx + !is_fg * 10);
|
snprintf(buff, sizeof buff, "\x1b[%dm", ((idx > 7) ? 82 : 30) + idx + !is_fg * 10);
|
||||||
} else {
|
} else {
|
||||||
snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx);
|
snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx);
|
||||||
|
|||||||
Reference in New Issue
Block a user