pub struct Text<'a> {
pub lines: Vec<Line<'a>>,
pub style: Style,
}Expand description
Multi-line rich text.
Text can contain multiple lines, each with its own spans and alignment.
§Example
use tuxtui_core::text::{Text, Line};
use tuxtui_core::style::{Color, Style};
let text = Text::from(vec![
Line::from("First line"),
Line::styled("Second line", Style::default().fg(Color::Blue)),
]);Fields§
§lines: Vec<Line<'a>>The lines that make up this text
style: StyleOverall style applied to all lines
Implementations§
Source§impl<'a> Text<'a>
impl<'a> Text<'a>
Sourcepub fn from_lines(lines: Vec<Line<'a>>) -> Self
pub fn from_lines(lines: Vec<Line<'a>>) -> Self
Create text from lines.
Sourcepub fn styled<T: Into<Cow<'a, str>>>(content: T, style: Style) -> Self
pub fn styled<T: Into<Cow<'a, str>>>(content: T, style: Style) -> Self
Create styled text from a string.
Sourcepub fn into_owned(self) -> Text<'static>
pub fn into_owned(self) -> Text<'static>
Convert this text to an owned version.
Sourcepub fn patch_style(self, style: Style) -> Self
pub fn patch_style(self, style: Style) -> Self
Patch the style of this text (affects all lines).
Sourcepub fn extend_lines(&mut self, lines: impl IntoIterator<Item = Line<'a>>)
pub fn extend_lines(&mut self, lines: impl IntoIterator<Item = Line<'a>>)
Extend this text with more lines.
Trait Implementations§
Source§impl<'de, 'a> Deserialize<'de> for Text<'a>
impl<'de, 'a> Deserialize<'de> for Text<'a>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'a> Stylize for Text<'a>
impl<'a> Stylize for Text<'a>
Source§fn underlined(self) -> Self
fn underlined(self) -> Self
Make the text underlined.
Source§fn slow_blink(self) -> Self
fn slow_blink(self) -> Self
Make the text blink slowly.
Source§fn rapid_blink(self) -> Self
fn rapid_blink(self) -> Self
Make the text blink rapidly.
Make the text hidden.
Source§fn crossed_out(self) -> Self
fn crossed_out(self) -> Self
Make the text crossed out.
impl<'a> Eq for Text<'a>
impl<'a> StructuralPartialEq for Text<'a>
Auto Trait Implementations§
impl<'a> Freeze for Text<'a>
impl<'a> RefUnwindSafe for Text<'a>
impl<'a> Send for Text<'a>
impl<'a> Sync for Text<'a>
impl<'a> Unpin for Text<'a>
impl<'a> UnwindSafe for Text<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.