aboutsummaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2023-02-03 13:23:08 -0600
committerRobin Jarry <robin@jarry.cc>2023-02-12 00:39:21 +0100
commit2a0da301c51a8862c4e8a73b141adc0f416833a5 (patch)
treedabf9adbef3a4732daae91acb11be941ff3c47f9 /commands
parent2df3a079a060bb56aaa4d94df066936cb7b73f9d (diff)
downloadaerc-2a0da301c51a8862c4e8a73b141adc0f416833a5.tar.gz
tabs: use template for compose tabs
Use a template for compose tabs. Other available values: Account string Subject string To []*mail.Address From []*mail.Address Cc []*mail.Address Bcc []*mail.Address OriginalFrom []*mail.Address When you use To, From, CC, BCC, or OriginalFrom the title will only be updated when an editing field has lost focus. This is so we don't end up calling "PrepareHeader" on every keystroke, which will likely error out anyways since it will be an invalid header. Subject still updates every keystroke. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'commands')
-rw-r--r--commands/account/compose.go11
-rw-r--r--commands/account/recover.go7
-rw-r--r--commands/msg/forward.go11
-rw-r--r--commands/msg/invite.go11
-rw-r--r--commands/msg/recall.go11
-rw-r--r--commands/msg/reply.go11
-rw-r--r--commands/msg/unsubscribe.go11
7 files changed, 7 insertions, 66 deletions
diff --git a/commands/account/compose.go b/commands/account/compose.go
index 5695bb7d..a8b16791 100644
--- a/commands/account/compose.go
+++ b/commands/account/compose.go
@@ -11,7 +11,6 @@ import (
"github.com/emersion/go-message/mail"
"git.sr.ht/~rjarry/aerc/config"
- "git.sr.ht/~rjarry/aerc/lib/ui"
"git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/widgets"
"git.sr.ht/~sircmpwn/getopt"
@@ -58,15 +57,7 @@ func (Compose) Execute(aerc *widgets.Aerc, args []string) error {
if err != nil {
return err
}
- tab := aerc.NewTab(composer, "New email")
- composer.OnHeaderChange("Subject", func(subject string) {
- if subject == "" {
- tab.Name = "New email"
- } else {
- tab.Name = subject
- }
- ui.Invalidate()
- })
+ composer.Tab = aerc.NewTab(composer, "New email")
go func() {
defer log.PanicHandler()
diff --git a/commands/account/recover.go b/commands/account/recover.go
index cef0720f..cccadf8d 100644
--- a/commands/account/recover.go
+++ b/commands/account/recover.go
@@ -8,7 +8,6 @@ import (
"path/filepath"
"git.sr.ht/~rjarry/aerc/commands"
- "git.sr.ht/~rjarry/aerc/lib/ui"
"git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/widgets"
"git.sr.ht/~sircmpwn/getopt"
@@ -107,11 +106,7 @@ func (Recover) Execute(aerc *widgets.Aerc, args []string) error {
return err
}
- tab := aerc.NewTab(composer, "Recovered")
- composer.OnHeaderChange("Subject", func(subject string) {
- tab.Name = subject
- ui.Invalidate()
- })
+ composer.Tab = aerc.NewTab(composer, "Recovered")
go func() {
defer log.PanicHandler()
diff --git a/commands/msg/forward.go b/commands/msg/forward.go
index 90c32ec2..92575abd 100644
--- a/commands/msg/forward.go
+++ b/commands/msg/forward.go
@@ -15,7 +15,6 @@ import (
"git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/lib/format"
- "git.sr.ht/~rjarry/aerc/lib/ui"
"git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
@@ -107,20 +106,12 @@ func (forward) Execute(aerc *widgets.Aerc, args []string) error {
return nil, err
}
- tab := aerc.NewTab(composer, subject)
+ composer.Tab = aerc.NewTab(composer, subject)
if !h.Has("to") {
composer.FocusEditor("to")
} else {
composer.FocusTerminal()
}
- composer.OnHeaderChange("Subject", func(subject string) {
- if subject == "" {
- tab.Name = "New email"
- } else {
- tab.Name = subject
- }
- ui.Invalidate()
- })
return composer, nil
}
diff --git a/commands/msg/invite.go b/commands/msg/invite.go
index 1528abea..774c4a69 100644
--- a/commands/msg/invite.go
+++ b/commands/msg/invite.go
@@ -9,7 +9,6 @@ import (
"git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/lib/calendar"
"git.sr.ht/~rjarry/aerc/lib/format"
- "git.sr.ht/~rjarry/aerc/lib/ui"
"git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
@@ -152,15 +151,7 @@ func (invite) Execute(aerc *widgets.Aerc, args []string) error {
}
composer.FocusTerminal()
- tab := aerc.NewTab(composer, subject)
- composer.OnHeaderChange("Subject", func(subject string) {
- if subject == "" {
- tab.Name = "New email"
- } else {
- tab.Name = subject
- }
- ui.Invalidate()
- })
+ composer.Tab = aerc.NewTab(composer, subject)
composer.OnClose(func(c *widgets.Composer) {
if c.Sent() {
diff --git a/commands/msg/recall.go b/commands/msg/recall.go
index 2ef468e0..4eda8339 100644
--- a/commands/msg/recall.go
+++ b/commands/msg/recall.go
@@ -13,7 +13,6 @@ import (
"github.com/pkg/errors"
"git.sr.ht/~rjarry/aerc/lib"
- "git.sr.ht/~rjarry/aerc/lib/ui"
"git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
@@ -87,15 +86,7 @@ func (Recall) Execute(aerc *widgets.Aerc, args []string) error {
if subject == "" {
subject = "Recalled email"
}
- tab := aerc.NewTab(composer, subject)
- composer.OnHeaderChange("Subject", func(subject string) {
- if subject == "" {
- tab.Name = "New email"
- } else {
- tab.Name = subject
- }
- ui.Invalidate()
- })
+ composer.Tab = aerc.NewTab(composer, subject)
composer.OnClose(func(composer *widgets.Composer) {
worker := composer.Worker()
uids := []uint32{msgInfo.Uid}
diff --git a/commands/msg/reply.go b/commands/msg/reply.go
index f8cde644..8a244fed 100644
--- a/commands/msg/reply.go
+++ b/commands/msg/reply.go
@@ -16,7 +16,6 @@ import (
"git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/lib/crypto"
"git.sr.ht/~rjarry/aerc/lib/format"
- "git.sr.ht/~rjarry/aerc/lib/ui"
"git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
@@ -190,15 +189,7 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error {
composer.FocusTerminal()
}
- tab := aerc.NewTab(composer, subject)
- composer.OnHeaderChange("Subject", func(subject string) {
- if subject == "" {
- tab.Name = "New email"
- } else {
- tab.Name = subject
- }
- ui.Invalidate()
- })
+ composer.Tab = aerc.NewTab(composer, subject)
composer.OnClose(func(c *widgets.Composer) {
switch {
diff --git a/commands/msg/unsubscribe.go b/commands/msg/unsubscribe.go
index 37ed707f..46ff5d1f 100644
--- a/commands/msg/unsubscribe.go
+++ b/commands/msg/unsubscribe.go
@@ -9,7 +9,6 @@ import (
"time"
"git.sr.ht/~rjarry/aerc/lib"
- "git.sr.ht/~rjarry/aerc/lib/ui"
"git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/widgets"
"github.com/emersion/go-message/mail"
@@ -160,15 +159,7 @@ func unsubscribeMailto(aerc *widgets.Aerc, u *url.URL) error {
return err
}
composer.SetContents(strings.NewReader(u.Query().Get("body")))
- tab := aerc.NewTab(composer, "unsubscribe")
- composer.OnHeaderChange("Subject", func(subject string) {
- if subject == "" {
- tab.Name = "unsubscribe"
- } else {
- tab.Name = subject
- }
- ui.Invalidate()
- })
+ composer.Tab = aerc.NewTab(composer, "unsubscribe")
composer.FocusTerminal()
return nil
}