X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fbackend%2FLogicalScreen.java;h=c24703e7a23098740804f5be8f4873b27ceb1324;hb=d36057dfab8def933a64be042b039d76708ac5ba;hp=c9b025abb257cb260f1ecff0f62a97e792d4caef;hpb=eb29bbb5ec70c43895dd0f053630c7e3cd402cba;p=fanfix.git diff --git a/src/jexer/backend/LogicalScreen.java b/src/jexer/backend/LogicalScreen.java index c9b025a..c24703e 100644 --- a/src/jexer/backend/LogicalScreen.java +++ b/src/jexer/backend/LogicalScreen.java @@ -37,6 +37,10 @@ import jexer.bits.GraphicsChars; */ public class LogicalScreen implements Screen { + // ------------------------------------------------------------------------ + // Variables -------------------------------------------------------------- + // ------------------------------------------------------------------------ + /** * Width of the visible window. */ @@ -52,6 +56,84 @@ public class LogicalScreen implements Screen { */ private int offsetX; + /** + * Drawing offset for y. + */ + private int offsetY; + + /** + * Ignore anything drawn right of clipRight. + */ + private int clipRight; + + /** + * Ignore anything drawn below clipBottom. + */ + private int clipBottom; + + /** + * Ignore anything drawn left of clipLeft. + */ + private int clipLeft; + + /** + * Ignore anything drawn above clipTop. + */ + private int clipTop; + + /** + * The physical screen last sent out on flush(). + */ + protected Cell [][] physical; + + /** + * The logical screen being rendered to. + */ + protected Cell [][] logical; + + /** + * Set if the user explicitly wants to redraw everything starting with a + * ECMATerminal.clearAll(). + */ + protected boolean reallyCleared; + + /** + * If true, the cursor is visible and should be placed onscreen at + * (cursorX, cursorY) during a call to flushPhysical(). + */ + protected boolean cursorVisible; + + /** + * Cursor X position if visible. + */ + protected int cursorX; + + /** + * Cursor Y position if visible. + */ + protected int cursorY; + + // ------------------------------------------------------------------------ + // Constructors ----------------------------------------------------------- + // ------------------------------------------------------------------------ + + /** + * Public constructor. Sets everything to not-bold, white-on-black. + */ + protected LogicalScreen() { + offsetX = 0; + offsetY = 0; + width = 80; + height = 24; + logical = null; + physical = null; + reallocate(width, height); + } + + // ------------------------------------------------------------------------ + // Screen ----------------------------------------------------------------- + // ------------------------------------------------------------------------ + /** * Set drawing offset for x. * @@ -61,11 +143,6 @@ public class LogicalScreen implements Screen { this.offsetX = offsetX; } - /** - * Drawing offset for y. - */ - private int offsetY; - /** * Set drawing offset for y. * @@ -75,11 +152,6 @@ public class LogicalScreen implements Screen { this.offsetY = offsetY; } - /** - * Ignore anything drawn right of clipRight. - */ - private int clipRight; - /** * Get right drawing clipping boundary. * @@ -98,11 +170,6 @@ public class LogicalScreen implements Screen { this.clipRight = clipRight; } - /** - * Ignore anything drawn below clipBottom. - */ - private int clipBottom; - /** * Get bottom drawing clipping boundary. * @@ -121,11 +188,6 @@ public class LogicalScreen implements Screen { this.clipBottom = clipBottom; } - /** - * Ignore anything drawn left of clipLeft. - */ - private int clipLeft; - /** * Get left drawing clipping boundary. * @@ -144,11 +206,6 @@ public class LogicalScreen implements Screen { this.clipLeft = clipLeft; } - /** - * Ignore anything drawn above clipTop. - */ - private int clipTop; - /** * Get top drawing clipping boundary. * @@ -167,16 +224,6 @@ public class LogicalScreen implements Screen { this.clipTop = clipTop; } - /** - * The physical screen last sent out on flush(). - */ - protected Cell [][] physical; - - /** - * The logical screen being rendered to. - */ - protected Cell [][] logical; - /** * Get dirty flag. * @@ -200,28 +247,6 @@ public class LogicalScreen implements Screen { return false; } - /** - * Set if the user explicitly wants to redraw everything starting with a - * ECMATerminal.clearAll(). - */ - protected boolean reallyCleared; - - /** - * If true, the cursor is visible and should be placed onscreen at - * (cursorX, cursorY) during a call to flushPhysical(). - */ - protected boolean cursorVisible; - - /** - * Cursor X position if visible. - */ - protected int cursorX; - - /** - * Cursor Y position if visible. - */ - protected int cursorY; - /** * Get the attributes at one location. * @@ -491,50 +516,6 @@ public class LogicalScreen implements Screen { } } - /** - * Reallocate screen buffers. - * - * @param width new width - * @param height new height - */ - private synchronized void reallocate(final int width, final int height) { - if (logical != null) { - for (int row = 0; row < this.height; row++) { - for (int col = 0; col < this.width; col++) { - logical[col][row] = null; - } - } - logical = null; - } - logical = new Cell[width][height]; - if (physical != null) { - for (int row = 0; row < this.height; row++) { - for (int col = 0; col < this.width; col++) { - physical[col][row] = null; - } - } - physical = null; - } - physical = new Cell[width][height]; - - for (int row = 0; row < height; row++) { - for (int col = 0; col < width; col++) { - physical[col][row] = new Cell(); - logical[col][row] = new Cell(); - } - } - - this.width = width; - this.height = height; - - clipLeft = 0; - clipTop = 0; - clipRight = width; - clipBottom = height; - - reallyCleared = true; - } - /** * Change the width. Everything on-screen will be destroyed and must be * redrawn. @@ -584,19 +565,6 @@ public class LogicalScreen implements Screen { return this.width; } - /** - * Public constructor. Sets everything to not-bold, white-on-black. - */ - protected LogicalScreen() { - offsetX = 0; - offsetY = 0; - width = 80; - height = 24; - logical = null; - physical = null; - reallocate(width, height); - } - /** * Reset screen to not-bold, white-on-black. Also flushes the offset and * clip variables. @@ -629,17 +597,6 @@ public class LogicalScreen implements Screen { reset(); } - /** - * Clear the physical screen. - */ - public final void clearPhysical() { - for (int row = 0; row < height; row++) { - for (int col = 0; col < width; col++) { - physical[col][row].reset(); - } - } - } - /** * Draw a box with a border and empty background. * @@ -852,4 +809,63 @@ public class LogicalScreen implements Screen { */ public void setTitle(final String title) {} + // ------------------------------------------------------------------------ + // LogicalScreen ---------------------------------------------------------- + // ------------------------------------------------------------------------ + + /** + * Reallocate screen buffers. + * + * @param width new width + * @param height new height + */ + private synchronized void reallocate(final int width, final int height) { + if (logical != null) { + for (int row = 0; row < this.height; row++) { + for (int col = 0; col < this.width; col++) { + logical[col][row] = null; + } + } + logical = null; + } + logical = new Cell[width][height]; + if (physical != null) { + for (int row = 0; row < this.height; row++) { + for (int col = 0; col < this.width; col++) { + physical[col][row] = null; + } + } + physical = null; + } + physical = new Cell[width][height]; + + for (int row = 0; row < height; row++) { + for (int col = 0; col < width; col++) { + physical[col][row] = new Cell(); + logical[col][row] = new Cell(); + } + } + + this.width = width; + this.height = height; + + clipLeft = 0; + clipTop = 0; + clipRight = width; + clipBottom = height; + + reallyCleared = true; + } + + /** + * Clear the physical screen. + */ + public final void clearPhysical() { + for (int row = 0; row < height; row++) { + for (int col = 0; col < width; col++) { + physical[col][row].reset(); + } + } + } + }