flx

package module
v0.0.0-...-e86b932 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 4 Imported by: 0

README

Release Go Reference

flx.go

Rewrite emacs-flx in Go

CI

🔨 Usage

import "github.com/the-flx/flx.go"

fmt.Println(flx.Score("switch-to-buffer", "stb").Score)  // 237

🛠️ Development

To run tests:

$ go test ./test/

⚜️ License

flx.go is distributed under the terms of the MIT license.

See LICENSE for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BiggerSublist

func BiggerSublist(sorted []int, val *int) []int

Return sublist bigger than `val` from sorted `sorted`.

func Boundary

func Boundary(lastCh *rune, ch *rune) bool

Check if `lastCh` is the end of a word and `ch` the start of the next.

This function is camel-case aware.

func Capital

func Capital(ch *rune) bool

Check if `ch` is an uppercase character.

func FindBestMatch

func FindBestMatch(imatch *[]Result, strInfo map[int][]int, heatmap []int, greaterThan *int, query string, queryLen int, qIndex int, matchCache *map[int][]Result)

Recursively compute the best match for a string, passed as `strInfo` and `heatmap`, according to `query`.

func GetHashForString

func GetHashForString(str string) map[int][]int

Return map for string where keys are characters. Value is a sorted list of indexes for character occurrences.

func GetHeatmapStr

func GetHeatmapStr(str string, groupSeparator *rune) []int

Generate the heatmap vector of string.

See documentation for logic.

func IncVec

func IncVec(vec []int, inc *int, beg *int, end *int) []int

Increment each element in `vec` between `beg` and `end` by `INC`.

func Word

func Word(ch *rune) bool

Check if `ch` is a word character.

Types

type Result

type Result struct {
	Indices []int
	Score   int
	Tail    int
}

func Score

func Score(str string, query string) *Result

Return best score matching `query` against `str`.

Jump to

Keyboard shortcuts

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