ansi

package
v12.120.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package ansi provides methods for working with ANSI/VT100 control sequences

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasCodes

func HasCodes(s string) bool

HasCodes returns true if given string contains ANSI/VT100 control sequences

Example
input := "Hello"
fmt.Println(HasCodes(input))

input = "\033[40;38;5;82mHello\x1B[0m"
fmt.Println(HasCodes(input))
Output:

false
true

func HasCodesBytes

func HasCodesBytes(b []byte) bool

HasCodes returns true if given byte slice contains ANSI/VT100 control sequences

Example
input := []byte("Hello")
fmt.Println(HasCodesBytes(input))

input = []byte("\033[40;38;5;82mHello\x1B[0m")
fmt.Println(HasCodesBytes(input))
Output:

false
true

func RemoveCodes

func RemoveCodes(s string) string

RemoveCodesBytes returns string without all ANSI/VT100 control sequences

Example
input := "\033[40;38;5;82mHello\x1B[0m"
fmt.Println(RemoveCodes(input))
Output:

Hello

func RemoveCodesBytes

func RemoveCodesBytes(b []byte) []byte

RemoveCodesBytes returns byte slice without all ANSI/VT100 control sequences

Example
input := []byte("\033[40;38;5;82mHello\x1B[0m")
fmt.Println(string(RemoveCodesBytes(input)))
Output:

Hello

Types

This section is empty.

Jump to

Keyboard shortcuts

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