Trait kas_text::EditableTextApi
source · [−]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
Required methods
fn insert_char(&mut self, index: usize, c: char)
fn insert_char(&mut self, index: usize, c: char)
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 efficient than
Text::set_text
. This may change in the future (TODO).
fn replace_range(&mut self, range: Range<usize>, replace_with: &str)
fn replace_range(&mut self, range: Range<usize>, replace_with: &str)
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 efficient than
Text::set_text
. This may change in the future (TODO).
fn set_string(&mut self, string: String)
fn set_string(&mut self, string: String)
Set text to a raw String
One must call Text::prepare
afterwards.
All existing text formatting is removed.
fn swap_string(&mut self, string: &mut String)
fn swap_string(&mut self, string: &mut String)
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 efficient than
Text::set_text
. This may change in the future (TODO).