2019-05-22 17:17:52 +02:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
2021-11-05 10:19:46 +01:00
|
|
|
"git.sr.ht/~rjarry/aerc/widgets"
|
2019-05-22 17:17:52 +02:00
|
|
|
)
|
|
|
|
|
2019-06-27 19:33:11 +02:00
|
|
|
type Help struct{}
|
|
|
|
|
2022-05-20 01:44:37 +02:00
|
|
|
var pages = []string{
|
|
|
|
"aerc",
|
|
|
|
"config",
|
|
|
|
"imap",
|
|
|
|
"notmuch",
|
|
|
|
"search",
|
|
|
|
"sendmail",
|
|
|
|
"smtp",
|
|
|
|
"stylesets",
|
|
|
|
"templates",
|
|
|
|
"tutorial",
|
2022-08-08 22:04:04 +02:00
|
|
|
"keys",
|
2022-05-20 01:44:37 +02:00
|
|
|
}
|
|
|
|
|
2019-05-22 17:17:52 +02:00
|
|
|
func init() {
|
2019-06-27 19:33:11 +02:00
|
|
|
register(Help{})
|
|
|
|
}
|
|
|
|
|
2019-09-03 21:34:03 +02:00
|
|
|
func (Help) Aliases() []string {
|
2019-06-27 19:33:11 +02:00
|
|
|
return []string{"help"}
|
|
|
|
}
|
|
|
|
|
2019-09-03 21:34:03 +02:00
|
|
|
func (Help) Complete(aerc *widgets.Aerc, args []string) []string {
|
2022-05-20 01:44:37 +02:00
|
|
|
return CompletionFromList(aerc, pages, args)
|
2019-05-22 17:17:52 +02:00
|
|
|
}
|
|
|
|
|
2019-09-03 21:34:03 +02:00
|
|
|
func (Help) Execute(aerc *widgets.Aerc, args []string) error {
|
2019-05-22 17:17:52 +02:00
|
|
|
page := "aerc"
|
2022-05-20 01:44:37 +02:00
|
|
|
if len(args) == 2 && args[1] != "aerc" {
|
2019-05-22 17:17:52 +02:00
|
|
|
page = "aerc-" + args[1]
|
|
|
|
} else if len(args) > 2 {
|
|
|
|
return errors.New("Usage: help [topic]")
|
|
|
|
}
|
2022-08-08 22:04:04 +02:00
|
|
|
|
|
|
|
if page == "aerc-keys" {
|
|
|
|
aerc.AddDialog(widgets.NewDialog(
|
|
|
|
widgets.NewListBox(
|
|
|
|
"Bindings: Press <Esc> or <Enter> to close. "+
|
|
|
|
"Start typing to filter bindings.",
|
|
|
|
aerc.HumanReadableBindings(),
|
|
|
|
aerc.SelectedAccountUiConfig(),
|
|
|
|
func(_ string) {
|
|
|
|
helpClose(aerc)
|
|
|
|
aerc.CloseDialog()
|
|
|
|
},
|
|
|
|
),
|
|
|
|
func(h int) int { return h / 4 },
|
|
|
|
func(h int) int { return h / 2 },
|
|
|
|
))
|
|
|
|
}
|
|
|
|
|
2019-06-27 19:33:11 +02:00
|
|
|
return TermCore(aerc, []string{"term", "man", page})
|
2019-05-22 17:17:52 +02:00
|
|
|
}
|
2022-08-08 22:04:04 +02:00
|
|
|
|
|
|
|
func helpClose(aerc *widgets.Aerc) {
|
|
|
|
if content, ok := aerc.SelectedTabContent().(*widgets.MessageViewer); ok {
|
|
|
|
content.UpdateScreen()
|
|
|
|
}
|
|
|
|
}
|