changeset 3712:d02323f750f6

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
author jlahoda
date Wed, 19 Oct 2016 12:42:37 +0200
parents 69db08651f8f
children b6f22cf3714e
files src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java	Thu Jul 14 13:35:35 2016 -0700
+++ b/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