fzf

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCancelled = errors.New("cancelled")

ErrCancelled is returned when the user cancelled fzf.

Functions

This section is empty.

Types

type Binding

type Binding struct {
	// Keyboard shortcut, e.g. `ctrl-n`.
	Keys string
	// fzf action, see `man fzf`.
	Action string
	// Description which will be displayed as a fzf header if not empty.
	Description string
}

Binding represents a keyboard shortcut bound to an action in fzf.

type Fzf

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

Fzf filters a set of fields using fzf.

After adding all the fields with Add, use Selection to get the filtered results.

func New

func New(opts Opts) (*Fzf, error)

New runs a fzf instance.

To show a preview of each line, provide a previewCmd which will be executed by fzf.

func (*Fzf) Add

func (f *Fzf) Add(fields []string) error

Add appends a new line of fields to fzf input.

func (*Fzf) Selection

func (f *Fzf) Selection() ([][]string, error)

Selection returns the field lines selected by the user through fzf.

type NoteFilter

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

NoteFilter uses fzf to filter interactively a set of notes.

func NewNoteFilter

func NewNoteFilter(opts NoteFilterOpts, fs core.FileStorage, terminal *term.Terminal, templateLoader core.TemplateLoader) *NoteFilter

func (*NoteFilter) Apply

func (f *NoteFilter) Apply(notes []core.ContextualNote) ([]core.ContextualNote, error)

Apply filters the given notes with fzf.

type NoteFilterOpts

type NoteFilterOpts struct {
	// Indicates whether the filtering is interactive. If not, fzf is bypassed.
	Interactive bool
	// Indicates whether fzf is opened for every query, even if empty.
	AlwaysFilter bool
	// Format for a single line, taken from the config `fzf-line` property.
	LineTemplate opt.String
	// Preview command to run when selecting a note.
	PreviewCmd opt.String
	// When non null, a "create new note from query" binding will be added to
	// fzf to create a note in this directory.
	NewNoteDir *core.Dir
	// Absolute path to the notebook.
	NotebookDir string
}

NoteFilterOpts holds the configuration for the fzf notes filtering.

The absolute path to the notebook (NotebookDir) and the working directory (WorkingDir) are used to make the path of each note relative to the working directory.

type Opts

type Opts struct {
	// Preview command executed by fzf when hovering a line.
	PreviewCmd opt.String
	// Amount of space between two non-empty fields.
	Padding int
	// Delimiter used by fzf between fields.
	Delimiter string
	// List of key bindings enabled in fzf.
	Bindings []Binding
}

Opts holds the options used to run fzf.

Jump to

Keyboard shortcuts

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