diff options
Diffstat (limited to 'cursed.py')
| -rw-r--r-- | cursed.py | 33 |
1 files changed, 17 insertions, 16 deletions
@@ -3,32 +3,33 @@ import asyncio import sys class Console(): - def __init__(self, stdscr): - self.stdscr = stdscr + def __init__(self): + self.stdscr = curses.initscr() def __enter__(self): print("ENTER") curses.noecho() curses.cbreak() self.stdscr.keypad(True) + print("Enter färdig") - def __exit__(self, _a, _b, _c): + def __exit__(self, *_): + print("EXIT") curses.nocbreak() self.stdscr.keypad(False) curses.echo() curses.endwin() -async def start(on_str, on_tab): - stdscr = curses.initscr() - with Console(stdscr) as _: - string = "" - while True: - char = await asyncio.to_thread(stdscr.getkey) - if char == '\n': - await on_str(string) - string = "" - elif char == '\t': - await on_tab() - else: - string += char +async def start(c, on_str, on_tab): + print("start") + string = "" + while True: + char = await asyncio.to_thread(c.stdscr.getkey) + if char == '\n': + await on_str(string) + string = "" + elif char == '\t': + await on_tab() + else: + string += char |
