X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fbackend%2FECMA48Terminal.java;h=75c4ce407e4b05e9bcade8af846da8b9bbb6f426;hb=04275552087576ff522598fa7664e01c6a660284;hp=44c4038935fc4ba6976ecb3726e8b53baa1abb26;hpb=d91ac0f5500f66bc9fa2691883e2e3ed3fe84ad7;p=nikiroo-utils.git diff --git a/src/jexer/backend/ECMA48Terminal.java b/src/jexer/backend/ECMA48Terminal.java index 44c4038..75c4ce4 100644 --- a/src/jexer/backend/ECMA48Terminal.java +++ b/src/jexer/backend/ECMA48Terminal.java @@ -1349,7 +1349,7 @@ public class ECMA48Terminal extends LogicalScreen // Disable mouse reporting and show cursor. Defensive null check // here in case closeTerminal() is called twice. if (output != null) { - output.printf("%s%s%s", mouse(false), cursor(true), normal()); + output.printf("%s%s%s", mouse(false), cursor(true), defaultColor()); output.flush(); } @@ -2760,6 +2760,27 @@ public class ECMA48Terminal extends LogicalScreen heightPixels = 400; } } + if ((params.size() > 2) && (params.get(0).equals("6"))) { + if (debugToStderr) { + System.err.printf("windowOp text cell pixels: " + + "height %s width %s\n", + params.get(1), params.get(2)); + } + try { + widthPixels = width * Integer.parseInt(params.get(2)); + heightPixels = height * Integer.parseInt(params.get(1)); + } catch (NumberFormatException e) { + if (debugToStderr) { + e.printStackTrace(); + } + } + if (widthPixels <= 0) { + widthPixels = 640; + } + if (heightPixels <= 0) { + heightPixels = 400; + } + } resetParser(); return; default: @@ -2794,7 +2815,9 @@ public class ECMA48Terminal extends LogicalScreen * @return the string to emit to xterm */ private String xtermReportWindowPixelDimensions() { - return "\033[14t"; + // We will ask for both window and text cell dimensions, and + // hopefully one of them will work. + return "\033[14t\033[16t"; } /** @@ -3060,6 +3083,10 @@ public class ECMA48Terminal extends LogicalScreen } image = palette.ditherImage(image); + // Collect the raster information + int rasterHeight = 0; + int rasterWidth = image.getWidth(); + // Emit the palette, but only for the colors actually used by these // cells. boolean [] usedColors = new boolean[sixelPaletteSize]; @@ -3136,6 +3163,9 @@ public class ECMA48Terminal extends LogicalScreen data += 32; break; } + if ((currentRow + j + 1) > rasterHeight) { + rasterHeight = currentRow + j + 1; + } } } assert (data >= 0); @@ -3175,6 +3205,9 @@ public class ECMA48Terminal extends LogicalScreen // Kill the very last "-", because it is unnecessary. sb.deleteCharAt(sb.length() - 1); + // Add the raster information + sb.insert(0, String.format("\"1;1;%d;%d", rasterWidth, rasterHeight)); + if (saveInCache) { // This row is OK to save into the cache. sixelCache.put(cells, sb.toString()); @@ -3643,7 +3676,7 @@ public class ECMA48Terminal extends LogicalScreen } /** - * Create a SGR parameter sequence to reset to defaults. + * Create a SGR parameter sequence to reset to VT100 defaults. * * @return the string to emit to an ANSI / ECMA-style terminal, * e.g. "\033[0m" @@ -3652,6 +3685,29 @@ public class ECMA48Terminal extends LogicalScreen return normal(true) + rgbColor(false, Color.WHITE, Color.BLACK); } + /** + * Create a SGR parameter sequence to reset to ECMA-48 default + * foreground/background. + * + * @return the string to emit to an ANSI / ECMA-style terminal, + * e.g. "\033[0m" + */ + private String defaultColor() { + /* + * VT100 normal. + * Normal (neither bold nor faint). + * Not italicized. + * Not underlined. + * Steady (not blinking). + * Positive (not inverse). + * Visible (not hidden). + * Not crossed-out. + * Default foreground color. + * Default background color. + */ + return "\033[0;22;23;24;25;27;28;29;39;49m"; + } + /** * Create a SGR parameter sequence to reset to defaults. *