terminaltext

package
v0.9.21 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EscapeControls

func EscapeControls(s string) string

EscapeControls renders control characters visibly instead of executing or deleting them. Use it where the exact untrusted value is security-relevant, such as a shell command awaiting approval or a file path in a diff header.

func EscapeControlsPreserveLayout

func EscapeControlsPreserveLayout(s string) string

EscapeControlsPreserveLayout escapes controls but retains newlines and tabs. It is intended for structured multi-line text such as diff content.

func Sanitize

func Sanitize(s string) string

Sanitize removes terminal control sequences from untrusted display text while preserving its printable text, tabs, and line structure. Trusted TUI styling should be applied only after this boundary.

func SanitizeBytes added in v0.0.400

func SanitizeBytes(input []byte) []byte

SanitizeBytes is the byte-slice form of Sanitize. It returns the original slice when no sanitization is needed, avoiding copies in rendering hot paths.

func SanitizeSingleLine

func SanitizeSingleLine(s string) string

SanitizeSingleLine removes terminal controls and flattens vertical or tabular whitespace so metadata cannot create convincing extra TUI rows.

Types

This section is empty.

Jump to

Keyboard shortcuts

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