diff options
author | Daniel Bridges <bridges2@gmail.com> | 2019-07-22 16:29:07 -0700 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-07-26 14:22:04 -0400 |
commit | 67fb0938a66605a0b6a837005804637b348b250d (patch) | |
tree | b9bb363185b248ae8eed29e7b8388d8a71433d3e /commands | |
parent | 1b673b5ea7d06ef914e9d48ff7299f8b5f2119fd (diff) |
Support configurable header layout in compose widget
Diffstat (limited to 'commands')
-rw-r--r-- | commands/account/compose.go | 4 | ||||
-rw-r--r-- | commands/msg/reply.go | 17 | ||||
-rw-r--r-- | commands/msg/unsubscribe.go | 14 |
3 files changed, 20 insertions, 15 deletions
diff --git a/commands/account/compose.go b/commands/account/compose.go index cafba78..f615c0b 100644 --- a/commands/account/compose.go +++ b/commands/account/compose.go @@ -27,9 +27,9 @@ func (_ Compose) Execute(aerc *widgets.Aerc, args []string) error { } acct := aerc.SelectedAccount() composer := widgets.NewComposer( - aerc.Config(), acct.AccountConfig(), acct.Worker()) + aerc.Config(), acct.AccountConfig(), acct.Worker(), nil) tab := aerc.NewTab(composer, "New email") - composer.OnSubjectChange(func(subject string) { + composer.OnHeaderChange("Subject", func(subject string) { if subject == "" { tab.Name = "New email" } else { diff --git a/commands/msg/reply.go b/commands/msg/reply.go index 85c5d3a..029cb42 100644 --- a/commands/msg/reply.go +++ b/commands/msg/reply.go @@ -113,14 +113,15 @@ func (_ reply) Execute(aerc *widgets.Aerc, args []string) error { } } + defaults := map[string]string{ + "To": strings.Join(to, ", "), + "Cc": strings.Join(cc, ", "), + "Subject": subject, + "In-Reply-To": msg.Envelope.MessageId, + } + composer := widgets.NewComposer( - aerc.Config(), acct.AccountConfig(), acct.Worker()). - Defaults(map[string]string{ - "To": strings.Join(to, ", "), - "Cc": strings.Join(cc, ", "), - "Subject": subject, - "In-Reply-To": msg.Envelope.MessageId, - }) + aerc.Config(), acct.AccountConfig(), acct.Worker(), defaults) if args[0] == "reply" { composer.FocusTerminal() @@ -128,7 +129,7 @@ func (_ reply) Execute(aerc *widgets.Aerc, args []string) error { addTab := func() { tab := aerc.NewTab(composer, subject) - composer.OnSubjectChange(func(subject string) { + composer.OnHeaderChange("Subject", func(subject string) { if subject == "" { tab.Name = "New email" } else { diff --git a/commands/msg/unsubscribe.go b/commands/msg/unsubscribe.go index 720ff43..f18da07 100644 --- a/commands/msg/unsubscribe.go +++ b/commands/msg/unsubscribe.go @@ -83,15 +83,19 @@ func parseUnsubscribeMethods(header string) (methods []*url.URL) { func unsubscribeMailto(aerc *widgets.Aerc, u *url.URL) error { widget := aerc.SelectedTab().(widgets.ProvidesMessage) acct := widget.SelectedAccount() - composer := widgets.NewComposer(aerc.Config(), acct.AccountConfig(), - acct.Worker()) - composer.Defaults(map[string]string{ + defaults := map[string]string{ "To": u.Opaque, "Subject": u.Query().Get("subject"), - }) + } + composer := widgets.NewComposer( + aerc.Config(), + acct.AccountConfig(), + acct.Worker(), + defaults, + ) composer.SetContents(strings.NewReader(u.Query().Get("body"))) tab := aerc.NewTab(composer, "unsubscribe") - composer.OnSubjectChange(func(subject string) { + composer.OnHeaderChange("Subject", func(subject string) { if subject == "" { tab.Name = "unsubscribe" } else { |