Documentation
¶
Overview ¶
Package terminalinput configures byte-oriented local console input and observes terminal dimensions without owning remote terminal behavior.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeRaw ¶
MakeRaw disables local line editing, echo, and signal processing for an interactive input terminal. It returns the reader to use while raw mode is active and a function that restores the exact prior state.
The returned restore function must run exactly once on every exit path after MakeRaw succeeds. Non-terminal readers are unchanged and receive a no-op restore function.
func ReadLine ¶ added in v0.2.0
func ReadLine(ctx context.Context, input *os.File, output io.Writer, prompt string, secret bool) (value []byte, err error)
ReadLine reads one local terminal response, with optional echo suppression. It requires an actual terminal, restores its original mode on every exit, and supports Ctrl+C, EOF, backspace, and context cancellation. It starts no background input reader and does not consume bytes beyond the response. The caller owns and should clear the returned bytes when they are secret.
func WatchSize ¶ added in v0.2.0
func WatchSize(ctx context.Context, file *os.File, initial Size, resize func(cols, rows uint16) error) error
WatchSize synchronously forwards valid changes relative to the local initial measurement. It rechecks after subscribing to catch changes during connection setup. An unchanged local size preserves explicit initial remote dimensions. Linux/macOS use SIGWINCH; Windows polls without consuming console input events. Invalid or unavailable measurements are ignored until the next notification. ctx stops watching, but cannot interrupt an in-flight resize callback: callers must release its underlying I/O before joining WatchSize during shutdown.