vterm

package
v0.10.8 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package vterm is a minimal in-process VT100/xterm screen emulator. It replaces tmux's pane rendering for the native session backend: the session host feeds raw PTY output into a Terminal, and Capture returns the rendered plain-text tail the way `tmux capture-pane -p -J` used to. It models only what peek/capture needs — a character grid, scrollback history, cursor motion, erase/insert/delete, scroll regions, and the alternate screen. Colors and attributes (SGR) are tracked per cell so Redraw can repaint a re-attaching client faithfully; Capture output stays plain text by contract, exactly like the old capture-pane path.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Terminal

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

Terminal is a virtual terminal. It is not goroutine-safe; the session host serializes access behind its own lock.

func New

func New(cols, rows, maxHistory int) *Terminal

New returns a Terminal with the given grid size and scrollback capacity.

func (*Terminal) Capture

func (t *Terminal) Capture(maxLines int) string

Capture renders the last maxLines lines of the terminal as plain text: scrollback history plus the active screen, with soft-wrapped lines joined (the capture-pane -J contract) and trailing blank lines trimmed. The result ends with a newline when non-empty.

func (*Terminal) FocusReporting

func (t *Terminal) FocusReporting() bool

FocusReporting reports whether the agent has focus reporting (DEC private mode 1004) enabled. The session host uses it to synthesize focus events at attach and detach boundaries: a real terminal tells the application when its window gains or loses focus, and an agent running under a detached host would otherwise never hear either.

func (*Terminal) Redraw

func (t *Terminal) Redraw() []byte

Redraw returns an ANSI byte sequence that repaints the current screen on a fresh terminal: reset attributes, clear, draw every row with the SGR state each cell was written with, and park the cursor. The session host sends it to a newly attached client so the user sees the live screen — colors included — immediately.

func (*Terminal) Resize

func (t *Terminal) Resize(cols, rows int)

Resize changes the grid size, preserving as much content as fits. Scroll regions reset to full height (matching xterm). Rows dropped from the top of the main screen move into history.

func (*Terminal) Size

func (t *Terminal) Size() (cols, rows int)

func (*Terminal) Write

func (t *Terminal) Write(p []byte) (int, error)

Write feeds raw PTY output into the emulator. It never fails; implementing io.Writer keeps the host's reader loop a plain io pipeline.

Jump to

Keyboard shortcuts

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