misc fixes
[fanfix.git] / src / jexer / backend / ECMA48Terminal.java
index 1dc3957d75b534deec2b318a9c2bd501db8d7f5f..2afa81a35500e2a99c17c6500c0b748a5f922926 100644 (file)
@@ -1085,23 +1085,7 @@ public class ECMA48Terminal extends LogicalScreen
         windowResize = new TResizeEvent(TResizeEvent.Type.SCREEN,
             sessionInfo.getWindowWidth(), sessionInfo.getWindowHeight());
 
-        // Permit RGB colors only if externally requested.
-        if (System.getProperty("jexer.ECMA48.rgbColor") != null) {
-            if (System.getProperty("jexer.ECMA48.rgbColor").equals("true")) {
-                doRgbColor = true;
-            } else {
-                doRgbColor = false;
-            }
-        }
-
-        // Pull the system properties for sixel output.
-        if (System.getProperty("jexer.ECMA48.sixel") != null) {
-            if (System.getProperty("jexer.ECMA48.sixel").equals("true")) {
-                sixel = true;
-            } else {
-                sixel = false;
-            }
-        }
+        reloadOptions();
 
         // Spin up the input reader
         eventQueue = new LinkedList<TInputEvent>();
@@ -1187,23 +1171,7 @@ public class ECMA48Terminal extends LogicalScreen
         windowResize = new TResizeEvent(TResizeEvent.Type.SCREEN,
             sessionInfo.getWindowWidth(), sessionInfo.getWindowHeight());
 
-        // Permit RGB colors only if externally requested
-        if (System.getProperty("jexer.ECMA48.rgbColor") != null) {
-            if (System.getProperty("jexer.ECMA48.rgbColor").equals("true")) {
-                doRgbColor = true;
-            } else {
-                doRgbColor = false;
-            }
-        }
-
-        // Pull the system properties for sixel output.
-        if (System.getProperty("jexer.ECMA48.sixel") != null) {
-            if (System.getProperty("jexer.ECMA48.sixel").equals("true")) {
-                sixel = true;
-            } else {
-                sixel = false;
-            }
-        }
+        reloadOptions();
 
         // Spin up the input reader
         eventQueue = new LinkedList<TInputEvent>();
@@ -1357,6 +1325,27 @@ public class ECMA48Terminal extends LogicalScreen
         this.listener = listener;
     }
 
+    /**
+     * Reload options from System properties.
+     */
+    public void reloadOptions() {
+        // Permit RGB colors only if externally requested.
+        if (System.getProperty("jexer.ECMA48.rgbColor",
+                "false").equals("true")
+        ) {
+            doRgbColor = true;
+        } else {
+            doRgbColor = false;
+        }
+
+        // Pull the system properties for sixel output.
+        if (System.getProperty("jexer.ECMA48.sixel", "true").equals("true")) {
+            sixel = true;
+        } else {
+            sixel = false;
+        }
+    }
+
     // ------------------------------------------------------------------------
     // Runnable ---------------------------------------------------------------
     // ------------------------------------------------------------------------
@@ -2745,11 +2734,19 @@ public class ECMA48Terminal extends LogicalScreen
 
         StringBuilder sb = new StringBuilder();
 
-        assert (sixel == true);
         assert (cells != null);
         assert (cells.size() > 0);
         assert (cells.get(0).getImage() != null);
 
+        if (sixel == false) {
+            sb.append(normal());
+            sb.append(gotoXY(x, y));
+            for (int i = 0; i < cells.size(); i++) {
+                sb.append(' ');
+            }
+            return sb.toString();
+        }
+
         if (sixelCache == null) {
             sixelCache = new SixelCache(height * 10);
         }