From: Scott Worley Date: Fri, 28 Jan 2022 06:21:06 +0000 (-0800) Subject: Rename inputStates to be less semantic and more concrete X-Git-Url: http://git.scottworley.com/vopamoi/commitdiff_plain/02c8a409c4aac79c5f0d2cc34ffba182198126a0?ds=sidebyside Rename inputStates to be less semantic and more concrete --- diff --git a/vopamoi.ts b/vopamoi.ts index 83354a4..50b25fa 100644 --- a/vopamoi.ts +++ b/vopamoi.ts @@ -451,10 +451,10 @@ function BrowserUI() { const browserUI = BrowserUI(); enum InputState { - Command, - View, + Root, + V, } -var inputState = InputState.Command; +var inputState = InputState.Root; function handleKey(event: any) { if (event.target.tagName === "INPUT") { @@ -469,7 +469,7 @@ function handleKey(event: any) { if (event.key == "Escape") return browserUI.completeEdit(event, CommitOrAbort.Abort); } } else { - if (inputState === InputState.Command) { + if (inputState === InputState.Root) { if (event.key == "j") return browserUI.moveCursor(1); if (event.key == "k") return browserUI.moveCursor(-1); if (event.key == "J") return browserUI.moveTask(1); @@ -486,9 +486,9 @@ function handleKey(event: any) { if (event.key == "u") return browserUI.undo(); if (event.key == "e") return browserUI.beginEdit(event); if (event.key == "t") return browserUI.beginTagEdit(event); - if (event.key == "v") return (inputState = InputState.View); - } else if (inputState === InputState.View) { - inputState = InputState.Command; + if (event.key == "v") return (inputState = InputState.V); + } else if (inputState === InputState.V) { + inputState = InputState.Root; if (event.key == "c") return browserUI.setView("cancelled", "Red"); if (event.key == "d") return browserUI.setView("done", "LawnGreen"); if (event.key == "q") return browserUI.setView("todo", "White");