diff options
author | Gokul Soumya | 2021-09-03 11:12:29 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-09-05 03:42:03 +0000 |
commit | e4e93e176ceca39a834abf7e67bf9bfaa34d886d (patch) | |
tree | bdc840e39c4ab413cc2b0fb94c33c82b972df010 /helix-view/src | |
parent | e40e6db2271b9568352b7477ed8b9f9895881cf9 (diff) |
fix: Merge default palette with user palette
Diffstat (limited to 'helix-view/src')
-rw-r--r-- | helix-view/src/theme.rs | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/helix-view/src/theme.rs b/helix-view/src/theme.rs index 9f768505..9c33685b 100644 --- a/helix-view/src/theme.rs +++ b/helix-view/src/theme.rs @@ -143,30 +143,37 @@ struct ThemePalette { impl Default for ThemePalette { fn default() -> Self { - Self::new(hashmap! { - "black".to_string() => Color::Black, - "red".to_string() => Color::Red, - "green".to_string() => Color::Green, - "yellow".to_string() => Color::Yellow, - "blue".to_string() => Color::Blue, - "magenta".to_string() => Color::Magenta, - "cyan".to_string() => Color::Cyan, - "gray".to_string() => Color::Gray, - "light-red".to_string() => Color::LightRed, - "light-green".to_string() => Color::LightGreen, - "light-yellow".to_string() => Color::LightYellow, - "light-blue".to_string() => Color::LightBlue, - "light-magenta".to_string() => Color::LightMagenta, - "light-cyan".to_string() => Color::LightCyan, - "light-gray".to_string() => Color::LightGray, - "white".to_string() => Color::White, - }) + Self { + palette: hashmap! { + "black".to_string() => Color::Black, + "red".to_string() => Color::Red, + "green".to_string() => Color::Green, + "yellow".to_string() => Color::Yellow, + "blue".to_string() => Color::Blue, + "magenta".to_string() => Color::Magenta, + "cyan".to_string() => Color::Cyan, + "gray".to_string() => Color::Gray, + "light-red".to_string() => Color::LightRed, + "light-green".to_string() => Color::LightGreen, + "light-yellow".to_string() => Color::LightYellow, + "light-blue".to_string() => Color::LightBlue, + "light-magenta".to_string() => Color::LightMagenta, + "light-cyan".to_string() => Color::LightCyan, + "light-gray".to_string() => Color::LightGray, + "white".to_string() => Color::White, + }, + } } } impl ThemePalette { pub fn new(palette: HashMap<String, Color>) -> Self { - Self { palette } + let ThemePalette { + palette: mut default, + } = ThemePalette::default(); + + default.extend(palette); + Self { palette: default } } pub fn hex_string_to_rgb(s: &str) -> Result<Color, String> { |