history

package
v1.22.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: Apache-2.0 Imports: 6 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 {
	Messages []string `json:"messages"`
	// contains filtered or unexported fields
}

func New

func New(opts ...Opt) (*History, error)

func (*History) Add

func (h *History) Add(message string) error

func (*History) FindNextContains added in v1.22.0

func (h *History) FindNextContains(query string, from int) (msg string, idx int, ok bool)

FindNextContains searches forward through history for a message containing query. from is an exclusive lower bound index. Pass -1 to start from the oldest. Returns the matched message, its index, and whether a match was found.

func (*History) FindPrevContains added in v1.22.0

func (h *History) FindPrevContains(query string, from int) (msg string, idx int, ok bool)

FindPrevContains searches backward through history for a message containing query. from is an exclusive upper bound index. Pass len(Messages) to start from the most recent. Returns the matched message, its index, and whether a match was found. An empty query matches any entry.

func (*History) LatestMatch added in v1.8.2

func (h *History) LatestMatch(prefix string) string

LatestMatch returns the most recent history entry that extends the provided prefix, or the latest message when no prefix is supplied.

func (*History) Next

func (h *History) Next() string

func (*History) Previous

func (h *History) Previous() string

func (*History) SetCurrent added in v1.22.0

func (h *History) SetCurrent(i int)

type Opt added in v1.8.2

type Opt func(*options)

func WithBaseDir added in v1.8.2

func WithBaseDir(dir string) Opt

Jump to

Keyboard shortcuts

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