pub enum Color {
Show 18 variants Black, LightRed, DarkRed, LightGreen, DarkGreen, LightYellow, DarkYellow, LightBlue, DarkBlue, LightMagenta, DarkMagenta, LightCyan, DarkCyan, White, Grey, DarkGrey, Rgb { r: u8, g: u8, b: u8, }, AnsiValue(u8),
}
Expand description

Represents a color to be used for text styling purposes.

Currently a clone of crossterm::style::Color. Check their documentation for detailed documentation.

In summary, the 16 defined colors are supported by almost all terminals. The Rgb and AnsiValue variants are supported in more modern ones.

Variants

Black

Black color.

Ansi code reference: 0

Supported on all terminal back-ends: crossterm, termion and console.

LightRed

Light red color.

Ansi code reference: 9

Supported on two terminal back-ends: crossterm (the default) and termion. On console, it is mapped to the DarkRed color (Ansi code reference 1).

DarkRed

Dark red color.

Ansi code reference: 1

Supported on all terminal back-ends: crossterm, termion and console.

LightGreen

Light green color.

Ansi code reference: 10

Supported on two terminal back-ends: crossterm (the default) and termion. On console, it is mapped to the DarkGreen color (Ansi code reference 2).

DarkGreen

Dark green color.

Ansi code reference: 2

Supported on all terminal back-ends: crossterm, termion and console.

LightYellow

Light yellow color.

Ansi code reference: 11

Supported on two terminal back-ends: crossterm (the default) and termion. On console, it is mapped to the DarkYellow color (Ansi code reference 3).

DarkYellow

Dark yellow color.

Ansi code reference: 3

Supported on all terminal back-ends: crossterm, termion and console.

LightBlue

Light blue color.

Ansi code reference: 12

Supported on two terminal back-ends: crossterm (the default) and termion. On console, it is mapped to the DarkBlue color (Ansi code reference 4).

DarkBlue

Dark blue color.

Ansi code reference: 4

Supported on all terminal back-ends: crossterm, termion and console.

LightMagenta

Light magenta color.

Ansi code reference: 13

Supported on two terminal back-ends: crossterm (the default) and termion. On console, it is mapped to the DarkMagenta color (Ansi code reference 5).

DarkMagenta

Dark magenta color.

Ansi code reference: 5

Supported on all terminal back-ends: crossterm, termion and console.

LightCyan

Light cyan color.

Ansi code reference: 14

Supported on two terminal back-ends: crossterm (the default) and termion. On console, it is mapped to the DarkCyan color (Ansi code reference 6).

DarkCyan

Dark cyan color.

Ansi code reference: 6

Supported on all terminal back-ends: crossterm, termion and console.

White

White color.

Ansi code reference: 15

Supported on two terminal back-ends: crossterm (the default) and termion. On console, it is mapped to the Grey color (Ansi code reference 7).

Grey

Grey color.

Ansi code reference: 7

Supported on all terminal back-ends: crossterm, termion and console.

DarkGrey

Dark grey color.

Ansi code reference: 8

Supported on two terminal back-ends: crossterm (the default) and termion. On console, it is mapped to the Black color (Ansi code reference 0).

Rgb

Fields

r: u8

red value of RGB.

g: u8

green value of RGB.

b: u8

blue value of 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.

Supported on the default terminal back-end crossterm and on termion. Not supported on console.

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.

Supported on all terminal back-ends: crossterm, termion and console.

Implementations

Shorthand method for creating a Color from RGB components


assert_eq!(Color::rgb(42, 17, 97), Color::Rgb { r: 42, g: 17, b: 97 });

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Write the foreground version of this color.
Write the background version of this color.
Formats the value using the given formatter. Read more
Converts to this type from the input type.
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
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.