Debian Codegraph @

ansi/hyperlink.go

raw
1 package ansi
2
3 import "strings"
4
5 // SetHyperlink returns a sequence for starting a hyperlink.
6 //
7 // OSC 8 ; Params ; Uri ST
8 // OSC 8 ; Params ; Uri BEL
9 //
10 // To reset the hyperlink, omit the URI.
11 //
12 // See: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
13 func SetHyperlink(uri string, params ...string) string {
14 var p string
15 if len(params) > 0 {
16 p = strings.Join(params, ":")
17 }
18 return "\x1b]8;" + p + ";" + uri + "\x07"
19 }
20
21 // ResetHyperlink returns a sequence for resetting the hyperlink.
22 //
23 // This is equivalent to SetHyperlink("", params...).
24 //
25 // See: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
26 func ResetHyperlink(params ...string) string {
27 return SetHyperlink("", params...)
28 }