From: Tim Ruffing Date: Thu, 11 Nov 2021 06:14:57 +0000 (+0100) Subject: Support Tc terminfo flag for 24-bit color support in terminal X-Git-Tag: emacs-29.0.90~3668^2~58 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f30f53115928fd65d066944d53d07742b0807670;p=emacs.git Support Tc terminfo flag for 24-bit color support in terminal * src/term.c (init_tty): Use the Tc flag (bug#44950). Copyright-paperwork-exempt: yes --- diff --git a/etc/NEWS b/etc/NEWS index e32446997b9..e0b1c35d81f 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -46,6 +46,11 @@ time. * Changes in Emacs 29.1 +** Terminal Emacs + +--- +*** Emacs will now use 24-bit colors on terminal that support "Tc". + ** Emoji +++ diff --git a/src/term.c b/src/term.c index 6f0b827cfc8..d86ae12ba84 100644 --- a/src/term.c +++ b/src/term.c @@ -4152,10 +4152,12 @@ use the Bourne shell command 'TERM=...; export TERM' (C-shell:\n\ 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";