on master help sign in
merge underline-style and underline-color into a single table
commit66a49080bc7e492c37f9cd10ed36a696de1787a3 authorPascal Kuthe <pascal.kuthe@semimod.de> dateThu 13 Oct 2022, 19:03 (4 years ago) parent963a0ac
4 files changed+27−16
book/src/themes.md+5−5 helix-view/src/theme.rs+16−5 runtime/themes/dark_plus.toml+2−2 runtime/themes/onedark.toml+4−4
book/src/themes.md+5−5
@@ -13,10 +13,10 @@ The default theme.toml can be found [here](https://github.com/helix-editor/helix
1313Each line in the theme file is specified as below:
1414
1515```toml
16−key = { fg = "#ffffff", bg = "#000000", underline-color = "#ff0000", underline-style = "curl", modifiers = ["bold", "italic"] }
16+key = { fg = "#ffffff", bg = "#000000", underline = { color = "#ff0000", style = "curl"}, modifiers = ["bold", "italic"] }
1717```
1818
19−where `key` represents what you want to style, `fg` specifies the foreground color, `bg` the background color, `underline-style` the underline style, `underline-color` the underline color (only meaningful if an underline style is enabled), and `modifiers` is a list of style modifiers. `bg`, `underline` and `modifiers` can be omitted to defer to the defaults.
19+where `key` represents what you want to style, `fg` specifies the foreground color, `bg` the background color, `underline` the underline `style`/`color`, and `modifiers` is a list of style modifiers. `bg`, `underline` and `modifiers` can be omitted to defer to the defaults.
2020
2121To specify only the foreground color:
2222
@@ -89,12 +89,12 @@ Less common modifiers might not be supported by your terminal emulator.
8989| `hidden` |
9090| `crossed_out` |
9191
92−> Note: The `underlined` modifier is deprecated and only available for backwards compatability.
93−> Its behaviour is equivalent to `underline-style="line"`.
92+> Note: The `underlined` modifier is deprecated and only available for backwards compatibility.
93+> Its behavior is equivalent to setting `underline.style="line"`.
9494
9595### Underline Style
9696
97−One of the following values may be used as an `underline-style`.
97+One of the following values may be used as a value for `underline.style`.
9898
9999Some styles might not be supported by your terminal emulator.
100100
helix-view/src/theme.rs+16−5
@@ -268,18 +268,29 @@ impl ThemePalette {
268268 value
269269 .as_str()
270270 .and_then(|s| s.parse().ok())
271− .ok_or(format!("Theme: invalid underline-style: {}", value))
271+ .ok_or(format!("Theme: invalid underline style: {}", value))
272272 }
273273
274274 pub fn parse_style(&self, style: &mut Style, value: Value) -> Result<(), String> {
275275 if let Value::Table(entries) = value {
276− for (name, value) in entries {
276+ for (name, mut value) in entries {
277277 match name.as_str() {
278278 "fg" => *style = style.fg(self.parse_color(value)?),
279279 "bg" => *style = style.bg(self.parse_color(value)?),
280− "underline-color" => *style = style.underline_color(self.parse_color(value)?),
281− "underline-style" => {
282− *style = style.underline_style(Self::parse_underline_style(&value)?)
280+ "underline" => {
281+ let table = value
282+ .as_table_mut()
283+ .ok_or("Theme: underline must be table")?;
284+ if let Some(value) = table.remove("color") {
285+ *style = style.underline_color(self.parse_color(value)?);
286+ }
287+ if let Some(value) = table.remove("style") {
288+ *style = style.underline_style(Self::parse_underline_style(&value)?);
289+ }
290+
291+ if let Some(attr) = table.keys().next() {
292+ return Err(format!("Theme: invalid underline attribute: {attr}"));
293+ }
283294 }
284295 "modifiers" => {
285296 let modifiers = value
runtime/themes/dark_plus.toml+2−2
@@ -92,8 +92,8 @@
9292"info" = { fg = "light_blue" }
9393"hint" = { fg = "light_gray3" }
9494
95−"diagnostic.error" = {underline-color = "red", underline-style = "curl"}
96−"diagnostic" = {underline-color = "gold", underline-style = "curl" }
95+"diagnostic.error".underline = { color = "red", style = "curl" }
96+"diagnostic".underline = { color = "gold", style = "curl" }
9797
9898[palette]
9999white = "#ffffff"
runtime/themes/onedark.toml+4−4
@@ -39,10 +39,10 @@
3939"diff.delta" = "gold"
4040"diff.minus" = "red"
4141
42−"diagnostic.info" = { underline-color = "blue", underline-style = "curl" }
43−"diagnostic.hint" = { underline-color = "green", underline-style = "curl" }
44−"diagnostic.warning" = { underline-color = "yellow", underline-style = "curl" }
45−"diagnostic.error" = { underline-color = "red", underline-style = "curl" }
42+"diagnostic.info".underline = { color = "blue", style = "curl" }
43+"diagnostic.hint".underline = { color = "green", style = "curl" }
44+"diagnostic.warning".underline = { color = "yellow", style = "curl" }
45+"diagnostic.error".underline = { color = "red", style = "curl" }
4646"info" = { fg = "blue", modifiers = ["bold"] }
4747"hint" = { fg = "green", modifiers = ["bold"] }
4848"warning" = { fg = "yellow", modifiers = ["bold"] }