termtest

package
v27.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StripANSICommands

func StripANSICommands(s string, opts ...ansiterm.Option) (string, error)

StripANSICommands attempts to strip ANSI console escape and control sequences from s, returning a string containing only the final printed characters which would be visible onscreen if the string was to be processed by a terminal emulator. Basic cursor positioning and screen erase control sequences are parsed and processed such that the output of simple CLI commands passed through a Windows Pseudoterminal and then this function yields the same string as if the output of those commands was redirected to a file.

The only correct way to represent the result of processing ANSI console output would be a two-dimensional array of an emulated terminal's display buffer. That would be awkward to test against, so this function instead attempts to render to a one-dimensional string without extra padding. This is an inherently lossy process, and any attempts to render a string containing many cursor positioning commands are unlikely to yield satisfactory results. Handlers for several ANSI control sequences are also unimplemented; attempts to parse a string containing one will panic.

Types

This section is empty.

Jump to

Keyboard shortcuts

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