diff options
Diffstat (limited to 'cursed.py')
| -rw-r--r-- | cursed.py | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -1,11 +1,25 @@ import curses +import asyncio +class Console(): + def __init__(self, stdscr): + self.stdscr = stdscr -def start(on_str, on_tab): - def main(stdscr): + def __enter__(self): curses.noecho() curses.cbreak() - stdscr.keypad(True) + self.stdscr.keypad(True) + + def __exit__(self, _a, _b, _c): + curses.nocbreak() + self.stdscr.keypad(False) + curses.echo() + curses.endwin() + + +def start(on_str, on_tab): + stdscr = curses.initscr() + with Console(stdscr) as _: string = "" while True: char = stdscr.getkey() @@ -16,4 +30,3 @@ def start(on_str, on_tab): on_tab() else: string += char - curses.wrapper(main) |
