forked from wildeyedskies/stmp
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
spezifisch
committed
Nov 5, 2023
1 parent
73238d2
commit 8d80387
Showing
5 changed files
with
144 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package main | ||
|
||
const helpPlayback = ` | ||
p play/pause | ||
P stop | ||
> next song | ||
-/= volume down/volume up | ||
,/. seek -10/+10 seconds | ||
r add 50 random songs to queue | ||
` | ||
|
||
const helpPageBrowser = ` | ||
ENTER play song (clears current queue) | ||
a add album or song to queue | ||
A add song to playlist | ||
y toggle star on song/album | ||
R refresh the list | ||
/ Search artists | ||
n Continue search forward | ||
N Continue search backwards | ||
ESC Close search | ||
` | ||
|
||
const helpPageQueue = ` | ||
d/DEL remove currently selected song from the queue | ||
D remove all songs from queue | ||
y toggle star on song | ||
` | ||
|
||
const helpPagePlaylists = ` | ||
n new playlist | ||
d delete playlist | ||
a add playlist or song to queue | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package main | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/rivo/tview" | ||
) | ||
|
||
type HelpWidget struct { | ||
Root *tview.Flex | ||
|
||
helpBook *tview.Flex | ||
leftColumn, rightColumn *tview.TextView | ||
|
||
// external references | ||
ui *Ui | ||
} | ||
|
||
func (ui *Ui) createHelpWidget() (m *HelpWidget) { | ||
m = &HelpWidget{ | ||
ui: ui, | ||
} | ||
|
||
// two help columns side by side | ||
m.leftColumn = tview.NewTextView().SetTextAlign(tview.AlignLeft) | ||
m.rightColumn = tview.NewTextView().SetTextAlign(tview.AlignLeft) | ||
m.helpBook = tview.NewFlex(). | ||
SetDirection(tview.FlexColumn) | ||
|
||
// button at the bottom | ||
closeButton := tview.NewButton("Close") | ||
closeButton.SetSelectedFunc(func() { | ||
ui.CloseHelp() | ||
}) | ||
|
||
m.Root = tview.NewFlex(). | ||
SetDirection(tview.FlexRow). | ||
AddItem(m.helpBook, 0, 1, false). | ||
AddItem(closeButton, 1, 0, true) | ||
|
||
m.Root.Box.SetBorder(true).SetTitle(" Help ") | ||
|
||
return | ||
} | ||
|
||
func (h *HelpWidget) RenderHelp(context string) { | ||
leftText := "[Playback]\n" + tview.Escape(strings.TrimSpace(helpPlayback)) | ||
h.leftColumn.SetText(leftText) | ||
|
||
rightText := "" | ||
switch context { | ||
case PageBrowser: | ||
rightText = "[Browser]\n" + tview.Escape(strings.TrimSpace(helpPageBrowser)) | ||
|
||
case PageQueue: | ||
rightText = "[Queue]\n" + tview.Escape(strings.TrimSpace(helpPageQueue)) | ||
|
||
case PagePlaylists: | ||
rightText = "[Playlists]\n" + tview.Escape(strings.TrimSpace(helpPagePlaylists)) | ||
|
||
case PageLog: | ||
fallthrough | ||
default: | ||
// no text | ||
} | ||
|
||
h.rightColumn.SetText(rightText) | ||
|
||
h.helpBook.Clear() | ||
if rightText != "" { | ||
h.helpBook.AddItem(h.leftColumn, 38, 0, false). | ||
AddItem(h.rightColumn, 0, 1, true) // gets focus for scrolling | ||
} else { | ||
h.helpBook.AddItem(h.leftColumn, 0, 1, false) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters