From ce18e928813526e59462e391c09e868c62facb42 Mon Sep 17 00:00:00 2001 From: Koni Marti Date: Mon, 18 Apr 2022 16:06:27 +0200 Subject: statusline: refactor to make it more customizable Refactor statusline by clearly separating the rendering part from the text display. Use printf-like format string for statusline customization. Document printf-like format string to customize the statusline. Allow to completely mute the statusline (except for push notifications) with a format specifier. Provide a display mode with unicode icons for the status elements. Implements: https://todo.sr.ht/~rjarry/aerc/34 Signed-off-by: Koni Marti Acked-by: Robin Jarry --- config/aerc.conf | 17 +++++++++++++++++ config/config.go | 28 +++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 5 deletions(-) (limited to 'config') diff --git a/config/aerc.conf b/config/aerc.conf index 1ad7ce5a..458f6359 100644 --- a/config/aerc.conf +++ b/config/aerc.conf @@ -139,6 +139,23 @@ styleset-name=default # Default: false #threading-enabled=false +[statusline] +# Describes the format string for the statusline. +# +# Default: [%a] %S %>%T +render-format=[%a] %S %>%T + +# Specifies the separator between grouped statusline elements. +# +# Default: " | " +# separator= + +# Defines the mode for displaying the status elements. +# Options: text, icon +# +# Default: text +# display-mode= + [viewer] # # Specifies the pager to use when displaying emails. Note that some filters diff --git a/config/config.go b/config/config.go index f8b2f650..8eeea100 100644 --- a/config/config.go +++ b/config/config.go @@ -147,6 +147,12 @@ type ViewerConfig struct { KeyPassthrough bool `ini:"-"` } +type StatuslineConfig struct { + RenderFormat string `ini:"render-format"` + Separator string + DisplayMode string `ini:"display-mode"` +} + type TriggersConfig struct { NewEmail string `ini:"new-email"` ExecuteCommand func(command []string) error @@ -163,11 +169,12 @@ type AercConfig struct { Bindings BindingConfig ContextualBinds []BindingConfigContext Compose ComposeConfig - Ini *ini.File `ini:"-"` - Accounts []AccountConfig `ini:"-"` - Filters []FilterConfig `ini:"-"` - Viewer ViewerConfig `ini:"-"` - Triggers TriggersConfig `ini:"-"` + Ini *ini.File `ini:"-"` + Accounts []AccountConfig `ini:"-"` + Filters []FilterConfig `ini:"-"` + Viewer ViewerConfig `ini:"-"` + Statusline StatuslineConfig `ini:"-"` + Triggers TriggersConfig `ini:"-"` Ui UIConfig ContextualUis []UIConfigContext General GeneralConfig @@ -410,6 +417,11 @@ func (config *AercConfig) LoadConfig(file *ini.File) error { } } } + if statusline, err := file.GetSection("statusline"); err == nil { + if err := statusline.MapTo(&config.Statusline); err != nil { + return err + } + } if compose, err := file.GetSection("compose"); err == nil { if err := compose.MapTo(&config.Compose); err != nil { return err @@ -654,6 +666,12 @@ func LoadConfigFromFile(root *string, logger *log.Logger) (*AercConfig, error) { }, }, + Statusline: StatuslineConfig{ + RenderFormat: "[%a] %S %>%T", + Separator: " | ", + DisplayMode: "", + }, + Compose: ComposeConfig{ HeaderLayout: [][]string{ {"To", "From"}, -- cgit