Struct rat_widget::text::core::MaskedCore
source · pub struct MaskedCore { /* private fields */ }Expand description
Text editing core.
Implementations§
source§impl MaskedCore
impl MaskedCore
pub fn new() -> MaskedCore
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 “.”
source§impl MaskedCore
impl MaskedCore
source§impl MaskedCore
impl MaskedCore
sourcepub fn set_undo_buffer(&mut self, undo: Option<Box<dyn UndoBuffer>>)
pub fn set_undo_buffer(&mut self, undo: Option<Box<dyn UndoBuffer>>)
Undo
sourcepub fn set_undo_count(&mut self, n: u32)
pub fn set_undo_count(&mut self, n: u32)
Set undo count
sourcepub fn begin_undo_seq(&mut self)
pub fn begin_undo_seq(&mut self)
Begin a sequence of changes that should be undone in one go.
sourcepub fn end_undo_seq(&mut self)
pub fn end_undo_seq(&mut self)
End a sequence of changes that should be undone in one go.
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 last replay recording.
sourcepub fn replay_log(&mut self, replay: &[UndoEntry])
pub fn replay_log(&mut self, replay: &[UndoEntry])
Replay a recording of changes.
source§impl MaskedCore
impl MaskedCore
sourcepub fn set_styles(&mut self, new_styles: Vec<(Range<usize>, usize)>)
pub fn set_styles(&mut self, new_styles: Vec<(Range<usize>, usize)>)
Set all styles.
The ranges are byte-ranges. The usize value is the index of the actual style. Those are set with the widget.
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 the given byte-range.
The usize value is the index of the actual style. Those are set at 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 a style for the given byte-range.
Range and style must match to be removed.
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)>)
Finds all styles for the given position.
source§impl MaskedCore
impl MaskedCore
sourcepub fn set_cursor(&mut self, cursor: u32, extend_selection: bool) -> bool
pub fn set_cursor(&mut self, cursor: u32, extend_selection: bool) -> bool
Set the cursor position. The value is capped to the number of text lines and the line-width for the given line.
Returns true, if the cursor actually changed.
sourcepub fn section_cursor(&self, cursor: u32) -> Option<u32>
pub fn section_cursor(&self, cursor: u32) -> Option<u32>
Get the default cursor for the section at the given cursor position, if it is an editable section.
sourcepub fn next_section_cursor(&self, cursor: u32) -> Option<u32>
pub fn next_section_cursor(&self, cursor: u32) -> Option<u32>
Get the default cursor position for the next editable section.
sourcepub fn prev_section_cursor(&self, cursor: u32) -> Option<u32>
pub fn prev_section_cursor(&self, cursor: u32) -> Option<u32>
Get the default cursor position for the next editable section.
sourcepub fn is_section_boundary(&self, pos: u32) -> bool
pub fn is_section_boundary(&self, pos: u32) -> bool
Is the position at a word boundary?
sourcepub fn section_range(&self, cursor: u32) -> Option<Range<u32>>
pub fn section_range(&self, cursor: u32) -> Option<Range<u32>>
Get the range for the section at the given cursor position, if it is an editable section.
sourcepub fn next_section_range(&self, cursor: u32) -> Option<Range<u32>>
pub fn next_section_range(&self, cursor: u32) -> Option<Range<u32>>
Get the default cursor position for the next editable section.
sourcepub fn prev_section_range(&self, cursor: u32) -> Option<Range<u32>>
pub fn prev_section_range(&self, cursor: u32) -> Option<Range<u32>>
Get the default cursor position for the next editable section.
sourcepub fn set_default_cursor(&mut self)
pub fn set_default_cursor(&mut self)
Place cursor at decimal separator, if any. 0 otherwise.
sourcepub fn has_selection(&self) -> bool
pub fn has_selection(&self) -> bool
Any text selection.
sourcepub fn set_selection(&mut self, anchor: u32, cursor: u32) -> bool
pub fn set_selection(&mut self, anchor: u32, cursor: u32) -> bool
Select text.
sourcepub fn select_all(&mut self) -> bool
pub fn select_all(&mut self) -> bool
Select all text.
sourcepub fn selected_text(&self) -> &str
pub fn selected_text(&self) -> &str
Selection.
source§impl MaskedCore
impl MaskedCore
sourcepub fn byte_at(&self, pos: u32) -> Result<Range<usize>, TextError>
pub fn byte_at(&self, pos: u32) -> 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<u32>,
) -> Result<Range<usize>, TextError>
pub fn bytes_at_range( &self, range: Range<u32>, ) -> Result<Range<usize>, TextError>
Grapheme range to byte range.
sourcepub fn byte_pos(&self, byte: usize) -> Result<u32, TextError>
pub fn byte_pos(&self, byte: usize) -> Result<u32, TextError>
Byte position to grapheme position. Returns the position that contains the given byte index.
sourcepub fn byte_range(&self, bytes: Range<usize>) -> Result<Range<u32>, TextError>
pub fn byte_range(&self, bytes: Range<usize>) -> Result<Range<u32>, TextError>
Byte range to grapheme range.
sourcepub fn str_slice_byte(
&self,
range: Range<usize>,
) -> Result<Cow<'_, str>, TextError>
pub fn str_slice_byte( &self, range: Range<usize>, ) -> Result<Cow<'_, str>, TextError>
Text slice as Cow
sourcepub fn str_slice(&self, range: Range<u32>) -> Result<Cow<'_, str>, TextError>
pub fn str_slice(&self, range: Range<u32>) -> Result<Cow<'_, str>, TextError>
A range of the text as Cow
sourcepub fn glyphs(
&self,
rows: Range<u32>,
screen_offset: u16,
screen_width: u16,
) -> Result<impl Iterator<Item = Glyph<'_>>, TextError>
pub fn glyphs( &self, rows: Range<u32>, screen_offset: u16, screen_width: u16, ) -> Result<impl Iterator<Item = Glyph<'_>>, TextError>
Iterator for the glyphs of the lines in range. Glyphs here a grapheme + display length.
sourcepub fn condensed_glyphs(
&self,
rows: Range<u32>,
screen_offset: u16,
screen_width: u16,
) -> Result<impl Iterator<Item = Glyph<'_>>, TextError>
pub fn condensed_glyphs( &self, rows: Range<u32>, screen_offset: u16, screen_width: u16, ) -> Result<impl Iterator<Item = Glyph<'_>>, TextError>
Iterator for the glyphs of the lines in range. Glyphs here a grapheme + display length.
This omits unnecessary white-space.
sourcepub fn grapheme_at(&self, pos: u32) -> Result<Option<Grapheme<'_>>, TextError>
pub fn grapheme_at(&self, pos: u32) -> Result<Option<Grapheme<'_>>, TextError>
Get the grapheme at the given position.
sourcepub fn text_graphemes(
&self,
pos: u32,
) -> Result<impl Iterator<Item = Grapheme<'_>> + Cursor, TextError>
pub fn text_graphemes( &self, pos: u32, ) -> Result<impl Iterator<Item = Grapheme<'_>> + Cursor, TextError>
Get a cursor over all the text with the current position set at pos.
sourcepub fn graphemes(
&self,
range: Range<u32>,
pos: u32,
) -> Result<impl Iterator<Item = Grapheme<'_>> + Cursor, TextError>
pub fn graphemes( &self, range: Range<u32>, pos: u32, ) -> Result<impl Iterator<Item = Grapheme<'_>> + Cursor, TextError>
Get a cursor over the text-range the current position set at pos.
pub fn line_width(&self) -> u32
source§impl MaskedCore
impl MaskedCore
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Reset value but not the mask and width. Resets offset and cursor position too.
sourcepub fn set_text<S>(&mut self, s: S)
pub fn set_text<S>(&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 advance_cursor(&mut self, c: char) -> bool
pub fn advance_cursor(&mut self, c: char) -> bool
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) -> bool
pub fn insert_char(&mut self, c: char) -> bool
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_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 previous char.
Trait Implementations§
source§impl Clone for MaskedCore
impl Clone for MaskedCore
source§fn clone(&self) -> MaskedCore
fn clone(&self) -> MaskedCore
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for MaskedCore
impl Debug for MaskedCore
source§impl Default for MaskedCore
impl Default for MaskedCore
source§fn default() -> MaskedCore
fn default() -> MaskedCore
Auto Trait Implementations§
impl Freeze for MaskedCore
impl !RefUnwindSafe for MaskedCore
impl !Send for MaskedCore
impl !Sync for MaskedCore
impl Unpin for MaskedCore
impl !UnwindSafe for MaskedCore
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)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