summary refs log tree commit diff stats
path: root/commands/account/compose.go
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-05-14 16:18:21 -0400
committerDrew DeVault <sir@cmpwn.com>2019-05-14 16:18:59 -0400
commit2c486cb7f52ac5dd88f7445ca79726639e4a0084 (patch)
tree552b1fe370f1fd2344687c7e55ada9d80c0bc9a7 /commands/account/compose.go
parent065da5e37230976d85d163a6f682eddb9345aede (diff)
downloadaerc-2c486cb7f52ac5dd88f7445ca79726639e4a0084.tar.gz
Update tab name as subject changes
Also moves truncation to the tab widget
Diffstat (limited to 'commands/account/compose.go')
-rw-r--r--commands/account/compose.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/commands/account/compose.go b/commands/account/compose.go
index 10be9ae..8097d10 100644
--- a/commands/account/compose.go
+++ b/commands/account/compose.go
@@ -3,8 +3,6 @@ package account
 import (
 	"errors"
 
-	"github.com/mattn/go-runewidth"
-
 	"git.sr.ht/~sircmpwn/aerc2/widgets"
 )
 
@@ -19,9 +17,15 @@ func Compose(aerc *widgets.Aerc, args []string) error {
 	}
 	acct := aerc.SelectedAccount()
 	composer := widgets.NewComposer(aerc.Config(), acct.AccountConfig())
-	// TODO: Change tab name when message subject changes
-	aerc.NewTab(composer, runewidth.Truncate(
-		"New email", 32, "…"))
+	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
 }