| 1 |
package account |
| 2 |
|
| 3 |
import ( |
| 4 |
"errors" |
| 5 |
|
| 6 |
"git.sr.ht/~rjarry/aerc/app" |
| 7 |
"git.sr.ht/~rjarry/aerc/commands" |
| 8 |
"git.sr.ht/~rjarry/aerc/lib/ui" |
| 9 |
) |
| 10 |
|
| 11 |
type NextPrevResult struct{} |
| 12 |
|
| 13 |
func init() { |
| 14 |
commands.Register(NextPrevResult{}) |
| 15 |
} |
| 16 |
|
| 17 |
func (NextPrevResult) Description() string { |
| 18 |
return "Select the next or previous search result." |
| 19 |
} |
| 20 |
|
| 21 |
func (NextPrevResult) Context() commands.CommandContext { |
| 22 |
return commands.MESSAGE_LIST |
| 23 |
} |
| 24 |
|
| 25 |
func (NextPrevResult) Aliases() []string { |
| 26 |
return []string{"next-result", "prev-result"} |
| 27 |
} |
| 28 |
|
| 29 |
func (NextPrevResult) Execute(args []string) error { |
| 30 |
acct := app.SelectedAccount() |
| 31 |
if acct == nil { |
| 32 |
return errors.New("No account selected") |
| 33 |
} |
| 34 |
if args[0] == "prev-result" { |
| 35 |
store := acct.Store() |
| 36 |
if store != nil { |
| 37 |
store.PrevResult() |
| 38 |
} |
| 39 |
ui.Invalidate() |
| 40 |
} else { |
| 41 |
store := acct.Store() |
| 42 |
if store != nil { |
| 43 |
store.NextResult() |
| 44 |
} |
| 45 |
ui.Invalidate() |
| 46 |
} |
| 47 |
return nil |
| 48 |
} |