Documentation
¶
Overview ¶
Package ttyin reads a terminal in raw mode in a way another goroutine can interrupt: a read waits on the terminal and on a pipe at once, so a program that is done with the terminal can end a read that is still blocked, rather than leave a goroutine behind that takes the next key typed into the shell.
Where the descriptors cannot be waited on (Windows, or a descriptor past what select(2) takes on macOS) a read blocks on the terminal alone and cannot be woken; Reader.Wakes reports which of the two applies.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrWoken = errors.New("ttyin: read woken")
ErrWoken is what Reader.Read returns when Reader.Wake ended it rather than input.
Functions ¶
This section is empty.
Types ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader reads from a terminal and can be woken.
func (*Reader) Close ¶
func (r *Reader) Close()
Close lets go of the pipe. Call it once no read is in progress any more.
func (*Reader) Read ¶
Read blocks until the terminal has input and reads it into p, or until Wake was called, when it returns ErrWoken and reads nothing.