Converted encoding setting to use protocol_flags rather than being stored on-session. Also renamed the 256 COLORS TTYPE setting to XTERM256 which is more accurate (and doesn't have a space)
This commit is contained in:
parent
1ddfbca7ea
commit
11ecdef7c8
8 changed files with 39 additions and 29 deletions
|
|
@ -401,12 +401,19 @@ class CmdOption(MuxPlayerCommand):
|
|||
|
||||
if not self.args:
|
||||
# list the option settings
|
||||
string = "{wEncoding{n:\n"
|
||||
pencoding = self.session.encoding or "None"
|
||||
sencodings = settings.ENCODINGS
|
||||
string += " Custom: %s\n Server: %s" % (pencoding, ", ".join(sencodings))
|
||||
string += "\n{wScreen Reader mode:{n %s" % self.session.protocol_flags.get("SCREENREADER", False)
|
||||
self.msg(string)
|
||||
flags = self.session.protocol_flags
|
||||
keys = sorted(flags)
|
||||
options = "\n".join(" {w%s{n: %s" % (key, flags[key]) for key in keys)
|
||||
self.msg("{wClient settings:\n%s" % options)
|
||||
#string = "{wEncoding{n:\n"
|
||||
#pencoding = flags.get("ENCODING", "None")
|
||||
#sencodings = settings.ENCODINGS
|
||||
#string += " Custom: %s\n Server: %s" % (pencoding, ", ".join(sencodings))
|
||||
#string += "\n{wScreen Reader mode:{n %s" % flags.get("SCREENREADER", False)
|
||||
## display all
|
||||
#keys =
|
||||
#string += "\n{wClient settings (read-only):\n%s" % options
|
||||
#self.msg(string)
|
||||
return
|
||||
|
||||
if not self.rhs:
|
||||
|
|
@ -417,14 +424,14 @@ class CmdOption(MuxPlayerCommand):
|
|||
|
||||
if self.lhs == "encoding":
|
||||
# change encoding
|
||||
old_encoding = self.session.encoding
|
||||
old_encoding = self.session.protocol_flags["ENCODING"]
|
||||
new_encoding = self.rhs.strip() or "utf-8"
|
||||
try:
|
||||
utils.to_str(utils.to_unicode("test-string"), encoding=new_encoding)
|
||||
except LookupError:
|
||||
string = "|rThe encoding '|w%s|r' is invalid. Keeping the previous encoding '|w%s|r'.|n" % (new_encoding, old_encoding)
|
||||
else:
|
||||
self.session.encoding = new_encoding
|
||||
self.session.protocol_flags["ENCODING"] = new_encoding
|
||||
string = "Encoding was changed from '|w%s|n' to '|w%s|n'." % (old_encoding, new_encoding)
|
||||
self.msg(string)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -459,17 +459,19 @@ class CmdUnconnectedEncoding(MuxCommand):
|
|||
if self.session is None:
|
||||
return
|
||||
|
||||
sync = False
|
||||
if 'clear' in self.switches:
|
||||
# remove customization
|
||||
old_encoding = self.session.encoding
|
||||
old_encoding = self.session.protocol_flags.get("ENCODING", None)
|
||||
if old_encoding:
|
||||
string = "Your custom text encoding ('%s') was cleared." % old_encoding
|
||||
else:
|
||||
string = "No custom encoding was set."
|
||||
self.session.encoding = "utf-8"
|
||||
self.session.protocol_flags["ENCODING"] = "utf-8"
|
||||
sync = True
|
||||
elif not self.args:
|
||||
# just list the encodings supported
|
||||
pencoding = self.session.encoding
|
||||
pencoding = self.session.protocol_flags.get("ENCODING", None)
|
||||
string = ""
|
||||
if pencoding:
|
||||
string += "Default encoding: {g%s{n (change with {w@encoding <encoding>{n)" % pencoding
|
||||
|
|
@ -480,15 +482,18 @@ class CmdUnconnectedEncoding(MuxCommand):
|
|||
string = "No encodings found."
|
||||
else:
|
||||
# change encoding
|
||||
old_encoding = self.session.encoding
|
||||
old_encoding = self.session.protocol_flags.get("ENCODING", None)
|
||||
encoding = self.args
|
||||
try:
|
||||
utils.to_str(utils.to_unicode("test-string"), encoding=encoding)
|
||||
except LookupError:
|
||||
string = "|rThe encoding '|w%s|r' is invalid. Keeping the previous encoding '|w%s|r'.|n" % (encoding, old_encoding)
|
||||
else:
|
||||
self.session.encoding = encoding
|
||||
self.session.protocol_flags["ENCODING"] = encoding
|
||||
string = "Your custom text encoding was changed from '|w%s|n' to '|w%s|n'." % (old_encoding, encoding)
|
||||
sync = True
|
||||
if sync:
|
||||
self.session.sessionhandler.session_portal_sync(self.session)
|
||||
self.caller.msg(string.strip())
|
||||
|
||||
class CmdUnconnectedScreenreader(MuxCommand):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue