Help us shape the future of Go! Take the 2026 Go Developer Survey

terminaltext

package
v0.0.49 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package terminaltext provides terminal-safe plain-text rendering helpers for mecatui UI and status-line renderers.

Index

Constants

View Source
const DefaultTabWidth = 4

DefaultTabWidth is the fixed spaces-per-tab policy for plain-text display paths without a style. It matches Lip Gloss's default tab width.

Variables

This section is empty.

Functions

func ExpandStyleTabs added in v0.0.49

func ExpandStyleTabs(text string, style lipgloss.Style) string

ExpandStyleTabs expands tabs using the style's effective conversion policy before display measurement or wrapping. It leaves all other text unchanged.

func ExpandTabs added in v0.0.49

func ExpandTabs(text string, width int) string

ExpandTabs replaces each tab with width spaces before display measurement or wrapping. Zero removes tabs; a negative width preserves them. This matches Lip Gloss's fixed-width conversion, not column-dependent terminal tab stops. It does not sanitize text or interpret Markdown.

func NormalizeWidth

func NormalizeWidth(src string) string

NormalizeWidth rewrites text so Lip Gloss's WcWidth and GraphemeWidth agree for every grapheme cluster. It preserves agreeing clusters, then tries removing VS16, keeping the first scalar, and finally U+FFFD.

func Sanitize

func Sanitize(s string) string

Sanitize removes terminal controls from plain text while preserving layout newlines and tabs. It removes C0 controls, ESC, DEL, C1 controls, and Unicode Cf format characters. Markdown must not pass through this function.

func SanitizeSingleLine

func SanitizeSingleLine(s string) string

SanitizeSingleLine removes terminal controls from a single-line display value. Unlike Sanitize, it removes layout newlines, tabs, U+2028, and U+2029.

Types

This section is empty.

Jump to

Keyboard shortcuts

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