mirror of
https://github.com/evennia/evennia.git
synced 2026-04-03 06:27:17 +02:00
Fix issue with option ansi/xterm256=False not correctly turning off colors. Change the NOMARKUP session option flag to NOCOLOR to better reflect its function.
This commit is contained in:
parent
b6a4997a97
commit
4699b38b31
8 changed files with 24 additions and 22 deletions
|
|
@ -563,7 +563,7 @@ class CmdOption(COMMAND_DEFAULT_CLASS):
|
|||
"ENCODING": validate_encoding,
|
||||
"MCCP": validate_bool,
|
||||
"MXP": validate_bool,
|
||||
"NOMARKUP": validate_bool,
|
||||
"NOCOLOR": validate_bool,
|
||||
"NOPKEEPALIVE": validate_bool,
|
||||
"OOB": validate_bool,
|
||||
"RAW": validate_bool,
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ def client_options(session, *args, **kwargs):
|
|||
screenheight (int): Screen height in lines
|
||||
screenwidth (int): Screen width in characters
|
||||
inputdebug (bool): Debug input functions
|
||||
nomarkup (bool): Strip markup
|
||||
nocolor (bool): Strip color
|
||||
raw (bool): Turn off parsing
|
||||
|
||||
"""
|
||||
|
|
@ -193,7 +193,7 @@ def client_options(session, *args, **kwargs):
|
|||
"UTF-8", "SCREENREADER", "ENCODING",
|
||||
"MCCP", "SCREENHEIGHT",
|
||||
"SCREENWIDTH", "INPUTDEBUG",
|
||||
"RAW", "NOMARKUP"))
|
||||
"RAW", "NOCOLOR"))
|
||||
session.msg(client_options=options)
|
||||
return
|
||||
|
||||
|
|
@ -240,8 +240,8 @@ def client_options(session, *args, **kwargs):
|
|||
flags["SCREENWIDTH"] = validate_size(value)
|
||||
elif key == "inputdebug":
|
||||
flags["INPUTDEBUG"] = validate_bool(value)
|
||||
elif key == "nomarkup":
|
||||
flags["NOMARKUP"] = validate_bool(value)
|
||||
elif key == "nocolor":
|
||||
flags["NOCOLOR"] = validate_bool(value)
|
||||
elif key == "raw":
|
||||
flags["RAW"] = validate_bool(value)
|
||||
elif key in ('Char 1', 'Char.Skills 1', 'Char.Items 1',
|
||||
|
|
|
|||
|
|
@ -289,6 +289,7 @@ class PortalSessionHandler(SessionHandler):
|
|||
# save protocols
|
||||
for sessid in to_save:
|
||||
self[sessid].load_sync_data(serversessions[sessid])
|
||||
print ("portalsessionhandler synced:", self[sessid].protocol_flags)
|
||||
if clean:
|
||||
# disconnect out-of-sync missing protocols
|
||||
to_delete = [sessid for sessid in self if sessid not in to_save]
|
||||
|
|
|
|||
|
|
@ -246,8 +246,7 @@ class SshProtocol(Manhole, session.Session):
|
|||
- mxp: Enforce MXP link support.
|
||||
- ansi: Enforce no ANSI colors.
|
||||
- xterm256: Enforce xterm256 colors, regardless of TTYPE setting.
|
||||
- noxterm256: Enforce no xterm256 color support, regardless of TTYPE.
|
||||
- nomarkup: Strip all ANSI markup. This is the same as noxterm256,noansi
|
||||
- nocolor: Strip all colors.
|
||||
- raw: Pass string through without any ansi processing
|
||||
(i.e. include Evennia ansi markers but do not
|
||||
convert them into ansi tokens)
|
||||
|
|
@ -265,10 +264,10 @@ class SshProtocol(Manhole, session.Session):
|
|||
# handle arguments
|
||||
options = kwargs.get("options", {})
|
||||
flags = self.protocol_flags
|
||||
xterm256 = options.get("xterm256", flags.get('XTERM256', False) if flags.get("TTYPE") else True)
|
||||
useansi = options.get("ansi", flags.get('ANSI', False) if flags.get("TTYPE") else True)
|
||||
xterm256 = options.get("xterm256", flags.get('XTERM256', True))
|
||||
useansi = options.get("ansi", flags.get('ANSI', True))
|
||||
raw = options.get("raw", flags.get("RAW", False))
|
||||
nomarkup = options.get("nomarkup", flags.get("NOMARKUP", not (xterm256 or useansi)))
|
||||
nocolor = options.get("nocolor", flags.get("NOCOLOR") or not (xterm256 or useansi))
|
||||
#echo = options.get("echo", None)
|
||||
screenreader = options.get("screenreader", flags.get("SCREENREADER", False))
|
||||
|
||||
|
|
@ -284,7 +283,7 @@ class SshProtocol(Manhole, session.Session):
|
|||
else:
|
||||
# we need to make sure to kill the color at the end in order
|
||||
# to match the webclient output.
|
||||
linetosend = ansi.parse_ansi(_RE_N.sub("", text) + "{n", strip_ansi=nomarkup, xterm256=xterm256, mxp=False)
|
||||
linetosend = ansi.parse_ansi(_RE_N.sub("", text) + "{n", strip_ansi=nocolor, xterm256=xterm256, mxp=False)
|
||||
self.sendLine(linetosend)
|
||||
|
||||
def send_prompt(self, *args, **kwargs):
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
|||
- ansi: Enforce no ANSI colors.
|
||||
- xterm256: Enforce xterm256 colors, regardless of TTYPE.
|
||||
- noxterm256: Enforce no xterm256 color support, regardless of TTYPE.
|
||||
- nomarkup: Strip all ANSI markup. This is the same as noxterm256,noansi
|
||||
- nocolor: Strip all Color, regardless of ansi/xterm256 setting.
|
||||
- raw: Pass string through without any ansi processing
|
||||
(i.e. include Evennia ansi markers but do not
|
||||
convert them into ansi tokens)
|
||||
|
|
@ -294,7 +294,7 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
|||
xterm256 = options.get("xterm256", flags.get('XTERM256', False) if flags["TTYPE"] else True)
|
||||
useansi = options.get("ansi", flags.get('ANSI', False) if flags["TTYPE"] else True)
|
||||
raw = options.get("raw", flags.get("RAW", False))
|
||||
nomarkup = options.get("nomarkup", flags.get("NOMARKUP", not (xterm256 or useansi)))
|
||||
nocolor = options.get("nocolor", flags.get("NOCOLOR") or not (xterm256 or useansi))
|
||||
echo = options.get("echo", None)
|
||||
mxp = options.get("mxp", flags.get("MXP", False))
|
||||
screenreader = options.get("screenreader", flags.get("SCREENREADER", False))
|
||||
|
|
@ -308,7 +308,7 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
|||
# send a prompt instead.
|
||||
if not raw:
|
||||
# processing
|
||||
prompt = ansi.parse_ansi(_RE_N.sub("", text) + "{n", strip_ansi=nomarkup, xterm256=xterm256)
|
||||
prompt = ansi.parse_ansi(_RE_N.sub("", text) + "{n", strip_ansi=nocolor, xterm256=xterm256)
|
||||
if mxp:
|
||||
prompt = mxp_parse(prompt)
|
||||
prompt = prompt.replace(IAC, IAC + IAC).replace('\n', '\r\n')
|
||||
|
|
@ -335,7 +335,7 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
|||
else:
|
||||
# we need to make sure to kill the color at the end in order
|
||||
# to match the webclient output.
|
||||
linetosend = ansi.parse_ansi(_RE_N.sub("", text) + "{n", strip_ansi=nomarkup, xterm256=xterm256, mxp=mxp)
|
||||
linetosend = ansi.parse_ansi(_RE_N.sub("", text) + "{n", strip_ansi=nocolor, xterm256=xterm256, mxp=mxp)
|
||||
if mxp:
|
||||
linetosend = mxp_parse(linetosend)
|
||||
self.sendLine(linetosend)
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ class WebSocketClient(Protocol, Session):
|
|||
Kwargs:
|
||||
options (dict): Options-dict with the following keys understood:
|
||||
- raw (bool): No parsing at all (leave ansi-to-html markers unparsed).
|
||||
- nomarkup (bool): Clean out all ansi/html markers and tokens.
|
||||
- nocolor (bool): Clean out all color.
|
||||
- screenreader (bool): Use Screenreader mode.
|
||||
- send_prompt (bool): Send a prompt with parsed html
|
||||
|
||||
|
|
@ -182,7 +182,7 @@ class WebSocketClient(Protocol, Session):
|
|||
|
||||
options = kwargs.pop("options", {})
|
||||
raw = options.get("raw", flags.get("RAW", False))
|
||||
nomarkup = options.get("nomarkup", flags.get("NOMARKUP", False))
|
||||
nocolor = options.get("nocolor", flags.get("NOCOLOR", False))
|
||||
screenreader = options.get("screenreader", flags.get("SCREENREADER", False))
|
||||
prompt = options.get("send_prompt", False)
|
||||
|
||||
|
|
@ -194,7 +194,7 @@ class WebSocketClient(Protocol, Session):
|
|||
if raw:
|
||||
args[0] = text
|
||||
else:
|
||||
args[0] = parse_html(text, strip_ansi=nomarkup)
|
||||
args[0] = parse_html(text, strip_ansi=nocolor)
|
||||
|
||||
# send to client on required form [cmdname, args, kwargs]
|
||||
self.sendLine(json.dumps([cmd, args, kwargs]))
|
||||
|
|
|
|||
|
|
@ -325,7 +325,7 @@ class WebClientSession(session.Session):
|
|||
Kwargs:
|
||||
options (dict): Options-dict with the following keys understood:
|
||||
- raw (bool): No parsing at all (leave ansi-to-html markers unparsed).
|
||||
- nomarkup (bool): Clean out all ansi/html markers and tokens.
|
||||
- nocolor (bool): Remove all color.
|
||||
- screenreader (bool): Use Screenreader mode.
|
||||
- send_prompt (bool): Send a prompt with parsed html
|
||||
|
||||
|
|
@ -343,7 +343,9 @@ class WebClientSession(session.Session):
|
|||
|
||||
options = kwargs.pop("options", {})
|
||||
raw = options.get("raw", flags.get("RAW", False))
|
||||
nomarkup = options.get("nomarkup", flags.get("NOMARKUP", False))
|
||||
xterm256 = options.get("xterm256", flags.get('XTERM256', True))
|
||||
useansi = options.get("ansi", flags.get('ANSI', True))
|
||||
nocolor = options.get("nocolor", flags.get("NOCOLOR") or not (xterm256 or useansi))
|
||||
screenreader = options.get("screenreader", flags.get("SCREENREADER", False))
|
||||
prompt = options.get("send_prompt", False)
|
||||
|
||||
|
|
@ -355,7 +357,7 @@ class WebClientSession(session.Session):
|
|||
if raw:
|
||||
args[0] = text
|
||||
else:
|
||||
args[0] = parse_html(text, strip_ansi=nomarkup)
|
||||
args[0] = parse_html(text, strip_ansi=nocolor)
|
||||
|
||||
# send to client on required form [cmdname, args, kwargs]
|
||||
self.client.lineSend(self.csessid, [cmd, args, kwargs])
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class Session(object):
|
|||
"SCREENREADER":False,
|
||||
"INPUTDEBUG": False,
|
||||
"RAW": False,
|
||||
"NOMARKUP": False}
|
||||
"NOCOLOR": False}
|
||||
self.server_data = {}
|
||||
|
||||
# map of input data to session methods
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue