render: OSC 8 hyperlinks with hover/click and a URL hint mode

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I7b39adae426d3fc5b7dfe1437eb10e976a6a6964
This commit is contained in:
raf 2026-06-25 13:48:20 +03:00
commit 2161d7250f
No known key found for this signature in database
GPG key ID: 29D95B64378DB4BF
6 changed files with 457 additions and 11 deletions

View file

@ -680,6 +680,17 @@ impl Perform for Term {
self.grid.set_prompt_mark(kind);
}
}
// OSC 8: hyperlink. `OSC 8 ; params ; URI ST`; an empty URI ends the
// link. The URI is everything after the second field, rejoined since
// a URI may itself contain ';'.
Some(&n) if n == b"8" => {
let uri_bytes = params
.get(2..)
.map(|parts| parts.join(&b';'))
.unwrap_or_default();
let uri = std::str::from_utf8(&uri_bytes).unwrap_or("");
self.grid.set_link((!uri.is_empty()).then_some(uri));
}
// OSC 4: set/query palette entries (pairs of index;spec).
Some(&n) if n == b"4" => self.osc_palette(params, bell),
// OSC 104: reset palette (all, or the listed indices).