Implemented xterm256 colours. If not supported by client, converts to normal ANSI, as per kaViir's snippet. Integrates into Evennia's normal ansi parser and collaborates with TTYPE protocol to determine if the client supports it.
This commit is contained in:
parent
fb78758356
commit
4cd80284c9
6 changed files with 194 additions and 146 deletions
|
|
@ -36,9 +36,11 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
|||
|
||||
# negotiate mssp (crawler communication)
|
||||
self.mssp = mssp.Mssp(self)
|
||||
|
||||
# add us to sessionhandler
|
||||
self.sessionhandler.connect(self)
|
||||
|
||||
# add this new connection to sessionhandler so
|
||||
# the Server becomes aware of it.
|
||||
self.sessionhandler.connect(self)
|
||||
|
||||
|
||||
def enableRemote(self, option):
|
||||
"""
|
||||
|
|
@ -137,8 +139,10 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
|||
string = utils.to_str(string, encoding=self.encoding)
|
||||
except Exception, e:
|
||||
self.sendLine(str(e))
|
||||
return
|
||||
nomarkup = False
|
||||
return
|
||||
xterm256 = self.protocol_flags.get('TTYPE', {}).get('256 COLORS')
|
||||
nomarkup = not (xterm256 or not self.protocol_flags.get('TTYPE')
|
||||
or self.protocol_flags.get('TTYPE', {}).get('ANSI'))
|
||||
raw = False
|
||||
if type(data) == dict:
|
||||
# check if we want escape codes to go through unparsed.
|
||||
|
|
@ -147,5 +151,5 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
|||
nomarkup = data.get("nomarkup", False)
|
||||
if raw:
|
||||
self.sendLine(string)
|
||||
else:
|
||||
self.sendLine(ansi.parse_ansi(string, strip_ansi=nomarkup))
|
||||
else:
|
||||
self.sendLine(ansi.parse_ansi(string, strip_ansi=nomarkup, xterm256=xterm256))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue