[][src]Trait kas_text::EditableTextApi

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

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

This allows dynamic dispatch over Text's type parameters.

Required methods

pub fn insert_char(&mut self, index: usize, c: char)[src]

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).

pub fn replace_range(&mut self, range: Range<usize>, replace_with: &str)[src]

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).

pub fn set_string(&mut self, string: String)[src]

Set text to a raw String

One must call Text::prepare afterwards.

All existing text formatting is removed.

pub fn swap_string(&mut self, string: &mut String)[src]

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).

Loading content...

Implementors

impl<T: EditableText> EditableTextApi for Text<T>[src]

Loading content...