diff options
Diffstat (limited to 'cursed.py')
| -rw-r--r-- | cursed.py | 33 |
1 files changed, 16 insertions, 17 deletions
@@ -28,21 +28,20 @@ class Console(): self.stdscr.addstr(self.typed_message) self.stdscr.refresh() - -async def start(c, on_str, on_tab): - while True: - c.redraw() - char = await asyncio.to_thread(c.stdscr.get_wch) - if isinstance(char, str): - if char == '\n': - if c.typed_message != "": - await on_str(c.typed_message) - c.messages.append(c.typed_message) - c.typed_message = "" - elif char == '\t': - await on_tab() + async def start(self, on_str, on_tab): + while True: + self.redraw() + char = await asyncio.to_thread(self.stdscr.get_wch) + if isinstance(char, str): + if char == '\n': + if self.typed_message != "": + await on_str(self.typed_message) + self.messages.append(self.typed_message) + self.typed_message = "" + elif char == '\t': + await on_tab() + else: + self.typed_message += char else: - c.typed_message += char - else: - if char == 263: - c.typed_message = c.typed_message[:-1] + if char == 263: + self.typed_message = self.typed_message[:-1] |
