Move prompt logic to a flag set by TTYPE (for Mudlet, currently)
This commit is contained in:
parent
9099796258
commit
c209a9b8ef
4 changed files with 8 additions and 2 deletions
|
|
@ -40,6 +40,7 @@ class SuppressGA(object):
|
||||||
self.protocol = protocol
|
self.protocol = protocol
|
||||||
|
|
||||||
self.protocol.protocol_flags["NOGOAHEAD"] = True
|
self.protocol.protocol_flags["NOGOAHEAD"] = True
|
||||||
|
self.protocol.protocol_flags["NOPROMPTGOAHEAD"] = True # Used to send a GA after a prompt line only, set in TTYPE (per client)
|
||||||
# tell the client that we prefer to suppress GA ...
|
# tell the client that we prefer to suppress GA ...
|
||||||
self.protocol.will(SUPPRESS_GA).addCallbacks(self.will_suppress_ga, self.wont_suppress_ga)
|
self.protocol.will(SUPPRESS_GA).addCallbacks(self.will_suppress_ga, self.wont_suppress_ga)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -337,6 +337,8 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
||||||
line = line.replace(b"\n", b"\r\n")
|
line = line.replace(b"\n", b"\r\n")
|
||||||
if not line.endswith(b"\r\n") and self.protocol_flags.get("FORCEDENDLINE", True):
|
if not line.endswith(b"\r\n") and self.protocol_flags.get("FORCEDENDLINE", True):
|
||||||
line += b"\r\n"
|
line += b"\r\n"
|
||||||
|
if not self.protocol_flags.get("NOGOAHEAD", True) and self.protocol_flags.get("NOPROMPTGOAHEAD", True):
|
||||||
|
line += IAC + GA
|
||||||
return self.transport.write(mccp_compress(self, line))
|
return self.transport.write(mccp_compress(self, line))
|
||||||
|
|
||||||
# Session hooks
|
# Session hooks
|
||||||
|
|
@ -438,8 +440,8 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
||||||
prompt = mxp_parse(prompt)
|
prompt = mxp_parse(prompt)
|
||||||
prompt = to_bytes(prompt, self)
|
prompt = to_bytes(prompt, self)
|
||||||
prompt = prompt.replace(IAC, IAC + IAC).replace(b"\n", b"\r\n")
|
prompt = prompt.replace(IAC, IAC + IAC).replace(b"\n", b"\r\n")
|
||||||
if not self.protocol_flags.get("NOGOAHEAD", True):
|
if not self.protocol_flags.get("NOGOAHEAD", True) and not self.protocol_flags.get("NOPROMPTGOAHEAD", True):
|
||||||
prompt += IAC + GA
|
prompt += IAC + GA
|
||||||
self.transport.write(mccp_compress(self, prompt))
|
self.transport.write(mccp_compress(self, prompt))
|
||||||
else:
|
else:
|
||||||
if echo is not None:
|
if echo is not None:
|
||||||
|
|
|
||||||
|
|
@ -252,6 +252,7 @@ class TestTelnet(TwistedTestCase):
|
||||||
self.assertTrue(self.proto.protocol_flags["XTERM256"])
|
self.assertTrue(self.proto.protocol_flags["XTERM256"])
|
||||||
self.assertEqual(self.proto.protocol_flags["CLIENTNAME"], "MUDLET")
|
self.assertEqual(self.proto.protocol_flags["CLIENTNAME"], "MUDLET")
|
||||||
self.assertTrue(self.proto.protocol_flags["FORCEDENDLINE"])
|
self.assertTrue(self.proto.protocol_flags["FORCEDENDLINE"])
|
||||||
|
self.assertFalse(self.proto.protocol_flags["NOPROMPTGOAHEAD"])
|
||||||
self.proto.dataReceived(b"".join([IAC, SB, TTYPE, IS, b"XTERM", IAC, SE]))
|
self.proto.dataReceived(b"".join([IAC, SB, TTYPE, IS, b"XTERM", IAC, SE]))
|
||||||
self.proto.dataReceived(b"".join([IAC, SB, TTYPE, IS, b"MTTS 137", IAC, SE]))
|
self.proto.dataReceived(b"".join([IAC, SB, TTYPE, IS, b"MTTS 137", IAC, SE]))
|
||||||
self.assertEqual(self.proto.handshakes, 5)
|
self.assertEqual(self.proto.handshakes, 5)
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,8 @@ class Ttype(object):
|
||||||
if clientname.startswith("MUDLET"):
|
if clientname.startswith("MUDLET"):
|
||||||
# supports xterm256 stably since 1.1 (2010?)
|
# supports xterm256 stably since 1.1 (2010?)
|
||||||
xterm256 = clientname.split("MUDLET", 1)[1].strip() >= "1.1"
|
xterm256 = clientname.split("MUDLET", 1)[1].strip() >= "1.1"
|
||||||
|
# Mudlet likes GA's on a prompt line for the prompt trigger to match.
|
||||||
|
self.protocol.protocol_flags["NOPROMPTGOAHEAD"] = False
|
||||||
|
|
||||||
if (
|
if (
|
||||||
clientname.startswith("XTERM")
|
clientname.startswith("XTERM")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue