From 2512c0403fa42b19c3e87fed44240da045ec902f Mon Sep 17 00:00:00 2001 From: Koni Marti Date: Fri, 18 Mar 2022 22:35:33 +0100 Subject: statusline: implement per-account status Implement a statusline state for each account. Keep the ex line and the push notifications global. Add account name prefix to push notifications. Prefix status line with account name when multiple accounts are available. Use account-specific status line for each tab where an account is defined. Handle threading, filter/search, viewer passthrough and connection status. Signed-off-by: Koni Marti Acked-by: Robin Jarry --- commands/account/clear.go | 4 +++- commands/account/connection.go | 12 ++++++++---- commands/account/search.go | 11 ++++++----- commands/msg/toggle-threads.go | 2 ++ commands/msgview/toggle-key-passthrough.go | 7 +++---- commands/next-tab.go | 1 + 6 files changed, 23 insertions(+), 14 deletions(-) (limited to 'commands') diff --git a/commands/account/clear.go b/commands/account/clear.go index 259a9de..64e7012 100644 --- a/commands/account/clear.go +++ b/commands/account/clear.go @@ -3,6 +3,7 @@ package account import ( "errors" + "git.sr.ht/~rjarry/aerc/lib/statusline" "git.sr.ht/~rjarry/aerc/widgets" ) @@ -30,6 +31,7 @@ func (Clear) Execute(aerc *widgets.Aerc, args []string) error { return errors.New("Cannot perform action. Messages still loading") } store.ApplyClear() - aerc.ClearExtraStatus() + acct.SetStatus(statusline.SearchFilterClear()) + return nil } diff --git a/commands/account/connection.go b/commands/account/connection.go index a87993b..52b569c 100644 --- a/commands/account/connection.go +++ b/commands/account/connection.go @@ -3,6 +3,7 @@ package account import ( "errors" + "git.sr.ht/~rjarry/aerc/lib/statusline" "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~rjarry/aerc/worker/types" ) @@ -26,12 +27,15 @@ func (Connection) Execute(aerc *widgets.Aerc, args []string) error { if acct == nil { return errors.New("No account selected") } + cb := func(msg types.WorkerMessage) { + acct.SetStatus(statusline.ConnectionActivity("")) + } if args[0] == "connect" { - acct.Worker().PostAction(&types.Connect{}, nil) - acct.SetStatus("Connecting...") + acct.Worker().PostAction(&types.Connect{}, cb) + acct.SetStatus(statusline.ConnectionActivity("Connecting...")) } else { - acct.Worker().PostAction(&types.Disconnect{}, nil) - acct.SetStatus("Disconnecting...") + acct.Worker().PostAction(&types.Disconnect{}, cb) + acct.SetStatus(statusline.ConnectionActivity("Disconnecting...")) } return nil } diff --git a/commands/account/search.go b/commands/account/search.go index 86d9dea..eeee7bd 100644 --- a/commands/account/search.go +++ b/commands/account/search.go @@ -2,8 +2,9 @@ package account import ( "errors" - "fmt" + "strings" + "git.sr.ht/~rjarry/aerc/lib/statusline" "git.sr.ht/~rjarry/aerc/widgets" ) @@ -33,16 +34,16 @@ func (SearchFilter) Execute(aerc *widgets.Aerc, args []string) error { var cb func([]uint32) if args[0] == "filter" { - aerc.SetExtraStatus("Filtering...") + acct.SetStatus(statusline.FilterActivity("Filtering..."), statusline.Search("")) cb = func(uids []uint32) { - aerc.SetExtraStatus(fmt.Sprintf("%s", args)) + acct.SetStatus(statusline.FilterResult(strings.Join(args, " "))) acct.Logger().Printf("Filter results: %v", uids) store.ApplyFilter(uids) } } else { - aerc.SetExtraStatus("Searching...") + acct.SetStatus(statusline.Search("Searching...")) cb = func(uids []uint32) { - aerc.SetExtraStatus(fmt.Sprintf("%s", args)) + acct.SetStatus(statusline.Search(strings.Join(args, " "))) acct.Logger().Printf("Search results: %v", uids) store.ApplySearch(uids) // TODO: Remove when stores have multiple OnUpdate handlers diff --git a/commands/msg/toggle-threads.go b/commands/msg/toggle-threads.go index e93cb42..79d515c 100644 --- a/commands/msg/toggle-threads.go +++ b/commands/msg/toggle-threads.go @@ -3,6 +3,7 @@ package msg import ( "errors" + "git.sr.ht/~rjarry/aerc/lib/statusline" "git.sr.ht/~rjarry/aerc/widgets" ) @@ -34,6 +35,7 @@ func (ToggleThreads) Execute(aerc *widgets.Aerc, args []string) error { return err } store.SetBuildThreads(!store.BuildThreads()) + acct.SetStatus(statusline.Threading(store.BuildThreads())) acct.Messages().Invalidate() return nil } diff --git a/commands/msgview/toggle-key-passthrough.go b/commands/msgview/toggle-key-passthrough.go index 6cd575b..1ac370e 100644 --- a/commands/msgview/toggle-key-passthrough.go +++ b/commands/msgview/toggle-key-passthrough.go @@ -3,6 +3,7 @@ package msgview import ( "errors" + "git.sr.ht/~rjarry/aerc/lib/statusline" "git.sr.ht/~rjarry/aerc/widgets" ) @@ -26,10 +27,8 @@ func (ToggleKeyPassthrough) Execute(aerc *widgets.Aerc, args []string) error { } mv, _ := aerc.SelectedTab().(*widgets.MessageViewer) keyPassthroughEnabled := mv.ToggleKeyPassthrough() - if keyPassthroughEnabled { - aerc.SetExtraStatus("[passthrough]") - } else { - aerc.ClearExtraStatus() + if acct := mv.SelectedAccount(); acct != nil { + acct.SetStatus(statusline.Passthrough(keyPassthroughEnabled)) } return nil } diff --git a/commands/next-tab.go b/commands/next-tab.go index 9d6a09b..854353f 100644 --- a/commands/next-tab.go +++ b/commands/next-tab.go @@ -42,6 +42,7 @@ func (NextPrevTab) Execute(aerc *widgets.Aerc, args []string) error { aerc.NextTab() } } + aerc.UpdateStatus() return nil } -- cgit v1.2.3