summary refs log tree commit diff stats
path: root/widgets
diff options
context:
space:
mode:
authorJeffas <dev@jeffas.io>2019-07-19 18:12:57 +0100
committerDrew DeVault <sir@cmpwn.com>2019-07-23 10:27:59 -0400
commite42b95a617399b2736df96ae6469309e6b306d71 (patch)
tree65bd6f78faa0607a3d73a35b7c59a713472adbea /widgets
parentd526786c9358bc92a5ffc3233e0ba4491aff07ba (diff)
downloadaerc-e42b95a617399b2736df96ae6469309e6b306d71.tar.gz
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 -
Diffstat (limited to 'widgets')
-rw-r--r--widgets/aerc.go22
1 files changed, 22 insertions, 0 deletions
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)