Struct rat_widget::masked_input::core::InputMaskCore
source · pub struct InputMaskCore { /* private fields */ }Expand description
Text editing core.
Implementations§
source§impl InputMaskCore
impl InputMaskCore
pub fn new() -> Self
pub fn new_with_symbols(sym: NumberSymbols) -> Self
sourcepub fn set_offset(&mut self, offset: usize)
pub fn set_offset(&mut self, offset: usize)
Change the offset.
Ensures the cursor is visible and modifies any given offset. Ensures the offset is not beyond the length.
pub fn set_cursor(&mut self, cursor: usize, extend_selection: bool) -> bool
sourcepub fn set_default_cursor(&mut self)
pub fn set_default_cursor(&mut self)
Place cursor at decimal separator, if any. 0 otherwise.
pub fn anchor(&self) -> usize
sourcepub fn set_num_symbols(&mut self, sym: NumberSymbols)
pub fn set_num_symbols(&mut self, sym: NumberSymbols)
Set the decimal separator and other symbols. Only used for rendering and to map user input. The value itself uses “.”
sourcepub fn set_mask<S: AsRef<str>>(&mut self, s: S) -> Result<(), Error>
pub fn set_mask<S: AsRef<str>>(&mut self, s: S) -> Result<(), Error>
Changes the mask. Resets the value to a default.
sourcepub fn debug_mask(&self) -> String
pub fn debug_mask(&self) -> String
Return the mask.
sourcepub fn set_display_mask<S: Into<String>>(&mut self, s: S)
pub fn set_display_mask<S: Into<String>>(&mut self, s: S)
Set the mask that is shown.
sourcepub fn display_mask(&self) -> String
pub fn display_mask(&self) -> String
Display mask
sourcepub fn default_value(&self) -> String
pub fn default_value(&self) -> String
Create a default value according to the mask.
sourcepub fn set_value<S: Into<String>>(&mut self, s: S)
pub fn set_value<S: Into<String>>(&mut self, s: S)
Sets the value. No checks if the value conforms to the mask. If the value is too short it will be filled with space. if the value is too long it will be truncated.
sourcepub fn value_graphemes(&self) -> Graphemes<'_>
pub fn value_graphemes(&self) -> Graphemes<'_>
Value as grapheme iterator.
sourcepub fn value_parts(&self) -> Vec<String>
pub fn value_parts(&self) -> Vec<String>
Value split along any separators
sourcepub fn compact_value(&self) -> String
pub fn compact_value(&self) -> String
Value without whitespace and grouping separators. Might be easier to parse.
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Reset value but not the mask and width. Resets offset and cursor position too.
pub fn has_selection(&self) -> bool
pub fn is_select_all(&self) -> bool
pub fn selection(&self) -> Range<usize>
sourcepub fn render_value(&mut self)
pub fn render_value(&mut self)
Create the rendered value.
sourcepub fn render_condensed_value(&mut self)
pub fn render_condensed_value(&mut self)
Create the rendered value.
sourcepub fn byte_pos(&self, byte_pos: usize) -> Option<usize>
pub fn byte_pos(&self, byte_pos: usize) -> Option<usize>
Convert the byte-position to a grapheme position.
sourcepub fn byte_at(&self, pos: usize) -> Option<(usize, usize)>
pub fn byte_at(&self, pos: usize) -> Option<(usize, usize)>
Grapheme position to byte position. Returns the byte-range for the grapheme at pos.
sourcepub fn char_at(&self, pos: usize) -> Option<usize>
pub fn char_at(&self, pos: usize) -> Option<usize>
Grapheme position to char position. Returns the first char position for the grapheme at pos.
sourcepub fn next_word_boundary(&self, pos: usize) -> Option<usize>
pub fn next_word_boundary(&self, pos: usize) -> Option<usize>
Find next word.
sourcepub fn prev_word_boundary(&self, pos: usize) -> Option<usize>
pub fn prev_word_boundary(&self, pos: usize) -> Option<usize>
Find previous word.
sourcepub fn advance_cursor(&mut self, c: char)
pub fn advance_cursor(&mut self, c: char)
Start at the cursor position and find a valid insert position for the input c. Put the cursor at that position.
sourcepub fn insert_char(&mut self, c: char)
pub fn insert_char(&mut self, c: char)
Insert the char if it matches the cursor mask and the current section is not full.
advance_cursor() must be called before for correct functionality.
Otherwise: your mileage might vary.
sourcepub fn remove_selection(&mut self, selection: Range<usize>)
pub fn remove_selection(&mut self, selection: Range<usize>)
Remove the selection.
sourcepub fn remove_prev(&mut self)
pub fn remove_prev(&mut self)
Remove the previous char.
sourcepub fn remove_next(&mut self)
pub fn remove_next(&mut self)
Remove the next char.
Trait Implementations§
source§impl Clone for InputMaskCore
impl Clone for InputMaskCore
source§fn clone(&self) -> InputMaskCore
fn clone(&self) -> InputMaskCore
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for InputMaskCore
impl Debug for InputMaskCore
source§impl Default for InputMaskCore
impl Default for InputMaskCore
source§fn default() -> InputMaskCore
fn default() -> InputMaskCore
source§impl PartialEq for InputMaskCore
impl PartialEq for InputMaskCore
source§fn eq(&self, other: &InputMaskCore) -> bool
fn eq(&self, other: &InputMaskCore) -> bool
self and other values to be equal, and is used
by ==.impl Eq for InputMaskCore
impl StructuralPartialEq for InputMaskCore
Auto Trait Implementations§
impl Freeze for InputMaskCore
impl RefUnwindSafe for InputMaskCore
impl Send for InputMaskCore
impl Sync for InputMaskCore
impl Unpin for InputMaskCore
impl UnwindSafe for InputMaskCore
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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