{"modulePath":"code.cloudfoundry.org/cli-sapi","version":"v6.1.1+incompatible","isLatest":false,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package terminal\n\nPackage terminal provides support functions for dealing with terminals, as commonly found on UNIX systems.\n\nPutting a terminal into raw mode is the most common requirement:\n\n\toldState, err := terminal.MakeRaw(0)\n\tif err != nil {\n\t        panic(err)\n\t}\n\tdefer terminal.Restore(0, oldState)\n\n## Functions\n\n```go\nfunc GetSize(fd int) (width, height int, err error)\n```\nGetSize returns the dimensions of the given terminal.\n\n```go\nfunc IsTerminal(fd int) bool\n```\nIsTerminal returns true if the given file descriptor is a terminal.\n\n```go\nfunc ReadPassword(fd int) ([]byte, error)\n```\nReadPassword reads a line of input from a terminal without local echo.  This is commonly used for inputting passwords and other sensitive data. The slice returned does not include the \\\\n.\n\n```go\nfunc Restore(fd int, state *State) error\n```\nRestore restores the terminal connected to the given file descriptor to a previous state.\n\n## Types\n\n```go\ntype EscapeCodes struct {\n\t// Foreground colors\n\tBlack, Red, Green, Yellow, Blue, Magenta, Cyan, White []byte\n\n\t// Reset all attributes\n\tReset []byte\n}\n```\nEscapeCodes contains escape sequences that can be written to the terminal in order to achieve different styles of text.\n\n```go\ntype State struct {\n\t// contains filtered or unexported fields\n}\n```\nState contains the state of a terminal.\n\n```go\nfunc GetState(fd int) (*State, error)\n```\nGetState returns the current state of a terminal which may be useful to restore the terminal after a signal.\n\n```go\nfunc MakeRaw(fd int) (*State, error)\n```\nMakeRaw put the terminal connected to the given file descriptor into raw mode and returns the previous state of the terminal so that it can be restored.\n\n```go\ntype Terminal struct {\n\t// AutoCompleteCallback, if non-null, is called for each keypress with\n\t// the full input line and the current position of the cursor (in\n\t// bytes, as an index into |line|). If it returns ok=false, the key\n\t// press is processed normally. Otherwise it returns a replacement line\n\t// and the new cursor position.\n\tAutoCompleteCallback func(line string, pos int, key rune) (newLine string, newPos int, ok bool)\n\n\t// Escape contains a pointer to the escape codes for this terminal.\n\t// It's always a valid pointer, although the escape codes themselves\n\t// may be empty if the terminal doesn't support them.\n\tEscape *EscapeCodes\n\t// contains filtered or unexported fields\n}\n```\nTerminal contains the state for running a VT100 terminal that is capable of reading lines of input.\n\n```go\nfunc NewTerminal(c io.ReadWriter, prompt string) *Terminal\n```\nNewTerminal runs a VT100 terminal on the given ReadWriter. If the ReadWriter is a local terminal, that terminal must first have been put into raw mode. prompt is a string that is written at the start of each input line (i.e. \"\u003e \").\n\n```go\nfunc (t *Terminal) ReadLine() (line string, err error)\n```\nReadLine returns a line of input from the terminal.\n\n```go\nfunc (t *Terminal) ReadPassword(prompt string) (line string, err error)\n```\nReadPassword temporarily changes the prompt and reads a password, without echo, from the terminal.\n\n```go\nfunc (t *Terminal) SetPrompt(prompt string)\n```\nSetPrompt sets the prompt to be used when reading subsequent lines.\n\n```go\nfunc (t *Terminal) SetSize(width, height int)\n```\n\n```go\nfunc (t *Terminal) Write(buf []byte) (n int, err error)\n```\n\n","path":"code.cloudfoundry.org/cli-sapi/src/code.google.com/p/go.crypto/ssh/terminal","name":"terminal","synopsis":"Package terminal provides support functions for dealing with terminals, as commonly found on UNIX systems.","isRedistributable":true}
