term

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package term is the seam between the TUI shell and the terminal primitives under term/. It provides the one type the shell needs: a Styler that paints semantic slots and measures, truncates and wraps text in real terminal cells.

Everything it does is delegated — theme resolution to term/theme, width and wrapping to term/ansi and term/charwidth. The value of this file is that the shell can depend on four methods instead of four packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Styler

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

Styler paints semantic slots and measures text the way the terminal will draw it. It satisfies the shell's Styler interface structurally, so neither package needs to import the other's.

func NewStyler

func NewStyler(themeName string, overrides map[string]string) *Styler

NewStyler resolves a named theme plus per-slot config overrides. An unknown theme name, an unknown slot, and an invalid spec all degrade rather than fail. Pass the theme name the configuration layer resolved — which is where the NO_COLOR convention selects "mono".

func NewStylerFromTheme

func NewStylerFromTheme(t *theme.Theme) *Styler

NewStylerFromTheme wraps an already-resolved theme.

func (*Styler) Pad

func (s *Styler) Pad(text string, width int) string

Pad extends text to exactly width cells (a no-op if it is already wider).

func (*Styler) Paint

func (s *Styler) Paint(slot, text string) string

Paint renders text in the named slot. An unknown slot, or one resolving to "none", returns the text unpainted.

func (*Styler) SGR

func (s *Styler) SGR(slot string) string

SGR is the raw opening sequence for a slot, or "" when the slot is unset.

func (*Styler) Slice

func (s *Styler) Slice(text string, start, width int) string

Slice returns the visible cell window [start, start+width) without splitting a grapheme cluster, keeping content after the window in its original column.

func (*Styler) Theme

func (s *Styler) Theme() *theme.Theme

Theme exposes the resolved theme for callers that need slot SGRs directly — the frame's selection compositing and the border gradient, for instance.

func (*Styler) Truncate

func (s *Styler) Truncate(text string, width int) string

Truncate cuts text to at most width cells, preserving styling and never splitting a wide character across the boundary. Truncated text is marked with an ellipsis.

func (*Styler) Width

func (s *Styler) Width(text string) int

Width is the display width of text in terminal cells: escape sequences count zero and a wide character counts two.

func (*Styler) Wrap

func (s *Styler) Wrap(text string, width int) []string

Wrap folds text to lines of at most width cells, preserving styling and grapheme clusters.

Directories

Path Synopsis
Package agent is the serial coordinator for autonomous TUI agent requests and the presentation of their transcripts.
Package agent is the serial coordinator for autonomous TUI agent requests and the presentation of their transcripts.
Package ansi holds the SGR-aware, width-aware string helpers.
Package ansi holds the SGR-aware, width-aware string helpers.
Package border is the single owner of box-drawing chrome: rounded corners plus an angled truecolor gradient swept across a container's border cells.
Package border is the single owner of box-drawing chrome: rounded corners plus an angled truecolor gradient swept across a container's border cells.
Package charwidth answers the terminal display width of Unicode codepoints and grapheme clusters.
Package charwidth answers the terminal display width of Unicode codepoints and grapheme clusters.
Package clipboard writes to the system clipboard via whatever tool the platform has, with no third-party dependency.
Package clipboard writes to the system clipboard via whatever tool the platform has, with no third-party dependency.
Package frame is a pure frame builder: given content, it returns one string per terminal row, each exactly `width` visible cells wide.
Package frame is a pure frame builder: given content, it returns one string per terminal row, each exactly `width` visible cells wide.
Package hitmap is pure geometry: it maps a screen (row, col) to a Hit zone using the rectangles a layout publishes.
Package hitmap is pure geometry: it maps a screen (row, col) to a Hit zone using the rectangles a layout publishes.
Package input holds the terminal input primitives: the raw key sequences the TUI recognizes, a raw-bytes-to-semantic-event key map, and the grapheme-aware single-line/multi-line text editor used by the prompt and by form fields.
Package input holds the terminal input primitives: the raw key sequences the TUI recognizes, a raw-bytes-to-semantic-event key map, and the grapheme-aware single-line/multi-line text editor used by the prompt and by form fields.
Package layout is pure geometry for one sampled terminal frame.
Package layout is pure geometry for one sampled terminal frame.
Package mouse is a pure SGR mouse-report decoder plus the (mode, zone, button, action) → intent table.
Package mouse is a pure SGR mouse-report decoder plus the (mode, zone, button, action) → intent table.
Package shortcuts is the declarative registry for every keyboard action shown in help.
Package shortcuts is the declarative registry for every keyboard action shown in help.
Package theme is the semantic color layer.
Package theme is the semantic color layer.

Jump to

Keyboard shortcuts

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