menu

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 10 Imported by: 0

README

go-fzf

Provides a wrapper around fzf for interactive menus.

Extracted from gomarks

example

package main

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 ExampleMenu() {
	m := menu.New[Item](
		menu.WithDefaults(true), // uses `$FZF_DEFAULT_OPTS_FILE` and `$FZF_DEFAULT_OPTS`
		menu.WithPrompt("Select> "),
		menu.WithHeader("Inventory"),
		menu.WithBorder(menu.BorderRounded),
		menu.WithBorderLabel("= demo ="),
		menu.WithPreviewCmd("echo {1}"),
		menu.WithHeight("40%"),
		menu.WithFooter("~~ Give me apples ~~"),
	)

	selected, err := m.Select(items)
	if err != nil {
		return
	}

	for _, item := range selected {
		fmt.Println(item.Name)
	}
}

Documentation

Overview

Package menu provides a flexible wrapper for the fzf interactive filter, enabling customizable selection menus.

Index

Examples

Constants

View Source
const ExitSuccess = 0

Variables

View Source
var (
	ErrInvalidConfigKeymap   = errors.New("invalid keymap")
	ErrInvalidConfigSettings = errors.New("invalid settings")
)
View Source
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")
)
View Source
var ErrArgEmpty = errors.New("argument cannot be empty")
View Source
var ErrInvalidHeaderArg = errors.New("invalid header argument")

Functions

func Select

func Select[T any](items []T, opts ...Option) ([]T, error)

Select displays the given items in an interactive menu and returns the selected items.

Types

type Args

type Args []string

Args holds the FZF arguments.

func (Args) Validate

func (a Args) Validate() error

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"
)

func (Border) Arg

func (b Border) Arg(s string) string

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 FmtFunc

type FmtFunc[T any] func(item T) string

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 NewKeymap

func NewKeymap() *Keymap

func (*Keymap) Arguments

func (k *Keymap) Arguments() []string

func (*Keymap) BindString

func (k *Keymap) BindString() string

func (*Keymap) Hide

func (k *Keymap) Hide() *Keymap

func (*Keymap) IsEnabled

func (k *Keymap) IsEnabled() bool

func (*Keymap) String added in v0.1.1

func (k *Keymap) String() string

func (*Keymap) WithArgs

func (k *Keymap) WithArgs(fn func(b *ArgsBuilder) *ArgsBuilder) *Keymap

func (*Keymap) WithBecome added in v0.1.1

func (k *Keymap) WithBecome(cmd string) *Keymap

func (*Keymap) WithBind

func (k *Keymap) WithBind(b Keybind) *Keymap

func (*Keymap) WithBuiltinAction

func (k *Keymap) WithBuiltinAction(cmd KeybindAction) *Keymap

func (*Keymap) WithCommand added in v0.1.1

func (k *Keymap) WithCommand(cmd string) *Keymap

func (*Keymap) WithDesc

func (k *Keymap) WithDesc(s string) *Keymap

func (*Keymap) WithEnabled

func (k *Keymap) WithEnabled(b bool) *Keymap

func (*Keymap) WithExecute

func (k *Keymap) WithExecute(cmd string) *Keymap

WithExecute returns a new Keymap with the given action command.

func (*Keymap) WithSilentExecute

func (k *Keymap) WithSilentExecute(cmd string) *Keymap

WithSilentExecute returns a new Keymap with the given action command.

type KeymapFormatter

type KeymapFormatter func(bind, sep, desc string) string

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[T any] struct {
	Options
	Items[T]
}
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 New

func New[T any](opts ...Option) *Menu[T]

New returns a new Menu.

func (m *Menu[T]) Select(items []T) ([]T, error)

Select executes Fzf with the set elements and returns the selected item/s.

func (m *Menu[T]) SetFormatter(preprocessor FmtFunc[T])

SetFormatter sets a function to format items for display in fzf.

func (m *Menu[T]) SetInterruptFn(fn func(error))

SetInterruptFn sets the interrupt function for the menu.

func (m Menu[T]) Validate() error
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 WithAnsi

func WithAnsi() Option

WithAnsi enable processing of ANSI color codes.

func WithArgs

func WithArgs(fn func(b *ArgsBuilder) *ArgsBuilder) Option

func WithArgsCustom

func WithArgsCustom(args ...string) Option

WithArgsCustom adds new args to Fzf.

func WithBorder

func WithBorder(b Border) Option

WithBorder sets border around the window.

func WithBorderLabel

func WithBorderLabel(s string) Option

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 WithCycle

func WithCycle() Option

WithCycle enable cyclic scroll.

func WithDefaults

func WithDefaults(b bool) Option

WithDefaults uses $FZF_DEFAULT_OPTS_FILE and $FZF_DEFAULT_OPTS.

func WithFooter

func WithFooter(footer string) Option

func WithFooterBorder

func WithFooterBorder(b Border) Option

func WithHeader

func WithHeader(header string) Option

WithHeader adds a header to FZF, appending to existing headers.

func WithHeaderBorder

func WithHeaderBorder(b Border) Option

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

func WithHeaderLabel(s string) Option

WithHeaderLabel label to print on the header border.

func WithHeaderSeparator

func WithHeaderSeparator(sep string) Option

func WithHeaderSeparatorFmt

func WithHeaderSeparatorFmt(fn SeparatorFormatter) Option

func WithHeight

func WithHeight(s string) Option

WithHeight sets the height of the menu.

func WithInfo

func WithInfo(is InfoStyle) Option

func WithInterruptFn

func WithInterruptFn(fn func(error)) Option

WithInterruptFn sets a callback that executes on fzf interruption. Use for cleanup or custom error handling when user cancels selection.

func WithKeybinds

func WithKeybinds(keys ...*Keymap) Option

WithKeybinds adds a keybind to Fzf.

func WithLayout

func WithLayout(l Layout) Option

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 WithNoScrollbar

func WithNoScrollbar() Option

WithNoScrollbar do not display scrollbar.

func WithNth

func WithNth(idx ...string) Option

WithNth transform the presentation of each line using the field index expressions.

func WithOutputColor

func WithOutputColor(b bool) Option

func WithPointer

func WithPointer(s string) Option

func WithPreviewBorder

func WithPreviewBorder(b Border) Option

WithPreviewBorder draws a single separator line.

func WithPreviewCmd

func WithPreviewCmd(cmd string) Option

WithPreviewCmd adds preview with a custom command.

func WithPreviewWindow

func WithPreviewWindow(args string) Option

WithPreviewWindow determines the layout of the preview window.

func WithPrompt

func WithPrompt(s string) Option

WithPrompt adds a prompt to Fzf.

func WithRunner

func WithRunner(r MenuRunner) Option

WithRunner Add new OptionFn for test configuration.

func WithSync

func WithSync() Option

WithSync synchronous search for multi-staged filtering.

func WithTac

func WithTac() Option

WithTac reverse the order of the input.

func WithoutHeader

func WithoutHeader(b bool) Option

type Options

type Options struct {
	// contains filtered or unexported fields
}

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

type SeparatorFormatter func(sep string) string

SeparatorFormatter formats the separator used between keymap entries in the menu header.

Jump to

Keyboard shortcuts

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