From 9bfaf2840cffe35d689bd115a308d21961ab082a Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 21 Jul 2024 12:45:05 +0200 Subject: Add `Link` support to `rich_text` widget --- core/src/text/paragraph.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'core/src/text') diff --git a/core/src/text/paragraph.rs b/core/src/text/paragraph.rs index 4ee83798..26650793 100644 --- a/core/src/text/paragraph.rs +++ b/core/src/text/paragraph.rs @@ -12,7 +12,9 @@ pub trait Paragraph: Sized + Default { fn with_text(text: Text<&str, Self::Font>) -> Self; /// Creates a new [`Paragraph`] laid out with the given [`Text`]. - fn with_spans(text: Text<&[Span<'_, Self::Font>], Self::Font>) -> Self; + fn with_spans( + text: Text<&[Span<'_, Link, Self::Font>], Self::Font>, + ) -> Self; /// Lays out the [`Paragraph`] with some new boundaries. fn resize(&mut self, new_bounds: Size); @@ -35,6 +37,11 @@ pub trait Paragraph: Sized + Default { /// [`Paragraph`], returning information about the nearest character. fn hit_test(&self, point: Point) -> Option; + /// Tests whether the provided point is within the boundaries of a + /// [`Span`] in the [`Paragraph`], returning the index of the [`Span`] + /// that was hit. + fn hit_span(&self, point: Point) -> Option; + /// Returns the distance to the given grapheme index in the [`Paragraph`]. fn grapheme_position(&self, line: usize, index: usize) -> Option; -- cgit