pub fn translate_font_style(
    syntect_font_style: FontStyle
) -> Result<Modifier, SyntectTuiError>
Expand description

Converts a syntect::highlighting::FontStyle into a ratatui::style::Modifier.

§Examples

Basic usage:

let input = syntect::highlighting::FontStyle::BOLD | syntect::highlighting::FontStyle::ITALIC;
let expected = ratatui::style::Modifier::BOLD | ratatui::style::Modifier::ITALIC;
let actual = syntect_tui::translate_font_style(input).unwrap();
assert_eq!(expected, actual);

§Errors

Can return SyntectTuiError::UnknownFontStyle if the input FontStyle is not supported.

All explicit compositions of BOLD, ITALIC & UNDERLINE are supported, however, implicit bitflag coercions are not. For example, even though FontStyle::from_bits(3) is coerced to Some(FontStyle::BOLD | FontStyle::ITALIC), we ignore this result as it would be a pain to handle all implicit coercions.