pub struct Text { /* private fields */ }Expand description
Styled text of any length: a paragraph, a table cell, a title.
Text from outside the program is safe to put here. Every character that
is_unsafe refuses is removed, except
newline and tab.
Every other line break becomes a newline: carriage return, vertical tab,
form feed, next line, and the line and paragraph separators. A carriage
return before a line feed is one break with it. A newline starts a new
line. A tab expands to the next tab stop of the Context it is rendered
in, counted from the start of its line.
Two texts are equal when their content, styles, and Overflow are.
Empty pieces are dropped and neighbours in one style are joined, however
the text was pushed.
Text is Renderable: Overflow decides how it fits a width.
Implementations§
Source§impl Text
impl Text
Sourcepub fn push(&mut self, text: impl AsRef<str>, style: Style)
pub fn push(&mut self, text: impl AsRef<str>, style: Style)
Adds text in style after what is already there. A newline in
text starts a new line.
Sourcepub fn overflow(self, overflow: Overflow) -> Text
pub fn overflow(self, overflow: Overflow) -> Text
Sets what to do with a line wider than the width it renders at.
The default is Overflow::KeepWords.
Source§impl Text
impl Text
Sourcepub fn measure_as(&self, context: &Context, overflow: Overflow) -> Measurement
pub fn measure_as(&self, context: &Context, overflow: Overflow) -> Measurement
measure as if the text’s overflow were
overflow, so a container that decides overflow per column measures a
table cell without cloning it.