Documentation
¶
Index ¶
- type In
- func (i *In) CheckTty(attachStdin, ttyMode bool) error
- func (i *In) Close() error
- func (i *In) FD() uintptr
- func (i *In) File() (*os.File, bool)
- func (i *In) IsTerminal() bool
- func (i *In) Read(p []byte) (int, error)
- func (i *In) RestoreTerminal()
- func (i *In) SetIsTerminal(isTerminal bool)
- func (i *In) SetRawTerminal() error
- type Out
- func (o *Out) FD() uintptr
- func (o *Out) File() (*os.File, bool)
- func (o *Out) GetTtySize() (height uint, width uint)
- func (o *Out) IsTerminal() bool
- func (o *Out) RestoreTerminal()
- func (o *Out) SetIsTerminal(isTerminal bool)
- func (o *Out) SetRawTerminal() error
- func (o *Out) Write(p []byte) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type In ¶
type In struct {
// contains filtered or unexported fields
}
In is an input stream to read user input. It implements io.ReadCloser with additional utilities, such as putting the terminal in raw mode.
func NewIn ¶
func NewIn(in io.ReadCloser) *In
NewIn returns a new In from an io.ReadCloser. If in is an *os.File, a reference is kept to the file, and accessible through In.File.
func (*In) CheckTty ¶
CheckTty reports an error when stdin is requested for a TTY-enabled container, but the client stdin is not itself a terminal (for example, when input is piped or redirected).
func (*In) File ¶
File returns the underlying *os.File if the stream was constructed from one. If the stream was created from a non-file (e.g., a pipe, buffer, or wrapper), the returned boolean will be false.
func (*In) IsTerminal ¶
IsTerminal returns whether this stream is connected to a terminal.
func (*In) RestoreTerminal ¶
func (i *In) RestoreTerminal()
RestoreTerminal restores the terminal state if SetRawTerminal succeeded earlier.
func (*In) SetIsTerminal ¶
SetIsTerminal overrides whether a terminal is connected. It is used to override this property in unit-tests, and should not be depended on for other purposes.
func (*In) SetRawTerminal ¶
SetRawTerminal sets raw mode on the input terminal. It is a no-op if In is not a TTY, or if the "NORAW" environment variable is set to a non-empty value.
type Out ¶
type Out struct {
// contains filtered or unexported fields
}
Out is an output stream to write normal program output. It implements an io.Writer, with additional utilities for detecting whether a terminal is connected, getting the TTY size, and putting the terminal in raw mode.
func NewOut ¶
NewOut returns a new Out from an io.Writer. If out is an *os.File, a reference is kept to the file, and accessible through Out.File.
func (*Out) File ¶
File returns the underlying *os.File if the stream was constructed from one. If the stream was created from a non-file (e.g., a pipe, buffer, or wrapper), the returned boolean will be false.
func (*Out) GetTtySize ¶
GetTtySize returns the height and width in characters of the TTY, or zero for both if no TTY is connected.
func (*Out) IsTerminal ¶
IsTerminal returns whether this stream is connected to a terminal.
func (*Out) RestoreTerminal ¶
func (o *Out) RestoreTerminal()
RestoreTerminal restores the terminal state if SetRawTerminal succeeded earlier.
func (*Out) SetIsTerminal ¶
SetIsTerminal overrides whether a terminal is connected. It is used to override this property in unit-tests, and should not be depended on for other purposes.
func (*Out) SetRawTerminal ¶
SetRawTerminal puts the output of the terminal connected to the stream into raw mode.
On UNIX, this does nothing. On Windows, it disables LF -> CRLF/ translation. It is a no-op if Out is not a TTY, or if the "NORAW" environment variable is set to a non-empty value.