Documentation ¶
Overview ¶
Package editor provides simple readline functionality for Go programs.
Index ¶
- Variables
- func GetLine(prompt string) (string, error)
- func GetPass(prompt string) (string, error)
- type Editor
- type History
- func (self *History) Add(line string)
- func (self *History) Clear()
- func (self *History) Delete(id int)
- func (self *History) Enum(id int, fn func(id int, line string) bool)
- func (self *History) Get(id int, dir int) (int, string)
- func (self *History) Len() int
- func (self *History) Read(reader io.Reader) (err error)
- func (self *History) Reset()
- func (self *History) SetCap(cap int)
- func (self *History) Write(writer io.Writer) (err error)
Constants ¶
This section is empty.
Variables ¶
DefaultEditor is the default Editor.
Functions ¶
Types ¶
type Editor ¶
type Editor struct {
// contains filtered or unexported fields
}
Editor is a command line editor with history and completion handling.
func (*Editor) SetCompletionHandler ¶
SetCompletionHandler sets a completion handler.
type History ¶
type History struct {
// contains filtered or unexported fields
}
History maintains a buffer of command lines.
func (*History) Clear ¶
func (self *History) Clear()
Clear clears all command lines from the history buffer.
func (*History) Delete ¶
Delete deletes a command line from the history buffer. The special id's of 0 or -1 mean to delete the first or last command line respectively.
func (*History) Enum ¶
Enum enumerates all command lines in the history buffer starting at id. The special id's of 0 or -1 mean to start the enumeration with the first or last command line respectively.
func (*History) Get ¶
Get gets a command line from the history buffer.
Command lines are identified by an integer id. The special id's of 0 or -1 mean to retrieve the first or last command line respectively. The dir parameter is used to determine which command line to retrieve relative to the one identified by id: 0 is the current command line, +1 is the next command line, -1 is the previous command line, etc. When retrieving command lines the history is treated as a circular buffer.