summaryrefslogtreecommitdiffstats
path: root/core/src/text.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-07-28 17:45:11 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-07-28 17:45:11 +0200
commitca8ebb16a67095260e4e94109f82d3ac1603e927 (patch)
tree0abbc20c913a1c002dbcb6af4e9291ead567a17c /core/src/text.rs
parentebc6c0eba86608dbd9912ab180f48ca603f20c19 (diff)
downloadiced-ca8ebb16a67095260e4e94109f82d3ac1603e927.tar.gz
iced-ca8ebb16a67095260e4e94109f82d3ac1603e927.tar.bz2
iced-ca8ebb16a67095260e4e94109f82d3ac1603e927.zip
Implement `strikethrough` support for `rich_text` spans
Diffstat (limited to 'core/src/text.rs')
-rw-r--r--core/src/text.rs10
1 files changed, 10 insertions, 0 deletions
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,
}
}
}