Skip to main content

History

Struct History 

Source
pub struct History {
Show 14 fields pub curhist: i64, pub histlinect: i64, pub histsiz: i64, pub savehistsiz: i64, pub histactive: u32, pub stophist: i32, pub histdone: i32, pub hist_skip_flags: i32, pub hist_ignore_all_dups: bool, pub curline: Option<HistEntry>, pub hsubl: Option<String>, pub hsubr: Option<String>, pub bangchar: char, pub histfile: Option<String>, /* private fields */
}
Expand description

History state

Fields§

§curhist: i64

Current history number

§histlinect: i64

History line count

§histsiz: i64

History size limit

§savehistsiz: i64

Save history size

§histactive: u32

History active state

§stophist: i32

Stop history flag

§histdone: i32

History done flags

§hist_skip_flags: i32

History skip flags

§hist_ignore_all_dups: bool

Ignore all dups

§curline: Option<HistEntry>

Current line being edited

§hsubl: Option<String>

History substitution patterns

§hsubr: Option<String>§bangchar: char

Bang character

§histfile: Option<String>

History file path

Implementations§

Source§

impl History

Source

pub fn new() -> Self

Source

pub fn init(&mut self)

Initialize history

Source

pub fn hbegin(&mut self, interactive: bool)

Begin history for a new command

Source

pub fn hend(&mut self, text: Option<String>) -> bool

End history for current command

Source

pub fn get(&self, num: i64) -> Option<&HistEntry>

Get entry by history number

Source

pub fn latest(&self) -> Option<&HistEntry>

Get the most recent entry

Source

pub fn recent(&self, n: usize) -> Option<&HistEntry>

Get the n-th most recent entry (0 = latest)

Source

pub fn search_back(&self, pattern: &str, start: i64) -> Option<&HistEntry>

Search history backwards for a pattern

Source

pub fn search_forward(&self, pattern: &str, start: i64) -> Option<&HistEntry>

Search history forwards for a pattern

Source

pub fn expand(&mut self, line: &str) -> Result<String, String>

Perform history substitution

Source

pub fn read_file(&mut self, path: &Path) -> Result<()>

Read history file

Source

pub fn write_file(&self, path: &Path, append: bool) -> Result<()>

Write history file

Source

pub fn clear(&mut self)

Clear all history

Source

pub fn all_entries(&self) -> Vec<&HistEntry>

Get all entries in order

Source

pub fn len(&self) -> usize

Number of entries

Source

pub fn is_empty(&self) -> bool

Check if empty

Source§

impl History

History search containing pattern (from hist.c hconsearch lines 1836-1854)

Source

pub fn hconsearch(&self, pattern: &str) -> Option<(i64, usize)>

Source

pub fn hcomsearch(&self, prefix: &str) -> Option<i64>

History search by prefix (from hist.c hcomsearch lines 1859-1872)

Source

pub fn getargs(&self, ev: i64, arg1: usize, arg2: usize) -> Option<String>

Get arguments from history entry (from hist.c getargs lines 2453-2482)

Source

pub fn save_context(&self) -> HistStack

Save history context (from hist.c hist_context_save lines 248-290)

Source

pub fn restore_context(&mut self, ctx: &HistStack)

Restore history context (from hist.c hist_context_restore lines 296-325)

Source

pub fn hist_in_word(&mut self, yesno: bool)

Set history in-word state (from hist.c hist_in_word lines 339-345)

Source

pub fn hist_is_in_word(&self) -> bool

Check if in word (from hist.c hist_is_in_word lines 348-352)

Source

pub fn addhistnum(&self, hl: i64, n: i64) -> i64

Add history number with offset (from hist.c addhistnum lines 1265-1280)

Source

pub fn histreduceblanks(line: &str, words: &[(usize, usize)]) -> String

Reduce blanks in history line (from hist.c histreduceblanks lines 1199-1250)

Source

pub fn resizehistents(&mut self)

Resize history entries to fit histsiz (from hist.c resizehistents lines 2620-2632)

Source

pub fn readhistfile(&mut self, filename: &str, err: bool) -> Result<usize>

Read history file (from hist.c readhistfile lines 2675-2920)

Source

pub fn savehistfile(&self, filename: &str, mode: WriteMode) -> Result<usize>

Write history file (from hist.c savehistfile lines 2925-3155)

Source

pub fn lockhistfile(&self, filename: &str, _excl: bool) -> Result<()>

Lock history file (from hist.c lockhistfile lines 2961-2998)

Source

pub fn unlockhistfile(&self, filename: &str) -> Result<()>

Unlock history file (from hist.c unlockhistfile lines 3001-3018)

Source

pub fn quotestring(s: &str) -> String

Quote string for history (from hist.c quotestring lines 2483-2523)

Source

pub fn get_history_word(line: &str, idx: usize) -> Option<&str>

History word split (from hist.c get_history_word)

Source

pub fn histword_count(line: &str) -> usize

Count words in history line

Source§

impl History

History entry navigation (from hist.c movehistent/up_histent/down_histent)

Source

pub fn movehistent(&self, start: i64, n: i64) -> Option<&HistEntry>

Move n entries in history (from hist.c movehistent)

Source

pub fn up_histent(&self, current: i64) -> Option<&HistEntry>

Move up one entry (from hist.c up_histent)

Source

pub fn down_histent(&self, current: i64) -> Option<&HistEntry>

Move down one entry (from hist.c down_histent)

Source

pub fn gethistent(&self, ev: i64, near_match: bool) -> Option<&HistEntry>

Get history entry by event number with near-match (from hist.c gethistent)

Source

pub fn prepnexthistent(&mut self) -> i64

Prepare next history entry (from hist.c prepnexthistent)

Trait Implementations§

Source§

impl Default for History

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more