Fix expand all under cursor and add docs

js-version
Anton Medvedev 5 years ago
parent 027b1a8dad
commit 33ea17be93

@ -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:

18
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)

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

Loading…
Cancel
Save