- @Override
- 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);
- } catch (InterruptedException e) {
- // Spurious interrupt, pretend it was like a timeout.
- // System.err.println("[interrupt] getEvents()");
- }
- if (terminal.hasEvents()) {
- // System.err.println("getEvents()");
- terminal.getEvents(queue);
- }
- }
- } else {
- // Asking for a poll, go get it.
- // System.err.println("[polled] getEvents()");
- terminal.getEvents(queue);
- }
+ public ECMA48Backend(final Object listener, final InputStream input,
+ final Reader reader, final PrintWriter writer,
+ final boolean setRawMode) {
+
+ // Create a terminal and explicitly set stdin into raw mode
+ terminal = new ECMA48Terminal(listener, input, reader, writer,
+ setRawMode);
+
+ // Keep the terminal's sessionInfo so that TApplication can see it
+ sessionInfo = ((ECMA48Terminal) terminal).getSessionInfo();
+
+ // ECMA48Terminal is the screen too
+ screen = (ECMA48Terminal) terminal;