Merge branch 'master' into beacon

This commit is contained in:
Héctor Ramón Jiménez 2025-04-01 02:18:20 +02:00
commit e060129951
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
30 changed files with 915 additions and 633 deletions

View file

@ -474,6 +474,7 @@ fn parse_with<'a>(
let mut strikethrough = false;
let mut metadata = false;
let mut table = false;
let mut code_block = false;
let mut link = None;
let mut image = None;
let mut stack = Vec::new();
@ -627,6 +628,7 @@ fn parse_with<'a>(
});
}
code_block = true;
code_language =
(!language.is_empty()).then(|| language.into_string());
@ -732,6 +734,8 @@ fn parse_with<'a>(
)
}
pulldown_cmark::TagEnd::CodeBlock if !metadata && !table => {
code_block = false;
#[cfg(feature = "highlighter")]
{
state.borrow_mut().highlighter = highlighter.take();
@ -759,14 +763,28 @@ fn parse_with<'a>(
_ => None,
},
pulldown_cmark::Event::Text(text) if !metadata && !table => {
#[cfg(feature = "highlighter")]
if let Some(highlighter) = &mut highlighter {
if code_block {
code.push_str(&text);
#[cfg(feature = "highlighter")]
if let Some(highlighter) = &mut highlighter {
for line in text.lines() {
code_lines.push(Text::new(
highlighter.highlight_line(line).to_vec(),
));
}
}
#[cfg(not(feature = "highlighter"))]
for line in text.lines() {
code_lines.push(Text::new(
highlighter.highlight_line(line).to_vec(),
));
code_lines.push(Text::new(vec![Span::Standard {
text: line.to_owned(),
strong,
emphasis,
strikethrough,
link: link.clone(),
code: false,
}]));
}
return None;

View file

@ -343,6 +343,10 @@ fn update<Message: Clone, Theme, Renderer>(
state.cursor_position = cursor_position;
state.bounds = bounds;
if widget.interaction.is_some() && state.is_hovered != was_hovered {
shell.request_redraw();
}
match (
widget.on_enter.as_ref(),
widget.on_move.as_ref(),

View file

@ -167,7 +167,10 @@ where
///
/// The original alignment of the [`Row`] is preserved per row wrapped.
pub fn wrap(self) -> Wrapping<'a, Message, Theme, Renderer> {
Wrapping { row: self }
Wrapping {
row: self,
vertical_spacing: None,
}
}
}
@ -372,6 +375,15 @@ pub struct Wrapping<
Renderer = crate::Renderer,
> {
row: Row<'a, Message, Theme, Renderer>,
vertical_spacing: Option<f32>,
}
impl<Message, Theme, Renderer> Wrapping<'_, Message, Theme, Renderer> {
/// Sets the vertical spacing _between_ lines.
pub fn vertical_spacing(mut self, amount: impl Into<Pixels>) -> Self {
self.vertical_spacing = Some(amount.into().0);
self
}
}
impl<Message, Theme, Renderer> Widget<Message, Theme, Renderer>
@ -403,6 +415,7 @@ where
.shrink(self.row.padding);
let spacing = self.row.spacing;
let vertical_spacing = self.vertical_spacing.unwrap_or(spacing);
let max_width = limits.max().width;
let mut children: Vec<layout::Node> = Vec::new();
@ -447,7 +460,7 @@ where
align(row_start..i, row_height, &mut children);
y += row_height + spacing;
y += row_height + vertical_spacing;
x = 0.0;
row_start = i;
row_height = 0.0;