aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Garde <remi.garde@free.fr>2018-07-23 18:48:27 +0200
committerChristian Duerr <chrisduerr@users.noreply.github.com>2018-07-23 16:48:27 +0000
commitd25134bc6b8b13d5ff550c950c65b6e9c4a7a267 (patch)
tree1742ed9d0613b018d147e54055da7dd2c518430d
parentea512cb0f3cb159707eb29fdbf2e31bbb1c1b902 (diff)
downloadalacritty-d25134bc6b8b13d5ff550c950c65b6e9c4a7a267.tar.gz
alacritty-d25134bc6b8b13d5ff550c950c65b6e9c4a7a267.zip
Add optional dim foreground color
Add optional color for the dim foreground (`\e[2m;`) Defaults to 2/3 of the foreground color. (same as other colors). If a bright color is dimmed, it's displayed as the normal color. The exception for this is when the bright foreground is dimmed when no bright foreground color is set. In that case it's treated as a normal foreground color and dimmed to DimForeground. To minimize the surprise for the user, the bright and dim colors have been completely removed from the default configuration file. Some documentation has also been added to make it clear to users what these options can be used for. This fixes #1448.
-rw-r--r--alacritty.yml10
-rw-r--r--alacritty_macos.yml10
-rw-r--r--src/ansi.rs5
-rw-r--r--src/config.rs7
-rw-r--r--src/term/color.rs8
-rw-r--r--src/term/mod.rs13
6 files changed, 44 insertions, 9 deletions
diff --git a/alacritty.yml b/alacritty.yml
index 8cee1d48..be350be9 100644
--- a/alacritty.yml
+++ b/alacritty.yml
@@ -117,7 +117,15 @@ colors:
primary:
background: '0x000000'
foreground: '0xeaeaea'
- bright_foreground: '0xeaeaea'
+
+ # (Optional) Bright and Dim foreground colors
+ #
+ # The dimmed foreground color is calculated automatically if it is not present.
+ # If the bright foreground color is not set, or `draw_bold_text_with_bright_colors`
+ # is `false`, the normal foreground color will be used.
+ #
+ # dim_foreground: '0x9a9a9a'
+ # bright_foreground: '0xffffff'
# Colors the cursor will use if `custom_cursor_colors` is true
cursor:
diff --git a/alacritty_macos.yml b/alacritty_macos.yml
index 76a4db4a..e3e57b86 100644
--- a/alacritty_macos.yml
+++ b/alacritty_macos.yml
@@ -95,7 +95,15 @@ colors:
primary:
background: '0x000000'
foreground: '0xeaeaea'
- bright_foreground: '0xeaeaea'
+
+ # (Optional) Bright and Dim foreground colors
+ #
+ # The dimmed foreground color is calculated automatically if it is not present.
+ # If the bright foreground color is not set, or `draw_bold_text_with_bright_colors`
+ # is `false`, the normal foreground color will be used.
+ #
+ # dim_foreground: '0x9a9a9a'
+ # bright_foreground: '0xffffff'
# Colors the cursor will use if `custom_cursor_colors` is true
cursor:
diff --git a/src/ansi.rs b/src/ansi.rs
index 726550a0..f1ca759a 100644
--- a/src/ansi.rs
+++ b/src/ansi.rs
@@ -560,6 +560,8 @@ pub enum NamedColor {
DimWhite,
/// The bright foreground color
BrightForeground,
+ /// Dim foreground
+ DimForeground,
}
impl NamedColor {
@@ -574,6 +576,7 @@ impl NamedColor {
NamedColor::Magenta => NamedColor::BrightMagenta,
NamedColor::Cyan => NamedColor::BrightCyan,
NamedColor::White => NamedColor::BrightWhite,
+ NamedColor::DimForeground => NamedColor::Foreground,
NamedColor::DimBlack => NamedColor::Black,
NamedColor::DimRed => NamedColor::Red,
NamedColor::DimGreen => NamedColor::Green,
@@ -596,6 +599,7 @@ impl NamedColor {
NamedColor::Magenta => NamedColor::DimMagenta,
NamedColor::Cyan => NamedColor::DimCyan,
NamedColor::White => NamedColor::DimWhite,
+ NamedColor::Foreground => NamedColor::DimForeground,
NamedColor::BrightBlack => NamedColor::Black,
NamedColor::BrightRed => NamedColor::Red,
NamedColor::BrightGreen => NamedColor::Green,
@@ -604,6 +608,7 @@ impl NamedColor {
NamedColor::BrightMagenta => NamedColor::Magenta,
NamedColor::BrightCyan => NamedColor::Cyan,
NamedColor::BrightWhite => NamedColor::White,
+ NamedColor::BrightForeground => NamedColor::Foreground,
val => val
}
}
diff --git a/src/config.rs b/src/config.rs
index 76daee05..b50e3243 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -1023,11 +1023,13 @@ pub struct PrimaryColors {
pub background: Rgb,
#[serde(deserialize_with = "rgb_from_hex")]
pub foreground: Rgb,
- #[serde(default, deserialize_with = "deserialize_bright_foreground")]
+ #[serde(default, deserialize_with = "deserialize_optional_color")]
pub bright_foreground: Option<Rgb>,
+ #[serde(default, deserialize_with = "deserialize_optional_color")]
+ pub dim_foreground: Option<Rgb>,
}
-fn deserialize_bright_foreground<'a, D>(deserializer: D) -> ::std::result::Result<Option<Rgb>, D::Error>
+fn deserialize_optional_color<'a, D>(deserializer: D) -> ::std::result::Result<Option<Rgb>, D::Error>
where D: de::Deserializer<'a>
{
match Option::deserialize(deserializer) {
@@ -1049,6 +1051,7 @@ impl Default for PrimaryColors {
background: Rgb { r: 0, g: 0, b: 0 },
foreground: Rgb { r: 0xea, g: 0xea, b: 0xea },
bright_foreground: None,
+ dim_foreground: None,
}
}
}
diff --git a/src/term/color.rs b/src/term/color.rs
index b84f11bd..6acd092a 100644
--- a/src/term/color.rs
+++ b/src/term/color.rs
@@ -4,7 +4,7 @@ use std::fmt;
use {Rgb, ansi};
use config::Colors;
-pub const COUNT: usize = 269;
+pub const COUNT: usize = 270;
/// List of indexed colors
///
@@ -13,7 +13,7 @@ pub const COUNT: usize = 269;
/// 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. Following that are 8 positions for dim colors.
-/// Item 268 is the bright foreground color.
+/// Item 268 is the bright foreground color, 269 the dim foreground.
#[derive(Copy, Clone)]
pub struct List([Rgb; COUNT]);
@@ -65,6 +65,10 @@ impl List {
self[ansi::NamedColor::Cursor] = colors.cursor.cursor;
// Dims
+ self[ansi::NamedColor::DimForeground] = colors
+ .primary
+ .dim_foreground
+ .unwrap_or(colors.primary.foreground * 0.66);
match colors.dim {
Some(ref dim) => {
trace!("Using config-provided dim colors");
diff --git a/src/term/mod.rs b/src/term/mod.rs
index 02d846a4..fd22fe54 100644
--- a/src/term/mod.rs
+++ b/src/term/mod.rs
@@ -275,11 +275,18 @@ impl<'a> RenderableCellsIter<'a> {
Color::Spec(rgb) => rgb,
Color::Named(ansi) => {
match (self.config.draw_bold_text_with_bright_colors(), cell.flags & Flags::DIM_BOLD) {
+ // If no bright foreground is set, treat it like the BOLD flag doesn't exist
+ (_, self::cell::Flags::DIM_BOLD)
+ if ansi == NamedColor::Foreground
+ && self.config.colors().primary.bright_foreground.is_none() =>
+ {
+ self.colors[NamedColor::DimForeground]
+ }
// Draw bold text in bright colors *and* contains bold flag.
- (true, self::cell::Flags::DIM_BOLD) |
- (true, self::cell::Flags::BOLD) => self.colors[ansi.to_bright()],
+ (true, self::cell::Flags::BOLD) => self.colors[ansi.to_bright()],
// Cell is marked as dim and not bold
- (_, self::cell::Flags::DIM) => self.colors[ansi.to_dim()],
+ (_, self::cell::Flags::DIM) |
+ (false, self::cell::Flags::DIM_BOLD) => self.colors[ansi.to_dim()],
// None of the above, keep original color.
_ => self.colors[ansi]
}