ansi

package module
v0.0.0-...-276c624 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: MIT Imports: 4 Imported by: 36

README

ansi

Latest Release Build Status Coverage Status Go ReportCard GoDoc

Raw ANSI sequence helpers

ANSI Writer

import "github.com/muesli/ansi"

w := ansi.Writer{Forward: os.Stdout}
w.Write([]byte("\x1b[31mHello, world!\x1b[0m"))
w.Close()

Compressor

The ANSI compressor eliminates unnecessary/redundant ANSI sequences.

import "github.com/muesli/ansi/compressor"

w := compressor.Writer{Forward: os.Stdout}
w.Write([]byte("\x1b[31mHello, world!\x1b[0m"))
w.Close()

Documentation

Index

Constants

View Source
const Marker = '\x1B'

Variables

This section is empty.

Functions

func IsTerminator

func IsTerminator(c rune) bool

func PrintableRuneWidth

func PrintableRuneWidth(s string) int

PrintableRuneWidth returns the cell width of the given string.

Types

type Buffer

type Buffer struct {
	bytes.Buffer
}

Buffer is a buffer aware of ANSI escape sequences.

func (Buffer) PrintableRuneWidth

func (w Buffer) PrintableRuneWidth() int

PrintableRuneWidth returns the cell width of all printable runes in the buffer.

type Writer

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

func (*Writer) LastSequence

func (w *Writer) LastSequence() string

func (*Writer) ResetAnsi

func (w *Writer) ResetAnsi()

func (*Writer) RestoreAnsi

func (w *Writer) RestoreAnsi()

func (*Writer) Write

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

Write is used to write content to the ANSI buffer.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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