ansidecoder

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package ansidecoder implements a ANSI decoder that returns runes and keeps track of cursor position and styling.

Index

Constants

View Source
const BELRune = rune('\x07')
View Source
const ESCRune = rune('\x1b')
View Source
const FinalBytes = "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~)"
View Source
const SGRByte = 'm' // Select Graphic Rendition

Variables

This section is empty.

Functions

This section is empty.

Types

type Color

type Color struct {
	N   int
	RGB []int
}

func (Color) String

func (c Color) String() string

type Decoder

type Decoder struct {
	// state of last returned rune
	X             int
	Y             int
	Foreground    Color
	Background    Color
	Underline     bool
	Intensity     bool
	Dim           bool
	Invert        bool
	Italic        bool
	Strikethrough bool

	MaxX  int
	MaxY  int
	State State
	// contains filtered or unexported fields
}

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder returns new ANSI decoder that is a io.RuneReader. See ReadRune for details.

func (*Decoder) ReadRune

func (d *Decoder) ReadRune() (r rune, size int, err error)

ReadRune returns next rune. The decoder struct has state for last returned rune, .X, .Y, .Foreground etc.

type State

type State int
const (
	StateCopy       State = iota
	StateSeenESC          // Seen ESC
	StateCSI              // Control Sequence Inducer ESC [
	StateOSC              // Operating System Command ESC ]
	StateOSCSeenESC       // Operating System Command ESC ] ... ESC
)

Jump to

Keyboard shortcuts

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