#37 don't resize except initial and font change
authorKevin Lamonte <kevin.lamonte@gmail.com>
Sun, 11 Aug 2019 18:17:28 +0000 (13:17 -0500)
committerKevin Lamonte <kevin.lamonte@gmail.com>
Sun, 11 Aug 2019 18:17:28 +0000 (13:17 -0500)
src/jexer/backend/SwingTerminal.java

index f5d15447b37eca234bd460476a088cdfa94a41b8..d32cf1ed248ba59a87ce5299b83c4413cc69b798 100644 (file)
@@ -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<Cell, BufferedImage>();
             glyphCache = new HashMap<Cell, BufferedImage>();
-            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);
     }
 
     /**