- public void getEvents(final List<TInputEvent> queue, final int timeout) {
- if (timeout > 0) {
- // Try to sleep, let the terminal's input thread wake me up if
- // something came in.
- synchronized (terminal) {
- try {
- terminal.wait(timeout);
- if (terminal.hasEvents()) {
- // System.err.println("getEvents()");
- terminal.getEvents(queue);
- } else {
- // If I got here, then I timed out. Call
- // terminal.getIdleEvents() to pick up stragglers
- // like bare resize.
- // System.err.println("getIdleEvents()");
- terminal.getIdleEvents(queue);
- }
- } catch (InterruptedException e) {
- // Spurious interrupt, pretend it was like a timeout.
- // System.err.println("[interrupt] getEvents()");
- terminal.getIdleEvents(queue);
- }
- }
- } else {
- // Asking for a poll, go get it.
- // System.err.println("[polled] getEvents()");