]> git.eshelyaron.com Git - emacs.git/commitdiff
Add fallback for 24-bit terminal color via COLORTERM=truecolor
authorJan Beich <jbeich@FreeBSD.org>
Sun, 14 Jun 2020 03:51:24 +0000 (03:51 +0000)
committerEli Zaretskii <eliz@gnu.org>
Sat, 20 Jun 2020 08:16:14 +0000 (11:16 +0300)
* src/term.c (init_tty): When COLORTERM=truecolor is defined,
override setaf/setab/colors terminfo capabilities with 24-bit
color support.

* doc/misc/efaq.texi (Colors on a TTY): Mention the possibility to
enable 24-bit color via the COLORTERM environment variable.

(Bug#41846)

Copyright-paperwork-exempt: yes

doc/misc/efaq.texi
src/term.c

index f5f01848f77ff5c3bbbc2bf57f5068cdae615968..8f7ed715b5232929a70ef017d11c6b7bf51e01af 100644 (file)
@@ -1595,6 +1595,10 @@ xterm-direct2   xterm with direct-color indexing (old)
 xterm-direct    xterm with direct-color indexing
 @end example
 
+If Terminfo database is not available, but 24-bit direct color mode is
+supported, it can still be enabled by defining the environment
+variable @env{COLORTERM} to @samp{truecolor}.
+
 Terminals with @samp{RGB} capability treat pixels #000001 - #000007 as
 indexed colors to maintain backward compatibility with applications
 that are unaware of direct color mode.  Therefore the seven darkest
index 94bf013f4a0728936c3b018cd9886c7982068f4e..5cbb092ad177e98658495a00e292004401c14fa1 100644 (file)
@@ -4168,6 +4168,15 @@ 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)
+         {
+           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";
+           tty->TN_max_colors = 16777216;
+         }
       }
 #endif