X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fbackend%2FSwingTerminal.java;h=b7a16249d49dda32af22bf5f053c8c02e6f99a3e;hb=e8a11f986bfe2556e450d7b8ad6ef0059b369bbc;hp=c2fbfb437eae6b54f43f4b0a497d703b45f0d950;hpb=42873e30bf487bc0b695d60652dba44f82185dbb;p=nikiroo-utils.git diff --git a/src/jexer/backend/SwingTerminal.java b/src/jexer/backend/SwingTerminal.java index c2fbfb4..b7a1624 100644 --- a/src/jexer/backend/SwingTerminal.java +++ b/src/jexer/backend/SwingTerminal.java @@ -500,7 +500,6 @@ public final class SwingTerminal extends LogicalScreen // monospace. textHeight = fm.getMaxAscent() + maxDescent - leading; - // TODO: is this still necessary? if (gotTerminus == true) { textHeight++; } @@ -658,6 +657,16 @@ public final class SwingTerminal extends LogicalScreen } } + /** + * Reset the blink timer. + */ + private void resetBlinkTimer() { + // See if it is time to flip the blink time. + long nowTime = (new Date()).getTime(); + lastBlinkTime = nowTime; + cursorBlinkVisible = true; + } + /** * Paint redraws the whole screen. * @@ -1069,9 +1078,9 @@ public final class SwingTerminal extends LogicalScreen // Pull the system property for triple buffering. if (System.getProperty("jexer.Swing.tripleBuffer") != null) { - if (System.getProperty("jexer.Swing.tripleBuffer"). - equals("false")) { - + if (System.getProperty("jexer.Swing.tripleBuffer").equals("true")) { + SwingComponent.tripleBuffer = true; + } else { SwingComponent.tripleBuffer = false; } } @@ -1142,7 +1151,8 @@ public final class SwingTerminal extends LogicalScreen SwingTerminal.this.sessionInfo = new SwingSessionInfo(SwingTerminal.this.swing, SwingTerminal.this.textWidth, - SwingTerminal.this.textHeight); + SwingTerminal.this.textHeight, + windowWidth, windowHeight); SwingTerminal.this.setDimensions(sessionInfo.getWindowWidth(), sessionInfo.getWindowHeight()); @@ -1171,7 +1181,7 @@ public final class SwingTerminal extends LogicalScreen } /** - * Public constructor creates a new JFrame to render to. + * Public constructor renders to an existing JComponent. * * @param component the Swing component to render to * @param windowWidth the number of text columns to start with @@ -1539,9 +1549,12 @@ public final class SwingTerminal extends LogicalScreen // Save it and we are done. synchronized (eventQueue) { eventQueue.add(new TKeypressEvent(keypress)); + resetBlinkTimer(); } - synchronized (listener) { - listener.notifyAll(); + if (listener != null) { + synchronized (listener) { + listener.notifyAll(); + } } } @@ -1575,9 +1588,12 @@ public final class SwingTerminal extends LogicalScreen // Drop a cmAbort and walk away synchronized (eventQueue) { eventQueue.add(new TCommandEvent(cmAbort)); + resetBlinkTimer(); } - synchronized (listener) { - listener.notifyAll(); + if (listener != null) { + synchronized (listener) { + listener.notifyAll(); + } } } @@ -1663,9 +1679,12 @@ public final class SwingTerminal extends LogicalScreen TResizeEvent windowResize = new TResizeEvent(TResizeEvent.Type.SCREEN, sessionInfo.getWindowWidth(), sessionInfo.getWindowHeight()); eventQueue.add(windowResize); + resetBlinkTimer(); } - synchronized (listener) { - listener.notifyAll(); + if (listener != null) { + synchronized (listener) { + listener.notifyAll(); + } } } @@ -1699,9 +1718,12 @@ public final class SwingTerminal extends LogicalScreen synchronized (eventQueue) { eventQueue.add(mouseEvent); + resetBlinkTimer(); } - synchronized (listener) { - listener.notifyAll(); + if (listener != null) { + synchronized (listener) { + listener.notifyAll(); + } } } @@ -1725,9 +1747,12 @@ public final class SwingTerminal extends LogicalScreen synchronized (eventQueue) { eventQueue.add(mouseEvent); + resetBlinkTimer(); } - synchronized (listener) { - listener.notifyAll(); + if (listener != null) { + synchronized (listener) { + listener.notifyAll(); + } } } @@ -1788,9 +1813,12 @@ public final class SwingTerminal extends LogicalScreen synchronized (eventQueue) { eventQueue.add(mouseEvent); + resetBlinkTimer(); } - synchronized (listener) { - listener.notifyAll(); + if (listener != null) { + synchronized (listener) { + listener.notifyAll(); + } } } @@ -1833,9 +1861,12 @@ public final class SwingTerminal extends LogicalScreen synchronized (eventQueue) { eventQueue.add(mouseEvent); + resetBlinkTimer(); } - synchronized (listener) { - listener.notifyAll(); + if (listener != null) { + synchronized (listener) { + listener.notifyAll(); + } } } @@ -1877,9 +1908,12 @@ public final class SwingTerminal extends LogicalScreen synchronized (eventQueue) { eventQueue.add(mouseEvent); + resetBlinkTimer(); } - synchronized (listener) { - listener.notifyAll(); + if (listener != null) { + synchronized (listener) { + listener.notifyAll(); + } } }