« get me outta code hell

Add lastInput function to forms - tui-lib - Pure Node.js library for making visual command-line programs (ala vim, ncdu)
about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2019-09-15 18:28:55 -0300
committerFlorrie <towerofnix@gmail.com>2019-09-15 18:28:55 -0300
commitf3974627bddb9f62132bf54bde3a66c87dbf7b23 (patch)
treed6990f15885c0c660e91792987ef7d5a15ebb803
parentd8943db70aab7e7192040caaf0bbf02d5ddf429c (diff)
Add lastInput function to forms
-rw-r--r--ui/form/Form.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/ui/form/Form.js b/ui/form/Form.js
index 74a1065..451baa4 100644
--- a/ui/form/Form.js
+++ b/ui/form/Form.js
@@ -117,6 +117,21 @@ module.exports = class Form extends FocusElement {
     }
   }
 
+  lastInput(selectForm = true) {
+    this.curIndex = this.inputs.length - 1
+
+    // TODO: See previousInput
+    if (!this.inputs[this.curIndex].selectable) {
+      this.previousInput()
+    }
+
+    if (selectForm || (
+      this.root.isChildOrSelfSelected && this.root.isChildOrSelfSelected(this)
+    )) {
+      this.updateSelectedElement()
+    }
+  }
+
   selected() {
     if (this.root.selectedElement === this) {
       this.updateSelectedElement()