unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH 0/1] Proper 24-bit TTY detection for Emacs 26.
@ 2018-01-23 20:05 Rami Ylimäki
  2018-01-23 20:05 ` [PATCH 1/1] Detect 24-bit TTY color support with standard Terminfo capabilites Rami Ylimäki
  2018-01-24 18:39 ` [PATCH 0/1] Proper 24-bit TTY detection for Emacs 26 Eli Zaretskii
  0 siblings, 2 replies; 5+ messages in thread
From: Rami Ylimäki @ 2018-01-23 20:05 UTC (permalink / raw)
  To: emacs-devel

Hi, I thought that it would make sense to fix this before official
release. Terminfo has just recently started to support capabilites for
detecting 24-bit terminals.

Rami Ylimäki (1):
  Detect 24-bit TTY color support with standard Terminfo capabilites.

 doc/misc/efaq.texi | 34 +++++++---------------------------
 src/term.c         | 26 +++++++++++++-------------
 src/tparam.h       |  3 ++-
 3 files changed, 22 insertions(+), 41 deletions(-)

-- 
2.11.0




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/1] Detect 24-bit TTY color support with standard Terminfo capabilites.
  2018-01-23 20:05 [PATCH 0/1] Proper 24-bit TTY detection for Emacs 26 Rami Ylimäki
@ 2018-01-23 20:05 ` Rami Ylimäki
  2018-01-24 18:39 ` [PATCH 0/1] Proper 24-bit TTY detection for Emacs 26 Eli Zaretskii
  1 sibling, 0 replies; 5+ messages in thread
From: Rami Ylimäki @ 2018-01-23 20:05 UTC (permalink / raw)
  To: emacs-devel; +Cc: Rami Ylimäki

Latest Terminfo supports RGB capability flag for direct color mode
terminals. Foreground and background colors are set with setaf and
setab capability strings.

* src/term.c (init_tty): Use standard Terminfo capabilities to detect
  24-bit TTY color support.
* src/tparam.h: Define prototype for tigetflag.

* doc/misc/efaq.texi (Colors on a TTY): Fix instructions on how to
  enable direct color TTY mode.
---
 doc/misc/efaq.texi | 34 +++++++---------------------------
 src/term.c         | 26 +++++++++++++-------------
 src/tparam.h       |  3 ++-
 3 files changed, 22 insertions(+), 41 deletions(-)

diff --git a/doc/misc/efaq.texi b/doc/misc/efaq.texi
index 8014c2b71f..0ed58eda66 100644
--- a/doc/misc/efaq.texi
+++ b/doc/misc/efaq.texi
@@ -1491,37 +1491,17 @@ Colors on a TTY
 Syntax highlighting is on by default since version 22.1.
 
 Emacs 26.1 and later support direct color mode in terminals.  If Emacs
-finds Terminfo capabilities @samp{setb24} and @samp{setf24}, 24-bit
-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.
+finds Terminfo capability @samp{RGB}, 24-bit direct color mode is
+used.
 
 @example
-$ cat terminfo-24bit.src
-
-# Use colon separators.
-xterm-24bit|xterm with 24-bit direct color mode,
-  use=xterm-256color,
-  setb24=\E[48:2:%p1%@{65536@}%/%d:%p1%@{256@}%/%@{255@}%&%d:%p1%@{255@}%&%dm,
-  setf24=\E[38:2:%p1%@{65536@}%/%d:%p1%@{256@}%/%@{255@}%&%d:%p1%@{255@}%&%dm,
-# Use semicolon separators.
-xterm-24bits|xterm with 24-bit direct color mode,
-  use=xterm-256color,
-  setb24=\E[48;2;%p1%@{65536@}%/%d;%p1%@{256@}%/%@{255@}%&%d;%p1%@{255@}%&%dm,
-  setf24=\E[38;2;%p1%@{65536@}%/%d;%p1%@{256@}%/%@{255@}%&%d;%p1%@{255@}%&%dm,
-
-$ tic -x -o ~/.terminfo terminfo-24bit.src
-
-$ TERM=xterm-24bit emacs -nw
+$ TERM=xterm-direct2 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.
+Currently direct color mode support is quite fragmented and therefore
+Terminfo provides various terminal specifications.  You need to make
+sure that the @samp{setab} and @samp{setaf} capabilites of your TERM
+match your terminal.
 
 @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 b3707da70a..975ba956d7 100644
--- a/src/term.c
+++ b/src/term.c
@@ -4144,19 +4144,19 @@ use the Bourne shell command 'TERM=...; export TERM' (C-shell:\n\
       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");
-	if (fg && bg
-	    && fg != (char *) (intptr_t) -1
-	    && bg != (char *) (intptr_t) -1)
-	  {
-	    tty->TS_set_foreground = fg;
-	    tty->TS_set_background = bg;
-	    tty->TN_max_colors = 16777216;
-	  }
-      }
+      if (tigetflag ("RGB") > 0)
+        {
+          const char *fg = tigetstr ("setaf");
+          const char *bg = tigetstr ("setab");
+          if (fg && bg
+              && fg != (char *) (intptr_t) -1
+              && bg != (char *) (intptr_t) -1)
+            {
+              tty->TS_set_foreground = fg;
+              tty->TS_set_background = bg;
+              tty->TN_max_colors = 16777216;
+            }
+        }
 #endif
 
       tty->TN_no_color_video = tgetnum ("NC");
diff --git a/src/tparam.h b/src/tparam.h
index f8fb9e0869..3a3cb52c17 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
 
 #endif /* EMACS_TPARAM_H */
-- 
2.11.0




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/1] Proper 24-bit TTY detection for Emacs 26.
  2018-01-23 20:05 [PATCH 0/1] Proper 24-bit TTY detection for Emacs 26 Rami Ylimäki
  2018-01-23 20:05 ` [PATCH 1/1] Detect 24-bit TTY color support with standard Terminfo capabilites Rami Ylimäki
@ 2018-01-24 18:39 ` Eli Zaretskii
  2018-01-29 13:27   ` Rami Ylimäki
  1 sibling, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2018-01-24 18:39 UTC (permalink / raw)
  To: Rami Ylimäki; +Cc: emacs-devel

> From: Rami Ylimäki <rami.ylimaki@vincit.fi>
> Date: Tue, 23 Jan 2018 22:05:35 +0200
> 
> Hi, I thought that it would make sense to fix this before official
> release. Terminfo has just recently started to support capabilites for
> detecting 24-bit terminals.

It's too late to make incompatible changes on the emacs-26 branch.

I actually don't understand the motivation for the change.  Did the
method we use now stop working in the recent versions of terminfo, and
the "RGB" and "setaf"/"setab" replace "setf24"/"setb24" we use in the
current code?  Or are the new attributes supported in addition to the
old ones?  If the latter, why do we need to change anything?  And if
the former, I think we want to support both, not just the new
replacements.

Thanks.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/1] Proper 24-bit TTY detection for Emacs 26.
  2018-01-24 18:39 ` [PATCH 0/1] Proper 24-bit TTY detection for Emacs 26 Eli Zaretskii
@ 2018-01-29 13:27   ` Rami Ylimäki
  2018-01-29 15:59     ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Rami Ylimäki @ 2018-01-29 13:27 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

> It's too late to make incompatible changes on the emacs-26 branch.
>
> I actually don't understand the motivation for the change.  Did the
> method we use now stop working in the recent versions of terminfo, and
> the "RGB" and "setaf"/"setab" replace "setf24"/"setb24" we use in the
> current code?  Or are the new attributes supported in addition to the
> old ones?  If the latter, why do we need to change anything?  And if
> the former, I think we want to support both, not just the new
> replacements.
The "set[bf]24" capabilities are only supported by Emacs, because 
traditionally Terminfo hasn't offered any way to detect direct color 
support. This workaround forces users to compile their own TERMs with 
these capabilities.

Latest Terminfo provides several TERMs with "-direct" suffix, such as 
"xterm-direct", that support "RGB" with "seta[bf]". We definitely want 
to support this.

I can open a bug about this and post a patch that supports both methods 
on Emacs 27, since it's too late for 26.

There might be some problems with Emacs 26 and TERM=xterm-direct, but I 
haven't properly investigated this yet. At least I already noticed some 
error messages from xterm.el:xterm-register-default-colors.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/1] Proper 24-bit TTY detection for Emacs 26.
  2018-01-29 13:27   ` Rami Ylimäki
@ 2018-01-29 15:59     ` Eli Zaretskii
  0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2018-01-29 15:59 UTC (permalink / raw)
  To: Rami Ylimäki; +Cc: emacs-devel

> Cc: emacs-devel@gnu.org
> From: Rami Ylimäki <rami.ylimaki@vincit.fi>
> Date: Mon, 29 Jan 2018 15:27:37 +0200
> 
> The "set[bf]24" capabilities are only supported by Emacs, because 
> traditionally Terminfo hasn't offered any way to detect direct color 
> support. This workaround forces users to compile their own TERMs with 
> these capabilities.
> 
> Latest Terminfo provides several TERMs with "-direct" suffix, such as 
> "xterm-direct", that support "RGB" with "seta[bf]". We definitely want 
> to support this.

OK, thanks for explaining the situation.

> I can open a bug about this and post a patch that supports both methods 
> on Emacs 27, since it's too late for 26.

Please do, and thanks.

> There might be some problems with Emacs 26 and TERM=xterm-direct, but I 
> haven't properly investigated this yet. At least I already noticed some 
> error messages from xterm.el:xterm-register-default-colors.

If there's a reasonable workaround for those problems, we could
perhaps describe it in etc/PROBLEMS for Emacs 26.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-01-29 15:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-23 20:05 [PATCH 0/1] Proper 24-bit TTY detection for Emacs 26 Rami Ylimäki
2018-01-23 20:05 ` [PATCH 1/1] Detect 24-bit TTY color support with standard Terminfo capabilites Rami Ylimäki
2018-01-24 18:39 ` [PATCH 0/1] Proper 24-bit TTY detection for Emacs 26 Eli Zaretskii
2018-01-29 13:27   ` Rami Ylimäki
2018-01-29 15:59     ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).