on master help sign in
merge underline-style and underline-color into a single table
66a4908Pascal Kuthe
book/src/themes.md+5−5
@@ -13,10 +13,10 @@ The default theme.toml can be found [here](https://github.com/helix-editor/helix
13Each line in the theme file is specified as below:
13Each line in the theme file is specified as below:
14
14
15```toml
15```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"] }
17```
17```
18
18
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.
20
20
21To specify only the foreground color:
21To specify only the foreground color:
22
22
@@ -89,12 +89,12 @@ Less common modifiers might not be supported by your terminal emulator.
89| `hidden` |
89| `hidden` |
90| `crossed_out` |
90| `crossed_out` |
91
91
92−> Note: The `underlined` modifier is deprecated and only available for backwards compatability.
92+> Note: The `underlined` modifier is deprecated and only available for backwards compatibility.
93−> Its behaviour is equivalent to `underline-style="line"`.
93+> Its behavior is equivalent to setting `underline.style="line"`.
94
94
95### Underline Style
95### Underline Style
96
96
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`.
98
98
99Some styles might not be supported by your terminal emulator.
99Some styles might not be supported by your terminal emulator.
100
100
helix-view/src/theme.rs+16−5
@@ -268,18 +268,29 @@ impl ThemePalette {
268 value
268 value
269 .as_str()
269 .as_str()
270 .and_then(|s| s.parse().ok())
270 .and_then(|s| s.parse().ok())
271− .ok_or(format!("Theme: invalid underline-style: {}", value))
271+ .ok_or(format!("Theme: invalid underline style: {}", value))
272 }
272 }
273
273
274 pub fn parse_style(&self, style: &mut Style, value: Value) -> Result<(), String> {
274 pub fn parse_style(&self, style: &mut Style, value: Value) -> Result<(), String> {
275 if let Value::Table(entries) = value {
275 if let Value::Table(entries) = value {
276− for (name, value) in entries {
276+ for (name, mut value) in entries {
277 match name.as_str() {
277 match name.as_str() {
278 "fg" => *style = style.fg(self.parse_color(value)?),
278 "fg" => *style = style.fg(self.parse_color(value)?),
279 "bg" => *style = style.bg(self.parse_color(value)?),
279 "bg" => *style = style.bg(self.parse_color(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") {
280− "underline-color" => *style = style.underline_color(self.parse_color(value)?),
285+ *style = style.underline_color(self.parse_color(value)?);
281− "underline-style" => {
286+ }
287+ if let Some(value) = table.remove("style") {
282− *style = style.underline_style(Self::parse_underline_style(&value)?)
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+ }
283 }
294 }
284 "modifiers" => {
295 "modifiers" => {
285 let modifiers = value
296 let modifiers = value
runtime/themes/dark_plus.toml+2−2
@@ -92,8 +92,8 @@
92"info" = { fg = "light_blue" }
92"info" = { fg = "light_blue" }
93"hint" = { fg = "light_gray3" }
93"hint" = { fg = "light_gray3" }
94
94
95−"diagnostic.error" = {underline-color = "red", underline-style = "curl"}
95+"diagnostic.error".underline = { color = "red", style = "curl" }
96−"diagnostic" = {underline-color = "gold", underline-style = "curl" }
96+"diagnostic".underline = { color = "gold", style = "curl" }
97
97
98[palette]
98[palette]
99white = "#ffffff"
99white = "#ffffff"
runtime/themes/onedark.toml+4−4
@@ -39,10 +39,10 @@
39"diff.delta" = "gold"
39"diff.delta" = "gold"
40"diff.minus" = "red"
40"diff.minus" = "red"
41
41
42−"diagnostic.info" = { underline-color = "blue", underline-style = "curl" }
42+"diagnostic.info".underline = { color = "blue", style = "curl" }
43−"diagnostic.hint" = { underline-color = "green", underline-style = "curl" }
43+"diagnostic.hint".underline = { color = "green", style = "curl" }
44−"diagnostic.warning" = { underline-color = "yellow", underline-style = "curl" }
44+"diagnostic.warning".underline = { color = "yellow", style = "curl" }
45−"diagnostic.error" = { underline-color = "red", underline-style = "curl" }
45+"diagnostic.error".underline = { color = "red", style = "curl" }
46"info" = { fg = "blue", modifiers = ["bold"] }
46"info" = { fg = "blue", modifiers = ["bold"] }
47"hint" = { fg = "green", modifiers = ["bold"] }
47"hint" = { fg = "green", modifiers = ["bold"] }
48"warning" = { fg = "yellow", modifiers = ["bold"] }
48"warning" = { fg = "yellow", modifiers = ["bold"] }