aboutsummaryrefslogtreecommitdiffstats
path: root/commands/next-tab.go
blob: 466c4ff08a029d3b953e2a330d263bcbe7d520a8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package commands

import (
	"git.sr.ht/~rjarry/aerc/app"
)

type NextPrevTab struct {
	Offset int `opt:"n" default:"1"`
}

func init() {
	Register(NextPrevTab{})
}

func (NextPrevTab) Description() string {
	return "Cycle to the previous or next tab."
}

func (NextPrevTab) Context() CommandContext {
	return GLOBAL
}

func (NextPrevTab) Aliases() []string {
	return []string{"next-tab", "prev-tab"}
}

func (np NextPrevTab) Execute(args []string) error {
	if np.Offset <= 0 {
		return nil
	}

	offset := np.Offset
	if args[0] == "prev-tab" {
		offset *= -1
	}

	app.SelectTabAtOffset(offset)
	app.UpdateStatus()
	return nil
}