pub struct PromptBuffer { /* private fields */ }Implementations§
Source§impl PromptBuffer
impl PromptBuffer
pub fn new() -> Self
pub fn is_empty(&self) -> bool
Sourcepub const fn cursor_row(&self) -> usize
pub const fn cursor_row(&self) -> usize
Current cursor row (0-based).
Sourcepub fn cursor_column(&self) -> u16
pub fn cursor_column(&self) -> u16
Same as [cursor] but as a u16 for ratatui’s column API.
Sourcepub fn line(&self, row: usize) -> Option<&[char]>
pub fn line(&self, row: usize) -> Option<&[char]>
Read a row’s contents — used by the widget for rendering.
Sourcepub const fn history(&self) -> &PromptHistory
pub const fn history(&self) -> &PromptHistory
Borrowed access to the history ring (read-only).
Sourcepub fn insert(&mut self, c: char)
pub fn insert(&mut self, c: char)
Insert a literal character at the cursor. Discards the history-recall flag — once you start typing on a recalled entry it’s part of your draft.
Sourcepub fn insert_newline(&mut self)
pub fn insert_newline(&mut self)
Shift+Enter — break the current line at the cursor and
move down. Capped at MAX_LINES; further newlines are
silently dropped so a stuck Repeat key cannot grow the
prompt indefinitely.
Sourcepub fn backspace(&mut self)
pub fn backspace(&mut self)
Backspace — delete the char to the left of the cursor; if at column 0 of a non-first row, merge with the previous row instead.
Sourcepub fn delete(&mut self)
pub fn delete(&mut self)
Delete — char at the cursor, or if at end of line, splice the next line up.
pub fn move_left(&mut self)
pub fn move_right(&mut self)
pub fn move_home(&mut self)
pub fn move_end(&mut self)
Sourcepub fn move_up(&mut self)
pub fn move_up(&mut self)
Up arrow — intra-buffer movement. The caller (input.rs) is responsible for routing Up to history recall when the cursor is at the first row; this method only moves up inside a multi-line buffer.
pub fn move_down(&mut self)
Sourcepub const fn cursor_on_first_row(&self) -> bool
pub const fn cursor_on_first_row(&self) -> bool
True when the cursor is on the visual top row of the buffer. Input router uses this to decide whether Up should recall history or move within the buffer.
Sourcepub fn cursor_on_last_row(&self) -> bool
pub fn cursor_on_last_row(&self) -> bool
True when the cursor is on the visual last row.
Sourcepub fn recall_prev(&mut self)
pub fn recall_prev(&mut self)
Recall the previous (older) history entry. Stashes the
live draft on first use so a subsequent recall_next
past the newest can restore it.
Sourcepub fn recall_next(&mut self)
pub fn recall_next(&mut self)
Recall the next (newer) history entry, or restore the saved draft when stepping past the newest entry.
Sourcepub fn take(&mut self) -> Option<String>
pub fn take(&mut self) -> Option<String>
Submit the buffer. Returns None for an all-whitespace
buffer so the caller can short-circuit. Also pushes the
joined text onto history and resets the recall cursor.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Discard the buffer and reset the cursor, but keep history intact. Used by Esc.
Sourcepub fn replace_all(&mut self, s: &str)
pub fn replace_all(&mut self, s: &str)
Replace the whole buffer with a literal value (used by the slash-command picker on Tab-complete). Cursor lands at end-of-buffer.
Trait Implementations§
Source§impl Debug for PromptBuffer
impl Debug for PromptBuffer
Auto Trait Implementations§
impl Freeze for PromptBuffer
impl RefUnwindSafe for PromptBuffer
impl Send for PromptBuffer
impl Sync for PromptBuffer
impl Unpin for PromptBuffer
impl UnsafeUnpin for PromptBuffer
impl UnwindSafe for PromptBuffer
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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