Debian Codegraph @

commands/compose/next-field.go

raw
1 package compose
2
3 import (
4 "fmt"
5
6 "git.sr.ht/~rjarry/aerc/app"
7 "git.sr.ht/~rjarry/aerc/commands"
8 )
9
10 type NextPrevField struct{}
11
12 func init() {
13 commands.Register(NextPrevField{})
14 }
15
16 func (NextPrevField) Description() string {
17 return "Cycle between header input fields."
18 }
19
20 func (NextPrevField) Context() commands.CommandContext {
21 return commands.COMPOSE_EDIT
22 }
23
24 func (NextPrevField) Aliases() []string {
25 return []string{"next-field", "prev-field"}
26 }
27
28 func (NextPrevField) Execute(args []string) error {
29 composer, _ := app.SelectedTabContent().(*app.Composer)
30 var ok bool
31 if args[0] == "prev-field" {
32 ok = composer.PrevField()
33 } else {
34 ok = composer.NextField()
35 }
36 if !ok {
37 return fmt.Errorf("%s not available when edit-headers=true", args[0])
38 }
39 return nil
40 }