From 96cc5db2b4062ced82faf01ddac24abef04df343 Mon Sep 17 00:00:00 2001 From: Simon Garrelou Date: Wed, 7 Dec 2022 21:51:22 +0100 Subject: Add keybinds in footer --- src/app.go | 6 +++++- src/footer.go | 17 +++++++++++++++++ src/page_artists.go | 3 +++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 src/footer.go diff --git a/src/app.go b/src/app.go index d9ed0cb..8eed517 100644 --- a/src/app.go +++ b/src/app.go @@ -32,7 +32,8 @@ func Run(cfg *Config) { a.tv = tview.NewApplication() a.pages = tview.NewPages() - a.footer = tview.NewTextView() + a.footer = tview.NewTextView(). + SetDynamicColors(true) a.header = tview.NewTextView(). SetRegions(true). @@ -104,6 +105,7 @@ func (a *app) switchToPage(name string) { case "artists": a.pages.SwitchToPage("artists") a.header.Highlight("artists") + a.tv.SetFocus(a.artistsTree) case "playlists": a.pages.SwitchToPage("playlists") a.header.Highlight("playlists") @@ -111,4 +113,6 @@ func (a *app) switchToPage(name string) { a.pages.SwitchToPage("config") a.header.Highlight("config") } + + a.updateFooter() } diff --git a/src/footer.go b/src/footer.go new file mode 100644 index 0000000..b0494d0 --- /dev/null +++ b/src/footer.go @@ -0,0 +1,17 @@ +package src + +func (a *app) updateFooter() { + switch a.header.GetHighlights()[0] { + case "artists": + switch a.tv.GetFocus() { + case a.artistsTree: + a.footer.SetText("Artists: [blue]Up/Down:[yellow] Move selection [blue]Space:[yellow] Select entry") + case a.songsList: + a.footer.SetText("Songs: [blue]Up/Down:[yellow] Move selection [blue]Space:[yellow] Play") + } + case "playlists": + a.footer.SetText("Come back later!") + case "config": + a.footer.SetText("Configuration page") + } +} diff --git a/src/page_artists.go b/src/page_artists.go index 23d9a1e..e8ce180 100644 --- a/src/page_artists.go +++ b/src/page_artists.go @@ -37,6 +37,7 @@ func (a *app) artistsPage() tview.Primitive { a.loadAlbumInPanel(sel.id) a.tv.SetFocus(a.songsList) + a.updateFooter() }) // Songs list for the selected album @@ -47,6 +48,7 @@ func (a *app) artistsPage() tview.Primitive { a.artistsTree.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { if event.Key() == tcell.KeyLeft || event.Key() == tcell.KeyRight { a.tv.SetFocus(a.songsList) + a.updateFooter() return nil } return event @@ -55,6 +57,7 @@ func (a *app) artistsPage() tview.Primitive { a.songsList.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { if event.Key() == tcell.KeyLeft || event.Key() == tcell.KeyRight { a.tv.SetFocus(a.artistsTree) + a.updateFooter() return nil } return event -- cgit v1.2.3