summaryrefslogtreecommitdiffstats
path: root/cursed.py
diff options
context:
space:
mode:
Diffstat (limited to 'cursed.py')
-rw-r--r--cursed.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/cursed.py b/cursed.py
index 905b457..e07ea05 100644
--- a/cursed.py
+++ b/cursed.py
@@ -1,11 +1,13 @@
import curses
import asyncio
+import sys
class Console():
def __init__(self, stdscr):
self.stdscr = stdscr
def __enter__(self):
+ print("ENTER")
curses.noecho()
curses.cbreak()
self.stdscr.keypad(True)
@@ -17,16 +19,16 @@ class Console():
curses.endwin()
-def start(on_str, on_tab):
+async def start(on_str, on_tab):
stdscr = curses.initscr()
with Console(stdscr) as _:
string = ""
while True:
- char = stdscr.getkey()
+ char = await asyncio.to_thread(stdscr.getkey)
if char == '\n':
- on_str(string)
+ await on_str(string)
string = ""
elif char == '\t':
- on_tab()
+ await on_tab()
else:
string += char