Documentation
¶
Overview ¶
Package fzf implements fzf, a command-line fuzzy finder.
Index ¶
- Constants
- func CountItems(cs []*Chunk) int
- func GetLastDelimiter(str string, delimiter Delimiter) string
- func JoinTokens(tokens []Token) string
- func RangesToString(ranges []Range) string
- func Run(opts *Options) (int, error)
- func StripLastDelimiter(str string, delimiter Delimiter) string
- func WriteTemporaryFile(data []string, printSep string) string
- type ByRelevance
- type ByRelevanceTac
- type Case
- type Chunk
- type ChunkBitmap
- type ChunkCache
- type ChunkList
- type Delimiter
- type History
- type Item
- type ItemBuilder
- type MatchRequest
- type MatchResult
- type Matcher
- type Merger
- type Offset
- type Options
- type Pattern
- type Range
- type Reader
- type Result
- type Status
- type StatusItem
- type Terminal
- func (t *Terminal) Input() (bool, []rune)
- func (t *Terminal) Loop() error
- func (t *Terminal) MaxFitAndPad() (int, int)
- func (t *Terminal) PauseRendering()
- func (t *Terminal) ResumeRendering()
- func (t *Terminal) UpdateCount(cnt int, final bool, failedCommand *string)
- func (t *Terminal) UpdateHeader(header []Item)
- func (t *Terminal) UpdateList(result MatchResult)
- func (t *Terminal) UpdateProgress(progress float32)
- type Token
Constants ¶
const ( EvtReadNew util.EventType = iota EvtReadFin EvtSearchNew EvtSearchProgress EvtSearchFin EvtReady EvtQuit )
fzf events
const ( ExitOk = 0 ExitNoMatch = 1 ExitError = 2 ExitBecome = 126 ExitInterrupt = 130 )
const Usage = `` /* 13170-byte string literal not displayed */
Variables ¶
This section is empty.
Functions ¶
func GetLastDelimiter ¶ added in v0.67.0
func JoinTokens ¶ added in v0.60.0
JoinTokens concatenates the tokens into a single string
func RangesToString ¶ added in v0.58.0
func StripLastDelimiter ¶ added in v0.60.0
StripLastDelimiter removes the trailing delimiter
func WriteTemporaryFile ¶
Types ¶
type ByRelevance ¶
type ByRelevance []Result
ByRelevance is for sorting Items
func (ByRelevance) Len ¶
func (a ByRelevance) Len() int
func (ByRelevance) Less ¶
func (a ByRelevance) Less(i, j int) bool
func (ByRelevance) Swap ¶
func (a ByRelevance) Swap(i, j int)
type ByRelevanceTac ¶
type ByRelevanceTac []Result
ByRelevanceTac is for sorting Items
func (ByRelevanceTac) Len ¶
func (a ByRelevanceTac) Len() int
func (ByRelevanceTac) Less ¶
func (a ByRelevanceTac) Less(i, j int) bool
func (ByRelevanceTac) Swap ¶
func (a ByRelevanceTac) Swap(i, j int)
type Chunk ¶
type Chunk struct {
// contains filtered or unexported fields
}
Chunk is a list of Items whose size has the upper limit of chunkSize
type ChunkBitmap ¶ added in v0.71.0
type ChunkBitmap [chunkBitWords]uint64
ChunkBitmap is a bitmap with one bit per item in a chunk.
type ChunkCache ¶
type ChunkCache struct {
// contains filtered or unexported fields
}
ChunkCache associates Chunk and query string to bitmaps
func (*ChunkCache) Add ¶
func (cc *ChunkCache) Add(chunk *Chunk, key string, bitmap ChunkBitmap, matchCount int)
Add stores the bitmap for the given chunk and key
func (*ChunkCache) Clear ¶
func (cc *ChunkCache) Clear()
func (*ChunkCache) Lookup ¶
func (cc *ChunkCache) Lookup(chunk *Chunk, key string) *ChunkBitmap
Lookup returns the bitmap for the exact key
func (*ChunkCache) Search ¶
func (cc *ChunkCache) Search(chunk *Chunk, key string) *ChunkBitmap
Search finds the bitmap for the longest prefix or suffix of the key
type ChunkList ¶
type ChunkList struct {
// contains filtered or unexported fields
}
ChunkList is a list of Chunks
func NewChunkList ¶
func NewChunkList(cache *ChunkCache, trans ItemBuilder) *ChunkList
NewChunkList returns a new ChunkList
func (*ChunkList) ForEachItem ¶ added in v0.70.0
ForEachItem iterates all items and applies fn to each one. The done callback runs under the lock to safely update shared state.
type Delimiter ¶
type Delimiter struct {
// contains filtered or unexported fields
}
Delimiter for tokenizing the input
type History ¶
type History struct {
// contains filtered or unexported fields
}
History struct represents input history
type Item ¶
type Item struct {
// contains filtered or unexported fields
}
Item represents each input line. 56 bytes.
func (*Item) Colors ¶
func (item *Item) Colors() []ansiOffset
Colors returns ansiOffsets of the Item
func (*Item) TrimLength ¶
type ItemBuilder ¶
ItemBuilder is a closure type that builds Item object from byte array
type MatchRequest ¶
type MatchRequest struct {
// contains filtered or unexported fields
}
MatchRequest represents a search request
type MatchResult ¶ added in v0.66.0
type MatchResult struct {
// contains filtered or unexported fields
}
type Matcher ¶
type Matcher struct {
// contains filtered or unexported fields
}
Matcher is responsible for performing search
func NewMatcher ¶
func NewMatcher(cache *ChunkCache, patternBuilder func([]rune) *Pattern, sort bool, tac bool, eventBox *util.EventBox, revision revision, threads int) *Matcher
NewMatcher returns a new Matcher
func (*Matcher) CancelScan ¶ added in v0.70.0
func (m *Matcher) CancelScan()
CancelScan cancels any in-flight scan, waits for it to finish, and prevents new scans from starting until ResumeScan is called. This is used to safely mutate shared items (e.g., during with-nth changes).
func (*Matcher) Reset ¶
func (m *Matcher) Reset(chunks []*Chunk, patternRunes []rune, cancel bool, final bool, sort bool, revision revision)
Reset is called to interrupt/signal the ongoing search
func (*Matcher) ResumeScan ¶ added in v0.70.0
func (m *Matcher) ResumeScan()
ResumeScan allows scans to proceed again after CancelScan.
type Merger ¶
type Merger struct {
// contains filtered or unexported fields
}
Merger holds a set of locally sorted lists of items and provides the view of a single, globally-sorted list
func NewMerger ¶
func NewMerger(pattern *Pattern, lists [][]Result, sorted bool, tac bool, revision revision, minIndex int32, maxIndex int32) *Merger
NewMerger returns a new Merger
func PassMerger ¶
PassMerger returns a new Merger that simply returns the items in the original order. startIndex items are skipped from the beginning.
type Offset ¶
type Offset [2]int32
Offset holds two 32-bit integers denoting the offsets of a matched substring
type Options ¶
type Options struct {
Input chan string
Output chan string
NoWinpty bool
Tmux *tmuxOptions
ForceTtyIn bool
ProxyScript string
Bash bool
Zsh bool
Fish bool
Nushell bool
Man bool
Fuzzy bool
FuzzyAlgo algo.Algo
Scheme string
Extended bool
Phony bool
Inputless bool
Case Case
Normalize bool
Nth []Range
FreezeLeft int
FreezeRight int
WithNth func(Delimiter) func([]Token, int32) string
WithNthExpr string
AcceptNth func(Delimiter) func([]Token, int32) string
Delimiter Delimiter
Sort int
Raw bool
Track trackOption
IdNth []Range
Tac bool
Tail int
Criteria []criterion
Multi int
Ansi bool
Mouse bool
BaseTheme *tui.ColorTheme
Theme *tui.ColorTheme
Black bool
Bold bool
Height heightSpec
MinHeight int
Layout layoutType
Cycle bool
Wrap bool
WrapWord bool
WrapSign *string
PreviewWrapSign *string
MultiLine bool
CursorLine bool
KeepRight bool
Hscroll bool
HscrollOff int
ScrollOff int
FileWord bool
InfoStyle infoStyle
InfoPrefix string
InfoCommand string
Ghost string
Separator *string
JumpLabels string
Prompt string
Gutter *string
GutterRaw *string
Pointer *string
Marker *string
MarkerMulti *[3]string
Query string
Select1 bool
Exit0 bool
Filter *string
ToggleSort bool
Expect map[tui.Event]string
Keymap map[tui.Event][]*action
Preview previewOpts
PrintQuery bool
ReadZero bool
Printer func(string)
PrintSep string
Sync bool
History *History
Header []string
HeaderLines int
HeaderFirst bool
Gap int
GapLine *string
Ellipsis *string
Scrollbar *string
Margin [4]sizeSpec
Padding [4]sizeSpec
BorderShape tui.BorderShape
ListBorderShape tui.BorderShape
InputBorderShape tui.BorderShape
HeaderBorderShape tui.BorderShape
HeaderLinesShape tui.BorderShape
InputLabel labelOpts
HeaderLabel labelOpts
BorderLabel labelOpts
ListLabel labelOpts
PreviewLabel labelOpts
Unicode bool
Ambidouble bool
Tabstop int
WithShell string
ListenAddr *listenAddress
Unsafe bool
ClearOnExit bool
WalkerOpts walkerOpts
WalkerRoot []string
WalkerSkip []string
Version bool
Help bool
Threads int
Bench time.Duration
CPUProfile string
MEMProfile string
BlockProfile string
MutexProfile string
TtyDefault string
}
Options stores the values of command-line options
type Pattern ¶
type Pattern struct {
// contains filtered or unexported fields
}
Pattern represents search pattern
func BuildPattern ¶
func BuildPattern(cache *ChunkCache, patternCache map[string]*Pattern, fuzzy bool, fuzzyAlgo algo.Algo, extended bool, caseMode Case, normalize bool, forward bool, withPos bool, cacheable bool, nth []Range, delimiter Delimiter, revision revision, runes []rune, denylist map[int32]struct{}, startIndex int32) *Pattern
BuildPattern builds Pattern object from the given arguments
type Range ¶
type Range struct {
// contains filtered or unexported fields
}
Range represents nth-expression
func ParseRange ¶
ParseRange parses nth-expression and returns the corresponding Range object
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader reads from command or standard input
type Status ¶
type Status struct {
Reading bool `json:"reading"`
Progress int `json:"progress"`
Query string `json:"query"`
Position int `json:"position"`
Sort bool `json:"sort"`
TotalCount int `json:"totalCount"`
MatchCount int `json:"matchCount"`
Current *StatusItem `json:"current"`
Matches []StatusItem `json:"matches"`
Selected []StatusItem `json:"selected"`
}
type StatusItem ¶
type Terminal ¶
type Terminal struct {
// contains filtered or unexported fields
}
Terminal represents terminal input/output
func NewTerminal ¶
func NewTerminal(opts *Options, eventBox *util.EventBox, executor *util.Executor) (*Terminal, error)
NewTerminal returns new Terminal object
func (*Terminal) MaxFitAndPad ¶
func (*Terminal) PauseRendering ¶ added in v0.70.0
func (t *Terminal) PauseRendering()
PauseRendering blocks the terminal from reading items. Must be paired with ResumeRendering.
func (*Terminal) ResumeRendering ¶ added in v0.70.0
func (t *Terminal) ResumeRendering()
ResumeRendering releases the lock acquired by PauseRendering.
func (*Terminal) UpdateCount ¶
UpdateCount updates the count information
func (*Terminal) UpdateHeader ¶
UpdateHeader updates the header
func (*Terminal) UpdateList ¶
func (t *Terminal) UpdateList(result MatchResult)
UpdateList updates Merger to display the list
func (*Terminal) UpdateProgress ¶
UpdateProgress updates the search progress
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
Token contains the tokenized part of the strings and its prefix length