summaryrefslogtreecommitdiffstats
path: root/core/src/text
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2024-07-21 17:18:53 +0200
committerLibravatar GitHub <noreply@github.com>2024-07-21 17:18:53 +0200
commit5443e4d8289873895587d856dbcf46f980bda6ab (patch)
tree4f0037c07349ba0f1ea3e3ace596d988d9c3d952 /core/src/text
parent4b44079f34aa9e01977a7974e5f49ae79ff6cd90 (diff)
parenta2943798a3cf79e15344063fbf4ea8c84d261d6f (diff)
downloadiced-5443e4d8289873895587d856dbcf46f980bda6ab.tar.gz
iced-5443e4d8289873895587d856dbcf46f980bda6ab.tar.bz2
iced-5443e4d8289873895587d856dbcf46f980bda6ab.zip
Merge pull request #2512 from iced-rs/feature/rich-text-links
Add `Link` support to `rich_text` widget
Diffstat (limited to 'core/src/text')
-rw-r--r--core/src/text/paragraph.rs9
1 files changed, 8 insertions, 1 deletions
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<Link>(
+ 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<Hit>;
+ /// 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<usize>;
+
/// Returns the distance to the given grapheme index in the [`Paragraph`].
fn grapheme_position(&self, line: usize, index: usize) -> Option<Point>;