Class History
java.lang.Object
org.aesh.readline.history.History
- Direct Known Subclasses:
InMemoryHistory
Abstract base class for managing command line history.
- Author:
- Ståle W. Pedersen
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidclear()Clears all entries from the history.voiddisable()Disables history tracking.voidenable()Enables history tracking.abstract int[]find(int[] search) Finds an entry in the history that matches the search.abstract int[]get(int index) Gets the history entry at the specified index.abstract List<int[]> getAll()Gets all entries in the history.abstract int[]Gets the current line being edited.abstract int[]Gets the next entry in the history (moving forward).abstract int[]Gets the previous entry in the history (moving backward).abstract SearchDirectionGets the current search direction.booleanChecks if history is enabled.abstract voidpush(int[] entry) Pushes a new entry to the history.abstract int[]search(int[] search) Searches for an entry in the history that contains the search pattern.abstract voidsetCurrent(int[] line) Sets the current line being edited (used for history navigation).abstract voidsetSearchDirection(SearchDirection direction) Sets the search direction for history searches.abstract intsize()Returns the number of entries in the history.abstract voidstop()Stops the history and performs any necessary cleanup (e.g., saving to file).
-
Constructor Details
-
History
protected History()Protected constructor for subclasses.
-
-
Method Details
-
isEnabled
public boolean isEnabled()Checks if history is enabled.- Returns:
- true if history is enabled, false otherwise
-
enable
public void enable()Enables history tracking. -
disable
public void disable()Disables history tracking. -
push
public abstract void push(int[] entry) Pushes a new entry to the history.- Parameters:
entry- the entry to add
-
find
public abstract int[] find(int[] search) Finds an entry in the history that matches the search.- Parameters:
search- the search pattern- Returns:
- the matching entry, or null if not found
-
get
public abstract int[] get(int index) Gets the history entry at the specified index.- Parameters:
index- the index of the entry to retrieve- Returns:
- the history entry at the specified index
-
size
public abstract int size()Returns the number of entries in the history.- Returns:
- the size of the history
-
setSearchDirection
Sets the search direction for history searches.- Parameters:
direction- the search direction
-
getSearchDirection
Gets the current search direction.- Returns:
- the current search direction
-
getNextFetch
public abstract int[] getNextFetch()Gets the next entry in the history (moving forward).- Returns:
- the next history entry, or null if at the end
-
getPreviousFetch
public abstract int[] getPreviousFetch()Gets the previous entry in the history (moving backward).- Returns:
- the previous history entry, or empty array if at the beginning
-
search
public abstract int[] search(int[] search) Searches for an entry in the history that contains the search pattern.- Parameters:
search- the search pattern- Returns:
- the matching entry, or null if not found
-
setCurrent
public abstract void setCurrent(int[] line) Sets the current line being edited (used for history navigation).- Parameters:
line- the current line
-
getCurrent
public abstract int[] getCurrent()Gets the current line being edited.- Returns:
- the current line
-
getAll
Gets all entries in the history.- Returns:
- a list of all history entries
-
clear
public abstract void clear()Clears all entries from the history. -
stop
public abstract void stop()Stops the history and performs any necessary cleanup (e.g., saving to file).
-