summaryrefslogtreecommitdiff
path: root/asciifarm/client/inputhandler.py
diff options
context:
space:
mode:
authortroido <troido@hotmail.com>2018-04-18 23:59:40 +0200
committertroido <troido@hotmail.com>2018-04-18 23:59:40 +0200
commit1bf981b4836dc7d48535fcfcdf0d1a4e6d8ffb84 (patch)
treecc52a29decf1721002aa27c4b9d144ab40a0b7a0 /asciifarm/client/inputhandler.py
parent757ad925b47d24b1d0714671b8f04147a5748480 (diff)
client can now read strings from chat input
Diffstat (limited to 'asciifarm/client/inputhandler.py')
-rw-r--r--asciifarm/client/inputhandler.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/asciifarm/client/inputhandler.py b/asciifarm/client/inputhandler.py
index 1d907e9..5296f9d 100644
--- a/asciifarm/client/inputhandler.py
+++ b/asciifarm/client/inputhandler.py
@@ -1,8 +1,11 @@
-from commandhandler import CommandHandler
-from .keynames import nameFromKey
import curses
import curses.ascii
+import shlex
+
+from commandhandler import CommandHandler, InvalidCommandException
+from .keynames import nameFromKey
+
class InputHandler:
@@ -38,6 +41,12 @@ class InputHandler:
else:
self.commandHandler.chat(message)
+ def startTyping(self):
+ self.typing = True
+ self.showString()
+
+ def showString(self):
+ self.client.display.setInputString(self.string, self.cursor if self.typing else -1)
def addKey(self, key):
if curses.ascii.isprint(key):
@@ -47,7 +56,7 @@ class InputHandler:
self.string = self.string[:self.cursor-1] + self.string[self.cursor:]
self.cursor = max(self.cursor - 1, 0)
elif key == curses.KEY_RIGHT:
- self.cursor = max(self.cursor + 1, len(self.string))
+ self.cursor = min(self.cursor + 1, len(self.string))
elif key == curses.KEY_LEFT:
self.cursor = max(self.cursor - 1, 0)
elif key == curses.KEY_DC:
@@ -68,6 +77,8 @@ class InputHandler:
self.typing = False
self.processString(message)
+ self.showString()
+