fzf

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2024 License: MIT, MIT Imports: 8 Imported by: 0

README

fzf

This is a fork of fzf's matching algorithm.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEBUG bool

Functions

func Init

func Init(scheme string) bool

func NormalizeRunes

func NormalizeRunes(runes []rune) []rune

NormalizeRunes normalizes latin script letters

Types

type Algo

type Algo func(caseSensitive bool, normalize bool, forward bool, input *util.Chars, pattern []rune, withPos bool, slab *util.Slab) (Result, *[]int)

Algo functions make two assumptions 1. "pattern" is given in lowercase if "caseSensitive" is false 2. "pattern" is already normalized if "normalize" is true

type Result

type Result struct {
	// TODO int32 should suffice
	Start int
	End   int
	Score int
}

Result contains the results of running a match function.

func EqualMatch

func EqualMatch(caseSensitive bool, normalize bool, forward bool, text *util.Chars, pattern []rune, withPos bool, slab *util.Slab) (Result, *[]int)

EqualMatch performs equal-match

func ExactMatchNaive

func ExactMatchNaive(caseSensitive bool, normalize bool, forward bool, text *util.Chars, pattern []rune, withPos bool, slab *util.Slab) (Result, *[]int)

ExactMatchNaive is a basic string searching algorithm that handles case sensitivity. Although naive, it still performs better than the combination of strings.ToLower + strings.Index for typical fzf use cases where input strings and patterns are not very long.

Since 0.15.0, this function searches for the match with the highest bonus point, instead of stopping immediately after finding the first match. The solution is much cheaper since there is only one possible alignment of the pattern.

func FuzzyMatchV1

func FuzzyMatchV1(caseSensitive bool, normalize bool, forward bool, text *util.Chars, pattern []rune, withPos bool, slab *util.Slab) (Result, *[]int)

FuzzyMatchV1 performs fuzzy-match

func FuzzyMatchV2

func FuzzyMatchV2(caseSensitive bool, normalize bool, forward bool, input *util.Chars, pattern []rune, withPos bool, slab *util.Slab) (Result, *[]int)

func PrefixMatch

func PrefixMatch(caseSensitive bool, normalize bool, forward bool, text *util.Chars, pattern []rune, withPos bool, slab *util.Slab) (Result, *[]int)

PrefixMatch performs prefix-match

func SuffixMatch

func SuffixMatch(caseSensitive bool, normalize bool, forward bool, text *util.Chars, pattern []rune, withPos bool, slab *util.Slab) (Result, *[]int)

SuffixMatch performs suffix-match

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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