termstate

package module
v0.0.0-...-57f4ce7 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2016 License: MIT Imports: 3 Imported by: 3 modules, 2 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.

README

termstate

Simple terminal state settings.

Description

This is a simple lib to set/reset cbreak and echo modes in Go.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeferredReset

func DeferredReset(modifiers ...modifier) func()

DeferredReset is a convenience function for setting modes on the current state, then resetting them later.

Example usage:

defer termstate.DeferredReset(
  termstate.State.Cbreak,
  termstate.State.EchoOff,
)()

func IsSupported

func IsSupported() bool

IsSupported indicates whether termstate is supported on this platform.

Types

type State

type State syscall.Termios

State holds information about a terminal.

func Get

func Get() (State, error)

Get fetches the current terminal state for stdin.

func GetFD

func GetFD(fd int) (state State, err error)

GetFD fetches the current terminal state for the given file descriptor.

func (State) Cbreak

func (state State) Cbreak() State

Cbreak adds `cbreak` (also called `rare`) mode to the state.

func (State) Echo

func (state State) Echo(on bool) State

Echo sets the `ECHO` and `ECHONL` properties.

func (State) EchoOff

func (state State) EchoOff() State

EchoOff is for use in `DeferredReset` (equivalent to `Echo(false)`).

func (State) EchoOn

func (state State) EchoOn() State

EchoOn is for use in `DeferredReset` (equivalent to `Echo(true)`).

func (State) Set

func (state State) Set() (oldstate State, err error)

Set attempts to set the terminal state for stdin.

func (State) SetFD

func (state State) SetFD(fd int) (oldstate State, err error)

SetFD attempts to set the terminal to this `State`, returning the original state and or an error.

Directories

Path Synopsis
examples
readchars command

Jump to

Keyboard shortcuts

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