Enum ansi_str::Color

source ·
pub enum Color {
Show 20 variants Black, BrightBlack, Red, BrightRed, Green, BrightGreen, Yellow, BrightYellow, Blue, BrightBlue, Purple, BrightPurple, Magenta, BrightMagenta, Cyan, BrightCyan, White, BrightWhite, Fixed(u8), Rgb(u8, u8, u8),
}
Expand description

A color is one specific type of ANSI escape code, and can refer to either the foreground or background color.

These use the standard numeric sequences. See http://invisible-island.net/xterm/ctlseqs/ctlseqs.html

Variants§

§

Black

Color #0 (foreground code 30, background code 40).

This is not necessarily the background color, and using it as one may render the text hard to read on terminals with dark backgrounds.

§

BrightBlack

Color #0 (foreground code 90, background code 100).

§

Red

Color #1 (foreground code 31, background code 41).

§

BrightRed

Color #1 (foreground code 91, background code 101).

§

Green

Color #2 (foreground code 32, background code 42).

§

BrightGreen

Color #2 (foreground code 92, background code 102).

§

Yellow

Color #3 (foreground code 33, background code 43).

§

BrightYellow

Color #3 (foreground code 93, background code 103).

§

Blue

Color #4 (foreground code 34, background code 44).

§

BrightBlue

Color #4 (foreground code 94, background code 104).

§

Purple

Color #5 (foreground code 35, background code 45).

§

BrightPurple

Color #5 (foreground code 95, background code 105).

§

Magenta

Color #5 (foreground code 35, background code 45).

§

BrightMagenta

Color #5 (foreground code 95, background code 105).

§

Cyan

Color #6 (foreground code 36, background code 46).

§

BrightCyan

Color #6 (foreground code 96, background code 106).

§

White

Color #7 (foreground code 37, background code 47).

As above, this is not necessarily the foreground color, and may be hard to read on terminals with light backgrounds.

§

BrightWhite

Color #7 (foreground code 97, background code 107).

§

Fixed(u8)

A color number from 0 to 255, for use in 256-color terminal environments.

  • colors 0 to 7 are the Black to White variants respectively. These colors can usually be changed in the terminal emulator.
  • colors 8 to 15 are brighter versions of the eight colors above. These can also usually be changed in the terminal emulator, or it could be configured to use the original colors and show the text in bold instead. It varies depending on the program.
  • colors 16 to 231 contain several palettes of bright colors, arranged in six squares measuring six by six each.
  • colors 232 to 255 are shades of grey from black to white.

It might make more sense to look at a color chart.

§

Rgb(u8, u8, u8)

A 24-bit Rgb color, as specified by ISO-8613-3.

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 From<AnsiColor> for Color

source§

fn from(clr: AnsiColor) -> Self

Converts to this type from the input type.
source§

impl Hash for Color

source§

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

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 Ord for Color

source§

fn cmp(&self, other: &Color) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
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 PartialOrd<Color> for Color

source§

fn partial_cmp(&self, other: &Color) -> Option<Ordering>

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

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

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

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

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

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

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

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
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.