aerc

Working clone of aerc-mail.org
git clone git://git.danielmoch.com/aerc.git
Log | Files | Refs | README | LICENSE

compose.go (642B)


      1 package account
      2 
      3 import (
      4 	"errors"
      5 
      6 	"git.sr.ht/~sircmpwn/aerc/widgets"
      7 )
      8 
      9 func init() {
     10 	register("compose", Compose)
     11 }
     12 
     13 // TODO: Accept arguments for default headers, message body
     14 func Compose(aerc *widgets.Aerc, args []string) error {
     15 	if len(args) != 1 {
     16 		return errors.New("Usage: compose")
     17 	}
     18 	acct := aerc.SelectedAccount()
     19 	composer := widgets.NewComposer(
     20 		aerc.Config(), acct.AccountConfig(), acct.Worker())
     21 	tab := aerc.NewTab(composer, "New email")
     22 	composer.OnSubjectChange(func(subject string) {
     23 		if subject == "" {
     24 			tab.Name = "New email"
     25 		} else {
     26 			tab.Name = subject
     27 		}
     28 		tab.Content.Invalidate()
     29 	})
     30 	return nil
     31 }