summaryrefslogtreecommitdiff
path: root/widgets/dirlist.go
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2022-02-21 00:18:42 +0100
committerRobin Jarry <robin@jarry.cc>2022-02-23 21:09:01 +0100
commit454606a9cd85923cc98e4d43ea8b8972de6a5e9c (patch)
treeced698391543007f9ed1b3e752ee40a44a62a197 /widgets/dirlist.go
parent5eac8d603e8807f7d4be58a4a7b03862a8c90df2 (diff)
downloadaerc-454606a9cd85923cc98e4d43ea8b8972de6a5e9c.zip
dirtree: implement foldable tree for directory list
implement a foldable tree for the directory list. Expand all parent directories when a hidden directory is selected with the change-folder command. folders-sort considers the top-level directories only. The folders and foldersexclude filters work with the full directory path. Enable tree view by adding 'dirlist-tree=true' to the config file. Implements: https://todo.sr.ht/~sircmpwn/aerc2/228 Signed-off-by: Koni Marti <koni.marti@gmail.com>
Diffstat (limited to 'widgets/dirlist.go')
-rw-r--r--widgets/dirlist.go35
1 files changed, 34 insertions, 1 deletions
diff --git a/widgets/dirlist.go b/widgets/dirlist.go
index 6f8869d..9535c69 100644
--- a/widgets/dirlist.go
+++ b/widgets/dirlist.go
@@ -4,6 +4,7 @@ import (
"fmt"
"log"
"math"
+ "os"
"regexp"
"sort"
"time"
@@ -19,6 +20,25 @@ import (
"git.sr.ht/~rjarry/aerc/worker/types"
)
+type DirectoryLister interface {
+ ui.Drawable
+
+ Selected() string
+ Select(string)
+
+ UpdateList(func([]string))
+ List() []string
+
+ NextPrev(int)
+
+ CollapseFolder()
+ ExpandFolder()
+
+ SelectedMsgStore() (*lib.MessageStore, bool)
+ MsgStore(string) (*lib.MessageStore, bool)
+ SetMsgStore(string, *lib.MessageStore)
+}
+
type DirectoryList struct {
ui.Invalidatable
aercConf *config.AercConfig
@@ -35,7 +55,7 @@ type DirectoryList struct {
}
func NewDirectoryList(conf *config.AercConfig, acctConf *config.AccountConfig,
- logger *log.Logger, worker *types.Worker) *DirectoryList {
+ logger *log.Logger, worker *types.Worker) DirectoryLister {
dirlist := &DirectoryList{
aercConf: conf,
@@ -51,6 +71,11 @@ func NewDirectoryList(conf *config.AercConfig, acctConf *config.AccountConfig,
dirlist.Invalidate()
})
dirlist.spinner.Start()
+
+ if uiConf.DirListTree {
+ return NewDirectoryTree(dirlist, string(os.PathSeparator))
+ }
+
return dirlist
}
@@ -88,6 +113,14 @@ func (dirlist *DirectoryList) UpdateList(done func(dirs []string)) {
})
}
+func (dirlist *DirectoryList) CollapseFolder() {
+ // no effect for the DirectoryList
+}
+
+func (dirlist *DirectoryList) ExpandFolder() {
+ // no effect for the DirectoryList
+}
+
func (dirlist *DirectoryList) Select(name string) {
dirlist.selecting = name