Skip to content

Commit 2eeacc6

Browse files
committed
Statusbar highlights and colors
1 parent 178e0d2 commit 2eeacc6

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

gui.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,12 @@ func InitGui(indexes *[]SubsonicIndex, connection *SubsonicConnection) *Ui {
143143
// player queue
144144
queueList := tview.NewList().ShowSecondaryText(false)
145145
// status text at the top
146-
startStopStatus := tview.NewTextView().SetText("stmp: stopped").
147-
SetTextAlign(tview.AlignLeft)
148-
playerStatus := tview.NewTextView().SetText("[100%][0:00/0:00]").
149-
SetTextAlign(tview.AlignRight)
146+
startStopStatus := tview.NewTextView().SetText("[::b]stmp: [red]stopped").
147+
SetTextAlign(tview.AlignLeft).
148+
SetDynamicColors(true)
149+
playerStatus := tview.NewTextView().SetText("[::b][100%][0:00/0:00]").
150+
SetTextAlign(tview.AlignRight).
151+
SetDynamicColors(true)
150152
player, err := InitPlayer()
151153
var currentDirectory *SubsonicDirectory
152154
var artistIdList []string
@@ -259,11 +261,11 @@ func InitGui(indexes *[]SubsonicIndex, connection *SubsonicConnection) *Ui {
259261
if event.Rune() == 'p' {
260262
status := player.Pause()
261263
if status == PlayerStopped {
262-
startStopStatus.SetText("stmp: stopped")
264+
startStopStatus.SetText("[::b]stmp: [red]stopped")
263265
} else if status == PlayerPlaying {
264-
startStopStatus.SetText("stmp: playing " + player.Queue[0].Title)
266+
startStopStatus.SetText("[::b]stmp: [green]playing " + player.Queue[0].Title)
265267
} else if status == PlayerPaused {
266-
startStopStatus.SetText("stmp: paused")
268+
startStopStatus.SetText("[::b]stmp: [yellow]paused")
267269
}
268270
return nil
269271
}
@@ -301,15 +303,15 @@ func handleMpvEvents(ui *Ui) {
301303
if e == nil {
302304
break
303305
} else if e.Event_Id == mpv.EVENT_END_FILE {
304-
ui.startStopStatus.SetText("stmp: stopped")
306+
ui.startStopStatus.SetText("[::b]stmp: [red]stopped")
305307
// TODO it's gross that this is here, need better event handling
306308
if len(ui.player.Queue) > 0 {
307309
ui.player.Queue = ui.player.Queue[1:]
308310
}
309311
updateQueueList(ui.player, ui.queueList)
310312
ui.player.PlayNextTrack()
311313
} else if e.Event_Id == mpv.EVENT_START_FILE {
312-
ui.startStopStatus.SetText("stmp: playing " + ui.player.Queue[0].Title)
314+
ui.startStopStatus.SetText("[::b]stmp: [green]playing " + ui.player.Queue[0].Title)
313315
updateQueueList(ui.player, ui.queueList)
314316
}
315317

@@ -348,7 +350,7 @@ func formatPlayerStatus(volume int64, position float64, duration float64) string
348350
positionMin, positionSec := secondsToMinAndSec(position)
349351
durationMin, durationSec := secondsToMinAndSec(duration)
350352

351-
return fmt.Sprintf("[%d%%][%02d:%02d/%02d:%02d]", volume,
353+
return fmt.Sprintf("[::b][%d%%][%02d:%02d/%02d:%02d]", volume,
352354
positionMin, positionSec, durationMin, durationSec)
353355
}
354356

0 commit comments

Comments
 (0)