termcaps

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package termcaps detects terminal capabilities (image protocol, true color, OSC 8 hyperlinks) and provides the pure hyperlink escape helper. It is a leaf so non-presentation layers (tool renderers) can ask "does this terminal support hyperlinks?" without linking the TUI; the tui package re-exports this surface unchanged.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hyperlink(text, url string) string

Hyperlink wraps text in an OSC 8 hyperlink escape sequence. In terminals without hyperlink support the escape codes are ignored and only the plain text is displayed.

func ProbeTmuxHyperlinks() bool

ProbeTmuxHyperlinks asks the ambient tmux client whether it forwards OSC 8.

func ResetCache

func ResetCache()

ResetCache clears the pinned or detected value so the next Get re-detects.

func Set

func Set(capabilities TerminalCapabilities)

Set pins the capabilities (tests and explicit configuration).

Types

type ImageProtocol

type ImageProtocol string
const (
	ImageProtocolKitty  ImageProtocol = "kitty"
	ImageProtocolITerm2 ImageProtocol = "iterm2"
)

type TerminalCapabilities

type TerminalCapabilities struct {
	Images     ImageProtocol
	TrueColor  bool
	Hyperlinks bool
}

func Detect

func Detect(tmuxForwardsHyperlink func() bool) TerminalCapabilities

Detect derives capabilities from the terminal environment. Behavior is a faithful port of upstream terminal-image.ts detection order.

func Get

Get returns the cached capabilities, detecting them once on first use.

Jump to

Keyboard shortcuts

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