8166183: jshell tool: on return from Ctrl-Z, garbage on screen, dies with Ctrl-C
Reset the console when the process is suspended and resumed. Reviewed-by: sundar
This commit is contained in:
parent
093753dee1
commit
3334929d21
@ -42,6 +42,8 @@ import jdk.internal.jline.WindowsTerminal;
|
||||
import jdk.internal.jline.console.ConsoleReader;
|
||||
import jdk.internal.jline.console.KeyMap;
|
||||
import jdk.internal.jline.extra.EditingHistory;
|
||||
import jdk.internal.misc.Signal;
|
||||
import jdk.internal.misc.Signal.Handler;
|
||||
|
||||
class Console implements AutoCloseable {
|
||||
private static final String DOCUMENTATION_SHORTCUT = "\033\133\132"; //Shift-TAB
|
||||
@ -68,6 +70,21 @@ class Console implements AutoCloseable {
|
||||
in.addCompleter(completer);
|
||||
Runtime.getRuntime().addShutdownHook(new Thread((Runnable)this::saveHistory));
|
||||
bind(DOCUMENTATION_SHORTCUT, (ActionListener)evt -> showDocumentation(docHelper));
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
String readLine(final String prompt) throws IOException {
|
||||
|
Loading…
x
Reference in New Issue
Block a user