mirror of
https://github.com/evennia/evennia.git
synced 2026-03-22 07:46:30 +01:00
Added basic terminal detection for truecolor support.
This commit is contained in:
parent
a552bf6fd4
commit
de09f7a71c
2 changed files with 23 additions and 8 deletions
|
|
@ -437,6 +437,9 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, _BASE_SESSION_CLASS):
|
|||
xterm256 = options.get(
|
||||
"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(
|
||||
"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"),
|
||||
strip_ansi=nocolor,
|
||||
xterm256=xterm256,
|
||||
truecolor=truecolor
|
||||
)
|
||||
if mxp:
|
||||
prompt = mxp_parse(prompt)
|
||||
|
|
@ -496,6 +500,7 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, _BASE_SESSION_CLASS):
|
|||
strip_ansi=nocolor,
|
||||
xterm256=xterm256,
|
||||
mxp=mxp,
|
||||
truecolor=truecolor
|
||||
)
|
||||
if mxp:
|
||||
linetosend = mxp_parse(linetosend)
|
||||
|
|
|
|||
|
|
@ -130,10 +130,10 @@ class Ttype:
|
|||
self.protocol.protocol_flags["NOPROMPTGOAHEAD"] = False
|
||||
|
||||
if (
|
||||
clientname.startswith("XTERM")
|
||||
or clientname.endswith("-256COLOR")
|
||||
or clientname
|
||||
in (
|
||||
clientname.startswith("XTERM")
|
||||
or clientname.endswith("-256COLOR")
|
||||
or clientname
|
||||
in (
|
||||
"ATLANTIS", # > 0.9.9.0 (aug 2009)
|
||||
"CMUD", # > 3.04 (mar 2009)
|
||||
"KILDCLIENT", # > 2.2.0 (sep 2005)
|
||||
|
|
@ -143,13 +143,23 @@ class Ttype:
|
|||
"BEIP", # > 2.00.206 (late 2009) (BeipMu)
|
||||
"POTATO", # > 2.00 (maybe earlier)
|
||||
"TINYFUGUE", # > 4.x (maybe earlier)
|
||||
)
|
||||
)
|
||||
):
|
||||
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
|
||||
self.protocol.protocol_flags["ANSI"] = True
|
||||
self.protocol.protocol_flags["XTERM256"] = xterm256
|
||||
self.protocol.protocol_flags["TRUECOLOR"] = truecolor
|
||||
self.protocol.protocol_flags["CLIENTNAME"] = clientname
|
||||
self.protocol.requestNegotiation(TTYPE, SEND)
|
||||
|
||||
|
|
@ -159,9 +169,9 @@ class Ttype:
|
|||
tupper = term.upper()
|
||||
# identify xterm256 based on flag
|
||||
xterm256 = (
|
||||
tupper.endswith("-256COLOR")
|
||||
or tupper.endswith("XTERM") # Apple Terminal, old Tintin
|
||||
and not tupper.endswith("-COLOR") # old Tintin, Putty
|
||||
tupper.endswith("-256COLOR")
|
||||
or tupper.endswith("XTERM") # Apple Terminal, old Tintin
|
||||
and not tupper.endswith("-COLOR") # old Tintin, Putty
|
||||
)
|
||||
if xterm256:
|
||||
self.protocol.protocol_flags["ANSI"] = True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue