[][src]Struct crossterm::style::Colors

pub struct Colors {
    pub foreground: Option<Color>,
    pub background: Option<Color>,
}

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

impl Colors[src]

pub fn then(&self, other: &Colors) -> Colors[src]

Returns a new Color which, when applied, has the same effect as applying self and then other.

impl Colors[src]

pub fn new(foreground: Color, background: Color) -> Colors[src]

Trait Implementations

impl Clone for Colors[src]

impl Copy for Colors[src]

impl Debug for Colors[src]

impl Eq for Colors[src]

impl From<Colored> for Colors[src]

impl PartialEq<Colors> for Colors[src]

impl StructuralEq for Colors[src]

impl StructuralPartialEq for Colors[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.