summaryrefslogtreecommitdiffstats
path: root/cursed.py
diff options
context:
space:
mode:
Diffstat (limited to 'cursed.py')
-rw-r--r--cursed.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/cursed.py b/cursed.py
index e63f44f..5259408 100644
--- a/cursed.py
+++ b/cursed.py
@@ -18,25 +18,24 @@ class Console():
curses.echo()
curses.endwin()
+ def redraw(self, messages):
+ self.stdscr.clear()
+ for msg in messages:
+ self.stdscr.addstr(msg + '\n')
+ self.stdscr.refresh()
+
async def start(c, on_str, on_tab, messages):
string = ""
- redraw(c.stdscr, messages)
+ c.redraw(messages)
while True:
char = await asyncio.to_thread(c.stdscr.getkey)
if char == '\n' and string != "":
await on_str(string)
messages.append(string)
- redraw(c.stdscr, messages)
+ c.redraw(messages)
string = ""
elif char == '\t':
await on_tab()
else:
string += char
-
-
-def redraw(stdscr, messages):
- stdscr.clear()
- for msg in messages:
- stdscr.addstr(msg + '\n')
- stdscr.refresh()