org.jmol.util

Class CommandHistory

public final class CommandHistory extends Object

Implements a queue for a bash-like command history.
Field Summary
VectorcommandList
Array of commands.
intcursorPos
Current position of the cursor;
static intDEFAULT_MAX_SIZE
static StringERROR_FLAG
booleanisOn
intmaxSize
intnextCommand
Position of the next command.
static StringNOHISTORYATALL_FLAG
static StringNOHISTORYLINE_FLAG
Constructor Summary
CommandHistory()
Creates a new instance using the default size (100)
CommandHistory(int maxSize)
Creates a new instance.
Method Summary
voidaddCommand(String strCommand)
Adds any number of lines to the command history
voidaddCommandLine(String command)
Adds a single line to the bottom of the list, resets list position.
voidclear()
clears the history.
StringgetCommand()
Calculates the command to return.
StringgetCommandDown()
Retrieves the following command from the top of the list, updates list position.
StringgetCommandUp()
Retrieves the following command from the bottom of the list, updates list position.
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;
StringremoveCommand()
StringremoveCommand(int n)
voidreset(int maxSize)
Resets instance.
voidsetMaxSize(int maxSize)
Resets maximum size of command queue.

Field Detail

commandList

private Vector commandList
Array of commands.

cursorPos

private int cursorPos
Current position of the cursor;

DEFAULT_MAX_SIZE

static final int DEFAULT_MAX_SIZE

ERROR_FLAG

public static final String ERROR_FLAG

isOn

boolean isOn

maxSize

private int maxSize

nextCommand

private int nextCommand
Position of the next command.

NOHISTORYATALL_FLAG

public static final String NOHISTORYATALL_FLAG

NOHISTORYLINE_FLAG

public static final String NOHISTORYLINE_FLAG

Constructor Detail

CommandHistory

public CommandHistory()
Creates a new instance using the default size (100)

CommandHistory

public CommandHistory(int maxSize)
Creates a new instance.

Parameters: maxSize maximum size for the command queue

Method Detail

addCommand

public void addCommand(String strCommand)
Adds any number of lines to the command history

Parameters: strCommand

addCommandLine

private void addCommandLine(String command)
Adds a single line to the bottom of the list, resets list position.

Parameters: command the String value of a command.

clear

public void clear()
clears the history.

getCommand

private String getCommand()
Calculates the command to return.

Returns: the String value of a command.

getCommandDown

public String getCommandDown()
Retrieves the following command from the top of the list, updates list position.

Returns: the String value of a command.

getCommandUp

public String getCommandUp()
Retrieves the following command from the bottom of the list, updates list position.

Returns: the String value of a command.

getSetHistory

public 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

removeCommand

public String removeCommand()

removeCommand

public String removeCommand(int n)

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.