From 8c5851a96447cd06f41d2983390e699461870072 Mon Sep 17 00:00:00 2001 From: Tim Ruffing Date: Mon, 31 May 2021 15:38:19 +0200 Subject: [PATCH] Support Tc terminfo flag forg 24-bit color support in terminal --- src/term.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/term.c b/src/term.c index c995a4499c..fdcc116b69 100644 --- a/src/term.c +++ b/src/term.c @@ -4157,10 +4157,12 @@ init_tty (const char *name, const char *terminal_type, bool must_succeed) could return 32767. */ tty->TN_max_colors = 16777216; } - /* Fall back to xterm+direct (semicolon version) if requested - by the COLORTERM environment variable. */ - else if ((bg = getenv("COLORTERM")) != NULL - && strcasecmp(bg, "truecolor") == 0) + /* Fall back to xterm+direct (semicolon version) if Tc is set + (de-facto standard introduced by tmux) or if requested by + the COLORTERM environment variable. */ + else if (tigetflag("Tc") + || ((bg = getenv("COLORTERM")) != NULL + && strcasecmp(bg, "truecolor") == 0)) { tty->TS_set_foreground = "\033[%?%p1%{8}%<%t3%p1%d%e38;2;%p1%{65536}%/%d;%p1%{256}%/%{255}%&%d;%p1%{255}%&%d%;m"; tty->TS_set_background = "\033[%?%p1%{8}%<%t4%p1%d%e48;2;%p1%{65536}%/%d;%p1%{256}%/%{255}%&%d;%p1%{255}%&%d%;m"; -- 2.31.1