terminalstate

package
v1.5.49 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package terminalstate preserves the host's kernel TTY state across an embedded terminal UI, including failures before its event loop starts. It does not read input, close borrowed files or reset terminal protocols.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Guard

type Guard struct {
	// contains filtered or unexported fields
}

Guard borrows terminal files; keeping them referenced prevents a finalizer from closing/reusing a descriptor before restoration. It never opens /dev/tty.

func Capture

func Capture(files ...*os.File) (Guard, error)

Capture must run before a UI takes raw mode. Pipes and absent files are ignored; a terminal whose state cannot be saved fails before ownership changes.

func (Guard) Restore

func (g Guard) Restore() error

Restore is a backstop for upstream Run early-error paths that leave ECHO, ICANON or ISIG disabled. A completed normal UI restoration is harmless to repeat. Failed network delivery of mouse/keyboard reset sequences is a separate issue.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL