diff --git a/cmd/guilds_tree.go b/cmd/guilds_tree.go index 31b8820..f006cf9 100644 --- a/cmd/guilds_tree.go +++ b/cmd/guilds_tree.go @@ -216,8 +216,28 @@ func (gt *GuildsTree) onSelected(n *tview.TreeNode) { } } +func (gt *GuildsTree) collapseParentNode(node *tview.TreeNode) { + gt. + GetRoot(). + Walk(func(n, parent *tview.TreeNode) bool { + if n == node && parent.GetLevel() != 0 { + parent.Collapse() + gt.SetCurrentNode(parent) + return false + } + + return true + }) +} + func (gt *GuildsTree) onInputCapture(event *tcell.EventKey) *tcell.EventKey { switch event.Name() { + case gt.cfg.Keys.GuildsTree.CollapseParentNode: + gt.collapseParentNode(gt.GetCurrentNode()) + return nil + case gt.cfg.Keys.GuildsTree.MoveToParentNode: + return tcell.NewEventKey(tcell.KeyRune, 'K', tcell.ModNone) + case gt.cfg.Keys.GuildsTree.SelectPrevious: return tcell.NewEventKey(tcell.KeyUp, 0, tcell.ModNone) case gt.cfg.Keys.GuildsTree.SelectNext: diff --git a/internal/config/keys.go b/internal/config/keys.go index 996c4a1..2bffc06 100644 --- a/internal/config/keys.go +++ b/internal/config/keys.go @@ -26,6 +26,9 @@ type ( NavigationKeys SelectCurrent string `toml:"select_current"` YankID string `toml:"yank_id"` + + CollapseParentNode string `toml:"collapse_parent_node"` + MoveToParentNode string `toml:"move_to_parent_node"` } MessagesTextKeys struct { @@ -69,6 +72,9 @@ func defaultKeys() Keys { }, SelectCurrent: "Enter", YankID: "Rune[y]", + + CollapseParentNode: "Rune[-]", + MoveToParentNode: "Rune[p]", }, MessagesText: MessagesTextKeys{