From c704c168cd14896aa0181a77971561931d4b17c7 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Tue, 9 Jan 2018 00:49:18 +0100 Subject: [PATCH 1/7] Expand key binding config documentation A link to all variants available as `key` has been added at the top of the key bindings documentation, to help users with finding the right place for mapping key codes. --- alacritty.yml | 3 +++ alacritty_macos.yml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/alacritty.yml b/alacritty.yml index 90a27254..4627e0a9 100644 --- a/alacritty.yml +++ b/alacritty.yml @@ -246,6 +246,9 @@ live_config_reload: true # Key bindings # +# A list with all available `key` names can be found here: +# https://docs.rs/glutin/0.12.0/glutin/enum.VirtualKeyCode.html#variants +# # Each binding is defined as an object with some properties. Most of the # properties are optional. All of the alphabetical keys should have a letter for # the `key` value such as `V`. Function keys are probably what you would expect diff --git a/alacritty_macos.yml b/alacritty_macos.yml index 7593cabe..9391b73d 100644 --- a/alacritty_macos.yml +++ b/alacritty_macos.yml @@ -227,6 +227,9 @@ live_config_reload: true # Key bindings # +# A list with all available `key` names can be found here: +# https://docs.rs/glutin/0.12.0/glutin/enum.VirtualKeyCode.html#variants +# # Each binding is defined as an object with some properties. Most of the # properties are optional. All of the alphabetical keys should have a letter for # the `key` value such as `V`. Function keys are probably what you would expect From ca05bc700eb237a503125f784def834dbf015c96 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Tue, 9 Jan 2018 01:33:24 +0100 Subject: [PATCH 2/7] Move link below the `key` block --- alacritty.yml | 3 --- alacritty_macos.yml | 3 --- 2 files changed, 6 deletions(-) diff --git a/alacritty.yml b/alacritty.yml index 4627e0a9..90a27254 100644 --- a/alacritty.yml +++ b/alacritty.yml @@ -246,9 +246,6 @@ live_config_reload: true # Key bindings # -# A list with all available `key` names can be found here: -# https://docs.rs/glutin/0.12.0/glutin/enum.VirtualKeyCode.html#variants -# # Each binding is defined as an object with some properties. Most of the # properties are optional. All of the alphabetical keys should have a letter for # the `key` value such as `V`. Function keys are probably what you would expect diff --git a/alacritty_macos.yml b/alacritty_macos.yml index 9391b73d..7593cabe 100644 --- a/alacritty_macos.yml +++ b/alacritty_macos.yml @@ -227,9 +227,6 @@ live_config_reload: true # Key bindings # -# A list with all available `key` names can be found here: -# https://docs.rs/glutin/0.12.0/glutin/enum.VirtualKeyCode.html#variants -# # Each binding is defined as an object with some properties. Most of the # properties are optional. All of the alphabetical keys should have a letter for # the `key` value such as `V`. Function keys are probably what you would expect From 72b4468aac34b0108ee7aebfe170c62dd25ac620 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sun, 14 Jan 2018 00:17:36 +0100 Subject: [PATCH 3/7] Add bright foreground color option It was requested in jwilm/alacritty#825 that it should be possible to add an optional bright foreground color. This is now added to the primary colors structure and allows the user to set a foreground color for bold normal text. This has no effect unless the `draw_bold_text_with_bright_colors` option is also enabled. If the color is not specified, the bright foreground color will fall back to the normal foreground color. --- alacritty.yml | 1 + alacritty_macos.yml | 1 + src/ansi.rs | 3 +++ src/config.rs | 19 +++++++++++++++++++ src/term/color.rs | 6 +++++- 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/alacritty.yml b/alacritty.yml index 90a27254..7a7f84ab 100644 --- a/alacritty.yml +++ b/alacritty.yml @@ -111,6 +111,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 7593cabe..449cb28d 100644 --- a/alacritty_macos.yml +++ b/alacritty_macos.yml @@ -91,6 +91,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..f6caee8b 100644 --- a/src/ansi.rs +++ b/src/ansi.rs @@ -536,6 +536,8 @@ 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 @@ -563,6 +565,7 @@ pub enum NamedColor { 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 be967150..dd00e71b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1017,6 +1017,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, +} + +fn deserialize_bright_foreground<'a, D>(deserializer: D) -> ::std::result::Result, 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 foreground color", err); + Ok(None) + }, + } } impl Default for PrimaryColors { @@ -1024,6 +1042,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..4b8ce861 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 /// @@ -50,6 +50,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; From add63a6fa84ac0d0f61dc2c056b85df84c6494a4 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Tue, 16 Jan 2018 20:07:31 +0100 Subject: [PATCH 4/7] 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`. --- alacritty.yml | 1 + alacritty_macos.yml | 1 + src/ansi.rs | 6 ++++-- src/config.rs | 9 ++++++--- 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, + #[serde(default, deserialize_with = "deserialize_bright_primary")] pub bright_foreground: Option, } -fn deserialize_bright_foreground<'a, D>(deserializer: D) -> ::std::result::Result, D::Error> +fn deserialize_bright_primary<'a, D>(deserializer: D) -> ::std::result::Result, 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; From 319f3e29bf6a2dd1da45a967eb1d3a039ff29b7d Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Tue, 16 Jan 2018 20:17:40 +0100 Subject: [PATCH 5/7] Revert addition of bold background There was no evidence for the existence of a bold background in the termite config or the escape sequence specifications, so the bold background has been removed again. The changes to the documentation have not been reverted. --- src/ansi.rs | 2 -- src/config.rs | 7 ++----- src/term/color.rs | 8 ++------ 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/ansi.rs b/src/ansi.rs index 696d0caf..c63d334e 100644 --- a/src/ansi.rs +++ b/src/ansi.rs @@ -560,8 +560,6 @@ pub enum NamedColor { DimWhite, /// The bright foreground color BrightForeground, - /// The bright background color - BrightBackground, } impl NamedColor { diff --git a/src/config.rs b/src/config.rs index 97fe7798..07a491c7 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1017,13 +1017,11 @@ pub struct PrimaryColors { pub background: Rgb, #[serde(deserialize_with = "rgb_from_hex")] pub foreground: Rgb, - #[serde(default, deserialize_with = "deserialize_bright_primary")] - pub bright_background: Option, - #[serde(default, deserialize_with = "deserialize_bright_primary")] + #[serde(default, deserialize_with = "deserialize_bright_foreground")] pub bright_foreground: Option, } -fn deserialize_bright_primary<'a, D>(deserializer: D) -> ::std::result::Result, D::Error> +fn deserialize_bright_foreground<'a, D>(deserializer: D) -> ::std::result::Result, D::Error> where D: de::Deserializer<'a> { match Option::deserialize(deserializer) { @@ -1044,7 +1042,6 @@ 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 90634f36..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 = 270; +pub const COUNT: usize = 269; /// List of indexed colors /// @@ -13,7 +13,7 @@ pub const COUNT: usize = 270; /// 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. +/// Item 268 is the bright foreground color. #[derive(Copy, Clone)] pub struct List([Rgb; COUNT]); @@ -55,10 +55,6 @@ 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; From 1ea866cc0bdbc5f530175e33378428f98b4e4b8e Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Tue, 16 Jan 2018 20:21:06 +0100 Subject: [PATCH 6/7] Remove bright background from alacritty yml --- alacritty.yml | 1 - alacritty_macos.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/alacritty.yml b/alacritty.yml index ebfca9b0..7a7f84ab 100644 --- a/alacritty.yml +++ b/alacritty.yml @@ -111,7 +111,6 @@ 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 24248f91..449cb28d 100644 --- a/alacritty_macos.yml +++ b/alacritty_macos.yml @@ -91,7 +91,6 @@ colors: primary: background: '0x000000' foreground: '0xeaeaea' - bright_background: '0x000000' bright_foreground: '0xeaeaea' # Colors the cursor will use if `custom_cursor_colors` is true From 574e449b917a3689f8377f2d149bd4481f0754a4 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Tue, 16 Jan 2018 20:22:39 +0100 Subject: [PATCH 7/7] Change bright foreground config error message --- src/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index 07a491c7..fa90fde1 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1031,7 +1031,7 @@ fn deserialize_bright_foreground<'a, D>(deserializer: D) -> ::std::result::Resul }, Ok(None) => Ok(None), Err(err) => { - eprintln!("problem with config: {}; Using non-bright color", err); + eprintln!("problem with config: {}; Using standard foreground color", err); Ok(None) }, }