aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/dirtree.go
diff options
context:
space:
mode:
authorSijmen <me@sijman.nl>2022-08-13 01:44:44 +0200
committerRobin Jarry <robin@jarry.cc>2022-08-22 09:45:02 +0200
commitdb39ca181adf61ebb5a89fe5eb7a1e0d6836be56 (patch)
tree5c966b33de809d6e4e836e80695ee34d34828944 /widgets/dirtree.go
parent7377b8b05a6276dd2913ca8836f9c7b96f3b09ca (diff)
downloadaerc-db39ca181adf61ebb5a89fe5eb7a1e0d6836be56.tar.gz
dirtree: add dirtree-collapse config setting
Adds a setting to the configuration to choose at which level the folders in the dirtree are collapsed by default. In my case, this is useful because my organisation has some rather deep nesting in the folder structure, and a _lot_ of folders, and this way I can keep my dirtree uncluttered while still having all folders there if I need them. Signed-off-by: Sijmen <me@sijman.nl> Acked-by: Koni Marti <koni.marti@gmail.com>
Diffstat (limited to 'widgets/dirtree.go')
-rw-r--r--widgets/dirtree.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/widgets/dirtree.go b/widgets/dirtree.go
index 65fb3116..eb0af6ed 100644
--- a/widgets/dirtree.go
+++ b/widgets/dirtree.go
@@ -327,7 +327,7 @@ func (dt *DirectoryTree) buildTree() {
copy(dt.treeDirs, dt.dirs)
root := &types.Thread{Uid: 0}
- buildTree(root, sTree, 0xFFFFFF)
+ dt.buildTreeNode(root, sTree, 0xFFFFFF, 1)
threads := make([]*types.Thread, 0)
@@ -373,7 +373,7 @@ func (dt *DirectoryTree) buildTree() {
}
}
-func buildTree(node *types.Thread, stree [][]string, defaultUid uint32) {
+func (dt *DirectoryTree) buildTreeNode(node *types.Thread, stree [][]string, defaultUid uint32, depth int) {
m := make(map[string][][]string)
for _, branch := range stree {
if len(branch) > 1 {
@@ -398,7 +398,10 @@ func buildTree(node *types.Thread, stree [][]string, defaultUid uint32) {
}
nextNode := &types.Thread{Uid: uid}
node.AddChild(nextNode)
- buildTree(nextNode, next, defaultUid)
+ if dt.UiConfig().DirListCollapse != 0 {
+ node.Hidden = depth > dt.UiConfig().DirListCollapse
+ }
+ dt.buildTreeNode(nextNode, next, defaultUid, depth+1)
}
}