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>
This commit is contained in:
Koni Marti 2022-02-21 00:18:43 +01:00 committed by Robin Jarry
parent 454606a9cd
commit 8f9a633523
3 changed files with 48 additions and 0 deletions

View File

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

View File

@ -24,6 +24,8 @@ G = :select -1<Enter>
J = :next-folder<Enter> J = :next-folder<Enter>
K = :prev-folder<Enter> K = :prev-folder<Enter>
H = :collapse-folder<Enter>
L = :expand-folder<Enter>
v = :mark -t<Enter> v = :mark -t<Enter>
V = :mark -v<Enter> V = :mark -v<Enter>

View File

@ -269,6 +269,10 @@ message list, the message in the message viewer, etc).
Cycles to the next (or previous) folder shown in the sidebar, repeated n Cycles to the next (or previous) folder shown in the sidebar, repeated n
times (default: 1). times (default: 1).
*expand-folder*, *collapse-folder*
Expands or collapses the current folder when the directory tree is
enabled.
*next-result*, *prev-result* *next-result*, *prev-result*
Selects the next or previous search result. Selects the next or previous search result.