pub struct Style {
pub fg: Option<Color>,
pub bg: Option<Color>,
pub bold: bool,
pub dim: bool,
pub italic: bool,
pub underline: bool,
pub strikethrough: bool,
pub blink: bool,
pub reset: bool,
pub prefix: Option<String>,
}Expand description
A complete set of visual attributes for a span of text.
Fields§
§fg: Option<Color>Foreground color. None leaves the terminal default unchanged.
bg: Option<Color>Background color. None leaves the terminal default unchanged.
bold: boolBold text (SGR 1).
dim: boolReduced intensity text (SGR 2).
italic: boolItalic text (SGR 3).
underline: boolUnderlined text (SGR 4).
strikethrough: boolCrossed-out text (SGR 9).
blink: boolBlinking text (SGR 5). Terminal support varies.
reset: boolFull reset. Enabling this option overrides all previous options.
prefix: Option<String>Optional prefix string prepended before the style’s escape sequence.
Implementations§
Source§impl Style
impl Style
Sourcepub fn parse(markup: impl Into<String>) -> Result<Self, LexError>
pub fn parse(markup: impl Into<String>) -> Result<Self, LexError>
Parses a farben markup string into a Style.
Tokenizes markup and folds the resulting tags into a single Style value.
Text tokens are ignored; only tag tokens affect the output.
§Errors
Returns a LexError if markup contains an unclosed tag, an unrecognized tag
name, or an invalid color argument.
§Example
let style = Style::parse("[bold red]")?;
assert!(style.bold);
assert_eq!(style.fg, Some(Color::Named(NamedColor::Red)));