statusline: indicate when sorting is in progress

Indicate when sorting is in progress in the statusline.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
Koni Marti 2022-03-24 23:12:16 +01:00 committed by Robin Jarry
parent 20218de913
commit fc604b6679
3 changed files with 16 additions and 2 deletions

View File

@ -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
}

View File

@ -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)
}

View File

@ -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 = ""