Enum comfy_table::Color
source · [−]pub enum Color {
}
Expand description
Colors used for styling cell content. Reexport of crossterm’s Color enum. 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
sourceimpl Color
impl Color
Colors used for styling cell content. Reexport of crossterm’s Color enum.
sourcepub fn parse_ansi(ansi: &str) -> Option<Color>
pub fn parse_ansi(ansi: &str) -> Option<Color>
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
sourceimpl Ord for Color
impl Ord for Color
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialEq<Color> for Color
impl PartialEq<Color> for Color
sourceimpl PartialOrd<Color> for Color
impl PartialOrd<Color> for Color
sourcefn partial_cmp(&self, other: &Color) -> Option<Ordering>
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 · sourcefn lt(&self, other: &Rhs) -> bool
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 · sourcefn 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 more
impl Copy for Color
impl Eq for Color
impl StructuralEq for Color
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more