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/mod.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/mod.rs')
-rw-r--r-- | src/term/mod.rs | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/term/mod.rs b/src/term/mod.rs index 8563be54..d898fe2f 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -268,23 +268,30 @@ impl<'a> RenderableCellsIter<'a> { } fn compute_fg_rgb(&self, fg: &Color, cell: &Cell) -> Rgb { + use self::cell::DIM_BOLD; match *fg { Color::Spec(rgb) => rgb, Color::Named(ansi) => { - if self.config.draw_bold_text_with_bright_colors() && cell.bold() { - self.colors[ansi.to_bright()] - } else { - self.colors[ansi] + match (self.config.draw_bold_text_with_bright_colors(), cell.flags & DIM_BOLD) { + // Draw bold text in bright colors *and* contains bold flag. + (true, self::cell::DIM_BOLD) | + (true, self::cell::BOLD) => self.colors[ansi.to_bright()], + // Cell is marked as dim and not bold + (_, self::cell::DIM) => self.colors[ansi.to_dim()], + // None of the above, keep original color. + _ => self.colors[ansi] } }, Color::Indexed(idx) => { - let idx = if self.config.draw_bold_text_with_bright_colors() - && cell.bold() - && idx < 8 - { - idx + 8 - } else { + let idx = match ( + self.config.draw_bold_text_with_bright_colors(), + cell.flags & DIM_BOLD, idx + ) { + (true, self::cell::BOLD, 0...7) => idx as usize + 8, + (false, self::cell::DIM, 8...15) => idx as usize - 8, + (false, self::cell::DIM, 0...7) => idx as usize + 260, + _ => idx as usize, }; self.colors[idx] @@ -1696,7 +1703,8 @@ impl ansi::Handler for Term { Attr::Reverse => self.cursor.template.flags.insert(cell::INVERSE), Attr::CancelReverse => self.cursor.template.flags.remove(cell::INVERSE), Attr::Bold => self.cursor.template.flags.insert(cell::BOLD), - Attr::CancelBoldDim => self.cursor.template.flags.remove(cell::BOLD), + Attr::Dim => self.cursor.template.flags.insert(cell::DIM), + Attr::CancelBoldDim => self.cursor.template.flags.remove(cell::BOLD | cell::DIM), Attr::Italic => self.cursor.template.flags.insert(cell::ITALIC), Attr::CancelItalic => self.cursor.template.flags.remove(cell::ITALIC), Attr::Underscore => self.cursor.template.flags.insert(cell::UNDERLINE), |