pub struct TextInput { /* private fields */ }Expand description
Single-line editable text with a cursor. cursor is a byte offset
into buf, always kept on a char boundary and within
0..=buf.len().
Implementations§
Source§impl TextInput
impl TextInput
Sourcepub fn with_text(text: impl Into<String>) -> Self
pub fn with_text(text: impl Into<String>) -> Self
Seed with existing text, cursor at the end — the natural spot when editing a pre-filled value (e.g. a rename).
Sourcepub fn trimmed(&self) -> &str
pub fn trimmed(&self) -> &str
The text with surrounding whitespace trimmed (for accept-time validation).
Sourcepub fn cursor_col(&self) -> usize
pub fn cursor_col(&self) -> usize
Display column of the cursor — the number of characters before it. Renderers add this to the input box’s left edge to place the terminal cursor.
Sourcepub fn insert_str(&mut self, s: &str)
pub fn insert_str(&mut self, s: &str)
Insert a string at the cursor (paste), advancing past it.
Sourcepub fn delete_forward(&mut self)
pub fn delete_forward(&mut self)
Delete the char at the cursor (Delete). No-op at the end.
Sourcepub fn delete_word_back(&mut self)
pub fn delete_word_back(&mut self)
Delete the word before the cursor (Ctrl-W): the run of trailing spaces, then the run of non-space chars up to the previous space.
Sourcepub fn handle_key(&mut self, key: KeyEvent) -> bool
pub fn handle_key(&mut self, key: KeyEvent) -> bool
Apply a single editing keypress. Returns true if the key was an
editing action (consumed), false if the caller should handle it
(Enter/Esc/Tab/…). Ctrl/Alt/Super-modified keys other than
the recognised emacs-style chords are left unhandled so global
chords (and OS shortcuts like Cmd+V on terminals that report the
Super modifier) still reach the dispatcher rather than being typed
as text.
Trait Implementations§
impl Eq for TextInput
impl StructuralPartialEq for TextInput
Auto Trait Implementations§
impl Freeze for TextInput
impl RefUnwindSafe for TextInput
impl Send for TextInput
impl Sync for TextInput
impl Unpin for TextInput
impl UnsafeUnpin for TextInput
impl UnwindSafe for TextInput
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<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