Refine search
private static String readLine(ConsoleReader reader, String prompt) throws IOException { String earlierLine = reader.getCursorBuffer().toString(); String readLine; try { readLine = reader.readLine(prompt); } catch (IndexOutOfBoundsException e) { if (earlierLine.length() == 0) { reader.println(); readLine = LINE_SEPARATOR; reader.getCursorBuffer().cursor = 0; } else { readLine = readLine(reader, prompt); } } return readLine; }
@Override public synchronized void flush() { try { if (jline) { reader.print(ConsoleReader.RESET_LINE + ""); reader.flush(); super.flush(); try { reader.drawLine(); } catch (Throwable ex) { reader.getCursorBuffer().clear(); } reader.flush(); } else { super.flush(); } } catch (IOException ex) { logger.log(Level.SEVERE, "I/O exception flushing console output", ex); } } }
} else { prompt = getDefaultSecondaryPrompt(); reader.getCursorBuffer().cursor = 0; reader.getCursorBuffer().write(removeBackslash(line) + LINE_SEPARATOR);
public CursorBuffer copy () { CursorBuffer that = new CursorBuffer(); that.overTyping = this.overTyping; that.cursor = this.cursor; that.buffer.append (this.toString()); return that; }
/** * Possible states in which the current readline operation may be in. */ private static enum State { /** * The user is just typing away */ NORMAL, /** * In the middle of a emacs seach */ SEARCH, FORWARD_SEARCH, /** * VI "yank-to" operation ("y" during move mode) */ VI_YANK_TO, /** * VI "delete-to" operation ("d" during move mode) */ VI_DELETE_TO, /** * VI "change-to" operation ("c" during move mode) */ VI_CHANGE_TO }
StringBuilder buffer = reader.getCursorBuffer().copy().buffer; int cursor = reader.getCursorBuffer().cursor; if (reader.getCursorBuffer().length() > 0) { reader.println(); reader.getCursorBuffer().clear(); reader.setPrompt(shellPromptAccessor.getShellPrompt()); reader.getCursorBuffer().write(buffer.toString()); reader.getCursorBuffer().cursor = cursor;
CursorBuffer buf = reader.getCursorBuffer(); if (value.equals(buf.toString())) { return false; reader.println(); reader.drawLine();
public synchronized void stashLine() { this.stashed = reader.getCursorBuffer().copy(); try { reader.getOutput().write("\u001b[1G\u001b[K"); reader.flush(); } catch (IOException e) { // ignore } }
CursorBuffer cursorBuffer = console.getCursorBuffer().copy(); String buffer = cursorBuffer.buffer.toString(); int cursor = cursorBuffer.cursor; String prompt = console.getPrompt(); console.restoreLine("", 0);
CursorBuffer origBuffer = buf.copy(); setCursorPosition (0); killLine(); putString(Character.toString(searchChar)); flush();
public boolean complete(final ConsoleReader reader, final List<CharSequence> candidates, final int pos) throws IOException { CursorBuffer buf = reader.getCursorBuffer(); // if there is only one completion, then fill in the buffer if (candidates.size() == 1) { String value = Ansi.stripAnsi(candidates.get(0).toString()); if (buf.cursor == buf.buffer.length() && printSpaceAfterFullCompletion && !value.endsWith(" ")) { value += " "; } // fail if the only candidate is the same as the current buffer if (value.equals(buf.toString())) { return false; } setBuffer(reader, value, pos); return true; } else if (candidates.size() > 1) { String value = getUnambiguousCompletions(candidates); setBuffer(reader, value, pos); } printCandidates(reader, candidates); // redraw the current console buffer reader.drawLine(); return true; }
private void abort() throws IOException { beep(); buf.clear(); println(); redrawLine(); }
int pos = buf.cursor; if (pos == buf.length()) { return false; int type = getBracketType(buf.buffer.charAt (pos)); int move = (type < 0) ? -1 : 1; int count = 1; int curType = getBracketType(buf.buffer.charAt (pos)); if (curType == type) { ++count; if (move > 0 && isInViMoveOperationState()) ++pos;
private boolean interruptTask() throws Exception { boolean interrupt = false; reader.getCursorBuffer().clear(); reader.redrawLine(); ConsoleTask task = getCurrentTask(); if (task != null) { synchronized (task) { log.debug("Interrupting task"); interrupt = true; if (task.isStopping()) { task.abort(); } else if (task.isRunning()) { task.stop(); } } } else { log.debug("No task running to interrupt"); } return interrupt; } }
@Override public void actionPerformed(ActionEvent e) { CursorBuffer buf = textTerminal.reader.getCursorBuffer(); String partialInput = buf.buffer.toString(); buf.clear(); ReadHandlerData handlerData = handler.apply(textTerminal); ReadInterruptionStrategy.Action action = handlerData.getAction(); if(action == CONTINUE) { buf.write(partialInput); } else { if(action == RESTART) { textTerminal.initialReadBuffer = partialInput; } ReadInterruptionData interruptData = ReadInterruptionData.from(handlerData, partialInput); throw new ReadInterruptionException(interruptData, partialInput); } } }
public void clear() { consoleReader.getCursorBuffer().clear(); }
public synchronized void unstashLine() { try { reader.resetPromptLine("> ", this.stashed.toString(), this.stashed.cursor); } catch (IOException e) { // ignore } }
public static String processMessegeForExtraCharactersFromConsoleBuffer(String messege) { ConsoleReader reader = Gfsh.getConsoleReader(); if (reader != null) { int bufferLength = reader.getCursorBuffer().length(); if (bufferLength > messege.length()) { int appendSpaces = bufferLength - messege.length(); for (int i = 0; i < appendSpaces; i++) { messege = messege + " "; } } } return messege; } }
str = expandEvents(str); } catch(IllegalArgumentException e) { Log.error("Could not expand event", e); beep(); buf.clear(); str = ""; if (mask == null && isHistoryEnabled()) { history.add(historyLine);
private boolean upCaseWord() throws IOException { int i = 1; char c; while (buf.cursor + i - 1 < buf.length() && !isDelimiter((c = buf.buffer.charAt(buf.cursor + i - 1)))) { buf.buffer.setCharAt(buf.cursor + i - 1, Character.toUpperCase(c)); i++; } drawBuffer(); moveCursor(i - 1); return true; }