pub struct PromptInputState {
pub mode: InputMode,
pub buffer: String,
pub cursor: usize,
pub history: Vec<String>,
pub history_idx: Option<usize>,
pub draft: String,
pub draft_mode: InputMode,
}Expand description
Mutable state of the multi-mode prompt input.
Owns the editing buffer, byte-cursor, in-session history, and a
stash slot for the user’s draft when they walk back through
history. Rendering is in crate::tui::ui::input.
Fields§
§mode: InputMode§buffer: String§cursor: usizeByte offset into [buffer]. Always at a char boundary.
history: Vec<String>Submitted entries, oldest first. Capped at
HISTORY_CAPACITY.
history_idx: Option<usize>Position when navigating history. None means “live draft”.
draft: StringStash slot: when the user starts walking history, the current buffer is preserved here and restored when they walk past the end.
draft_mode: InputModeStash for the current mode while walking history. Restored
alongside draft.
Implementations§
Source§impl PromptInputState
impl PromptInputState
pub fn new() -> Self
Sourcepub fn insert_char(&mut self, ch: char)
pub fn insert_char(&mut self, ch: char)
Insert a single character at the cursor. Updates cursor to
stay just past the inserted char.
Sourcepub fn backspace(&mut self) -> bool
pub fn backspace(&mut self) -> bool
Delete the character to the left of the cursor (Backspace).
Returns true if a char was deleted.
Sourcepub fn delete_forward(&mut self)
pub fn delete_forward(&mut self)
Delete the character at the cursor (Delete key).
Sourcepub fn move_right(&mut self)
pub fn move_right(&mut self)
Move cursor one char right.
Sourcepub fn move_prev_line(&mut self)
pub fn move_prev_line(&mut self)
Move cursor to the same column on the previous visual line.
No-op when the cursor is already on the first line. If the
previous line is shorter than the current column, the cursor
lands at the end of the previous line (emacs previous-line
semantics).
Sourcepub fn move_next_line(&mut self)
pub fn move_next_line(&mut self)
Move cursor to the same column on the next visual line.
No-op when the cursor is already on the last line. If the
next line is shorter than the current column, the cursor
lands at the end of the next line (emacs next-line
semantics).
Sourcepub fn cursor_on_first_line(&self) -> bool
pub fn cursor_on_first_line(&self) -> bool
True when the cursor sits on the first visual line.
Sourcepub fn cursor_on_last_line(&self) -> bool
pub fn cursor_on_last_line(&self) -> bool
True when the cursor sits on the last visual line.
Sourcepub fn history_prev(&mut self) -> bool
pub fn history_prev(&mut self) -> bool
Walk history one step back (older). Returns true if state
changed.
Sourcepub fn history_next(&mut self) -> bool
pub fn history_next(&mut self) -> bool
Walk history one step forward (newer). Restores the draft
when stepping past the most-recent entry. Returns true if
state changed.
Sourcepub fn record_submission(&mut self, prefixed: String)
pub fn record_submission(&mut self, prefixed: String)
Push the just-submitted entry onto the history ring (with mode prefix) and reset transient state.
Trait Implementations§
Source§impl Clone for PromptInputState
impl Clone for PromptInputState
Source§fn clone(&self) -> PromptInputState
fn clone(&self) -> PromptInputState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PromptInputState
impl Debug for PromptInputState
Source§impl Default for PromptInputState
impl Default for PromptInputState
impl Eq for PromptInputState
Source§impl PartialEq for PromptInputState
impl PartialEq for PromptInputState
Source§fn eq(&self, other: &PromptInputState) -> bool
fn eq(&self, other: &PromptInputState) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for PromptInputState
Auto Trait Implementations§
impl Freeze for PromptInputState
impl RefUnwindSafe for PromptInputState
impl Send for PromptInputState
impl Sync for PromptInputState
impl Unpin for PromptInputState
impl UnsafeUnpin for PromptInputState
impl UnwindSafe for PromptInputState
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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