Documentation
¶
Overview ¶
Package screen keeps the visible terminal screen of a session in a VT emulator (charmbracelet/x/vt) and renders it for attached clients: a full ANSI snapshot to resynchronize a client, and per-client diffs that redraw only the rows changed since that client's previous frame.
Only the visible screen is kept in memory; scrollback lives on disk as raw bytes (package scrollback).
Index ¶
- Constants
- func ClampSize(cols, rows int) (int, int)
- type Differ
- type Screen
- func (s *Screen) AppCursorKeys() bool
- func (s *Screen) BracketedPaste() bool
- func (s *Screen) Close()
- func (s *Screen) Resize(cols, rows int) (int, int)
- func (s *Screen) Size() (cols, rows int)
- func (s *Screen) Snapshot() []byte
- func (s *Screen) SnapshotDiffer() ([]byte, *Differ)
- func (s *Screen) Title() string
- func (s *Screen) Write(p []byte)
Constants ¶
const (
MinCols, MaxCols = 2, 500
MinRows, MaxRows = 2, 250
DefaultCols = 80
DefaultRows = 24
)
Size limits. Both screens (main and alternate) hold one cell struct per position, so an absurd size requested by a client must not become an absurd allocation.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Differ ¶
type Differ struct {
// contains filtered or unexported fields
}
Differ renders screen-mode frames for one client.
type Screen ¶
type Screen struct {
// contains filtered or unexported fields
}
Screen is a session's emulated terminal screen. All methods are safe for concurrent use.
func New ¶
New returns a screen of the given size. respond receives the emulator's replies to terminal queries (DA, DSR/CPR, DECRQM, colour queries, ...); pass nil when a real terminal answers them (passthrough), otherwise forward them to the program (detached). respond must not block for long and must not call into the Screen.
func (*Screen) AppCursorKeys ¶
AppCursorKeys reports whether the program enabled DECCKM (cursor keys send SS3 sequences).
func (*Screen) BracketedPaste ¶
BracketedPaste reports whether the program enabled DECSET 2004.
func (*Screen) Close ¶
func (s *Screen) Close()
Close stops the reply drain. The screen stays readable.
func (*Screen) Resize ¶
Resize changes the screen size (clamped with ClampSize) and returns the size in effect.
func (*Screen) Snapshot ¶
Snapshot returns ANSI that reproduces the current screen on a cleared terminal of the same size, and leaves that terminal in the state the program's next bytes expect: cursor position and visibility, current pen, scroll region, autowrap. When the alternate screen is active, the main screen is drawn first and the alternate screen entered on top of it, so a later switch back shows the right content. Used for raw-mode resets.
func (*Screen) SnapshotDiffer ¶
SnapshotDiffer returns a full frame of the current screen (for a screen-mode client, sent with reset) and a Differ whose next Frame is relative to that snapshot. The frame carries content, cursor position and visibility only; screen-mode clients never receive pen or scroll-region state.