Documentation
¶
Overview ¶
Package ptyproxy is the client-side PTY proxy used by `godo attach` (and the in-pane attach inside the TUI). It puts stdin in raw mode, forwards PTY output to stdout, sends SIGWINCH events as resize frames, and watches for a configurable detach key sequence.
Index ¶
- Variables
- func Banner(target string, seq []byte) string
- func FormatDetachSequence(seq []byte) string
- func ParseDetachSequence(s string) ([]byte, error)
- func Run(stream Stream, opts ...Option) error
- func RunOn(stream Stream, stdin *os.File, stdout io.Writer, opts ...Option) error
- type Option
- type Stream
Constants ¶
This section is empty.
Variables ¶
var DefaultDetachSequence = []byte{0x18, 'd'} // Ctrl+X, d
DefaultDetachSequence is the default detach hotkey: Ctrl+X then 'd'. Two bytes so the prefix Ctrl+X alone (an emacs/readline prefix) doesn't fire a detach. Avoids the mode-prefix keys of tmux (Ctrl+B), screen (Ctrl+A), and zellij (Ctrl+G/P/T/N/H/S/O/Q) — Docker's Ctrl+P,Ctrl+Q collides with zellij's pane-mode + quit and tears down the whole session.
Functions ¶
func Banner ¶
Banner returns the one-line connection notice printed before raw mode is enabled. Both `godo attach` and the TUI's in-pane attach emit this so users always see the detach shortcut at the moment of entry.
Style: dim ANSI escape so it sits visually below whatever the child process renders. Plain ASCII fallback if the caller's terminal strips escapes (the bytes are still readable).
func FormatDetachSequence ¶
FormatDetachSequence renders a byte sequence as the human-readable "Ctrl+P Ctrl+Q" form for the banner and docs.
func ParseDetachSequence ¶
ParseDetachSequence interprets a comma-separated spec (e.g. "Ctrl+P,Ctrl+Q" or "Ctrl+B,d") into a byte sequence. Whitespace around commas is ignored; the "Ctrl+" prefix is case-insensitive. Single ASCII characters pass through as their byte value.
func Run ¶
Run takes over the calling process's stdin/stdout to proxy to and from stream. It puts stdin in raw mode (if it's a tty), forwards SIGWINCH events as resize frames, and watches for the configured detach key sequence. Returns nil on detach or clean stream EOF.
Caller does not need to do their own terminal cleanup — Run restores state on every return path.
Types ¶
type Option ¶
type Option func(*config)
Option configures Run / RunOn behaviour.
func WithDetachSequence ¶
WithDetachSequence overrides the default detach hotkey. nil or empty resets to DefaultDetachSequence.