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>
Implementations§
Trait Implementations§
source§impl PartialEq for Colors
impl PartialEq for Colors
impl Copy for Colors
impl Eq for Colors
impl StructuralPartialEq for Colors
Auto Trait Implementations§
impl Freeze for Colors
impl RefUnwindSafe for Colors
impl Send for Colors
impl Sync for Colors
impl Unpin for Colors
impl UnwindSafe for Colors
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