diff --git a/buffer/cell.go b/buffer/cell.go index a0fa159..308a58a 100644 --- a/buffer/cell.go +++ b/buffer/cell.go @@ -5,9 +5,10 @@ import ( ) type Cell struct { - r rune - attr CellAttributes - image *image.RGBA + r rune + attr CellAttributes + image *image.RGBA + hyperlink *Hyperlink } type CellAttributes struct { diff --git a/buffer/hyperlink.go b/buffer/hyperlink.go new file mode 100644 index 0000000..105fa3b --- /dev/null +++ b/buffer/hyperlink.go @@ -0,0 +1,5 @@ +package buffer + +type Hyperlink struct { + Uri string +} diff --git a/buffer/terminal_state.go b/buffer/terminal_state.go index 38b9972..5f36cc5 100644 --- a/buffer/terminal_state.go +++ b/buffer/terminal_state.go @@ -18,6 +18,7 @@ type TerminalState struct { tabStops map[uint16]struct{} Charsets []*map[rune]rune // array of 2 charsets, nil means ASCII (no conversion) CurrentCharset int // active charset index in Charsets array, valid values are 0 or 1 + CurrentHyperlink *Hyperlink } // NewTerminalMode creates a new terminal state diff --git a/terminal/osc.go b/terminal/osc.go index 6393018..7c41920 100644 --- a/terminal/osc.go +++ b/terminal/osc.go @@ -3,6 +3,8 @@ package terminal import ( "fmt" "strings" + + "github.com/liamg/aminal/buffer" ) func oscHandler(pty chan rune, terminal *Terminal) error { @@ -39,6 +41,12 @@ func oscHandler(pty chan rune, terminal *Terminal) error { switch pS[0] { case "0", "2": terminal.SetTitle(pT) + case "8": // hyperlink + if len(pS) > 2 { + terminal.terminalState.CurrentHyperlink = &buffer.Hyperlink{Uri: pS[2]} + } else { + terminal.terminalState.CurrentHyperlink = nil + } case "10": // get/set foreground colour if len(pS) > 1 { if pS[1] == "?" {