pub enum Colored {
ForegroundColor(Color),
BackgroundColor(Color),
UnderlineColor(Color),
}
Expand description
Variants§
ForegroundColor(Color)
A foreground color.
BackgroundColor(Color)
A background color.
UnderlineColor(Color)
An underline color. Imporant: doesnt work on windows 10 or lower.
Implementations§
source§impl Colored
impl Colored
sourcepub fn parse_ansi(ansi: &str) -> Option<Self>
pub fn parse_ansi(ansi: &str) -> Option<Self>
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
.
sourcepub 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§
source§impl Ord for Colored
impl Ord for Colored
source§impl PartialEq for Colored
impl PartialEq for Colored
source§impl PartialOrd for Colored
impl PartialOrd for Colored
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
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 moreimpl Copy for Colored
impl Eq 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 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