diff --git a/docs/wiki/Commands.md b/docs/wiki/Commands.md index 75bb9ce..d2171a8 100644 --- a/docs/wiki/Commands.md +++ b/docs/wiki/Commands.md @@ -60,7 +60,7 @@ arguments and `↑` / `↓` recall earlier lines. | `gb` | the documents that link to the open one — \[\[title]] links by title, \[\[ completes one while writing | | `:` | command line — Tab / Shift-Tab cycle the matches, then the argument; ↑ ↓ recall what ran before | | `Ctrl-S` | save, from anywhere | -| `?` | this screen — in the editor too | +| `?` | this screen, from the editor too — h/l a column, / filters it down | ### On a board diff --git a/docs/wiki/Getting-Started.md b/docs/wiki/Getting-Started.md index d90e368..0e1e031 100644 --- a/docs/wiki/Getting-Started.md +++ b/docs/wiki/Getting-Started.md @@ -74,7 +74,7 @@ The rail of buttons on the right does the same as the keys, for a mouse. inbox of this space's board. Press `b` to see the board, and `b` again to go back. 7. Press `T`. That is today's diary entry, started for you. -8. Press `?` for the list of every key and command, and `Esc` to close it. +8. Press `?` for the list of every key and command. `h` / `l` walk its columns, `/` narrows it down, and `Esc` closes it. On a phone the same things are buttons: the dock at the bottom has a new document, a new folder, the board, today's entry, an upload and a search, and diff --git a/web/src/App.svelte b/web/src/App.svelte index f2f66bb..686496d 100644 --- a/web/src/App.svelte +++ b/web/src/App.svelte @@ -9,7 +9,7 @@ import DocumentPane from './lib/DocumentPane.svelte' import FilePane from './lib/FilePane.svelte' import Headings from './lib/Headings.svelte' - import Help from './lib/Help.svelte' + import Help, { focusHelpFilter, scrollHelp } from './lib/Help.svelte' import Hints from './lib/Hints.svelte' import Verify from './lib/Verify.svelte' import Login from './lib/Login.svelte' @@ -378,6 +378,46 @@ } } + /** + * The help's keys: its columns run on to the right, so h/l and j/k move a + * column, Ctrl-D/U a screen, g/G to either end, and `/` narrows it down. + */ + function helpKey(event: KeyboardEvent): boolean { + if (event.ctrlKey) { + if (event.key !== 'd' && event.key !== 'u') return false + scrollHelp(event.key === 'd' ? 'pagedown' : 'pageup') + return true + } + switch (event.key) { + case 'l': + case 'j': + case 'ArrowRight': + case 'ArrowDown': + scrollHelp(1) + return true + case 'h': + case 'k': + case 'ArrowLeft': + case 'ArrowUp': + scrollHelp(-1) + return true + case ' ': + scrollHelp(event.shiftKey ? 'pageup' : 'pagedown') + return true + case 'g': + scrollHelp('start') + return true + case 'G': + scrollHelp('end') + return true + case '/': + focusHelpFilter() + return true + default: + return false + } + } + /** `gO`'s list: j/k down the headings, Enter to the one picked. */ function outlineKey(event: KeyboardEvent): boolean { const last = Math.max(workspace.outline.length - 1, 0) @@ -682,6 +722,12 @@ // The command line over an overlay — `D` in the agenda — keeps its keys. const listening = cmdline === null && !isTypingTarget(event.target) + if (workspace.overlay === 'help' && listening && !event.metaKey && !event.altKey) { + if (helpKey(event)) { + event.preventDefault() + return + } + } if (workspace.overlay === 'overview' && listening && !event.ctrlKey && !event.metaKey && !event.altKey) { if (overviewKey(event)) { event.preventDefault() diff --git a/web/src/lib/Help.svelte b/web/src/lib/Help.svelte index 21b449b..2a57dc1 100644 --- a/web/src/lib/Help.svelte +++ b/web/src/lib/Help.svelte @@ -1,6 +1,47 @@ + +
nothing matches "{helpFilter.text}"
{/each}