Change help menus: Only display shortcuts used on the page

Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
Hadi
2026-05-18 20:23:56 +02:00
parent 6aa377acd8
commit 969febb14c
13 changed files with 115 additions and 49 deletions
+13 -3
View File
@@ -196,6 +196,7 @@ func (m *Model) refreshListViewport() {
type pluginsKeyMap struct {
editing bool
hasConfig bool
width int
}
func (k pluginsKeyMap) ShortHelp() []key.Binding {
@@ -210,11 +211,20 @@ func (k pluginsKeyMap) ShortHelp() []key.Binding {
key.WithHelp(g.ScrollUp.Help().Key+"/"+g.ScrollDown.Help().Key, "scroll detail"),
)
if k.hasConfig {
return []key.Binding{pk.Toggle, pk.EditConfig, pk.Filter, scrollHint}
return []key.Binding{pk.Toggle, pk.EditConfig, pk.Filter, scrollHint, g.Help}
}
return []key.Binding{pk.Toggle, pk.Filter, scrollHint}
return []key.Binding{pk.Toggle, pk.Filter, scrollHint, g.Help}
}
func (k pluginsKeyMap) FullHelp() [][]key.Binding {
return [][]key.Binding{k.ShortHelp()}
g := keys.Keys.Global
if k.editing {
return [][]key.Binding{k.ShortHelp()}
}
pk := keys.Keys.Plugins
pageGlobals := []key.Binding{g.Up, g.Down, g.ScrollUp, g.ScrollDown, g.Escape}
all := []key.Binding{pk.Toggle, pk.EditConfig, pk.Filter}
all = append(all, pageGlobals...)
all = append(all, g.CommonBindings()...)
return keys.ChunkByWidth(all, k.width)
}
+2 -2
View File
@@ -120,9 +120,9 @@ func (m *Model) renderStatusBar() string {
escKey := keys.Keys.Global.Escape.Help().Key
accent := lipgloss.NewStyle().Foreground(s.Primary)
filterLine := pad.Render(accent.Render(filterKey) + " " + s.Bold.Render(m.filter) + s.Faint.Render(" "+escKey+" to clear"))
return lipgloss.JoinVertical(lipgloss.Left, filterLine, pad.Render(m.help.View(pluginsKeyMap{editing: m.editing, hasConfig: m.hasConfig()})))
return lipgloss.JoinVertical(lipgloss.Left, filterLine, pad.Render(m.help.View(pluginsKeyMap{editing: m.editing, hasConfig: m.hasConfig(), width: m.width})))
}
return pad.Render(m.help.View(pluginsKeyMap{editing: m.editing, hasConfig: m.hasConfig()}))
return pad.Render(m.help.View(pluginsKeyMap{editing: m.editing, hasConfig: m.hasConfig(), width: m.width}))
}
func (m *Model) renderList() string {