aboutsummaryrefslogtreecommitdiff
path: root/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'widgets')
-rw-r--r--widgets/aerc.go40
-rw-r--r--widgets/compose.go7
2 files changed, 47 insertions, 0 deletions
diff --git a/widgets/aerc.go b/widgets/aerc.go
index a73caec..14cf3c4 100644
--- a/widgets/aerc.go
+++ b/widgets/aerc.go
@@ -1,7 +1,10 @@
package widgets
import (
+ "errors"
"log"
+ "net/url"
+ "strings"
"time"
"github.com/gdamore/tcell"
@@ -302,3 +305,40 @@ func (aerc *Aerc) BeginExCommand() {
aerc.statusbar.Push(exline)
aerc.focus(exline)
}
+
+func (aerc *Aerc) Mailto(addr *url.URL) error {
+ acct := aerc.SelectedAccount()
+ if acct == nil {
+ return errors.New("No account selected")
+ }
+ defaults := make(map[string]string)
+ defaults["To"] = addr.Opaque
+ headerMap := map[string]string{
+ "cc": "Cc",
+ "in-reply-to": "In-Reply-To",
+ "subject": "Subject",
+ }
+ for key, vals := range addr.Query() {
+ if header, ok := headerMap[strings.ToLower(key)]; ok {
+ defaults[header] = strings.Join(vals, ",")
+ }
+ }
+ composer := NewComposer(aerc.Config(),
+ acct.AccountConfig(), acct.Worker()).Defaults(defaults)
+ composer.FocusSubject()
+ title := "New email"
+ if subj, ok := defaults["Subject"]; ok {
+ title = subj
+ composer.FocusTerminal()
+ }
+ tab := aerc.NewTab(composer, title)
+ composer.OnSubjectChange(func(subject string) {
+ if subject == "" {
+ tab.Name = "New email"
+ } else {
+ tab.Name = subject
+ }
+ tab.Content.Invalidate()
+ })
+ return nil
+}
diff --git a/widgets/compose.go b/widgets/compose.go
index f1c8014..401815c 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -138,6 +138,13 @@ func (c *Composer) FocusTerminal() *Composer {
return c
}
+func (c *Composer) FocusSubject() *Composer {
+ c.focusable[c.focused].Focus(false)
+ c.focused = 2
+ c.focusable[c.focused].Focus(true)
+ return c
+}
+
func (c *Composer) OnSubjectChange(fn func(subject string)) {
c.headers.subject.OnChange(func() {
fn(c.headers.subject.input.String())