mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Define help with keys This means that keys and help are automatically in sync This means that you can't define keys, but forget help This unfortunately also means that formatting may not be quite as good
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package spotifyweb
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
func (widget *Widget) initializeKeyboardControls() {
|
|
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
|
|
widget.SetKeyboardChar("h", widget.selectPrevious, "Select previous item")
|
|
widget.SetKeyboardChar("l", widget.selectNext, "Select next item")
|
|
widget.SetKeyboardChar(" ", widget.playPause, "Play/pause")
|
|
widget.SetKeyboardChar("s", widget.toggleShuffle, "Toggle shuffle")
|
|
}
|
|
|
|
func (widget *Widget) selectPrevious() {
|
|
widget.client.Previous()
|
|
time.Sleep(time.Millisecond * 500)
|
|
widget.Refresh()
|
|
}
|
|
|
|
func (widget *Widget) selectNext() {
|
|
widget.client.Next()
|
|
time.Sleep(time.Millisecond * 500)
|
|
widget.Refresh()
|
|
}
|
|
|
|
func (widget *Widget) playPause() {
|
|
if widget.playerState.CurrentlyPlaying.Playing {
|
|
widget.client.Pause()
|
|
} else {
|
|
widget.client.Play()
|
|
}
|
|
time.Sleep(time.Millisecond * 500)
|
|
widget.Refresh()
|
|
}
|
|
|
|
func (widget *Widget) toggleShuffle() {
|
|
widget.playerState.ShuffleState = !widget.playerState.ShuffleState
|
|
widget.client.Shuffle(widget.playerState.ShuffleState)
|
|
time.Sleep(time.Millisecond * 500)
|
|
widget.Refresh()
|
|
}
|