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. This fixes #825.
This commit is contained in:
parent
4ae2bc66f2
commit
96b3d737a8
|
@ -117,6 +117,7 @@ colors:
|
|||
primary:
|
||||
background: '0x000000'
|
||||
foreground: '0xeaeaea'
|
||||
bright_foreground: '0xeaeaea'
|
||||
|
||||
# Colors the cursor will use if `custom_cursor_colors` is true
|
||||
cursor:
|
||||
|
|
|
@ -95,6 +95,7 @@ colors:
|
|||
primary:
|
||||
background: '0x000000'
|
||||
foreground: '0xeaeaea'
|
||||
bright_foreground: '0xeaeaea'
|
||||
|
||||
# Colors the cursor will use if `custom_cursor_colors` is true
|
||||
cursor:
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -1022,6 +1022,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 {
|
||||
|
@ -1029,6 +1047,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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue