« get me outta code hell

http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
path: root/src/play.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/play.js')
-rwxr-xr-xsrc/play.js36
1 files changed, 32 insertions, 4 deletions
diff --git a/src/play.js b/src/play.js
index 7e70db3..619cf55 100755
--- a/src/play.js
+++ b/src/play.js
@@ -81,7 +81,10 @@ async function main(args) {
   let trackDisplayFile
 
   // The (custom) status line template strings.
-  let statusLineTemplate
+  let statusLineTemplates = [
+    '%longIndex% (%percentDone%) %timeDone% / %timeLeft%',
+    '%longIndex% (%percentDone%) %timeDone% / %duration%'
+  ]
   let titleLineTemplate
 
   const keybindings = [
@@ -97,6 +100,8 @@ async function main(args) {
     [['i'], 'showTrackInfo'], [['I'], 'showTrackInfo'],
     [['t'], 'showTrackInfo', 0, 0], [['T'], 'showTrackInfo', 0, 0],
     [['%'], 'showTrackInfo', 20, 0],
+    [['<'], 'previousStatusLine'],
+    [['>'], 'nextStatusLine'],
     [['q'], 'quit'], [['Q'], 'quit']
   ]
 
@@ -391,8 +396,8 @@ async function main(args) {
       // which means you can use text such as %timeLeft% and %duration% and
       // these will be replaced with appropriate values.)
 
-      statusLineTemplate = util.nextArg()
-      console.log('Using custom status line:', statusLineTemplate)
+      statusLineTemplates = [util.nextArg()]
+      console.log('Using custom status line:', statusLineTemplates[0])
     },
 
     '-playback-status': util => util.alias('-status-line'),
@@ -400,6 +405,21 @@ async function main(args) {
     '-playback-line': util => util.alias('-status-line'),
     '-status': util => util.alias('-status-line'),
 
+    '-add-status-line': function(util) {
+      // --add-status-line <string> (alias: all the same ones as --status-line)
+      // Works basically the same as --status-line, but adds a status line that
+      // can be switched to using the "<" and ">" keys. The most-recently-added
+      // status line is the one that's selected by default.
+
+      const line = util.nextArg()
+      if (statusLineTemplates) {
+        statusLineTemplates.push(line)
+      } else {
+        statusLineTemplates = [line]
+      }
+      console.log('Adding a quick-switch status line:', line)
+    },
+
     '-title-status-line': function(util) {
       // --title-status-line <string> (alias: --title)
       // Sets the text to be displayed in the title of the terminal window.
@@ -517,7 +537,7 @@ async function main(args) {
         willUseConverterOptions === null && shouldUseConverterOptions
       ),
       disablePlaybackStatus,
-      statusLineTemplate,
+      statusLineTemplates,
       titleLineTemplate,
       startTrack,
       trackDisplayFile
@@ -572,6 +592,14 @@ async function main(args) {
         }
       },
 
+      'nextStatusLine': function() {
+        playController.nextStatusLine()
+      },
+
+      'previousStatusLine': function() {
+        playController.previousStatusLine()
+      },
+
       // TODO: Skip back/ahead multiple tracks at once
 
       'skipBack': function() {