aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Garrelou <simon.garrelou@gmail.com>2022-12-07 21:51:22 +0100
committerSimon Garrelou <simon.garrelou@gmail.com>2022-12-07 21:51:22 +0100
commit96cc5db2b4062ced82faf01ddac24abef04df343 (patch)
treecbede4969df8d792aa54b3541d3c99278172acf8
parent38fe18fc9b89365566359d075335a8d474f16709 (diff)
downloadtermsonic-96cc5db2b4062ced82faf01ddac24abef04df343.tar.gz
termsonic-96cc5db2b4062ced82faf01ddac24abef04df343.zip
Add keybinds in footer
-rw-r--r--src/app.go6
-rw-r--r--src/footer.go17
-rw-r--r--src/page_artists.go3
3 files changed, 25 insertions, 1 deletions
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) {
32 32
33 a.tv = tview.NewApplication() 33 a.tv = tview.NewApplication()
34 a.pages = tview.NewPages() 34 a.pages = tview.NewPages()
35 a.footer = tview.NewTextView() 35 a.footer = tview.NewTextView().
36 SetDynamicColors(true)
36 37
37 a.header = tview.NewTextView(). 38 a.header = tview.NewTextView().
38 SetRegions(true). 39 SetRegions(true).
@@ -104,6 +105,7 @@ func (a *app) switchToPage(name string) {
104 case "artists": 105 case "artists":
105 a.pages.SwitchToPage("artists") 106 a.pages.SwitchToPage("artists")
106 a.header.Highlight("artists") 107 a.header.Highlight("artists")
108 a.tv.SetFocus(a.artistsTree)
107 case "playlists": 109 case "playlists":
108 a.pages.SwitchToPage("playlists") 110 a.pages.SwitchToPage("playlists")
109 a.header.Highlight("playlists") 111 a.header.Highlight("playlists")
@@ -111,4 +113,6 @@ func (a *app) switchToPage(name string) {
111 a.pages.SwitchToPage("config") 113 a.pages.SwitchToPage("config")
112 a.header.Highlight("config") 114 a.header.Highlight("config")
113 } 115 }
116
117 a.updateFooter()
114} 118}
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 @@
1package src
2
3func (a *app) updateFooter() {
4 switch a.header.GetHighlights()[0] {
5 case "artists":
6 switch a.tv.GetFocus() {
7 case a.artistsTree:
8 a.footer.SetText("Artists: [blue]Up/Down:[yellow] Move selection [blue]Space:[yellow] Select entry")
9 case a.songsList:
10 a.footer.SetText("Songs: [blue]Up/Down:[yellow] Move selection [blue]Space:[yellow] Play")
11 }
12 case "playlists":
13 a.footer.SetText("Come back later!")
14 case "config":
15 a.footer.SetText("Configuration page")
16 }
17}
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 {
37 37
38 a.loadAlbumInPanel(sel.id) 38 a.loadAlbumInPanel(sel.id)
39 a.tv.SetFocus(a.songsList) 39 a.tv.SetFocus(a.songsList)
40 a.updateFooter()
40 }) 41 })
41 42
42 // Songs list for the selected album 43 // Songs list for the selected album
@@ -47,6 +48,7 @@ func (a *app) artistsPage() tview.Primitive {
47 a.artistsTree.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { 48 a.artistsTree.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
48 if event.Key() == tcell.KeyLeft || event.Key() == tcell.KeyRight { 49 if event.Key() == tcell.KeyLeft || event.Key() == tcell.KeyRight {
49 a.tv.SetFocus(a.songsList) 50 a.tv.SetFocus(a.songsList)
51 a.updateFooter()
50 return nil 52 return nil
51 } 53 }
52 return event 54 return event
@@ -55,6 +57,7 @@ func (a *app) artistsPage() tview.Primitive {
55 a.songsList.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { 57 a.songsList.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
56 if event.Key() == tcell.KeyLeft || event.Key() == tcell.KeyRight { 58 if event.Key() == tcell.KeyLeft || event.Key() == tcell.KeyRight {
57 a.tv.SetFocus(a.artistsTree) 59 a.tv.SetFocus(a.artistsTree)
60 a.updateFooter()
58 return nil 61 return nil
59 } 62 }
60 return event 63 return event