diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2023-01-26 10:16:43 -0600 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-01-29 21:47:11 +0100 |
commit | 6b39c0dae1e1c42445a2d8557e48135b02fc729b (patch) | |
tree | d65d2898424178203c0be52c56c255f96f8d51ee /config/ui.go | |
parent | db60d7edeceaec075f91a802968c397698798d50 (diff) | |
download | aerc-6b39c0dae1e1c42445a2d8557e48135b02fc729b.tar.gz |
tabs: use template for account tab name
Use a go template to render the account tab display. Add config option
for setting a specific template for the account. Add a method on Tab to
allow setting a title, which may be different than the tab Name.
The default template is {{.Account}}.
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'config/ui.go')
-rw-r--r-- | config/ui.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/config/ui.go b/config/ui.go index 5f51140c..1b4c35fb 100644 --- a/config/ui.go +++ b/config/ui.go @@ -6,6 +6,7 @@ import ( "regexp" "strconv" "strings" + "text/template" "time" "git.sr.ht/~rjarry/aerc/lib/templates" @@ -72,6 +73,9 @@ type UIConfig struct { ReverseThreadOrder bool `ini:"reverse-thread-order"` SortThreadSiblings bool `ini:"sort-thread-siblings"` + // Tab Templates + TabTitleAccount *template.Template `ini:"-"` + // private contextualUis []*UiConfigContext contextualCounts map[uiContextType]int @@ -102,6 +106,7 @@ func defaultUiConfig() *UIConfig { name, _ := templates.ParseTemplate("column-name", "{{index (.From | names) 0}}") flags, _ := templates.ParseTemplate("column-flags", `{{.Flags | join ""}}`) subject, _ := templates.ParseTemplate("column-subject", "{{.Subject}}") + tabTitleAccount, _ := templates.ParseTemplate("tab-title-account", "{{.Account}}") return &UIConfig{ IndexFormat: "", // deprecated IndexColumns: []*ColumnDef{ @@ -144,6 +149,7 @@ func defaultUiConfig() *UIConfig { MouseEnabled: false, ClientThreadsDelay: 50 * time.Millisecond, NewMessageBell: true, + TabTitleAccount: tabTitleAccount, FuzzyComplete: false, Spinner: "[..] , [..] , [..] , [..] , [..], [..] , [..] , [..] ", SpinnerDelimiter: ",", @@ -336,6 +342,14 @@ func (config *UIConfig) parse(section *ini.Section) error { } config.IndexColumns = columns } + if key, err := section.GetKey("tab-title-account"); err == nil { + val := key.Value() + tmpl, err := templates.ParseTemplate("tab-title-account", val) + if err != nil { + return err + } + config.TabTitleAccount = tmpl + } return nil } |