From c077d2bf0f5d1a3aa0f97f7942c3d6938c9c43ff Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Sun, 20 Aug 2023 20:45:51 +0200 Subject: 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 Reviewed-by: Tristan Partin Tested-by: Tim Culverhouse --- widgets/selector.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'widgets/selector.go') 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] } -- cgit