diff options
author | Pascal Kuthe | 2022-10-13 17:03:58 +0000 |
---|---|---|
committer | Pascal Kuthe | 2022-10-13 17:03:58 +0000 |
commit | 66a49080bc7e492c37f9cd10ed36a696de1787a3 (patch) | |
tree | e15fd2359a2dfab095af6b908168382471f24c6d /helix-view | |
parent | 963a0ac0bbc43e2b26a9662bc67dd226582ad12a (diff) |
merge underline-style and underline-color into a single table
Diffstat (limited to 'helix-view')
-rw-r--r-- | helix-view/src/theme.rs | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/helix-view/src/theme.rs b/helix-view/src/theme.rs index c32b3edf..aaef28b2 100644 --- a/helix-view/src/theme.rs +++ b/helix-view/src/theme.rs @@ -268,18 +268,29 @@ impl ThemePalette { value .as_str() .and_then(|s| s.parse().ok()) - .ok_or(format!("Theme: invalid underline-style: {}", value)) + .ok_or(format!("Theme: invalid underline style: {}", value)) } pub fn parse_style(&self, style: &mut Style, value: Value) -> Result<(), String> { if let Value::Table(entries) = value { - for (name, value) in entries { + for (name, mut value) in entries { match name.as_str() { "fg" => *style = style.fg(self.parse_color(value)?), "bg" => *style = style.bg(self.parse_color(value)?), - "underline-color" => *style = style.underline_color(self.parse_color(value)?), - "underline-style" => { - *style = style.underline_style(Self::parse_underline_style(&value)?) + "underline" => { + let table = value + .as_table_mut() + .ok_or("Theme: underline must be table")?; + if let Some(value) = table.remove("color") { + *style = style.underline_color(self.parse_color(value)?); + } + if let Some(value) = table.remove("style") { + *style = style.underline_style(Self::parse_underline_style(&value)?); + } + + if let Some(attr) = table.keys().next() { + return Err(format!("Theme: invalid underline attribute: {attr}")); + } } "modifiers" => { let modifiers = value |