سؤال

How can I make my Ruby application do nothing and continue if Curses.getch takes too long (over x amount of milliseconds) to respond?

Example:

case Curses.getch
  when ?a (do stuff)
  when ?s (do stuff)
  etc.
  when takesTooLong (do nothing)
end

I want the application to continue if the user does not press a key in the specified amount of time.

How can I do this? I thought about doing a sleep after the Curses.getch, but the sleep would execute after the user presses a key.

هل كانت مفيدة؟

المحلول

Use Curses::timeout=, Doorknob.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top