pub struct Input { /* private fields */ }Expand description
Holds the chars typed by the user and the cursor position. Methods allow mutation of this content and movement of the cursor.
Implementations§
Source§impl Input
impl Input
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn display_index(&self, available_space: usize) -> usize
pub fn display_index(&self, available_space: usize) -> usize
Index on screen of the cursor. It’s the index minus the left index considering the available space.
Sourcepub fn scrolled_string(&self, available_space: usize) -> String
pub fn scrolled_string(&self, available_space: usize) -> String
Returns the displayable input as a string accounting for available space. If the text is short enough to be displayed completely it’s the string it self.
Sourcepub fn insert_string(&mut self, pasted: &str)
pub fn insert_string(&mut self, pasted: &str)
Insert a pasted string at current position.
Sourcepub fn cursor_start(&mut self)
pub fn cursor_start(&mut self)
Move the cursor to the start
Sourcepub fn cursor_end(&mut self)
pub fn cursor_end(&mut self)
Move the cursor to the end
Sourcepub fn cursor_left(&mut self)
pub fn cursor_left(&mut self)
Move the cursor left if possible
Sourcepub fn cursor_right(&mut self)
pub fn cursor_right(&mut self)
Move the cursor right if possible
Sourcepub fn cursor_move(&mut self, index: usize)
pub fn cursor_move(&mut self, index: usize)
Move the cursor to the given index, limited to the length of the input.
Used when the user click on the input string.
Sourcepub fn delete_char_left(&mut self)
pub fn delete_char_left(&mut self)
Backspace, delete the char under the cursor and move left
Sourcepub fn delete_chars_right(&mut self)
pub fn delete_chars_right(&mut self)
Delete all chars right to the cursor
pub fn delete_line(&mut self)
Sourcepub fn delete_left(&mut self)
pub fn delete_left(&mut self)
Deletes left symbols until a word is reached or the start of the line A word is delimited by a “separator” \t/\.,;!?%_-+*(){}[]
Sourcepub fn replace(&mut self, content: &str)
pub fn replace(&mut self, content: &str)
Replace the content with the new content. Put the cursor at the end.
To avoid splitting graphemes at wrong place, the new content is read as Unicode Graphemes with
unicode_segmentation::UnicodeSegmentation::graphemes(content, true)See UnicodeSegmentation for more information.
Sourcepub fn next_word(&mut self)
pub fn next_word(&mut self)
Move the cursor to the previous “word”. A word is delimited by a “separator” \t/\.,;!?%_-+*(){}[]
Sourcepub fn previous_word(&mut self)
pub fn previous_word(&mut self)
Move the cursor to the previous “word”. A word is delimited by a “separator” \t/\.,;!?%_-+*(){}[]
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Input
impl RefUnwindSafe for Input
impl Send for Input
impl Sync for Input
impl Unpin for Input
impl UnwindSafe for Input
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for 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