also check for text cell size
[fanfix.git] / src / jexer / backend / ECMA48Terminal.java
index 44c4038935fc4ba6976ecb3726e8b53baa1abb26..9884835591adba9cfa57530cca3759ee8fb6404e 100644 (file)
@@ -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";
     }
 
     /**
@@ -3643,7 +3666,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 +3675,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.
      *