pub struct MaskedInputState {
pub area: Rect,
pub inner: Rect,
pub offset: upos_type,
pub dark_offset: (u16, u16),
pub value: MaskedCore,
pub invalid: bool,
pub overwrite: bool,
pub on_focus_gained: TextFocusGained,
pub on_focus_lost: TextFocusLost,
pub focus: FocusFlag,
pub mouse: MouseFlags,
pub non_exhaustive: NonExhaustive,
}Expand description
State & event-handling.
Fields§
§area: RectThe whole area with block. read only renewed with each render.
inner: RectArea inside a possible block. read only renewed with each render.
offset: upos_typeDisplay offset read+write
dark_offset: (u16, u16)Dark offset due to clipping. read only secondary offset due to clipping.
value: MaskedCoreEditing core
invalid: boolDisplay as invalid. read+write
overwrite: boolThe next user edit clears the text for doing any edit. It will reset this flag. Other interactions may reset this flag too.
on_focus_gained: TextFocusGainedFocus behaviour. read only
on_focus_lost: TextFocusLostFocus behaviour. read only
focus: FocusFlagCurrent focus state. read+write
mouse: MouseFlagsMouse selection in progress. read+write
non_exhaustive: NonExhaustiveConstruct with ..Default::default()
Implementations§
Source§impl MaskedInputState
impl MaskedInputState
pub fn new() -> Self
pub fn named(name: &str) -> Self
Sourcepub fn with_symbols(self, sym: NumberSymbols) -> Self
pub fn with_symbols(self, sym: NumberSymbols) -> Self
With localized symbols for number formatting.
Sourcepub fn set_num_symbols(&mut self, sym: NumberSymbols)
pub fn set_num_symbols(&mut self, sym: NumberSymbols)
Set symbols for number display.
These are only used for rendering and to map user input. The value itself uses “.”, “,” and “-”.
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>
Set the input mask. This overwrites the display mask and the value with a default representation of the mask.
The result value contains all punctuation and the value given as ‘display’ below.
-
0: can enter digit, display as 0 -
9: can enter digit, display as space -
#: digit, plus or minus sign, display as space -
+: sign. display ‘+’ for positive -
-: sign. display ’ ’ for positive -
.and,: decimal and grouping separators -
H: must enter a hex digit, display as 0 -
h: can enter a hex digit, display as space -
O: must enter an octal digit, display as 0 -
o: can enter an octal digit, display as space -
D: must enter a decimal digit, display as 0 -
d: can enter a decimal digit, display as space -
l: can enter letter, display as space -
a: can enter letter or digit, display as space -
c: can enter character or space, display as space -
_: anything, display as space -
SPACE: separator character move the cursor when entered. -
\: escapes the following character and uses it as a separator. -
all other ascii characters a reserved.
Sourcepub fn set_invalid(&mut self, invalid: bool)
pub fn set_invalid(&mut self, invalid: bool)
Renders the widget in invalid style.
Sourcepub fn get_invalid(&self) -> bool
pub fn get_invalid(&self) -> bool
Renders the widget in invalid style.
Sourcepub fn set_overwrite(&mut self, overwrite: bool)
pub fn set_overwrite(&mut self, overwrite: bool)
The next edit operation will overwrite the current content instead of adding text. Any move operations will cancel this overwrite.
Source§impl MaskedInputState
impl MaskedInputState
Sourcepub fn set_clipboard(&mut self, clip: Option<impl Clipboard + 'static>)
pub fn set_clipboard(&mut self, clip: Option<impl Clipboard + 'static>)
Clipboard used. Default is to use the global_clipboard().
Sourcepub fn clipboard(&self) -> Option<&dyn Clipboard>
pub fn clipboard(&self) -> Option<&dyn Clipboard>
Clipboard used. Default is to use the global_clipboard().
Sourcepub fn copy_to_clip(&mut self) -> bool
pub fn copy_to_clip(&mut self) -> bool
Copy to internal buffer
Sourcepub fn cut_to_clip(&mut self) -> bool
pub fn cut_to_clip(&mut self) -> bool
Cut to internal buffer
Sourcepub fn paste_from_clip(&mut self) -> bool
pub fn paste_from_clip(&mut self) -> bool
Paste from internal buffer.
Source§impl MaskedInputState
impl MaskedInputState
Sourcepub fn set_undo_buffer(&mut self, undo: Option<impl UndoBuffer + 'static>)
pub fn set_undo_buffer(&mut self, undo: Option<impl UndoBuffer + 'static>)
Set undo buffer.
Sourcepub fn undo_buffer(&self) -> Option<&dyn UndoBuffer>
pub fn undo_buffer(&self) -> Option<&dyn UndoBuffer>
Undo
Sourcepub fn undo_buffer_mut(&mut self) -> Option<&mut dyn UndoBuffer>
pub fn undo_buffer_mut(&mut self) -> Option<&mut dyn UndoBuffer>
Undo
Sourcepub fn recent_replay_log(&mut self) -> Vec<UndoEntry>
pub fn recent_replay_log(&mut self) -> Vec<UndoEntry>
Get all recent replay recordings.
Sourcepub fn replay_log(&mut self, replay: &[UndoEntry])
pub fn replay_log(&mut self, replay: &[UndoEntry])
Apply the replay recording.
Source§impl MaskedInputState
impl MaskedInputState
Sourcepub fn add_style(&mut self, range: Range<usize>, style: usize)
pub fn add_style(&mut self, range: Range<usize>, style: usize)
Add a style for a byte-range. The style-nr refers to one of the styles set with the widget.
Sourcepub fn add_range_style(
&mut self,
range: Range<upos_type>,
style: usize,
) -> Result<(), TextError>
pub fn add_range_style( &mut self, range: Range<upos_type>, style: usize, ) -> Result<(), TextError>
Add a style for a Range<upos_type> to denote the cells.
The style-nr refers to one of the styles set with the widget.
Sourcepub fn remove_style(&mut self, range: Range<usize>, style: usize)
pub fn remove_style(&mut self, range: Range<usize>, style: usize)
Remove the exact byte-range and style.
Sourcepub fn remove_range_style(
&mut self,
range: Range<upos_type>,
style: usize,
) -> Result<(), TextError>
pub fn remove_range_style( &mut self, range: Range<upos_type>, style: usize, ) -> Result<(), TextError>
Remove the exact Range<upos_type> and style.
Sourcepub fn styles_in(
&self,
range: Range<usize>,
buf: &mut Vec<(Range<usize>, usize)>,
)
pub fn styles_in( &self, range: Range<usize>, buf: &mut Vec<(Range<usize>, usize)>, )
Find all styles that touch the given range.
Sourcepub fn styles_at(&self, byte_pos: usize, buf: &mut Vec<(Range<usize>, usize)>)
pub fn styles_at(&self, byte_pos: usize, buf: &mut Vec<(Range<usize>, usize)>)
All styles active at the given position.
Source§impl MaskedInputState
impl MaskedInputState
Sourcepub fn set_offset(&mut self, offset: upos_type)
pub fn set_offset(&mut self, offset: upos_type)
Offset shown. This is corrected if the cursor wouldn’t be visible.
Sourcepub fn set_cursor(&mut self, cursor: upos_type, extend_selection: bool) -> bool
pub fn set_cursor(&mut self, cursor: upos_type, extend_selection: bool) -> bool
Set the cursor position, reset selection.
Sourcepub fn set_default_cursor(&mut self)
pub fn set_default_cursor(&mut self)
Place cursor at the decimal separator, if any. 0 otherwise.
Sourcepub fn has_selection(&self) -> bool
pub fn has_selection(&self) -> bool
Selection.
Sourcepub fn set_selection(&mut self, anchor: upos_type, cursor: upos_type) -> bool
pub fn set_selection(&mut self, anchor: upos_type, cursor: upos_type) -> bool
Selection.
Sourcepub fn select_all(&mut self) -> bool
pub fn select_all(&mut self) -> bool
Selection.
Sourcepub fn selected_text(&self) -> &str
pub fn selected_text(&self) -> &str
Selection.
Source§impl MaskedInputState
impl MaskedInputState
Sourcepub fn text(&self) -> &str
pub fn text(&self) -> &str
Value with all punctuation and default values according to the mask type.
Sourcepub fn str_slice_byte(&self, range: Range<usize>) -> Cow<'_, str>
pub fn str_slice_byte(&self, range: Range<usize>) -> Cow<'_, str>
Text slice as Cow<str>. Uses a byte range.
Sourcepub fn try_str_slice_byte(
&self,
range: Range<usize>,
) -> Result<Cow<'_, str>, TextError>
pub fn try_str_slice_byte( &self, range: Range<usize>, ) -> Result<Cow<'_, str>, TextError>
Text slice as Cow<str>. Uses a byte range.
Sourcepub fn try_str_slice(
&self,
range: Range<upos_type>,
) -> Result<Cow<'_, str>, TextError>
pub fn try_str_slice( &self, range: Range<upos_type>, ) -> Result<Cow<'_, str>, TextError>
Text slice as Cow<str>
Sourcepub fn line_width(&self) -> upos_type
pub fn line_width(&self) -> upos_type
Length as grapheme count.
Sourcepub fn glyphs(
&self,
screen_offset: u16,
screen_width: u16,
) -> impl Iterator<Item = Glyph<'_>>
pub fn glyphs( &self, screen_offset: u16, screen_width: u16, ) -> impl Iterator<Item = Glyph<'_>>
Iterator for the glyphs of the lines in range. Glyphs here a grapheme + display length.
Sourcepub fn condensed_glyphs(
&self,
screen_offset: u16,
screen_width: u16,
) -> impl Iterator<Item = Glyph<'_>>
pub fn condensed_glyphs( &self, screen_offset: u16, screen_width: u16, ) -> impl Iterator<Item = Glyph<'_>>
Iterator for the glyphs of the lines in range. Glyphs here a grapheme + display length.
Sourcepub fn text_graphemes(&self, pos: upos_type) -> impl Cursor<Item = Grapheme<'_>>
pub fn text_graphemes(&self, pos: upos_type) -> impl Cursor<Item = Grapheme<'_>>
Get a cursor over all the text with the current position set at pos.
Sourcepub fn try_text_graphemes(
&self,
pos: upos_type,
) -> Result<impl Cursor<Item = Grapheme<'_>>, TextError>
pub fn try_text_graphemes( &self, pos: upos_type, ) -> Result<impl Cursor<Item = Grapheme<'_>>, TextError>
Get a cursor over all the text with the current position set at pos.
Sourcepub fn graphemes(
&self,
range: Range<upos_type>,
pos: upos_type,
) -> impl Cursor<Item = Grapheme<'_>>
pub fn graphemes( &self, range: Range<upos_type>, pos: upos_type, ) -> impl Cursor<Item = Grapheme<'_>>
Get a cursor over the text-range the current position set at pos.
Sourcepub fn try_graphemes(
&self,
range: Range<upos_type>,
pos: upos_type,
) -> Result<impl Cursor<Item = Grapheme<'_>>, TextError>
pub fn try_graphemes( &self, range: Range<upos_type>, pos: upos_type, ) -> Result<impl Cursor<Item = Grapheme<'_>>, TextError>
Get a cursor over the text-range the current position set at pos.
Sourcepub fn byte_at(&self, pos: upos_type) -> Range<usize>
pub fn byte_at(&self, pos: upos_type) -> Range<usize>
Grapheme position to byte position. This is the (start,end) position of the single grapheme after pos.
Sourcepub fn try_byte_at(&self, pos: upos_type) -> Result<Range<usize>, TextError>
pub fn try_byte_at(&self, pos: upos_type) -> Result<Range<usize>, TextError>
Grapheme position to byte position. This is the (start,end) position of the single grapheme after pos.
Sourcepub fn bytes_at_range(&self, range: Range<upos_type>) -> Range<usize>
pub fn bytes_at_range(&self, range: Range<upos_type>) -> Range<usize>
Grapheme range to byte range.
Sourcepub fn try_bytes_at_range(
&self,
range: Range<upos_type>,
) -> Result<Range<usize>, TextError>
pub fn try_bytes_at_range( &self, range: Range<upos_type>, ) -> Result<Range<usize>, TextError>
Grapheme range to byte range.
Sourcepub fn byte_pos(&self, byte: usize) -> upos_type
pub fn byte_pos(&self, byte: usize) -> upos_type
Byte position to grapheme position. Returns the position that contains the given byte index.
Sourcepub fn try_byte_pos(&self, byte: usize) -> Result<upos_type, TextError>
pub fn try_byte_pos(&self, byte: usize) -> Result<upos_type, TextError>
Byte position to grapheme position. Returns the position that contains the given byte index.
Source§impl MaskedInputState
impl MaskedInputState
Sourcepub fn set_text<S: Into<String>>(&mut self, s: S)
pub fn set_text<S: Into<String>>(&mut self, s: S)
Set 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 insert_char(&mut self, c: char) -> bool
pub fn insert_char(&mut self, c: char) -> bool
Insert a char at the current position.
Sourcepub fn delete_range(&mut self, range: Range<upos_type>) -> bool
pub fn delete_range(&mut self, range: Range<upos_type>) -> bool
Remove the selected range. The text will be replaced with the default value as defined by the mask.
Source§impl MaskedInputState
impl MaskedInputState
Sourcepub fn delete_next_char(&mut self) -> bool
pub fn delete_next_char(&mut self) -> bool
Delete the char after the cursor.
Sourcepub fn delete_prev_char(&mut self) -> bool
pub fn delete_prev_char(&mut self) -> bool
Delete the char before the cursor.
Sourcepub fn delete_prev_section(&mut self) -> bool
pub fn delete_prev_section(&mut self) -> bool
Delete the previous section.
Sourcepub fn delete_next_section(&mut self) -> bool
pub fn delete_next_section(&mut self) -> bool
Delete the next section.
Sourcepub fn move_right(&mut self, extend_selection: bool) -> bool
pub fn move_right(&mut self, extend_selection: bool) -> bool
Move to the next char.
Sourcepub fn move_to_line_start(&mut self, extend_selection: bool) -> bool
pub fn move_to_line_start(&mut self, extend_selection: bool) -> bool
Start of line
Sourcepub fn move_to_line_end(&mut self, extend_selection: bool) -> bool
pub fn move_to_line_end(&mut self, extend_selection: bool) -> bool
End of line
Sourcepub fn move_to_prev_section(&mut self, extend_selection: bool) -> bool
pub fn move_to_prev_section(&mut self, extend_selection: bool) -> bool
Move to start of previous section.
Sourcepub fn move_to_next_section(&mut self, extend_selection: bool) -> bool
pub fn move_to_next_section(&mut self, extend_selection: bool) -> bool
Move to end of previous section.
Sourcepub fn select_current_section(&mut self) -> bool
pub fn select_current_section(&mut self) -> bool
Select next section.
Sourcepub fn select_next_section(&mut self) -> bool
pub fn select_next_section(&mut self) -> bool
Select next section.
Sourcepub fn select_prev_section(&mut self) -> bool
pub fn select_prev_section(&mut self) -> bool
Select previous section.
Source§impl MaskedInputState
impl MaskedInputState
Sourcepub fn screen_to_col(&self, scx: i16) -> upos_type
pub fn screen_to_col(&self, scx: i16) -> upos_type
Converts from a widget relative screen coordinate to a grapheme index. x is the relative screen position.
Sourcepub fn col_to_screen(&self, pos: upos_type) -> Option<u16>
pub fn col_to_screen(&self, pos: upos_type) -> Option<u16>
Converts a grapheme based position to a screen position relative to the widget area.
Sourcepub fn set_screen_cursor(&mut self, cursor: i16, extend_selection: bool) -> bool
pub fn set_screen_cursor(&mut self, cursor: i16, extend_selection: bool) -> bool
Set the cursor position from a screen position relative to the origin of the widget. This value can be negative, which selects a currently not visible position and scrolls to it.
Sourcepub fn set_screen_cursor_sections(
&mut self,
screen_cursor: i16,
extend_selection: bool,
) -> bool
pub fn set_screen_cursor_sections( &mut self, screen_cursor: i16, extend_selection: bool, ) -> bool
Set the cursor position from screen coordinates, rounds the position to the next section bounds.
The cursor positions are relative to the inner rect. They may be negative too, this allows setting the cursor to a position that is currently scrolled away.
Sourcepub fn scroll_left(&mut self, delta: upos_type) -> bool
pub fn scroll_left(&mut self, delta: upos_type) -> bool
Scrolling
Sourcepub fn scroll_right(&mut self, delta: upos_type) -> bool
pub fn scroll_right(&mut self, delta: upos_type) -> bool
Scrolling
Sourcepub fn scroll_cursor_to_visible(&mut self) -> bool
pub fn scroll_cursor_to_visible(&mut self) -> bool
Change the offset in a way that the cursor is visible.
Trait Implementations§
Source§impl Clone for MaskedInputState
impl Clone for MaskedInputState
Source§impl Debug for MaskedInputState
impl Debug for MaskedInputState
Source§impl Default for MaskedInputState
impl Default for MaskedInputState
Source§impl HandleEvent<Event, MouseOnly, TextOutcome> for MaskedInputState
impl HandleEvent<Event, MouseOnly, TextOutcome> for MaskedInputState
Source§impl HandleEvent<Event, ReadOnly, TextOutcome> for MaskedInputState
impl HandleEvent<Event, ReadOnly, TextOutcome> for MaskedInputState
Source§impl HandleEvent<Event, Regular, TextOutcome> for MaskedInputState
impl HandleEvent<Event, Regular, TextOutcome> for MaskedInputState
Source§impl HasFocus for MaskedInputState
impl HasFocus for MaskedInputState
Source§fn build(&self, builder: &mut FocusBuilder)
fn build(&self, builder: &mut FocusBuilder)
Source§fn is_focused(&self) -> bool
fn is_focused(&self) -> bool
Source§fn lost_focus(&self) -> bool
fn lost_focus(&self) -> bool
Source§fn gained_focus(&self) -> bool
fn gained_focus(&self) -> bool
Source§impl HasScreenCursor for MaskedInputState
impl HasScreenCursor for MaskedInputState
Source§impl RelocatableState for MaskedInputState
impl RelocatableState for MaskedInputState
Auto Trait Implementations§
impl !Freeze for MaskedInputState
impl !RefUnwindSafe for MaskedInputState
impl !Send for MaskedInputState
impl !Sync for MaskedInputState
impl Unpin for MaskedInputState
impl !UnwindSafe for MaskedInputState
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> 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