X-Git-Url: http://git.scottworley.com/vopamoi/blobdiff_plain/40025d1248bf8a26e5f25d2720f9411a5fa1ded3..a1aa43d897067989508bdf46e178cb27fc7464a1:/vopamoi.ts?ds=inline diff --git a/vopamoi.ts b/vopamoi.ts index 7d2f3ee..3b0b470 100644 --- a/vopamoi.ts +++ b/vopamoi.ts @@ -287,8 +287,9 @@ function BrowserUI() { }, beginEdit: function (event: Event) { - const task = document.activeElement; + var task = document.activeElement; if (!task) return; + if (task.classList.contains("tag")) task = task.parentElement!; const input = document.createElement("input"); const desc = task.getElementsByClassName("desc")[0]; const oldDescription = desc.textContent!; @@ -358,6 +359,7 @@ function BrowserUI() { taskFocusedBeforeJumpingToInput = document.activeElement; } document.getElementById("taskName")!.focus(); + window.scroll(0, 0); event.preventDefault(); }, @@ -489,6 +491,7 @@ function BrowserUI() { } const browserUI = BrowserUI(); +const scrollIncrement = 60; enum InputState { Root, S, @@ -517,25 +520,30 @@ function handleKey(event: any) { 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; }