From: Kevin Lamonte Date: Sun, 4 Aug 2019 19:22:58 +0000 (-0500) Subject: Remove timage list X-Git-Url: http://git.nikiroo.be/?a=commitdiff_plain;h=e6469faa3f6895ec0ff9b7592a7348a321898b71;p=fanfix.git Remove timage list --- diff --git a/src/jexer/TApplication.java b/src/jexer/TApplication.java index 658e50b..83dbd25 100644 --- a/src/jexer/TApplication.java +++ b/src/jexer/TApplication.java @@ -283,11 +283,6 @@ public class TApplication implements Runnable { */ private boolean focusFollowsMouse = false; - /** - * The images that might be displayed. Note package private access. - */ - private List images; - /** * The list of commands to run before the next I/O check. */ @@ -606,7 +601,6 @@ public class TApplication implements Runnable { accelerators = new HashMap(); menuItems = new LinkedList(); desktop = new TDesktop(this); - images = new LinkedList(); // Special case: the Swing backend needs to have a timer to drive its // blink state. @@ -1617,7 +1611,7 @@ public class TApplication implements Runnable { getScreen().putCharXY(oldDrawnMouseX, oldDrawnMouseY, oldDrawnMouseCell); oldDrawnMouseCell = getScreen().getCharXY(mouseX, mouseY); - if ((images.size() > 0) && (backend instanceof ECMA48Backend)) { + if (backend instanceof ECMA48Backend) { // Special case: the entire row containing the mouse has // to be re-drawn if it has any image data, AND any rows // in between. @@ -1644,7 +1638,7 @@ public class TApplication implements Runnable { oldDrawnMouseX = mouseX; oldDrawnMouseY = mouseY; } - if ((images.size() > 0) || getScreen().isDirty()) { + if (getScreen().isDirty()) { backend.flushScreen(); } return; @@ -1746,7 +1740,7 @@ public class TApplication implements Runnable { oldDrawnMouseX, oldDrawnMouseY); } oldDrawnMouseCell = getScreen().getCharXY(mouseX, mouseY); - if ((images.size() > 0) && (backend instanceof ECMA48Backend)) { + if (backend instanceof ECMA48Backend) { // Special case: the entire row containing the mouse has to be // re-drawn if it has any image data, AND any rows in between. if (oldDrawnMouseY != mouseY) { @@ -1797,7 +1791,7 @@ public class TApplication implements Runnable { } // Flush the screen contents - if ((images.size() > 0) || getScreen().isDirty()) { + if (getScreen().isDirty()) { if (debugThreads) { System.err.printf("%d %s backend.flushScreen()\n", System.currentTimeMillis(), Thread.currentThread()); @@ -2529,46 +2523,6 @@ public class TApplication implements Runnable { window.setY(windowY); } - // ------------------------------------------------------------------------ - // TImage management ------------------------------------------------------ - // ------------------------------------------------------------------------ - - /** - * Add an image to the list. Note package private access. - * - * @param image the image to add - * @throws IllegalArgumentException if the image is already used in - * another TApplication - */ - final void addImage(final TImage image) { - if ((image.getApplication() != null) - && (image.getApplication() != this) - ) { - throw new IllegalArgumentException("Image " + image + - " is already " + "part of application " + - image.getApplication()); - } - images.add(image); - } - - /** - * Remove an image from the list. Note package private access. - * - * @param image the image to remove - * @throws IllegalArgumentException if the image is already used in - * another TApplication - */ - final void removeImage(final TImage image) { - if ((image.getApplication() != null) - && (image.getApplication() != this) - ) { - throw new IllegalArgumentException("Image " + image + - " is already " + "part of application " + - image.getApplication()); - } - images.remove(image); - } - // ------------------------------------------------------------------------ // TMenu management ------------------------------------------------------- // ------------------------------------------------------------------------ diff --git a/src/jexer/TImage.java b/src/jexer/TImage.java index d170707..c3e75be 100644 --- a/src/jexer/TImage.java +++ b/src/jexer/TImage.java @@ -202,24 +202,12 @@ public class TImage extends TWidget { this.clickAction = clickAction; sizeToImage(true); - - getApplication().addImage(this); } // ------------------------------------------------------------------------ // Event handlers --------------------------------------------------------- // ------------------------------------------------------------------------ - /** - * Subclasses should override this method to cleanup resources. This is - * called by TWindow.onClose(). - */ - @Override - protected void close() { - getApplication().removeImage(this); - super.close(); - } - /** * Handle mouse press events. * diff --git a/src/jexer/backend/ECMA48Terminal.java b/src/jexer/backend/ECMA48Terminal.java index dfc3edb..39ca236 100644 --- a/src/jexer/backend/ECMA48Terminal.java +++ b/src/jexer/backend/ECMA48Terminal.java @@ -2994,6 +2994,7 @@ public class ECMA48Terminal extends LogicalScreen assert (data >= 0); assert (data < 64); data += 63; + if (data == oldData) { oldDataCount++; } else { @@ -3006,6 +3007,7 @@ public class ECMA48Terminal extends LogicalScreen oldDataCount = 1; oldData = data; } + } // for (int imageX = 0; imageX < image.getWidth(); imageX++) // Emit the last sequence. diff --git a/src/jexer/tterminal/Sixel.java b/src/jexer/tterminal/Sixel.java index de3232c..6a10b7a 100644 --- a/src/jexer/tterminal/Sixel.java +++ b/src/jexer/tterminal/Sixel.java @@ -247,6 +247,12 @@ public class Sixel { */ private void addSixel(final char ch) { int n = ((int) ch - 63); + + if (DEBUG && (color == null)) { + System.err.println("color is null?!"); + System.err.println(buffer); + } + int rgb = color.getRGB(); int rep = (repeatCount == -1 ? 1 : repeatCount); @@ -311,7 +317,10 @@ public class Sixel { if (newColor != null) { color = newColor; } else { - System.err.println("COLOR " + idx + " NOT FOUND"); + if (DEBUG) { + System.err.println("COLOR " + idx + " NOT FOUND"); + } + color = Color.BLACK; } if (DEBUG) {