diff options
author | Jake Merdich <jake@merdich.com> | 2017-06-23 10:01:53 -0700 |
---|---|---|
committer | Joe Wilm <jwilm@users.noreply.github.com> | 2017-06-23 11:27:15 -0700 |
commit | b4a839aee9784a2d281be1bec87ac6f2ae4a79f0 (patch) | |
tree | 19a72d9a8a80c472a5cc4bf431e769695b01a02c /src/term/color.rs | |
parent | 0091d3cb99e69ffc946ab6bbf40530ff8694b246 (diff) | |
download | alacritty-b4a839aee9784a2d281be1bec87ac6f2ae4a79f0.tar.gz alacritty-b4a839aee9784a2d281be1bec87ac6f2ae4a79f0.zip |
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.
Diffstat (limited to 'src/term/color.rs')
-rw-r--r-- | src/term/color.rs | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/src/term/color.rs b/src/term/color.rs index 0c701c34..8f58d0ca 100644 --- a/src/term/color.rs +++ b/src/term/color.rs @@ -7,11 +7,11 @@ use config::Colors; /// List of indexed colors /// /// The first 16 entries are the standard ansi named colors. Items 16..232 are -/// the color cube. Items 233..256 are the grayscale ramp. Finally, item 256 is +/// the color cube. Items 233..256 are the grayscale ramp. Item 256 is /// the configured foreground color, item 257 is the configured background /// color, item 258 is the cursor foreground color, item 259 is the cursor -/// background color. -pub struct List([Rgb; 260]); +/// background color. Following that are 8 positions for dim colors. +pub struct List([Rgb; 268]); impl<'a> From<&'a Colors> for List { fn from(colors: &Colors) -> List { @@ -55,6 +55,32 @@ impl List { // Foreground and background for custom cursor colors self[ansi::NamedColor::CursorText] = colors.cursor.text; self[ansi::NamedColor::Cursor] = colors.cursor.cursor; + + // Dims + match colors.dim { + Some(ref dim) => { + trace!("Using config-provided dim colors"); + self[ansi::NamedColor::DimBlack] = dim.black; + self[ansi::NamedColor::DimRed] = dim.red; + self[ansi::NamedColor::DimGreen] = dim.green; + self[ansi::NamedColor::DimYellow] = dim.yellow; + self[ansi::NamedColor::DimBlue] = dim.blue; + self[ansi::NamedColor::DimMagenta] = dim.magenta; + self[ansi::NamedColor::DimCyan] = dim.cyan; + self[ansi::NamedColor::DimWhite] = dim.white; + } + None => { + trace!("Deriving dim colors from normal colors"); + self[ansi::NamedColor::DimBlack] = colors.normal.black * 0.66; + self[ansi::NamedColor::DimRed] = colors.normal.red * 0.66; + self[ansi::NamedColor::DimGreen] = colors.normal.green * 0.66; + self[ansi::NamedColor::DimYellow] = colors.normal.yellow * 0.66; + self[ansi::NamedColor::DimBlue] = colors.normal.blue * 0.66; + self[ansi::NamedColor::DimMagenta] = colors.normal.magenta * 0.66; + self[ansi::NamedColor::DimCyan] = colors.normal.cyan * 0.66; + self[ansi::NamedColor::DimWhite] = colors.normal.white * 0.66; + } + } } fn fill_cube(&mut self) { |