Allow imported themes to refine StatusColors
Co-Authored-By: Marshall Bowers <1486634+maxdeviant@users.noreply.github.com>
This commit is contained in:
parent
7253160b04
commit
4b5ca3e420
16 changed files with 475 additions and 56 deletions
|
@ -159,7 +159,7 @@ fn main() -> Result<()> {
|
|||
use gpui::rgba;
|
||||
|
||||
use crate::{{
|
||||
Appearance, ThemeColorsRefinement, UserTheme, UserThemeFamily, UserThemeStylesRefinement,
|
||||
Appearance, ThemeColorsRefinement, StatusColorsRefinement, UserTheme, UserThemeFamily, UserThemeStylesRefinement,
|
||||
}};
|
||||
|
||||
pub fn {theme_family_slug}() -> UserThemeFamily {{
|
||||
|
|
|
@ -2,8 +2,8 @@ use std::fmt::{self, Debug};
|
|||
|
||||
use gpui::{Hsla, Rgba};
|
||||
use theme::{
|
||||
Appearance, PlayerColor, PlayerColors, StatusColors, SyntaxTheme, SystemColors,
|
||||
ThemeColorsRefinement, UserTheme, UserThemeFamily, UserThemeStylesRefinement,
|
||||
Appearance, PlayerColor, PlayerColors, StatusColors, StatusColorsRefinement, SyntaxTheme,
|
||||
SystemColors, ThemeColorsRefinement, UserTheme, UserThemeFamily, UserThemeStylesRefinement,
|
||||
};
|
||||
|
||||
struct RawSyntaxPrinter<'a>(&'a str);
|
||||
|
@ -92,6 +92,7 @@ impl<'a> Debug for UserThemeStylesRefinementPrinter<'a> {
|
|||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("UserThemeStylesRefinement")
|
||||
.field("colors", &ThemeColorsRefinementPrinter(&self.0.colors))
|
||||
.field("status", &StatusColorsRefinementPrinter(&self.0.status))
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
@ -250,23 +251,39 @@ impl<'a> Debug for ThemeColorsRefinementPrinter<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct StatusColorsPrinter<'a>(&'a StatusColors);
|
||||
pub struct StatusColorsRefinementPrinter<'a>(&'a StatusColorsRefinement);
|
||||
|
||||
impl<'a> Debug for StatusColorsPrinter<'a> {
|
||||
impl<'a> Debug for StatusColorsRefinementPrinter<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("StatusColors")
|
||||
.field("conflict", &HslaPrinter(self.0.conflict))
|
||||
.field("created", &HslaPrinter(self.0.created))
|
||||
.field("deleted", &HslaPrinter(self.0.deleted))
|
||||
.field("error", &HslaPrinter(self.0.error))
|
||||
.field("hidden", &HslaPrinter(self.0.hidden))
|
||||
.field("ignored", &HslaPrinter(self.0.ignored))
|
||||
.field("info", &HslaPrinter(self.0.info))
|
||||
.field("modified", &HslaPrinter(self.0.modified))
|
||||
.field("renamed", &HslaPrinter(self.0.renamed))
|
||||
.field("success", &HslaPrinter(self.0.success))
|
||||
.field("warning", &HslaPrinter(self.0.warning))
|
||||
.finish()
|
||||
let status_colors = vec![
|
||||
("conflict", self.0.conflict),
|
||||
("created", self.0.created),
|
||||
("deleted", self.0.deleted),
|
||||
("error", self.0.error),
|
||||
("hidden", self.0.hidden),
|
||||
("ignored", self.0.ignored),
|
||||
("info", self.0.info),
|
||||
("modified", self.0.modified),
|
||||
("renamed", self.0.renamed),
|
||||
("success", self.0.success),
|
||||
("warning", self.0.warning),
|
||||
];
|
||||
|
||||
f.write_str("StatusColorsRefinement {")?;
|
||||
|
||||
for (color_name, color) in status_colors {
|
||||
if let Some(color) = color {
|
||||
f.write_str(color_name)?;
|
||||
f.write_str(": ")?;
|
||||
f.write_str("Some(")?;
|
||||
HslaPrinter(color).fmt(f)?;
|
||||
f.write_str(")")?;
|
||||
f.write_str(",")?;
|
||||
}
|
||||
}
|
||||
|
||||
f.write_str("..Default::default()")?;
|
||||
f.write_str("}")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use anyhow::Result;
|
||||
use gpui::{Hsla, Rgba};
|
||||
use serde::Deserialize;
|
||||
use theme::{ThemeColorsRefinement, UserTheme, UserThemeStylesRefinement};
|
||||
use theme::{StatusColorsRefinement, ThemeColorsRefinement, UserTheme, UserThemeStylesRefinement};
|
||||
|
||||
use crate::util::Traverse;
|
||||
use crate::ThemeMetadata;
|
||||
|
@ -435,6 +435,33 @@ impl VsCodeThemeConverter {
|
|||
|
||||
let vscode_colors = &self.theme.colors;
|
||||
|
||||
let status_color_refinements = StatusColorsRefinement {
|
||||
// conflict: None,
|
||||
// created: None,
|
||||
deleted: vscode_colors
|
||||
.error_foreground
|
||||
.as_ref()
|
||||
.traverse(|color| try_parse_color(&color))?,
|
||||
error: vscode_colors
|
||||
.error_foreground
|
||||
.as_ref()
|
||||
.traverse(|color| try_parse_color(&color))?,
|
||||
hidden: vscode_colors
|
||||
.tab_inactive_foreground
|
||||
.as_ref()
|
||||
.traverse(|color| try_parse_color(&color))?,
|
||||
// ignored: None,
|
||||
// info: None,
|
||||
// modified: None,
|
||||
// renamed: None,
|
||||
// success: None,
|
||||
warning: vscode_colors
|
||||
.list_warning_foreground
|
||||
.as_ref()
|
||||
.traverse(|color| try_parse_color(&color))?,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let theme_colors_refinements = ThemeColorsRefinement {
|
||||
border: vscode_colors
|
||||
.panel_border
|
||||
|
@ -596,6 +623,7 @@ impl VsCodeThemeConverter {
|
|||
appearance,
|
||||
styles: UserThemeStylesRefinement {
|
||||
colors: theme_colors_refinements,
|
||||
status: status_color_refinements,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue