Skip to main content

Color

Enum Color 

Source
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

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.

Fields

§r: u8

red value of RGB.

§g: u8

green value of RGB.

§b: u8

blue value of RGB.

§

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§

Source§

impl Color

Source

pub fn rgb(r: u8, g: u8, b: u8) -> Color

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§

Source§

impl Clone for Color

Source§

fn clone(&self) -> Color

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Color

Source§

impl Debug for Color

Source§

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

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

impl Eq for Color

Source§

impl Hash for Color

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

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

impl PartialEq for Color

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Color

Auto Trait Implementations§

§

impl Freeze for Color

§

impl RefUnwindSafe for Color

§

impl Send for Color

§

impl Sync for Color

§

impl Unpin for Color

§

impl UnsafeUnpin for Color

§

impl UnwindSafe for Color

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V