From ca8ebb16a67095260e4e94109f82d3ac1603e927 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 28 Jul 2024 17:45:11 +0200 Subject: Implement `strikethrough` support for `rich_text` spans --- core/src/text.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'core') diff --git a/core/src/text.rs b/core/src/text.rs index 68c586f1..436fee9a 100644 --- a/core/src/text.rs +++ b/core/src/text.rs @@ -247,6 +247,8 @@ pub struct Span<'a, Link = (), Font = crate::Font> { pub padding: Padding, /// Whether the [`Span`] should be underlined or not. pub underline: bool, + /// Whether the [`Span`] should be struck through or not. + pub strikethrough: bool, } /// A text highlight. @@ -271,6 +273,7 @@ impl<'a, Link, Font> Span<'a, Link, Font> { link: None, padding: Padding::ZERO, underline: false, + strikethrough: false, } } @@ -395,6 +398,12 @@ impl<'a, Link, Font> Span<'a, Link, Font> { self } + /// Sets whether the [`Span`] shoud be struck through or not. + pub fn strikethrough(mut self, strikethrough: bool) -> Self { + self.strikethrough = strikethrough; + self + } + /// Turns the [`Span`] into a static one. pub fn to_static(self) -> Span<'static, Link, Font> { Span { @@ -407,6 +416,7 @@ impl<'a, Link, Font> Span<'a, Link, Font> { highlight: self.highlight, padding: self.padding, underline: self.underline, + strikethrough: self.strikethrough, } } } -- cgit