import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
import java.util.LinkedList;
* physical screen
*/
private String flushString() {
- if (!dirty) {
- assert (!reallyCleared);
- return "";
- }
-
CellAttributes attr = null;
StringBuilder sb = new StringBuilder();
flushLine(y, sb, attr);
}
- dirty = false;
reallyCleared = false;
String result = sb.toString();
public void flushPhysical() {
String result = flushString();
if ((cursorVisible)
+ && (cursorY >= 0)
+ && (cursorX >= 0)
&& (cursorY <= height - 1)
&& (cursorX <= width - 1)
) {
* @param queue list to append new events to
*/
private void getIdleEvents(final List<TInputEvent> queue) {
- Date now = new Date();
+ long nowTime = System.currentTimeMillis();
// Check for new window size
- long windowSizeDelay = now.getTime() - windowSizeTime;
+ long windowSizeDelay = nowTime - windowSizeTime;
if (windowSizeDelay > 1000) {
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,
newWidth, newHeight);
queue.add(event);
}
- windowSizeTime = now.getTime();
+ windowSizeTime = nowTime;
}
// ESCDELAY type timeout
if (state == ParseState.ESCAPE) {
- long escDelay = now.getTime() - escapeTime;
+ long escDelay = nowTime - escapeTime;
if (escDelay > 100) {
// After 0.1 seconds, assume a true escape character
queue.add(controlChar((char)0x1B, false));
private void processChar(final List<TInputEvent> events, final char ch) {
// ESCDELAY type timeout
- Date now = new Date();
+ long nowTime = System.currentTimeMillis();
if (state == ParseState.ESCAPE) {
- long escDelay = now.getTime() - escapeTime;
+ long escDelay = nowTime - escapeTime;
if (escDelay > 250) {
// After 0.25 seconds, assume a true escape character
events.add(controlChar((char)0x1B, false));
if (ch == 0x1B) {
state = ParseState.ESCAPE;
- escapeTime = now.getTime();
+ escapeTime = nowTime;
return;
}
// 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) {