8166183: jshell tool: on return from Ctrl-Z, garbage on screen, dies with Ctrl-C
authorjlahoda
Wed, 19 Oct 2016 12:42:37 +0200
changeset 41631 a348d1cc8d9d
parent 41630 9cc5bcc88057
child 41632 c599331f6040
8166183: jshell tool: on return from Ctrl-Z, garbage on screen, dies with Ctrl-C Summary: Reset the console when the process is suspended and resumed. Reviewed-by: rfield
langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java	Thu Jul 14 13:35:35 2016 -0700
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java	Wed Oct 19 12:42:37 2016 +0200
@@ -62,6 +62,8 @@
 import jdk.internal.jline.console.history.MemoryHistory;
 import jdk.internal.jline.extra.EditingHistory;
 import jdk.internal.jshell.tool.StopDetectingInputStream.State;
+import jdk.internal.misc.Signal;
+import jdk.internal.misc.Signal.Handler;
 
 class ConsoleIOContext extends IOContext {
 
@@ -171,6 +173,21 @@
                 bind(shortcuts + computer.shortcut, (ActionListener) evt -> fixes(computer));
             }
         }
+        try {
+            Signal.handle(new Signal("CONT"), new Handler() {
+                @Override public void handle(Signal sig) {
+                    try {
+                        in.getTerminal().reset();
+                        in.redrawLine();
+                        in.flush();
+                    } catch (Exception ex) {
+                        ex.printStackTrace();
+                    }
+                }
+            });
+        } catch (IllegalArgumentException ignored) {
+            //the CONT signal does not exist on this platform
+        }
     }
 
     @Override