editline

package module
v0.0.0-...-4451ab3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

README

go-editline

PkgGoDev

Go bindings for the editline.

Installation

This library depends on editline and requires it to be installed beforehand. You can refer to the following link for instructions on how to build and install editline: https://github.com/troglobit/editline#build--install.

go get github.com/maolonglong/go-editline

Usage

Some useful hints on how to use the library is available in the examples/ directory.

package main

import (
	"fmt"
	"io"

	"github.com/maolonglong/go-editline"
)

func main() {
	defer editline.Uninitialize()

	for {
		line, err := editline.ReadLine("> ")
		if err != nil {
			if err == io.EOF {
				break
			}
			panic(err)
		}

		fmt.Println(line)
	}
}

Documentation

Overview

Package editline provides Go bindings for editline.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHistroy

func AddHistroy(line string)

AddHistroy adds a line to the editline history.

func Initialize

func Initialize()

Initialize initializes the editline library.

There is no need to call it manually as it will be initialized automatically.

func ReadHistroy

func ReadHistroy(filename string) error

ReadHistroy reads the editline history from a file.

func ReadLine

func ReadLine(prompt string) (string, error)

ReadLine displays the given prompt on stdout, waits for user input on stdin and then returns a line of text with the trailing newline removed.

Each line returned is automatically saved in the internal history list, unless it happens to be equal to the previous line.

func SetCompleteFunc

func SetCompleteFunc(f CompleteFunc)

SetCompleteFunc sets the complete function that will be called during tab completion.

func SetHistSize

func SetHistSize(i int)

SetHistSize sets the maximum size of the history.

func SetListPossibFunc

func SetListPossibFunc(f ListPossibFunc)

SetListPossibFunc sets the list possibilities function that will be called during tab completion.

func SetNoEcho

func SetNoEcho(b bool)

SetNoEcho sets whether or not to echo the input in the terminal.

func SetNoHist

func SetNoHist(b bool)

SetNoHist sets whether or not to enable auto-save and access to history.

func Uninitialize

func Uninitialize()

Uninitialize frees all internal memory.

func WriteHistroy

func WriteHistroy(filename string) error

WriteHistroy writes the editline history to a file.

Types

type CompleteFunc

type CompleteFunc func(token string) (s string, matched bool)

CompleteFunc equals rl_complete_func_t.

type ListPossibFunc

type ListPossibFunc func(token string) []string

ListPossibFunc equals rl_list_possib_func_t.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL