From 387c6ef664688582ca1be950e2fe260699aa8862 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Wed, 14 Aug 2024 23:04:05 +0900 Subject: Support hyperlinks (OSC 8) in the main window Close #2557 --- src/result.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/result.go') diff --git a/src/result.go b/src/result.go index e1c20801..f10db19b 100644 --- a/src/result.go +++ b/src/result.go @@ -16,6 +16,7 @@ type colorOffset struct { offset [2]int32 color tui.ColorPair match bool + url *url } type Result struct { @@ -177,8 +178,11 @@ func (result *Result) colorOffsets(matchOffsets []Offset, theme *tui.ColorTheme, if curr != 0 && idx > start { if curr < 0 { color := colMatch + var url *url if curr < -1 && theme.Colored { - origColor := ansiToColorPair(itemColors[-curr-2], colMatch) + ansi := itemColors[-curr-2] + url = ansi.color.url + origColor := ansiToColorPair(ansi, colMatch) // hl or hl+ only sets the foreground color, so colMatch is the // combination of either [hl and bg] or [hl+ and bg+]. // @@ -194,13 +198,14 @@ func (result *Result) colorOffsets(matchOffsets []Offset, theme *tui.ColorTheme, } } colors = append(colors, colorOffset{ - offset: [2]int32{int32(start), int32(idx)}, color: color, match: true}) + offset: [2]int32{int32(start), int32(idx)}, color: color, match: true, url: url}) } else { ansi := itemColors[curr-1] colors = append(colors, colorOffset{ offset: [2]int32{int32(start), int32(idx)}, color: ansiToColorPair(ansi, colBase), - match: false}) + match: false, + url: ansi.color.url}) } } } -- cgit v1.2.3