Skip to content

Commit

Permalink
Windows: hyperlink support
Browse files Browse the repository at this point in the history
  • Loading branch information
gdamore committed Mar 5, 2024
1 parent 18256bb commit 581a114
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions console_win.go
Expand Up @@ -171,6 +171,8 @@ const (
vtUnderColor = "\x1b[58:5:%dm"
vtUnderColorRGB = "\x1b[58:2::%d:%d:%dm"
vtUnderColorReset = "\x1b[59m"
vtEnterUrl = "\x1b]8;%s;%s\x1b\\" // NB arg 1 is id, arg 2 is url
vtExitUrl = "\x1b]8;;\x1b\\"
)

var vtCursorStyles = map[CursorStyle]string{
Expand Down Expand Up @@ -969,6 +971,13 @@ func (s *cScreen) sendVtStyle(style Style) {
} else if bg.Valid() {
_, _ = fmt.Fprintf(esc, vtSetBg, bg&0xff)
}
// URL string can be long, so don't send it unless we really need to
if style.url != "" {
_, _ = fmt.Fprintf(esc, vtEnterUrl, style.urlId, style.url)
} else {
esc.WriteString(vtExitUrl)
}

s.emitVtString(esc.String())
}

Expand Down

0 comments on commit 581a114

Please sign in to comment.