Properly emit UserHighlightStyles

This commit is contained in:
Marshall Bowers 2023-11-09 12:59:20 -05:00
parent ff19a0ca18
commit 34e31fd489
13 changed files with 786 additions and 130 deletions

View file

@ -160,7 +160,8 @@ fn main() -> Result<()> {
use gpui::rgba;
use crate::{{
Appearance, ThemeColorsRefinement, StatusColorsRefinement, UserTheme, UserThemeFamily, UserThemeStylesRefinement,
Appearance, StatusColorsRefinement, ThemeColorsRefinement, UserHighlightStyle, UserSyntaxTheme,
UserTheme, UserThemeFamily, UserThemeStylesRefinement,
}};
pub fn {theme_family_slug}() -> UserThemeFamily {{

View file

@ -3,7 +3,8 @@ use std::fmt::{self, Debug};
use gpui::{Hsla, Rgba};
use theme::{
Appearance, PlayerColor, PlayerColors, StatusColorsRefinement, SystemColors,
ThemeColorsRefinement, UserSyntaxTheme, UserTheme, UserThemeFamily, UserThemeStylesRefinement,
ThemeColorsRefinement, UserHighlightStyle, UserSyntaxTheme, UserTheme, UserThemeFamily,
UserThemeStylesRefinement,
};
struct RawSyntaxPrinter<'a>(&'a str);
@ -350,7 +351,7 @@ impl<'a> Debug for UserSyntaxThemePrinter<'a> {
.highlights
.iter()
.map(|(token, highlight)| {
(IntoPrinter(token), HslaPrinter(highlight.color.unwrap()))
(IntoPrinter(token), UserHighlightStylePrinter(&highlight))
})
.collect(),
),
@ -358,3 +359,27 @@ impl<'a> Debug for UserSyntaxThemePrinter<'a> {
.finish()
}
}
pub struct UserHighlightStylePrinter<'a>(&'a UserHighlightStyle);
impl<'a> Debug for UserHighlightStylePrinter<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let fields = vec![("color", self.0.color)];
f.write_str("UserHighlightStyle {")?;
for (field_name, value) in fields {
if let Some(color) = value {
f.write_str(field_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("}")
}
}