From b4a839aee9784a2d281be1bec87ac6f2ae4a79f0 Mon Sep 17 00:00:00 2001 From: Jake Merdich Date: Fri, 23 Jun 2017 10:01:53 -0700 Subject: Add dim color support Add support for the VTE 'dim' flag, with additional support for custom-themed dim colors. If no color is specified in the config, it will default to 2/3 the previous (not a spec, but the value other terminals seem to use). The actual dimming behavior brings bright colors to normal and regular colors to the new dim ones. Custom RGB values are not changed, nor are non-named indexed colors. --- src/ansi.rs | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'src/ansi.rs') diff --git a/src/ansi.rs b/src/ansi.rs index 5114f7df..2eccf335 100644 --- a/src/ansi.rs +++ b/src/ansi.rs @@ -442,6 +442,22 @@ pub enum NamedColor { CursorText, /// Color for the cursor itself Cursor, + /// Dim black + DimBlack, + /// Dim red + DimRed, + /// Dim green + DimGreen, + /// Dim yellow + DimYellow, + /// Dim blue + DimBlue, + /// Dim magenta + DimMagenta, + /// Dim cyan + DimCyan, + /// Dim white + DimWhite, } impl NamedColor { @@ -455,6 +471,36 @@ impl NamedColor { NamedColor::Magenta => NamedColor::BrightMagenta, NamedColor::Cyan => NamedColor::BrightCyan, NamedColor::White => NamedColor::BrightWhite, + NamedColor::DimBlack => NamedColor::Black, + NamedColor::DimRed => NamedColor::Red, + NamedColor::DimGreen => NamedColor::Green, + NamedColor::DimYellow => NamedColor::Yellow, + NamedColor::DimBlue => NamedColor::Blue, + NamedColor::DimMagenta => NamedColor::Magenta, + NamedColor::DimCyan => NamedColor::Cyan, + NamedColor::DimWhite => NamedColor::White, + val => val + } + } + + pub fn to_dim(&self) -> Self { + match *self { + NamedColor::Black => NamedColor::DimBlack, + NamedColor::Red => NamedColor::DimRed, + NamedColor::Green => NamedColor::DimGreen, + NamedColor::Yellow => NamedColor::DimYellow, + NamedColor::Blue => NamedColor::DimBlue, + NamedColor::Magenta => NamedColor::DimMagenta, + NamedColor::Cyan => NamedColor::DimCyan, + NamedColor::White => NamedColor::DimWhite, + NamedColor::BrightBlack => NamedColor::Black, + NamedColor::BrightRed => NamedColor::Red, + NamedColor::BrightGreen => NamedColor::Green, + NamedColor::BrightYellow => NamedColor::Yellow, + NamedColor::BrightBlue => NamedColor::Blue, + NamedColor::BrightMagenta => NamedColor::Magenta, + NamedColor::BrightCyan => NamedColor::Cyan, + NamedColor::BrightWhite => NamedColor::White, val => val } } -- cgit v1.2.3-54-g00ecf