network socket support, Swing blink/reverse
[nikiroo-utils.git] / src / jexer / TTerminalWindow.java
index 336c3ff8db7cd19c2a6761f98469cc869f0b6b78..bb91a6317453f665a08119b8a83f0564fd9e7fa3 100644 (file)
@@ -208,7 +208,7 @@ public class TTerminalWindow extends TWindow {
                     Cell ch = line.charAt(i);
                     Cell newCell = new Cell();
                     newCell.setTo(ch);
-                    boolean reverse = line.isReverseColor() ^ ch.getReverse();
+                    boolean reverse = line.isReverseColor() ^ ch.isReverse();
                     newCell.setReverse(false);
                     if (reverse) {
                         newCell.setBackColor(ch.getForeColor());
@@ -242,7 +242,12 @@ public class TTerminalWindow extends TWindow {
      * Handle window close.
      */
     @Override public void onClose() {
-        emulator.close();
+        if (shell != null) {
+            shell.destroy();
+            shell = null;
+        } else {
+            emulator.close();
+        }
     }
 
     /**
@@ -260,12 +265,12 @@ public class TTerminalWindow extends TWindow {
             if (vScroller != null) {
                 setCursorY(getCursorY() - vScroller.getValue());
             }
-            setHasCursor(emulator.visibleCursor());
+            setCursorVisible(emulator.isCursorVisible());
             if (getCursorX() > getWidth() - 2) {
-                setHasCursor(false);
+                setCursorVisible(false);
             }
             if ((getCursorY() > getHeight() - 2) || (getCursorY() < 0)) {
-                setHasCursor(false);
+                setCursorVisible(false);
             }
             if (emulator.getScreenTitle().length() > 0) {
                 // Only update the title if the shell is still alive
@@ -276,11 +281,18 @@ public class TTerminalWindow extends TWindow {
 
             // Check to see if the shell has died.
             if (!emulator.isReading() && (shell != null)) {
-                // The emulator exited on its own, all is fine
-                setTitle(String.format("%s [Completed - %d]",
-                        getTitle(), shell.exitValue()));
-                shell = null;
-                emulator.close();
+                try {
+                    int rc = shell.exitValue();
+                    // The emulator exited on its own, all is fine
+                    setTitle(String.format("%s [Completed - %d]",
+                            getTitle(), shell.exitValue()));
+                    shell = null;
+                    emulator.close();
+                } catch (IllegalThreadStateException e) {
+                    // The emulator thread has exited, but the shell Process
+                    // hasn't figured that out yet.  Do nothing, we will see
+                    // this in a future tick.
+                }
             } else if (emulator.isReading() && (shell != null)) {
                 // The shell might be dead, let's check
                 try {
@@ -439,11 +451,11 @@ public class TTerminalWindow extends TWindow {
             return;
         }
 
-        if (mouse.getMouseWheelUp()) {
+        if (mouse.isMouseWheelUp()) {
             vScroller.decrement();
             return;
         }
-        if (mouse.getMouseWheelDown()) {
+        if (mouse.isMouseWheelDown()) {
             vScroller.increment();
             return;
         }