Documentation ¶
Overview ¶
Package terminal provides functionality for terminals.
Index ¶
- Variables
- func AnsiEscapeCode(code string) string
- func Escape(s string, delims string, escape func(string) string) string
- func GetSize(fd uintptr) (int, int, error)
- func IsAnsiTerminal(fd uintptr) bool
- func IsTerminal(fd uintptr) bool
- func NewEscapeWriter(writer io.Writer, delims string, escape func(string) string) io.Writer
- func NewReader(r io.Reader) io.Reader
- func NullEscapeCode(code string) string
- func SetState(fd uintptr, s State) error
- type State
Constants ¶
This section is empty.
Variables ¶
var Stderr io.Writer
var Stdout io.Writer
Functions ¶
func AnsiEscapeCode ¶
AnsiEscapeCode translates a named escape code to its ANSI equivalent.
func Escape ¶
Escape replaces escape code instances within a string. Escape codes must be delimited using the delimiters in the delims parameter, which has the syntax "START END". For example, to use {{ and }} as delimiters specify "{{ }}".
For consistency with NewEscapeWriter, Escape will discard an unterminated escape code. For example, if delims is "{{ }}" and the string s is "hello {{world", the resulting string will be "hello ".
func IsAnsiTerminal ¶
IsAnsiTerminal determines if the file descriptor describes a terminal that has ANSI capabilities.
func IsTerminal ¶
IsTerminal determines if the file descriptor describes a terminal.
func NewEscapeWriter ¶
NewEscapeWriter replaces escape code instances within a string. Escape codes must be delimited using the delimiters in the delims parameter, which has the syntax "START END". For example, to use {{ and }} as delimiters specify "{{ }}".
Because NewEscapeWriter is an io.Writer it cannot know when the last Write will be received. For this reason it will discard an unterminated escape code. For example, if delims is "{{ }}" and the string s is "hello {{world", the resulting string will be "hello ".
func NullEscapeCode ¶
NullEscapeCode translates a named escape code to the empty string. It is used to eliminate escape codes.