diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-03-08 16:31:54 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2021-03-08 16:32:08 +0100 |
| commit | d61433662e548ab2f2318fdd251c92f6259ebc3e (patch) | |
| tree | 6c8e9b15e54631300f63901fbde80b8f22417ce7 /cursed.py | |
| parent | 786485190e2e9373c707f8baa86fb4292f13b2fb (diff) | |
| download | tg-d61433662e548ab2f2318fdd251c92f6259ebc3e.tar.gz | |
refresh on redraw and move redraw to Console
Diffstat (limited to 'cursed.py')
| -rw-r--r-- | cursed.py | 17 |
1 files changed, 8 insertions, 9 deletions
@@ -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() |
