Represent theme's syntax colors with string keys
Co-authored-by: Marshall Bowers <marshall@zed.dev>
This commit is contained in:
parent
a569c82492
commit
0eae962abf
10 changed files with 156 additions and 132 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue