aboutsummaryrefslogblamecommitdiffstats
path: root/commands/account/compose.go
blob: 1ffd2e26953ee945d1aa679325f8a1aecdf5d2dc (plain) (tree)
1
2
3
4
5




                











                                                           
                                      

                                                                   








                                                       



                  
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(), acct.Worker())
	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
}