pub struct TextInput { /* private fields */ }Expand description
A multi-line text input with its own wrapping, cursor tracking, and rendering.
Implementations§
Source§impl TextInput
impl TextInput
pub fn new() -> Self
pub fn insert_char(&mut self, ch: char)
Sourcepub fn insert_str(&mut self, s: &str)
pub fn insert_str(&mut self, s: &str)
Insert an arbitrary string at the cursor (e.g. from a bracketed paste). The cursor advances to the end of the inserted text.
Line breaks are normalized to \n (see [normalize_line_breaks]).
pub fn backspace(&mut self)
pub fn delete(&mut self)
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)
Move the cursor up one visual (wrapped) line. If the cursor is already on the first line, it moves to the beginning.
Sourcepub fn move_down(&mut self)
pub fn move_down(&mut self)
Move the cursor down one visual (wrapped) line. If the cursor is already on the last line, it moves to the end.
Sourcepub fn move_word_left(&mut self)
pub fn move_word_left(&mut self)
Move cursor one word to the left (Option+Left / Ctrl+Left).
Sourcepub fn move_word_right(&mut self)
pub fn move_word_right(&mut self)
Move cursor one word to the right (Option+Right / Ctrl+Right).
Sourcepub fn delete_word_left(&mut self)
pub fn delete_word_left(&mut self)
Delete the word to the left of the cursor (Option+Backspace).
Sourcepub fn insert_newline(&mut self)
pub fn insert_newline(&mut self)
Insert a newline at the cursor (Shift+Enter).
Sourcepub fn handle_keystroke(&mut self, key: KeyEvent) -> KeyResult
pub fn handle_keystroke(&mut self, key: KeyEvent) -> KeyResult
Handle a key event. Returns KeyResult::Captured if the event was consumed by the
input area, KeyResult::NotCaptured if it should fall through to other handlers.
Sourcepub fn take_text(&mut self) -> String
pub fn take_text(&mut self) -> String
Take the current text, clear the buffer, and reset the cursor.
pub fn text(&self) -> &str
pub fn set_text(&mut self, s: &str)
pub fn is_empty(&self) -> bool
Sourcepub fn preferred_height(&self, outer_width: u16) -> u16
pub fn preferred_height(&self, outer_width: u16) -> u16
The total height this widget wants given a particular outer width. Includes top/bottom padding rows.
Sourcepub fn render(&self, area: Rect, buf: &mut Buffer) -> RenderResult
pub fn render(&self, area: Rect, buf: &mut Buffer) -> RenderResult
Render into the given area and return the cursor screen position.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for TextInput
impl !RefUnwindSafe for TextInput
impl !Sync for TextInput
impl Send 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> 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