aerc/commands/account/compose.go
Drew DeVault 2c486cb7f5 Update tab name as subject changes
Also moves truncation to the tab widget
2019-05-14 16:18:59 -04:00

32 lines
627 B
Go

package account
import (
"errors"
"git.sr.ht/~sircmpwn/aerc2/widgets"
)
func init() {
register("compose", Compose)
}
// TODO: Accept arguments for default headers, message body
func Compose(aerc *widgets.Aerc, args []string) error {
if len(args) != 1 {
return errors.New("Usage: compose")
}
acct := aerc.SelectedAccount()
composer := widgets.NewComposer(aerc.Config(), acct.AccountConfig())
tab := aerc.NewTab(composer, "New email")
composer.OnSubjectChange(func(subject string) {
if subject == "" {
tab.Name = "New email"
} else {
tab.Name = subject
}
tab.Content.Invalidate()
})
return nil
}