From 2a0da301c51a8862c4e8a73b141adc0f416833a5 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Fri, 3 Feb 2023 13:23:08 -0600 Subject: 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 Acked-by: Robin Jarry --- config/ui.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'config') diff --git a/config/ui.go b/config/ui.go index 6c880293..db596d97 100644 --- a/config/ui.go +++ b/config/ui.go @@ -73,7 +73,8 @@ type UIConfig struct { SortThreadSiblings bool `ini:"sort-thread-siblings"` // Tab Templates - TabTitleAccount *template.Template `ini:"-"` + TabTitleAccount *template.Template `ini:"-"` + TabTitleComposer *template.Template `ini:"-"` // private contextualUis []*UiConfigContext @@ -106,6 +107,7 @@ func defaultUiConfig() *UIConfig { flags, _ := templates.ParseTemplate("column-flags", `{{.Flags | join ""}}`) subject, _ := templates.ParseTemplate("column-subject", "{{.Subject}}") tabTitleAccount, _ := templates.ParseTemplate("tab-title-account", "{{.Account}}") + tabTitleComposer, _ := templates.ParseTemplate("tab-title-composer", "{{.Subject}}") return &UIConfig{ IndexFormat: "", // deprecated IndexColumns: []*ColumnDef{ @@ -148,6 +150,7 @@ func defaultUiConfig() *UIConfig { ClientThreadsDelay: 50 * time.Millisecond, NewMessageBell: true, TabTitleAccount: tabTitleAccount, + TabTitleComposer: tabTitleComposer, FuzzyComplete: false, Spinner: "[..] , [..] , [..] , [..] , [..], [..] , [..] , [..] ", SpinnerDelimiter: ",", @@ -362,6 +365,14 @@ index-format will be removed in aerc 0.17. } config.TabTitleAccount = tmpl } + if key, err := section.GetKey("tab-title-composer"); err == nil { + val := key.Value() + tmpl, err := templates.ParseTemplate("tab-title-composer", val) + if err != nil { + return err + } + config.TabTitleComposer = tmpl + } return nil } -- cgit