Enum comfy_table::Color[][src]

pub enum Color {
Show 19 variants Reset, Black, DarkGrey, Red, DarkRed, Green, DarkGreen, Yellow, DarkYellow, Blue, DarkBlue, Magenta, DarkMagenta, Cyan, DarkCyan, White, Grey, Rgb { r: u8, g: u8, b: u8, }, AnsiValue(u8),
}
Expand description

Colors used for styling cell content. Reexport of crossterm’s Color enum. Represents a color.

Platform-specific Notes

The following list of 16 base colors are available for almost all terminals (Windows 7 and 8 included).

LightDark
GreyBlack
RedDarkRed
GreenDarkGreen
YellowDarkYellow
BlueDarkBlue
MagentaDarkMagenta
CyanDarkCyan
WhiteDarkWhite

Most UNIX terminals and Windows 10 consoles support additional colors. See Color::Rgb or Color::AnsiValue for more info.

Variants

Reset

Resets the terminal color.

Black

Black color.

DarkGrey

Dark grey color.

Red

Light red color.

DarkRed

Dark red color.

Green

Light green color.

DarkGreen

Dark green color.

Yellow

Light yellow color.

DarkYellow

Dark yellow color.

Blue

Light blue color.

DarkBlue

Dark blue color.

Magenta

Light magenta color.

DarkMagenta

Dark magenta color.

Cyan

Light cyan color.

DarkCyan

Dark cyan color.

White

White color.

Grey

Grey color.

Rgb

An RGB color. See RGB color model for more info.

Most UNIX terminals and Windows 10 supported only. See Platform-specific notes for more info.

Fields of Rgb

r: u8g: u8b: u8
AnsiValue(u8)

An ANSI color. See 256 colors - cheat sheet for more info.

Most UNIX terminals and Windows 10 supported only. See Platform-specific notes for more info.

Implementations

Colors used for styling cell content. Reexport of crossterm’s Color enum.

Parses an ANSI color sequence.

Examples

use crossterm::style::Color;

assert_eq!(Color::parse_ansi("5;0"), Some(Color::Black));
assert_eq!(Color::parse_ansi("5;26"), Some(Color::AnsiValue(26)));
assert_eq!(Color::parse_ansi("2;50;60;70"), Some(Color::Rgb { r: 50, g: 60, b: 70 }));
assert_eq!(Color::parse_ansi("invalid color"), None);

Currently, 3/4 bit color values aren’t supported so return None.

See also: Colored::parse_ansi.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Creates a ‘Color’ from the tuple representation.

Creates a Color from the string representation.

Notes

  • Returns Color::White in case of an unknown color.
  • Does not return Err and you can safely unwrap.

The associated error which can be returned from parsing.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Try to create a Color from the string representation. This returns an error if the string does not match.

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.