diff options
author | Christian Duerr <contact@christianduerr.com> | 2018-01-16 20:07:31 +0100 |
---|---|---|
committer | Christian Duerr <contact@christianduerr.com> | 2018-01-22 01:24:48 +0100 |
commit | add63a6fa84ac0d0f61dc2c056b85df84c6494a4 (patch) | |
tree | fbb6546a11e0ce6931c3eb60bf59f00c51aba536 | |
parent | 72b4468aac34b0108ee7aebfe170c62dd25ac620 (diff) | |
download | alacritty-add63a6fa84ac0d0f61dc2c056b85df84c6494a4.tar.gz alacritty-add63a6fa84ac0d0f61dc2c056b85df84c6494a4.zip |
Add bright background color
This adds a bright background color. It is currently unclear to me how
this would be used and it is likely that it is not possible to use the
bright background color at the moment.
The bright background color behaves the same way as the bright
foreground color and falls back to the background color when not set or
`draw_bold_text_with_bright_colors` is `false`.
-rw-r--r-- | alacritty.yml | 1 | ||||
-rw-r--r-- | alacritty_macos.yml | 1 | ||||
-rw-r--r-- | src/ansi.rs | 6 | ||||
-rw-r--r-- | src/config.rs | 9 | ||||
-rw-r--r-- | src/term/color.rs | 7 |
5 files changed, 18 insertions, 6 deletions
diff --git a/alacritty.yml b/alacritty.yml index 7a7f84ab..ebfca9b0 100644 --- a/alacritty.yml +++ b/alacritty.yml @@ -111,6 +111,7 @@ colors: primary: background: '0x000000' foreground: '0xeaeaea' + bright_background: '0x000000' bright_foreground: '0xeaeaea' # Colors the cursor will use if `custom_cursor_colors` is true diff --git a/alacritty_macos.yml b/alacritty_macos.yml index 449cb28d..24248f91 100644 --- a/alacritty_macos.yml +++ b/alacritty_macos.yml @@ -91,6 +91,7 @@ colors: primary: background: '0x000000' foreground: '0xeaeaea' + bright_background: '0x000000' bright_foreground: '0xeaeaea' # Colors the cursor will use if `custom_cursor_colors` is true diff --git a/src/ansi.rs b/src/ansi.rs index f6caee8b..696d0caf 100644 --- a/src/ansi.rs +++ b/src/ansi.rs @@ -536,8 +536,6 @@ pub enum NamedColor { BrightWhite, /// The foreground color Foreground = 256, - /// The bright foreground color - BrightForeground, /// The background color Background, /// Color for the text under the cursor @@ -560,6 +558,10 @@ pub enum NamedColor { DimCyan, /// Dim white DimWhite, + /// The bright foreground color + BrightForeground, + /// The bright background color + BrightBackground, } impl NamedColor { diff --git a/src/config.rs b/src/config.rs index dd00e71b..97fe7798 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1017,11 +1017,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_bright_primary")] + pub bright_background: Option<Rgb>, + #[serde(default, deserialize_with = "deserialize_bright_primary")] pub bright_foreground: Option<Rgb>, } -fn deserialize_bright_foreground<'a, D>(deserializer: D) -> ::std::result::Result<Option<Rgb>, D::Error> +fn deserialize_bright_primary<'a, D>(deserializer: D) -> ::std::result::Result<Option<Rgb>, D::Error> where D: de::Deserializer<'a> { match Option::deserialize(deserializer) { @@ -1031,7 +1033,7 @@ fn deserialize_bright_foreground<'a, D>(deserializer: D) -> ::std::result::Resul }, Ok(None) => Ok(None), Err(err) => { - eprintln!("problem with config: {}; Using foreground color", err); + eprintln!("problem with config: {}; Using non-bright color", err); Ok(None) }, } @@ -1042,6 +1044,7 @@ impl Default for PrimaryColors { PrimaryColors { background: Rgb { r: 0, g: 0, b: 0 }, foreground: Rgb { r: 0xea, g: 0xea, b: 0xea }, + bright_background: None, bright_foreground: None, } } diff --git a/src/term/color.rs b/src/term/color.rs index 4b8ce861..90634f36 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,6 +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 and 269 is the bright background. #[derive(Copy, Clone)] pub struct List([Rgb; COUNT]); @@ -54,6 +55,10 @@ impl List { .primary .bright_foreground .unwrap_or(colors.primary.foreground); + self[ansi::NamedColor::BrightBackground] = colors + .primary + .bright_background + .unwrap_or(colors.primary.background); // Foreground and background self[ansi::NamedColor::Foreground] = colors.primary.foreground; |