/
interface.go
79 lines (65 loc) · 1.51 KB
/
interface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package filter
import (
"context"
"errors"
"regexp"
"sync"
"time"
"github.com/peco/peco/line"
"github.com/peco/peco/pipeline"
)
var ErrFilterNotFound = errors.New("specified filter was not found")
var ignoreCaseFlags = regexpFlagList([]string{"i"})
var defaultFlags = regexpFlagList{}
var queryKey = &struct{}{}
var incomingBufferKey = &struct{}{}
// DefaultCustomFilterBufferThreshold is the default value
// for BufferThreshold setting on CustomFilters.
const DefaultCustomFilterBufferThreshold = 100
type Set struct {
current int
filters []Filter
mutex sync.Mutex
}
// internal stuff
type regexpFlags interface {
flags(string) []string
}
type regexpFlagList []string
type regexpFlagFunc func(string) []string
type regexpQueryFactory struct {
compiled map[string]regexpQuery
mutex sync.Mutex
threshold time.Duration
}
type regexpQuery struct {
rx []*regexp.Regexp
lastUsed time.Time
}
type Fuzzy struct {
sortLongest bool
}
type Regexp struct {
factory *regexpQueryFactory
flags regexpFlags
quotemeta bool
mutex sync.Mutex
name string
onEnd func()
outCh pipeline.ChanOutput
}
type ExternalCmd struct {
args []string
cmd string
enableSep bool
idgen line.IDGenerator
outCh pipeline.ChanOutput
name string
thresholdBufsiz int
}
type Filter interface {
Apply(context.Context, []line.Line, pipeline.ChanOutput) error
BufSize() int
NewContext(context.Context, string) context.Context
String() string
}