Enum Colored
pub enum Colored {
ForegroundColor(Color),
BackgroundColor(Color),
UnderlineColor(Color),
}Available on crate feature
term only.Expand description
Variants§
ForegroundColor(Color)
A foreground color.
BackgroundColor(Color)
A background color.
UnderlineColor(Color)
An underline color. Important: doesn’t work on windows 10 or lower.
Implementations§
§impl Colored
impl Colored
pub fn parse_ansi(ansi: &str) -> Option<Colored>
pub fn parse_ansi(ansi: &str) -> Option<Colored>
Parse an ANSI foreground or background color.
This is the string that would appear within an ESC [ <str> m escape sequence, as found in
various configuration files.
§Examples
use crossterm::style::{Colored::{self, ForegroundColor, BackgroundColor}, Color};
assert_eq!(Colored::parse_ansi("38;5;0"), Some(ForegroundColor(Color::Black)));
assert_eq!(Colored::parse_ansi("38;5;26"), Some(ForegroundColor(Color::AnsiValue(26))));
assert_eq!(Colored::parse_ansi("48;2;50;60;70"), Some(BackgroundColor(Color::Rgb { r: 50, g: 60, b: 70 })));
assert_eq!(Colored::parse_ansi("49"), Some(BackgroundColor(Color::Reset)));
assert_eq!(Colored::parse_ansi("invalid color"), None);Currently, 3/4 bit color values aren’t supported so return None.
See also: Color::parse_ansi.
pub fn ansi_color_disabled() -> bool
pub fn ansi_color_disabled() -> bool
Checks whether ansi color sequences are disabled by setting of NO_COLOR in environment as per https://no-color.org/
pub fn ansi_color_disabled_memoized() -> bool
pub fn set_ansi_color_disabled(val: bool)
Trait Implementations§
impl Copy for Colored
impl Eq for Colored
§impl Ord for Colored
impl Ord for Colored
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
§impl PartialOrd for Colored
impl PartialOrd for Colored
impl StructuralPartialEq for Colored
Auto Trait Implementations§
impl Freeze for Colored
impl RefUnwindSafe for Colored
impl Send for Colored
impl Sync for Colored
impl Unpin for Colored
impl UnsafeUnpin for Colored
impl UnwindSafe for Colored
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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