Added a new flag in the options/protocol_flags to ignore or follow NAWS updates.
This commit is contained in:
parent
8011750931
commit
c94b7f47c1
4 changed files with 17 additions and 1 deletions
|
|
@ -635,6 +635,11 @@ class CmdOption(COMMAND_DEFAULT_CLASS):
|
||||||
self.msg(f"Option |w{new_name}|n was kept as '|w{old_val}|n'.")
|
self.msg(f"Option |w{new_name}|n was kept as '|w{old_val}|n'.")
|
||||||
else:
|
else:
|
||||||
flags[new_name] = new_val
|
flags[new_name] = new_val
|
||||||
|
|
||||||
|
# If we're manually assign a display size, turn off auto-resizing
|
||||||
|
if new_name in ['SCREENWIDTH', 'SCREENHEIGHT']:
|
||||||
|
flags['AUTORESIZE'] = False
|
||||||
|
|
||||||
self.msg(
|
self.msg(
|
||||||
f"Option |w{new_name}|n was changed from '|w{old_val}|n' to"
|
f"Option |w{new_name}|n was changed from '|w{old_val}|n' to"
|
||||||
f" '|w{new_val}|n'."
|
f" '|w{new_val}|n'."
|
||||||
|
|
@ -657,6 +662,7 @@ class CmdOption(COMMAND_DEFAULT_CLASS):
|
||||||
"RAW": validate_bool,
|
"RAW": validate_bool,
|
||||||
"SCREENHEIGHT": validate_size,
|
"SCREENHEIGHT": validate_size,
|
||||||
"SCREENWIDTH": validate_size,
|
"SCREENWIDTH": validate_size,
|
||||||
|
"AUTORESIZE": validate_bool,
|
||||||
"SCREENREADER": validate_bool,
|
"SCREENREADER": validate_bool,
|
||||||
"TERM": utils.to_str,
|
"TERM": utils.to_str,
|
||||||
"UTF-8": validate_bool,
|
"UTF-8": validate_bool,
|
||||||
|
|
|
||||||
|
|
@ -175,6 +175,7 @@ _CLIENT_OPTIONS = (
|
||||||
"MCCP",
|
"MCCP",
|
||||||
"SCREENHEIGHT",
|
"SCREENHEIGHT",
|
||||||
"SCREENWIDTH",
|
"SCREENWIDTH",
|
||||||
|
"AUTORESIZE",
|
||||||
"INPUTDEBUG",
|
"INPUTDEBUG",
|
||||||
"RAW",
|
"RAW",
|
||||||
"NOCOLOR",
|
"NOCOLOR",
|
||||||
|
|
@ -201,6 +202,7 @@ def client_options(session, *args, **kwargs):
|
||||||
mccp (bool): MCCP compression on/off
|
mccp (bool): MCCP compression on/off
|
||||||
screenheight (int): Screen height in lines
|
screenheight (int): Screen height in lines
|
||||||
screenwidth (int): Screen width in characters
|
screenwidth (int): Screen width in characters
|
||||||
|
autoresize (bool): Use NAWS updates to dynamically adjust format
|
||||||
inputdebug (bool): Debug input functions
|
inputdebug (bool): Debug input functions
|
||||||
nocolor (bool): Strip color
|
nocolor (bool): Strip color
|
||||||
raw (bool): Turn off parsing
|
raw (bool): Turn off parsing
|
||||||
|
|
@ -256,6 +258,8 @@ def client_options(session, *args, **kwargs):
|
||||||
flags["SCREENHEIGHT"] = validate_size(value)
|
flags["SCREENHEIGHT"] = validate_size(value)
|
||||||
elif key == "screenwidth":
|
elif key == "screenwidth":
|
||||||
flags["SCREENWIDTH"] = validate_size(value)
|
flags["SCREENWIDTH"] = validate_size(value)
|
||||||
|
elif key == "autoresize":
|
||||||
|
flags["AUTORESIZE"] = validate_size(value)
|
||||||
elif key == "inputdebug":
|
elif key == "inputdebug":
|
||||||
flags["INPUTDEBUG"] = validate_bool(value)
|
flags["INPUTDEBUG"] = validate_bool(value)
|
||||||
elif key == "nocolor":
|
elif key == "nocolor":
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ class Naws:
|
||||||
option (Option): Not used.
|
option (Option): Not used.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
self.protocol.protocol_flags["AUTORESIZE"] = False
|
||||||
self.protocol.handshake_done()
|
self.protocol.handshake_done()
|
||||||
|
|
||||||
def do_naws(self, option):
|
def do_naws(self, option):
|
||||||
|
|
@ -67,6 +68,7 @@ class Naws:
|
||||||
option (Option): Not used.
|
option (Option): Not used.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
self.protocol.protocol_flags["AUTORESIZE"] = True
|
||||||
self.protocol.handshake_done()
|
self.protocol.handshake_done()
|
||||||
|
|
||||||
def negotiate_sizes(self, options):
|
def negotiate_sizes(self, options):
|
||||||
|
|
|
||||||
|
|
@ -94,8 +94,12 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, _BASE_SESSION_CLASS):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# Do we have a NAWS update?
|
# Do we have a NAWS update?
|
||||||
if NAWS in data and len([data[i:i+1] for i in range(0, len(data))]) == 9:
|
if (NAWS in data and
|
||||||
|
len([data[i:i+1] for i in range(0, len(data))]) == 9 and
|
||||||
|
# Is auto resizing on?
|
||||||
|
self.protocol_flags.get('AUTORESIZE')):
|
||||||
self.sessionhandler.sync(self.sessionhandler.get(self.sessid))
|
self.sessionhandler.sync(self.sessionhandler.get(self.sessid))
|
||||||
|
|
||||||
super().dataReceived(data)
|
super().dataReceived(data)
|
||||||
except ValueError as err:
|
except ValueError as err:
|
||||||
from evennia.utils import logger
|
from evennia.utils import logger
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue