summaryrefslogtreecommitdiff
path: root/commands
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2022-02-21 00:18:43 +0100
committerRobin Jarry <robin@jarry.cc>2022-02-23 21:09:01 +0100
commit8f9a6335239052c676fbcf4d9ca0205ef15fdcf2 (patch)
treeedbac1bae4308ddf65576dc8ee9213cf651be2b6 /commands
parent454606a9cd85923cc98e4d43ea8b8972de6a5e9c (diff)
downloadaerc-8f9a6335239052c676fbcf4d9ca0205ef15fdcf2.zip
commands: add expand-folder and collapse-folder
add the expand-folder and collapse-folder commands to navigate the directory tree view. Provide keybinds for a vi-like folder navigation experience. Signed-off-by: Koni Marti <koni.marti@gmail.com>
Diffstat (limited to 'commands')
-rw-r--r--commands/account/expand-folder.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/commands/account/expand-folder.go b/commands/account/expand-folder.go
new file mode 100644
index 0000000..3eafaa0
--- /dev/null
+++ b/commands/account/expand-folder.go
@@ -0,0 +1,42 @@
+package account
+
+import (
+ "errors"
+ "fmt"
+
+ "git.sr.ht/~rjarry/aerc/widgets"
+)
+
+type ExpandCollapseFolder struct{}
+
+func init() {
+ register(ExpandCollapseFolder{})
+}
+
+func (ExpandCollapseFolder) Aliases() []string {
+ return []string{"expand-folder", "collapse-folder"}
+}
+
+func (ExpandCollapseFolder) Complete(aerc *widgets.Aerc, args []string) []string {
+ return nil
+}
+
+func (ExpandCollapseFolder) Execute(aerc *widgets.Aerc, args []string) error {
+ if len(args) > 1 {
+ return expandCollapseFolderUsage(args[0])
+ }
+ acct := aerc.SelectedAccount()
+ if acct == nil {
+ return errors.New("No account selected")
+ }
+ if args[0] == "expand-folder" {
+ acct.Directories().ExpandFolder()
+ } else {
+ acct.Directories().CollapseFolder()
+ }
+ return nil
+}
+
+func expandCollapseFolderUsage(cmd string) error {
+ return fmt.Errorf("Usage: %s", cmd)
+}