From: Scott Worley Date: Sat, 29 Jan 2022 23:10:25 +0000 (-0800) Subject: ^e and ^y for scrolling without moving the cursor X-Git-Url: http://git.scottworley.com/vopamoi/commitdiff_plain/90381b6d517d1a68e91c7049c04b476285c4f79d?ds=inline;hp=bb25aeb64a51985374e378cd10e70e683be004f6 ^e and ^y for scrolling without moving the cursor --- diff --git a/vopamoi.ts b/vopamoi.ts index 9137ff5..3798488 100644 --- a/vopamoi.ts +++ b/vopamoi.ts @@ -489,6 +489,7 @@ function BrowserUI() { } const browserUI = BrowserUI(); +const scrollIncrement = 60; enum InputState { Root, S, @@ -512,31 +513,35 @@ function handleKey(event: any) { if (event.key == "Escape") return browserUI.completeEdit(event, CommitOrAbort.Abort); } } else { - if (event.ctrlKey) return; // eg: Don't redo when user refreshes the page with ctrl-R if (inputState === InputState.Root) { if ("0" <= event.key && event.key <= "9") { return (inputCount = (inputCount ?? 0) * 10 + parseInt(event.key)); } try { - if (event.key == "j") return browserUI.moveCursor(inputCount ?? 1); - if (event.key == "k") return browserUI.moveCursor(-(inputCount ?? 1)); - if (event.key == "J") return browserUI.moveTask(inputCount ?? 1); - if (event.key == "K") return browserUI.moveTask(-(inputCount ?? 1)); - if (event.key == "G") return browserUI.jumpCursor(inputCount ?? MAX_SAFE_INTEGER); - if (event.key == "T") return browserUI.makeTopPriority(); - if (event.key == "n") return browserUI.focusTaskNameInput(event); - if (event.key == "c") return browserUI.setState("cancelled"); - if (event.key == "d") return browserUI.setState("done"); - if (event.key == "q") return browserUI.setState("todo"); - if (event.key == "s") return (inputState = InputState.S); - if (event.key == "w") return browserUI.setState("waiting"); - if (event.key == "X") return browserUI.setState("deleted"); - if (event.key == "x") return browserUI.removeTag(); - if (event.key == "u") return browserUI.undo(); - if (event.key == "r") return browserUI.redo(); - if (event.key == "e") return browserUI.beginEdit(event); - if (event.key == "t") return browserUI.beginTagEdit(event); - if (event.key == "v") return (inputState = InputState.V); + if (event.ctrlKey) { + if (event.key == "e") return window.scrollBy(0, (inputCount ?? 1) * scrollIncrement); + if (event.key == "y") return window.scrollBy(0, (inputCount ?? 1) * -scrollIncrement); + } else { + if (event.key == "j") return browserUI.moveCursor(inputCount ?? 1); + if (event.key == "k") return browserUI.moveCursor(-(inputCount ?? 1)); + if (event.key == "J") return browserUI.moveTask(inputCount ?? 1); + if (event.key == "K") return browserUI.moveTask(-(inputCount ?? 1)); + if (event.key == "G") return browserUI.jumpCursor(inputCount ?? MAX_SAFE_INTEGER); + if (event.key == "T") return browserUI.makeTopPriority(); + if (event.key == "n") return browserUI.focusTaskNameInput(event); + if (event.key == "c") return browserUI.setState("cancelled"); + if (event.key == "d") return browserUI.setState("done"); + if (event.key == "q") return browserUI.setState("todo"); + if (event.key == "s") return (inputState = InputState.S); + if (event.key == "w") return browserUI.setState("waiting"); + if (event.key == "X") return browserUI.setState("deleted"); + if (event.key == "x") return browserUI.removeTag(); + if (event.key == "u") return browserUI.undo(); + if (event.key == "r") return browserUI.redo(); + if (event.key == "e") return browserUI.beginEdit(event); + if (event.key == "t") return browserUI.beginTagEdit(event); + if (event.key == "v") return (inputState = InputState.V); + } } finally { inputCount = null; }