1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00
wtf/modules/spotify/keyboard.go
Chris Cummer 5337656c58 Remove the need for every module to define a widget.ShowHelp keyboard control
This common functionality is moved up to KeyboardWidget. Modules now
include widget.InitializeCommonControls() instead.
2019-08-23 21:18:51 -07:00

38 lines
895 B
Go

package spotify
import (
"time"
"github.com/gdamore/tcell"
)
func (widget *Widget) initializeKeyboardControls() {
widget.InitializeCommonControls()
widget.SetKeyboardChar("r", widget.Refresh, "Refresh widgett")
widget.SetKeyboardChar("l", widget.next, "Select next item")
widget.SetKeyboardChar("h", widget.previous, "Select previous item")
widget.SetKeyboardChar(" ", widget.playPause, "Play/pause song")
widget.SetKeyboardKey(tcell.KeyDown, widget.next, "Select next item")
widget.SetKeyboardKey(tcell.KeyUp, widget.previous, "Select previous item")
}
func (widget *Widget) previous() {
widget.client.Previous()
time.Sleep(time.Second * 1)
widget.Refresh()
}
func (widget *Widget) next() {
widget.client.Next()
time.Sleep(time.Second * 1)
widget.Refresh()
}
func (widget *Widget) playPause() {
widget.client.PlayPause()
time.Sleep(time.Second * 1)
widget.Refresh()
}