hyperlink

package
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package hyperlink provides terminal hyperlink configuration for clog.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearFormats

func ClearFormats()

ClearFormats resets all format pointers to nil (unset).

func Enabled

func Enabled() bool

Enabled reports whether hyperlinks are enabled.

func OSC8

func OSC8(url, text string) string

OSC8 wraps text in raw OSC 8 escape sequences unconditionally.

func PathDisplayText

func PathDisplayText(path string, line, column int) string

PathDisplayText returns the display string for a path hyperlink.

func ResolvePathURL

func ResolvePathURL(path string, line, column int) string

ResolvePathURL builds the full hyperlink URL for a file path.

func Restore

func Restore(s Snapshot)

Restore resets the hyperlink configuration to a previously saved Snapshot.

func SetColumnFormat

func SetColumnFormat(format string)

SetColumnFormat configures the URL format for file+line+column hyperlinks.

Accepts a full format string or a preset name (e.g. "vscode"). Known presets: cursor, kitty, macvim, textmate, vscode, vscode-insiders, vscodium.

Use {path}, {line}, and {column} (or {col}) as placeholders.

func SetDirFormat

func SetDirFormat(format string)

SetDirFormat configures the URL format for directory hyperlinks.

Accepts a full format string or a preset name. Falls back to SetPathFormat if not set.

func SetEnabled

func SetEnabled(e bool)

SetEnabled enables or disables all hyperlink rendering. When disabled, hyperlink functions return plain text without OSC 8 sequences.

func SetFileFormat

func SetFileFormat(format string)

SetFileFormat configures the URL format for file-only hyperlinks (used by Path and PathLink with line 0, when the path is not a directory).

Accepts a full format string or a preset name. Falls back to SetPathFormat if not set.

func SetLineFormat

func SetLineFormat(format string)

SetLineFormat configures the URL format for file+line hyperlinks.

Accepts a full format string or a preset name (e.g. "vscode").

func SetPathFormat

func SetPathFormat(format string)

SetPathFormat configures the generic fallback URL format for any path.

Accepts a full format string or a preset name.

func SetPreset

func SetPreset(name string) error

SetPreset configures all hyperlink format slots using a named preset. This is a convenience wrapper around the individual Set*Format functions.

Known presets: cursor, kitty, macvim, textmate, vscode, vscode-insiders, vscodium.

Types

type Snapshot

type Snapshot struct {
	// contains filtered or unexported fields
}

Snapshot captures the current state of all format pointers and the enabled flag. Use Restore to reset the state in test cleanup.

func Save

func Save() Snapshot

Save captures the current hyperlink configuration so it can be restored later with Restore. Typical usage in tests:

snap := hyperlink.Save()
t.Cleanup(func() { hyperlink.Restore(snap) })

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL