]> granicus.if.org Git - php/commitdiff
...
authorkrakjoe <joe.watkins@live.co.uk>
Sat, 30 Nov 2013 00:25:05 +0000 (00:25 +0000)
committerkrakjoe <joe.watkins@live.co.uk>
Sat, 30 Nov 2013 00:25:05 +0000 (00:25 +0000)
tutorials/java/dist/phpdbg-ui.jar
tutorials/java/src/phpdbg/ui/DebugSocket.java
tutorials/java/src/phpdbg/ui/JTerminalPane.java

index b98dace3e2381ea5e2c855cccd8e12ac878fc19d..b5b63649144b88149a90cf611a395d27fe8839d0 100644 (file)
Binary files a/tutorials/java/dist/phpdbg-ui.jar and b/tutorials/java/dist/phpdbg-ui.jar differ
index bbd7d34a44e927aef51c633e7740cc75c6a6a05c..4542cbf70de942e46c69f28019a49b71e63631f3 100644 (file)
@@ -76,37 +76,33 @@ public class DebugSocket implements Runnable {
             if (reader) {
                 /* The reader thread part will wait() until there is input */
                 Socket socket = new Socket(this.host, this.port);
-                try {
-                    do {
-                        String command;
-                        OutputStream output = socket.getOutputStream();
+                do {
+                    String command;
+                    OutputStream output = socket.getOutputStream();
 
-                        synchronized(this) {
-                            wait();
+                    synchronized(this) {
+                        wait();
 
-                            if (!quit) {
-                                command = main.getInputField().getText();
-                                /* send command to stdin socket */
-                                if (command != null) {
-                                    if (main.isEchoing()) {
-                                        main.getOutputField().appendANSI("remote> ");
-                                        main.getOutputField().appendANSI(command);
-                                        main.getOutputField().appendANSI("\n");
-                                    }
-                                    output.write(
-                                       command.getBytes());
-                                    output.write("\n".getBytes());
-                                    output.flush();
+                        if (!quit) {
+                            command = main.getInputField().getText();
+                            /* send command to stdin socket */
+                            if (command != null) {
+                                if (main.isEchoing()) {
+                                    main.getOutputField().appendANSI("remote> ");
+                                    main.getOutputField().appendANSI(command);
+                                    main.getOutputField().appendANSI("\n");
                                 }
-                                main.getInputField().setText(null);
+                                output.write(
+                                   command.getBytes());
+                                output.write("\n".getBytes());
+                                output.flush();
                             }
+                            main.getInputField().setText(null);
                         }
-                    } while (!quit);
-                } catch (IOException ex) {
-                    if (!quit) {
-                        main.messageBox(ex.getMessage(), MessageType.ERROR);
                     }
-                }
+                } while (!quit);
+                
+                socket.close();
             } else {
                 /*
                 * The writer thread will use non-blocking i/o consuming
@@ -144,6 +140,7 @@ public class DebugSocket implements Runnable {
                         }
                     }
                 }
+                channel.close();
             }
         } catch (IOException | InterruptedException ex) {
             if (!quit) {
index c616d2a8b86a0afd036cc80cf000b1824015aa63..ae63c223004bc814606eb7e6690744f453f26704 100644 (file)
@@ -72,11 +72,10 @@ public class JTerminalPane extends JTextPane {
             SimpleAttributeSet.EMPTY, StyleConstants.Foreground, c);
     setCharacterAttributes(aset, false);
     replaceSelection(s);
-    setCaretPosition(
-            (getDocument().getLength() > 0) ? (getDocument().getLength() - 1) : 0);
+    setCaretPosition(getDocument().getLength());
   }
 
-  public void appendANSI(String s) {
+  public synchronized void appendANSI(String s) {
     int aPos = 0;
     int aIndex;
     int mIndex;