Package com.j3d.engine.interact.cmd
Class RunHistory
java.lang.Object
com.j3d.engine.interact.cmd.RunHistory
Manages the history of executed commands in the command palette.
It provides functionality to navigate through the command history using up() and down() methods,
and to commit new commands to the history using commit(String).
- Author:
- Lehlogonolo Poole
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCommits a command line to the history.down()Navigates down through the command history.private voidremoveFirstIfFull(ArrayList<String> arr) Removes the first element from the given ArrayList if its size reaches the maximum limit.up()Navigates up through the command history.
-
Field Details
-
history
-
backup
-
-
Constructor Details
-
RunHistory
public RunHistory()Constructs a newRunHistory.
-
-
Method Details
-
commit
Commits a command line to the history.This clears the backup history and adds the new command to the main history.
- Parameters:
line- The command line to commit.
-
up
Navigates up through the command history.Moves the last command from the main history to the backup history and returns it.
- Returns:
- The previous command in the history, or an empty string if the history is empty.
-
down
Navigates down through the command history.Moves the last command from the backup history back to the main history and returns it.
- Returns:
- The next command in the history, or an empty string if the backup history is empty.
-
removeFirstIfFull
Removes the first element from the given ArrayList if its size reaches the maximum limit.This method ensures that the history lists do not grow indefinitely.
- Parameters:
arr- The ArrayList to check and modify.
-