diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2023-05-08 20:20:34 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-05-16 11:11:48 +0200 |
commit | 6e038c7fd510563efc35780e293e25e34ffe3077 (patch) | |
tree | b8d9d6b323aba6e741ffa8cdd481db92a1c6da88 /widgets/dirtree.go | |
parent | f1772c92f92eca7b68c5042d71a7985d64dfef63 (diff) | |
download | aerc-6e038c7fd510563efc35780e293e25e34ffe3077.tar.gz |
dirtree: modify drawing of the dirtree
Update the dirtree drawing structure to be a bit more compact. The
dirtree is drawn with one column left for a flag, which indicates if a
parent is collapsed or expanded. Only draw the "flag" when the parent is
collapsed. Change the flag to a '+' character to match common UI
patterns of expanding lists having a '+' box.
Don't draw the '>' character in the dirtree. This character is nice in
the threaded message view, but clutters up the dirtree. I know this is a
matter of preference, but this approach is similar to most other UI tree
view and gives the dirtree an extra column of space.
The original dirtree looks like this:
┌Inbox
├─>Sub
└─>Sub
And collapsed:
-Inbox
This patch changes it to:
Inbox
├─Sub
└─Sub
And collapsed:
+Inbox
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
Diffstat (limited to 'widgets/dirtree.go')
-rw-r--r-- | widgets/dirtree.go | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/widgets/dirtree.go b/widgets/dirtree.go index b0943ae4..41477c5f 100644 --- a/widgets/dirtree.go +++ b/widgets/dirtree.go @@ -275,7 +275,7 @@ func (dt *DirectoryTree) countVisible(list []*types.Thread) (n int) { func (dt *DirectoryTree) displayText(node *types.Thread) string { elems := strings.Split(dt.treeDirs[getAnyUid(node)], dt.pathSeparator) - return fmt.Sprintf("%s%s%s", threadPrefix(node, false), getFlag(node), elems[countLevels(node)]) + return fmt.Sprintf("%s%s%s", threadPrefix(node, false, false), getFlag(node), elems[countLevels(node)]) } func (dt *DirectoryTree) getDirectory(node *types.Thread) string { @@ -471,13 +471,12 @@ func countLevels(node *types.Thread) (level int) { return } -func getFlag(node *types.Thread) (flag string) { - if node != nil && node.FirstChild != nil { - if node.Hidden { - flag = "─" - } else { - flag = "┌" - } +func getFlag(node *types.Thread) string { + if node == nil && node.FirstChild == nil { + return "" } - return + if node.Hidden { + return "+" + } + return "" } |