Package org.aesh.readline.history
Class InMemoryHistory
java.lang.Object
org.aesh.readline.history.History
org.aesh.readline.history.InMemoryHistory
- Direct Known Subclasses:
FileHistory
A simple in-memory history implementation
By default max size is 500
- Author:
- Ståle W. Pedersen
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an InMemoryHistory with the default maximum size of 500 entries.InMemoryHistory(int maxSize) Creates an InMemoryHistory with the specified maximum size. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all entries from the history.int[]find(int[] search) Finds an entry in the history that matches the search.int[]get(int index) Gets the history entry at the specified index.List<int[]> getAll()Gets all entries in the history.int[]Gets the current line being edited.int[]Gets the next entry in the history (moving forward).int[]Gets the previous entry in the history (moving backward).Gets the current search direction.voidpush(int[] entry) Pushes a new entry to the history.int[]search(int[] search) Searches for an entry in the history that contains the search pattern.voidsetCurrent(int[] line) Sets the current line being edited (used for history navigation).voidsetSearchDirection(SearchDirection direction) Sets the search direction for history searches.intsize()Returns the number of entries in the history.voidstop()Stops the history and performs any necessary cleanup (e.g., saving to file).
-
Constructor Details
-
InMemoryHistory
public InMemoryHistory()Creates an InMemoryHistory with the default maximum size of 500 entries. -
InMemoryHistory
public InMemoryHistory(int maxSize) Creates an InMemoryHistory with the specified maximum size.- Parameters:
maxSize- the maximum number of history entries, or -1 for unlimited
-
-
Method Details
-
push
public void push(int[] entry) Description copied from class:HistoryPushes a new entry to the history. -
find
public int[] find(int[] search) Description copied from class:HistoryFinds an entry in the history that matches the search. -
get
public int[] get(int index) Description copied from class:HistoryGets the history entry at the specified index. -
size
public int size()Description copied from class:HistoryReturns the number of entries in the history. -
setSearchDirection
Description copied from class:HistorySets the search direction for history searches.- Specified by:
setSearchDirectionin classHistory- Parameters:
direction- the search direction
-
getSearchDirection
Description copied from class:HistoryGets the current search direction.- Specified by:
getSearchDirectionin classHistory- Returns:
- the current search direction
-
getPreviousFetch
public int[] getPreviousFetch()Description copied from class:HistoryGets the previous entry in the history (moving backward).- Specified by:
getPreviousFetchin classHistory- Returns:
- the previous history entry, or empty array if at the beginning
-
getNextFetch
public int[] getNextFetch()Description copied from class:HistoryGets the next entry in the history (moving forward).- Specified by:
getNextFetchin classHistory- Returns:
- the next history entry, or null if at the end
-
search
public int[] search(int[] search) Description copied from class:HistorySearches for an entry in the history that contains the search pattern. -
setCurrent
public void setCurrent(int[] line) Description copied from class:HistorySets the current line being edited (used for history navigation).- Specified by:
setCurrentin classHistory- Parameters:
line- the current line
-
getCurrent
public int[] getCurrent()Description copied from class:HistoryGets the current line being edited.- Specified by:
getCurrentin classHistory- Returns:
- the current line
-
getAll
Description copied from class:HistoryGets all entries in the history. -
clear
public void clear()Description copied from class:HistoryClears all entries from the history. -
stop
public void stop()Description copied from class:HistoryStops the history and performs any necessary cleanup (e.g., saving to file).
-