From e42b95a617399b2736df96ae6469309e6b306d71 Mon Sep 17 00:00:00 2001 From: Jeffas Date: Fri, 19 Jul 2019 18:12:57 +0100 Subject: Add change tab command This command allows the user to change tab by giving the tab name. This can be tab completed too. The previous tab is stored in the tabs module so that when a new tab is created it is still possible to go to the previous one. Normal invocation is :ct folder Previous tab is :ct - --- widgets/aerc.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'widgets') diff --git a/widgets/aerc.go b/widgets/aerc.go index 14cf3c4..079d442 100644 --- a/widgets/aerc.go +++ b/widgets/aerc.go @@ -252,6 +252,28 @@ func (aerc *Aerc) PrevTab() { aerc.tabs.Select(next) } +func (aerc *Aerc) SelectTab(name string) bool { + for i, tab := range aerc.tabs.Tabs { + if tab.Name == name { + aerc.tabs.Select(i) + return true + } + } + return false +} + +func (aerc *Aerc) TabNames() []string { + var names []string + for _, tab := range aerc.tabs.Tabs { + names = append(names, tab.Name) + } + return names +} + +func (aerc *Aerc) SelectPreviousTab() bool { + return aerc.tabs.SelectPrevious() +} + // TODO: Use per-account status lines, but a global ex line func (aerc *Aerc) SetStatus(status string) *StatusMessage { return aerc.statusline.Set(status) -- cgit 1.4.1-2-gfad0