From: Scott Worley Date: Thu, 27 Jan 2022 06:53:54 +0000 (-0800) Subject: Commands are in command mode X-Git-Url: http://git.scottworley.com/vopamoi/commitdiff_plain/e94e9f27c762273111ae0526d6ca24cee0c02592?ds=inline;hp=27c6778445473dedef08331260f1db3f2bea75ef Commands are in command mode --- diff --git a/vopamoi.ts b/vopamoi.ts index 271354f..80e8ff9 100644 --- a/vopamoi.ts +++ b/vopamoi.ts @@ -310,6 +310,11 @@ const BrowserUI = { }, }; +enum InputState { + Command, +} +var inputState = InputState.Command; + function handleKey(event: any) { if (event.target.tagName === "INPUT") { if (event.target.id === "taskName") { @@ -318,19 +323,21 @@ function handleKey(event: any) { if (event.key == "Enter") return BrowserUI.completeEdit(event); } } else { - if (event.key == "j") return BrowserUI.moveCursor(1); - if (event.key == "k") return BrowserUI.moveCursor(-1); - if (event.key == "J") return BrowserUI.moveTask(1); - if (event.key == "K") return BrowserUI.moveTask(-1); - if (event.key == "n") return BrowserUI.focusTaskNameInput(event); - if (event.key == "s") return BrowserUI.setState("someday-maybe"); - if (event.key == "w") return BrowserUI.setState("waiting"); - if (event.key == "d") return BrowserUI.setState("done"); - if (event.key == "c") return BrowserUI.setState("cancelled"); - if (event.key == "t") return BrowserUI.setState("todo"); - if (event.key == "X") return BrowserUI.setState("deleted"); - if (event.key == "u") return BrowserUI.undo(); - if (event.key == "e") return BrowserUI.beginEdit(event); + if (inputState === InputState.Command) { + if (event.key == "j") return BrowserUI.moveCursor(1); + if (event.key == "k") return BrowserUI.moveCursor(-1); + if (event.key == "J") return BrowserUI.moveTask(1); + if (event.key == "K") return BrowserUI.moveTask(-1); + if (event.key == "n") return BrowserUI.focusTaskNameInput(event); + if (event.key == "s") return BrowserUI.setState("someday-maybe"); + if (event.key == "w") return BrowserUI.setState("waiting"); + if (event.key == "d") return BrowserUI.setState("done"); + if (event.key == "c") return BrowserUI.setState("cancelled"); + if (event.key == "t") return BrowserUI.setState("todo"); + if (event.key == "X") return BrowserUI.setState("deleted"); + if (event.key == "u") return BrowserUI.undo(); + if (event.key == "e") return BrowserUI.beginEdit(event); + } } }