MaskedCore

Struct MaskedCore 

Source
pub struct MaskedCore { /* private fields */ }
Expand description

Text editing core.

Implementations§

Source§

impl MaskedCore

Source

pub fn new() -> Self

Source

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

pub fn set_mask<S: AsRef<str>>(&mut self, s: S) -> Result<(), Error>

Changes the mask. Resets the value to a default.

Source

pub fn mask(&self) -> String

Return the mask.

Source§

impl MaskedCore

Source

pub fn set_clipboard(&mut self, clip: Option<Box<dyn Clipboard + 'static>>)

Clipboard

Source

pub fn clipboard(&self) -> Option<&dyn Clipboard>

Clipboard

Source§

impl MaskedCore

Source

pub fn set_undo_buffer(&mut self, undo: Option<Box<dyn UndoBuffer>>)

Undo

Source

pub fn set_undo_count(&mut self, n: u32)

Set undo count

Source

pub fn begin_undo_seq(&mut self)

Begin a sequence of changes that should be undone in one go.

Source

pub fn end_undo_seq(&mut self)

End a sequence of changes that should be undone in one go.

Source

pub fn undo_buffer(&self) -> Option<&dyn UndoBuffer>

Undo

Source

pub fn undo_buffer_mut(&mut self) -> Option<&mut dyn UndoBuffer>

Undo

Source

pub fn undo(&mut self) -> bool

Undo last.

Source

pub fn redo(&mut self) -> bool

Redo last.

Source

pub fn recent_replay_log(&mut self) -> Vec<UndoEntry>

Get last replay recording.

Source

pub fn replay_log(&mut self, replay: &[UndoEntry])

Replay a recording of changes.

Source§

impl MaskedCore

Source

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.

Source

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.

Source

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.

Source

pub fn styles_in( &self, range: Range<usize>, buf: &mut Vec<(Range<usize>, usize)>, )

Find all styles that touch the given range.

Source

pub fn styles_at(&self, byte_pos: usize, buf: &mut Vec<(Range<usize>, usize)>)

Finds all styles for the given position.

Source

pub fn style_match(&self, byte_pos: usize, style: usize) -> Option<Range<usize>>

Check if the given style applies at the position and return the complete range for the style.

Source

pub fn styles(&self) -> Option<impl Iterator<Item = (Range<usize>, usize)> + '_>

List of all styles.

Source§

impl MaskedCore

Source

pub fn set_cursor(&mut self, cursor: upos_type, 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.

Source

pub fn section_cursor(&self, cursor: upos_type) -> Option<upos_type>

Get the default cursor for the section at the given cursor position, if it is an editable section.

Source

pub fn next_section_cursor(&self, cursor: upos_type) -> Option<upos_type>

Get the default cursor position for the next editable section.

Source

pub fn prev_section_cursor(&self, cursor: upos_type) -> Option<upos_type>

Get the default cursor position for the next editable section.

Source

pub fn is_section_boundary(&self, pos: upos_type) -> bool

Is the position at a word boundary?

Source

pub fn section_range(&self, cursor: upos_type) -> Option<Range<upos_type>>

Get the range for the section at the given cursor position, if it is an editable section.

Source

pub fn next_section_range(&self, cursor: upos_type) -> Option<Range<upos_type>>

Get the default cursor position for the next editable section.

Source

pub fn prev_section_range(&self, cursor: upos_type) -> Option<Range<upos_type>>

Get the default cursor position for the next editable section.

Source

pub fn set_default_cursor(&mut self)

Place cursor at decimal separator, if any. 0 otherwise.

Source

pub fn cursor(&self) -> upos_type

Cursor position as grapheme-idx.

Source

pub fn anchor(&self) -> upos_type

Selection anchor

Source

pub fn has_selection(&self) -> bool

Any text selection.

Source

pub fn set_selection(&mut self, anchor: upos_type, cursor: upos_type) -> bool

Select text.

Source

pub fn select_all(&mut self) -> bool

Select all text.

Source

pub fn selection(&self) -> Range<upos_type>

Returns the selection as TextRange.

Source

pub fn selected_text(&self) -> &str

Selection.

Source§

impl MaskedCore

Source

pub fn is_empty(&self) -> bool

Empty.

Source

pub fn 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.

Source

pub fn bytes_at_range( &self, range: Range<upos_type>, ) -> Result<Range<usize>, TextError>

Grapheme range to byte range.

Source

pub fn byte_pos(&self, byte: usize) -> Result<upos_type, TextError>

Byte position to grapheme position. Returns the position that contains the given byte index.

Source

pub fn byte_range( &self, bytes: Range<usize>, ) -> Result<Range<upos_type>, TextError>

Byte range to grapheme range.

Source

pub fn str_slice_byte( &self, range: Range<usize>, ) -> Result<Cow<'_, str>, TextError>

Text slice as Cow<str>. Uses a byte range.

Source

pub fn str_slice( &self, range: Range<upos_type>, ) -> Result<Cow<'_, str>, TextError>

A range of the text as Cow<str>

Source

pub fn glyphs( &self, rows: Range<upos_type>, 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.

Source

pub fn condensed_glyphs( &self, rows: Range<upos_type>, 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.

Source

pub fn grapheme_at( &self, pos: upos_type, ) -> Result<Option<Grapheme<'_>>, TextError>

Get the grapheme at the given position.

Source

pub fn 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.

Source

pub fn 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.

Source

pub fn line_width(&self) -> upos_type

Source§

impl MaskedCore

Source

pub fn clear(&mut self)

Reset value but not the mask and width. Resets offset and cursor position too.

Source

pub fn text(&self) -> &str

Copy of the text-value.

Source

pub fn set_text<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.

Source

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.

Source

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.

Source

pub fn remove_prev(&mut self)

Remove the previous char.

Source

pub fn remove_next(&mut self)

Remove the previous char.

Source

pub fn remove_range( &mut self, range: Range<upos_type>, ) -> Result<bool, TextError>

Remove the selection

Trait Implementations§

Source§

impl Clone for MaskedCore

Source§

fn clone(&self) -> MaskedCore

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MaskedCore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MaskedCore

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.