completion

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FuzzyMatchRunes

func FuzzyMatchRunes(sChars, sub []rune) bool

Types

type CompletionManager

type CompletionManager struct {
	Selected int // -1 means nothing one is selected.
	Max      int

	VerticalScroll int
	WordSeparator  string
	// contains filtered or unexported fields
}

CompletionManager manages which suggestion is now selected.

func NewCompletionManager

func NewCompletionManager(max int) *CompletionManager

NewCompletionManager returns initialized CompletionManager object.

func (*CompletionManager) GetSelectedSuggestion

func (c *CompletionManager) GetSelectedSuggestion() (s *Suggest)

GetSelectedSuggestion returns the selected item.

func (*CompletionManager) GetSuggestions

func (c *CompletionManager) GetSuggestions() []*Suggest

GetSuggestions returns the list of suggestion.

func (*CompletionManager) Next

func (c *CompletionManager) Next()

Next to select the next suggestion item.

func (*CompletionManager) Previous

func (c *CompletionManager) Previous()

Previous to select the previous suggestion item.

func (*CompletionManager) Reset

func (c *CompletionManager) Reset()

Reset to select nothing.

func (*CompletionManager) Update

func (c *CompletionManager) Update(in []*Suggest)

Update to update the suggestions.

type Filter

type Filter func([]*Suggest, string, bool) []*Suggest

Filter is the type to filter the prompt.Suggestion array.

type Suggest

type Suggest struct {
	Text        string
	Description string
}

Suggest is printed when completing.

func FilterContains

func FilterContains(completions []*Suggest, sub string, ignoreCase bool) []*Suggest

FilterContains checks whether the completion.Text contains sub.

func FilterFuzzy

func FilterFuzzy(completions []*Suggest, sub string, ignoreCase bool) []*Suggest

FilterFuzzy checks whether the completion.Text fuzzy matches sub. Fuzzy searching for "dog" is equivalent to "*d*o*g*". This search term would match, for example, "Good food is gone"

^  ^      ^

func FilterHasPrefix

func FilterHasPrefix(completions []*Suggest, sub string, ignoreCase bool) []*Suggest

FilterHasPrefix checks whether the string completions.Text begins with sub.

func FilterHasSuffix

func FilterHasSuffix(completions []*Suggest, sub string, ignoreCase bool) []*Suggest

FilterHasSuffix checks whether the completion.Text ends with sub.

Jump to

Keyboard shortcuts

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