vt

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

README

vev-vt

A Go library for reading terminal output and keeping track of what should appear on screen. It powers vev.

Feed it the bytes from a shell or command. It handles text, colors, cursor movement, scrolling and resizing. You can then read the screen, save its history, or use the ansi package to draw it in a terminal.

This library does not start processes or manage a PTY. Your application does that and passes the output to vev-vt.

Install

Requires Go 1.27 or newer.

go get github.com/bnema/vev-vt

Alpha software: APIs and saved-history formats can change between versions. The current history format does not read older VTH3 data.

Read terminal output

package main

import (
    "fmt"

    vt "github.com/bnema/vev-vt"
)

func main() {
    screen := vt.NewScreen(80, 24)
    screen.Write([]byte("Hello, \x1b[31mworld\x1b[0m!"))

    // Colors and escape sequences are processed, not included in the text.
    for x := 0; x < 13; x++ {
        fmt.Printf("%c", screen.Cell(x, 0).Rune)
    }
    fmt.Println() // Hello, world!
}

Use screen.Resize(columns, rows) when the terminal size changes. Use screen.Snapshot() when you need a copy that stays unchanged as new output arrives.

Keep scrollback

Scrollback is the text that has moved above the visible screen.

// Your application chooses these limits; vev-vt has no default budget.
config := vt.HistoryConfig{
    MaxBytes: 20_000_000, // At most 20 MB of history data.
    MaxRows:  5_000,      // Optional: also keep at most 5,000 lines.
}
screen := vt.NewScreenWithHistory(80, 24, config)

vev-vt enforces the limits your application supplies. The PTY transports bytes; it does not store scrollback. The oldest lines are removed when a supplied limit is reached. Limits apply to each screen separately and exclude the visible screen. The byte limit measures uncompressed history data, not total process memory.

History guide →: limit settings, saving/restoring history and optional compression during idle time.

A few rules

  • Serialize Write, Resize, Snapshot, reads and history mutations in one goroutine, or protect them with your own lock.
  • Rows returned by the API are copies. Changing one does not change the screen.
  • Use vt.DefaultStyle() for terminal-default colors, not vt.Style{}.
  • Callbacks run during screen.Write; keep them short.

API ownership and styles →

Packages

Package Use it for
vev-vt Parse terminal output, read the screen and manage history.
vev-vt/core Work with cells, styles and writable grids.
vev-vt/ansi Render a screen or grid as ANSI terminal output.
vev-vt/graphics Read supported terminal images and their positions.

Supported image features →

Development

go test ./...
go test ./... -race
go vet ./...

Storage benchmarks and design decisions →

Documentation

Overview

Package vt implements the frontend-neutral terminal emulator core.

It tracks the visible cell grid, damage rectangles, scroll regions, alternate-screen state, cursor/reporting modes, and common xterm/VT control sequences. Wide runes that fit are stored as a head cell plus a continuation cell, and resize or edit operations repair row-boundary splits instead of leaving orphaned halves.

Stateful values are single-owner and are not internally synchronized. The owner must serialize Write, Resize, Snapshot, and History mutations. Write parses synchronously: every callback runs before Write returns and callbacks are delivered in the order their control sequences are encountered. A line eviction callback receives a stable row copy; response bytes should be consumed or copied during the callback. Other callback arguments are values or strings owned by the callback.

Snapshot and HistorySnapshotView capture owned state without sealing or mutating the live owner. Screen, ScreenSnapshot, and core.Frame expose storage-independent CellSource reads, and Row methods return owned copies. HistoryView.Row and HistoryView.Range decode owned semantic rows from compact slabs. A HistoryChunk pointer has stable identity for the lifetime of the view, so consumers can reuse unchanged sealed chunks.

Index

Constants

View Source
const (
	AttrDim           = core.AttrDim
	AttrUnderline     = core.AttrUnderline
	AttrBlink         = core.AttrBlink
	AttrStrikethrough = core.AttrStrikethrough

	UnderlineNone   = core.UnderlineNone
	UnderlineSingle = core.UnderlineSingle
	UnderlineDouble = core.UnderlineDouble
	UnderlineCurly  = core.UnderlineCurly
	UnderlineDotted = core.UnderlineDotted
	UnderlineDashed = core.UnderlineDashed

	DamageText       = core.DamageText
	DamageClear      = core.DamageClear
	DamageScrollUp   = core.DamageScrollUp
	DamageFullRedraw = core.DamageFullRedraw
)
View Source
const (
	// ColorSchemeReportDark is the DEC 2031 dark-scheme report.
	ColorSchemeReportDark = "\x1b[?997;1n"
	// ColorSchemeReportLight is the DEC 2031 light-scheme report.
	ColorSchemeReportLight = "\x1b[?997;2n"
)

Variables

View Source
var (
	BlankCell      = core.BlankCell
	DefaultStyle   = core.DefaultStyle
	FullRedraw     = core.FullRedraw
	NewFrame       = core.NewFrame
	NewCellPayload = core.NewCellPayload
)
View Source
var ErrHistoryCorrupt = errors.New("corrupt compressed history page")

ErrHistoryCorrupt reports corruption of an internally compressed sealed page. Public history decoders reject malformed external data before installing it.

View Source
var ErrHistoryRowTooLarge = errors.New("history row exceeds logical byte capacity")

ErrHistoryRowTooLarge is returned when one row cannot fit within the configured logical-byte budget or compact page bounds. History is unchanged.

View Source
var ErrInvalidHistoryConfig = errors.New("invalid history configuration")

Functions

func MarshalEmptyHistoryTail

func MarshalEmptyHistoryTail() ([]byte, error)

MarshalEmptyHistoryTail returns the mandatory canonical empty tail blob.

func MarshalHistory

func MarshalHistory(view HistoryView) ([]byte, error)

MarshalHistory serializes semantic cells with canonical chunk-local style dictionaries. Internal style IDs and page memory never cross this boundary.

func MarshalHistoryChunk

func MarshalHistoryChunk(chunk *HistoryChunk) ([]byte, error)

MarshalHistoryChunk encodes one immutable chunk as a self-contained blob.

func MarshalHistoryTail

func MarshalHistoryTail(view HistorySnapshotView) ([]byte, error)

MarshalHistoryTail encodes the copied mutable tail of a snapshot view as one canonical history blob. It does not seal or otherwise mutate live history.

func MarshalSealedHistory

func MarshalSealedHistory(view HistoryView) ([][]byte, []byte, error)

MarshalSealedHistory serializes a SealAndView result as oldest-first, self-contained sealed blobs plus a mandatory empty tail blob. The empty tail carries NextRowID and is not the canonical default empty encoding.

func RuneWidth

func RuneWidth(r rune) int

Types

type Cell

type Cell = core.Cell

The root package re-exports the frontend-neutral core model so screen, history, and renderer consumers share one cell/style/frame representation. The implementation and storage policy remain owned by the core package.

type CellPayload added in v0.5.0

type CellPayload = core.CellPayload

type CellSource added in v0.5.0

type CellSource = core.CellSource

type CursorSnapshot

type CursorSnapshot struct {
	Row      int
	Col      int
	Visible  bool
	Style    int
	StyleSet bool
}

CursorSnapshot is the cursor state captured with a visible screen snapshot.

type Damage

type Damage = core.Damage

type DamageCapture

type DamageCapture struct {
	Damage     []renderer.Damage
	Generation uint64
}

DamageCapture is an immutable copy of pending damage at one screen generation.

type DamageKind

type DamageKind = core.DamageKind

type DecodeStats

type DecodeStats struct {
	Chunks uint64
	Rows   uint64
	Cells  uint64
	Styles uint64
	Bytes  uint64
}

DecodeStats describes resources declared by one canonical VT blob.

func MeasureHistoryBlob added in v0.5.0

func MeasureHistoryBlob(data []byte) (DecodeStats, error)

MeasureHistoryBlob scans resource declarations without allocating. It is a sizing pass, NOT semantic validation: callers must still use PreflightHistoryBlob or UnmarshalHistory after accepting their aggregate budget. In particular, duplicate IDs/dictionary entries are not checked here.

func PreflightHistoryBlob

func PreflightHistoryBlob(data []byte) (DecodeStats, error)

PreflightHistoryBlob validates one self-contained history blob without allocating decoded rows.

func (*DecodeStats) Add

func (s *DecodeStats) Add(other DecodeStats) bool

Add adds another preflight result with overflow checking.

type Frame

type Frame = core.Frame

type Geometry added in v0.4.0

type Geometry struct {
	Cols, Rows              int
	PixelWidth, PixelHeight int
}

Geometry combines a terminal's required cell dimensions with optional pixel dimensions reported by its frontend. Zero pixel dimensions mean they are unknown and must not be inferred from the cell dimensions.

func (Geometry) PixelsKnown added in v0.4.0

func (g Geometry) PixelsKnown() bool

PixelsKnown reports whether both pixel dimensions are available.

func (Geometry) Valid added in v0.4.0

func (g Geometry) Valid() bool

Valid reports whether the cell dimensions can describe a terminal screen.

type History

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

History stores terminal rows in immutable chunks. It is intended to be mutated by the owner of a Screen; views are safe to retain after later appends.

func HistoryFromBlobs

func HistoryFromBlobs(config HistoryConfig, sealed [][]byte, tail []byte) (*History, error)

HistoryFromBlobs restores history directly from sealed, oldest-first blobs and the mandatory tail blob. It never feeds decoded rows through Append.

func NewHistory

func NewHistory(config HistoryConfig) *History

NewHistory constructs owned bounded history. Invalid programmer-supplied configuration panics; user-input boundaries should call Validate first.

func (*History) Append

func (h *History) Append(row []renderer.Cell, bound LineBound) error

Append records a copy of row along with its logical extent and an automatically allocated nonzero ID. Once a chunk is full it is sealed forever. Rows larger than the logical-byte capacity are rejected without mutation.

func (*History) AppendWithID

func (h *History) AppendWithID(row []renderer.Cell, bound LineBound, id RowID) error

AppendWithID records a copy of row with an explicit persisted identity. Unlike Append, malformed identities are rejected rather than synthesized.

func (*History) ByteCap added in v0.5.0

func (h *History) ByteCap() uint64

ByteCap returns the configured uncompressed byte ceiling. Zero means no independent byte ceiling, or disabled history when Cap is also zero.

func (*History) Cap

func (h *History) Cap() int

Cap returns the configured row ceiling; zero means no independent row ceiling, or disabled history when ByteCap is also zero.

func (*History) Cells

func (h *History) Cells() int

Cells returns the currently retained history cell count.

func (*History) CompressIdle added in v0.5.0

func (h *History) CompressIdle(maxPages int) (int, error)

CompressIdle visits at most maxPages sealed pages. Call it from the history owner's idle scheduler, never concurrently with append/eviction. A page must remain unread across two visits; the newest sealed chunk and mutable tail are kept hot. There are no internal goroutines, clocks, pooling or mmap mappings.

func (*History) CompressionStats added in v0.5.0

func (h *History) CompressionStats() HistoryCompressionStats

func (*History) Len

func (h *History) Len() int

Len returns the currently retained history row count.

func (*History) Limits added in v0.5.0

func (h *History) Limits() HistoryConfig

Limits reports the application's policy. A zero limit is omitted; both zero mean history is disabled. ChunkRows reports the resolved grouping size.

func (*History) LogicalBytes added in v0.5.0

func (h *History) LogicalBytes() uint64

LogicalBytes returns deterministic uncompressed bytes retained by history. It excludes the live primary and alternate screens and has no page allowance.

func (*History) NextRowID

func (h *History) NextRowID() RowID

NextRowID returns the next identity allocated by this history.

func (*History) SealAndView

func (h *History) SealAndView() HistoryView

SealAndView rotates the mutable tail into an immutable chunk, then captures the sealed chunks by identity. Callers must synchronize access to History.

func (*History) SetLimits added in v0.5.0

func (h *History) SetLimits(config HistoryConfig) error

SetLimits validates first, then updates limits and evicts oldest rows before returning. Existing borrowed views remain valid. Disabling history releases its owned backing but preserves the next row identity. The owner must serialize this operation with all other History mutations.

func (*History) SnapshotView

func (h *History) SnapshotView() HistorySnapshotView

SnapshotView captures history for persistence without sealing the mutable tail. Sealed chunks are shared by identity and the tail is deeply copied.

func (*History) View

func (h *History) View() HistoryView

View captures the current history. Sealed chunks are shared by identity; the immutable tail copy is reused until the mutable tail changes.

type HistoryChunk

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

HistoryChunk is an immutable compact slab of equal-width history rows. Its identity is stable and can be used by consumers to reuse unchanged chunks.

func (*HistoryChunk) CheckInvariants added in v0.5.0

func (c *HistoryChunk) CheckInvariants() error

CheckInvariants validates one compact immutable history slab.

func (*HistoryChunk) Restore added in v0.5.0

func (c *HistoryChunk) Restore() error

Restore validates and caches the chunk's backing before a caller starts a read transaction. Ordinary reads restore transparently; if private backing is corrupted they panic with ErrHistoryCorrupt rather than silently losing text.

func (*HistoryChunk) RowID

func (c *HistoryChunk) RowID(i int) RowID

RowID returns the identity of the row within an immutable chunk.

type HistoryCompressionStats added in v0.5.0

type HistoryCompressionStats struct {
	ColdPages            int
	CompressedBytes      uint64
	ResidentLogicalBytes uint64
	Restores             uint64
}

HistoryCompressionStats describes retained physical backing, not process RSS. ResidentLogicalBytes excludes Go allocator/map overhead; CompressedBytes is the encoded backing size. Retention remains governed by LogicalBytes alone.

type HistoryConfig

type HistoryConfig struct {
	MaxRows   int
	MaxBytes  uint64
	ChunkRows int
}

HistoryConfig enforces limits selected by the application. The library supplies no byte or line defaults. Each positive limit is an independent ceiling; zero omits that ceiling. Both zero disable history. Live grids are excluded. ChunkRows is an internal grouping hint in [1,256]; zero selects 256 and does not grant space beyond the application's retention limits.

func (HistoryConfig) Validate added in v0.5.0

func (c HistoryConfig) Validate() error

type HistorySnapshotView

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

HistorySnapshotView captures sealed history chunks and the mutable tail independently. Sealed chunks are shared by identity; Tail is owned by the view and can be serialized without rotating the live tail into a chunk.

func (HistorySnapshotView) Cells

func (v HistorySnapshotView) Cells() int

func (HistorySnapshotView) Chunk

func (v HistorySnapshotView) Chunk(i int) *HistoryChunk

Chunk returns a sealed immutable chunk at i, or nil when i is out of range.

func (HistorySnapshotView) ChunkCount

func (v HistorySnapshotView) ChunkCount() int

func (HistorySnapshotView) Len

func (v HistorySnapshotView) Len() int

func (HistorySnapshotView) LogicalBytes added in v0.5.0

func (v HistorySnapshotView) LogicalBytes() uint64

func (HistorySnapshotView) NextRowID

func (v HistorySnapshotView) NextRowID() RowID

NextRowID returns the next identity recorded by this snapshot.

func (HistorySnapshotView) Tail

Tail returns an immutable view of the copied mutable tail.

type HistoryView

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

HistoryView is an immutable snapshot of history. Row returns a copy so the storage behind a sealed chunk remains owned by VT.

func UnmarshalHistory

func UnmarshalHistory(data []byte) (HistoryView, error)

UnmarshalHistory accepts only VTC1. Validation precedes all decoded frame allocations, including validation of later chunks in the same payload.

func (HistoryView) Bound

func (v HistoryView) Bound(i int) LineBound

Bound returns the logical extent of the row at i, or the zero value when i is out of range. A zero value describes a hard row whose End is not meaningful.

func (HistoryView) Cell added in v0.5.0

func (v HistoryView) Cell(x, y int) renderer.Cell

Cell returns one semantic cell without allocating a row. Coordinates follow Screen.Cell: x is the column and y is the row. Invalid coordinates return the canonical blank cell. Variable-width history does not implement CellSource.

func (HistoryView) Cells

func (v HistoryView) Cells() int

func (HistoryView) Chunk

func (v HistoryView) Chunk(i int) *HistoryChunk

Chunk returns the immutable chunk at i, or nil when i is out of range.

func (HistoryView) ChunkCount

func (v HistoryView) ChunkCount() int

func (HistoryView) CopyRow added in v0.5.0

func (v HistoryView) CopyRow(y int, dst []renderer.Cell) int

CopyRow copies up to len(dst) cells into caller-owned storage and returns the number copied. It neither allocates a row nor exposes mutable page storage.

func (HistoryView) FindRowID

func (v HistoryView) FindRowID(id RowID) int

FindRowID returns the oldest-first index of id, or -1 when id is absent.

func (HistoryView) Len

func (v HistoryView) Len() int

func (HistoryView) LogicalBytes added in v0.5.0

func (v HistoryView) LogicalBytes() uint64

func (HistoryView) NextRowID

func (v HistoryView) NextRowID() RowID

NextRowID returns the next identity recorded by this view.

func (HistoryView) Range

func (v HistoryView) Range(yield func([]renderer.Cell) bool) error

Range calls yield with a decoded owned row in oldest-first order. Returning false stops iteration successfully; a backing restore failure returns an error.

func (HistoryView) Row

func (v HistoryView) Row(i int) []renderer.Cell

Row returns a decoded owned copy of the row at i, or nil when out of range.

func (HistoryView) RowID

func (v HistoryView) RowID(i int) RowID

RowID returns the identity of the row at i, or zero when i is out of range.

func (HistoryView) RowWidth added in v0.5.0

func (v HistoryView) RowWidth(y int) int

RowWidth returns the retained width of row y, or zero outside the view. Unlike Row, it does not allocate or decode a semantic row.

type LineBound

type LineBound struct {
	End  int
	Soft bool
}

LineBound describes a physical row's logical extent. End is exclusive: it is the count of meaningful cells, so the last significant column is End-1. It excludes padding introduced when a wide rune was moved off the right edge. Soft reports that the row continues into the following physical row.

type ModeSnapshot

type ModeSnapshot struct {
	AlternateScreen    bool
	BracketedPaste     bool
	SynchronizedUpdate bool
	ColorSchemeMode    bool
	MouseTracking      int
	MouseSGR           bool
}

ModeSnapshot is the renderer-relevant VT mode state captured with a screen.

type RGB

type RGB = core.RGB

type RecoveryTranscriptSnapshot

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

RecoveryTranscriptSnapshot owns compact viewport pages to replay after retained history. No semantic row slices are retained by the snapshot.

func (RecoveryTranscriptSnapshot) Marshal

func (snapshot RecoveryTranscriptSnapshot) Marshal() ([]byte, error)

Marshal encodes the compact capture without consulting or mutating live state.

type RowID

type RowID uint64

RowID identifies one physical terminal row for the lifetime of a Screen. Row IDs are never zero and are never reused by their owning Screen.

type Screen

type Screen struct {
	Row   int
	Col   int
	Style renderer.Style
	// OnLineEvicted is called just before a full-width upward scroll recycles
	// and blanks rows. The callback receives a stable copy of each evicted row.
	OnLineEvicted func([]renderer.Cell)
	// OnResponse is called synchronously from Write with reply bytes that the
	// emulator must send back to the child process (DA, DSR, and ANSI/DEC mode
	// query reports). The host wires it to the PTY input. Nil disables responses.
	OnResponse func([]byte)
	// OnBell is called synchronously from Write for each lone BEL (0x07)
	// outside escape sequences. BELs that terminate an OSC never fire it.
	// Nil disables bell reporting.
	OnBell func()
	// OnNotify is called synchronously from Write for explicit terminal
	// notifications: OSC 9 (body only) and OSC 777 "notify" (title;body).
	// Other non-clipboard OSC payloads remain discarded. Nil disables it.
	OnNotify func(title, body string)
	// OnProgress is called synchronously from Write for OSC 9;4 progress
	// transitions that request attention: active progress cleared or first entry
	// into error state. Nil disables progress reporting.
	OnProgress func(errored bool)
	// OnClipboard is called synchronously from Write for a complete OSC 52
	// clipboard set request from the child. The OSC 52 selection field is
	// accepted but ignored; the callback receives only the raw base64 payload.
	// Clipboard queries (data == "?") and malformed payloads are ignored and
	// never invoke it. Nil disables it.
	OnClipboard func(b64 string)
	// contains filtered or unexported fields
}

func NewScreen

func NewScreen(width, height int) *Screen

func NewScreenWithHistory

func NewScreenWithHistory(width, height int, config HistoryConfig) *Screen

NewScreenWithHistory creates a screen that records rows evicted from its primary screen into bounded immutable terminal history.

func NewScreenWithRecoveryTranscript

func NewScreenWithRecoveryTranscript(width, height int, config HistoryConfig, sealed [][]byte, tail, transcript []byte) (*Screen, error)

NewScreenWithRecoveryTranscript constructs a fresh blank screen whose history contains the restored bounded history followed by the recovery transcript. The transcript is decoded in full before history is restored.

func (*Screen) AcknowledgeDamage

func (s *Screen) AcknowledgeDamage(generation uint64) bool

AcknowledgeDamage consumes a capture only if no screen mutation occurred since it was taken. A stale acknowledgement conservatively requests a full redraw, ensuring intervening writes remain visible to the next capture.

func (*Screen) AltScreenActive

func (s *Screen) AltScreenActive() bool

func (*Screen) BracketedPasteMode

func (s *Screen) BracketedPasteMode() bool

BracketedPasteMode reports whether DEC private mode 2004 is currently enabled by the child process.

func (*Screen) CaptureDamage

func (s *Screen) CaptureDamage() DamageCapture

CaptureDamage snapshots pending damage without consuming it.

func (*Screen) Cell added in v0.5.0

func (s *Screen) Cell(x, y int) renderer.Cell

Cell returns the semantic cell at x, y. Coordinates must be inside the visible grid.

func (*Screen) ClearColorScheme

func (s *Screen) ClearColorScheme()

ClearColorScheme marks the host color scheme as unknown. Future child color scheme queries are silent until SetColorScheme supplies a known value again.

func (*Screen) ClearDamage

func (s *Screen) ClearDamage()

func (*Screen) ColorSchemeMode

func (s *Screen) ColorSchemeMode() bool

ColorSchemeMode reports whether DEC private mode 2031 is currently enabled.

func (*Screen) Columns added in v0.5.0

func (s *Screen) Columns() int

Columns returns the visible grid width.

func (*Screen) CursorCol

func (s *Screen) CursorCol() int

func (*Screen) CursorRow

func (s *Screen) CursorRow() int

func (*Screen) CursorStyle

func (s *Screen) CursorStyle() (int, bool)

func (*Screen) CursorVisible

func (s *Screen) CursorVisible() bool

func (*Screen) Damage

func (s *Screen) Damage() []renderer.Damage

Damage returns the current damage list. The caller must not modify the returned slice; ClearDamage must be called after the damage is consumed.

func (*Screen) ForceSyncEnd

func (s *Screen) ForceSyncEnd()

ForceSyncEnd forcibly leaves DEC private mode 2026 (synchronized update). Hosts use this as a safety valve if a child enters synchronized update mode and never sends the matching end sequence.

func (*Screen) Geometry added in v0.4.0

func (s *Screen) Geometry() Geometry

Geometry returns the screen's last frontend-supplied geometry.

func (*Screen) GraphicsSnapshot added in v0.4.0

func (s *Screen) GraphicsSnapshot() *graphics.Snapshot

GraphicsSnapshot returns an immutable snapshot of the active screen buffer's graphics scene, or nil before graphics has been used. The returned reference remains valid after subsequent Screen mutations.

func (*Screen) History

func (s *Screen) History() *History

History returns this screen's terminal history, or nil when history was not configured with NewScreenWithHistory.

func (*Screen) LineBounds

func (s *Screen) LineBounds() []LineBound

LineBounds returns an owned copy of the live grid's per-row logical extents, indexed like Frame rows. It returns nil when the screen has no buffer.

func (*Screen) MouseMode

func (s *Screen) MouseMode() (int, bool)

func (*Screen) RecoveryTranscriptSnapshot

func (s *Screen) RecoveryTranscriptSnapshot() RecoveryTranscriptSnapshot

RecoveryTranscriptSnapshot captures the primary viewport, followed by the alternate viewport when active. Untouched trailing rows are omitted and each viewport ends with a hard line, independently of physical row rotation.

func (*Screen) Resize

func (s *Screen) Resize(width, height int)

func (*Screen) RowCells added in v0.5.0

func (s *Screen) RowCells(y int) []renderer.Cell

RowCells returns an owned copy of visible row y, or nil when y is out of range.

func (*Screen) RowID

func (s *Screen) RowID(y int) RowID

RowID returns the identity of active live row y, or zero when y is out of range.

func (*Screen) RowIDs

func (s *Screen) RowIDs() []RowID

RowIDs returns an owned copy of the active live grid's row identities.

func (*Screen) Rows added in v0.5.0

func (s *Screen) Rows() int

Rows returns the visible grid height.

func (*Screen) SetColorScheme

func (s *Screen) SetColorScheme(light bool)

SetColorScheme updates the host color scheme and notifies subscribed child apps.

func (*Screen) SetDefaultColors

func (s *Screen) SetDefaultColors(fg, bg renderer.RGB, ok bool)

SetDefaultColors sets the terminal default foreground/background colors used to answer child OSC 10/11 color queries. Passing ok=false makes color queries silent until known colors are supplied again.

func (*Screen) SetGeometry added in v0.4.0

func (s *Screen) SetGeometry(geometry Geometry)

SetGeometry updates the frontend-supplied cell and optional pixel geometry. Cell changes retain the existing Resize behavior; pixel-only changes do not touch the text frame or damage state.

func (*Screen) Snapshot

func (s *Screen) Snapshot() ScreenSnapshot

Snapshot captures the active visible viewport without mutating Screen, history, or pending damage. Screen remains single-owner; callers must serialize Snapshot with Write, Resize, and host mutations.

func (*Screen) SyncUpdateActive

func (s *Screen) SyncUpdateActive() bool

SyncUpdateActive reports whether DEC private mode 2026 (synchronized update) is currently enabled by the child process.

func (*Screen) TerminalTitle

func (s *Screen) TerminalTitle() string

TerminalTitle returns the latest title set by OSC 0 or OSC 2.

func (*Screen) Write

func (s *Screen) Write(data []byte)

type ScreenSnapshot

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

ScreenSnapshot is an owned immutable capture of the active terminal viewport. It implements core.CellSource, and Row returns caller-owned storage.

func (ScreenSnapshot) Bound

func (s ScreenSnapshot) Bound(y int) LineBound

func (ScreenSnapshot) Cell added in v0.5.0

func (s ScreenSnapshot) Cell(x, y int) renderer.Cell

Cell returns the semantic cell at x, y.

func (ScreenSnapshot) Columns

func (s ScreenSnapshot) Columns() int

func (ScreenSnapshot) Cursor

func (s ScreenSnapshot) Cursor() CursorSnapshot

func (ScreenSnapshot) Graphics added in v0.4.0

func (s ScreenSnapshot) Graphics() *graphics.Snapshot

Graphics returns the immutable graphics scene snapshot for the active screen buffer, or nil when that buffer has not used Kitty graphics.

func (ScreenSnapshot) Modes

func (s ScreenSnapshot) Modes() ModeSnapshot

func (ScreenSnapshot) NextRowID

func (s ScreenSnapshot) NextRowID() RowID

NextRowID returns the next identity allocated by the captured screen.

func (ScreenSnapshot) Row

func (s ScreenSnapshot) Row(y int) []renderer.Cell

Row returns an owned copy of row y, or nil when y is out of range.

func (ScreenSnapshot) RowID

func (s ScreenSnapshot) RowID(y int) RowID

RowID returns the identity of visible row y, or zero when out of range.

func (ScreenSnapshot) RowIDs

func (s ScreenSnapshot) RowIDs() []RowID

RowIDs returns an owned copy of the visible physical-row identities.

func (ScreenSnapshot) Rows

func (s ScreenSnapshot) Rows() int

func (ScreenSnapshot) Title

func (s ScreenSnapshot) Title() string

type Style

type Style = core.Style

type StyleAttrs

type StyleAttrs = core.StyleAttrs

type UnderlineStyle

type UnderlineStyle = core.UnderlineStyle

Directories

Path Synopsis
Package ansi emits ANSI terminal output from the frontend-neutral github.com/bnema/vev-vt/core model.
Package ansi emits ANSI terminal output from the frontend-neutral github.com/bnema/vev-vt/core model.
cmd
graphics-harness command
Command graphics-harness renders Kitty graphics terminal input to a PNG for local development inspection.
Command graphics-harness renders Kitty graphics terminal input to a PNG for local development inspection.
Package vtcore defines the frontend-neutral terminal model shared by the VT emulator and concrete ANSI renderers.
Package vtcore defines the frontend-neutral terminal model shared by the VT emulator and concrete ANSI renderers.
Package graphics provides a renderer-neutral, bounded graphics scene.
Package graphics provides a renderer-neutral, bounded graphics scene.
internal
graphicsharness
Package graphicsharness provides a headless reference compositor for inspecting graphics snapshots during development.
Package graphicsharness provides a headless reference compositor for inspecting graphics snapshots during development.
protocol
kittygraphics
Package kittygraphics implements the bounded Kitty graphics protocol adapter.
Package kittygraphics implements the bounded Kitty graphics protocol adapter.
terminalquery
Package terminalquery provides bounded parsers for terminal capability probes.
Package terminalquery provides bounded parsers for terminal capability probes.

Jump to

Keyboard shortcuts

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