« get me outta code hell

mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--todo.txt3
-rw-r--r--ui.js17
2 files changed, 16 insertions, 4 deletions
diff --git a/todo.txt b/todo.txt
index 18ed0c9..d8e9e3b 100644
--- a/todo.txt
+++ b/todo.txt
@@ -528,6 +528,7 @@ TODO: Deselecting a grouplike listing (e.g. by clicking elsewhere) should hide
       its "jump to" element.
 
 TODO: A "before selected item" option for in the queue menu!
+      (Done!)
 
 TODO: The sorting for library3/C418 seems to be weird???? Could be pointing to
       some bug!
@@ -543,3 +544,5 @@ TODO: Selecting a group from the path listing at the bottom of listings should
 TODO: UI to change the directory from which mtui reads music by default!
 
 TODO: file/folder browse-select UI 0_0
+
+TODO: Change any "song" terminology to "track" in the UI.
diff --git a/ui.js b/ui.js
index 85cefcd..0f20bc5 100644
--- a/ui.js
+++ b/ui.js
@@ -306,11 +306,12 @@ class AppElement extends FocusElement {
     this.addChild(this.menuLayer)
 
     this.whereControl = new InlineListPickerElement('Where?', [
-      {value: 'next-selected', label: 'After selected song'},
+      {value: 'after-selected', label: 'After selected song'},
       {value: 'next', label: 'After current song'},
       {value: 'end', label: 'At end of queue'},
       {value: 'distribute-evenly', label: 'Distributed across queue evenly'},
-      {value: 'distribute-randomly', label: 'Distributed across queue randomly'}
+      {value: 'distribute-randomly', label: 'Distributed across queue randomly'},
+      {value: 'before-selected', label: 'Before selected song'}
     ], this.showContextMenu)
 
     this.orderControl = new InlineListPickerElement('Order?', [
@@ -1500,12 +1501,20 @@ class AppElement extends FocusElement {
       item = {name: oldName, items: [item]}
     }
 
-    if (where === 'next' || where === 'next-selected' || where === 'end') {
+    if (where === 'next' || where === 'after-selected' || where === 'before-selected' || where === 'end') {
       let afterItem = null
       if (where === 'next') {
         afterItem = playingTrack
-      } else if (where === 'next-selected') {
+      } else if (where === 'after-selected') {
         afterItem = this.queueListingElement.currentItem
+      } else if (where === 'before-selected') {
+        const { items } = this.SQP.queueGrouplike
+        const index = items.indexOf(this.queueListingElement.currentItem)
+        if (index === 0) {
+          afterItem = 'FRONT'
+        } else if (index > 0) {
+          afterItem = items[index - 1]
+        }
       }
 
       this.SQP.queue(item, afterItem, {