Documentation
¶
Overview ¶
Package liner implements a simple command line editor, inspired by linenoise (https://github.com/antirez/linenoise/). This package supports WIN32 in addition to the xterm codes supported by everything else.
Index ¶
Constants ¶
const HistoryLimit = 100
HistoryLimit is the maximum number of entries saved in the scrollback history.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Completer ¶
Completer takes the currently edited line and returns a list of completion candidates.
type State ¶
type State struct {
// contains filtered or unexported fields
}
func NewLiner ¶
func NewLiner() *State
NewLiner initializes a new *State, and sets the terminal into raw mode. To restore the terminal to its previous state, call State.Close(). NewLiner handles SIGWINCH, so it will leak a channel every time you call it. Therefore, it is recommened that NewLiner only be called once.
func (*State) AppendHistory ¶
AppendHistory appends an entry to the scrollback history. AppendHistory should be called iff Prompt returns a valid command.
func (*State) Prompt ¶
Prompt displays p, and then waits for user input. Prompt allows line editing if the terminal supports it.
func (*State) ReadHistory ¶
ReadHistory reads scrollback history from r. Returns the number of lines read, and any read error (except io.EOF).
func (*State) SetCompleter ¶
SetCompleter sets the completion function that Liner will call to fetch completion candidates when the user presses tab.