Tab cycles panels within a view; views switch only via F1-F4/Alt+digit
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -84,13 +84,20 @@ func newDownloadsView(app *App, sab *sabnzbd.Client, sources []arrSource, interv
|
||||
common := func(extra map[rune]func()) func(*tcell.EventKey) *tcell.EventKey {
|
||||
keys := map[rune]func(){
|
||||
'r': v.refreshNow,
|
||||
'h': v.nextPanel,
|
||||
'p': v.togglePause,
|
||||
}
|
||||
for r, f := range extra {
|
||||
keys[r] = f
|
||||
}
|
||||
return func(ev *tcell.EventKey) *tcell.EventKey {
|
||||
switch ev.Key() {
|
||||
case tcell.KeyTab:
|
||||
v.nextPanel(1)
|
||||
return nil
|
||||
case tcell.KeyBacktab:
|
||||
v.nextPanel(-1)
|
||||
return nil
|
||||
}
|
||||
if ev.Key() == tcell.KeyRune {
|
||||
if f, ok := keys[ev.Rune()]; ok {
|
||||
f()
|
||||
@@ -114,12 +121,13 @@ func newDownloadsView(app *App, sab *sabnzbd.Client, sources []arrSource, interv
|
||||
return v
|
||||
}
|
||||
|
||||
// nextPanel moves focus to the next panel (queue, Radarr/Sonarr queue, history).
|
||||
func (v *downloadsView) nextPanel() {
|
||||
// nextPanel moves focus to the next (dir 1) or previous (dir -1) panel:
|
||||
// queue, Radarr/Sonarr queue, history.
|
||||
func (v *downloadsView) nextPanel(dir int) {
|
||||
cur := v.app.app.GetFocus()
|
||||
for i, p := range v.panels {
|
||||
if p == cur {
|
||||
v.app.app.SetFocus(v.panels[(i+1)%len(v.panels)])
|
||||
v.app.app.SetFocus(v.panels[(i+dir+len(v.panels))%len(v.panels)])
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user