X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fbackend%2FECMA48Terminal.java;h=ca1d499594734c75275a53f90a7f5fb8aa9f9a56;hb=9f613a0c54cb97e9305fd87ce8eb2f76ac82804e;hp=dfc3edbe8a528633db9e2dfdd62e2a75ac29cba2;hpb=fa535516b7a3aeb9aedc90bac9a5bfcc9abcb17f;p=fanfix.git diff --git a/src/jexer/backend/ECMA48Terminal.java b/src/jexer/backend/ECMA48Terminal.java index dfc3edb..ca1d499 100644 --- a/src/jexer/backend/ECMA48Terminal.java +++ b/src/jexer/backend/ECMA48Terminal.java @@ -1002,7 +1002,8 @@ public class ECMA48Terminal extends LogicalScreen // ------------------------------------------------------------------------ /** - * Constructor sets up state for getEvent(). + * Constructor sets up state for getEvent(). If either windowWidth or + * windowHeight are less than 1, the terminal is not resized. * * @param listener the object this backend needs to wake up when new * input comes in @@ -1026,10 +1027,12 @@ public class ECMA48Terminal extends LogicalScreen // Send dtterm/xterm sequences, which will probably not work because // allowWindowOps is defaulted to false. - String resizeString = String.format("\033[8;%d;%dt", windowHeight, - windowWidth); - this.output.write(resizeString); - this.output.flush(); + if ((windowWidth > 0) && (windowHeight > 0)) { + String resizeString = String.format("\033[8;%d;%dt", windowHeight, + windowWidth); + this.output.write(resizeString); + this.output.flush(); + } } /** @@ -2851,14 +2854,32 @@ public class ECMA48Terminal extends LogicalScreen int [] rgbArray; for (int i = 0; i < cells.size() - 1; i++) { - if (cells.get(i).isInvertedImage()) { + int tileWidth = Math.min(cells.get(i).getImage().getWidth(), + imageWidth); + int tileHeight = Math.min(cells.get(i).getImage().getHeight(), + imageHeight); + if (false && cells.get(i).isInvertedImage()) { + // I used to put an all-white cell over the cursor, don't do + // that anymore. rgbArray = new int[imageWidth * imageHeight]; for (int j = 0; j < rgbArray.length; j++) { rgbArray[j] = 0xFFFFFF; } } else { - rgbArray = cells.get(i).getImage().getRGB(0, 0, - imageWidth, imageHeight, null, 0, imageWidth); + try { + rgbArray = cells.get(i).getImage().getRGB(0, 0, + tileWidth, tileHeight, null, 0, tileWidth); + } catch (Exception e) { + throw new RuntimeException("image " + imageWidth + "x" + + imageHeight + + "tile " + tileWidth + "x" + + tileHeight + + " cells.get(i).getImage() " + + cells.get(i).getImage() + + " i " + i + + " fullWidth " + fullWidth + + " fullHeight " + fullHeight, e); + } } /* @@ -2869,9 +2890,9 @@ public class ECMA48Terminal extends LogicalScreen fullWidth, fullHeight, cells.size(), getTextWidth()); */ - image.setRGB(i * imageWidth, 0, imageWidth, imageHeight, - rgbArray, 0, imageWidth); - if (imageHeight < fullHeight) { + image.setRGB(i * imageWidth, 0, tileWidth, tileHeight, + rgbArray, 0, tileWidth); + if (tileHeight < fullHeight) { int backgroundColor = cells.get(i).getBackground().getRGB(); for (int imageX = 0; imageX < image.getWidth(); imageX++) { for (int imageY = imageHeight; imageY < fullHeight; @@ -2883,14 +2904,22 @@ public class ECMA48Terminal extends LogicalScreen } } totalWidth -= ((cells.size() - 1) * imageWidth); - if (cells.get(cells.size() - 1).isInvertedImage()) { + if (false && cells.get(cells.size() - 1).isInvertedImage()) { + // I used to put an all-white cell over the cursor, don't do that + // anymore. rgbArray = new int[totalWidth * imageHeight]; for (int j = 0; j < rgbArray.length; j++) { rgbArray[j] = 0xFFFFFF; } } else { - rgbArray = cells.get(cells.size() - 1).getImage().getRGB(0, 0, - totalWidth, imageHeight, null, 0, totalWidth); + try { + rgbArray = cells.get(cells.size() - 1).getImage().getRGB(0, 0, + totalWidth, imageHeight, null, 0, totalWidth); + } catch (Exception e) { + throw new RuntimeException("image " + imageWidth + "x" + + imageHeight + " cells.get(cells.size() - 1).getImage() " + + cells.get(cells.size() - 1).getImage(), e); + } } image.setRGB((cells.size() - 1) * imageWidth, 0, totalWidth, imageHeight, rgbArray, 0, totalWidth); @@ -2994,6 +3023,7 @@ public class ECMA48Terminal extends LogicalScreen assert (data >= 0); assert (data < 64); data += 63; + if (data == oldData) { oldDataCount++; } else { @@ -3006,6 +3036,7 @@ public class ECMA48Terminal extends LogicalScreen oldDataCount = 1; oldData = data; } + } // for (int imageX = 0; imageX < image.getWidth(); imageX++) // Emit the last sequence.