From 0ef94ac82676ce1602e9df9cf282ec3e5961525e Mon Sep 17 00:00:00 2001 From: skanehira Date: Mon, 4 Nov 2019 21:53:57 +0900 Subject: [PATCH] use spacebar to expand/collaspe nodes --- README.md | 42 ++++++++++++++++++++++-------------------- gui/tree.go | 3 +++ 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 9f13606..614e805 100644 --- a/README.md +++ b/README.md @@ -29,26 +29,28 @@ $ tson -url http://gorilla/likes/json ## Keybinding ### JSON tree -| key | description | -|--------|----------------------| -| j | move down | -| k | move up | -| g | move to the top | -| G | move to the bottom | -| ctrl-f | page up | -| ctrl-b | page down | -| h | hide current node | -| H | collaspe all nodes | -| l | expand current node | -| L | expand all nodes | -| r | read from file | -| s | save to file | -| a | add new node | -| A | add new value | -| d | clear children nodes | -| Enter | edit node | -| / | search nodes | -| ? | show helps | +| key | description | +|--------|--------------------------------| +| j | move down | +| k | move up | +| g | move to the top | +| G | move to the bottom | +| ctrl-f | page up | +| ctrl-b | page down | +| h | hide current node | +| H | collaspe all nodes | +| l | expand current node | +| L | expand all nodes | +| r | read from file | +| s | save to file | +| a | add new node | +| A | add new value | +| d | clear children nodes | +| Enter | edit node | +| / | search nodes | +| ? | show helps | +| space | expand/collaspe children nodes | +| ctrl-c | exit tson | ### help | key | description | diff --git a/gui/tree.go b/gui/tree.go index 6871f5e..c3747d1 100644 --- a/gui/tree.go +++ b/gui/tree.go @@ -151,6 +151,9 @@ func (t *Tree) SetKeybindings(g *Gui) { g.AddValue() case '?': g.NaviPanel() + case ' ': + current := t.GetCurrentNode() + current.SetExpanded(!current.IsExpanded()) } return event