Struct ansi_term::Style [−][src]
pub struct Style {
pub foreground: Option<Colour>,
pub background: Option<Colour>,
pub is_bold: bool,
pub is_dimmed: bool,
pub is_italic: bool,
pub is_underline: bool,
pub is_blink: bool,
pub is_reverse: bool,
pub is_hidden: bool,
pub is_strikethrough: bool,
}Expand description
A style is a collection of properties that can format a string using ANSI escape codes.
Fields
foreground: Option<Colour>The style’s foreground colour, if it has one.
background: Option<Colour>The style’s background colour, if it has one.
is_bold: boolWhether this style is bold.
is_dimmed: boolWhether this style is dimmed.
is_italic: boolWhether this style is italic.
is_underline: boolWhether this style is underlined.
is_blink: boolWhether this style is blinking.
is_reverse: boolWhether this style has reverse colours.
Whether this style is hidden.
is_strikethrough: boolWhether this style is struckthrough.
Implementations
Returns a Style with the hidden property set.
Returns a Style with the hidden property set.
Returns a Style with the foreground colour property set.
Returns a Style with the background colour property set.
Trait Implementations
Styles have a special Debug implementation that only shows the fields that
are set. Fields that haven’t been touched aren’t included in the output.
This behaviour gets bypassed when using the alternate formatting mode
format!("{:#?}").
use ansi_term::Colour::{Red, Blue}; assert_eq!("Style { fg(Red), on(Blue), bold, italic }", format!("{:?}", Red.on(Blue).bold().italic()));
Returns a style with no properties set. Formatting text using this style returns the exact same text.
use ansi_term::Style; assert_eq!(None, Style::default().foreground); assert_eq!(None, Style::default().background); assert_eq!(false, Style::default().is_bold); assert_eq!("txt", Style::default().paint("txt").to_string());
You can turn a Colour into a Style with the foreground colour set
with the From trait.
use ansi_term::{Style, Colour}; let green_foreground = Style::default().fg(Colour::Green); assert_eq!(green_foreground, Colour::Green.normal()); assert_eq!(green_foreground, Colour::Green.into()); assert_eq!(green_foreground, Style::from(Colour::Green));
Auto Trait Implementations
impl RefUnwindSafe for Style
impl UnwindSafe for Style
Blanket Implementations
Mutably borrows from an owned value. Read more