Categorygithub.com/ergochat/readline
modulepackage
0.1.3
Repository: https://github.com/ergochat/readline.git
Documentation: pkg.go.dev

# README

readline

Godoc

This is a pure Go implementation of functionality comparable to GNU Readline, i.e. line editing and command history for simple TUI programs.

It is a fork of chzyer/readline.

  • Relative to the upstream repository, it is actively maintained and has numerous bug fixes
    • See our changelog for details on fixes and improvements
    • See our migration guide for advice on how to migrate from upstream
  • Relative to x/term, it has more features (e.g. tab-completion)
  • In use by multiple projects: gopass, fq, and ircdog
package main

import (
	"fmt"
	"log"

	"github.com/ergochat/readline"
)

func main() {
	// see readline.NewFromConfig for advanced options:
	rl, err := readline.New("> ")
	if err != nil {
		log.Fatal(err)
	}
	defer rl.Close()
	log.SetOutput(rl.Stderr()) // redraw the prompt correctly after log output

	for {
		line, err := rl.ReadLine()
		// `err` is either nil, io.EOF, readline.ErrInterrupt, or an unexpected
		// condition in stdin:
		if err != nil {
			return
		}
		// `line` is returned without the terminating \n or CRLF:
		fmt.Fprintf(rl, "you wrote: %s\n", line)
	}
}

# Packages

No description provided by the author

# Functions

New creates a readline instance with default configuration.
NewFromConfig creates a readline instance from the specified configuration.
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
NewEx is an alias for NewFromConfig, for compatibility.

# Structs

No description provided by the author
No description provided by the author
PrefixCompleter implements AutoCompleter via a recursive tree.

# Interfaces

No description provided by the author

# Type aliases

Listener is a callback type to listen for keypresses while the line is being edited.
Painter is a callback type to allow modifying the buffer before it is rendered on screen, for example, to implement real-time syntax highlighting.