Documentation
¶
Overview ¶
Package filterpick is the values list and condition of one column of a filter, in the manner of fzf: a condition on top, then the column's values with checkboxes, narrowed by a fuzzy search as you type. The sheet's filter and a pivot table's filters open it, each saying what applying and cancelling do. It knows the UI only through Host.
Index ¶
- Constants
- type Host
- type Picker
- func (p *Picker) Answer(text string) error
- func (p *Picker) Changed()
- func (p *Picker) Cursor() (int, int)
- func (p *Picker) Indicator() string
- func (p *Picker) Key(k tea.KeyPressMsg) tea.Cmd
- func (p *Picker) Layout() []overlay.Box
- func (p *Picker) Mouse(e overlay.MouseEvent) tea.Cmd
- func (p *Picker) OnlyCondition()
- func (p *Picker) Start()
- func (p *Picker) Status() (string, string)
Constants ¶
const ID = "filter"
ID identifies the picker's box in mouse events.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Host ¶
type Host interface {
Theme() *theme.Theme
Size() (width, height int)
// Line is the shared edit line the focused field is typed in.
Line() *lineedit.Line
// Close closes the open overlay.
Close()
// Locale is how the condition's value is typed and shown.
Locale() *locale.Locale
}
Host is what the filter picker needs of the UI.
type Picker ¶
type Picker struct {
// OnApply gets the criteria chosen, after the picker has closed.
OnApply func(cr sheet.Criteria)
// OnCancel, when set, runs after Esc or a click outside closes the
// picker.
OnCancel func()
overlay.List // over the rows: "Select all", then shown
// contains filtered or unexported fields
}
Picker is the values list and condition for one column.
func New ¶
func New(h Host, title string, x int, values []sheet.FilterValue, cond sheet.Condition, apply func(sheet.Criteria)) *Picker
New returns a picker titled title at screen column x over values, with cond as the condition, calling apply with the criteria chosen. The caller opens it, then calls Start.
func (*Picker) Answer ¶
Answer applies criteria a macro recorded, as sheet.Criteria.JSON writes them: the values hidden, and a condition with its value in en-US's form, as if checked and typed.
func (*Picker) OnlyCondition ¶ added in v0.6.0
func (p *Picker) OnlyCondition()
OnlyCondition has the picker ask for the condition alone, with no values to tick, for a column whose values are too many to list (a linked source's). Call it after Start.