public final class CommandHistory
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private javajs.util.Lst<java.lang.String> |
commandList
Array of commands.
|
private int |
cursorPos
Current position of the cursor;
|
(package private) static int |
DEFAULT_MAX_SIZE |
static java.lang.String |
ERROR_FLAG |
(package private) boolean |
isOn |
private int |
maxSize |
private int |
nextCommand
Position of the next command.
|
static java.lang.String |
NOHISTORYATALL_FLAG |
static java.lang.String |
NOHISTORYLINE_FLAG |
Constructor and Description |
---|
CommandHistory()
Creates a new instance using the default size (100)
|
Modifier and Type | Method and Description |
---|---|
void |
addCommand(java.lang.String strCommand)
Adds any number of lines to the command history
|
private void |
addCommandLine(java.lang.String command)
Adds a single line to the bottom of the list, resets list position.
|
void |
clear()
clears the history.
|
java.lang.String |
find(java.lang.String cmd,
int dir) |
private java.lang.String |
getCommand()
Calculates the command to return.
|
java.lang.String |
getCommandDown()
Retrieves the following command from the top of the list, updates list position.
|
java.lang.String |
getCommandUp()
Retrieves the following command from the bottom of the list, updates list position.
|
java.lang.String |
getSetHistory(int n)
Options include:
all Integer.MAX_VALUE
n prev n >= 1
next -1
set max to -2 - n n <= -3
just clear -2
clear and turn off; return "" 0
clear and turn on; return "" Integer.MIN_VALUE;
|
java.lang.String |
removeCommand() |
java.lang.String |
removeCommand(int n) |
void |
reset(int maxSize)
Resets instance.
|
void |
setMaxSize(int maxSize)
Resets maximum size of command queue.
|
public static final java.lang.String ERROR_FLAG
public static final java.lang.String NOHISTORYLINE_FLAG
public static final java.lang.String NOHISTORYATALL_FLAG
static final int DEFAULT_MAX_SIZE
private javajs.util.Lst<java.lang.String> commandList
private int maxSize
private int nextCommand
private int cursorPos
boolean isOn
public CommandHistory()
public void clear()
public void reset(int maxSize)
maxSize
- maximum size for the command queue.public void setMaxSize(int maxSize)
maxSize
- maximum size for the command queue.public java.lang.String getCommandUp()
public java.lang.String getCommandDown()
private java.lang.String getCommand()
public void addCommand(java.lang.String strCommand)
strCommand
- public java.lang.String getSetHistory(int n)
n
- public java.lang.String find(java.lang.String cmd, int dir)
public java.lang.String removeCommand()
public java.lang.String removeCommand(int n)
private void addCommandLine(java.lang.String command)
command
- the String value of a command.