Skip to main content

Module tui

Module tui 

Source

Structsยง

EntryCache ๐Ÿ”’
Bounded cache of candidate sets from previous DB loads. Backspacing (or re-typing) a query restores a previous set by moving it out of the cache instead of re-scanning the table, which costs ~100ms at 500k rows.
EntrySnapshot ๐Ÿ”’
A candidate entry set as loaded for a particular DB-level query (None = the broad, unfiltered recency window).
RecallState
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.
RecallTerminal ๐Ÿ”’
The terminal adapter: raw mode, /dev/tty, keyboard enhancement, and the restore-exactly-once guard. The only piece of recall that needs a real terminal; everything behind it renders to a plain Write.
RecallTui
The interactive recall UI: a RecallState driven by events from a RecallTerminal.

Enumsยง

KeyAction ๐Ÿ”’

Constantsยง

FLASH_DURATION_MS ๐Ÿ”’
PREVIEW_HEIGHT ๐Ÿ”’
SCROLL_MARGIN ๐Ÿ”’

Functionsยง

base64_encode ๐Ÿ”’
Base64-encode bytes for OSC 52 clipboard escape.
char_width ๐Ÿ”’
Highlight a command using pre-computed match indices from fuzzy matching. Returns spans with (text, is_highlight) pairs. Terminal columns a character occupies: 2 for East Asian wide, 0 for combining marks and controls.
deduplicate_entries ๐Ÿ”’
Deduplicate history entries by command string, keeping the most recent occurrence. Entries are already sorted by timestamp (most recent first), so we keep the first occurrence of each command, accumulating the number of collapsed duplicates in its use_count for the frequency component of scoring. Trailing whitespace is ignored for dedup since โ€œdf -hโ€ and โ€œdf -h โ€œ are visually identical and semantically the same.
enter_recall_screen ๐Ÿ”’
Switch the terminal into recall mode: alternate screen, hidden cursor, and (off Windows) the kitty keyboard protocol for instant Escape. Returns whether keyboard enhancement was requested, for the matching pop.
format_duration ๐Ÿ”’
highlight_command_with_indices ๐Ÿ”’
leave_recall_screen ๐Ÿ”’
Undo enter_recall_screen.
sanitize_for_display ๐Ÿ”’
Sanitize a string for safe terminal display by removing ANSI escape sequences and control characters that could affect cursor position or terminal state.
truncate_to_width ๐Ÿ”’
Cut s to at most max_width terminal columns, ending in โ€œโ€ฆโ€ when cut.