text rendering: support strikethroughs (#7363)
<img width="1269" alt="image" src="https://github.com/zed-industries/zed/assets/18583882/d4c93033-b2ac-4ae0-8e12-457f256ee869"> Release Notes: - Added support for styling text with strikethrough. Related: - https://github.com/zed-industries/zed/issues/5364 - https://github.com/zed-industries/zed/pull/7345
This commit is contained in:
parent
55129d4d6c
commit
ad3940c66f
14 changed files with 145 additions and 4 deletions
|
@ -197,6 +197,9 @@ pub struct TextStyle {
|
|||
/// The underline style of the text
|
||||
pub underline: Option<UnderlineStyle>,
|
||||
|
||||
/// The strikethrough style of the text
|
||||
pub strikethrough: Option<StrikethroughStyle>,
|
||||
|
||||
/// How to handle whitespace in the text
|
||||
pub white_space: WhiteSpace,
|
||||
}
|
||||
|
@ -214,6 +217,7 @@ impl Default for TextStyle {
|
|||
font_style: FontStyle::default(),
|
||||
background_color: None,
|
||||
underline: None,
|
||||
strikethrough: None,
|
||||
white_space: WhiteSpace::Normal,
|
||||
}
|
||||
}
|
||||
|
@ -246,6 +250,10 @@ impl TextStyle {
|
|||
self.underline = Some(underline);
|
||||
}
|
||||
|
||||
if let Some(strikethrough) = style.strikethrough {
|
||||
self.strikethrough = Some(strikethrough);
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
|
@ -277,6 +285,7 @@ impl TextStyle {
|
|||
color: self.color,
|
||||
background_color: self.background_color,
|
||||
underline: self.underline,
|
||||
strikethrough: self.strikethrough,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -300,6 +309,9 @@ pub struct HighlightStyle {
|
|||
/// The underline style of the text
|
||||
pub underline: Option<UnderlineStyle>,
|
||||
|
||||
/// The underline style of the text
|
||||
pub strikethrough: Option<StrikethroughStyle>,
|
||||
|
||||
/// Similar to the CSS `opacity` property, this will cause the text to be less vibrant.
|
||||
pub fade_out: Option<f32>,
|
||||
}
|
||||
|
@ -553,6 +565,17 @@ pub struct UnderlineStyle {
|
|||
pub wavy: bool,
|
||||
}
|
||||
|
||||
/// The properties that can be applied to a strikethrough.
|
||||
#[derive(Refineable, Copy, Clone, Default, Debug, PartialEq, Eq)]
|
||||
#[refineable(Debug)]
|
||||
pub struct StrikethroughStyle {
|
||||
/// The thickness of the strikethrough.
|
||||
pub thickness: Pixels,
|
||||
|
||||
/// The color of the strikethrough.
|
||||
pub color: Option<Hsla>,
|
||||
}
|
||||
|
||||
/// The kinds of fill that can be applied to a shape.
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Fill {
|
||||
|
@ -601,6 +624,7 @@ impl From<&TextStyle> for HighlightStyle {
|
|||
font_style: Some(other.font_style),
|
||||
background_color: other.background_color,
|
||||
underline: other.underline,
|
||||
strikethrough: other.strikethrough,
|
||||
fade_out: None,
|
||||
}
|
||||
}
|
||||
|
@ -636,6 +660,10 @@ impl HighlightStyle {
|
|||
self.underline = other.underline;
|
||||
}
|
||||
|
||||
if other.strikethrough.is_some() {
|
||||
self.strikethrough = other.strikethrough;
|
||||
}
|
||||
|
||||
match (other.fade_out, self.fade_out) {
|
||||
(Some(source_fade), None) => self.fade_out = Some(source_fade),
|
||||
(Some(source_fade), Some(dest_fade)) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue