widget: expose text region resolution

This commit adds exported methods to both LabelState and Editor
allowing callers to locate the text regions representing a range
of runes. This can be used to build interactive subregions of text,
like (for instance) hyperlinks.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
Chris Waldon
2022-12-22 14:51:13 -05:00
committed by Elias Naur
parent e98c8955bb
commit dc6fbf07f0
3 changed files with 16 additions and 0 deletions
+6
View File
@@ -341,3 +341,9 @@ func (l *Selectable) Events() []EditorEvent {
l.prevEvents = 0
return events
}
// Regions returns visible regions covering the rune range [start,end).
func (l *Selectable) Regions(start, end int, regions []Region) []Region {
l.initialize()
return l.text.Regions(start, end, regions)
}