From d2e74cdb91e140b50d14c3a8b315cde272f32587 Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Tue, 27 Dec 2022 22:59:10 +0100 Subject: statusline: add column based render format In the spirit of commit 535300cfdbfc ("config: add columns based index format"), reuse the column definitions and table widget. Add automatic translation of render-format to column definitions. Allow empty columns to be compatible with the %m (mute) flag. Rename the State object to AccountState to be more precise. Reuse that object in state.TempateData to expose account state info. Move actual status line rendering in StatusLine.Draw(). Add new template fields for status specific data: {{.ConnectionInfo}} Connection state. {{.ContentInfo}} General status information (e.g. filter, search) {{.StatusInfo}} Combination of {{.ConnectionInfo}} and {{.StatusInfo}} {{.TrayInfo}} General on/off information (e.g. passthrough, threading, sorting) {{.PendingKeys}} Currently pressed key sequence that does not match any key binding and/or is incomplete. Display a warning on startup if render-format has been converted to status-columns. Signed-off-by: Robin Jarry Acked-by: Tim Culverhouse --- lib/state/texter.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'lib/state/texter.go') diff --git a/lib/state/texter.go b/lib/state/texter.go index 21cf3627..9212108d 100644 --- a/lib/state/texter.go +++ b/lib/state/texter.go @@ -1,8 +1,12 @@ package state -import "strings" +import ( + "strings" -type Texter interface { + "git.sr.ht/~rjarry/aerc/config" +) + +type texterInterface interface { Connected() string Disconnected() string Passthrough() string @@ -14,6 +18,8 @@ type Texter interface { type text struct{} +var txt text + func (t text) Connected() string { return "Connected" } @@ -44,6 +50,8 @@ func (t text) FormatSearch(s string) string { type icon struct{} +var icn icon + func (i icon) Connected() string { return "✓" } @@ -71,3 +79,12 @@ func (i icon) FormatFilter(s string) string { func (i icon) FormatSearch(s string) string { return strings.ReplaceAll(s, "search", "🔎") } + +func texter() texterInterface { + switch strings.ToLower(config.Statusline.DisplayMode) { + case "icon": + return &icn + default: + return &txt + } +} -- cgit