]> git.eshelyaron.com Git - emacs.git/commitdiff
Support Tc terminfo flag for 24-bit color support in terminal
authorTim Ruffing <crypto@timruffing.de>
Thu, 11 Nov 2021 06:14:57 +0000 (07:14 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Thu, 11 Nov 2021 06:14:57 +0000 (07:14 +0100)
* src/term.c (init_tty): Use the Tc flag (bug#44950).

Copyright-paperwork-exempt: yes

etc/NEWS
src/term.c

index e32446997b9db4634591d9f8cd34a5193c2f7b93..e0b1c35d81f94f058ff0368ea367f69b128ebaa0 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -46,6 +46,11 @@ time.
 \f
 * Changes in Emacs 29.1
 
+** Terminal Emacs
+
+---
+*** Emacs will now use 24-bit colors on terminal that support "Tc".
+
 ** Emoji
 
 +++
index 6f0b827cfc853d3d7964e8cd2539c4ecd68beec3..d86ae12ba84d04bd36d62d804a7eb54afb719ad2 100644 (file)
@@ -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";