diff --git a/DOCS.md b/DOCS.md index 47b282d..e396aaf 100644 --- a/DOCS.md +++ b/DOCS.md @@ -221,13 +221,18 @@ Next commands available in interactive mode: | Key | Command | |-------------------------------|-------------------------| | `q` or `Esc` or `Ctrl`+`c` | Exit | -| `e`/`E` | Expand/Collapse all | -| `g`/`G` | Goto top/bottom | -| `up`/`down` or `k/j` | Move cursor up/down | -| `left`/`right` or `h/l` | Expand/Collapse | +| `up` or `k` | Move cursor up | +| `down` or `j` | Move cursor down | +| `left` or `h` | Collapse | +| `right` or `l` | Expand | +| `Shift`+`right` or `L` | Expand all under cursor | +| `e` | Expand all | +| `E` | Collapse all | +| `g` | Scroll to top | +| `G` | Scroll to bottom | | `.` | Edit filter | | `/` | Search | -| `n` | Goto next found pattern | +| `n` | Find next | These commands are available when editing the filter: diff --git a/fx.js b/fx.js index 18394a0..2534088 100644 --- a/fx.js +++ b/fx.js @@ -350,7 +350,7 @@ module.exports = function start(filename, source) { program.showCursor() program.cursorPos(program.y, line.search(/\S/)) const path = index.get(n) - const subJson = reduce(json, path) + const subJson = reduce(json, 'this' + path) for (let p of dfs(subJson, path)) { if (expanded.size < 1000) { expanded.add(p) @@ -398,22 +398,6 @@ module.exports = function start(filename, source) { } }) - // Collapse all under cursor. - box.key(['S-left', 'S-h'], function () { - hideStatusBar() - const [n, line] = getLine(program.y) - program.showCursor() - program.cursorPos(program.y, line.search(/\S/)) - const path = index.get(n) - const subJson = reduce(json, path) - for (let p of dfs(subJson, path)) { - if (expanded.has(p)) { - expanded.delete(p) - } - } - render() - }) - box.on('click', function (mouse) { hideStatusBar() const [n, line] = getLine(mouse.y) diff --git a/index.js b/index.js index ef40dd2..a0bcfd1 100755 --- a/index.js +++ b/index.js @@ -30,6 +30,21 @@ const usage = ` Usage $ fx [code ...] + Shortcuts + q or Esc or Ctrl+c Exit + up or k Move cursor up + down or j Move cursor down + left or h Collapse + right or l Expand + Shift+right or L Expand all under cursor + e Expand all + E Collapse all + g Scroll to top + G Scroll to bottom + . Edit filter + / Search + n Find next + Examples $ echo '{"key": "value"}' | fx 'x => x.key' value