Subject: Re: bug#62237: 28.1 or higher: 24-bit true color breaks colours in Emacsen built without X under GNU Screen

From: Robert Pluim <[email-masked]>
Date: Mon, 20 Mar 2023 15:08:14 +0100

>>>>> On Mon, 20 Mar 2023 14:15:35 +0200, Eli Zaretskii <[email-masked]> said:

    >> From: Robert Pluim <[email-masked]>
    >> Changing the interpretation of the userʼs TERM seems pretty radical to
    >> me, even if it will tend to improve usersʼ experience.

    Eli> If screen.FOO is not recognizable while FOO is, then we cannot
    Eli> possibly break anything by this change, however radical.  (But it
    Eli> sounds like I misunderstood what is going on here, see below.)

Iʼm sure I donʼt entirely understand whatʼs going on either

    >> >> I guess we could do something with not checking COLORTERM under screen
    >> >> instead.
    >> 
    Eli> That's a separate issue, from where I stand.  Users can unset
    Eli> COLORTERM, but their true terminal type will still be "hidden" behind
    Eli> the "screen." prefix, won't it?  The terminal type is about more than
    Eli> just the colors.  Or does terminfo know about this "screen." business?
    >> 
    >> I have both a 'screen.xterm-256color' and a 'xterm-256color' terminfo
    >> file. I donʼt think terminfo does any prefix stripping, as thereʼs a
    >> whole bunch of screen.$TERM files, which would be unnecessary if
    >> stripping were happening.

    Eli> Are the screen.$TERM files different from the corresponding $TERM
    Eli> ones?  If so, what are the differences?

$ infocmp screen.xterm-256color xterm-256color

comparing screen.xterm-256color to xterm-256color.
    comparing booleans.
	bce: F:T.
	bw: T:F.
	ccc: F:T.
    comparing numbers.
    comparing strings.
	initc: NULL, '\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\'.
	invis: NULL, '\E[8m'.
	kIC: NULL, '\E[2;2~'.
	kNXT: NULL, '\E[6;2~'.
	kPRV: NULL, '\E[5;2~'.
	kend: '\E[4~', '\EOF'.
	khome: '\E[1~', '\EOH'.
	kmous: '\E[M', '\E[<'.
	oc: NULL, '\E]104\007'.
	ritm: NULL, '\E[23m'.
	rs1: '\Ec', '\Ec\E]104\007'.
	sgr: '%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p5%t;2%;m', '%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p5%t;2%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m'.
	sitm: NULL, '\E[3m'.

    Eli> And if screen.$TERM files are available in the terminfo DB, then why
    Eli> did you suggest to do something in init_tty in the first place?

Becasue the behaviour is different (all under 'screen' in gnome-terminal):

1.
COLORTERM=truecolor TERM=screen.xterm-256color src/emacs -nw -Q etc/NEWS

(display-color-cells) => 16777216

but the display looks black & white, and `list-colors-display' looks
really off.

2.
COLORTERM=truecolor TERM=xterm-256color src/emacs -nw -Q etc/NEWS

(display-color-cells) => 16777216

The display looks more colourful, but `list-colors-display' is still
off.

3.
COLORTERM= TERM=screen.xterm-256color src/emacs -nw -Q etc/NEWS

(display-color-cells) => 256
The display is now colourful, and `list-colors-display' has 256
entries, but:

4.
COLORTERM= TERM=xterm-256color src/emacs -nw -Q etc/NEWS

This is like [3], but the colours are different.

[2] is a definite improvement over [1], but it would be nice if we
could get to [3] or [4] (my gnome-terminal may be too old for proper
truecolor support, itʼs 3.83.3 with VTE 0.62.3)

    Eli> Also, what about the lisp/term/ files -- are we loading the right
    Eli> files when TERM -s set to screen.SOMETHING? should we?

Weʼre running term/screen.el (which then runs xterm.el)
 
    >> Perhaps the best thing to do is put an entry in etc/PROBLEMS?

    Eli> About what?  If screen.FOO files are available, then everything should
    Eli> already work correctly OOTB, no?  Or what am I missing here?

If everything worked OOTB, then yes, but our handling of COLORTERM is
still problematic. If we could delay the 24bit colour support decision
until weʼre in lisp/term I think that would help.

Robert
--