22 package com.realtime.crossfire.jxclient.settings;
24 import java.util.ArrayList;
25 import java.util.Iterator;
26 import java.util.List;
27 import org.jetbrains.annotations.NotNull;
28 import org.jetbrains.annotations.Nullable;
64 final String trimmedCommand = command.trim();
65 if (trimmedCommand.length() <= 0) {
69 commands.add(trimmedCommand);
70 commandIndex = commands.size();
81 if (commandIndex > 0) {
92 final Iterator<String> it = commands.iterator();
93 while (it.hasNext()) {
94 final String oldCommand = it.next();
95 if (oldCommand.equals(command)) {
109 return 1 <= commandIndex && commandIndex <= commands.size() ? commands.get(--commandIndex) : null;
118 if (commandIndex < commands.size()) {
121 return commandIndex < commands.size() ? commands.get(commandIndex) : null;
131 public CharSequence
last(
final int index) {
132 return index >= commands.size() ? null : commands.get(commands.size()-index-1);
static final int HISTORY_SIZE
The maximum number of commands to store.
String up()
Returns the previous command.
String down()
Returns the next command.
void removeCommand(@NotNull final String command)
Removes a command.
final List< String > commands
The commands.
CharSequence last(final int index)
Returns the last executed command.
void trimToMaxSize()
Cut off old entries if more than HISTORY_SIZE commands are present.
CommandHistory(@NotNull final String ident)
Creates a new instance.
void addCommand(@NotNull final String command)
Adds a new command.
int commandIndex
The current command index.
Manages a list of previously entered commands.