pub enum Color {
}
Expand description
Represents a color.
§Platform-specific Notes
The following list of 16 base colors are available for almost all terminals (Windows 7 and 8 included).
Light | Dark |
---|---|
DarkGrey | Black |
Red | DarkRed |
Green | DarkGreen |
Yellow | DarkYellow |
Blue | DarkBlue |
Magenta | DarkMagenta |
Cyan | DarkCyan |
White | Grey |
Most UNIX terminals and Windows 10 consoles support additional colors.
See Color::Rgb
or Color::AnsiValue
for more info.
Variants§
Reset
Resets the terminal color.
Black
Black color.
DarkGrey
Dark grey color.
Red
Light red color.
DarkRed
Dark red color.
Green
Light green color.
DarkGreen
Dark green color.
Yellow
Light yellow color.
DarkYellow
Dark yellow color.
Blue
Light blue color.
DarkBlue
Dark blue color.
Magenta
Light magenta color.
DarkMagenta
Dark magenta color.
Cyan
Light cyan color.
DarkCyan
Dark cyan color.
White
White color.
Grey
Grey color.
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.
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.
Implementations§
source§impl Color
impl Color
sourcepub fn parse_ansi(ansi: &str) -> Option<Self>
pub fn parse_ansi(ansi: &str) -> Option<Self>
Parses an ANSI color sequence.
§Examples
use crossterm::style::Color;
assert_eq!(Color::parse_ansi("5;0"), Some(Color::Black));
assert_eq!(Color::parse_ansi("5;26"), Some(Color::AnsiValue(26)));
assert_eq!(Color::parse_ansi("2;50;60;70"), Some(Color::Rgb { r: 50, g: 60, b: 70 }));
assert_eq!(Color::parse_ansi("invalid color"), None);
Currently, 3/4 bit color values aren’t supported so return None
.
See also: Colored::parse_ansi
.
Trait Implementations§
source§impl Ord for Color
impl Ord for Color
source§impl PartialEq for Color
impl PartialEq for Color
source§impl PartialOrd for Color
impl PartialOrd for Color
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more