« get me outta code hell

Make next/previous tab controls wrap around - mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2019-10-15 18:18:26 -0300
committerFlorrie <towerofnix@gmail.com>2019-10-15 18:18:42 -0300
commit5c2e12b7f8cdc48e1ddb41710e60144f5c778cda (patch)
tree5a24c4d4c69e5d33230a114f0e969e76699fd3c3
parent0f1197138e3aae2d9cc25f3f1d3c6c3d7a235422 (diff)
Make next/previous tab controls wrap around
-rw-r--r--ui.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/ui.js b/ui.js
index 368c8ea..a7ad672 100644
--- a/ui.js
+++ b/ui.js
@@ -3271,11 +3271,17 @@ class Tabber extends FocusElement {
 
   nextTab() {
     this.currentElementIndex++
+    if (this.currentElementIndex >= this.tabberElements.length) {
+      this.currentElementIndex = 0
+    }
     this.updateVisibleElement()
   }
 
   previousTab() {
     this.currentElementIndex--
+    if (this.currentElementIndex < 0) {
+      this.currentElementIndex = this.tabberElements.length - 1
+    }
     this.updateVisibleElement()
   }