Documentation
¶
Overview ¶
Package term hosts terminal emulation for agent panes behind the VT interface.
Index ¶
- Constants
- func EncodeKey(k uv.KeyPressEvent, m KeyModes) []byte
- func EncodePaste(text string, bracketed bool) []byte
- func PaneEnv(base []string) []string
- type Command
- func AgentCommand(env func(string) string, dir string, argv, extraEnv []string) Command
- func EditorCommand(env func(string) string, dir, editor string, args, extraEnv []string) Command
- func EditorOnlyCommand(env func(string) string, dir, editor string, args, extraEnv []string) Command
- func ShellCommand(env func(string) string, dir string, extraEnv []string) Command
- type KeyModes
- type Process
- func (p *Process) Close() error
- func (p *Process) Cwd() (string, error)
- func (p *Process) Done() <-chan struct{}
- func (p *Process) Foreground() (string, error)
- func (p *Process) Pid() int
- func (p *Process) Read(b []byte) (int, error)
- func (p *Process) Resize(cols, rows int) error
- func (p *Process) Write(b []byte) (int, error)
- type TextCell
- type VT
Constants ¶
const ScrollbackLines = 10000
ScrollbackLines is the scrollback depth of every pane emulator.
Variables ¶
This section is empty.
Functions ¶
func EncodeKey ¶
func EncodeKey(k uv.KeyPressEvent, m KeyModes) []byte
EncodeKey returns the bytes a key press sends to a guest with the given modes, or nil.
func EncodePaste ¶
EncodePaste sanitises text and wraps it in bracketed-paste markers when bracketed is true.
Types ¶
type Command ¶
Command is a program to run on a PTY. Env is the complete child environment.
func AgentCommand ¶
AgentCommand runs argv in an interactive login shell, then stays in a shell when the agent exits. argv reaches the shell as separate arguments after a fixed script, so nothing in it is parsed. argv must not be empty.
func EditorCommand ¶
EditorCommand runs editor with args in an interactive login shell, then stays in a shell when the editor exits. The shell reads editor as git reads $EDITOR, so a value such as `code -w` runs code with -w; args reach the shell as separate arguments after a fixed script, so nothing in them is parsed. editor comes from the operator's own environment and must not be empty.
type Process ¶
type Process struct {
// contains filtered or unexported fields
}
Process is a child running on a pseudo terminal in its own session.
func (*Process) Close ¶
Close sends SIGHUP to the leader's process group and to the terminal's foreground group (a job-control shell runs its commands in their own group), waits for the child and closes the master. After a second it escalates to SIGKILL and closes the master before waiting. It is idempotent.
func (*Process) Cwd ¶
Cwd is the working directory of the terminal's foreground process group, which follows a `cd` in the shell or whatever it is running.
func (*Process) Done ¶
func (p *Process) Done() <-chan struct{}
Done is closed after the child has been waited for.
func (*Process) Foreground ¶
Foreground is the name of the terminal's foreground process group leader.
func (*Process) Read ¶
Read returns io.EOF when the child closes the terminal; EIO is the normal end of stream on Linux.
type TextCell ¶
TextCell is one history cell's text: no style, no link. Content is empty for the spacer after a wide character, and aliases history storage, so a callback must not keep it.
type VT ¶
type VT interface {
Write(p []byte) (int, error)
Resize(cols, rows int)
Size() (cols, rows int)
CellAt(x, y int) *uv.Cell // nil outside the grid
Cursor() (pos uv.Position, visible bool)
ScrollbackLen() int
// ScrollbackText calls fn with the text of history lines [from, end), oldest
// first, until it returns false. Blank lines are skipped. It decodes no styles.
ScrollbackText(from, end int, fn func(i int, cells []TextCell) bool)
ScrollbackLine(i int) []uv.Cell // copy of history line i (0 oldest); nil out of range
ScrollbackWrapped(i int) bool // history line i soft-wraps into i+1
HistoryTrimmed() uint64 // lines dropped from the front of the history so far: ring overwrite, CSI 3J, reflow
RowWrapped(y int) bool // live row y soft-wraps into y+1
AltScreen() bool
MouseTracking() bool // guest enabled any of mouse modes 9, 1000, 1001, 1002, 1003
SendMouse(ev uv.MouseEvent) // encoded per the guest's modes onto the reply stream; nothing when tracking is off
SetClipboardHandler(fn func(selection, content string)) // guest OSC 52 writes; runs on the goroutine calling Write under the pane lock, so it must only enqueue
SyncState() (open bool, serial uint64) // raw DEC 2026; serial bumps on each closed-to-open edge
Title() string // last OSC 0/2 title
WorkingDir() string // last OSC 7 path (file URL decoded to a path), "" if none
FocusReporting() bool // DECSET 1004
KeyModes() KeyModes // for EncodeKey
BracketedPaste() bool // DECSET 2004
SetDefaultColors(fg, bg color.Color) // answers OSC 10 and 11 queries; mode 2031 guests get a notice on change
SendBytes(b []byte) // raw bytes queued on the reply stream, ordered with query replies
SendKey(k uv.KeyPressEvent) // EncodeKey with the current KeyModes; unencodable keys send nothing
Close() error // idempotent: emulator Close, then wait for the drain
}
VT is one pane's emulator. Not safe for concurrent use; the pane serialises calls.