types

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var C0Names = map[byte]string{
	0x00: "NUL",
	0x01: "SOH",
	0x02: "STX",
	0x03: "ETX",
	0x04: "EOT",
	0x05: "ENQ",
	0x06: "ACK",
	0x07: "BEL",
	0x08: "BS",
	0x09: "HT",
	0x0A: "LF",
	0x0B: "VT",
	0x0C: "FF",
	0x0D: "CR",
	0x0E: "SO",
	0x0F: "SI",
	0x10: "DLE",
	0x11: "DC1",
	0x12: "DC2",
	0x13: "DC3",
	0x14: "DC4",
	0x15: "NAK",
	0x16: "SYN",
	0x17: "ETB",
	0x18: "CAN",
	0x19: "EM",
	0x1A: "SUB",
	0x1B: "ESC",
	0x1C: "FS",
	0x1D: "GS",
	0x1E: "RS",
	0x1F: "US",
}

C0 control codes names

View Source
var VGAPalette = [16][3]uint8{
	{0x00, 0x00, 0x00},
	{0xAA, 0x00, 0x00},
	{0x00, 0xAA, 0x00},
	{0xAA, 0x55, 0x00},
	{0x00, 0x00, 0xAA},
	{0xAA, 0x00, 0xAA},
	{0x00, 0xAA, 0xAA},
	{0xAA, 0xAA, 0xAA},
	{0x55, 0x55, 0x55},
	{0xFF, 0x55, 0x55},
	{0x55, 0xFF, 0x55},
	{0xFF, 0xFF, 0x55},
	{0x55, 0x55, 0xFF},
	{0xFF, 0x55, 0xFF},
	{0x55, 0xFF, 0xFF},
	{0xFF, 0xFF, 0xFF},
}

VGA Palette with exact VGA hardware color values

Functions

This section is empty.

Types

type Cell

type Cell struct {
	Char rune
	SGR  *SGR
}

Cell represents a single character in the virtual terminal buffer with its associated SGR (Select Graphic Rendition) styling.

func NewCell

func NewCell() Cell

NewCell creates a new empty cell with default SGR styling.

func (Cell) Copy

func (c Cell) Copy() Cell

Copy returns a deep copy of the cell.

type ColorType

type ColorType int
const (
	ColorDefault  ColorType = iota
	ColorStandard           // 0-15 (codes 30-37, 90-97, etc.)
	ColorIndexed            // 0-255 (ESC[38;5;n)
	ColorRGB                // RGB (ESC[38;2;r;g;b)
)

type ColorValue

type ColorValue struct {
	Type    ColorType
	R, G, B uint8
	Index   uint8
}

func (ColorValue) IsDefault

func (c ColorValue) IsDefault() bool

func (ColorValue) String

func (c ColorValue) String() string

type CropRegion

type CropRegion struct {
	X      int // Start X (column)
	Y      int // Start Y (row)
	Width  int // Width of region
	Height int // Height of region
}

CropRegion defines a rectangular region for cropping. Coordinates are 1-indexed in input, stored as 0-indexed internally.

func ParseCropRegion

func ParseCropRegion(s string) (*CropRegion, error)

ParseCropRegion parses a crop string in format "x,y:x1,y1" (start:end coordinates). Coordinates are 1-indexed (first column/row is 1, not 0). Returns nil if the string is empty.

func (*CropRegion) IsSet

func (c *CropRegion) IsSet() bool

IsSet returns true if the crop region is defined (not nil).

type LineWithSequences

type LineWithSequences struct {
	Text      string
	Sequences []SGRSequence
}

LineWithSequences contains a line of text and all SGR changes within that line

type SGR

type SGR struct {
	FgColor       ColorValue
	BgColor       ColorValue
	Bold          bool
	Dim           bool
	Italic        bool
	Underline     bool
	Blink         bool
	Reverse       bool
	Hidden        bool
	Strikethrough bool
}

func NewSGR

func NewSGR() *SGR

func (*SGR) ApplyParams

func (s *SGR) ApplyParams(params []int)

func (*SGR) Copy

func (s *SGR) Copy() *SGR

func (*SGR) Diff

func (s *SGR) Diff(previous *SGR, legacyMode bool) []int

Diff returns the minimal set of SGR codes to transition from previous to current state. If previous is nil, returns full state codes. If legacyMode is true, uses [0m + full state when any attribute needs to be turned OFF. If legacyMode is false, uses individual OFF codes (22, 23, 24, etc.).

func (*SGR) DiffToANSI

func (s *SGR) DiffToANSI(previous *SGR, useVGAColors bool, legacyMode bool) string

DiffToANSI generates the minimal ANSI escape sequence to transition from previous to current state. If legacyMode is true, uses [0m + full state when attributes need to be turned OFF (ANSI 1990 compatible). If legacyMode is false, uses individual OFF codes (modern terminals).

func (*SGR) Equals

func (s *SGR) Equals(other *SGR) bool

func (*SGR) Reset

func (s *SGR) Reset()

func (*SGR) String

func (s *SGR) String() string

func (*SGR) ToANSI

func (s *SGR) ToANSI(useVGAColors bool, legacyMode bool) string

type SGRSequence

type SGRSequence struct {
	Position int  // Position of the character in the line (0-indexed)
	SGR      *SGR // The SGR sequence to apply from this position
}

SGRSequence represents a SGR style at a specific position in a line

type Token

type Token struct {
	Type          TokenType `json:"type"`
	Pos           int       `json:"pos"`
	Raw           string    `json:"raw"`
	Value         string    `json:"value,omitempty"`
	Parameters    []string  `json:"parameters,omitempty"`
	C0Code        byte      `json:"c0_code,omitempty"`
	C1Code        string    `json:"c1_code,omitempty"`
	CSINotation   string    `json:"csi_notation,omitempty"`
	Signification string    `json:"signification,omitempty"`
}

func (Token) String

func (t Token) String() string

type TokenStats

type TokenStats struct {
	TotalTokens         int               `json:"total_tokens"`
	TokensByType        map[TokenType]int `json:"tokens_by_type"`
	SGRCodes            map[string]int    `json:"sgr_codes"`
	CSISequences        map[string]int    `json:"csi_sequences"`
	C0Codes             map[byte]int      `json:"c0_codes"`
	C1Codes             map[string]int    `json:"c1_codes"`
	TotalTextLength     int               `json:"total_text_length"`
	FileSize            int64             `json:"file_size"`
	ParsedPercent       float64           `json:"parsed_percent"`
	PosFirstBadSequence int64             `json:"pos_first_bad_sequence"`
}

type TokenType

type TokenType int
const (
	TokenText TokenType = iota
	TokenC0
	TokenC1
	TokenCSI
	TokenCSIInterupted
	TokenSGR
	TokenDCS
	TokenOSC
	TokenEscape
	TokenSauce
	TokenUnknown
)

func (TokenType) MarshalJSON

func (t TokenType) MarshalJSON() ([]byte, error)

func (TokenType) String

func (t TokenType) String() string

func (*TokenType) UnmarshalJSON

func (t *TokenType) UnmarshalJSON(data []byte) error

type Tokenizer

type Tokenizer interface {
	Tokenize() []Token
}

type TokenizerWithStats

type TokenizerWithStats interface {
	Tokenizer
	GetStats() TokenStats
}

Tokenize with statistics

Jump to

Keyboard shortcuts

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