Skip to main content

RecallState

Struct RecallState 

Source
pub struct RecallState {
Show 19 fields engine: SearchEngine, filter_mode: FilterMode, host_filter: HostFilter, entries: Vec<HistoryEntry>, filtered_indices: Vec<(usize, Vec<u32>)>, query: String, selected_index: usize, scroll_offset: usize, term_height: u16, term_width: u16, keymap_mode: KeymapMode, show_preview: bool, preview_config: PreviewConfig, shell_mode: bool, db_query_used: Option<RecallQuery>, entry_cache: EntryCache, flash_until: Option<Instant>, status_message: Option<(String, Instant)>, needs_redraw: bool,
}
Expand description

The pure recall UI state machine: entries, cache, query, selection, scroll, keymaps, and frame rendering – everything except the terminal itself. Constructible without a tty, so key handling, scroll math, cache coverage, and drawing (into any Write) are all unit-testable.

Fields§

§engine: SearchEngine§filter_mode: FilterMode§host_filter: HostFilter§entries: Vec<HistoryEntry>§filtered_indices: Vec<(usize, Vec<u32>)>

Filtered indices with match positions: (entry_index, match_char_indices)

§query: String§selected_index: usize§scroll_offset: usize§term_height: u16§term_width: u16§keymap_mode: KeymapMode§show_preview: bool§preview_config: PreviewConfig§shell_mode: bool§db_query_used: Option<RecallQuery>§entry_cache: EntryCache§flash_until: Option<Instant>§status_message: Option<(String, Instant)>§needs_redraw: bool

Implementations§

Source§

impl RecallState

Source

fn new( engine: SearchEngine, initial_mode: FilterMode, initial_query: Option<String>, config: &RecallConfig, shell_mode: bool, ) -> Result<Self>

Source

fn set_dimensions(&mut self, width: u16, height: u16)

Source

fn expire_timed_effects(&mut self) -> bool

Clear expired timed effects (status message, flash); returns true if anything changed and a redraw is needed.

Source

fn results_height(&self) -> usize

Source

fn adjust_scroll_for_selection(&mut self)

Source

fn reload_entries(&mut self)

Reload entries from database and re-apply fuzzy filtering. Called when mode (directory/global) or host filter changes, which invalidates previously cached candidate sets. (Deletion keeps the live set and clears the cache in place instead.) Always loads the broad set (no query filter at DB level).

Source

fn update_filtered_indices(&mut self)

Apply fuzzy filtering to the current entries based on query. The query is parsed once here; the same parse drives both the candidate coverage check and the fuzzy stage, so the two cannot disagree about atom semantics.

Source

fn ensure_entries_cover_query(&mut self, query: &RecallQuery)

Ensure self.entries is a valid candidate superset for the current query, hitting the database only when no previously loaded set covers it. Queries >= 3 chars with at least one prefilterable atom want a DB-level LIKE dig so old commands beyond the initial result_limit window are included; shorter queries (and ones with no prefilterable atoms, e.g. pure negation “!vim”) want the broad recency window. Appending to a query is covered by the current set (LIKE ‘%abc%’ is a superset of LIKE ‘%abcd%’); backspacing restores the previous set from the cache. Only divergent edits reach the database.

Source

fn take_current_snapshot(&mut self) -> EntrySnapshot

Move the current candidate set out of self for caching.

Source

fn flash(&mut self)

Trigger a brief visual flash for feedback on unrecognized keys

Source

fn is_flashing(&self) -> bool

Check if flash effect is currently active

Source

fn copy_selected(&mut self) -> KeyAction

Stage the selected command for a clipboard copy. The terminal adapter performs the actual OSC 52 write; state only records the feedback.

Source

fn delete_selected_entry(&mut self)

Delete all database rows matching the selected entry’s command text, since the recall list is deduplicated by command.

Source

fn toggle_host_filter(&mut self)

Source

fn toggle_filter_mode(&mut self)

Source

fn print_entry_details(&self)

Source

fn get_selected_command(&self) -> Option<String>

Source

fn handle_key(&mut self, key: KeyEvent) -> Result<KeyAction>

Source

fn handle_common_key(&mut self, key: KeyEvent) -> Option<KeyAction>

Handle common keys that work in all modes

Source

fn handle_key_emacs(&mut self, key: KeyEvent) -> Result<KeyAction>

Source

fn handle_key_vim_insert(&mut self, key: KeyEvent) -> Result<KeyAction>

Source

fn handle_key_vim_normal(&mut self, key: KeyEvent) -> Result<KeyAction>

Source

fn move_selection_up(&mut self)

Source

fn move_selection_down(&mut self)

Source

fn page_up(&mut self)

Source

fn page_down(&mut self)

Source

fn insert_char(&mut self, c: char)

Source

fn delete_last_char(&mut self)

Source

fn clear_query(&mut self)

Source

fn delete_last_word(&mut self)

Source

fn draw_preview<W: Write>( &self, w: &mut W, start_y: u16, width: u16, ) -> Result<()>

Source

fn draw<W: Write>(&mut self, w: &mut W) -> Result<()>

Render a full frame into w using the current dimensions (see set_dimensions). Generic over the writer so tests can render into a buffer; the live path hands in a buffered /dev/tty.

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, 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.