rawmode

package
v0.0.0-...-89b28be Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package rawmode provides a minimal set of functions to enter and exit raw input mode. Entering raw mode requires a system call which is OS specific. This package collects all these syscall functions.

The implementation has been largely inspired by golang.org/x/term but has been simplified as well as adopted for the specific needs and direction of this module.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsTerminal

func IsTerminal(fd uintptr) bool

IsTerminal returns true, iff fd references an input channel connected to a terminal.

func Restore

func Restore(fd uintptr, state *State) error

Restore restores the terminal state on the input channel pointed to by fd with state. It returns any error that might happen during the system call.

func Size

func Size(fd uintptr) (width, height int, err error)

Size returns the terminal's dimension in character slots. fd should be the file descriptor referencing the input channel of the terminal.

Types

type State

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

State represents an opaque value describing the OS specific state a terminal was in when entering raw mode. It can only be used to be restored which means leaving raw mode.

func Enter

func Enter(fd uintptr) (*State, error)

Enter enters raw input mode for the input file descriptor fd. This is usually os.Stdin.Fd() but may be selected differently for specific applications. Enter performs the required system calls and returns an opaque State which describes the terminal state before entering raw mode. Restoring that state later means to exit raw mode and return to canonical mode. In case the operation fails a non-nil error is returned and State is undefined.

Jump to

Keyboard shortcuts

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