aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2018-01-14 00:17:36 +0100
committerChristian Duerr <contact@christianduerr.com>2018-01-22 01:24:17 +0100
commit72b4468aac34b0108ee7aebfe170c62dd25ac620 (patch)
treea8a6fe89ab6341a4b7aca9932cda31512aaf647e
parentca05bc700eb237a503125f784def834dbf015c96 (diff)
downloadalacritty-72b4468aac34b0108ee7aebfe170c62dd25ac620.tar.gz
alacritty-72b4468aac34b0108ee7aebfe170c62dd25ac620.zip
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.
-rw-r--r--alacritty.yml1
-rw-r--r--alacritty_macos.yml1
-rw-r--r--src/ansi.rs3
-rw-r--r--src/config.rs19
-rw-r--r--src/term/color.rs6
5 files changed, 29 insertions, 1 deletions
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<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 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;