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,10 +5,10 @@ import (
|
||||
)
|
||||
|
||||
func (widget *Widget) initializeKeyboardControls() {
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp)
|
||||
widget.SetKeyboardChar("h", widget.previous)
|
||||
widget.SetKeyboardChar("l", widget.next)
|
||||
widget.SetKeyboardChar(" ", widget.playPause)
|
||||
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help prompt")
|
||||
widget.SetKeyboardChar("h", widget.previous, "Select previous item")
|
||||
widget.SetKeyboardChar("l", widget.next, "Select next item")
|
||||
widget.SetKeyboardChar(" ", widget.playPause, "Play/pause song")
|
||||
}
|
||||
|
||||
func (widget *Widget) previous() {
|
||||
|
||||
@@ -8,16 +8,8 @@ import (
|
||||
"github.com/wtfutil/wtf/wtf"
|
||||
)
|
||||
|
||||
const HelpText = `
|
||||
To control Spotify use:
|
||||
[Spacebar] for Play & Pause
|
||||
[h] for Previous Song
|
||||
[l] for Next Song
|
||||
`
|
||||
|
||||
// A Widget represents a Spotify widget
|
||||
type Widget struct {
|
||||
wtf.HelpfulWidget
|
||||
wtf.KeyboardWidget
|
||||
wtf.TextWidget
|
||||
|
||||
@@ -30,8 +22,7 @@ type Widget struct {
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
spotifyClient := spotigopher.NewClient()
|
||||
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: spotigopher.Info{},
|
||||
@@ -49,7 +40,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
widget.View.SetWordWrap(true)
|
||||
widget.View.SetTitle(fmt.Sprint("[green]Spotify[white]"))
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
widget.KeyboardWidget.SetView(widget.View)
|
||||
|
||||
return &widget
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user