blob: af806f2c36d7e733948ddcd155a6680cee8abfa7 (
plain)
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
|
package types
type SearchType int
const (
SearchTypeNone SearchType = iota
// searching is where matches are highlighted but the content is not filtered down
SearchTypeSearch
// filter is where the list is filtered down to only matches
SearchTypeFilter
)
// TODO: could we remove this entirely?
type SearchState struct {
Context Context
PrevSearchIndex int
}
func NewSearchState() *SearchState {
return &SearchState{PrevSearchIndex: -1}
}
func (self *SearchState) SearchType() SearchType {
switch self.Context.(type) {
case IFilterableContext:
return SearchTypeFilter
case ISearchableContext:
return SearchTypeSearch
default:
return SearchTypeNone
}
}
|