Mercurial > hg > openjdk > jdk9 > nashorn
changeset 1798:e8627495578f
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: sundar
author | jlahoda |
---|---|
date | Wed, 19 Oct 2016 12:42:41 +0200 |
parents | 0d5081c856bc |
children | ca08ca9bef23 |
files | src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/Console.java |
diffstat | 1 files changed, 17 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/Console.java Wed Oct 19 13:27:20 2016 +0530 +++ b/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/Console.java Wed Oct 19 12:42:41 2016 +0200 @@ -42,6 +42,8 @@ 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 @@ 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 {