filters

package
v0.0.0-...-d18e9c3 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FilterIntersectChar rune = '&'
	FilterUnionChar     rune = '+'
	FilterExcludeChar   rune = '-'
	FilterHighlightChar rune = '~'
)
View Source
const FilterMinLength int = 2

Variables

View Source
var CaseSensitive = SearchType{
	Color: termbox.ColorYellow,
	Name:  "CaseS",
}
View Source
var ErrBadFilterDefinition = errors.New("Bad filter definition")
View Source
var RegEx = SearchType{
	Color: termbox.ColorRed,
	Name:  "RegEx",
}
View Source
var SearchTypeMap map[uint8]SearchType

Functions

func IndexAll

func IndexAll(searchFunc SearchFunc, runestack []rune) (indices [][]int)

Types

type ActionFunc

type ActionFunc func(str []rune, currentAction FilterResult) FilterResult

type Filter

type Filter struct {
	Action     FilterAction
	TakeAction ActionFunc
	// contains filtered or unexported fields
}

func NewFilter

func NewFilter(sub []rune, action FilterAction, searchType SearchType) (*Filter, error)

func ParseFiltersFile

func ParseFiltersFile(filename string) ([]*Filter, error)

func ParseFiltersOpt

func ParseFiltersOpt(optStr string) ([]*Filter, error)

type FilterAction

type FilterAction uint8
const (
	FilterIntersect FilterAction = iota
	FilterUnion
	FilterExclude
	FilterHighlight
)

type FilterResult

type FilterResult uint8
const (
	FilterNoaction FilterResult = iota
	FilterIncluded
	FilterExcluded
	FilterHighlighted
)

type FilterTooShortError

type FilterTooShortError struct {
	FilterStr string
	Filename  string
}

func (*FilterTooShortError) Error

func (e *FilterTooShortError) Error() string

type SearchFunc

type SearchFunc func(sub []rune) []int

Follows regex return value pattern. nil if not found, slice of range if found Filter does not really need it, but highlighting also must search and requires it

func GetSearchFunc

func GetSearchFunc(searchType SearchType, sub []rune) (SearchFunc, error)

type SearchType

type SearchType struct {
	ID    uint8 // id will be generated by order defined in init
	Color termbox.Attribute
	Name  string
}

type UnknownFilterTypeError

type UnknownFilterTypeError struct {
	FilterTypeStr string
	Filename      string
}

func (*UnknownFilterTypeError) Error

func (e *UnknownFilterTypeError) Error() string

Jump to

Keyboard shortcuts

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