pub enum ColorSpec {
Reset,
PaletteIndex(PaletteIndex),
TrueColor(RgbaColor),
}Expand description
Terminal color specification for Sgr color commands.
This is the common color input type for foreground, background, and underline colors. Named
ANSI colors and 256-color palette values use Self::PaletteIndex; true-color values use
Self::TrueColor; Self::Reset returns the terminal color to its default.
use termina::{
escape::csi::{Csi, Sgr},
style::{ColorSpec, RgbColor},
};
assert_eq!(Csi::Sgr(Sgr::Foreground(ColorSpec::RED)).to_string(), "\x1b[31m");
let blue = ColorSpec::from(RgbColor::new(0, 0, 255));
assert_eq!(Csi::Sgr(Sgr::Foreground(blue)).to_string(), "\x1b[38;2;0;0;255m");Variants§
Reset
Reset the color back to the terminal default.
For SGR foreground and background colors this formats as the standard reset color codes rather than as an indexed palette color.
PaletteIndex(PaletteIndex)
Use an indexed palette color.
Values 0-15 address the standard ANSI palette. Values 16-255 address the 256-color
extension palette described by WebColor.
TrueColor(RgbaColor)
Use a true-color red, green, blue, and alpha value.
Red, green, and blue values format using SGR true-color parameters. Non-opaque alpha uses the colon form from ITU T.416-style color notation.
Implementations§
Source§impl ColorSpec
impl ColorSpec
Sourcepub const BRIGHT_BLACK: Self
pub const BRIGHT_BLACK: Self
Bright black palette color.
Sourcepub const BRIGHT_RED: Self
pub const BRIGHT_RED: Self
Bright red palette color.
Sourcepub const BRIGHT_GREEN: Self
pub const BRIGHT_GREEN: Self
Bright green palette color.
Sourcepub const BRIGHT_YELLOW: Self
pub const BRIGHT_YELLOW: Self
Bright yellow palette color.
Sourcepub const BRIGHT_BLUE: Self
pub const BRIGHT_BLUE: Self
Bright blue palette color.
Sourcepub const BRIGHT_MAGENTA: Self
pub const BRIGHT_MAGENTA: Self
Bright magenta palette color.
Sourcepub const BRIGHT_CYAN: Self
pub const BRIGHT_CYAN: Self
Bright cyan palette color.
Sourcepub const BRIGHT_WHITE: Self
pub const BRIGHT_WHITE: Self
Bright white palette color.