Added basic terminal detection for truecolor support.

This commit is contained in:
mike 2024-04-06 17:45:37 -07:00
parent a552bf6fd4
commit de09f7a71c
2 changed files with 23 additions and 8 deletions

View file

@ -437,6 +437,9 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, _BASE_SESSION_CLASS):
xterm256 = options.get( xterm256 = options.get(
"xterm256", flags.get("XTERM256", False) if flags.get("TTYPE", False) else True "xterm256", flags.get("XTERM256", False) if flags.get("TTYPE", False) else True
) )
truecolor = options.get(
"truecolor", flags.get("TRUECOLOR", False) if flags.get("TTYPE", False) else True
)
useansi = options.get( useansi = options.get(
"ansi", flags.get("ANSI", False) if flags.get("TTYPE", False) else True "ansi", flags.get("ANSI", False) if flags.get("TTYPE", False) else True
) )
@ -460,6 +463,7 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, _BASE_SESSION_CLASS):
_RE_N.sub("", prompt) + ("||n" if prompt.endswith("|") else "|n"), _RE_N.sub("", prompt) + ("||n" if prompt.endswith("|") else "|n"),
strip_ansi=nocolor, strip_ansi=nocolor,
xterm256=xterm256, xterm256=xterm256,
truecolor=truecolor
) )
if mxp: if mxp:
prompt = mxp_parse(prompt) prompt = mxp_parse(prompt)
@ -496,6 +500,7 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, _BASE_SESSION_CLASS):
strip_ansi=nocolor, strip_ansi=nocolor,
xterm256=xterm256, xterm256=xterm256,
mxp=mxp, mxp=mxp,
truecolor=truecolor
) )
if mxp: if mxp:
linetosend = mxp_parse(linetosend) linetosend = mxp_parse(linetosend)

View file

@ -147,9 +147,19 @@ class Ttype:
): ):
xterm256 = True xterm256 = True
# use name to identify support for xterm truecolor
truecolor = False
if (clientname.endswith("-TRUECOLOR") or
clientname in (
"AXMUD",
"TINTIN"
)):
truecolor = True
# all clients supporting TTYPE at all seem to support ANSI # all clients supporting TTYPE at all seem to support ANSI
self.protocol.protocol_flags["ANSI"] = True self.protocol.protocol_flags["ANSI"] = True
self.protocol.protocol_flags["XTERM256"] = xterm256 self.protocol.protocol_flags["XTERM256"] = xterm256
self.protocol.protocol_flags["TRUECOLOR"] = truecolor
self.protocol.protocol_flags["CLIENTNAME"] = clientname self.protocol.protocol_flags["CLIENTNAME"] = clientname
self.protocol.requestNegotiation(TTYPE, SEND) self.protocol.requestNegotiation(TTYPE, SEND)