aboutsummaryrefslogtreecommitdiff
path: root/helix-view
diff options
context:
space:
mode:
authorGokul Soumya2022-07-08 22:05:06 +0000
committerPascal Kuthe2022-10-01 15:00:32 +0000
commit999b45b28c157418c20a9a8cd9219db6ce0beac7 (patch)
tree2e865dec1254cfe759b04c72ece5e7d2af5d0991 /helix-view
parentc9584251f321a8540cf530561896b2f48f0b76a2 (diff)
Support different kinds of underline rendering
Adds four new modifiers that can be used in themes: - undercurled - underdashed - underdotted - double-underline
Diffstat (limited to 'helix-view')
-rw-r--r--helix-view/src/graphics.rs34
1 files changed, 24 insertions, 10 deletions
diff --git a/helix-view/src/graphics.rs b/helix-view/src/graphics.rs
index fb3c8b3f..15492119 100644
--- a/helix-view/src/graphics.rs
+++ b/helix-view/src/graphics.rs
@@ -327,17 +327,27 @@ bitflags! {
///
/// let m = Modifier::BOLD | Modifier::ITALIC;
/// ```
- #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
+ #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(rename_all = "kebab-case"))]
pub struct Modifier: u16 {
- const BOLD = 0b0000_0000_0001;
- const DIM = 0b0000_0000_0010;
- const ITALIC = 0b0000_0000_0100;
- const UNDERLINED = 0b0000_0000_1000;
- const SLOW_BLINK = 0b0000_0001_0000;
- const RAPID_BLINK = 0b0000_0010_0000;
- const REVERSED = 0b0000_0100_0000;
- const HIDDEN = 0b0000_1000_0000;
- const CROSSED_OUT = 0b0001_0000_0000;
+ const BOLD = 0b0000_0000_0000_0001;
+ const DIM = 0b0000_0000_0000_0010;
+ const ITALIC = 0b0000_0000_0000_0100;
+ const UNDERLINED = 0b0000_0000_0000_1000;
+ const SLOW_BLINK = 0b0000_0000_0001_0000;
+ const RAPID_BLINK = 0b0000_0000_0010_0000;
+ const REVERSED = 0b0000_0000_0100_0000;
+ const HIDDEN = 0b0000_0000_1000_0000;
+ const CROSSED_OUT = 0b0000_0001_0000_0000;
+ const UNDERCURLED = 0b0000_0010_0000_0000;
+ const UNDERDOTTED = 0b0000_0100_0000_0000;
+ const UNDERDASHED = 0b0000_1000_0000_0000;
+ const DOUBLE_UNDERLINED = 0b0001_0000_0000_0000;
+
+ const ANY_UNDERLINE = Self::UNDERLINED.bits
+ | Self::UNDERCURLED.bits
+ | Self::UNDERDOTTED.bits
+ | Self::UNDERDASHED.bits
+ | Self::DOUBLE_UNDERLINED.bits;
}
}
@@ -355,6 +365,10 @@ impl FromStr for Modifier {
"reversed" => Ok(Self::REVERSED),
"hidden" => Ok(Self::HIDDEN),
"crossed_out" => Ok(Self::CROSSED_OUT),
+ "undercurled" => Ok(Self::UNDERCURLED),
+ "underdotted" => Ok(Self::UNDERDOTTED),
+ "underdashed" => Ok(Self::UNDERDASHED),
+ "double_underlined" => Ok(Self::DOUBLE_UNDERLINED),
_ => Err("Invalid modifier"),
}
}