accept non-ascii characters in chat; adapt to new ratuil textinput
This commit is contained in:
parent
a8598a309f
commit
ee6f83b073
|
@ -55,13 +55,10 @@ class InputHandler:
|
|||
self.showString()
|
||||
|
||||
def showString(self):
|
||||
self.client.display.setInputString(self.string, self.cursor if self.typing else -1)
|
||||
self.client.display.setInputString(self.string, self.cursor if self.typing else None)
|
||||
|
||||
def addKey(self, key):
|
||||
if key in string.printable:
|
||||
self.string = self.string[:self.cursor] + key + self.string[self.cursor:]
|
||||
self.cursor += 1
|
||||
elif key == inp.BACKSPACE:
|
||||
if key == inp.BACKSPACE:
|
||||
self.string = self.string[:self.cursor-1] + self.string[self.cursor:]
|
||||
self.cursor = max(self.cursor - 1, 0)
|
||||
elif key == inp.RIGHT:
|
||||
|
@ -90,6 +87,9 @@ class InputHandler:
|
|||
elif key == "^I": # tab
|
||||
# return to game but keep entered string
|
||||
self.typing = False
|
||||
elif key.isprintable():
|
||||
self.string = self.string[:self.cursor] + key + self.string[self.cursor:]
|
||||
self.cursor += len(key)
|
||||
|
||||
self.showString()
|
||||
|
||||
|
|
|
@ -60,9 +60,10 @@ class NameMessage(ClientToServerMessage):
|
|||
assert isinstance(name, str), InvalidNameError("name must be a string")
|
||||
assert (len(name) > 0), InvalidNameError("name needs at least one character")
|
||||
assert (len(bytes(name, "utf-8")) <= 256), InvalidNameError("name may not be longer than 256 utf8 bytes")
|
||||
for char in name if name[0] != "~" else name[1:]:
|
||||
category = unicodedata.category(char)
|
||||
assert category in self.categories, InvalidNameError("all name caracters must be in these unicode categories: " + "|".join(self.categories) + " (except the tilde in a tildename)")
|
||||
if name[0] != "~":
|
||||
for char in name:
|
||||
category = unicodedata.category(char)
|
||||
assert category in self.categories, InvalidNameError("all name caracters must be in these unicode categories: " + "|".join(self.categories) + " (except for tildenames)")
|
||||
self.name = name
|
||||
|
||||
def body(self):
|
||||
|
|
|
@ -30,6 +30,8 @@ def main(argv=None):
|
|||
|
||||
args = parser.parse_args(argv)
|
||||
socketargs = args.socket
|
||||
if socketargs is None:
|
||||
socketargs = []
|
||||
if len(socketargs) == 0:
|
||||
socketargs.append(["abstract", "asciifarm"])
|
||||
|
||||
|
|
Loading…
Reference in New Issue