pub struct Style {
pub fg: Option<Color>,
pub bg: Option<Color>,
pub modifiers: Modifiers,
pub underline_color: Option<Color>,
pub underline_style: UnderlineStyle,
}Expand description
Visual style for a terminal cell (foreground, background, modifiers).
Styles are applied to text via the builder methods on Context widget
calls (e.g., .bold(), .fg(Color::Cyan)). All fields are optional;
None means “inherit from the terminal default.”
§Example
use slt::{Style, Color};
let style = Style::new().fg(Color::Cyan).bold();Fields§
§fg: Option<Color>Foreground color, or None to use the terminal default.
bg: Option<Color>Background color, or None to use the terminal default.
modifiers: ModifiersText modifiers (bold, italic, underline, etc.).
underline_color: Option<Color>Underline color, or None to use the same color as the foreground.
Emitted as SGR 58 when set and SGR 59 (reset to foreground) when
cleared. Requires a terminal that supports separate underline colors.
underline_style: UnderlineStyleUnderline rendering style (straight, curly, dotted, etc.).
Defaults to UnderlineStyle::Straight. Non-straight styles are
emitted as CSI 4:Nm and require terminal support.
Implementations§
Source§impl Style
impl Style
Sourcepub fn strikethrough(self) -> Self
pub fn strikethrough(self) -> Self
Add the strikethrough modifier.
Sourcepub const fn underline_color(self, color: Color) -> Self
pub const fn underline_color(self, color: Color) -> Self
Set a separate underline color.
Setting this implies the Modifiers::UNDERLINE bit so the
underline is actually rendered. Emitted as SGR 58.
§Example
use slt::{Color, Modifiers, Style};
let s = Style::new().underline_color(Color::Red);
assert!(s.modifiers.contains(Modifiers::UNDERLINE));Sourcepub const fn underline_style(self, style: UnderlineStyle) -> Self
pub const fn underline_style(self, style: UnderlineStyle) -> Self
Set the underline rendering style (straight, curly, dotted, etc.).
Setting a style implies the Modifiers::UNDERLINE bit so the
underline is actually rendered. Emitted as CSI 4:Nm.
§Example
use slt::{Modifiers, Style, UnderlineStyle};
let s = Style::new().underline_style(UnderlineStyle::Curly);
assert!(s.modifiers.contains(Modifiers::UNDERLINE));Trait Implementations§
impl Copy for Style
Source§impl<'de> Deserialize<'de> for Style
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Style
serde only.