pub enum Color {
    TerminalDefault,
    Dark(BaseColor),
    Light(BaseColor),
    Rgb(u8u8u8),
    RgbLowRes(u8u8u8),
}
Expand description

Represents a color used by the theme.

Variants§

§

TerminalDefault

Represents a color, preset by terminal.

§

Dark(BaseColor)

One of the 8 base colors.

These colors should work on any terminal.

Note: the actual color used depends on the terminal configuration.

§

Light(BaseColor)

Lighter version of a base color.

The native linux TTY usually doesn’t support these colors, but almost all terminal emulators should.

Note: the actual color used depends on the terminal configuration.

§

Rgb(u8u8u8)

True-color, 24-bit.

On terminals that don’t support this, the color will be “downgraded” to the closest one available.

§

RgbLowRes(u8u8u8)

Low-resolution color.

Each value should be <= 5 (you’ll get panics otherwise).

These 216 possible colors are part of the terminal color palette (256 colors).

Implementations§

Creates a color from its ID in the 256 colors list.

  • Colors 0-7 are base dark colors.
  • Colors 8-15 are base light colors.
  • Colors 16-231 are rgb colors with 6 values per channel (216 colors).
  • Colors 232-255 are grayscale colors.

Creates a Color::RgbLowRes from the given values for red, green and blue.

Returns None if any of the values exceeds 5.

Parse a string into a color.

Examples:

  • "red" becomes Color::Dark(BaseColor::Red)
  • "light green" becomes Color::Light(BaseColor::Green)
  • "default" becomes Color::TerminalDefault
  • "#123456" becomes Color::Rgb(0x12, 0x34, 0x56)

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
Converts to this type from the input type.
Converts to this type from the input type.
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.

Should always be Self
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.