merge underline-style and underline-color into a single table

pull/4061/head
Pascal Kuthe 2 years ago
parent 963a0ac0bb
commit 66a49080bc
No known key found for this signature in database
GPG Key ID: D715E8655AE166A6

@ -13,10 +13,10 @@ The default theme.toml can be found [here](https://github.com/helix-editor/helix
Each line in the theme file is specified as below:
```toml
key = { fg = "#ffffff", bg = "#000000", underline-color = "#ff0000", underline-style = "curl", modifiers = ["bold", "italic"] }
key = { fg = "#ffffff", bg = "#000000", underline = { color = "#ff0000", style = "curl"}, modifiers = ["bold", "italic"] }
```
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.
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.
To specify only the foreground color:
@ -89,12 +89,12 @@ Less common modifiers might not be supported by your terminal emulator.
| `hidden` |
| `crossed_out` |
> Note: The `underlined` modifier is deprecated and only available for backwards compatability.
> Its behaviour is equivalent to `underline-style="line"`.
> Note: The `underlined` modifier is deprecated and only available for backwards compatibility.
> Its behavior is equivalent to setting `underline.style="line"`.
### Underline Style
One of the following values may be used as an `underline-style`.
One of the following values may be used as a value for `underline.style`.
Some styles might not be supported by your terminal emulator.

@ -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

@ -92,8 +92,8 @@
"info" = { fg = "light_blue" }
"hint" = { fg = "light_gray3" }
"diagnostic.error" = {underline-color = "red", underline-style = "curl"}
"diagnostic" = {underline-color = "gold", underline-style = "curl" }
"diagnostic.error".underline = { color = "red", style = "curl" }
"diagnostic".underline = { color = "gold", style = "curl" }
[palette]
white = "#ffffff"

@ -39,10 +39,10 @@
"diff.delta" = "gold"
"diff.minus" = "red"
"diagnostic.info" = { underline-color = "blue", underline-style = "curl" }
"diagnostic.hint" = { underline-color = "green", underline-style = "curl" }
"diagnostic.warning" = { underline-color = "yellow", underline-style = "curl" }
"diagnostic.error" = { underline-color = "red", underline-style = "curl" }
"diagnostic.info".underline = { color = "blue", style = "curl" }
"diagnostic.hint".underline = { color = "green", style = "curl" }
"diagnostic.warning".underline = { color = "yellow", style = "curl" }
"diagnostic.error".underline = { color = "red", style = "curl" }
"info" = { fg = "blue", modifiers = ["bold"] }
"hint" = { fg = "green", modifiers = ["bold"] }
"warning" = { fg = "yellow", modifiers = ["bold"] }

Loading…
Cancel
Save