Documentation
¶
Overview ¶
Package terminal implements a streaming VT screen and native shell sessions. It has no dependencies outside the Go standard library.
Index ¶
- Variables
- func RuneWidth(r rune) int
- type Cell
- type Color
- type Process
- type Screen
- func (s *Screen) Alternate() bool
- func (s *Screen) Clear()
- func (s *Screen) ClearOutput()
- func (s *Screen) Cursor() (int, int)
- func (s *Screen) Feed(data []byte)
- func (s *Screen) HistoryRow(index int) []Cell
- func (s *Screen) Replies() []byte
- func (s *Screen) Reset(cols, rows int)
- func (s *Screen) Resize(cols, rows int)
- func (s *Screen) TrimHistory()
- type Session
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("terminal session is closed")
var ErrInputFull = errors.New("terminal input queue is full")
var Palette = [16]Color{0x1e1e1e, 0xcd3131, 0x0dbc79, 0xe5e510, 0x2472c8, 0xbc3fbc, 0x11a8cd, 0xe5e5e5, 0x666666, 0xf14c4c, 0x23d18b, 0xf5f543, 0x3b8eea, 0xd670d6, 0x29b8db, 0xffffff}
Functions ¶
Types ¶
type Process ¶
type Process interface {
io.ReadWriteCloser
Resize(cols, rows int) error
Wait() error
}
type Screen ¶
type Screen struct {
Title string
Cells []Cell
History []historyCell
MouseTracking int
Cols, Rows int
Scrolled uint64
Revision uint64
HistoryLimit int
DefaultForeground, DefaultBackground Color
CursorVisible, ApplicationCursor, BracketedPaste bool
MouseSGR bool
// contains filtered or unexported fields
}
Screen is owned by the foreground. Feed accepts arbitrary byte boundaries.
func (*Screen) ClearOutput ¶
func (s *Screen) ClearOutput()
ClearOutput removes scrollback and all rows except the current input line. Keep the cursor coordinates in sync with applications such as Windows ConPTY, which can continue rendering with absolute cursor positions after a UI clear.
func (*Screen) HistoryRow ¶
HistoryRow borrows a decoded chronological row until the next HistoryRow or Resize call. Reading a warm row does not allocate.
func (*Screen) Reset ¶
Reset starts a fresh VT stream, retaining cell storage for repeated snapshots.
func (*Screen) TrimHistory ¶
func (s *Screen) TrimHistory()
TrimHistory releases oversized storage after replaying a shorter snapshot. Keep the physical row order so the ring head and combining indices stay valid.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session bounds both queues. Output applies backpressure instead of dropping bytes (dropping even one byte can corrupt a VT sequence). No worker touches UI.
func (*Session) Close ¶
func (s *Session) Close()
Close never waits for a process or pipe on the foreground thread.