]> git.scottworley.com Git - vopamoi/blobdiff - vopamoi.ts
'l' goes to first *visible* subtask
[vopamoi] / vopamoi.ts
index 302307fe31df5d25c8c5498dab70cb671075c19b..8e7280964e076c45dc740cae6661e09ccaf6fe00 100644 (file)
@@ -297,9 +297,6 @@ function BrowserUI() {
         this.firstVisibleTask()?.focus();
       }
       input.value = "";
-      if (currentTagView) {
-        ui.addTag(task.getAttribute("data-created")!, currentTagView);
-      }
       if (event.getModifierState("Control")) {
         this.makeBottomPriority(task);
       }
@@ -381,8 +378,9 @@ function BrowserUI() {
       return target as HTMLElement;
     },
 
-    firstVisibleTask: function () {
-      for (const task of document.getElementsByClassName("task")) {
+    firstVisibleTask: function (root: Element | null = null) {
+      if (root === null) root = document.body;
+      for (const task of root.getElementsByClassName("task")) {
         const state = task.getAttribute("data-state");
         if (
           task instanceof HTMLElement &&
@@ -441,6 +439,20 @@ function BrowserUI() {
       task instanceof HTMLElement && task.focus();
     },
 
+    moveCursorLeft: function () {
+      const active = this.currentTask();
+      if (!active) return false;
+      if (active.parentElement!.classList.contains("task")) {
+        active.parentElement!.focus();
+      }
+    },
+
+    moveCursorRight: function () {
+      const active = this.currentTask();
+      if (!active) return false;
+      (this.firstVisibleTask(active) as HTMLElement | null)?.focus();
+    },
+
     moveCursorVertically: function (offset: number): boolean {
       const active = this.currentTask();
       if (!active) return false;
@@ -643,6 +655,8 @@ function handleKey(event: any) {
           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 == "h") return browserUI.moveCursorLeft();
+          if (event.key == "l") return browserUI.moveCursorRight();
           if (event.key == "j") return browserUI.moveCursorVertically(inputCount ?? 1);
           if (event.key == "k") return browserUI.moveCursorVertically(-(inputCount ?? 1));
           if (event.key == "J") return browserUI.moveTask(inputCount ?? 1);