Trait kas_text::EditableTextApi[][src]

pub trait EditableTextApi {
    fn insert_char(&mut self, index: usize, c: char);
fn replace_range(&mut self, range: Range<usize>, replace_with: &str);
fn set_string(&mut self, string: String);
fn swap_string(&mut self, string: &mut String); }
Expand description

Trait over a sub-set of Text functionality for editable text

This allows dynamic dispatch over Text’s type parameters.

Required methods

Insert a char at the given position

This may be used to edit the raw text instead of replacing it. One must call Text::prepare afterwards.

Formatting is adjusted: any specifiers starting at or after index are delayed by the length of c.

Currently this is not significantly more efficent than Text::set_text. This may change in the future (TODO).

Replace a section of text

This may be used to edit the raw text instead of replacing it. One must call Text::prepare afterwards.

One may simulate an unbounded range by via start..usize::MAX.

Formatting is adjusted: any specifiers within the replaced text are pushed back to the end of the replacement, and the position of any specifiers after the replaced section is adjusted as appropriate.

Currently this is not significantly more efficent than Text::set_text. This may change in the future (TODO).

Set text to a raw String

One must call Text::prepare afterwards.

All existing text formatting is removed.

Swap the raw text with a String

This may be used to edit the raw text instead of replacing it. One must call Text::prepare afterwards.

All existing text formatting is removed.

Currently this is not significantly more efficent than Text::set_text. This may change in the future (TODO).

Implementors