void teardown(@Observes final Shutdown shutdown, final Event<PreShutdown> preShutdown) { preShutdown.fire(new PreShutdown(shutdown.getStatus())); exitRequested = true; if (inputPipe != null) { inputPipe.stop(); } }
public void interrupt() { if (executorThread != null) { executorThread.interrupt(); try { inputPipe.interruptPipe(); } catch (Exception e) { // } print("[killed]"); interruptedState = true; } }
private void initReaderAndStreams() throws IOException { boolean noInitMode = isNoInitMode(); if ((_redirectedStream == null) && noInitMode) { return; } if ((inputPipe == null) && (_redirectedStream == null)) { inputPipe = new ConsoleInputSession(System.in); } if (outputStream == null) { outputStream = System.out; } Terminal terminal; if (Boolean.getBoolean("forge.compatibility.IDE")) { terminal = new IdeTerminal(); } else if (OSUtils.isWindows()) { final OutputStream ansiOut = AnsiConsole.wrapOutputStream(System.out); TerminalFactory.configure(TerminalFactory.Type.WINDOWS); terminal = TerminalFactory.get(); final OutputStreamWriter writer = new OutputStreamWriter( ansiOut, System.getProperty( "jline.WindowsTerminal.output.encoding", System.getProperty("file.encoding"))); outputStream = new OutputStream() { @Override public void write(final int b) throws IOException { writer.write(b); writer.flush(); } }; } else { terminal = TerminalFactory.get(); } this.screenBuffer = new JLineScreenBuffer(terminal, outputStream); this.reader = new ConsoleReader( _redirectedStream == null ? inputPipe.getExternalInputStream() : _redirectedStream, this, null, terminal); this.reader.setHistoryEnabled(true); this.reader.setBellEnabled(false); for (TriggeredAction action : triggeredActions) { this.reader.addTriggeredAction(action.getTrigger(), action.getListener()); } if (noInitMode) { if (_historyOverride != null) { _setHistory(_historyOverride); } if (_deferredCompleters != null) { for (Completer completer : _deferredCompleters) { _initCompleters(completer); } } } }