history

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type History

type History struct {
	// contains filtered or unexported fields
}

History is a ring buffer for command history strings.

func New

func New(size int) *History

New returns a History with the given size.

func (*History) Add

func (hist *History) Add(s string)

Add appends a new history entry.

func (*History) At

func (hist *History) At(n int) string

At returns the entry at index n.

func (*History) Export

func (hist *History) Export(w io.Writer) error

Export writes all history entries to w.

func (*History) Import

func (hist *History) Import(r io.Reader) error

Import loads history entries from r.

func (*History) Len

func (hist *History) Len() int

Len returns the number of entries currently buffered.

func (*History) Size

func (hist *History) Size() int

Size returns the capacity of the history buffer.

type HistoryFile

type HistoryFile struct {
	*History
	// contains filtered or unexported fields
}

HistoryFile stores history entries backed by a file.

func NewFile

func NewFile(size int, path string) *HistoryFile

NewFile returns a new HistoryFile.

func (*HistoryFile) Load

func (hf *HistoryFile) Load() (err error)

Load imports history entries from the file.

func (*HistoryFile) Save

func (hf *HistoryFile) Save() (err error)

Save writes history entries to the file.

Jump to

Keyboard shortcuts

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