aerc/commands/account/compose.go

42 lines
839 B
Go
Raw Normal View History

2019-05-12 04:06:09 +00:00
package account
import (
"errors"
2019-05-18 00:57:10 +00:00
"git.sr.ht/~sircmpwn/aerc/widgets"
2019-05-12 04:06:09 +00:00
)
type Compose struct{}
2019-05-12 04:06:09 +00:00
func init() {
register(Compose{})
}
func (_ Compose) Aliases() []string {
return []string{"compose"}
}
func (_ Compose) Complete(aerc *widgets.Aerc, args []string) []string {
return nil
2019-05-12 04:06:09 +00:00
}
// TODO: Accept arguments for default headers, message body
func (_ Compose) Execute(aerc *widgets.Aerc, args []string) error {
2019-05-12 04:06:09 +00:00
if len(args) != 1 {
return errors.New("Usage: compose")
}
acct := aerc.SelectedAccount()
composer := widgets.NewComposer(
aerc.Config(), acct.AccountConfig(), acct.Worker(), nil)
tab := aerc.NewTab(composer, "New email")
composer.OnHeaderChange("Subject", func(subject string) {
if subject == "" {
tab.Name = "New email"
} else {
tab.Name = subject
}
tab.Content.Invalidate()
})
2019-05-12 04:06:09 +00:00
return nil
}