Package org.jmol.util
Class CommandHistory
- java.lang.Object
-
- org.jmol.util.CommandHistory
-
public final class CommandHistory extends java.lang.ObjectImplements a queue for a bash-like command history.
-
-
Field Summary
Fields Modifier and Type Field Description private javajs.util.Lst<java.lang.String>commandListArray of commands.private intcursorPosCurrent position of the cursor;(package private) static intDEFAULT_MAX_SIZEstatic java.lang.StringERROR_FLAG(package private) booleanisOnprivate intmaxSizeprivate intnextCommandPosition of the next command.static java.lang.StringNOHISTORYATALL_FLAGstatic java.lang.StringNOHISTORYLINE_FLAG
-
Constructor Summary
Constructors Constructor Description CommandHistory()Creates a new instance using the default size (100)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCommand(java.lang.String strCommand)Adds any number of lines to the command historyprivate voidaddCommandLine(java.lang.String command)Adds a single line to the bottom of the list, resets list position.voidclear()clears the history.java.lang.Stringfind(java.lang.String cmd, int dir)private java.lang.StringgetCommand()Calculates the command to return.java.lang.StringgetCommandDown()Retrieves the following command from the top of the list, updates list position.java.lang.StringgetCommandUp()Retrieves the following command from the bottom of the list, updates list position.java.lang.StringgetSetHistory(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.StringremoveCommand()java.lang.StringremoveCommand(int n)voidreset(int maxSize)Resets instance.voidsetMaxSize(int maxSize)Resets maximum size of command queue.
-
-
-
Field Detail
-
ERROR_FLAG
public static final java.lang.String ERROR_FLAG
- See Also:
- Constant Field Values
-
NOHISTORYLINE_FLAG
public static final java.lang.String NOHISTORYLINE_FLAG
- See Also:
- Constant Field Values
-
NOHISTORYATALL_FLAG
public static final java.lang.String NOHISTORYATALL_FLAG
- See Also:
- Constant Field Values
-
DEFAULT_MAX_SIZE
static final int DEFAULT_MAX_SIZE
- See Also:
- Constant Field Values
-
commandList
private javajs.util.Lst<java.lang.String> commandList
Array of commands.
-
maxSize
private int maxSize
-
nextCommand
private int nextCommand
Position of the next command.
-
cursorPos
private int cursorPos
Current position of the cursor;
-
isOn
boolean isOn
-
-
Method Detail
-
clear
public void clear()
clears the history.
-
reset
public void reset(int maxSize)
Resets instance.- Parameters:
maxSize- maximum size for the command queue.
-
setMaxSize
public void setMaxSize(int maxSize)
Resets maximum size of command queue. Cuts off extra commands.- Parameters:
maxSize- maximum size for the command queue.
-
getCommandUp
public java.lang.String getCommandUp()
Retrieves the following command from the bottom of the list, updates list position.- Returns:
- the String value of a command.
-
getCommandDown
public java.lang.String getCommandDown()
Retrieves the following command from the top of the list, updates list position.- Returns:
- the String value of a command.
-
getCommand
private java.lang.String getCommand()
Calculates the command to return.- Returns:
- the String value of a command.
-
addCommand
public void addCommand(java.lang.String strCommand)
Adds any number of lines to the command history- Parameters:
strCommand-
-
getSetHistory
public 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;- Parameters:
n-- Returns:
- one or more lines of command history
-
find
public java.lang.String find(java.lang.String cmd, int dir)
-
removeCommand
public java.lang.String removeCommand()
-
removeCommand
public java.lang.String removeCommand(int n)
-
addCommandLine
private void addCommandLine(java.lang.String command)
Adds a single line to the bottom of the list, resets list position.- Parameters:
command- the String value of a command.
-
-