filter

package
v2.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package filter provides a termshark-specific edit widget which changes color according to the validity of its input, and which activates a drop-down menu of possible completions for the term at point.

Index

Constants

This section is empty.

Variables

View Source
var Goroutinewg *sync.WaitGroup

This is a debugging aid - I use it to ensure goroutines stop as expected. If they don't the main program will hang at termination.

Functions

This section is empty.

Types

type AppFilterCB

type AppFilterCB func(gowid.IApp)

type DisplayFilterValidator

type DisplayFilterValidator struct {
	Valid    IValidateCB
	Invalid  IValidateCB
	KilledCB IValidateCB
	EmptyCB  IValidateCB
	Cmd      *exec.Cmd
}

func (*DisplayFilterValidator) Kill

func (f *DisplayFilterValidator) Kill() (bool, error)

func (*DisplayFilterValidator) SetEmpty

func (f *DisplayFilterValidator) SetEmpty(cb IValidateCB)

func (*DisplayFilterValidator) SetInvalid

func (f *DisplayFilterValidator) SetInvalid(cb IValidateCB)

func (*DisplayFilterValidator) SetKilled

func (f *DisplayFilterValidator) SetKilled(cb IValidateCB)

func (*DisplayFilterValidator) SetValid

func (f *DisplayFilterValidator) SetValid(cb IValidateCB)

func (*DisplayFilterValidator) Validate

func (f *DisplayFilterValidator) Validate(filter string)

type EmptyCB

type EmptyCB struct{}

type IValidateCB

type IValidateCB interface {
	Call(filter string)
}

type IValidator

type IValidator interface {
	SetValid(cb IValidateCB)
	SetInvalid(cb IValidateCB)
	SetKilled(cb IValidateCB)
	SetEmpty(cv IValidateCB)
	Kill() (bool, error)
	Validate(filter string)
}

IValidator is passed to the filter constructor

type IntermediateCB

type IntermediateCB struct{}

type InvalidCB

type InvalidCB struct{}

type Options

type Options struct {
	Completer      fields.IPrefixCompleter
	MenuOpener     menu.IOpener
	Position       Pos
	Validator      IValidator
	MaxCompletions int
}

type Pos

type Pos int
const (
	Left  Pos = iota
	Below Pos = iota
)

type SubmitCB

type SubmitCB struct{}

type ValidCB

type ValidCB struct{}

type ValidateCB

type ValidateCB struct {
	App gowid.IApp
	Fn  AppFilterCB
}

func (*ValidateCB) Call

func (v *ValidateCB) Call(filter string)

type Widget

type Widget struct {
	*gowid.Callbacks
	gowid.IsSelectable
	// contains filtered or unexported fields
}

func New

func New(name string, opt Options) *Widget

func (*Widget) Close

func (w *Widget) Close() error

func (*Widget) IsValid

func (w *Widget) IsValid() bool

func (*Widget) Menus

func (w *Widget) Menus() []gowid.IMenuCompatible

func (*Widget) OnEmpty

func (w *Widget) OnEmpty(f gowid.IWidgetChangedCallback)

func (*Widget) OnIntermediate

func (w *Widget) OnIntermediate(f gowid.IWidgetChangedCallback)

func (*Widget) OnInvalid

func (w *Widget) OnInvalid(f gowid.IWidgetChangedCallback)

func (*Widget) OnSubmit

func (w *Widget) OnSubmit(f gowid.IWidgetChangedCallback)

func (*Widget) OnValid

func (w *Widget) OnValid(f gowid.IWidgetChangedCallback)

func (*Widget) Render

func (w *Widget) Render(size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) gowid.ICanvas

func (*Widget) RenderSize

func (w *Widget) RenderSize(size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) gowid.IRenderBox

func (*Widget) SetValue

func (w *Widget) SetValue(v string, app gowid.IApp)

func (*Widget) UpdateCompletions

func (w *Widget) UpdateCompletions(app gowid.IApp)

Start an asynchronous routine to update the drop-down menu with completion options. Runs on a small delay so it can be cancelled and restarted if the user is typing quickly.

func (*Widget) UserInput

func (w *Widget) UserInput(ev interface{}, size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) bool

Reject tab because I want it to switch views. Not intended to be transferable. Reject down because accepting it triggers the OnCursorSet callback, which re-evaluates the filter value - the user sees it go orange briefly, which is unpleasant.

func (*Widget) Value

func (w *Widget) Value() string

Jump to

Keyboard shortcuts

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