Documentation
¶
Overview ¶
Package terminal provides a pipe-based terminal backend for grut. It starts a shell process with piped stdin/stdout/stderr and captures output into a scrollback buffer. This is a v1 implementation using plain pipes; full PTY emulation can be added later.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultShell ¶
func DefaultShell() string
DefaultShell returns the platform-appropriate default shell. On Windows it returns "cmd.exe"; on Unix it checks $SHELL and falls back to "/bin/sh".
Types ¶
type Runner ¶
type Runner interface {
// Write sends data to the shell's stdin.
Write(data []byte) error
// Lines returns a snapshot of the current output lines (thread-safe).
Lines() []string
// Close kills the shell process and waits for it to exit.
Close() error
// Done returns a channel that is closed when the shell process exits.
Done() <-chan struct{}
// ExitCode returns the process exit code, or -1 if still running.
ExitCode() int
}
Runner abstracts the terminal backend so that panels can use a mock implementation in tests.
type Terminal ¶
type Terminal struct {
// contains filtered or unexported fields
}
Terminal manages a shell process with piped stdin/stdout/stderr. It reads output in background goroutines and stores lines in a thread-safe scrollback buffer with a configurable maximum.
func New ¶
New starts a shell process and begins reading its output. If shell is empty, DefaultShell() is used. If maxLines is <= 0, it defaults to 10000.
func (*Terminal) Close ¶
Close closes stdin, kills the process if still running, and waits for the done channel to be closed.
func (*Terminal) Done ¶
func (t *Terminal) Done() <-chan struct{}
Done returns a channel that is closed when the shell process exits.
func (*Terminal) ExitCode ¶
ExitCode returns the process exit code. Returns -1 if the process is still running or was killed.