Skip to content

Commit

Permalink
input handler fixes, help formatting, some ? presses still get lost w…
Browse files Browse the repository at this point in the history
…hen some items are focused
  • Loading branch information
spezifisch committed Nov 5, 2023
1 parent 8d80387 commit 2569ebd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
5 changes: 5 additions & 0 deletions page_browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func (ui *Ui) createBrowserPage(indexes *[]subsonic.SubsonicIndex) *BrowserPage
ui.app.SetFocus(browserPage.artistList)
return nil
}

switch event.Rune() {
case '/':
browserPage.showSearchField(true)
Expand Down Expand Up @@ -129,6 +130,7 @@ func (ui *Ui) createBrowserPage(indexes *[]subsonic.SubsonicIndex) *BrowserPage
if goBackTo < browserPage.artistList.GetItemCount() {
browserPage.artistList.SetCurrentItem(goBackTo)
}
return nil
}
return event
})
Expand All @@ -155,14 +157,17 @@ func (ui *Ui) createBrowserPage(indexes *[]subsonic.SubsonicIndex) *BrowserPage
ui.pages.HidePage(PageAddToPlaylist)
ui.pages.SwitchToPage(PageBrowser)
ui.app.SetFocus(browserPage.entityList)
return nil
} else if event.Key() == tcell.KeyEnter {
playlist := ui.playlists[ui.addToPlaylistList.GetCurrentItem()]
browserPage.handleAddSongToPlaylist(&playlist)

ui.pages.HidePage(PageAddToPlaylist)
ui.pages.SwitchToPage(PageBrowser)
ui.app.SetFocus(browserPage.entityList)
return nil
}

return event
})

Expand Down
3 changes: 3 additions & 0 deletions page_playlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,13 @@ func (ui *Ui) createPlaylistPage() *PlaylistPage {
if event.Rune() == 'n' {
ui.pages.ShowPage(PageNewPlaylist)
ui.app.SetFocus(ui.playlistPage.newPlaylistInput)
return nil
}
if event.Rune() == 'd' {
ui.pages.ShowPage(PageDeletePlaylist)
return nil
}

return event
})

Expand Down
16 changes: 10 additions & 6 deletions widget_help.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ func (ui *Ui) createHelpWidget() (m *HelpWidget) {
}

// two help columns side by side
m.leftColumn = tview.NewTextView().SetTextAlign(tview.AlignLeft)
m.rightColumn = tview.NewTextView().SetTextAlign(tview.AlignLeft)
m.leftColumn = tview.NewTextView().
SetTextAlign(tview.AlignLeft).
SetDynamicColors(true)
m.rightColumn = tview.NewTextView().
SetTextAlign(tview.AlignLeft).
SetDynamicColors(true)
m.helpBook = tview.NewFlex().
SetDirection(tview.FlexColumn)

Expand All @@ -44,19 +48,19 @@ func (ui *Ui) createHelpWidget() (m *HelpWidget) {
}

func (h *HelpWidget) RenderHelp(context string) {
leftText := "[Playback]\n" + tview.Escape(strings.TrimSpace(helpPlayback))
leftText := "[::b]Playback[::-]\n" + tview.Escape(strings.TrimSpace(helpPlayback))
h.leftColumn.SetText(leftText)

rightText := ""
switch context {
case PageBrowser:
rightText = "[Browser]\n" + tview.Escape(strings.TrimSpace(helpPageBrowser))
rightText = "[::b]Browser[::-]\n" + tview.Escape(strings.TrimSpace(helpPageBrowser))

case PageQueue:
rightText = "[Queue]\n" + tview.Escape(strings.TrimSpace(helpPageQueue))
rightText = "[::b]Queue[::-]\n" + tview.Escape(strings.TrimSpace(helpPageQueue))

case PagePlaylists:
rightText = "[Playlists]\n" + tview.Escape(strings.TrimSpace(helpPagePlaylists))
rightText = "[::b]Playlists[::-]\n" + tview.Escape(strings.TrimSpace(helpPagePlaylists))

case PageLog:
fallthrough
Expand Down

0 comments on commit 2569ebd

Please sign in to comment.