From 2569ebddb5293d2d807d0ccbd57083cac1d9762e Mon Sep 17 00:00:00 2001 From: spezifisch Date: Sun, 5 Nov 2023 02:49:20 +0100 Subject: [PATCH] input handler fixes, help formatting, some ? presses still get lost when some items are focused --- page_browser.go | 5 +++++ page_playlist.go | 3 +++ widget_help.go | 16 ++++++++++------ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/page_browser.go b/page_browser.go index 7cef562..6717b06 100644 --- a/page_browser.go +++ b/page_browser.go @@ -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) @@ -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 }) @@ -155,6 +157,7 @@ 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) @@ -162,7 +165,9 @@ func (ui *Ui) createBrowserPage(indexes *[]subsonic.SubsonicIndex) *BrowserPage ui.pages.HidePage(PageAddToPlaylist) ui.pages.SwitchToPage(PageBrowser) ui.app.SetFocus(browserPage.entityList) + return nil } + return event }) diff --git a/page_playlist.go b/page_playlist.go index faabd27..9af4246 100644 --- a/page_playlist.go +++ b/page_playlist.go @@ -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 }) diff --git a/widget_help.go b/widget_help.go index 6cca807..69487b3 100644 --- a/widget_help.go +++ b/widget_help.go @@ -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) @@ -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