Documentation
¶
Overview ¶
Package menu provides a flexible wrapper for the fzf interactive filter, enabling customizable selection menus.
Index ¶
- Constants
- Variables
- func Select[T any](items []T, opts ...Option) ([]T, error)
- type Args
- type ArgsBuilder
- func (a *ArgsBuilder) Add(s ...string) *ArgsBuilder
- func (a *ArgsBuilder) Build() Args
- func (a *ArgsBuilder) Custom(s ...string) *ArgsBuilder
- func (a *ArgsBuilder) Parse() error
- func (a *ArgsBuilder) String() string
- func (a *ArgsBuilder) Validate() error
- func (a *ArgsBuilder) WithAnsi() *ArgsBuilder
- func (a *ArgsBuilder) WithBorder(b Border) *ArgsBuilder
- func (a *ArgsBuilder) WithBorderLabel(s string) *ArgsBuilder
- func (a *ArgsBuilder) WithColor(target string, styles ...string) *ArgsBuilder
- func (a *ArgsBuilder) WithCycle() *ArgsBuilder
- func (a *ArgsBuilder) WithFooter(footer string) *ArgsBuilder
- func (a *ArgsBuilder) WithFooterBorder(b Border) *ArgsBuilder
- func (a *ArgsBuilder) WithHeader(s string) *ArgsBuilder
- func (a *ArgsBuilder) WithHeaderBorder(b Border) *ArgsBuilder
- func (a *ArgsBuilder) WithHeight(s string) *ArgsBuilder
- func (a *ArgsBuilder) WithHighlightLine() *ArgsBuilder
- func (a *ArgsBuilder) WithInfo(is InfoStyle) *ArgsBuilder
- func (a *ArgsBuilder) WithLayout(l Layout) *ArgsBuilder
- func (a *ArgsBuilder) WithMultiSelection() *ArgsBuilder
- func (a *ArgsBuilder) WithNoColor() *ArgsBuilder
- func (a *ArgsBuilder) WithNoScrollbar() *ArgsBuilder
- func (a *ArgsBuilder) WithNth(idx ...string) *ArgsBuilder
- func (a *ArgsBuilder) WithPointer(s string) *ArgsBuilder
- func (a *ArgsBuilder) WithPreview(s string) *ArgsBuilder
- func (a *ArgsBuilder) WithPreviewBorder(b Border) *ArgsBuilder
- func (a *ArgsBuilder) WithPreviewWindow(s string) *ArgsBuilder
- func (a *ArgsBuilder) WithPrompt(s string) *ArgsBuilder
- func (a *ArgsBuilder) WithSync() *ArgsBuilder
- func (a *ArgsBuilder) WithTac() *ArgsBuilder
- type Border
- type ColorValue
- type FmtFunc
- type InfoStyle
- type Items
- type Keybind
- type KeybindAction
- type Keymap
- func (k *Keymap) Arguments() []string
- func (k *Keymap) BindString() string
- func (k *Keymap) Hide() *Keymap
- func (k *Keymap) IsEnabled() bool
- func (k *Keymap) String() string
- func (k *Keymap) WithArgs(fn func(b *ArgsBuilder) *ArgsBuilder) *Keymap
- func (k *Keymap) WithBecome(cmd string) *Keymap
- func (k *Keymap) WithBind(b Keybind) *Keymap
- func (k *Keymap) WithBuiltinAction(cmd KeybindAction) *Keymap
- func (k *Keymap) WithCommand(cmd string) *Keymap
- func (k *Keymap) WithDesc(s string) *Keymap
- func (k *Keymap) WithEnabled(b bool) *Keymap
- func (k *Keymap) WithExecute(cmd string) *Keymap
- func (k *Keymap) WithSilentExecute(cmd string) *Keymap
- type KeymapFormatter
- type KeymapManager
- type Layout
- type Menu
- type MenuRunner
- type Option
- func WithAnsi() Option
- func WithArgs(fn func(b *ArgsBuilder) *ArgsBuilder) Option
- func WithArgsCustom(args ...string) Option
- func WithBorder(b Border) Option
- func WithBorderLabel(s string) Option
- func WithColor(target string, values ...ColorValue) Option
- func WithCycle() Option
- func WithDefaults(b bool) Option
- func WithFooter(footer string) Option
- func WithFooterBorder(b Border) Option
- func WithHeader(header string) Option
- func WithHeaderBorder(b Border) Option
- func WithHeaderFirst() Option
- func WithHeaderKeymapFmt(fn KeymapFormatter) Option
- func WithHeaderKeymaps() Option
- func WithHeaderLabel(s string) Option
- func WithHeaderSeparator(sep string) Option
- func WithHeaderSeparatorFmt(fn SeparatorFormatter) Option
- func WithHeight(s string) Option
- func WithInfo(is InfoStyle) Option
- func WithInterruptFn(fn func(error)) Option
- func WithKeybinds(keys ...*Keymap) Option
- func WithLayout(l Layout) Option
- func WithMultiSelection() Option
- func WithMultilineView() Option
- func WithNoOutputColor() Option
- func WithNoScrollbar() Option
- func WithNth(idx ...string) Option
- func WithOutputColor(b bool) Option
- func WithPointer(s string) Option
- func WithPreviewBorder(b Border) Option
- func WithPreviewCmd(cmd string) Option
- func WithPreviewWindow(args string) Option
- func WithPrompt(s string) Option
- func WithRunner(r MenuRunner) Option
- func WithSync() Option
- func WithTac() Option
- func WithoutHeader(b bool) Option
- type Options
- type RunOptions
- type SeparatorFormatter
Examples ¶
Constants ¶
const ExitSuccess = 0
Variables ¶
var ( ErrInvalidConfigKeymap = errors.New("invalid keymap") ErrInvalidConfigSettings = errors.New("invalid settings") )
var ( // ErrFzf reports a generic fzf error (return code: 2). ErrFzf = errors.New("error: code 2") // ErrNoMatching reports that no items matched the query (return code: 1). ErrNoMatching = errors.New("no matching record: code 1") // ErrInvalidShellCommand reports an invalid shell command for a become // action (return code: 126). ErrInvalidShellCommand = errors.New("invalid shell command for become action: code 126") // ErrActionAborted reports that the user aborted the fzf session (return code: // 130). ErrActionAborted = errors.New("action aborted: code 130") // ErrPermissionDenied reports a permission error from a become action // (return code: 127). ErrPermissionDenied = errors.New("permission denied from become action: code 127") // ErrNoItems reports that no items were provided. ErrNoItems = errors.New("no items found") )
var ErrArgEmpty = errors.New("argument cannot be empty")
var ErrInvalidHeaderArg = errors.New("invalid header argument")
Functions ¶
Types ¶
type ArgsBuilder ¶
type ArgsBuilder struct {
// contains filtered or unexported fields
}
ArgsBuilder constructs command-line arguments for FZF.
func NewArgsBuilder ¶
func NewArgsBuilder() *ArgsBuilder
func (*ArgsBuilder) Add ¶
func (a *ArgsBuilder) Add(s ...string) *ArgsBuilder
func (*ArgsBuilder) Build ¶
func (a *ArgsBuilder) Build() Args
func (*ArgsBuilder) Custom ¶
func (a *ArgsBuilder) Custom(s ...string) *ArgsBuilder
func (*ArgsBuilder) Parse ¶
func (a *ArgsBuilder) Parse() error
func (*ArgsBuilder) String ¶
func (a *ArgsBuilder) String() string
func (*ArgsBuilder) Validate ¶
func (a *ArgsBuilder) Validate() error
Validate checks that all string fields in ArgsBuilder are not empty.
func (*ArgsBuilder) WithAnsi ¶
func (a *ArgsBuilder) WithAnsi() *ArgsBuilder
func (*ArgsBuilder) WithBorder ¶
func (a *ArgsBuilder) WithBorder(b Border) *ArgsBuilder
func (*ArgsBuilder) WithBorderLabel ¶
func (a *ArgsBuilder) WithBorderLabel(s string) *ArgsBuilder
func (*ArgsBuilder) WithColor ¶
func (a *ArgsBuilder) WithColor(target string, styles ...string) *ArgsBuilder
func (*ArgsBuilder) WithCycle ¶
func (a *ArgsBuilder) WithCycle() *ArgsBuilder
func (*ArgsBuilder) WithFooter ¶
func (a *ArgsBuilder) WithFooter(footer string) *ArgsBuilder
func (*ArgsBuilder) WithFooterBorder ¶
func (a *ArgsBuilder) WithFooterBorder(b Border) *ArgsBuilder
func (*ArgsBuilder) WithHeader ¶
func (a *ArgsBuilder) WithHeader(s string) *ArgsBuilder
func (*ArgsBuilder) WithHeaderBorder ¶
func (a *ArgsBuilder) WithHeaderBorder(b Border) *ArgsBuilder
func (*ArgsBuilder) WithHeight ¶
func (a *ArgsBuilder) WithHeight(s string) *ArgsBuilder
func (*ArgsBuilder) WithHighlightLine ¶
func (a *ArgsBuilder) WithHighlightLine() *ArgsBuilder
func (*ArgsBuilder) WithInfo ¶
func (a *ArgsBuilder) WithInfo(is InfoStyle) *ArgsBuilder
func (*ArgsBuilder) WithLayout ¶
func (a *ArgsBuilder) WithLayout(l Layout) *ArgsBuilder
func (*ArgsBuilder) WithMultiSelection ¶
func (a *ArgsBuilder) WithMultiSelection() *ArgsBuilder
func (*ArgsBuilder) WithNoColor ¶
func (a *ArgsBuilder) WithNoColor() *ArgsBuilder
func (*ArgsBuilder) WithNoScrollbar ¶
func (a *ArgsBuilder) WithNoScrollbar() *ArgsBuilder
func (*ArgsBuilder) WithNth ¶
func (a *ArgsBuilder) WithNth(idx ...string) *ArgsBuilder
func (*ArgsBuilder) WithPointer ¶
func (a *ArgsBuilder) WithPointer(s string) *ArgsBuilder
func (*ArgsBuilder) WithPreview ¶
func (a *ArgsBuilder) WithPreview(s string) *ArgsBuilder
func (*ArgsBuilder) WithPreviewBorder ¶
func (a *ArgsBuilder) WithPreviewBorder(b Border) *ArgsBuilder
func (*ArgsBuilder) WithPreviewWindow ¶
func (a *ArgsBuilder) WithPreviewWindow(s string) *ArgsBuilder
func (*ArgsBuilder) WithPrompt ¶
func (a *ArgsBuilder) WithPrompt(s string) *ArgsBuilder
func (*ArgsBuilder) WithSync ¶
func (a *ArgsBuilder) WithSync() *ArgsBuilder
func (*ArgsBuilder) WithTac ¶
func (a *ArgsBuilder) WithTac() *ArgsBuilder
type Border ¶
type Border string
Border draw border around the finder.
const ( BorderRounded Border = "rounded" BorderSharp Border = "sharp" BorderBold Border = "bold" BorderDouble Border = "double" BorderBlock Border = "block" BorderThinblock Border = "thinblock" BorderHorizontal Border = "horizontal" BorderVertical Border = "vertical" BorderLine Border = "line" BorderTop Border = "top" BorderBottom Border = "bottom" BorderLeft Border = "left" BorderRight Border = "right" BorderDashed Border = "dashed" BorderNone Border = "none" )
type ColorValue ¶
type ColorValue string
ColorValue represents an ANSI color understood by fzf.
const ( // ColorDefault default or original terminal color. ColorDefault ColorValue = "-1" ColorBlack ColorValue = "black" ColorRed ColorValue = "red" ColorGreen ColorValue = "green" ColorYellow ColorValue = "yellow" ColorBlue ColorValue = "blue" ColorMagenta ColorValue = "magenta" ColorCyan ColorValue = "cyan" ColorWhite ColorValue = "white" ColorBrightBlack ColorValue = "bright-black" ColorBrightRed ColorValue = "bright-red" ColorBrightGreen ColorValue = "bright-green" ColorBrightYellow ColorValue = "bright-yellow" ColorBrightBlue ColorValue = "bright-blue" ColorBrightMagenta ColorValue = "bright-magenta" ColorBrightCyan ColorValue = "bright-cyan" ColorBrightWhite ColorValue = "bright-white" AttributeRegular ColorValue = "regular" AttributeStrip ColorValue = "strip" AttributeBold ColorValue = "bold" AttributeUnderline ColorValue = "underline" AttributeUnderlineDouble ColorValue = "underline-double" AttributeUnderlineCurly ColorValue = "underline-curly" AttributeUnderlineDotted ColorValue = "underline-dotted" AttributeUnderlineDashed ColorValue = "underline-dashed" AttributeReverse ColorValue = "reverse" AttributeDim ColorValue = "dim" AttributeItalic ColorValue = "italic" AttributeStrikethrough ColorValue = "strikethrough" )
type InfoStyle ¶
type InfoStyle string
InfoStyle determines the display style of the finder info. (e.g. match counter, loading indicator, etc.)
const ( InfoStyleDefault InfoStyle = "default" // InfoStyleDefault on the left end of the horizontal separator. InfoStyleRight InfoStyle = "right" // InfoStyleRight on the right end of the horizontal separator. InfoStyleHidden InfoStyle = "hidden" // InfoStyleHidden do not display finder info. InfoStyleInline InfoStyle = "inline" // InfoStyleInline after the prompt with the default prefix ' < '. InfoStyleInlineRight InfoStyle = "inline-right" // InfoStyleInlineRight on the right end of the prompt line. )
type Items ¶
type Items[T any] struct { // Formatter converts items to display strings for FZF. // If nil, a default Formatter will be used that calls String() method. // The function should return ANSI-formatted strings for rich display. Formatter FmtFunc[T] }
Items holds the data and transformation logic for menu items.
type Keybind ¶
type Keybind string // (e.g., "ctrl-a", "ctrl-e", etc...)
const ( KeyEnter Keybind = "enter" KeyTab Keybind = "tab" KeyBTab Keybind = "btab" KeyEsc Keybind = "esc" KeySpace Keybind = "space" KeyUp Keybind = "up" KeyDown Keybind = "down" KeyLeft Keybind = "left" KeyRight Keybind = "right" KeyHome Keybind = "home" KeyEnd Keybind = "end" KeyPgUp Keybind = "pgup" KeyPgDn Keybind = "pgdn" KeyCtrlA Keybind = "ctrl-a" KeyCtrlB Keybind = "ctrl-b" KeyCtrlC Keybind = "ctrl-c" KeyCtrlD Keybind = "ctrl-d" KeyCtrlE Keybind = "ctrl-e" KeyCtrlF Keybind = "ctrl-f" KeyCtrlG Keybind = "ctrl-g" KeyCtrlH Keybind = "ctrl-h" KeyCtrlI Keybind = "ctrl-i" KeyCtrlJ Keybind = "ctrl-j" KeyCtrlK Keybind = "ctrl-k" KeyCtrlL Keybind = "ctrl-l" KeyCtrlM Keybind = "ctrl-m" KeyCtrlN Keybind = "ctrl-n" KeyCtrlO Keybind = "ctrl-o" KeyCtrlP Keybind = "ctrl-p" KeyCtrlQ Keybind = "ctrl-q" KeyCtrlR Keybind = "ctrl-r" KeyCtrlS Keybind = "ctrl-s" KeyCtrlT Keybind = "ctrl-t" KeyCtrlU Keybind = "ctrl-u" KeyCtrlV Keybind = "ctrl-v" KeyCtrlW Keybind = "ctrl-w" KeyCtrlX Keybind = "ctrl-x" KeyCtrlY Keybind = "ctrl-y" KeyCtrlZ Keybind = "ctrl-z" KeyCtrlSlash Keybind = "ctrl-/" KeyAltA Keybind = "alt-a" KeyAltB Keybind = "alt-b" KeyAltC Keybind = "alt-c" KeyAltD Keybind = "alt-d" KeyAltE Keybind = "alt-e" KeyAltF Keybind = "alt-f" KeyAltG Keybind = "alt-g" KeyAltH Keybind = "alt-h" KeyAltI Keybind = "alt-i" KeyAltJ Keybind = "alt-j" KeyAltK Keybind = "alt-k" KeyAltL Keybind = "alt-l" KeyAltM Keybind = "alt-m" KeyAltN Keybind = "alt-n" KeyAltO Keybind = "alt-o" KeyAltP Keybind = "alt-p" KeyAltQ Keybind = "alt-q" KeyAltR Keybind = "alt-r" KeyAltS Keybind = "alt-s" KeyAltT Keybind = "alt-t" KeyAltU Keybind = "alt-u" KeyAltV Keybind = "alt-v" KeyAltW Keybind = "alt-w" KeyAltX Keybind = "alt-x" KeyAltY Keybind = "alt-y" KeyAltZ Keybind = "alt-z" KeyF1 Keybind = "f1" KeyF2 Keybind = "f2" KeyF3 Keybind = "f3" KeyF4 Keybind = "f4" KeyF5 Keybind = "f5" KeyF6 Keybind = "f6" KeyF7 Keybind = "f7" KeyF8 Keybind = "f8" KeyF9 Keybind = "f9" KeyF10 Keybind = "f10" KeyF11 Keybind = "f11" KeyF12 Keybind = "f12" KeyShiftUp Keybind = "shift-up" KeyShiftDown Keybind = "shift-down" KeyShiftLeft Keybind = "shift-left" KeyShiftRight Keybind = "shift-right" )
type KeybindAction ¶
type KeybindAction string // (e.g., "toggle-preview", "toggle-all")
const ( // General. KeybindActionAccept KeybindAction = "accept" KeybindActionAbort KeybindAction = "abort" // Selection. KeybindActionToggle KeybindAction = "toggle" KeybindActionToggleAll KeybindAction = "toggle-all" KeybindActionSelect KeybindAction = "select" KeybindActionSelectAll KeybindAction = "select-all" KeybindActionDeselectAll KeybindAction = "deselect-all" // Navigation. KeybindActionUp KeybindAction = "up" KeybindActionDown KeybindAction = "down" KeybindActionFirst KeybindAction = "first" KeybindActionLast KeybindAction = "last" KeybindActionPageUp KeybindAction = "page-up" KeybindActionPageDown KeybindAction = "page-down" KeybindActionHalfPageUp KeybindAction = "half-page-up" KeybindActionHalfPageDown KeybindAction = "half-page-down" // Preview navigation. KeybindActionPreviewUp KeybindAction = "preview-up" KeybindActionPreviewDown KeybindAction = "preview-down" KeybindActionPreviewPageUp KeybindAction = "preview-page-up" KeybindActionPreviewPageDown KeybindAction = "preview-page-down" KeybindActionPreviewHalfPageUp KeybindAction = "preview-half-page-up" KeybindActionPreviewHalfPageDown KeybindAction = "preview-half-page-down" // Preview. KeybindActionTogglePreview KeybindAction = "toggle-preview" KeybindActionChangePreviewWindow KeybindAction = "change-preview-window" )
type Keymap ¶
type Keymap struct {
Bind Keybind `json:"bind" yaml:"bind"` // keybind combination
Action KeybindAction `json:"-" yaml:"-"` // action to execute
Desc string `json:"description" yaml:"description"` // keybind description
Enabled bool `json:"enabled" yaml:"enabled"` // keybind enabled
Hidden bool `json:"hidden" yaml:"hidden"` // keybind hidden
Args Args `json:"args,omitempty" yaml:"args,omitempty"` // arguments added to the menu
}
Keymap holds the keymap configuration.
func KeymapToggleAll ¶
func KeymapToggleAll() *Keymap
func KeymapTogglePreview ¶
func KeymapTogglePreview() *Keymap
func (*Keymap) BindString ¶
func (*Keymap) WithArgs ¶
func (k *Keymap) WithArgs(fn func(b *ArgsBuilder) *ArgsBuilder) *Keymap
func (*Keymap) WithBecome ¶ added in v0.1.1
func (*Keymap) WithBuiltinAction ¶
func (k *Keymap) WithBuiltinAction(cmd KeybindAction) *Keymap
func (*Keymap) WithCommand ¶ added in v0.1.1
func (*Keymap) WithEnabled ¶
func (*Keymap) WithExecute ¶
WithExecute returns a new Keymap with the given action command.
func (*Keymap) WithSilentExecute ¶
WithSilentExecute returns a new Keymap with the given action command.
type KeymapFormatter ¶
KeymapFormatter formats a single keymap entry.
The arguments are the key binding, the separator between the binding and description (typically ":"), and the description.
type KeymapManager ¶
type KeymapManager struct {
// contains filtered or unexported fields
}
func NewKeymapManager ¶
func NewKeymapManager() *KeymapManager
func (*KeymapManager) Find ¶
func (km *KeymapManager) Find(bind *Keymap) *Keymap
Find returns the first Keymap that matches the given action or bind. It returns nil if no keymap is found.
func (*KeymapManager) Len ¶
func (km *KeymapManager) Len() int
func (*KeymapManager) List ¶
func (km *KeymapManager) List() []*Keymap
List returns a sorted keymap slice.
func (*KeymapManager) NewKeymap ¶
func (km *KeymapManager) NewKeymap() *Keymap
func (*KeymapManager) Register ¶
func (km *KeymapManager) Register(keys ...*Keymap)
func (*KeymapManager) Remove ¶
func (km *KeymapManager) Remove(k *Keymap)
Remove removes bind from keymaps map.
type Layout ¶
type Layout string
const ( LayoutDefault Layout = "default" // LayoutDefault display from the bottom of the screen. LayoutReverse Layout = "reverse" // LayoutReverse display from the top of the screen. LayoutReverseList Layout = "reverse-list" // LayoutReverseList display from the top of the screen, prompt at the bottom. )
type Menu ¶
Example ¶
package main
import (
"fmt"
menu "github.com/mateconpizza/go-fzf"
)
type Item struct {
Name string
Quantity int
}
func (item Item) String() string {
return fmt.Sprintf("%-12s (%d)", item.Name, item.Quantity)
}
var items = []Item{
{Name: "Apples", Quantity: 12},
{Name: "Bananas", Quantity: 8},
{Name: "Oranges", Quantity: 5},
{Name: "Pears", Quantity: 3},
{Name: "Palandri", Quantity: 1},
}
func main() {
m := menu.New[Item](
// Uses `$FZF_DEFAULT_OPTS_FILE` and `$FZF_DEFAULT_OPTS`
menu.WithDefaults(true),
// Layout
menu.WithHeight("40%"),
menu.WithBorder(menu.BorderRounded),
// Header
menu.WithHeader("Inventory"),
menu.WithHeaderKeymaps(),
menu.WithHeaderBorder(menu.BorderBottom),
// Interaction
menu.WithMultiSelection(),
menu.WithCycle(),
menu.WithPrompt("Select> "),
// Preview
menu.WithPreviewCmd("echo {1}"),
menu.WithPreviewBorder(menu.BorderRounded),
// Appearance
menu.WithColor("prompt", menu.ColorBrightCyan, menu.AttributeBold),
menu.WithColor("footer", menu.ColorBrightBlue, menu.AttributeItalic),
)
selected, err := m.Select(items)
if err != nil {
return
}
for _, item := range selected {
fmt.Println(item.Name)
}
}
Output: Apples
func (*Menu[T]) SetFormatter ¶
SetFormatter sets a function to format items for display in fzf.
func (*Menu[T]) SetInterruptFn ¶
SetInterruptFn sets the interrupt function for the menu.
type MenuRunner ¶
type MenuRunner interface {
// Run executes FZF with the given options and returns the exit code.
Run(options *RunOptions) (int, error)
// Parse converts command line arguments to FZF options, optionally applying
// defaults.
Parse(defaults bool, args Args) (*RunOptions, error)
}
MenuRunner defines the interface for running FZF with options and parsing arguments.
type Option ¶
type Option func(*Options)
func WithArgs ¶
func WithArgs(fn func(b *ArgsBuilder) *ArgsBuilder) Option
func WithArgsCustom ¶
WithArgsCustom adds new args to Fzf.
func WithBorderLabel ¶
func WithColor ¶
func WithColor(target string, values ...ColorValue) Option
WithColor configures the color and text attributes for an fzf UI element.
The target specifies the UI element to style (for example, "prompt", "header", or "border"). The values specify one or more ANSI colors or text attributes supported by fzf.
func WithDefaults ¶
WithDefaults uses $FZF_DEFAULT_OPTS_FILE and $FZF_DEFAULT_OPTS.
func WithFooter ¶
func WithFooterBorder ¶
func WithHeader ¶
WithHeader adds a header to FZF, appending to existing headers.
func WithHeaderBorder ¶
WithHeaderBorder draw border around the header section.
func WithHeaderFirst ¶
func WithHeaderFirst() Option
WithHeaderFirst print header before the prompt line.
func WithHeaderKeymapFmt ¶
func WithHeaderKeymapFmt(fn KeymapFormatter) Option
func WithHeaderKeymaps ¶
func WithHeaderKeymaps() Option
func WithHeaderLabel ¶
WithHeaderLabel label to print on the header border.
func WithHeaderSeparator ¶
func WithHeaderSeparatorFmt ¶
func WithHeaderSeparatorFmt(fn SeparatorFormatter) Option
func WithInterruptFn ¶
WithInterruptFn sets a callback that executes on fzf interruption. Use for cleanup or custom error handling when user cancels selection.
func WithLayout ¶
func WithMultiSelection ¶
func WithMultiSelection() Option
WithMultiSelection adds a keybind to select multiple records.
func WithMultilineView ¶
func WithMultilineView() Option
WithMultilineView adds multiline view and highlights the entire current line in Fzf.
func WithNoOutputColor ¶
func WithNoOutputColor() Option
func WithOutputColor ¶
func WithPointer ¶
func WithPreviewBorder ¶
WithPreviewBorder draws a single separator line.
func WithPreviewCmd ¶
WithPreviewCmd adds preview with a custom command.
func WithPreviewWindow ¶
WithPreviewWindow determines the layout of the preview window.
func WithRunner ¶
func WithRunner(r MenuRunner) Option
WithRunner Add new OptionFn for test configuration.
func WithoutHeader ¶
type RunOptions ¶ added in v0.1.3
type RunOptions struct {
Input chan string
Output chan string
// contains filtered or unexported fields
}
RunOptions wraps the real fzf options internally so that MenuRunner — and any custom implementation of it, e.g. a test fake — never needs to import the fzf package.
type SeparatorFormatter ¶
SeparatorFormatter formats the separator used between keymap entries in the menu header.