Add help title

pull/295/head
Anton Medvedev 2 months ago
parent d4e18dd66f
commit 7d9b1ce465
No known key found for this signature in database

@ -44,6 +44,18 @@ func usage(keyMap KeyMap) string {
)
}
func help(keyMap KeyMap) string {
title := lipgloss.NewStyle().Bold(true)
pad := lipgloss.NewStyle().PaddingLeft(4)
return fmt.Sprintf(`
%v
%v
`,
title.Render("Key Bindings"),
strings.Join(keyMapInfo(keyMap, pad), "\n"),
)
}
func keyMapInfo(keyMap KeyMap, style lipgloss.Style) []string {
v := reflect.ValueOf(keyMap)
fields := reflect.VisibleFields(v.Type())

@ -387,7 +387,7 @@ func (m *model) handleKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
return m, tea.Quit
case key.Matches(msg, keyMap.Help):
m.help.SetContent(strings.Join(keyMapInfo(keyMap, lipgloss.NewStyle().Padding(1, 2)), "\n"))
m.help.SetContent(help(keyMap))
m.showHelp = true
case key.Matches(msg, keyMap.Up):

Loading…
Cancel
Save