hyperlink

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package hyperlink provides terminal hyperlink rendering for clog. All configuration is explicit: callers pass a Config (usually derived from the logger's FieldFormats) - the package holds no global state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expand added in v0.11.0

func Expand(value, slot string) string

Expand resolves a preset name to its format string for the given slot ("path", "line", or "column"). Returns value unchanged if it is not a known preset name, so full format strings pass through unmodified.

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.

Types

type Config added in v0.11.0

type Config struct {
	// Enabled controls whether hyperlinks are rendered at all. When false,
	// hyperlink helpers return plain text without OSC 8 sequences.
	Enabled bool

	// ColumnFormat is the URL format for file+line+column hyperlinks.
	// Falls back to LineFormat when empty.
	ColumnFormat string
	// DirFormat is the URL format for directory hyperlinks.
	// Falls back to PathFormat when empty.
	DirFormat string
	// FileFormat is the URL format for file-only hyperlinks (no line
	// number). Falls back to PathFormat when empty.
	FileFormat string
	// LineFormat is the URL format for file+line hyperlinks.
	// Falls back to "file://{path}" when empty.
	LineFormat string
	// PathFormat is the generic fallback URL format for any path.
	// Falls back to "file://{path}" when empty.
	PathFormat string
}

Config holds resolved hyperlink rendering configuration. The format strings use {path}, {line}, and {column} (or {col}) as placeholders; an empty string means the documented fallback.

func DefaultConfig added in v0.11.0

func DefaultConfig() Config

DefaultConfig returns the default hyperlink configuration: enabled, with all format slots empty (plain file:// URLs).

func Preset added in v0.11.0

func Preset(name string) (Config, error)

Preset returns the Config for a named editor preset. Known presets: cursor, kitty, macvim, subl, textmate, vscode, vscode-insiders, vscodium.

func (Config) ResolvePathURL added in v0.11.0

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

ResolvePathURL builds the full hyperlink URL for a file path using the given configuration.

Jump to

Keyboard shortcuts

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