CLI: Changed header output, lists now highlight they currently playing items.
This commit is contained in:
parent
729c27bd72
commit
255f9f9eed
@ -77,15 +77,17 @@ Configuration:
|
||||
/// Console output data
|
||||
private String titleStyle, normalStyle, statusStyle, promptStyle,
|
||||
artistStyle, albumStyle, fileStyle, errorStyle, playlistStyle
|
||||
|
||||
private String clearLine = new ANSI().eraseLine(Erase.All).toString()
|
||||
private String afterInput =
|
||||
new ANSI().eraseLine(Erase.All).scrollUp().cursorUp().toString()
|
||||
private String beforeLeader =
|
||||
new ANSI().saveCursor().cursorPrevLine(2).toString()
|
||||
new ANSI().saveCursor().cursorPrevLine(3).toString()
|
||||
private String afterLeader =
|
||||
new ANSI().restoreCursor().eraseLine(Erase.ToEnd).toString()
|
||||
private String eraseLeader =
|
||||
new ANSI().eraseLine(Erase.All).cursorPrevLine().eraseLine(Erase.All)
|
||||
.cursorPrevLine().eraseLine(Erase.All)
|
||||
.cursorPrevLine().eraseLine(Erase.All).toString()
|
||||
|
||||
public final static modelClass = [
|
||||
@ -95,7 +97,7 @@ Configuration:
|
||||
private int displayWidth = 79
|
||||
private long msgTimeout
|
||||
private ScrollText currentlyPlaying = new ScrollText(
|
||||
maxWidth: displayWidth - 15 - VERSION.size(),
|
||||
maxWidth: displayWidth - 17,
|
||||
text: "No media currently playing.")
|
||||
private ScrollText status = new ScrollText(maxWidth: displayWidth)
|
||||
private Date dismissMsgDate = new Date()
|
||||
@ -244,7 +246,7 @@ Configuration:
|
||||
}
|
||||
|
||||
void setupTextStyles() {
|
||||
titleStyle = new ANSI().color(Colors.WHITE, Colors.DEFAULT, false).toString()
|
||||
titleStyle = new ANSI().color(Colors.WHITE, Colors.DEFAULT, true).toString()
|
||||
normalStyle = new ANSI().resetText().toString()
|
||||
promptStyle = new ANSI().color(Colors.YELLOW, Colors.DEFAULT, true).toString()
|
||||
statusStyle = new ANSI().color(Colors.CYAN, Colors.DEFAULT, false).toString()
|
||||
@ -272,8 +274,7 @@ Configuration:
|
||||
this.running = true
|
||||
String line = null
|
||||
|
||||
outStream.println ""
|
||||
outStream.println ""
|
||||
outStream.println "\n\n\n"
|
||||
drawLeader()
|
||||
|
||||
while(this.running) {
|
||||
@ -453,7 +454,14 @@ Configuration:
|
||||
private def processClear(LinkedList line) {
|
||||
def option = line.poll()
|
||||
switch(option) {
|
||||
case 'queue': return library.removeAllFromPlaylist(playQueue.id)
|
||||
case null:
|
||||
print(new ANSI().eraseDisplay(Erase.All))//.cursorPosition(4, 0))
|
||||
drawLeader(true)
|
||||
return
|
||||
case 'queue':
|
||||
playQueue = library.removeAllFromPlaylist(playQueue.id)
|
||||
setPlayQueue(playQueue)
|
||||
return playQueue
|
||||
case 'selected playlist':
|
||||
if (!currentSelection.playlist) {
|
||||
printLongMessage("No playlist currently selected.")
|
||||
@ -571,7 +579,7 @@ Configuration:
|
||||
String tagMatch = options?.join(" ")?.trim()
|
||||
if (tagMatch) list = list.findAll { it.name =~ tagMatch }
|
||||
printLongMessage(makeList(selection, Tag, list, all,
|
||||
{ "${it.id}: ${it.name}" }))
|
||||
{ "${it.id}: ${it}" }))
|
||||
break
|
||||
|
||||
default:
|
||||
@ -804,10 +812,31 @@ Configuration:
|
||||
.append(titleStyle)
|
||||
.append("WDIWTLT - v")
|
||||
.append(VERSION)
|
||||
.append(normalStyle)
|
||||
.append(" -- ")
|
||||
.append('\n')
|
||||
|
||||
StringBuilder statusLine = new StringBuilder()
|
||||
.append(statusStyle)
|
||||
.append(currentlyPlaying)
|
||||
|
||||
if (playBookmark) statusLine.append('(')
|
||||
.append(playBookmark.playIndex + 1)
|
||||
.append('/')
|
||||
.append(vlcj.mediaList.size())
|
||||
.append(') ')
|
||||
|
||||
statusLine.append(currentlyPlaying)
|
||||
|
||||
if (curMediaFile) {
|
||||
long playTime = Math.floor(vlcj.mediaListPlayer.mediaPlayer.time / 1000) as long
|
||||
int statusLength = ANSI.strip(statusLine.toString()).length()
|
||||
statusLine.append((' ' * (displayWidth - (statusLength + 7))))
|
||||
.append(promptStyle)
|
||||
.append(String.format('%02d', Math.floor(playTime / 60) as int))
|
||||
.append(':')
|
||||
.append(String.format('%02d', Math.floor(playTime % 60) as int))
|
||||
.append(' ')}
|
||||
|
||||
leader.append(clearLine)
|
||||
.append(statusLine)
|
||||
.append("\n")
|
||||
.append(clearLine)
|
||||
.append(normalStyle)
|
||||
@ -816,13 +845,62 @@ Configuration:
|
||||
|
||||
return leader.toString() }
|
||||
|
||||
private String setMsg(String msg) {
|
||||
status.text = msg
|
||||
dismissMsgDate = new Date(new Date().time + msgTimeout) }
|
||||
|
||||
private String setErr(String errMsg) {
|
||||
status.text = errorStyle + errMsg
|
||||
dismissMsgDate = new Date(new Date().time + msgTimeout) }
|
||||
|
||||
private String makeFullMediaFileDescription(MediaFile mf) {
|
||||
def artist = library.getArtistsWhere( mediaFileId: mf.id)
|
||||
def album = library.getAlbumsWhere(mediaFileId: mf.id)
|
||||
|
||||
StringBuilder s = new StringBuilder()
|
||||
|
||||
if (artist) s.append(artistStyle)
|
||||
.append(artist[0])
|
||||
.append(normalStyle)
|
||||
.append(" / ")
|
||||
|
||||
if (album) s.append(albumStyle)
|
||||
.append(album[0])
|
||||
.append(normalStyle)
|
||||
.append(" / ")
|
||||
|
||||
s.append(fileStyle)
|
||||
.append(mf)
|
||||
.append(normalStyle)
|
||||
.append(' ')
|
||||
|
||||
return s.toString() }
|
||||
|
||||
private String makeList(Selection selection, Class modelClass,
|
||||
def items, boolean listAll = false, Closure toString = null) {
|
||||
|
||||
if (!toString) toString = { it.toString() }
|
||||
|
||||
def currentCollection
|
||||
|
||||
if (curMediaFile) {
|
||||
def lookupFun
|
||||
|
||||
switch (modelClass) {
|
||||
case Album: lookupFun = library.&getAlbumsWhere; break
|
||||
case Artist: lookupFun = library.&getArtistsWhere; break
|
||||
case Playlist: lookupFun = library.&getPlaylistsWhere; break
|
||||
case MediaFile: lookupFun = { ign -> [curMediaFile] }; break
|
||||
case Tag: lookupFun = library.&getTagsWhere; break
|
||||
default: lookupFun = { ign -> [] } }
|
||||
|
||||
currentCollection = lookupFun([mediaFileId: curMediaFile.id]) }
|
||||
|
||||
def highlightSelected = { item ->
|
||||
if (currentCollection && currentCollection.find {it.id == item.id})
|
||||
return "${promptStyle}${toString(item)}${normalStyle}"
|
||||
else return toString(item) }
|
||||
|
||||
def result = new StringBuilder()
|
||||
.append("--------------------\n${modelClass.simpleName}s")
|
||||
|
||||
@ -834,8 +912,8 @@ Configuration:
|
||||
.append(")")
|
||||
|
||||
result.append(":\n\n")
|
||||
result.append(items.collect( toString ?: { it.toString() }).join("\n"))
|
||||
.append("\n")
|
||||
result.append(items.collect(highlightSelected).join("\n"))
|
||||
.append("\n\n")
|
||||
|
||||
return result.toString() }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user