Represent theme's syntax colors with string keys
Co-authored-by: Marshall Bowers <marshall@zed.dev>
This commit is contained in:
co-authored by
Marshall Bowers
parent
a569c82492
commit
0eae962abf
@@ -90,13 +90,22 @@ pub struct Theme {
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SyntaxTheme {
|
||||
pub comment: Hsla,
|
||||
pub string: Hsla,
|
||||
pub function: Hsla,
|
||||
pub keyword: Hsla,
|
||||
pub highlights: Vec<(String, HighlightStyle)>,
|
||||
}
|
||||
|
||||
impl SyntaxTheme {
|
||||
pub fn get(&self, name: &str) -> HighlightStyle {
|
||||
self.highlights
|
||||
.iter()
|
||||
.find_map(|entry| if entry.0 == name { Some(entry.1) } else { None })
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn color(&self, name: &str) -> Hsla {
|
||||
self.get(name).color.unwrap_or_default()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct PlayerTheme {
|
||||
pub cursor: Hsla,
|
||||
|
||||
Reference in New Issue
Block a user