linenoise clone in Go
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples/ssh
.gitignore
.travis.yml
LICENSE.md
README.md
editor.go
editor_test.go

README.md

Linesqueak

Build Status

Linesqueak is a simple pure-Go line editor. It speaks to io.Reader and io.Writer instead of pty/tty, which makes it easy to integrate with network based applications (see examples/ssh).

It is inspired by Linenoise.

Features

  • Standard Key Bindings
  • History
  • Completion
  • Hints

Basic Usage

e := &linesqueak.Editor{
	In:     bufio.NewReader(r), // `r` is `io.Reader` (e.g. `ssh.Channel`)
	Out:    bufio.NewWriter(w), // `w` is `io.Writer` (e.g. `ssh.Channel`)
	Prompt: "> ",               // you can be creative here :)
}

// you may want to process multiple lines
// if so, call `Line()` in a loop
for {
	line, err := e.Line() // `Line()` does all the editor things and returns input line
	if err != nil {
		panic(err) // TODO: proper error handling
	}
	
	fmt.Fprintf(e.Out, "\ryou have typed: %s\n", line)
}

Similar Projects

License

See the LICENSE file for license rights and limitations (MIT).