Enum term_painter::Color

source ·
pub enum Color {
Show 18 variants NotSet, Black, Red, Green, Yellow, Blue, Magenta, Cyan, White, BrightBlack, BrightRed, BrightGreen, BrightYellow, BrightBlue, BrightMagenta, BrightCyan, BrightWhite, Custom(u32),
}
Expand description

Lists all possible Colors. It implements ToStyle so it’s possible to call ToStyle’s methods directly on a Color variant like:


println!("{}", Color::Red.bold().paint("Red and bold"));

It is not guaranteed that the local terminal supports all of those colors. As already mentioned in the module documentation, you should use term directly to check the terminal’s capabilities.

Note: Using Color::NotSet will not reset the color to the default terminal color.

Variants§

§

NotSet

§

Black

§

Red

§

Green

§

Yellow

§

Blue

§

Magenta

§

Cyan

§

White

§

BrightBlack

§

BrightRed

§

BrightGreen

§

BrightYellow

§

BrightBlue

§

BrightMagenta

§

BrightCyan

§

BrightWhite

§

Custom(u32)

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() -> Self

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

impl PartialEq 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 ToStyle for Color

source§

fn to_style(self) -> Style

Returns a Style with default values and the self color as foreground color.

source§

fn to_mapped_style<F>(self, func: F) -> Style
where F: FnOnce(&mut Style),

Convenience method for modifying the style before it’s returned.
source§

fn fg(self, c: Color) -> Style

Sets the foreground (text) color.
source§

fn bg(self, c: Color) -> Style

Sets the background color.
source§

fn bold(self) -> Style

Makes the text bold.
source§

fn dim(self) -> Style

Dim mode.
source§

fn underline(self) -> Style

Underlines the text.
source§

fn not_underline(self) -> Style

Removes underline-attribute.
Underlines the text.
source§

fn reverse(self) -> Style

Underlines the text.
source§

fn secure(self) -> Style

Secure mode.
source§

fn paint<T>(&self, obj: T) -> Painted<T>
where Self: Clone,

Wraps the style specified in self and something of arbitrary type into a Painted. When Painted is printed it will print the arbitrary something with the given style.
source§

fn with<F, R>(&self, f: F) -> R
where F: FnOnce() -> R, Self: Clone,

Executes the given function, applying the style information before calling it and resetting after it finished.
source§

impl Copy for Color

source§

impl Eq 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 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> 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> ToOwned for T
where 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 T
where 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 T
where 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.