[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 7f6153d: Support standard Terminfo direct mode term

From: Eli Zaretskii
Subject: [Emacs-diffs] master 7f6153d: Support standard Terminfo direct mode terminals
Date: Sat, 10 Feb 2018 06:33:26 -0500 (EST)

branch: master
commit 7f6153d9563cfe7753083996f59eacc9f4c694df
Author: Rami Ylimäki <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Support standard Terminfo direct mode terminals
    Latest Terminfo introduces terminal definitions that support direct
    color mode.  The "Co"/"colors" capability is set to 0x1000000 on these
    terminals and Emacs is already compatible with them.
    However, if used Terminfo library hasn't been compiled with 32-bit
    value support, "Co"/"colors" is truncated to 0x7fff.  In this case
    direct color mode support can be detected from the "RGB" capability
    There are some minor problems if the color count isn't corrected from
    0x7fff.  First eight standard colors defined in xterm-standard-colors
    are shown correctly.  However, their RGB values match the terminal
    settings, not the RGB values defined in xterm-standard-colors.  Bright
    versions of these colors are shown incorrectly.  They are interpreted
    as pixels #000008 - #000015, which are very dark shades of blue.
    * src/term.c (init_tty): Force terminal color count to 0x1000000 if
    "RGB" capability is present.
    * src/tparam.h: Define prototype for tigetflag.  (Bug#30308)
    * doc/misc/efaq.texi (Colors on a TTY): Add information about direct
    mode terminals supported by Terminfo.
 doc/misc/efaq.texi | 45 +++++++++++++++++++++++++++------------------
 src/term.c         | 10 +++++++++-
 src/tparam.h       |  3 ++-
 3 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/doc/misc/efaq.texi b/doc/misc/efaq.texi
index 3e67438..fef9b10 100644
--- a/doc/misc/efaq.texi
+++ b/doc/misc/efaq.texi
@@ -1496,32 +1496,41 @@ direct color mode is used.  The capability strings are 
expected to
 take one 24-bit pixel value as argument and transform the pixel to a
 string that can be used to send 24-bit colors to the terminal.
-There aren't yet any standard terminal type definitions that would
-support the capabilities, but Emacs can be invoked with a custom
-definition as shown below.
+Standard terminal definitions don't support these capabilities and
+therefore custom definition is needed.
-$ cat terminfo-24bit.src
+$ cat terminfo-custom.src
-# Use colon separators.
-xterm-24bit|xterm with 24-bit direct color mode,
+xterm-emacs|xterm with 24-bit direct color mode for Emacs,
-# Use semicolon separators.
-xterm-24bits|xterm with 24-bit direct color mode,
-  use=xterm-256color,
+$ tic -x -o ~/.terminfo terminfo-custom.src
+$ TERM=xterm-emacs emacs -nw
address@hidden example
+Emacs 27.1 and later support Terminfo capability @samp{RGB} for
+detecting 24-bit direct color mode.  Multiple standard terminal
+definitions support this capability.
+$ TERM=xterm-direct infocmp | grep seta[bf]
-$ tic -x -o ~/.terminfo terminfo-24bit.src
-$ TERM=xterm-24bit emacs -nw
+$ TERM=xterm-direct emacs -nw
 @end example
-Currently there's no standard way to determine whether a terminal
-supports direct color mode.  If such standard arises later on, support
-for @samp{setb24} and @samp{setf24} may be removed.
+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
+blue shades may not be available.  If this is a problem, you can
+always use custom terminal definition with @samp{setb24} and
 @node Debugging a customization file
 @section How do I debug a @file{.emacs} file?
diff --git a/src/term.c b/src/term.c
index b3707da..64a2b7e 100644
--- a/src/term.c
+++ b/src/term.c
@@ -4144,10 +4144,10 @@ use the Bourne shell command 'TERM=...; export TERM' 
       tty->TN_max_colors = tgetnum ("Co");
 #ifdef TERMINFO
-      /* Non-standard support for 24-bit colors. */
        const char *fg = tigetstr ("setf24");
        const char *bg = tigetstr ("setb24");
+       /* Non-standard support for 24-bit colors. */
        if (fg && bg
            && fg != (char *) (intptr_t) -1
            && bg != (char *) (intptr_t) -1)
@@ -4156,6 +4156,14 @@ use the Bourne shell command 'TERM=...; export TERM' 
            tty->TS_set_background = bg;
            tty->TN_max_colors = 16777216;
+       /* Standard support for 24-bit colors.  */
+       else if (tigetflag ("RGB") > 0)
+         {
+           /* If the used Terminfo library supports only 16-bit
+              signed values, tgetnum("Co") and tigetnum("colors")
+              could return 32767.  */
+           tty->TN_max_colors = 16777216;
+         }
diff --git a/src/tparam.h b/src/tparam.h
index f8fb9e0..3a3cb52 100644
--- a/src/tparam.h
+++ b/src/tparam.h
@@ -37,7 +37,8 @@ extern char *BC;
 extern char *UP;
 #ifdef TERMINFO
-char *tigetstr(const char *);
+int tigetflag (const char *);
+char *tigetstr (const char *);
 #endif /* EMACS_TPARAM_H */

reply via email to

[Prev in Thread] Current Thread [Next in Thread]