From 989730d47000feb297b5fab4e273a9d9b13c5741 Mon Sep 17 00:00:00 2001 From: Jeffas Date: Fri, 26 Jul 2019 22:41:13 +0100 Subject: Add index option to change-tab This allows selection of a tab using its index. It attempts to parse the given argument as a number, if it fails then it uses it as a name. Also supports relative indexes using prefixed + or -. --- widgets/aerc.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'widgets') diff --git a/widgets/aerc.go b/widgets/aerc.go index 458c2f9..90b56c8 100644 --- a/widgets/aerc.go +++ b/widgets/aerc.go @@ -268,6 +268,16 @@ func (aerc *Aerc) SelectTab(name string) bool { return false } +func (aerc *Aerc) SelectTabIndex(index int) bool { + for i, _ := range aerc.tabs.Tabs { + if i == index { + aerc.tabs.Select(i) + return true + } + } + return false +} + func (aerc *Aerc) TabNames() []string { var names []string for _, tab := range aerc.tabs.Tabs { -- cgit v1.2.3