mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Have keyboard widget manage its own help
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
This commit is contained in:
@@ -5,11 +5,11 @@ import (
|
||||
)
|
||||
|
||||
func (widget *Widget) initializeKeyboardControls() {
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp)
|
||||
widget.SetKeyboardChar("h", widget.selectPrevious)
|
||||
widget.SetKeyboardChar("l", widget.selectNext)
|
||||
widget.SetKeyboardChar(" ", widget.playPause)
|
||||
widget.SetKeyboardChar("s", widget.toggleShuffle)
|
||||
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() {
|
||||
|
||||
@@ -11,26 +11,6 @@ import (
|
||||
"github.com/zmb3/spotify"
|
||||
)
|
||||
|
||||
// HelpText contains the help text for the Spotify Web API widget.
|
||||
const HelpText = `
|
||||
Keyboard commands for Spotify Web:
|
||||
|
||||
Before any of these commands are used, you should authenticate using the
|
||||
URL provided by the widget.
|
||||
|
||||
The widget should automatically open a browser window for you, otherwise
|
||||
you should check out the logs for the URL.
|
||||
|
||||
/: Show/hide this help window
|
||||
h: Switch to previous song in Spotify queue
|
||||
l: Switch to next song in Spotify queue
|
||||
s: Toggle shuffle
|
||||
|
||||
[space]: Pause/play current song
|
||||
|
||||
esc: Unselect the Spotify Web module
|
||||
`
|
||||
|
||||
// Info is the struct that contains all the information the Spotify player displays to the user
|
||||
type Info struct {
|
||||
Artists string
|
||||
@@ -42,7 +22,6 @@ type Info struct {
|
||||
|
||||
// Widget is the struct used by all WTF widgets to transfer to the main widget controller
|
||||
type Widget struct {
|
||||
wtf.HelpfulWidget
|
||||
wtf.KeyboardWidget
|
||||
wtf.TextWidget
|
||||
|
||||
@@ -92,8 +71,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
var playerState *spotify.PlayerState
|
||||
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(),
|
||||
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||
|
||||
Info: Info{},
|
||||
@@ -146,7 +124,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
widget.View.SetWordWrap(true)
|
||||
widget.View.SetTitle("[green]Spotify Web[white]")
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
widget.KeyboardWidget.SetView(widget.View)
|
||||
|
||||
return &widget
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user