pub struct History {
pub buffers: VecDeque<Buffer>,
pub append_duplicate_entries: bool,
pub inc_append: bool,
pub share: bool,
pub file_size: u64,
pub load_duplicates: bool,
/* private fields */
}
Expand description
Structure encapsulating command history
Fields§
§buffers: VecDeque<Buffer>
Vector of buffers to store history in
append_duplicate_entries: bool
§inc_append: bool
Append each entry to history file as entered?
Share history across ion’s with the same history file (combine with inc_append).
file_size: u64
Last filesize of history file, used to optimize history sharing.
load_duplicates: bool
Allow loading duplicate entries, need to know this for loading history files.
Implementations§
Source§impl History
impl History
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<u64>
pub fn load_history(&mut self, append: bool) -> Result<u64>
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_buffers_size(&mut self, size: usize)
pub fn set_max_buffers_size(&mut self, size: usize)
Set maximal number of buffers stored in memory
Sourcepub fn set_max_file_size(&mut self, size: usize)
pub fn set_max_file_size(&mut self, size: usize)
Set maximal number of entries in history file
Sourcepub fn push(&mut self, new_item: Buffer) -> Result<()>
pub fn push(&mut self, new_item: Buffer) -> 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 remove_duplicates(&mut self, input: &str)
pub fn remove_duplicates(&mut self, input: &str)
Removes duplicate entries in the history
Sourcepub fn get_newest_match(
&self,
curr_position: Option<usize>,
new_buff: &Buffer,
) -> Option<usize>
pub fn get_newest_match( &self, curr_position: Option<usize>, new_buff: &Buffer, ) -> 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 no wrap.
pub fn get_history_subset(&self, search_term: &Buffer) -> Vec<usize>
pub fn search_index(&self, search_term: &Buffer) -> Vec<usize>
pub fn commit_to_file_path<P: AsRef<Path>>(&mut self, path: P) -> Result<String>
pub fn commit_to_file(&mut self)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for History
impl RefUnwindSafe for History
impl Send for History
impl Sync for History
impl Unpin for History
impl UnwindSafe for History
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more