Skip to content

config: add link-url-style for always-underline link rendering#397

Draft
deblasis wants to merge 1 commit into
windowsfrom
link-url-style
Draft

config: add link-url-style for always-underline link rendering#397
deblasis wants to merge 1 commit into
windowsfrom
link-url-style

Conversation

@deblasis

Copy link
Copy Markdown
Owner

Staging draft for a planned ghostty-org/ghostty PR.

This branch is upstream/main plus the #394 cherry-pick (79550b8c2). The "Files changed" view here previews exactly what the upstream submission will look like.

Validated:

  • Mac: zig build test-lib-vt — 4177/4195 passed, 18 skipped, 0 failed
  • Windows: zig build test-lib-vt + dotnet build Ghostty.csproj -p:Platform=x64 clean

See the pinned comment for the do-not-merge / do-not-Update-branch reminder.

OSC 8 hyperlinks and the default URL matcher currently only show
underlines while the mouse is hovering them with Ctrl/Cmd held. The
majority of modern terminal emulators (Windows Terminal, iTerm2,
WezTerm, Kitty, VS Code) underline links unconditionally, which makes
hyperlinked output discoverable without the modifier-press signal.

This adds a new config knob:

  link-url-style: hover-mods | always

Default is hover-mods, which preserves the current behavior. Users who
want industry-standard always-underline can set it to `always`.

Click behavior is intentionally unchanged: opening a link still
requires Ctrl/Cmd regardless of the style setting, so mouse-aware TUI
programs (vim with mouse=a, htop) keep their normal mouse-button
semantics.

Three small changes:

  - src/config/Config.zig: new LinkUrlStyle enum + `@"link-url-style"`
    config option, plus a finalize() hook that switches the default
    URL matcher's highlight to .always when style == .always.

  - src/renderer/generic.zig: DerivedConfig.link_url_style propagated
    from Config; the OSC 8 underline gate now branches on the style.
    In .always mode it walks the whole viewport for hyperlink cells;
    in .hover-mods mode the existing point-under-cursor logic runs.

  - src/terminal/render.zig: new RenderState.allHyperlinkCells helper
    that returns every OSC 8 hyperlink cell in the viewport regardless
    of any specific link ID or mouse position. Two tests pin empty-
    viewport and multi-hyperlink-per-row cases.

Tested:
  - zig build -Dapp-runtime=none (Windows): clean
  - zig build test-lib-vt: pass
  - dotnet build Ghostty.csproj -p:Platform=x64: clean against the
    rebuilt ghostty.dll
@deblasis

Copy link
Copy Markdown
Owner Author

Heads-up to future-me / reviewers: this draft is intentionally weird.

Why the diff looks the way it does:

  • This branch is based on upstream/main, not on windows.
  • The only commit on top is the config: add link-url-style for always-underline link rendering #394 cherry-pick (79550b8c2), which is already merged into windows as the squash of #394.
  • So GitHub's merge would be a no-op, and the "Files changed" view is showing the upstream-ready patch as it will appear in the ghostty-org/ghostty PR.

Rules of engagement:

  • Do not merge. The change is already in windows.
  • Do not click "Update branch". That would pull all of windows into this branch and replace the clean upstream-shaped diff with a mess.
  • Do not delete the branch on PR close — keep it for the upstream submission and for re-validation if upstream/main advances.

Sole purpose: a tracked, browsable preview of what gets sent to ghostty-org/ghostty. When the upstream PR is filed, link it here and close this draft (without --delete-branch).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant