pub struct InputStates {
pub input: Vec<char>,
pub cursor: usize,
pub display_offset: usize,
pub last_width: Option<u16>,
}Expand description
The state that needs to be kept for the Input component.
Fields§
§input: Vec<char>The current input text
cursor: usizeThe cursor into “input”, used as a index on where a character gets added next
display_offset: usizeThe display offset for scrolling, always tries to keep the cursor within bounds
last_width: Option<u16>The last drawn width of the component that displays “input”.
This is necessary to keep “display_offset” from jumping around on width changes.
Implementations§
Source§impl InputStates
impl InputStates
Sourcepub fn append(&mut self, ch: char, itype: &InputType, max_len: Option<usize>)
pub fn append(&mut self, ch: char, itype: &InputType, max_len: Option<usize>)
Append a character, if possible according to input type.
Sourcepub fn incr_cursor(&mut self)
pub fn incr_cursor(&mut self)
Increment cursor by one if possible. (also known as moving RIGHT)
Sourcepub fn decr_cursor(&mut self)
pub fn decr_cursor(&mut self)
Decrement cursor value by one if possible. (also known as moving LEFT)
Sourcepub fn cursor_at_begin(&mut self)
pub fn cursor_at_begin(&mut self)
Move the cursor to the beginning of the input.
Sourcepub fn cursor_at_end(&mut self)
pub fn cursor_at_end(&mut self)
Move the cursor the the end of the input.
Sourcepub fn update_width(&mut self, new_width: u16)
pub fn update_width(&mut self, new_width: u16)
Update the last width used to display InputStates::input.
This is necessary to update InputStates::display_offset correctly and keep it
from jumping around on width changes.
Without using this function, no scrolling will effectively be applied.
Sourcepub fn render_value(&self, itype: &InputType) -> String
pub fn render_value(&self, itype: &InputType) -> String
Get the full text to render in the input, according to the InputType.
Sourcepub fn render_value_offset(&self, itype: &InputType) -> String
pub fn render_value_offset(&self, itype: &InputType) -> String
Get the partial text to render, according to the InputType.
Unlike InputStates::render_value, this will only collect the actually displayed text in the returned String.
Sourcepub fn render_value_chars(&self, itype: &InputType) -> Vec<char>
pub fn render_value_chars(&self, itype: &InputType) -> Vec<char>
Get the characters to render, according to InputType.
It is recommended to use render_value or render_value_offset over this function.
Trait Implementations§
Source§impl Debug for InputStates
impl Debug for InputStates
Source§impl Default for InputStates
impl Default for InputStates
Source§fn default() -> InputStates
fn default() -> InputStates
Auto Trait Implementations§
impl Freeze for InputStates
impl RefUnwindSafe for InputStates
impl Send for InputStates
impl Sync for InputStates
impl Unpin for InputStates
impl UnsafeUnpin for InputStates
impl UnwindSafe for InputStates
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> 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