# Class CommandHistory

java.lang.Object
org.jmol.util.CommandHistory

public final class CommandHistory extends Object
Implements a queue for a bash-like command history.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`ERROR_FLAG`
`static final String`
`NOHISTORYATALL_FLAG`
`static final String`
`NOHISTORYLINE_FLAG`

## Constructor Summary

Constructors
Constructor
Description
`CommandHistory()`
Creates a new instance using the default size (100)

## Method Summary

Modifier and Type
Method
Description
`void`
`addCommand(String strCommand)`
Adds any number of lines to the command history
`void`
`clear()`
clears the history.
`String`
`find(String cmd, int dir)`
`String`
`getCommandDown()`
Retrieves the following command from the top of the list, updates list position.
`String`
`getCommandUp()`
Retrieves the following command from the bottom of the list, updates list position.
`String`
`getSetHistory(int n)`
Options include: all Integer.MAX_VALUE n prev n >= 1 next -1 set max to -2 - n n invalid input: '<'= -3 just clear -2 clear and turn off; return "" 0 clear and turn on; return "" Integer.MIN_VALUE;
`String`
`popState()`
`void`
`pushState(String stateInfo)`
`String`
`removeCommand()`
`String`
`removeCommand(int n)`
`void`
`reset(int maxSize)`
Resets instance.
`void`
`setMaxSize(int maxSize)`
Resets maximum size of command queue.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### ERROR_FLAG

public static final String ERROR_FLAG

See Also:
  - Constant Field Values

### NOHISTORYLINE_FLAG

public static final String NOHISTORYLINE_FLAG

See Also:
  - Constant Field Values

### NOHISTORYATALL_FLAG

public static final String NOHISTORYATALL_FLAG

See Also:
  - Constant Field Values

## Constructor Details

### CommandHistory

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

## Method Details

### 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 String getCommandUp()
Retrieves the following command from the bottom of the list, updates list position.

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.

### addCommand

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

Parameters:
  `strCommand` -

### getSetHistory

public String getSetHistory(int n)
Options include: all Integer.MAX_VALUE n prev n >= 1 next -1 set max to -2 - n n invalid input: '<'= -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 String find(String cmd, int dir)

### removeCommand

public String removeCommand()

### removeCommand

public String removeCommand(int n)

### pushState

public void pushState(String stateInfo)

### popState

public String popState()