default boolean isEmpty() { return size() == 0; }
public int last() { return first() + history.size() - 1; }
public int last() { return first() + history.size() - 1; }
protected boolean viHistorySearchBackward() { searchDir = -1; searchIndex = history.size() - 1; return getViSearchString() && viRepeatSearch(); }
@ShellMethod(value = "Display or save the history of previously run commands") public List<String> history(@ShellOption(help = "A file to save history to.", defaultValue = ShellOption.NULL) File file) throws IOException { if (file == null) { List<String> result = new ArrayList<>(jLineHistory.size()); jLineHistory.forEach(e -> result.add(e.line())); return result; } else { try (FileWriter w = new FileWriter(file)) { for (org.jline.reader.History.Entry entry : jLineHistory) { w.append(entry.line()).append(System.lineSeparator()); } } return Collections.singletonList(String.format("Wrote %d entries to %s", jLineHistory.size(), file)); } } }
private String calculateCommand(int currentOffset, Set<Integer> offsets) { if (!offsets.add(currentOffset)) { throw new IllegalArgumentException( "Cycled rerun of commands from history " + offsets); } History history = sqlLine.getLineReader().getHistory(); Iterator<History.Entry> iterator = currentOffset > 0 ? history.iterator(currentOffset - 1) : history.reverseIterator(history.size() - 1 + currentOffset); String command = iterator.next().line(); if (command.trim().startsWith("!/") || command.startsWith("!rerun")) { String[] cmd = sqlLine.split(command); if (cmd.length > 2 || (cmd.length == 2 && !cmd[1].matches("-?\\d+"))) { return command; } int offset = cmd.length == 1 ? -1 : Integer.parseInt(cmd[1]); if (history.size() < offset || history.size() - 1 < -offset) { return command; } return calculateCommand(offset, offsets); } return command; }
private String calculateCommand(int currentOffset, Set<Integer> offsets) { if (!offsets.add(currentOffset)) { throw new IllegalArgumentException( "Cycled rerun of commands from history " + offsets); } History history = sqlLine.getLineReader().getHistory(); Iterator<History.Entry> iterator = currentOffset > 0 ? history.iterator(currentOffset - 1) : history.reverseIterator(history.size() - 1 + currentOffset); String command = iterator.next().line(); if (command.trim().startsWith("!/") || command.startsWith("!rerun")) { String[] cmd = sqlLine.split(command); if (cmd.length > 2 || (cmd.length == 2 && !cmd[1].matches("-?\\d+"))) { return command; } int offset = cmd.length == 1 ? -1 : Integer.parseInt(cmd[1]); if (history.size() < offset || history.size() - 1 < -offset) { return command; } return calculateCommand(offset, offsets); } return command; }
switch (c) { case '!': if (history.size() == 0) { throw new IllegalArgumentException("!!: event not found"); if (history.size() == 0) { throw new IllegalArgumentException("!$: event not found"); throw new IllegalArgumentException((neg ? "!-" : "!") + line.substring(i1, i) + ": event not found"); if (neg && idx > 0 && idx <= history.size()) { rep = history.get(history.index() - idx); } else if (!neg && idx > history.index() - history.size() && idx <= history.index()) { rep = history.get(idx - 1); } else {
public void rerun(String line, DispatchCallback callback) { String[] cmd = sqlLine.split(line); History history = sqlLine.getLineReader().getHistory(); int size = history.size(); if (cmd.length > 2 || (cmd.length == 2 && !cmd[1].matches("-?\\d+"))) { if (size == 0) {
public void rerun(String line, DispatchCallback callback) { String[] cmd = sqlLine.split(line); History history = sqlLine.getLineReader().getHistory(); int size = history.size(); if (cmd.length > 2 || (cmd.length == 2 && !cmd[1].matches("-?\\d+"))) { if (size == 0) {