Skip to content

💡 OSC 8 hyperlink support #67

@natemoo-re

Description

@natemoo-re

Is your feature request related to a problem?

There's no built-in way to render a hyperlink inside text. Terminals support OSC 8 hyperlinks (ESC ]8;;<url> … ESC ]8;;), which render as clickable links, but text only takes a string plus styling—so a CLI can't emit a clickable URL without hand-writing the escape sequence and fighting the renderer's U+FFFD substitution.

Describe the solution you'd like

Either a new link("value", { href: "https://example.com" }) util, or extending the text options with an optional { href }.

link("docs", { href: "https://example.com" });
text("docs", { href: "https://example.com" });
// emits:  ESC ]8;;https://example.com ST   docs   ESC ]8;; ST

The link text renders and measures like normal text; the OSC 8 open/close bytes are zero-width.

Describe alternatives you've considered

Putting the OSC 8 bytes inside the content string doesn't work today—they'd be mangled to U+FFFD. A verbatim-passthrough escape hatch (#66) would let you hand-roll it, but a first-class href option keeps width accounting correct and the call site readable.

Additional context

Failing test case on nm/repro/osc8-hyperlinks (test · diff).

Needs an href field on the text op (ops.ts)—or a link() helper that sets it—carried through the text decode in reduce (src/clayterm.c:562); the renderer emits the OSC 8 open before the run's glyph cells and the close after, both zero-width.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions