pub struct Text<T: FormattableText> { /* private fields */ }
Expand description
Text, prepared for display in a given environment
This struct is composed of three parts: an Environment
, a representation
of the FormattableText
being displayed, and a TextDisplay
object.
Most Functionality is implemented via the TextApi
and TextApiExt
traits.
Implementations
sourceimpl<T: FormattableText> Text<T>
impl<T: FormattableText> Text<T>
sourcepub fn new(env: Environment, text: T) -> Self
pub fn new(env: Environment, text: T) -> Self
Construct from an environment and a text model
This struct must be made ready for usage by calling Text::prepare
.
sourcepub fn new_single(text: T) -> Self
pub fn new_single(text: T) -> Self
Construct from a default environment (single-line) and text
The environment is default-constructed, with line-wrapping
turned off (see Environment::flags
doc).
sourcepub fn new_multi(text: T) -> Self
pub fn new_multi(text: T) -> Self
Construct from a default environment (multi-line) and text
The environment is default-constructed (line-wrap on).
sourcepub fn clone_text(&self) -> T where
T: Clone,
pub fn clone_text(&self) -> T where
T: Clone,
Clone the formatted text
sourcepub fn set_text(&mut self, text: T)
pub fn set_text(&mut self, text: T)
Set the text
One must call Text::prepare
afterwards and may wish to inspect its
return value to check the size allocation meets requirements.
Trait Implementations
sourceimpl<T: FormattableText> AsMut<TextDisplay> for Text<T>
impl<T: FormattableText> AsMut<TextDisplay> for Text<T>
sourcefn as_mut(&mut self) -> &mut TextDisplay
fn as_mut(&mut self) -> &mut TextDisplay
Performs the conversion.
sourceimpl<T: FormattableText> AsRef<TextDisplay> for Text<T>
impl<T: FormattableText> AsRef<TextDisplay> for Text<T>
sourcefn as_ref(&self) -> &TextDisplay
fn as_ref(&self) -> &TextDisplay
Performs the conversion.
sourceimpl<T: Clone + FormattableText> Clone for Text<T>
impl<T: Clone + FormattableText> Clone for Text<T>
sourceimpl<T: Debug + FormattableText> Debug for Text<T>
impl<T: Debug + FormattableText> Debug for Text<T>
sourceimpl<T: FormattableText + Default> Default for Text<T>
impl<T: FormattableText + Default> Default for Text<T>
sourceimpl<T: EditableText> EditableTextApi for Text<T>
impl<T: EditableText> EditableTextApi for Text<T>
sourcefn insert_char(&mut self, index: usize, c: char)
fn insert_char(&mut self, index: usize, c: char)
Insert a char at the given position Read more
sourcefn 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 Read more
sourcefn set_string(&mut self, string: String)
fn set_string(&mut self, string: String)
Set text to a raw String
Read more
sourcefn swap_string(&mut self, string: &mut String)
fn swap_string(&mut self, string: &mut String)
Swap the raw text with a String
Read more
sourceimpl<T: FormattableText> TextApi for Text<T>
impl<T: FormattableText> TextApi for Text<T>
sourcefn display(&self) -> &TextDisplay
fn display(&self) -> &TextDisplay
Read the TextDisplay
sourcefn clone_string(&self) -> String
fn clone_string(&self) -> String
Clone the unformatted text as a String
sourcefn env(&self) -> &Environment
fn env(&self) -> &Environment
Read the environment
sourcefn env_mut(&mut self) -> &mut Environment
fn env_mut(&mut self) -> &mut Environment
Mutate the environment Read more
sourcefn require_action(&mut self, action: Action)
fn require_action(&mut self, action: Action)
Require an action Read more
sourcefn prepare_runs(&mut self)
fn prepare_runs(&mut self)
Prepare text runs Read more
sourcefn resize_runs(&mut self)
fn resize_runs(&mut self)
Update font size Read more
sourcefn prepare_lines(&mut self) -> Vec2
fn prepare_lines(&mut self) -> Vec2
Prepare lines (“wrap”) Read more
Auto Trait Implementations
impl<T> RefUnwindSafe for Text<T> where
T: RefUnwindSafe,
impl<T> Send for Text<T> where
T: Send,
impl<T> Sync for Text<T> where
T: Sync,
impl<T> Unpin for Text<T> where
T: Unpin,
impl<T> UnwindSafe for Text<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<S, T> CastFloat<T> for S where
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for S where
T: ConvFloat<S>,
sourcepub fn cast_trunc(self) -> T
pub fn cast_trunc(self) -> T
Cast to integer, truncating Read more
sourcepub fn cast_nearest(self) -> T
pub fn cast_nearest(self) -> T
Cast to the nearest integer Read more
sourcepub fn cast_floor(self) -> T
pub fn cast_floor(self) -> T
Cast the floor to an integer Read more
sourcepub fn try_cast_trunc(self) -> Result<T, Error>
pub fn try_cast_trunc(self) -> Result<T, Error>
Try converting to integer with truncation Read more
sourcepub fn try_cast_nearest(self) -> Result<T, Error>
pub fn try_cast_nearest(self) -> Result<T, Error>
Try converting to the nearest integer Read more
sourcepub fn try_cast_floor(self) -> Result<T, Error>
pub fn try_cast_floor(self) -> Result<T, Error>
Try converting the floor to an integer Read more
sourcepub fn try_cast_ceil(self) -> Result<T, Error>
pub fn try_cast_ceil(self) -> Result<T, Error>
Try convert the ceiling to an integer Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more