mirror of
https://github.com/antonmedv/fx
synced 2024-11-05 12:00:46 +00:00
Add collapse/expand all under cursor functionality
This commit is contained in:
parent
fd2a30b79e
commit
83efa1d109
34
fx.js
34
fx.js
@ -343,6 +343,24 @@ module.exports = function start(filename, source) {
|
||||
}
|
||||
})
|
||||
|
||||
// Expand everything under cursor.
|
||||
box.key(['S-right', 'S-l'], 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.size < 1000) {
|
||||
expanded.add(p)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
render()
|
||||
})
|
||||
|
||||
box.key(['left', 'h'], function () {
|
||||
hideStatusBar()
|
||||
const [n, line] = getLine(program.y)
|
||||
@ -380,6 +398,22 @@ 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)
|
||||
|
Loading…
Reference in New Issue
Block a user