Skip to content

Commit

Permalink
Enable OSC 8 hyperlink on VTE-based terminals >= 0.50.0
Browse files Browse the repository at this point in the history
Some terminals will not support it even when on VTE >= 0.50.0, but these
terminals will ignore the sequence, so this is harmless.

See: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
  • Loading branch information
delthas committed Feb 23, 2022
1 parent cd5be44 commit 2362f49
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tscreen.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ func NewTerminfoScreenFromTty(tty Tty) (Screen, error) {
}
terminfo.AddTerminfo(ti)
}
if vteVersion := os.Getenv("VTE_VERSION"); vteVersion != "" && ti.Hyperlink == "" && ti.StringTerminator == "" {
v, err := strconv.Atoi(vteVersion)
if err == nil && v > 5000 {
// hyperlinks are supported in VTE-based terminal on VTE >= 0.50.0.
// some terminals do not support it even when VTE does, but they will ignore the escape code in those cases.
// see https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda#terminal-emulators
ti.Hyperlink = "\x1b]8;;"
ti.StringTerminator = "\x1b\\"
}
}
t := &tScreen{ti: ti, tty: tty}

t.keyexist = make(map[Key]bool)
Expand Down

0 comments on commit 2362f49

Please sign in to comment.