if (value.equals(buf.toString())) { return false;
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; }
public CursorBuffer copy () { CursorBuffer that = new CursorBuffer(); that.overTyping = this.overTyping; that.cursor = this.cursor; that.buffer.append (this.toString()); return that; }
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; }
public synchronized void unstashLine() { try { reader.resetPromptLine("> ", this.stashed.toString(), this.stashed.cursor); } catch (IOException e) { // ignore } }
public CursorBuffer copy () { CursorBuffer that = new CursorBuffer(); that.overTyping = this.overTyping; that.cursor = this.cursor; that.buffer.append (this.toString()); return that; }
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; }
public boolean complete(ConsoleReader reader, @SuppressWarnings("rawtypes") List<CharSequence> candidates, 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 = candidates.get(0).toString(); // fail if the only candidate is the same as the current buffer if (value.equals(buf.toString())) { return false; } jline.console.completer.CandidateListCompletionHandler.setBuffer(reader, value, pos); return true; } if (candidates.size() > 1) { String value = getUnambiguousCompletions(candidates); jline.console.completer.CandidateListCompletionHandler.setBuffer(reader, value, pos); } if (eagerNewlines) { reader.println(); } jline.console.completer.CandidateListCompletionHandler.printCandidates(reader, candidates); // redraw the current console buffer reader.drawLine(); return true; }
public boolean complete(final ConsoleReader reader, final List<CharSequence> candidates, final int pos) throws IOException { CursorBuffer buffer = reader.getCursorBuffer(); // if there is only one completion, then fill in the buffer, that's all if (candidates.size() == 1) { CharSequence candidate = candidates.get(0); // fail if the only candidate is the same as the current buffer if (candidate.equals(buffer.toString())) { return false; } updateBuffer(reader, candidate, pos); return true; } //if there are more suggestions, then fill in the buffer with the longer common prefix available //and show auto-suggestions if (candidates.size() > 1) { String commonPrefix = getUnambiguousCompletions(candidates); updateBuffer(reader, commonPrefix, pos); } printCandidates(reader, candidates); //next line seems to cause small problems when cursor is not at the end of the buffer //e.g. FilterBuilders.queryFilter(QueryBuilders.) reader.drawLine(); return true; }
private static String readLine(ConsoleReader reader, String prompt) throws IOException { String earlierLine = reader.getCursorBuffer().toString(); String readLine = null; 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; }