processor

package
v0.11.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContentBounds

type ContentBounds struct {
	MinX   int  // First column with content (0-indexed)
	MaxX   int  // Last column with content (0-indexed)
	MinY   int  // First row with content (0-indexed)
	MaxY   int  // Last row with content (0-indexed)
	Width  int  // MaxX - MinX + 1
	Height int  // MaxY - MinY + 1
	Empty  bool // True if no content found
}

ContentBounds represents the bounding box of actual content in the buffer.

type VirtualTerminal

type VirtualTerminal struct {
	// contains filtered or unexported fields
}

func NewVirtualTerminal

func NewVirtualTerminal(width, height int, outputEncoding string, useVGAColors bool, legacyMode bool) *VirtualTerminal

func NewVirtualTerminalFromCells

func NewVirtualTerminalFromCells(cells [][]types.Cell, outputEncoding string, useVGAColors bool, legacyMode bool) *VirtualTerminal

NewVirtualTerminalFromCells creates a VirtualTerminal from a cell buffer. Useful for reconstructing a VT after cropping or manipulation.

func (*VirtualTerminal) ApplyTokens

func (vt *VirtualTerminal) ApplyTokens(tokens []types.Token) error

ApplyTokens applies ANSI tokens to the virtual terminal

func (*VirtualTerminal) Crop

func (vt *VirtualTerminal) Crop(x, y, width, height int) *VirtualTerminal

Crop extracts a rectangular region from the buffer and returns a new VirtualTerminal. Coordinates are 0-indexed. Returns nil if region is invalid. The cropped VT preserves all cell styles (colors, effects).

func (*VirtualTerminal) ExportFlattenedANSI

func (vt *VirtualTerminal) ExportFlattenedANSI() string

ExportFlattenedANSI exports the buffer with optimized ANSI codes using differential encoding. Uses ExportSplitTextAndSequences and applies minimal SGR codes at the appropriate positions. The legacyMode ensures ANSI 1990 compatibility by using reset+rebuild when attributes need to be turned OFF, rather than using codes like [22m, [23m, etc.

func (*VirtualTerminal) ExportFlattenedANSIInline

func (vt *VirtualTerminal) ExportFlattenedANSIInline() string

ExportFlattenedANSIInline exports the buffer as a single line with minimal ANSI codes.

func (*VirtualTerminal) ExportFlattenedANSIWithTrailing added in v0.10.0

func (vt *VirtualTerminal) ExportFlattenedANSIWithTrailing() string

ExportFlattenedANSIWithTrailing exports the buffer with optimized ANSI codes and preserves trailing empty lines.

func (*VirtualTerminal) ExportPlainText

func (vt *VirtualTerminal) ExportPlainText(keepTrailing bool) string

ExportPlainText exports the buffer as plain text without ANSI codes. Uses ExportSplitTextAndSequences and extracts only the text part. When keepTrailing is true, trailing empty lines are preserved.

func (*VirtualTerminal) ExportPlainTextInline

func (vt *VirtualTerminal) ExportPlainTextInline() string

ExportPlainTextInline exports the buffer as plain text without newlines.

func (*VirtualTerminal) ExportSplitTextAndSequences

func (vt *VirtualTerminal) ExportSplitTextAndSequences(keepTrailing bool) []types.LineWithSequences

ExportSplitTextAndSequences exports the buffer as separate text and sequences. Returns a slice of LineWithSequences, each containing the plain text and SGR changes. When keepTrailing is true, trailing empty lines are preserved.

func (*VirtualTerminal) Fill

func (vt *VirtualTerminal) Fill(char rune, sgr *types.SGR)

Fill sets all cells in the buffer to the specified character and SGR style. Useful for creating colored backgrounds before compositing.

func (*VirtualTerminal) GetBuffer

func (vt *VirtualTerminal) GetBuffer() [][]types.Cell

GetBuffer returns a deep copy of the buffer with all cells and their styles. Each cell contains the character and its complete SGR state. Useful for extracting raw buffer data for manipulation or cropping.

func (*VirtualTerminal) GetContentBounds

func (vt *VirtualTerminal) GetContentBounds() ContentBounds

GetContentBounds calculates the bounding box of actual content. Ignores null characters and default-style spaces (equivalent to R0). Returns ContentBounds with Empty=true if no content found.

func (*VirtualTerminal) GetHeight

func (vt *VirtualTerminal) GetHeight() int

GetHeight returns the height of the virtual terminal buffer.

func (*VirtualTerminal) GetMaxCursorX

func (vt *VirtualTerminal) GetMaxCursorX() int

func (*VirtualTerminal) GetMaxCursorY

func (vt *VirtualTerminal) GetMaxCursorY() int

func (*VirtualTerminal) GetWidth

func (vt *VirtualTerminal) GetWidth() int

func (*VirtualTerminal) Paste

func (vt *VirtualTerminal) Paste(source *VirtualTerminal, x, y int) error

Paste copies the content of source into the current VT at position (x, y). Cells with Char == 0 are treated as transparent and are not copied. If source extends beyond the destination bounds, it is clipped. Returns error if coordinates are negative.

Jump to

Keyboard shortcuts

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