forked from abenz1267/walker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswitcher.go
87 lines (64 loc) · 1.4 KB
/
switcher.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
80
81
82
83
84
85
86
87
package modules
import (
"context"
"github.com/abenz1267/walker/config"
"github.com/abenz1267/walker/util"
)
type Switcher struct {
general config.GeneralModule
cfg *config.Config
}
func (s Switcher) Cleanup() {}
func (s Switcher) History() bool {
return s.general.History
}
func (s Switcher) Typeahead() bool {
return s.general.Typeahead
}
func (Switcher) KeepSort() bool {
return false
}
func (s Switcher) Placeholder() string {
if s.general.Placeholder == "" {
return "switcher"
}
return s.general.Placeholder
}
func (s Switcher) SwitcherOnly() bool {
return false
}
func (s Switcher) Entries(ctx context.Context, term string) []util.Entry {
entries := []util.Entry{}
for _, v := range s.cfg.Available {
if v == "switcher" {
continue
}
e := util.Entry{
Label: v,
Sub: "switcher",
Exec: "",
Categories: []string{"switcher"},
Class: "switcher",
Matching: util.Fuzzy,
}
entries = append(entries, e)
}
return entries
}
func (s Switcher) Prefix() string {
return s.general.Prefix
}
func (s Switcher) Name() string {
return "switcher"
}
func (s *Switcher) Setup(cfg *config.Config) bool {
s.general = cfg.Builtins.Switcher.GeneralModule
s.cfg = cfg
s.general.IsSetup = true
return true
}
func (s *Switcher) SetupData(cfg *config.Config) {}
func (s Switcher) IsSetup() bool {
return s.general.IsSetup
}
func (s Switcher) Refresh() {}