From 7c7d32d0136092d06f9747cc44c5a37bcc9832b8 Mon Sep 17 00:00:00 2001 From: Florrie Date: Wed, 7 Mar 2018 19:15:26 -0400 Subject: Make (t) key only show information about one track The showTrackInfo keybinding command can now take a number of next/ previous tracks to show. --- src/loop-play.js | 10 +++++++--- src/play.js | 7 +++---- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/loop-play.js b/src/loop-play.js index b44e83f..0fd94e4 100644 --- a/src/loop-play.js +++ b/src/loop-play.js @@ -652,7 +652,11 @@ class PlayController extends EventEmitter { this.stopped = true } - logTrackInfo() { + logTrackInfo(upNextTrackCount = 3, previousTrackCount = undefined) { + if (typeof previousTrackCount === 'undefined') { + previousTrackCount = upNextTrackCount + } + const getColorMessage = t => { if (!t) return '\x1b[2m(No track)\x1b[0m' @@ -675,13 +679,13 @@ class PlayController extends EventEmitter { const tl = hc.timeline const tlI = hc.timelineIndex - for (let i = Math.max(0, tlI - 2); i < tlI; i++) { + for (let i = Math.max(0, tlI - (previousTrackCount - 1)); i < tlI; i++) { console.log(`\x1b[2m(Prev) ${getCleanMessage(tl[i])}\x1b[0m`) } console.log(`\x1b[1m(Curr) \x1b[1m${getColorMessage(tl[tlI])}\x1b[0m`) - for (let i = tlI + 1; i < Math.min(tlI + 3, tl.length); i++) { + for (let i = tlI + 1; i < Math.min(tlI + upNextTrackCount, tl.length); i++) { console.log(`(Next) ${getCleanMessage(tl[i])}`) } } diff --git a/src/play.js b/src/play.js index 28fd2c7..0b521b4 100755 --- a/src/play.js +++ b/src/play.js @@ -114,7 +114,7 @@ async function main(args) { [['delete'], 'skipUpNext'], [['s'], 'skipAhead'], [['S'], 'skipAhead'], [['i'], 'showTrackInfo'], [['I'], 'showTrackInfo'], - [['t'], 'showTrackInfo'], [['T'], 'showTrackInfo'], + [['t'], 'showTrackInfo', 0, 0], [['T'], 'showTrackInfo', 0, 0], [['q'], 'quit'], [['Q'], 'quit'] ] @@ -788,10 +788,9 @@ async function main(args) { }) }, - // TODO: Number of history/up-next tracks to show. - 'showTrackInfo': function() { + 'showTrackInfo': function(previousTrackCount = 3, upNextTrackCount = undefined) { clearConsoleLine() - playController.logTrackInfo() + playController.logTrackInfo(previousTrackCount, upNextTrackCount) }, 'runShellCommand': async function(command, args) { -- cgit 1.3.0-6-gf8a5