COSMIC Light theme update and built-in theme cleanup
This commit is contained in:
parent
94f71faa1d
commit
ee6d546dc5
3 changed files with 65 additions and 159 deletions
|
|
@ -3,7 +3,7 @@
|
|||
foreground: "#C4C4C4",
|
||||
cursor: "#C4C4C4",
|
||||
bright_foreground: "#C4C4C4",
|
||||
dim_foreground: "#8E8E8E",
|
||||
dim_foreground: "#898989",
|
||||
normal: (
|
||||
black: "#1B1B1B",
|
||||
red: "#F16161",
|
||||
|
|
|
|||
|
|
@ -1,37 +1,37 @@
|
|||
(
|
||||
name: "COSMIC Light",
|
||||
foreground: "#292929",
|
||||
cursor: "#292929",
|
||||
bright_foreground: "#808080",
|
||||
dim_foreground: "#181818",
|
||||
foreground: "#1B1B1B",
|
||||
cursor: "#1B1B1B",
|
||||
bright_foreground: "#000000",
|
||||
dim_foreground: "#262626",
|
||||
normal: (
|
||||
black: "#292929",
|
||||
red: "#8C151F",
|
||||
green: "#145129",
|
||||
yellow: "#624000",
|
||||
blue: "#003F5F",
|
||||
magenta: "#6D169C",
|
||||
cyan: "#004F57",
|
||||
white: "#BEBEBE",
|
||||
black: "#1B1B1B",
|
||||
red: "#A24F50",
|
||||
green: "#437E4F",
|
||||
yellow: "#7D6E1E",
|
||||
blue: "#516D94",
|
||||
magenta: "#9A30CA",
|
||||
cyan: "#227A85",
|
||||
white: "#C4C4C4",
|
||||
),
|
||||
bright: (
|
||||
black: "#808080",
|
||||
red: "#9D2329",
|
||||
green: "#235D34",
|
||||
yellow: "#714B00",
|
||||
blue: "#054B6F",
|
||||
magenta: "#7A28A9",
|
||||
cyan: "#005C5D",
|
||||
white: "#D7D7D7",
|
||||
black: "#000000",
|
||||
red: "#890418",
|
||||
green: "#185529",
|
||||
yellow: "#534800",
|
||||
blue: "#2E496D",
|
||||
magenta: "#6B0091",
|
||||
cyan: "#00525A",
|
||||
white: "#E8E8E8",
|
||||
),
|
||||
dim: (
|
||||
black: "#181818",
|
||||
red: "#652020",
|
||||
green: "#183C22",
|
||||
yellow: "#4A320A",
|
||||
blue: "#072D44",
|
||||
magenta: "#50256D",
|
||||
cyan: "#0B3C41",
|
||||
white: "#ABABAB",
|
||||
black: "#262626",
|
||||
red: "#B25D5E",
|
||||
green: "#528D5E",
|
||||
yellow: "#8C7D30",
|
||||
blue: "#5F7CA4",
|
||||
magenta: "#AA43DB",
|
||||
cyan: "#358994",
|
||||
white: "#C4C4C4",
|
||||
),
|
||||
)
|
||||
|
|
@ -10,108 +10,6 @@ use crate::config::{
|
|||
COSMIC_THEME_DARK, COSMIC_THEME_LIGHT, ColorScheme, ColorSchemeAnsi, ColorSchemeKind,
|
||||
};
|
||||
|
||||
// Fill missing dim/bright colors with derived values from normal ones.
|
||||
#[allow(dead_code)]
|
||||
struct ColorDerive {
|
||||
dim_saturation_adjustment: f32,
|
||||
dim_lightness_adjustment: f32,
|
||||
bright_saturation_adjustment: f32,
|
||||
bright_lightness_adjustment: f32,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl ColorDerive {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
// The dim flag/escape code is also sometimes described as faint.
|
||||
// So we reduce lightness and saturation to get both effects.
|
||||
dim_saturation_adjustment: -0.2,
|
||||
dim_lightness_adjustment: -0.2,
|
||||
// Normal colors are usually saturated enough. So we default this to 0.0
|
||||
// to avoid pushing colors towards white.
|
||||
bright_saturation_adjustment: 0.0,
|
||||
bright_lightness_adjustment: 0.10,
|
||||
}
|
||||
}
|
||||
|
||||
fn with_dim_lightness_adjustment(self, dim_lightness_adjustment: f32) -> Self {
|
||||
Self {
|
||||
dim_lightness_adjustment,
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
fn rgb_to_okhsl(c: Rgb) -> Okhsl {
|
||||
let p_rgb = PRgb::<Srgb, u8>::new(c.r, c.g, c.b).into_format::<f32>();
|
||||
Okhsl::from_color(p_rgb)
|
||||
}
|
||||
|
||||
fn okhsl_to_rgb(c: Okhsl) -> Rgb {
|
||||
let p_rgb = PRgb::<Srgb, _>::from_color(c).into_format::<u8>();
|
||||
let (r, g, b) = p_rgb.into_components();
|
||||
Rgb { r, g, b }
|
||||
}
|
||||
|
||||
fn color_adj(rgb: Rgb, saturation_adj: f32, lightness_adj: f32) -> Rgb {
|
||||
let mut okhsl = Self::rgb_to_okhsl(rgb);
|
||||
|
||||
okhsl.saturation = (okhsl.saturation + saturation_adj).clamp(0.0, 1.0);
|
||||
okhsl.lightness = (okhsl.lightness + lightness_adj).clamp(0.0, 1.0);
|
||||
|
||||
Self::okhsl_to_rgb(okhsl)
|
||||
}
|
||||
|
||||
fn brighten(&self, rgb: Rgb) -> Rgb {
|
||||
let saturation_adj = self.bright_saturation_adjustment;
|
||||
let lightness_adj = self.bright_lightness_adjustment;
|
||||
Self::color_adj(rgb, saturation_adj, lightness_adj)
|
||||
}
|
||||
|
||||
fn dim_and_faint(&self, rgb: Rgb) -> Rgb {
|
||||
let saturation_adj = self.dim_saturation_adjustment;
|
||||
let lightness_adj = self.dim_lightness_adjustment;
|
||||
Self::color_adj(rgb, saturation_adj, lightness_adj)
|
||||
}
|
||||
|
||||
fn fill_missing_brights(&self, colors: &mut Colors) {
|
||||
macro_rules! populate {
|
||||
($($normal:ident$(,)?)+) => {
|
||||
paste::paste!{
|
||||
$(
|
||||
if colors[NamedColor::[<Bright $normal>]].is_none() {
|
||||
match colors[NamedColor::$normal] {
|
||||
None => panic!("tried to derive bright color from {} which is not set", stringify!($normal)),
|
||||
Some(rgb) => colors[NamedColor::[<Bright $normal>]] = Some(self.brighten(rgb)),
|
||||
}
|
||||
}
|
||||
)+
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
populate! { Foreground, Black, Red, Green, Yellow, Blue, Magenta, Cyan, White };
|
||||
}
|
||||
|
||||
fn fill_missing_dims(&self, colors: &mut Colors) {
|
||||
macro_rules! populate {
|
||||
($($normal:ident$(,)?)+) => {
|
||||
paste::paste!{
|
||||
$(
|
||||
if colors[NamedColor::[<Dim $normal>]].is_none() {
|
||||
match colors[NamedColor::$normal] {
|
||||
None => panic!("tried to derive dim color from {} which is not set", stringify!($normal)),
|
||||
Some(rgb) => colors[NamedColor::[<Dim $normal>]] = Some(self.dim_and_faint(rgb)),
|
||||
}
|
||||
}
|
||||
)+
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
populate! { Foreground, Black, Red, Green, Yellow, Blue, Magenta, Cyan, White };
|
||||
}
|
||||
}
|
||||
|
||||
fn auto_colors() -> Colors {
|
||||
let mut colors = Colors::default();
|
||||
|
||||
|
|
@ -277,14 +175,21 @@ pub fn cosmic_dark() -> Colors {
|
|||
colors[NamedColor::BrightCyan] = Some(encode_rgb(0x49BAC8));
|
||||
colors[NamedColor::BrightWhite] = Some(encode_rgb(0xC4C4C4));
|
||||
|
||||
colors[NamedColor::DimBlack] = Some(encode_rgb(0x000000));
|
||||
colors[NamedColor::DimRed] = Some(encode_rgb(0xA04040));
|
||||
colors[NamedColor::DimGreen] = Some(encode_rgb(0x5D7D62));
|
||||
colors[NamedColor::DimYellow] = Some(encode_rgb(0x9E914A));
|
||||
colors[NamedColor::DimBlue] = Some(encode_rgb(0x486073));
|
||||
colors[NamedColor::DimMagenta] = Some(encode_rgb(0x7F46A1));
|
||||
colors[NamedColor::DimCyan] = Some(encode_rgb(0x3F7F87));
|
||||
colors[NamedColor::DimWhite] = Some(encode_rgb(0x898989));
|
||||
|
||||
// Set special colors
|
||||
colors[NamedColor::Foreground] = colors[NamedColor::BrightWhite];
|
||||
// Background comes from theme settings: colors[NamedColor::Background] = colors[NamedColor::Black];
|
||||
colors[NamedColor::Cursor] = colors[NamedColor::BrightWhite];
|
||||
colors[NamedColor::BrightForeground] = colors[NamedColor::BrightWhite];
|
||||
|
||||
// Fill missing dim colors
|
||||
ColorDerive::new().fill_missing_dims(&mut colors);
|
||||
colors[NamedColor::DimForeground] = colors[NamedColor::DimWhite];
|
||||
|
||||
colors
|
||||
}
|
||||
|
|
@ -300,38 +205,39 @@ pub fn cosmic_light() -> Colors {
|
|||
}
|
||||
};
|
||||
|
||||
colors[NamedColor::Black] = Some(encode_rgb(0x292929));
|
||||
colors[NamedColor::Red] = Some(encode_rgb(0x8C151F));
|
||||
colors[NamedColor::Green] = Some(encode_rgb(0x145129));
|
||||
colors[NamedColor::Yellow] = Some(encode_rgb(0x624000));
|
||||
colors[NamedColor::Blue] = Some(encode_rgb(0x003F5F));
|
||||
colors[NamedColor::Magenta] = Some(encode_rgb(0x6D169C));
|
||||
colors[NamedColor::Cyan] = Some(encode_rgb(0x004F57));
|
||||
colors[NamedColor::White] = Some(encode_rgb(0xBEBEBE));
|
||||
colors[NamedColor::Black] = Some(encode_rgb(0x1B1B1B));
|
||||
colors[NamedColor::Red] = Some(encode_rgb(0xA24F50));
|
||||
colors[NamedColor::Green] = Some(encode_rgb(0x437E4F));
|
||||
colors[NamedColor::Yellow] = Some(encode_rgb(0x7D6E1E));
|
||||
colors[NamedColor::Blue] = Some(encode_rgb(0x516D94));
|
||||
colors[NamedColor::Magenta] = Some(encode_rgb(0x9A30CA));
|
||||
colors[NamedColor::Cyan] = Some(encode_rgb(0x227A85));
|
||||
colors[NamedColor::White] = Some(encode_rgb(0xC4C4C4));
|
||||
|
||||
colors[NamedColor::BrightBlack] = Some(encode_rgb(0x808080));
|
||||
colors[NamedColor::BrightRed] = Some(encode_rgb(0x9D2329));
|
||||
colors[NamedColor::BrightGreen] = Some(encode_rgb(0x235D34));
|
||||
colors[NamedColor::BrightYellow] = Some(encode_rgb(0x714B00));
|
||||
colors[NamedColor::BrightBlue] = Some(encode_rgb(0x054B6F));
|
||||
colors[NamedColor::BrightMagenta] = Some(encode_rgb(0x7A28A9));
|
||||
colors[NamedColor::BrightCyan] = Some(encode_rgb(0x005C5D));
|
||||
colors[NamedColor::BrightWhite] = Some(encode_rgb(0xD7D7D7));
|
||||
colors[NamedColor::BrightBlack] = Some(encode_rgb(0x000000));
|
||||
colors[NamedColor::BrightRed] = Some(encode_rgb(0x890418));
|
||||
colors[NamedColor::BrightGreen] = Some(encode_rgb(0x185529));
|
||||
colors[NamedColor::BrightYellow] = Some(encode_rgb(0x534800));
|
||||
colors[NamedColor::BrightBlue] = Some(encode_rgb(0x2E496D));
|
||||
colors[NamedColor::BrightMagenta] = Some(encode_rgb(0x6B0091));
|
||||
colors[NamedColor::BrightCyan] = Some(encode_rgb(0x00525A));
|
||||
colors[NamedColor::BrightWhite] = Some(encode_rgb(0xE8E8E8));
|
||||
|
||||
colors[NamedColor::DimBlack] = Some(encode_rgb(0x262626));
|
||||
colors[NamedColor::DimRed] = Some(encode_rgb(0xB25D5E));
|
||||
colors[NamedColor::DimGreen] = Some(encode_rgb(0x528D5E));
|
||||
colors[NamedColor::DimYellow] = Some(encode_rgb(0x8C7D30));
|
||||
colors[NamedColor::DimBlue] = Some(encode_rgb(0x5F7CA4));
|
||||
colors[NamedColor::DimMagenta] = Some(encode_rgb(0xAA43DB));
|
||||
colors[NamedColor::DimCyan] = Some(encode_rgb(0x358994));
|
||||
colors[NamedColor::DimWhite] = Some(encode_rgb(0xC4C4C4));
|
||||
|
||||
// Set special colors
|
||||
colors[NamedColor::Foreground] = colors[NamedColor::Black];
|
||||
// Background comes from theme settings: colors[NamedColor::Background] = colors[NamedColor::BrightWhite];
|
||||
colors[NamedColor::Cursor] = colors[NamedColor::Black];
|
||||
colors[NamedColor::BrightForeground] = colors[NamedColor::BrightBlack];
|
||||
|
||||
// Fill missing dim colors
|
||||
ColorDerive::new()
|
||||
// With light backgrounds, the dim and faint descriptions are at odds!
|
||||
// To make the color fainter, we would need to increase lightness not decrease it!
|
||||
// But other terminals seem to still dim colors in light themes. So we dim too, but
|
||||
// not by much, since normal colors are dim enough already.
|
||||
.with_dim_lightness_adjustment(-0.07)
|
||||
.fill_missing_dims(&mut colors);
|
||||
colors[NamedColor::DimForeground] = colors[NamedColor::DimBlack];
|
||||
|
||||
colors
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue