diff options
author | Christian Dürr <contact@christianduerr.com> | 2018-02-07 10:05:22 +0100 |
---|---|---|
committer | Christian Dürr <contact@christianduerr.com> | 2018-02-07 10:05:22 +0100 |
commit | c0b7dced404266ef824f95fe065a1c357cbb68cf (patch) | |
tree | d3fee6583d0f70e131ab3ca159cc908a968c1425 | |
parent | 8b1f988da37a28c2bd7143049a52f64caeabe559 (diff) | |
parent | 574e449b917a3689f8377f2d149bd4481f0754a4 (diff) | |
download | alacritty-c0b7dced404266ef824f95fe065a1c357cbb68cf.tar.gz alacritty-c0b7dced404266ef824f95fe065a1c357cbb68cf.zip |
Merge branch 'master' of https://github.com/chrisduerr/alacritty into cursor-config
-rw-r--r-- | alacritty.yml | 1 | ||||
-rw-r--r-- | alacritty_macos.yml | 1 | ||||
-rw-r--r-- | src/ansi.rs | 3 | ||||
-rw-r--r-- | src/config.rs | 19 | ||||
-rw-r--r-- | src/term/color.rs | 7 |
5 files changed, 30 insertions, 1 deletions
diff --git a/alacritty.yml b/alacritty.yml index c87b7ce9..2858295c 100644 --- a/alacritty.yml +++ b/alacritty.yml @@ -107,6 +107,7 @@ colors: primary: background: '0x000000' foreground: '0xeaeaea' + bright_foreground: '0xeaeaea' # Colors the cursor will use if `custom_cursor_colors` is true cursor: diff --git a/alacritty_macos.yml b/alacritty_macos.yml index b5e54d2a..99ca4c94 100644 --- a/alacritty_macos.yml +++ b/alacritty_macos.yml @@ -87,6 +87,7 @@ colors: primary: background: '0x000000' foreground: '0xeaeaea' + bright_foreground: '0xeaeaea' # Colors the cursor will use if `custom_cursor_colors` is true cursor: diff --git a/src/ansi.rs b/src/ansi.rs index 3bcfff88..c63d334e 100644 --- a/src/ansi.rs +++ b/src/ansi.rs @@ -558,11 +558,14 @@ pub enum NamedColor { DimCyan, /// Dim white DimWhite, + /// The bright foreground color + BrightForeground, } impl NamedColor { pub fn to_bright(&self) -> Self { match *self { + NamedColor::Foreground => NamedColor::BrightForeground, NamedColor::Black => NamedColor::BrightBlack, NamedColor::Red => NamedColor::BrightRed, NamedColor::Green => NamedColor::BrightGreen, diff --git a/src/config.rs b/src/config.rs index 4295c2ce..68be2a6d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -969,6 +969,24 @@ pub struct PrimaryColors { pub background: Rgb, #[serde(deserialize_with = "rgb_from_hex")] pub foreground: Rgb, + #[serde(default, deserialize_with = "deserialize_bright_foreground")] + pub bright_foreground: Option<Rgb>, +} + +fn deserialize_bright_foreground<'a, D>(deserializer: D) -> ::std::result::Result<Option<Rgb>, D::Error> + where D: de::Deserializer<'a> +{ + match Option::deserialize(deserializer) { + Ok(Some(color)) => { + let color: serde_yaml::Value = color; + Ok(Some(rgb_from_hex(color).unwrap())) + }, + Ok(None) => Ok(None), + Err(err) => { + eprintln!("problem with config: {}; Using standard foreground color", err); + Ok(None) + }, + } } impl Default for PrimaryColors { @@ -976,6 +994,7 @@ impl Default for PrimaryColors { PrimaryColors { background: Rgb { r: 0, g: 0, b: 0 }, foreground: Rgb { r: 0xea, g: 0xea, b: 0xea }, + bright_foreground: None, } } } diff --git a/src/term/color.rs b/src/term/color.rs index d25f2f3d..b84f11bd 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 = 268; +pub const COUNT: usize = 269; /// List of indexed colors /// @@ -13,6 +13,7 @@ pub const COUNT: usize = 268; /// 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. #[derive(Copy, Clone)] pub struct List([Rgb; COUNT]); @@ -50,6 +51,10 @@ impl List { self[ansi::NamedColor::BrightMagenta] = colors.bright.magenta; self[ansi::NamedColor::BrightCyan] = colors.bright.cyan; self[ansi::NamedColor::BrightWhite] = colors.bright.white; + self[ansi::NamedColor::BrightForeground] = colors + .primary + .bright_foreground + .unwrap_or(colors.primary.foreground); // Foreground and background self[ansi::NamedColor::Foreground] = colors.primary.foreground; |