diff options
| author | troido <troido@hotmail.com> | 2018-04-19 00:10:47 +0200 |
|---|---|---|
| committer | troido <troido@hotmail.com> | 2018-04-19 00:10:47 +0200 |
| commit | e03f6096b3fdd75575ff12a2bc98205b8069b043 (patch) | |
| tree | cca413207c6bbd837e8690ad23f56e713ebef895 /asciifarm/client/inputhandler.py | |
| parent | 1bf981b4836dc7d48535fcfcdf0d1a4e6d8ffb84 (diff) | |
tab now returns to game keeping entered string; / starts string with text /
Diffstat (limited to 'asciifarm/client/inputhandler.py')
| -rw-r--r-- | asciifarm/client/inputhandler.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/asciifarm/client/inputhandler.py b/asciifarm/client/inputhandler.py index 5296f9d..1db594d 100644 --- a/asciifarm/client/inputhandler.py +++ b/asciifarm/client/inputhandler.py @@ -41,8 +41,12 @@ class InputHandler: else: self.commandHandler.chat(message) - def startTyping(self): + def startTyping(self, startText=""): self.typing = True + if startText and not self.string: + self.string = startText + self.cursor = len(self.string) + self.showString() def showString(self): @@ -67,15 +71,20 @@ class InputHandler: self.cursor = len(self.string) elif key == curses.ascii.ESC or key == curses.KEY_DL: + # throw away entered string and go back to game self.typing = False self.string = "" self.cursor = 0 elif key == curses.ascii.LF or key == curses.ascii.CR: + # process entered string and reset it message = self.string self.string = "" self.cursor = 0 self.typing = False self.processString(message) + elif key == curses.ascii.TAB: + # return to game but keep entered string + self.typing = False self.showString() |
