@Test public void signalHandlerRespondsToSIGINTByClearingPrompt() throws IOException { // Interactive attention (CTRL-C). JVM exits normally GfshSignalHandler signalHandler = new GfshSignalHandler(); ConsoleReader consoleReader = mock(ConsoleReader.class); when(consoleReader.getPrompt()).thenReturn(PROMPT); signalHandler.handleDefault(SIGINT, consoleReader); verify(consoleReader, times(1)).resetPromptLine(eq(PROMPT), eq(""), eq(END_OF_LINE)); } }
protected void handleDefault(final sun.misc.Signal sig, final ConsoleReader consoleReader) throws IOException { final Signal signal = Signal.valueOfName(sig.getName()); switch (signal) { case SIGINT: if (consoleReader != null) { String prompt = consoleReader.getPrompt(); consoleReader.resetPromptLine(prompt, "", -1); } break; default: final SignalHandler handler = getOriginalSignalHandler(signal); if (handler != null) { handler.handle(sig); } } }
private void printSearchStatus(String searchTerm, String match, String searchLabel) throws IOException { String prompt = searchLabel + searchTerm + "': "; int cursorDest = match.indexOf(searchTerm); resetPromptLine(prompt, match, cursorDest); }
public void restoreLine(String originalPrompt, int cursorDest) throws IOException { // TODO move cursor to matched string String prompt = lastLine(originalPrompt); String buffer = buf.buffer.toString(); resetPromptLine(prompt, buffer, cursorDest); }
private void printSearchStatus(String searchTerm, String match, String searchLabel) throws IOException { String prompt = searchLabel + searchTerm + "': "; int cursorDest = match.indexOf(searchTerm); resetPromptLine(prompt, match, cursorDest); }
@Override public boolean resetLine() { try { reader.resetPromptLine("", "", 0); return true; } catch (IOException e) { logger.error("resetLine error.", e); return false; } }
public void removePromptLine() { try { reader.resetPromptLine("", "", 0); } catch (IOException e) { e.printStackTrace(); } }
public void restoreLine(String originalPrompt, int cursorDest) throws IOException { // TODO move cursor to matched string String prompt = lastLine(originalPrompt); String buffer = buf.buffer.toString(); resetPromptLine(prompt, buffer, cursorDest); }
public synchronized void unstashLine() { try { reader.resetPromptLine("> ", this.stashed.toString(), this.stashed.cursor); } catch (IOException e) { // ignore } }
String preloadReadLine(ConsoleReader reader, String prompt, String preload) throws IOException { reader.resetPromptLine(prompt, preload, 0); reader.print("\r"); return reader.readLine(prompt); }
private void handleCommandQueue() throws IOException, InterruptedException { boolean handledQueue = false; String queuedCommand; while ((queuedCommand = commandQueue.poll()) != null) { handledQueue = true; reader.resetPromptLine(reader.getPrompt(), queuedCommand, 0); reader.println(); reader.getHistory().add(queuedCommand); try { handlingInput = true; handleInput(queuedCommand); } finally { handlingInput = false; } } if (handledQueue) { String oldPrompt = reader.getPrompt(); reader.resetPromptLine("", "", 0); reader.setPrompt(oldPrompt); } }
public String readLine() { try { reader.resetPromptLine("", "", 0); return this.reader.readLine("> "); } catch (IOException e) { Server.getInstance().getLogger().logException(e); return ""; } }
console.resetPromptLine(prompt, buffer, cursor); } else { console.restoreLine("", 0);
id = currentLanguage.getId(); prompt = createPrompt(currentLanguage); console.resetPromptLine("", "", 0); context.initialize(id); } catch (PolyglotException e) {
cloudNetLogging.getReader().resetPromptLine(NetworkUtils.EMPTY_STRING, "", 0); while ((commandLine = cloudNetLogging.getReader().readLine(user + "@" + cloudNetWrapper.getWrapperConfig().getWrapperId() + " $ ")) != null)
cloudNetLogging.getReader().resetPromptLine(NetworkUtils.EMPTY_STRING, "", 0); while ((commandLine = cloudNetLogging.getReader().readLine(user + "@Master $ ")) != null && CloudNet.RUNNING)
reader.resetPromptLine("> ", "", 0); reader.println(); return true;