pub struct Text { /* private fields */ }Expand description
A block of text: its lines, each a run of literal glyphs. No position and no stroke.
The lines are split once, at construction, and never again. A shape holding a string would have to split it while drawing, which makes drawing fallible or silently drops what it cannot write; holding glyphs means a line that could not be written cannot be built at all.
A block has no position, because the figure that holds it owns where it goes: a stored point would be a second copy of that answer and the first thing to go stale when the figure moves.
Implementations§
Source§impl Text
impl Text
Sourcepub fn new(content: &str) -> Option<Self>
pub fn new(content: &str) -> Option<Self>
Splits content on '\n'; one Glyph per extended grapheme cluster.
None when any line holds any other control character. A '\r' included: a CRLF is refused
rather than normalized, and the caller writes '\n'.
Sourcepub fn width(&self) -> u16
pub fn width(&self) -> u16
The longest line, in cells.
The width of one glyph is one cell, however many columns a terminal draws it in, so a wide cluster is counted once and the grid may not line up with the rows around it.