Skip to content

OSC 8 Support #1197

@rockorager

Description

@rockorager

Ghostty should support OSC8 Hyperlinks

Some general implementation considerations and thoughts that go beyond the reference:

  • Links are generally rare. A look aside table would be appropriate, with each cell requiring only an index into that ArrayList. This could probably be a u8
  • Hyperlinks should be defined per-screen. I believe we can clear the hyperlink storage when exiting the alt screen. The primary screen should retain the list of hyperlinks for the life of the screen (any old link could be scrolled into and require us to know the ID and target)
  • My preference would be that OSC hyperlinks always show a dotted underline, and on hover show the normal hover underline. This would be unique to Ghostty but IMO is a huge benefit. In other terminals, applications need to style these cells separately on their own (and basically none of them do), leaving users with no idea when a hyperlink is present
  • Given that hyperlinks are rare and to keep the per-cell byte count low, the index value should be as small as possible, considering alignment. u8 seems appropriate but given the lifetime of some primary screens may be too small.
  • The cursor also needs an OSC 8 field. The OSC8 sequence is in effect for any cell the cursor paints, meaning after the OSC 8 opener we add this as an effective "attribute" to the cursor. For example, this is valid and works in terminals which support OSC 8:
printf '\x1B[3;3H\x1B]8;;https://example.org\x1B\\Hyperlink Text\x1B[HMore, non-consecutive text\x1B]8;;\x1B\\

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions