aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/selector.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-08-20 20:45:51 +0200
committerRobin Jarry <robin@jarry.cc>2023-08-26 21:41:05 +0200
commitc077d2bf0f5d1a3aa0f97f7942c3d6938c9c43ff (patch)
treee87a7e3bde30b275f6dd6ac1273f531dad3115a0 /widgets/selector.go
parentd620a75f347a88d152e2dc63014178fb9ca2bb73 (diff)
downloadaerc-c077d2bf0f5d1a3aa0f97f7942c3d6938c9c43ff.tar.gz
wizard: add protocol & transport fields
In preparation for other protocols, add a new "Protocol" field both in the source and outgoing sections. For now, there is only one source protocol and one outgoing protocol. Rename the "mode" fields to "transport". They will be reused later to include different authentication mechanisms. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Tristan Partin <tristan@partin.io> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'widgets/selector.go')
-rw-r--r--widgets/selector.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/widgets/selector.go b/widgets/selector.go
index fb8c8094..00479d4f 100644
--- a/widgets/selector.go
+++ b/widgets/selector.go
@@ -122,6 +122,18 @@ func (sel *Selector) OnSelect(fn func(option string)) *Selector {
return sel
}
+func (sel *Selector) Select(option string) {
+ for i, opt := range sel.options {
+ if option == opt {
+ sel.focus = i
+ if sel.onSelect != nil {
+ sel.onSelect(opt)
+ }
+ break
+ }
+ }
+}
+
func (sel *Selector) Selected() string {
return sel.options[sel.focus]
}