From: Kevin Lamonte Date: Thu, 17 Aug 2017 13:05:23 +0000 (-0400) Subject: #18 repaint after screen resize X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=85c07c5e6db3a5e74f5ba2bd6e7ee2656d5b63a0;p=fanfix-jexer.git #18 repaint after screen resize --- diff --git a/src/jexer/TApplication.java b/src/jexer/TApplication.java index 105f1ce..cedb631 100644 --- a/src/jexer/TApplication.java +++ b/src/jexer/TApplication.java @@ -1030,6 +1030,8 @@ public class TApplication implements Runnable { desktop.setDimensions(0, 0, resize.getWidth(), resize.getHeight() - 1); } + // We are dirty, redraw the screen. + doRepaint(); return; } diff --git a/src/jexer/backend/ECMA48Terminal.java b/src/jexer/backend/ECMA48Terminal.java index ea99a0b..56c2c7c 100644 --- a/src/jexer/backend/ECMA48Terminal.java +++ b/src/jexer/backend/ECMA48Terminal.java @@ -1107,9 +1107,18 @@ public final class ECMA48Terminal extends LogicalScreen 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, @@ -1870,14 +1879,27 @@ public final class ECMA48Terminal extends LogicalScreen // 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; @@ -1907,16 +1929,16 @@ public final class ECMA48Terminal extends LogicalScreen 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) { diff --git a/src/jexer/backend/TTYSessionInfo.java b/src/jexer/backend/TTYSessionInfo.java index 22d5314..67b2e5c 100644 --- a/src/jexer/backend/TTYSessionInfo.java +++ b/src/jexer/backend/TTYSessionInfo.java @@ -183,8 +183,9 @@ public final class TTYSessionInfo implements SessionInfo { lastQueryWindowTime = System.currentTimeMillis(); } else { long nowTime = System.currentTimeMillis(); - if (nowTime - lastQueryWindowTime < 3000) { - // Don't re-spawn stty, it's been too soon. + if (nowTime - lastQueryWindowTime < 1000) { + // Don't re-spawn stty if it hasn't been a full second since + // the last time. return; } }