fuzzy

package
v1.3.1 Latest Latest
Warning

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

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

README

fuzzy

Package fuzzy is a fully-featured fuzzy finder a la fzf. In fact, it makes use of fzf's actual agorithm, forked here as the fuzzy/fzf package.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BottomRight stories.InitFunc = func(ctx context.Context) (mux.Screen, error) {
	location := geom.DEFAULT_SIZE
	location.C -= 1
	location.R -= 1
	return New(
		ctx,
		pokemonText,
		WithInline(location, geom.DEFAULT_SIZE),
	), nil
}
View Source
var CommandTable stories.InitFunc = func(ctx context.Context) (mux.Screen, error) {
	return New(
		ctx,
		[]Option{
			newColumnOption("ll", "/foo/bar"),
			newColumnOption("ll", "/foo/bar"),
			newColumnOption("longer command", "/foo/bar"),
		},
		WithInline(geom.Size{}, geom.DEFAULT_SIZE),
	), nil
}
View Source
var FullBottom stories.InitFunc = func(ctx context.Context) (mux.Screen, error) {
	f := New(
		ctx,
		pokemonText,
	)
	return f, nil
}
View Source
var FullBottomTable stories.InitFunc = func(ctx context.Context) (mux.Screen, error) {
	f := New(
		ctx,
		pokemonTable,
		WithHeaders("Name", "#", "Type"),
	)
	return f, nil
}
View Source
var FullTop stories.InitFunc = func(ctx context.Context) (mux.Screen, error) {
	f := New(
		ctx,
		pokemonText,
		WithReverse,
	)
	return f, nil
}
View Source
var FullTopTable stories.InitFunc = func(ctx context.Context) (mux.Screen, error) {
	f := New(
		ctx,
		pokemonTable,
		WithReverse,
		WithHeaders("Name", "#", "Type"),
	)
	return f, nil
}
View Source
var Search stories.InitFunc = func(ctx context.Context) (mux.Screen, error) {
	f := New(
		ctx,
		pokemonText,
		WithInline(geom.Size{}, geom.DEFAULT_SIZE),
	)

	stories.Send(f, "Pid")
	return f, nil
}
View Source
var TopLeft stories.InitFunc = func(ctx context.Context) (mux.Screen, error) {
	return New(
		ctx,
		pokemonText,
		WithInline(geom.Size{}, geom.DEFAULT_SIZE),
	), nil
}
View Source
var TopLeftTable stories.InitFunc = func(ctx context.Context) (mux.Screen, error) {
	return New(
		ctx,
		pokemonTable,
		WithHeaders("Name", "#", "Type"),
		WithInline(geom.Size{}, geom.DEFAULT_SIZE),
	), nil
}

Functions

func New

func New(
	ctx context.Context,
	options []Option,
	settings ...Setting,
) *taro.Program

func WithReverse

func WithReverse(ctx context.Context, f *Fuzzy)

func WithSticky

func WithSticky(ctx context.Context, f *Fuzzy)

WithSticky makes it so Fuzzy cannot be quit by the user.

Types

type Fuzzy

type Fuzzy struct {
	util.Lifetime
	// contains filtered or unexported fields
}

func (*Fuzzy) Init

func (f *Fuzzy) Init() taro.Cmd

func (*Fuzzy) Update

func (f *Fuzzy) Update(msg tea.Msg) (taro.Model, tea.Cmd)

func (*Fuzzy) View

func (f *Fuzzy) View(state *tty.State)

type Match

type Match struct {
	Score int
	Index *[]int
}

type Option

type Option struct {
	Text    string
	Columns []string
	Preview interface{}
	Chars   *util.Chars
	Match   *Match
	Result  interface{}
}

func Filter

func Filter(
	options []Option,
	search string,
	caseSensitive bool,
) []Option

func NewOption

func NewOption(text string, result interface{}) Option

func UnmarshalOptions

func UnmarshalOptions(input *janet.Value) (result []Option, err error)

type SelectedEvent

type SelectedEvent struct {
	Option Option
}

type Setting

type Setting func(context.Context, *Fuzzy)

func WithAnimation

func WithAnimation(initial image.Image, creator anim.Creator) Setting

WithAnimation provides a specific animation to render in the background.

func WithCaseSensitive added in v0.5.0

func WithCaseSensitive(value bool) Setting

WithCaseSensitive determines whether the matching algorithm will be case-sensitive.

func WithHeaders

func WithHeaders(headers ...string) Setting

func WithInitial added in v0.3.0

func WithInitial(initial image.Image) Setting

WithInitial provides the initial background image. Used independently of WithAnimation to still support animation previews even if animation is turned off.

func WithInline

func WithInline(location, size geom.Vec2) Setting

Displays Fuzzy as a small window at this location on the screen.

func WithNodes

func WithNodes(
	tree *tree.Tree,
	server *server.Server,
) Setting

If both of these are provided, Fuzzy can show previews for panes.

func WithParams added in v0.12.0

func WithParams(params *params.Parameters) Setting

WithParams provides parameters this Fuzzy will use for rendering.

func WithPrompt

func WithPrompt(prompt string) Setting

func WithResult

func WithResult(result chan<- interface{}) Setting

func WithSize added in v0.11.0

func WithSize(size geom.Size) Setting

WithSize sets the desired size of the Fuzzy window. The width is only used if Fuzzy is not in full screen mode. A value of zero for either property implies no constraints.

Directories

Path Synopsis
fzf

Jump to

Keyboard shortcuts

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