Documentation ¶
Overview ¶
Package linenoise wraps the linenoise library (https://github.com/yhirose/linenoise).
Index ¶
- Variables
- func AddHistory(line string) error
- func Clear()
- func Line(prompt string) (string, error)
- func LoadHistory(filename string) error
- func PrintKeyCodes()
- func SaveHistory(filename string) error
- func SetCompletionHandler(h CompletionHandler)
- func SetHintColor(color uint8, bold bool) error
- func SetHintHandler(h HintHandler)
- func SetHistoryCapacity(capacity int) error
- func SetMaskMode(enable bool)
- func SetMultiline(enable bool)
- type CompletionHandler
- type HintHandler
Constants ¶
This section is empty.
Variables ¶
var ErrKillSignal = errors.New("Prompt was quited with a kill signal")
ErrKillSignal is returned returned by Line() when a user quits from prompt. This occurs when the user enters ctrl+C or ctrl+D.
Functions ¶
func AddHistory ¶
AddHistory adds a line to history. Returns non-nil error on fail
func LoadHistory ¶
LoadHistory loads from file with given filename. Returns non-nil error on fail
func PrintKeyCodes ¶
func PrintKeyCodes()
PrintKeyCodes puts linenoise in key codes debugging mode. Press keys and key combinations to see key codes. Type 'quit' at any time to exit. PrintKeyCodes blocks until user enters 'quit'.
func SaveHistory ¶
SaveHistory saves from file with given filename. Returns non-nil error on fail
func SetCompletionHandler ¶
func SetCompletionHandler(h CompletionHandler)
SetCompletionHandler sets the CompletionHandler to be used for completion (using Tab key)
You can pass nil as the handler to remove the previously set handler
func SetHintColor ¶
SetHintColor sets hint text color to color with given ANSI code
Color codes: https://github.com/essentialkaos/fmtc/wiki#816-colors
func SetHintHandler ¶
func SetHintHandler(h HintHandler)
SetHintHandler sets the HintHandler to be used for input hints
You can pass nil as the handler to remove the previously set handler
func SetHistoryCapacity ¶
SetHistoryCapacity changes the maximum length of history. Returns non-nil error on fail
func SetMaskMode ¶ added in v3.4.0
func SetMaskMode(enable bool)
SetMaskMode sets mask mode. When it is enabled, instead of the input that the user is typing, the terminal will just display a corresponding number of asterisks, like "****". This is useful for passwords and other secrets that should not be displayed.
func SetMultiline ¶
func SetMultiline(enable bool)
SetMultiline sets linenoise to multiline or single line. In multiline mode the user input will be wrapped to a new line when the length exceeds the amount of available rows in the terminal.
Types ¶
type CompletionHandler ¶
CompletionHandler provides possible completions for given input
type HintHandler ¶
HintHandler provides hint for user input