Documentation
¶
Index ¶
- type DirectRenderer
- type Session
- type SessionBackend
- type TermView
- type TmuxSession
- func (ts *TmuxSession) Alive() bool
- func (ts *TmuxSession) Close() error
- func (ts *TmuxSession) Read(buf []byte) (int, error)
- func (ts *TmuxSession) Render() string
- func (ts *TmuxSession) Resize(cols, rows int) error
- func (ts *TmuxSession) SessionName() string
- func (ts *TmuxSession) Write(data []byte) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DirectRenderer ¶
type DirectRenderer interface {
Render() string
}
DirectRenderer is an optional interface that backends can implement when their output is already rendered terminal text (e.g., tmux capture-pane). SessionView checks for this: if present, it skips the VT emulator and uses Render() directly. If absent, output goes through the VT emulator.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session manages a PTY-backed subprocess. It provides thread-safe read, write, and resize operations for embedding interactive terminal processes.
func (*Session) Alive ¶
Alive returns true if the session is still open and the process has not exited.
func (*Session) Close ¶
Close terminates the PTY session. It closes the PTY file descriptor and signals the process to exit, but does not block waiting for the process to finish. Cleanup runs in a background goroutine so the TUI returns immediately. It is safe to call multiple times.
type SessionBackend ¶
type SessionBackend interface {
Read(buf []byte) (int, error)
Write(data []byte) (int, error)
Resize(cols, rows int) error
Close() error
Alive() bool
}
SessionBackend is the common interface for terminal session backends. The direct PTY backend (Session) and the tmux mirror backend (TmuxSession) both implement this interface. SessionView works with either.
type TermView ¶
type TermView struct {
// contains filtered or unexported fields
}
TermView wraps a charmbracelet/x/vt terminal emulator, providing a thread-safe interface for writing PTY output and rendering the screen buffer as an ANSI-styled string.
func NewTermView ¶
NewTermView creates a new TermView with the given column and row dimensions.
type TmuxSession ¶
type TmuxSession struct {
// contains filtered or unexported fields
}
TmuxSession mirrors a tmux session's pane content. It polls `tmux capture-pane` for output and forwards keystrokes via `tmux send-keys`. This allows embedding any TUI (Codex, Gemini) inside aimux's split view.
func AttachTmux ¶
func AttachTmux(sessionName string, cols, rows int) (*TmuxSession, error)
AttachTmux mirrors an existing tmux session without creating it. The session is left running when Close is called.
func StartTmux ¶
StartTmux creates a new tmux session running cmd, then mirrors it. The session is killed when Close is called.
func (*TmuxSession) Alive ¶
func (ts *TmuxSession) Alive() bool
Alive returns true if the tmux session still exists.
func (*TmuxSession) Close ¶
func (ts *TmuxSession) Close() error
Close stops polling. If the session was created by StartTmux, it kills the tmux session. If it was attached via AttachTmux, the session continues running.
func (*TmuxSession) Read ¶
func (ts *TmuxSession) Read(buf []byte) (int, error)
Read returns captured pane content. Blocks until data is available or the session is closed.
func (*TmuxSession) Render ¶
func (ts *TmuxSession) Render() string
Render returns the latest captured pane content. This implements the DirectRenderer interface, allowing SessionView to skip the VT emulator and display the tmux output directly (it's already rendered terminal text).
func (*TmuxSession) Resize ¶
func (ts *TmuxSession) Resize(cols, rows int) error
Resize changes the tmux window dimensions.
func (*TmuxSession) SessionName ¶
func (ts *TmuxSession) SessionName() string
SessionName returns the tmux session name for external reference.