« get me outta code hell

mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
path: root/ui.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui.js')
-rw-r--r--ui.js14
1 files changed, 11 insertions, 3 deletions
diff --git a/ui.js b/ui.js
index 972e139..bdc4258 100644
--- a/ui.js
+++ b/ui.js
@@ -58,6 +58,8 @@ const keyBindings = [
   ['isBackspace', telc.isBackspace],
   ['isMenu', 'm'],
   ['isMenu', 'f'],
+  ['isScrollToStart', 'g', {caseless: false}],
+  ['isScrollToEnd', 'G', {caseless: false}],
   ['isTogglePause', telc.isSpace],
   ['isToggleLoop', 'l', {caseless: false}],
   ['isStop', telc.isEscape],
@@ -1216,10 +1218,10 @@ class GrouplikeListingElement extends Form {
       this.loadParentGrouplike()
     } else if (telc.isCharacter(keyBuf, '/') || keyBuf[0] === 6) { // '/', ctrl-F
       this.showJumpElement()
-    } else if (telc.isCharacter(keyBuf, 'g')) {
+    } else if (input.isScrollToStart(keyBuf)) {
       this.form.selectAndShow(this.grouplike.items[0])
       this.form.scrollToBeginning()
-    } else if (telc.isCharacter(keyBuf, 'G')) {
+    } else if (input.isScrollToEnd(keyBuf)) {
       this.form.selectAndShow(this.grouplike.items[this.grouplike.items.length - 1])
     } else if (keyBuf[0] === 12) { // ctrl-L
       if (this.grouplike.isTheQueue) {
@@ -3049,8 +3051,14 @@ class ContextMenu extends FocusElement {
       return false
     } else if (this.keyboardSelector.keyPressed(keyBuf)) {
       return false
+    } else if (input.isScrollToStart(keyBuf)) {
+      this.form.firstInput()
+      this.form.scrollToBeginning()
+    } else if (input.isScrollToEnd(keyBuf)) {
+      this.form.lastInput()
+    } else {
+      return super.keyPressed(keyBuf)
     }
-    super.keyPressed(keyBuf)
   }
 
   unselected() {