public AnsiStringsCompleter(final Collection<String> strings) { checkNotNull(strings); for (String str : strings) { this.strings.put(Ansi.stripAnsi(str), str); } }
public int complete(String buffer, final int cursor, final List<CharSequence> candidates) { // buffer could be null checkNotNull(candidates); if (buffer == null) { candidates.addAll(strings.values()); } else { buffer = Ansi.stripAnsi(buffer); for (Map.Entry<String, String> match : strings.tailMap(buffer).entrySet()) { if (!match.getKey().startsWith(buffer)) { break; } candidates.add(match.getValue()); } } return candidates.isEmpty() ? -1 : 0; } }
public void setPrompt(final String prompt) { this.prompt = prompt; this.promptLen = (prompt == null) ? 0 : wcwidth(Ansi.stripAnsi(lastLine(prompt)), 0); }
String str = candidates.get(i).toString(); if (stripAnsi) { str = Ansi.stripAnsi(str);
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 AnsiStringsCompleter(final Collection<String> strings) { checkNotNull(strings); for (String str : strings) { this.strings.put(Ansi.stripAnsi(str), str); } }
public int complete(String buffer, final int cursor, final List<CharSequence> candidates) { // buffer could be null checkNotNull(candidates); if (buffer == null) { candidates.addAll(strings.values()); } else { buffer = Ansi.stripAnsi(buffer); for (Map.Entry<String, String> match : strings.tailMap(buffer).entrySet()) { if (!match.getKey().startsWith(buffer)) { break; } candidates.add(match.getValue()); } } return candidates.isEmpty() ? -1 : 0; } }
String str = candidates.get(i).toString(); if (stripAnsi) { str = Ansi.stripAnsi(str);
public void setPrompt(final String prompt) { this.prompt = prompt; this.promptLen = (prompt == null) ? 0 : wcwidth(Ansi.stripAnsi(lastLine(prompt)), 0); }
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; }