mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 17:05:38 +00:00
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:
@@ -984,6 +984,12 @@ func (e *Editor) Read(p []byte) (int, error) {
|
||||
return e.text.Read(p)
|
||||
}
|
||||
|
||||
// Regions returns visible regions covering the rune range [start,end).
|
||||
func (e *Editor) Regions(start, end int, regions []Region) []Region {
|
||||
e.initBuffer()
|
||||
return e.text.Regions(start, end, regions)
|
||||
}
|
||||
|
||||
func max(a, b int) int {
|
||||
if a > b {
|
||||
return a
|
||||
|
||||
Reference in New Issue
Block a user