vt

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package vt defines Loom's pane-display abstraction. An Emulator consumes raw PTY bytes from the tmux-client stream and renders the current visible screen as a string the UI prints verbatim. tmux remains the session owner; this is display only.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cursor

type Cursor struct {
	X, Y    int
	Visible bool
	Shape   CursorShape
	Blink   bool
}

Cursor is the visible cursor state in cells, 0-based, origin top-left. Visible reflects DECTCEM (apps hide the cursor while painting); Shape and Blink reflect DECSCUSR. The defaults — visible blinking block — match a fresh terminal.

type CursorShape added in v0.8.0

type CursorShape int

CursorShape is the visual form of the cursor, as set by DECSCUSR.

const (
	CursorShapeBlock CursorShape = iota
	CursorShapeUnderline
	CursorShapeBar
)

type Emulator

type Emulator interface {
	// Write feeds raw PTY bytes (ANSI/CSI/OSC/DCS) into the emulator. It
	// mirrors io.Writer so it can be the output pump's destination directly.
	Write(p []byte) (n int, err error)

	// Resize sets the emulator's screen geometry in cells.
	Resize(cols, rows int)

	// Render returns the current VISIBLE screen as a string with embedded
	// ANSI SGR sequences, sized to the last Resize. The UI prints this verbatim.
	Render() string

	// Cursor returns the current cursor position and visibility.
	Cursor() Cursor

	// Title returns the window title most recently set by the inner app via
	// OSC 0/2, or "" if never set.
	Title() string

	// SetBellFunc installs a handler invoked when the inner app rings BEL.
	// The handler runs inside Write on the pump goroutine — it must be
	// cheap, must not call back into the Emulator, and must be safe to
	// invoke concurrently with readers (tea.Program.Send qualifies).
	SetBellFunc(f func())

	// FocusReportingEnabled reports whether the inner app enabled focus
	// reporting (DEC private mode 1004). Focus in/out sequences must only
	// be forwarded while true — unsolicited CSI I/O is garbage input to
	// apps that never asked for it.
	FocusReportingEnabled() bool

	// Close releases emulator resources. Safe to call multiple times.
	Close() error
}

Emulator is the display surface for one pane. Implementations must be safe for one writer goroutine (the tmux output pump calling Write) concurrent with reader calls (Render/Cursor) from the Bubble Tea Update goroutine.

func NewXVT

func NewXVT(cols, rows int) Emulator

NewXVT constructs a real terminal emulator sized to cols x rows.

Jump to

Keyboard shortcuts

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