[][src]Trait kas::text::TextApi

pub trait TextApi {
    pub fn as_str(&self) -> &str;
pub fn clone_string(&self) -> String;
pub fn env(&self) -> &Environment;
pub fn env_mut(&mut self) -> &mut Environment;
pub fn display(&self) -> &TextDisplay;
pub fn require_action(&mut self, action: Action);
pub fn prepare(&mut self);
pub fn prepare_runs(&mut self);
pub fn resize_runs(&mut self);
pub fn prepare_lines(&mut self) -> Vec2;
pub fn effect_tokens(&self) -> &[Effect<()>]; pub fn str_len(&self) -> usize { ... } }

Trait over a sub-set of Text functionality

This allows dynamic dispatch over Text's type parameters.

Required methods

pub fn as_str(&self) -> &str[src]

Access whole text as contiguous str

It is valid to reference text within the range 0..text_len(), even if not all text within this range will be displayed (due to runs).

pub fn clone_string(&self) -> String[src]

Clone the unformatted text as a String

pub fn env(&self) -> &Environment[src]

Read the environment

pub fn env_mut(&mut self) -> &mut Environment[src]

Mutate the environment

If using this directly, ensure that necessary preparation actions are completed afterwards. Consider using TextApiExt::update_env instead.

pub fn display(&self) -> &TextDisplay[src]

Read the TextDisplay

pub fn require_action(&mut self, action: Action)[src]

Require an action

Wraps TextDisplay::require_action.

pub fn prepare(&mut self)[src]

Prepare text for display

Wraps TextDisplay::prepare, passing through env.

pub fn prepare_runs(&mut self)[src]

Prepare text runs

Wraps TextDisplay::prepare_runs, passing parameters from the environment state.

pub fn resize_runs(&mut self)[src]

Update font size

Wraps TextDisplay::resize_runs, passing parameters from the environment state.

pub fn prepare_lines(&mut self) -> Vec2[src]

Prepare lines ("wrap")

Wraps TextDisplay::prepare_lines, passing parameters from the environment state.

pub fn effect_tokens(&self) -> &[Effect<()>][src]

Get the sequence of effect tokens

This method has some limitations: (1) it may only return a reference to an existing sequence, (2) effect tokens cannot be generated dependent on input state, and (3) it does not incorporate colour information. For most uses it should still be sufficient, but for other cases it may be preferable not to use this method (use a dummy implementation returning &[] and use inherent methods on the text object via Text::text).

Loading content...

Provided methods

pub fn str_len(&self) -> usize[src]

Length of text

This is a shortcut to self.as_str().len().

It is valid to reference text within the range 0..text_len(), even if not all text within this range will be displayed (due to runs).

Loading content...

Implementors

impl<T> TextApi for Text<T> where
    T: FormattableText
[src]

Loading content...