From 763423109a24b4002c5ae94d65bd2dedb01009df Mon Sep 17 00:00:00 2001 From: skanehira Date: Thu, 7 Nov 2019 21:41:51 +0900 Subject: [PATCH] use 'q' to quit tson --- README.md | 3 ++- gui/navi.go | 3 ++- gui/tree.go | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5f830c2..a4398cb 100644 --- a/README.md +++ b/README.md @@ -47,13 +47,14 @@ $ tson -url http://gorilla/likes/json | A | add new value | | d | clear children nodes | | e | edit json with $EDITOR(only when use --url) | +| q | quit tson | | Enter | edit node | | / | search nodes | | ? | show helps | | space | expand/collaspe children nodes | | ctrl-j | move to next parent node | | ctrk-k | move to next previous node | -| ctrl-c | exit tson | +| ctrl-c | quit tson | ### help | key | description | diff --git a/gui/navi.go b/gui/navi.go index 0ef20b6..5729c32 100644 --- a/gui/navi.go +++ b/gui/navi.go @@ -39,6 +39,7 @@ var ( addNewValue = fmt.Sprintf(RedColor, "A", " add new value") clearChildrenNodes = fmt.Sprintf(RedColor, "d", " clear children nodes") editNodes = fmt.Sprintf(RedColor, "e", " edit json with $EDITOR(only when use --url)") + quitTson = fmt.Sprintf(RedColor, "q", " quit tson") editNodeValue = fmt.Sprintf(RedColor, "Enter", "edit current node") searchNodes = fmt.Sprintf(RedColor, "/", " search nodes") toggleExpandNodes = fmt.Sprintf(RedColor, "space", " expand/collaspe nodes") @@ -46,7 +47,7 @@ var ( movePreParentNode = fmt.Sprintf(RedColor, "ctrl-k", "move to previous parent node") treeNavi = strings.Join([]string{hideNode, collaspeAllNode, expandNode, expandAllNode, readFile, saveFile, addNewNode, addNewValue, clearChildrenNodes, editNodeValue, searchNodes, - moveNextParentNode, movePreParentNode, editNodes}, "\n") + moveNextParentNode, movePreParentNode, editNodes, quitTson}, "\n") ) type Navi struct { diff --git a/gui/tree.go b/gui/tree.go index 7270184..7c16967 100644 --- a/gui/tree.go +++ b/gui/tree.go @@ -163,6 +163,8 @@ func (t *Tree) SetKeybindings(g *Gui) { case ' ': current := t.GetCurrentNode() current.SetExpanded(!current.IsExpanded()) + case 'q': + g.App.Stop() } switch event.Key() {