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 ¶
- type Styler
- func (s *Styler) Composite(slot, text string) string
- func (s *Styler) Pad(text string, width int) string
- func (s *Styler) Paint(slot, text string) string
- func (s *Styler) SGR(slot string) string
- func (s *Styler) Slice(text string, start, width int) string
- func (s *Styler) Theme() *theme.Theme
- func (s *Styler) Truncate(text string, width int) string
- func (s *Styler) Width(text string) int
- func (s *Styler) Wrap(text string, width int) []string
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 ¶
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 ¶
NewStylerFromTheme wraps an already-resolved theme.
func (*Styler) Composite ¶ added in v1.6.0
Composite layers already-painted text over the named slot, re-opening the slot after every reset the text carries so a field's own colour sits ON the selection background instead of clearing it. A slot that resolves to nothing returns the text untouched.
func (*Styler) Paint ¶
Paint renders text in the named slot. An unknown slot, or one resolving to "none", returns the text unpainted.
func (*Styler) Slice ¶
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 ¶
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 ¶
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.
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. |