terminalescaper

package
v0.0.0-...-66acf6f Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clean

func Clean(s string) string

Clean escapes the UTF8 encoded string provided as input so it is safe to print on a unix terminal. It removes non printing characters and substitutes the vt100 escape character 0x1b with '^['.

func CleanBytes

func CleanBytes(p []byte) []byte

CleanBytes is a wrapper around Clean to work on byte slices instead of strings.

Types

type EscapeCode

type EscapeCode []byte

Taken from unexported data at golang.org/x/crypto/ssh/terminal and expanded with data at github.com/adamwalz/keybase-client/go/client:color.go

type Writer

type Writer struct {
	io.Writer
	// contains filtered or unexported fields
}

Writer can be used to write data to the underlying io.Writer, while transparently sanitizing it. If an error occurs writing to a Writer, all subsequent writes will return the error. Note that the sanitization might alter the size of the actual data being written.

func (*Writer) Write

func (w *Writer) Write(p []byte) (int, error)

Write writes p to the underlying io.Writer, after sanitizing it. It returns n = len(p) on a successful write (regardless of how much data is written). This is because the escaping function might alter the actual dimension of the data, but the caller is interested in knowing how much of what they wanted to write was actually written. In case of errors it (conservatively) returns n=0 and the error, and no other writes are possible.

Jump to

Keyboard shortcuts

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