Documentation
¶
Overview ¶
Package textutil provides terminal-cell-aware operations on Unicode text.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clip ¶
Clip returns the longest prefix of whole grapheme clusters whose terminal width does not exceed cols. It does not pad or sanitize its input.
func DropLast ¶
DropLast removes the final complete grapheme cluster from s. This is useful for implementing Backspace without splitting UTF-8, combining sequences, or emoji. It does not sanitize its input.
func Fit ¶
Fit clips s to cols terminal cells and pads the result with spaces so that its width is exactly cols. It does not sanitize its input.
func Sanitize ¶
Sanitize makes s safe to draw as terminal text. Control and formatting characters which could affect the terminal or the visual ordering of text are replaced with spaces. ZWNJ and ZWJ are retained because they participate in legitimate grapheme clusters. Invalid UTF-8 is converted to utf8.RuneError by ranging over the string.
Types ¶
This section is empty.