Documentation
¶
Overview ¶
Package fuzzyfinder provides terminal user interfaces for fuzzy-finding.
Note that, all functions are not goroutine-safe.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrAbort is returned from Find* functions if there are no selections. ErrAbort = errors.New("abort") )
Functions ¶
func Find ¶
Find displays a fuzzy-finder UI over items and returns the indices of the selected entries, or ErrAbort if the user cancels. With Opt.Multi=false, the returned slice always has exactly one element.
Pass lock=nil for a static slice. Pass a non-nil lock when the slice may grow concurrently — the picker re-snapshots under lock on a 30ms cadence.
Types ¶
type Opt ¶ added in v0.8.0
type Opt struct {
// Prompt is the string drawn before the query. Defaults to "> ".
Prompt string
// Header is a static line displayed above the items.
Header string
// Query pre-fills the picker's query.
Query string
// SelectOne auto-selects the only matching item without showing the UI.
SelectOne bool
// Reverse renders the prompt at the top with items growing downward.
// Default is bottom-up (prompt at bottom).
Reverse bool
// Multi lets the user select multiple items via Tab. When false, the
// returned slice always has exactly one element.
Multi bool
// Height controls inline rendering.
// 0 fullscreen (alt-screen)
// N>0 exactly N rows at the bottom; prior output preserved above
// N<0 terminal_rows + N
// Honored only by the default litescreen renderer; ignored when the
// FF_RENDERER=legacy escape hatch is set (tcell can't preserve
// terminal scrollback).
Height int
}
Opt configures a fuzzy-finder run. The zero value is valid; only set the fields you want to override.
type TerminalMock ¶
type TerminalMock struct {
tcell.SimulationScreen
}
TerminalMock is a mocked terminal for testing. Use NewWithMockedTerminal to create one.
func (*TerminalMock) GetResult ¶
func (m *TerminalMock) GetResult() string
GetResult returns a flushed string that is displayed to the actual terminal. It contains all escape sequences such that ANSI escape code.
func (*TerminalMock) SetEvents ¶
func (m *TerminalMock) SetEvents(events ...tcell.Event)
SetEvents sets all events, which are fetched from the terminal event channel. A user of this must set the EscKey event at the end.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package matching filters a slice of strings against a query using case-insensitive, whitespace-split substring matching: an item matches when it contains every whitespace-delimited word in the query (any order).
|
Package matching filters a slice of strings against a query using case-insensitive, whitespace-split substring matching: an item matches when it contains every whitespace-delimited word in the query (any order). |