« get me outta code hell

Add %esc% and %name% - http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2018-04-08 21:34:53 -0300
committerFlorrie <towerofnix@gmail.com>2018-04-08 21:35:38 -0300
commit8812c7a1ea343ce85f4c1cc8e379f6ab2c8bdaca (patch)
tree3fb1ce718975b9c6e783105c1e550e8066a16efb
parentf2e0502bdba4b951582261026299e2bf431ce27e (diff)
Add %esc% and %name%
%esc% is for fancy ANSI formatting (e.g. %esc%[2m%timeLeft%).
%name% is just an alias for %trackName%.
-rw-r--r--src/loop-play.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/loop-play.js b/src/loop-play.js
index cca1108..62e67fd 100644
--- a/src/loop-play.js
+++ b/src/loop-play.js
@@ -463,14 +463,18 @@ class PlayController extends EventEmitter {
       const groupIndexArr = (track && track.groupTrackIndex) || ['', '']
 
       fullStatusLine += processTemplateString(statusLineTemplate, Object.assign({
+        esc: '\x1b',
         index: track ? (track.overallTrackIndex[0] + 1) : '',
         trackCount: track ? (track.overallTrackIndex[1]) : '',
         indexGroup: groupIndexArr[0],
         trackCountGroup: groupIndexArr[1],
         longIndex,
-        trackName: track.name
+        trackName: track.name, name: track.name
       }, playerData))
 
+      // Clear format - custom color codes, etc.
+      fullStatusLine += '\x1b[0m'
+
       // Carriage return - moves the cursor back to the start of the line,
       // so that the next status line is printed on top of this one.
       fullStatusLine += '\r'