Enum text_terminal::Color

source ·
pub enum Color {
Show 19 variants Black, Red, Green, Yellow, Blue, Magenta, Cyan, White, BrightBlack, BrightRed, BrightGreen, BrightYellow, BrightBlue, BrightMagenta, BrightCyan, BrightWhite, Color8Bit(u8), RGB { red: u8, green: u8, blue: u8, }, Default,
}
Expand description

The set of colors that can be displayed by a terminal emulator.

  • The first 8 variants are 3-bit colors, supported on every terminal emulator.
  • The next 8 variants are 4-bit colors, which are brightened (or bold) versions of the first 8.
  • After that, the 8-bit color variant accepts any value from 0 to 256, in which values of 0-15 are the same as the first 16 variants of this enum
  • Finally, the 24-bit color variant accepts standard RGB values.

See here for the set of colors: https://en.wikipedia.org/wiki/ANSI_escape_code#Colors

Variants§

§

Black

§

Red

§

Green

§

Yellow

§

Blue

§

Magenta

§

Cyan

§

White

More of a light gray/grey. Use BrightWhite for true white.

§

BrightBlack

Gray/grey.

§

BrightRed

§

BrightGreen

§

BrightYellow

§

BrightBlue

§

BrightMagenta

§

BrightCyan

§

BrightWhite

True pure white.

§

Color8Bit(u8)

8-bit color, as introduced in xterm.

  • Values of 0 through 15 are identical to the above 16 color variants.
  • The next 216 colors 16 through 231 are arranged into a 6 x 6 x 6 color cube, as shown here: https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit.
  • The last 24 colors 232 through 255 are grayscale steps from dark gray to light.

This is sometimes referred to as a Palette color lookup table.

§

RGB

Fields

§red: u8
§green: u8
§blue: u8

True 24-bit RGB color, with 8 bits for each of the red, green, and blue channels.

§

Default

The default color, which is generally unspecified and depends on the context in which it is used.

Trait Implementations§

source§

impl Clone for Color

source§

fn clone(&self) -> Color

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Color

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Color

source§

fn default() -> Color

Returns the “default value” for a type. Read more
source§

impl From<Color> for BackgroundColor

source§

fn from(c: Color) -> Self

Converts to this type from the input type.
source§

impl From<Color> for ForegroundColor

source§

fn from(c: Color) -> Self

Converts to this type from the input type.
source§

impl From<Color> for UnderlinedColor

source§

fn from(c: Color) -> Self

Converts to this type from the input type.
source§

impl From<u8> for Color

source§

fn from(value: u8) -> Self

Converts to this type from the input type.
source§

impl PartialEq<Color> for Color

source§

fn eq(&self, other: &Color) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Color

source§

impl Eq for Color

source§

impl StructuralEq for Color

source§

impl StructuralPartialEq for Color

Auto Trait Implementations§

§

impl RefUnwindSafe for Color

§

impl Send for Color

§

impl Sync for Color

§

impl Unpin for Color

§

impl UnwindSafe for Color

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.