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