pub struct Colors {
pub foreground: Option<Color>,
pub background: Option<Color>,
}
Expand description
Represents, optionally, a foreground and/or a background color.
It can be applied using the SetColors
command.
It can also be created from a Colored value or a tuple of
(Color, Color)
in the order (foreground, background)
.
The then method can be used to combine Colors
values.
For example:
use crossterm::style::{Color, Colors, Colored};
// An example color, loaded from a config, file in ANSI format.
let config_color = "38;2;23;147;209";
// Default to green text on a black background.
let default_colors = Colors::new(Color::Green, Color::Black);
// Load a colored value from a config and override the default colors
let colors = match Colored::parse_ansi(config_color) {
Some(colored) => default_colors.then(&colored.into()),
None => default_colors,
};
See Color.
Fields§
§foreground: Option<Color>
§background: Option<Color>