From fc604b667939bfe52ab8758a9a369e2c63de4dbc Mon Sep 17 00:00:00 2001 From: Koni Marti Date: Thu, 24 Mar 2022 23:12:16 +0100 Subject: [PATCH] statusline: indicate when sorting is in progress Indicate when sorting is in progress in the statusline. Signed-off-by: Koni Marti Acked-by: Robin Jarry --- commands/account/sort.go | 5 +++-- lib/statusline/folderstate.go | 4 ++++ lib/statusline/state.go | 9 +++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/commands/account/sort.go b/commands/account/sort.go index c08991c..a35ff33 100644 --- a/commands/account/sort.go +++ b/commands/account/sort.go @@ -6,6 +6,7 @@ import ( "git.sr.ht/~rjarry/aerc/commands" "git.sr.ht/~rjarry/aerc/lib/sort" + "git.sr.ht/~rjarry/aerc/lib/statusline" "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~rjarry/aerc/worker/types" ) @@ -82,9 +83,9 @@ func (Sort) Execute(aerc *widgets.Aerc, args []string) error { } } - aerc.SetStatus("Sorting") + acct.SetStatus(statusline.Sorting(true)) store.Sort(sortCriteria, func() { - aerc.SetStatus("Sorting complete") + acct.SetStatus(statusline.Sorting(false)) }) return nil } diff --git a/lib/statusline/folderstate.go b/lib/statusline/folderstate.go index 50a8c82..ff470b7 100644 --- a/lib/statusline/folderstate.go +++ b/lib/statusline/folderstate.go @@ -4,6 +4,7 @@ type folderState struct { Search string Filter string FilterActivity string + Sorting string Threading string } @@ -21,6 +22,9 @@ func (fs *folderState) State() []string { if fs.Search != "" { line = append(line, fs.Search) } + if fs.Sorting != "" { + line = append(line, fs.Sorting) + } if fs.Threading != "" { line = append(line, fs.Threading) } diff --git a/lib/statusline/state.go b/lib/statusline/state.go index fe32626..895bb2c 100644 --- a/lib/statusline/state.go +++ b/lib/statusline/state.go @@ -109,6 +109,15 @@ func Search(desc string) SetStateFunc { } } +func Sorting(on bool) SetStateFunc { + return func(s *State, folder string) { + s.folderState(folder).Sorting = "" + if on { + s.folderState(folder).Sorting = "sorting" + } + } +} + func Threading(on bool) SetStateFunc { return func(s *State, folder string) { s.folderState(folder).Threading = ""