X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fbackend%2FLogicalScreen.java;h=4e7971eaf71fce92b4fa61e32e6d3288ef05aaa4;hb=be72cb5ccbd42fe304c0acafc380c5636f0d03a2;hp=bfe1c7226700df9993d0dd25010b13ebe9c7e54f;hpb=f6d9020703931f645f553b59426e085a81e90c60;p=fanfix.git diff --git a/src/jexer/backend/LogicalScreen.java b/src/jexer/backend/LogicalScreen.java index bfe1c72..4e7971e 100644 --- a/src/jexer/backend/LogicalScreen.java +++ b/src/jexer/backend/LogicalScreen.java @@ -177,11 +177,6 @@ public class LogicalScreen implements Screen { */ protected Cell [][] logical; - /** - * When true, logical != physical. - */ - protected volatile boolean dirty; - /** * Get dirty flag. * @@ -189,7 +184,20 @@ public class LogicalScreen implements Screen { * screen */ public final boolean isDirty() { - return dirty; + for (int x = 0; x < width; x++) { + for (int y = 0; y < height; y++) { + if (!logical[x][y].equals(physical[x][y])) { + return true; + } + if (logical[x][y].isBlink()) { + // Blinking screens are always dirty. There is + // opportunity for a Netscape blink tag joke here... + return true; + } + } + } + + return false; } /** @@ -284,14 +292,7 @@ public class LogicalScreen implements Screen { } if ((X >= 0) && (X < width) && (Y >= 0) && (Y < height)) { - dirty = true; - logical[X][Y].setForeColor(attr.getForeColor()); - logical[X][Y].setBackColor(attr.getBackColor()); - logical[X][Y].setBold(attr.isBold()); - logical[X][Y].setBlink(attr.isBlink()); - logical[X][Y].setReverse(attr.isReverse()); - logical[X][Y].setUnderline(attr.isUnderline()); - logical[X][Y].setProtect(attr.isProtect()); + logical[X][Y].setTo(attr); } } @@ -346,20 +347,13 @@ public class LogicalScreen implements Screen { // System.err.printf("putCharXY: %d, %d, %c\n", X, Y, ch); if ((X >= 0) && (X < width) && (Y >= 0) && (Y < height)) { - dirty = true; // Do not put control characters on the display assert (ch >= 0x20); assert (ch != 0x7F); + logical[X][Y].setTo(attr); logical[X][Y].setChar(ch); - logical[X][Y].setForeColor(attr.getForeColor()); - logical[X][Y].setBackColor(attr.getBackColor()); - logical[X][Y].setBold(attr.isBold()); - logical[X][Y].setBlink(attr.isBlink()); - logical[X][Y].setReverse(attr.isReverse()); - logical[X][Y].setUnderline(attr.isUnderline()); - logical[X][Y].setProtect(attr.isProtect()); } } @@ -386,7 +380,6 @@ public class LogicalScreen implements Screen { // System.err.printf("putCharXY: %d, %d, %c\n", X, Y, ch); if ((X >= 0) && (X < width) && (Y >= 0) && (Y < height)) { - dirty = true; logical[X][Y].setChar(ch); } } @@ -510,7 +503,6 @@ public class LogicalScreen implements Screen { clipBottom = height; reallyCleared = true; - dirty = true; } /** @@ -580,7 +572,6 @@ public class LogicalScreen implements Screen { * clip variables. */ public final synchronized void reset() { - dirty = true; for (int row = 0; row < height; row++) { for (int col = 0; col < width; col++) { logical[col][row].reset(); @@ -612,7 +603,6 @@ public class LogicalScreen implements Screen { * Clear the physical screen. */ public final void clearPhysical() { - dirty = true; for (int row = 0; row < height; row++) { for (int col = 0; col < width; col++) { physical[col][row].reset(); @@ -773,6 +763,18 @@ public class LogicalScreen implements Screen { * @param y row coordinate to put the cursor on */ public void putCursor(final boolean visible, final int x, final int y) { + if ((cursorY >= 0) + && (cursorX >= 0) + && (cursorY <= height - 1) + && (cursorX <= width - 1) + ) { + // Make the current cursor position dirty + if (physical[cursorX][cursorY].getChar() == 'Q') { + physical[cursorX][cursorY].setChar('X'); + } else { + physical[cursorX][cursorY].setChar('Q'); + } + } cursorVisible = visible; cursorX = x;