pub struct Style {
pub foreground: Option<Color>,
pub background: Option<Color>,
pub font_style: FontStyle,
pub underline: Option<Color>,
}
Expand description
A foreground color, background color and font-style.
Fields§
§foreground: Option<Color>
§background: Option<Color>
§font_style: FontStyle
§underline: Option<Color>
Implementations§
source§impl Style
impl Style
sourcepub fn from_ansi_sequence(code: &str) -> Option<Style>
pub fn from_ansi_sequence(code: &str) -> Option<Style>
Parse ANSI escape sequences like 38;2;255;0;100;1;4
(pink, bold, underlined).
sourcepub fn to_nu_ansi_term_style(&self) -> Style
pub fn to_nu_ansi_term_style(&self) -> Style
Convert to a nu_ansi_term::Style
(if the nu-ansi-term
or gnu_legacy
feature is enabled).
§Example for nu-ansi-term feature
use lscolors::{Color, FontStyle, Style};
let style = Style {
font_style: FontStyle {
bold: true,
..Default::default()
},
foreground: Some(Color::Blue),
..Default::default()
};
let nu_ansi = style.to_nu_ansi_term_style();
assert_eq!("\x1b[1;34mwow\x1b[0m", nu_ansi.paint("wow").to_string());
§Example for gnu_legacy feature
use lscolors::{Color, FontStyle, Style};
let style = Style {
font_style: FontStyle {
bold: true,
..Default::default()
},
foreground: Some(Color::Blue),
..Default::default()
};
let nu_ansi = style.to_nu_ansi_term_style();
assert_eq!(
"\u{1b}[0m\u{1b}[01;34mwow\u{1b}[0m",
nu_ansi.paint("wow").to_string()
);
Trait Implementations§
source§impl PartialEq for Style
impl PartialEq for Style
impl StructuralPartialEq for Style
Auto Trait Implementations§
impl RefUnwindSafe for Style
impl Send for Style
impl Sync for Style
impl Unpin for Style
impl UnwindSafe for Style
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