refactor, sixel performance
[fanfix.git] / src / jexer / backend / LogicalScreen.java
index b7648313d0d15513584dddf4659f42a841e8f47e..513c599145440e8a9682ef5c764b8e5d650e9c29 100644 (file)
@@ -134,6 +134,26 @@ public class LogicalScreen implements Screen {
     // Screen -----------------------------------------------------------------
     // ------------------------------------------------------------------------
 
+    /**
+     * Get the width of a character cell in pixels.
+     *
+     * @return the width in pixels of a character cell
+     */
+    public int getTextWidth() {
+        // Default width is 16 pixels.
+        return 16;
+    }
+
+    /**
+     * Get the height of a character cell in pixels.
+     *
+     * @return the height in pixels of a character cell
+     */
+    public int getTextHeight() {
+        // Default height is 20 pixels.
+        return 20;
+    }
+
     /**
      * Set drawing offset for x.
      *
@@ -564,6 +584,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 +917,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();