Documentation
¶
Index ¶
- type EventAPC
- type EventBell
- type EventClosed
- type EventMouseShape
- type EventNotify
- type EventPanic
- type EventProgress
- type EventTitle
- type EventWorkingDirectory
- type Image
- type Model
- func (vt *Model) Attach(fn func(ev vaxis.Event))
- func (vt *Model) AttachUI(fn func(ui.Event))
- func (vt *Model) Blur()
- func (vt *Model) ClearSelection()
- func (vt *Model) Close()
- func (vt *Model) Detach()
- func (vt *Model) Draw(win vaxis.Window)
- func (vt *Model) Focus()
- func (vt *Model) HasSelection() bool
- func (vt *Model) Resize(w int, h int)
- func (vt *Model) RowString(row int) string
- func (vt *Model) Rows() []string
- func (vt *Model) Selection() string
- func (vt *Model) Snapshot() Snapshot
- func (vt *Model) Start(cmd *exec.Cmd) error
- func (vt *Model) StartWithSize(cmd *exec.Cmd, width int, height int) error
- func (vt *Model) String() string
- func (vt *Model) Update(msg vaxis.Event)
- func (vt *Model) Write(p []byte) (int, error)
- func (vt *Model) WriteString(s string)
- type Option
- type PositionedCell
- type ProgressState
- type Snapshot
- type Terminal
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 EventClosed ¶
type EventMouseShape ¶
type EventMouseShape struct {
Shape vaxis.MouseShape
}
type EventNotify ¶
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 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 (*Model) ClearSelection ¶
func (vt *Model) ClearSelection()
func (*Model) HasSelection ¶
func (*Model) RowString ¶
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 ¶
Rows returns the visible viewport text split into rows. Empty cells are returned as spaces.
func (*Model) 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 ¶
Start starts the terminal with the specified command. Start returns when the command has been successfully started.
func (*Model) StartWithSize ¶
func (*Model) Write ¶
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 ¶
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 WithKeyboardActionMode ¶
WithKeyboardActionMode controls whether ANSI KAM (SM 2) is honored for terminal input. When enabled, KAM suppresses key and paste input while set.
func WithKittyKeyboard ¶
WithKittyKeyboard controls Kitty keyboard passthrough directly. Most callers should prefer WithVaxis so passthrough follows detected host capabilities.
type PositionedCell ¶
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.