@Override public int cursor() { return cmdLine.getBufferPosition(); } };
@Override public int cursor() { return cmdLine.getBufferPosition(); } };
default void completeCandidates(Session session, CommandLine commandLine, List<Candidate> candidates) { List<String> strings = new ArrayList<>(); int idx = complete(session, commandLine, strings); String word = ""; if (idx > commandLine.getBufferPosition() - commandLine.getArgumentPosition()) { word = commandLine.getBuffer().substring(commandLine.getBufferPosition() - commandLine.getArgumentPosition(), idx); } for (String string : strings) { String str = word + string; if (str.endsWith(" ")) { candidates.add(new Candidate(str.substring(0, str.length() - 1), true)); } else { candidates.add(new Candidate(word + string, false)); } } } }
default void completeCandidates(Session session, CommandLine commandLine, List<Candidate> candidates) { List<String> strings = new ArrayList<>(); int idx = complete(session, commandLine, strings); String word = ""; if (idx > commandLine.getBufferPosition() - commandLine.getArgumentPosition()) { word = commandLine.getBuffer().substring(commandLine.getBufferPosition() - commandLine.getArgumentPosition(), idx); } for (String string : strings) { String str = word + string; if (str.endsWith(" ")) { candidates.add(new Candidate(str.substring(0, str.length() - 1), true)); } else { candidates.add(new Candidate(word + string, false)); } } } }
public int complete(final Session session, final CommandLine commandLine, final List<String> candidates) { // buffer could be null assert candidates != null; String buffer = commandLine.getCursorArgument(); if (buffer == null) { buffer = ""; } else { buffer = buffer.substring(0, commandLine.getArgumentPosition()); } if (!caseSensitive) { buffer = buffer.toLowerCase(); } // KARAF-421, use getStrings() instead strings field. SortedSet<String> matches = getStrings().tailSet(buffer); for (String match : matches) { String s = caseSensitive ? match : match.toLowerCase(); if (!s.startsWith(buffer)) { break; } // noinspection unchecked candidates.add(match + " "); } return candidates.isEmpty() ? -1 : commandLine.getBufferPosition() - commandLine.getArgumentPosition(); } }
public int complete(final Session session, final CommandLine commandLine, final List<String> candidates) { // buffer could be null assert candidates != null; String buffer = commandLine.getCursorArgument(); if (buffer == null) { buffer = ""; } else { buffer = buffer.substring(0, commandLine.getArgumentPosition()); } if (!caseSensitive) { buffer = buffer.toLowerCase(); } // KARAF-421, use getStrings() instead strings field. SortedSet<String> matches = getStrings().tailSet(buffer); for (String match : matches) { String s = caseSensitive ? match : match.toLowerCase(); if (!s.startsWith(buffer)) { break; } // noinspection unchecked candidates.add(match + " "); } return candidates.isEmpty() ? -1 : commandLine.getBufferPosition() - commandLine.getArgumentPosition(); } }
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { String arg = commandLine.getCursorArgument(); int pos = commandLine.getArgumentPosition(); CommandLine cmdLine = new DefaultParser().parse(session, arg, pos); Completer completer = session.getRegistry().getService(CommandsCompleter.class); List<String> cands = new ArrayList<>(); int res = completer.complete(session, cmdLine, cands); for (String cand : cands) { candidates.add(arg.substring(0, cmdLine.getBufferPosition() - cmdLine.getArgumentPosition()) + cand); } if (res >= 0) { res += commandLine.getBufferPosition() - commandLine.getArgumentPosition(); } return res; }
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { String arg = commandLine.getCursorArgument(); int pos = commandLine.getArgumentPosition(); CommandLine cmdLine = new DefaultParser().parse(session, arg, pos); Completer completer = session.getRegistry().getService(CommandsCompleter.class); List<String> cands = new ArrayList<>(); int res = completer.complete(session, cmdLine, cands); for (String cand : cands) { candidates.add(arg.substring(0, cmdLine.getBufferPosition() - cmdLine.getArgumentPosition()) + cand); } if (res >= 0) { res += commandLine.getBufferPosition() - commandLine.getArgumentPosition(); } return res; }
int pos = ret + (list.getBufferPosition() - argpos); int cursor = list.getBufferPosition(); if ((buffer != null) && (cursor != buffer.length()) && isDelimiter(buffer, cursor)) { for (int i = 0; i < candidates.size(); i++) {
int pos = ret + (list.getBufferPosition() - argpos); int cursor = list.getBufferPosition(); if ((buffer != null) && (cursor != buffer.length()) && isDelimiter(buffer, cursor)) { for (int i = 0; i < candidates.size(); i++) {
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { String[] args = commandLine.getArguments(); int argIndex = commandLine.getCursorArgumentIndex(); StringsCompleter completer = new StringsCompleter(getNames(session)); if (argIndex == 0) { int res = completer.complete(session, new ArgumentCommandLine(args[argIndex], commandLine.getArgumentPosition()), candidates); if (res > -1) { res += commandLine.getBufferPosition() - commandLine.getArgumentPosition(); } return res; } else if (!verifyCompleter(session, completer, args[0])) { return -1; } return 0; }
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { String[] args = commandLine.getArguments(); int argIndex = commandLine.getCursorArgumentIndex(); StringsCompleter completer = new StringsCompleter(getNames(session)); if (argIndex == 0) { int res = completer.complete(session, new ArgumentCommandLine(args[argIndex], commandLine.getArgumentPosition()), candidates); if (res > -1) { res += commandLine.getBufferPosition() - commandLine.getArgumentPosition(); } return res; } else if (!verifyCompleter(session, completer, args[0])) { return -1; } return 0; }
res = completer.complete(session, new ArgumentCommandLine("", 0), candidates); return res + (commandLine.getBufferPosition() - commandLine.getArgumentPosition()); } else if (!verifyCompleter(session, completer, args[1])) { return -1;
res = completer.complete(session, new ArgumentCommandLine("", 0), candidates); return res + (commandLine.getBufferPosition() - commandLine.getArgumentPosition()); } else if (!verifyCompleter(session, completer, args[1])) { return -1;