term

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serialize

func Serialize(s Screen) []byte

Serialize renders a Screen as one repaint escape sequence: reset, clear, paint every row with minimal SGR changes, restore cursor. Feeding the result into a fresh emulator of the same size reproduces the screen.

Types

type Cell

type Cell struct {
	R         rune
	FG, BG    Color
	Bold      bool
	Underline bool
	Reverse   bool

	// Width is the cell's mono-spaced column width: 1 for an ordinary cell,
	// 2 for the lead cell of a wide (e.g. CJK, emoji) rune, and 0 for the
	// placeholder cell immediately following a width-2 cell. Serialize skips
	// Width-0 cells entirely — the wide rune written for the lead cell
	// already advances a real terminal's cursor across both columns, so
	// emitting anything for the placeholder would shift everything after it
	// one column to the right.
	Width int
}

type Color

type Color struct {
	Mode    uint8 // 0=default, 1=ansi256, 2=rgb
	Idx     uint8
	R, G, B uint8
}

type Emulator

type Emulator interface {
	Feed(p []byte)
	Screen() Screen
	Resize(cols, rows int)
}

func NewEmulator

func NewEmulator(cols, rows int) Emulator

NewEmulator returns an Emulator backed by charmbracelet/x/vt.

type Screen

type Screen struct {
	Cells        [][]Cell // [row][col]
	CursorX      int
	CursorY      int
	CursorHidden bool
	Alt          bool
	Cols, Rows   int
}

Jump to

Keyboard shortcuts

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