From b4570a63cef669dc85335a7f8d571a5eefdfc3c7 Mon Sep 17 00:00:00 2001 From: Kevin Lamonte Date: Sun, 11 Aug 2019 13:17:28 -0500 Subject: [PATCH] #37 don't resize except initial and font change --- src/jexer/backend/SwingTerminal.java | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/jexer/backend/SwingTerminal.java b/src/jexer/backend/SwingTerminal.java index f5d15447..d32cf1ed 100644 --- a/src/jexer/backend/SwingTerminal.java +++ b/src/jexer/backend/SwingTerminal.java @@ -403,7 +403,7 @@ public class SwingTerminal extends LogicalScreen SwingTerminal.this.setDimensions(sessionInfo. getWindowWidth(), sessionInfo.getWindowHeight()); - SwingTerminal.this.resizeToScreen(); + SwingTerminal.this.resizeToScreen(true); SwingTerminal.this.swing.setVisible(true); } }); @@ -572,8 +572,8 @@ public class SwingTerminal extends LogicalScreen && (swing.getBufferStrategy() != null) ) { do { - clearPhysical(); do { + clearPhysical(); drawToSwing(); } while (swing.getBufferStrategy().contentsRestored()); @@ -761,7 +761,7 @@ public class SwingTerminal extends LogicalScreen swing.setFont(font); glyphCacheBlink = new HashMap(); glyphCache = new HashMap(); - resizeToScreen(); + resizeToScreen(true); } } @@ -1110,13 +1110,24 @@ public class SwingTerminal extends LogicalScreen gotFontDimensions = true; } + /** + * Resize the physical screen to match the logical screen dimensions. + * + * @param resizeComponent if true, resize the Swing component + */ + private void resizeToScreen(final boolean resizeComponent) { + if (resizeComponent) { + swing.setDimensions(textWidth * width, textHeight * height); + } + clearPhysical(); + } + /** * Resize the physical screen to match the logical screen dimensions. */ @Override public void resizeToScreen() { - swing.setDimensions(textWidth * width, textHeight * height); - clearPhysical(); + resizeToScreen(false); } /** -- 2.27.0