diff --git a/evennia/commands/default/account.py b/evennia/commands/default/account.py index f51b079e17..1185648d01 100644 --- a/evennia/commands/default/account.py +++ b/evennia/commands/default/account.py @@ -636,6 +636,11 @@ class CmdOption(COMMAND_DEFAULT_CLASS): self.msg(f"Option |w{new_name}|n was kept as '|w{old_val}|n'.") else: 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( f"Option |w{new_name}|n was changed from '|w{old_val}|n' to" f" '|w{new_val}|n'." @@ -658,6 +663,7 @@ class CmdOption(COMMAND_DEFAULT_CLASS): "RAW": validate_bool, "SCREENHEIGHT": validate_size, "SCREENWIDTH": validate_size, + "AUTORESIZE": validate_bool, "SCREENREADER": validate_bool, "TERM": utils.to_str, "UTF-8": validate_bool, diff --git a/evennia/server/inputfuncs.py b/evennia/server/inputfuncs.py index ee60643059..d30b06d4a5 100644 --- a/evennia/server/inputfuncs.py +++ b/evennia/server/inputfuncs.py @@ -175,6 +175,7 @@ _CLIENT_OPTIONS = ( "MCCP", "SCREENHEIGHT", "SCREENWIDTH", + "AUTORESIZE", "INPUTDEBUG", "RAW", "NOCOLOR", @@ -201,6 +202,7 @@ def client_options(session, *args, **kwargs): mccp (bool): MCCP compression on/off screenheight (int): Screen height in lines screenwidth (int): Screen width in characters + autoresize (bool): Use NAWS updates to dynamically adjust format inputdebug (bool): Debug input functions nocolor (bool): Strip color raw (bool): Turn off parsing @@ -256,6 +258,8 @@ def client_options(session, *args, **kwargs): flags["SCREENHEIGHT"] = validate_size(value) elif key == "screenwidth": flags["SCREENWIDTH"] = validate_size(value) + elif key == "autoresize": + flags["AUTORESIZE"] = validate_size(value) elif key == "inputdebug": flags["INPUTDEBUG"] = validate_bool(value) elif key == "nocolor": diff --git a/evennia/server/portal/naws.py b/evennia/server/portal/naws.py index b4498e71ea..71d3a75352 100644 --- a/evennia/server/portal/naws.py +++ b/evennia/server/portal/naws.py @@ -58,6 +58,7 @@ class Naws: option (Option): Not used. """ + self.protocol.protocol_flags["AUTORESIZE"] = False self.protocol.handshake_done() def do_naws(self, option): @@ -68,6 +69,7 @@ class Naws: option (Option): Not used. """ + self.protocol.protocol_flags["AUTORESIZE"] = True self.protocol.handshake_done() def negotiate_sizes(self, options): diff --git a/evennia/server/portal/portalsessionhandler.py b/evennia/server/portal/portalsessionhandler.py index cb118893c1..cd2c231258 100644 --- a/evennia/server/portal/portalsessionhandler.py +++ b/evennia/server/portal/portalsessionhandler.py @@ -467,7 +467,7 @@ class PortalSessionHandler(SessionHandler): kwargs (any): Each key is a command instruction to the protocol on the form key = [[args],{kwargs}]. This will call a method send_ on the protocol. If no such - method exixts, it sends the data to a method send_default. + method exits, it sends the data to a method send_default. """ # from evennia.server.profiling.timetrace import timetrace # DEBUG diff --git a/evennia/server/portal/telnet.py b/evennia/server/portal/telnet.py index cb577f3835..b545e67f7e 100644 --- a/evennia/server/portal/telnet.py +++ b/evennia/server/portal/telnet.py @@ -31,6 +31,7 @@ from twisted.internet.task import LoopingCall from evennia.server.portal import mssp, naws, suppress_ga, telnet_oob, ttype from evennia.server.portal.mccp import MCCP, Mccp, mccp_compress from evennia.server.portal.mxp import Mxp, mxp_parse +from evennia.server.portal.naws import NAWS from evennia.utils import ansi from evennia.utils.utils import class_from_module, to_bytes @@ -91,8 +92,14 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, _BASE_SESSION_CLASS): of incoming data. """ - # print(f"telnet dataReceived: {data}") try: + # Do we have a NAWS update? + 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)) + super().dataReceived(data) except ValueError as err: from evennia.utils import logger diff --git a/evennia/server/serversession.py b/evennia/server/serversession.py index e1573b37c0..4f76960592 100644 --- a/evennia/server/serversession.py +++ b/evennia/server/serversession.py @@ -269,7 +269,7 @@ class ServerSession(_BASE_SESSION_CLASS): Notes: Since protocols can vary, no checking is done - as to the existene of the flag or not. The input + as to the existence of the flag or not. The input data should have been validated before this call. """