From 2c486cb7f52ac5dd88f7445ca79726639e4a0084 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 14 May 2019 16:18:21 -0400 Subject: Update tab name as subject changes Also moves truncation to the tab widget --- commands/account/compose.go | 14 +++++++++----- commands/account/view-message.go | 5 +---- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'commands') 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 } diff --git a/commands/account/view-message.go b/commands/account/view-message.go index ea6addc..3697aa7 100644 --- a/commands/account/view-message.go +++ b/commands/account/view-message.go @@ -3,8 +3,6 @@ package account import ( "errors" - "github.com/mattn/go-runewidth" - "git.sr.ht/~sircmpwn/aerc2/widgets" ) @@ -26,8 +24,7 @@ func ViewMessage(aerc *widgets.Aerc, args []string) error { return nil } viewer := widgets.NewMessageViewer(aerc.Config(), store, msg) - aerc.NewTab(viewer, runewidth.Truncate( - msg.Envelope.Subject, 32, "…")) + aerc.NewTab(viewer, msg.Envelope.Subject) return nil } -- cgit 1.4.1-2-gfad0