term

package
v0.24.2 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT, Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventAPC

type EventAPC struct {
	Payload string
}

EventAPC is emitted when an APC sequence is received in the terminal

type EventBell

type EventBell struct{}

EventBell is emitted when BEL is received

type EventClosed

type EventClosed struct {
	Term  *Model
	Error error
}

type EventMouseShape

type EventMouseShape struct {
	Shape vaxis.MouseShape
}

type EventNotify

type EventNotify struct {
	Title string
	Body  string
}

type EventPanic

type EventPanic error

type EventProgress

type EventProgress struct {
	State       ProgressState
	Progress    int
	HasProgress bool
}

type EventTitle

type EventTitle string

type EventWorkingDirectory

type EventWorkingDirectory struct {
	URL string
}

type Image

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

type Model

type Model struct {
	// If true, OSC8 enables the output of OSC8 strings. Otherwise, any OSC8
	// sequences will be stripped
	OSC8 bool
	// Set the TERM environment variable to be passed to the command's
	// environment. If not set, xterm-256color will be used unless Kitty
	// keyboard passthrough is enabled.
	TERM string
	// EnableKittyKeyboard allows child applications to negotiate Kitty keyboard
	// protocol state through the terminal widget. Only enable this when the
	// host terminal supports Kitty keyboard encoding.
	EnableKittyKeyboard bool
	// AllowKeyboardActionMode allows ANSI KAM (SM 2) to suppress keyboard input.
	// It is disabled by default because applications can otherwise make the
	// terminal ignore user typing.
	AllowKeyboardActionMode bool
	// EnquiryResponse is written to the child PTY in response to ENQ (0x05).
	// Empty means ENQ is ignored.
	EnquiryResponse string
	// contains filtered or unexported fields
}

Model models a virtual terminal

func New

func New(opts ...Option) *Model

func (*Model) Attach

func (vt *Model) Attach(fn func(ev vaxis.Event))

func (*Model) AttachUI

func (vt *Model) AttachUI(fn func(ui.Event))

AttachUI attaches a UI-native terminal event handler.

func (*Model) Blur

func (vt *Model) Blur()

func (*Model) ClearSelection

func (vt *Model) ClearSelection()

func (*Model) Close

func (vt *Model) Close()

func (*Model) Detach

func (vt *Model) Detach()

func (*Model) Draw

func (vt *Model) Draw(win vaxis.Window)

func (*Model) Focus

func (vt *Model) Focus()

func (*Model) HasSelection

func (vt *Model) HasSelection() bool

func (*Model) Resize

func (vt *Model) Resize(w int, h int)

func (*Model) RowString

func (vt *Model) RowString(row int) string

RowString returns the visible text for one viewport row. Out-of-range rows return an empty string. Empty cells are returned as spaces.

func (*Model) Rows

func (vt *Model) Rows() []string

Rows returns the visible viewport text split into rows. Empty cells are returned as spaces.

func (*Model) Selection

func (vt *Model) Selection() string

func (*Model) Snapshot

func (vt *Model) Snapshot() Snapshot

Snapshot returns the terminal's current visible cells and cursor state.

Snapshot does not include terminal graphics; callers that need graphics should continue to use Draw with a vaxis.Window.

func (*Model) Start

func (vt *Model) Start(cmd *exec.Cmd) error

Start starts the terminal with the specified command. Start returns when the command has been successfully started.

func (*Model) StartWithSize

func (vt *Model) StartWithSize(cmd *exec.Cmd, width int, height int) error

func (*Model) String

func (vt *Model) String() string

func (*Model) Update

func (vt *Model) Update(msg vaxis.Event)

Update is called from the host application. This is user input

func (*Model) Write

func (vt *Model) Write(p []byte) (int, error)

Write applies terminal output to the terminal model.

This is useful for embedding an in-memory terminal model in tests or demos. PTY-backed terminals should normally receive output through Start/StartWithSize.

func (*Model) WriteString

func (vt *Model) WriteString(s string)

WriteString applies terminal output to the terminal model.

This is useful for embedding an in-memory terminal model in tests or demos. PTY-backed terminals should normally receive output through Start/StartWithSize.

type Option

type Option func(*Model)

func WithEnquiryResponse

func WithEnquiryResponse(response string) Option

func WithKeyboardActionMode

func WithKeyboardActionMode(enabled bool) Option

WithKeyboardActionMode controls whether ANSI KAM (SM 2) is honored for terminal input. When enabled, KAM suppresses key and paste input while set.

func WithKittyKeyboard

func WithKittyKeyboard(enabled bool) Option

WithKittyKeyboard controls Kitty keyboard passthrough directly. Most callers should prefer WithVaxis so passthrough follows detected host capabilities.

func WithVaxis

func WithVaxis(vx *vaxis.Vaxis) Option

WithVaxis attaches the host Vaxis instance used to render this terminal. Kitty keyboard passthrough is enabled only when the host terminal advertised support to Vaxis.

type PositionedCell

type PositionedCell struct {
	Col  int
	Row  int
	Cell vaxis.Cell
}

PositionedCell is one visible terminal cell at a viewport position.

type ProgressState

type ProgressState int
const (
	ProgressRemove ProgressState = iota
	ProgressSet
	ProgressError
	ProgressIndeterminate
	ProgressPause
)

type Snapshot

type Snapshot struct {
	Cells         []PositionedCell
	CursorCol     int
	CursorRow     int
	CursorStyle   vaxis.CursorStyle
	CursorVisible bool
}

Snapshot is a UI-friendly immutable view of the terminal's visible cells and cursor state.

type Terminal

type Terminal struct {
	// Model is an optional pre-created terminal model.
	Model *Model
	// Command is started in a PTY when Model is nil.
	Command *exec.Cmd
	// Options are passed to New when Model is nil.
	Options []Option
	// AutoFocus requests focus for the terminal after it is built.
	AutoFocus bool
	// OnEvent receives terminal-generated events on the UI event loop.
	OnEvent func(ui.EventContext, ui.Event) ui.EventResult
}

Terminal adapts Model to the ui widget framework.

If Model is nil, Terminal creates and owns a model using Options and starts Command when it first receives a non-zero layout size. If Model is non-nil, the caller owns the model and Terminal only adapts layout, painting, focus, and events.

func (Terminal) CreateState

func (w Terminal) CreateState() ui.State

Directories

Path Synopsis
Package pty provides pseudo-terminal support for the terminal widget.
Package pty provides pseudo-terminal support for the terminal widget.

Jump to

Keyboard shortcuts

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