Struct tuirealm::tui::text::Span [−][src]
Expand description
A string where all graphemes have the same style.
Fields
content: Cow<'a, str>
style: Style
Implementations
pub fn styled_graphemes(
&'a self,
base_style: Style
) -> impl Iterator<Item = StyledGrapheme<'a>>
pub fn styled_graphemes(
&'a self,
base_style: Style
) -> impl Iterator<Item = StyledGrapheme<'a>>
Returns an iterator over the graphemes held by this span.
base_style
is the Style
that will be patched with each grapheme Style
to get
the resulting Style
.
Examples
let style = Style::default().fg(Color::Yellow); let span = Span::styled("Text", style); let style = Style::default().fg(Color::Green).bg(Color::Black); let styled_graphemes = span.styled_graphemes(style); assert_eq!( vec![ StyledGrapheme { symbol: "T", style: Style { fg: Some(Color::Yellow), bg: Some(Color::Black), add_modifier: Modifier::empty(), sub_modifier: Modifier::empty(), }, }, StyledGrapheme { symbol: "e", style: Style { fg: Some(Color::Yellow), bg: Some(Color::Black), add_modifier: Modifier::empty(), sub_modifier: Modifier::empty(), }, }, StyledGrapheme { symbol: "x", style: Style { fg: Some(Color::Yellow), bg: Some(Color::Black), add_modifier: Modifier::empty(), sub_modifier: Modifier::empty(), }, }, StyledGrapheme { symbol: "t", style: Style { fg: Some(Color::Yellow), bg: Some(Color::Black), add_modifier: Modifier::empty(), sub_modifier: Modifier::empty(), }, }, ], styled_graphemes.collect::<Vec<StyledGrapheme>>() );Run
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for Span<'a>
impl<'a> UnwindSafe for Span<'a>
Blanket Implementations
Mutably borrows from an owned value. Read more