commit
7c2ac4a655
8 changed files with 433 additions and 26 deletions
|
|
@ -429,6 +429,7 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, _BASE_SESSION_CLASS):
|
|||
- xterm256: Enforce xterm256 colors, regardless of TTYPE.
|
||||
- noxterm256: Enforce no xterm256 color support, regardless of TTYPE.
|
||||
- nocolor: Strip all Color, regardless of ansi/xterm256 setting.
|
||||
- truecolor: Enforce truecolor, regardless of TTYPE.
|
||||
- raw: Pass string through without any ansi processing
|
||||
(i.e. include Evennia ansi markers but do not
|
||||
convert them into ansi tokens)
|
||||
|
|
@ -447,6 +448,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
|
||||
)
|
||||
|
|
@ -470,6 +474,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)
|
||||
|
|
@ -506,6 +511,7 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, _BASE_SESSION_CLASS):
|
|||
strip_ansi=nocolor,
|
||||
xterm256=xterm256,
|
||||
mxp=mxp,
|
||||
truecolor=truecolor
|
||||
)
|
||||
if mxp:
|
||||
linetosend = mxp_parse(linetosend)
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class Ttype:
|
|||
def __init__(self, protocol):
|
||||
"""
|
||||
Initialize ttype by storing protocol on ourselves and calling
|
||||
the client to see if it supporst ttype.
|
||||
the client to see if it supports ttype.
|
||||
|
||||
Args:
|
||||
protocol (Protocol): The protocol instance.
|
||||
|
|
@ -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