-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
An equivalent of curses.flushinp
#254
Comments
Actually, |
@jquast Any thoughts on this? |
I think we disagree, here! I think this default behavior is best :)
flushinp would be trivial to implement as a loop by calling import blessed, time
def flushinp(t):
gathered = []
while toss := t.inkey(timeout=0):
gathered.append(toss)
return gathered
t = blessed.Terminal()
print('Go ahead, type some input, Ill wait for 3 seconds')
with t.raw():
time.sleep(3)
gathered = flushinp(t)
print("\r\nHere's what I flushed", gathered)
print("\r\nNow... press any key to exit")
t.inkey() We could implement that as method Terminal.flushinp() (or as keyword argument flush=True to inkey, if you rather), if it is helpful to avoid importing curses. But I just wanted to show it is also very easy to do with the inkey method, using timeout=0 argument. |
I really like the game, by the way !!! |
Oh, cool. I didn't think of that. Thanks. I think adding a
Glad to hear it! I hope to make the first playable release around the end of the month. |
I'm making good progress on a game using blessed, but I noticed that keys pressed while an animation is playing (i.e. during
time.sleep
) or during slow processing will be queued up for delivery by the nextTerminal.inkey
, instead ofinkey
blocking for a new key as intended. I can prevent this by callingcurses.flushinp()
before eachinkey
. Perhaps blessed should have an equivalent offlushinp
, as its own method or as a parameter ofinkey
.The text was updated successfully, but these errors were encountered: