go_input_history

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2022 License: MIT Imports: 1 Imported by: 0

README

go_input_history

Package input history contains structs and methods to aid in developing cli ui's with input history

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type History

type History struct {
	Max   int
	Data  []string
	Index int
	// contains filtered or unexported fields
}

History struct to hold the history of the user input

func New

func New(max int) *History

New history struct

func (*History) Add

func (h *History) Add(line string)

Add line to history

func (*History) Get

func (h *History) Get(index int) string

Get history at index

func (*History) HasLine

func (h *History) HasLine(line string) bool

HasLine will return true if the history buffer contains the given string

func (*History) IsEmpty

func (h *History) IsEmpty() bool

IsEmpty return true if the history data array is empty

func (*History) Next

func (h *History) Next() string

Next returns the history line after the current index

func (*History) Prev

func (h *History) Prev() string

Prev returns the previous history line from the current index

func (*History) SetIndexToNew

func (h *History) SetIndexToNew()

SetIndexToNew sets the index to the new elements index

Jump to

Keyboard shortcuts

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