Documentation ¶
Index ¶
- Constants
- Variables
- func BeginReadKey() error
- func EndReadKey() error
- func Fatal(a ...interface{})
- func Fatalf(format string, a ...interface{})
- func Fatalln(a ...interface{})
- func Fatallnf(format string, a ...interface{})
- func GetSize() (int, int, error)
- func Print(a ...interface{}) (int, error)
- func PrintList(obj interface{}) error
- func Printf(format string, a ...interface{}) (int, error)
- func Println(a ...interface{}) (int, error)
- func Printlnf(format string, a ...interface{}) (int, error)
- func ReadLine() (string, error)
- func ReadPassword() (string, error)
- func SupportsColors() bool
- func WithReadKeyContext(f func() error) error
- type Input
- type Key
- type Output
Constants ¶
const ( // KeyEscape represents the escape key KeyEscape = Key(keyboard.KeyEsc) // KeyCtrlC represents the key combination Ctrl+C KeyCtrlC = Key(keyboard.KeyCtrlC) // KeyCtrlW represents the key combination Ctrl+W KeyCtrlW = Key(keyboard.KeyCtrlW) // KeyCtrlS represents the key combination Ctrl+S KeyCtrlS = Key(keyboard.KeyCtrlS) // KeyUp represents the arrow up key KeyUp = Key(keyboard.KeyArrowUp) // KeyDown represents the arrow down key KeyDown = Key(keyboard.KeyArrowDown) // KeyLeft represents the arrow left key KeyLeft = Key(keyboard.KeyArrowLeft) // KeyRight represents the arrow right key KeyRight = Key(keyboard.KeyArrowRight) // KeyHome represents the home (Pos1) key KeyHome = Key(keyboard.KeyHome) // KeyEnd represents the end key KeyEnd = Key(keyboard.KeyEnd) // KeyPageUp represents the page up key KeyPageUp = Key(keyboard.KeyPgup) // KeyPageDown represents the page down key KeyPageDown = Key(keyboard.KeyPgdn) // KeyBackspace represents the backspace key KeyBackspace = Key(keyboard.KeyBackspace2) // KeyDelete represents the delete key KeyDelete = Key(keyboard.KeyDelete) // KeyEnter represents the enter key KeyEnter = Key(keyboard.KeyEnter) // KeyTab represents the tabulator key KeyTab = Key(keyboard.KeyTab) // KeySpace represents the space key KeySpace = Key(keyboard.KeySpace) )
Variables ¶
var ( // DefaultInput can be used to redirect input sources. DefaultInput Input // DefaultOutput can be used to redirect output destinations. DefaultOutput Output )
Functions ¶
func BeginReadKey ¶ added in v0.9.9
func BeginReadKey() error
BeginReadKey opens a raw TTY and allows you to use ReadKey.
func EndReadKey ¶ added in v0.9.9
func EndReadKey() error
EndReadKey closes the raw TTY opened by BeginReadKey and discards all unprocessed key events.
func Fatalf ¶
func Fatalf(format string, a ...interface{})
Fatalf calls Printf and exits with code 1.
func Fatallnf ¶
func Fatallnf(format string, a ...interface{})
Fatallnf calls Printlnf and exits with code 1.
func PrintList ¶
func PrintList(obj interface{}) error
PrintList prints all array or map values in a regular grid.
func Println ¶
Println writes a set of objects separated by whitespaces to Stdout and ends the line.
func ReadLine ¶
ReadLine reads a line from Stdin.
This method should not be used in conjunction with Stdin read from other packages as it might leave an orphaned '\n' in the input buffer for '\r\n' line breaks.
func ReadPassword ¶
ReadPassword reads a line from Stdin while hiding the user input.
This method should not be used in conjunction with Stdin read from other packages as it might leave an orphaned '\n' in the input buffer for '\r\n' line breaks.
func SupportsColors ¶ added in v0.9.2
func SupportsColors() bool
SupportsColors returns true when the current terminal supports ANSI colors.
func WithReadKeyContext ¶ added in v0.9.3
WithReadKeyContext executes the given function with surrounding BeginReadKey and EndReadKey calls.
Types ¶
type Input ¶ added in v0.9.3
type Input interface { ReadLine() (string, error) ReadPassword() (string, error) BeginReadKey() error ReadKey() (Key, rune, error) EndReadKey() error }
Input defines functionality to handle console input.