1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-11 11:42:12 +02:00

Add function to render a hyperlink

It might seem cleaner to integrate this into the text style system, so that you
could say `ts := ts.Url("some link")` and then `ts.Sprint("my text")`. However,
this would require adding a new field to TextStyle, which I didn't want to do.
This commit is contained in:
Stefan Haller 2024-08-16 11:25:28 +02:00
parent fb81fc6057
commit 3f7674a2e9

@ -0,0 +1,13 @@
package style
import "fmt"
// Render the given text as an OSC 8 hyperlink
func PrintHyperlink(text string, link string) string {
return fmt.Sprintf("\033]8;;%s\033\\%s\033]8;;\033\\", link, text)
}
// Render a link where the text is the same as a link
func PrintSimpleHyperlink(link string) string {
return fmt.Sprintf("\033]8;;%s\033\\%s\033]8;;\033\\", link, link)
}