Documentation
¶
Overview ¶
Package linenoise wraps the linenoise library (https://github.com/antirez/linenoise).
The package is imported with "go." prefix
import "github.com/GeertJohan/go.linenoise"
Simple readline usage:
linenoise.Line("prompt> ")
Adding lines to history, you could simply do this for every line you read.
linenoise.AddHistory("This will be displayed in prompt when arrow-up is pressed")
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(c CompletionHandler)
- func SetHistoryCapacity(capacity int) error
- func SetMultiline(ml bool)
- type CompletionHandler
Constants ¶
This section is empty.
Variables ¶
var DefaultCompletionHandler = func(input string) []string { return make([]string, 0) }
DefaultCompletionHandler simply returns an empty slice.
var KillSignalError = errors.New("prompt was quited with a killsignal")
KillSignalError 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(c CompletionHandler)
SetCompletionHandler sets the CompletionHandler to be used for completion
func SetHistoryCapacity ¶
SetHistoryCapacity changes the maximum length of history. Returns non-nil error on fail.
func SetMultiline ¶
func SetMultiline(ml 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