Load themes from settings and rework Settings trait

This commit is contained in:
Marshall Bowers 2023-10-25 20:37:55 +02:00
parent 98e2490807
commit e67048ee7b
19 changed files with 114 additions and 86 deletions

View file

@ -5,9 +5,19 @@ mod themes;
pub use registry::*;
pub use settings::*;
use gpui2::{HighlightStyle, Hsla, SharedString};
use gpui2::{AppContext, HighlightStyle, Hsla, SharedString};
use settings2::Settings;
use std::sync::Arc;
pub fn init(cx: &mut AppContext) {
cx.set_global(ThemeRegistry::default());
ThemeSettings::register(cx);
}
pub fn active_theme<'a>(cx: &'a AppContext) -> &'a Arc<Theme> {
&ThemeSettings::get_global(cx).active_theme
}
pub struct Theme {
pub metadata: ThemeMetadata,
@ -102,14 +112,3 @@ pub struct ThemeMetadata {
pub struct Editor {
pub syntax: Arc<SyntaxTheme>,
}
// #[derive(Default)]
// pub struct SyntaxTheme {
// pub highlights: Vec<(String, HighlightStyle)>,
// }
// impl SyntaxTheme {
// pub fn new(highlights: Vec<(String, HighlightStyle)>) -> Self {
// Self { highlights }
// }
// }