}
}
+ /**
+ * Constructor sets up state for getEvent().
+ *
+ * @param listener the object this backend needs to wake up when new
+ * input comes in
+ * @param input an InputStream connected to the remote user, or null for
+ * System.in. If System.in is used, then on non-Windows systems it will
+ * be put in raw mode; shutdown() will (blindly!) put System.in in cooked
+ * mode. input is always converted to a Reader with UTF-8 encoding.
+ * @param output an OutputStream connected to the remote user, or null
+ * for System.out. output is always converted to a Writer with UTF-8
+ * encoding.
+ * @param windowWidth the number of text columns to start with
+ * @param windowHeight the number of text rows to start with
+ * @throws UnsupportedEncodingException if an exception is thrown when
+ * creating the InputStreamReader
+ */
+ public ECMA48Terminal(final Object listener, final InputStream input,
+ final OutputStream output, final int windowWidth,
+ final int windowHeight) throws UnsupportedEncodingException {
+
+ this(listener, input, output);
+
+ // Send dtterm/xterm sequences, which will probably not work because
+ // allowWindowOps is defaulted to false.
+ String resizeString = String.format("\033[8;%d;%dt", windowHeight,
+ windowWidth);
+ this.output.write(resizeString);
+ this.output.flush();
+ }
+
/**
* Constructor sets up state for getEvent().
*
sessionInfo.queryWindowSize();
int newWidth = sessionInfo.getWindowWidth();
int newHeight = sessionInfo.getWindowHeight();
+
if ((newWidth != windowResize.getWidth())
|| (newHeight != windowResize.getHeight())
) {
+
+ if (debugToStderr) {
+ System.err.println("Screen size changed, old size " +
+ windowResize);
+ System.err.println(" new size " +
+ newWidth + " x " + newHeight);
+ }
+
TResizeEvent event = new TResizeEvent(TResizeEvent.Type.SCREEN,
newWidth, newHeight);
windowResize = new TResizeEvent(TResizeEvent.Type.SCREEN,
// We assume that if inputStream has bytes available, then
// input won't block on read().
int n = inputStream.available();
+
+ /*
+ System.err.printf("inputStream.available(): %d\n", n);
+ System.err.flush();
+ */
+
if (n > 0) {
if (readBuffer.length < n) {
// The buffer wasn't big enough, make it huger
readBuffer = new char[readBuffer.length * 2];
}
+ // System.err.printf("BEFORE read()\n"); System.err.flush();
+
int rc = input.read(readBuffer, 0, readBuffer.length);
- // System.err.printf("read() %d", rc); System.err.flush();
+
+ /*
+ System.err.printf("AFTER read() %d\n", rc);
+ System.err.flush();
+ */
+
if (rc == -1) {
// This is EOF
done = true;
synchronized (eventQueue) {
eventQueue.addAll(events);
}
- events.clear();
if (listener != null) {
synchronized (listener) {
listener.notifyAll();
}
}
+ events.clear();
}
- // Wait 10 millis for more data
- Thread.sleep(10);
+ // Wait 20 millis for more data
+ Thread.sleep(20);
}
// System.err.println("end while loop"); System.err.flush();
} catch (InterruptedException e) {