pub struct History { /* private fields */ }
Expand description
Structure encapsulating command history
Implementations§
Source§impl History
impl History
pub fn set_max_contexts(&mut self, n: usize)
pub fn set_search_context(&mut self, context: Option<String>)
Sourcepub fn clear_history(&mut self)
pub fn clear_history(&mut self)
Clears out the history.
Sourcepub fn load_history(&mut self, append: bool) -> Result<()>
pub fn load_history(&mut self, append: bool) -> Result<()>
Loads the history file from the saved path and appends it to the end of the history if append is true otherwise replace history.
Sourcepub fn load_history_file<P: AsRef<Path>>(
&mut self,
path: P,
append: bool,
) -> Result<u64>
pub fn load_history_file<P: AsRef<Path>>( &mut self, path: P, append: bool, ) -> Result<u64>
Loads the history file from path and appends it to the end of the history if append is true.
Sourcepub fn set_file_name_and_load_history<P: AsRef<Path>>(
&mut self,
path: P,
) -> Result<u64>
pub fn set_file_name_and_load_history<P: AsRef<Path>>( &mut self, path: P, ) -> Result<u64>
Set history file name and at the same time load the history.
Sourcepub fn set_max_history_size(&mut self, size: usize)
pub fn set_max_history_size(&mut self, size: usize)
Set maximal number of buffers in history
Sourcepub fn push_throwaway(&mut self, new_item: impl Into<String>) -> Result<()>
pub fn push_throwaway(&mut self, new_item: impl Into<String>) -> Result<()>
Adds a “throwaway” history item. Any of these will be removed once push is called. Intended to allow “error” or other bad items to stick around long enough for the user to correct without cluttering history long term.
Sourcepub fn push(&mut self, new_item: impl Into<String>) -> Result<()>
pub fn push(&mut self, new_item: impl Into<String>) -> Result<()>
Add a command to the history buffer and remove the oldest commands when the max history size has been met. If writing to the disk is enabled, this function will be used for logging history to the designated history file.
Sourcepub fn get_newest_match(
&self,
curr_position: Option<usize>,
new_buff: &str,
) -> Option<usize>
pub fn get_newest_match( &self, curr_position: Option<usize>, new_buff: &str, ) -> Option<usize>
Go through the history and try to find an index (newest to oldest) which starts the same as the new buffer given to this function as argument. Starts at curr_position. Does not wrap.