retrofit from gjexer
[fanfix.git] / src / jexer / backend / LogicalScreen.java
index b7648313d0d15513584dddf4659f42a841e8f47e..24ba4aff9f12afeec1b8b0609baf4e733d3a0524 100644 (file)
@@ -564,6 +564,14 @@ public class LogicalScreen implements Screen {
      */
     public final void setDimensions(final int width, final int height) {
         reallocate(width, height);
+        resizeToScreen();
+    }
+
+    /**
+     * Resize the physical screen to match the logical screen dimensions.
+     */
+    public void resizeToScreen() {
+        // Subclasses are expected to override this.
     }
 
     /**
@@ -889,6 +897,9 @@ public class LogicalScreen implements Screen {
      * @param y row coordinate.  0 is the top-most row.
      */
     public final void unsetImageRow(final int y) {
+        if ((y < 0) || (y >= height)) {
+            return;
+        }
         for (int x = 0; x < width; x++) {
             if (logical[x][y].isImage()) {
                 physical[x][y].unset();