add function to style keybind for header

This commit is contained in:
Lilian Jónsdóttir 2024-07-30 18:28:14 -07:00
parent 3f317d58df
commit 3e195f0d73

View file

@ -259,16 +259,16 @@ func (m model) showHelp() string {
// TODO: maybe use bubbletea built in help // TODO: maybe use bubbletea built in help
var keys = []string{ var keys = []string{
fmt.Sprintf("%s %s (%s)", darktext.Render(m.keys.sort.Help().Key), darkertext.Render(m.keys.sort.Help().Desc), m.sorting.String()), fmt.Sprintf("%s %s (%s)", darktext.Render(m.keys.sort.Help().Key), darkertext.Render(m.keys.sort.Help().Desc), m.sorting.String()),
fmt.Sprintf("%s %s", darktext.Render(m.keys.quit.Help().Key), darkertext.Render(m.keys.quit.Help().Desc)), styleKey(m.keys.quit),
} }
if !m.readonly { if !m.readonly {
if m.mode != modes.Interactive { if m.mode != modes.Interactive {
keys = append([]string{ keys = append([]string{
fmt.Sprintf("%s %s", darktext.Render(m.keys.doit.Help().Key), darkertext.Render(m.keys.doit.Help().Desc)), styleKey(m.keys.doit),
}, keys...) }, keys...)
} }
keys = append([]string{ keys = append([]string{
fmt.Sprintf("%s %s", darktext.Render(m.keys.mark.Help().Key), darkertext.Render(m.keys.mark.Help().Desc)), styleKey(m.keys.mark),
}, keys...) }, keys...)
} }
return strings.Join(keys, darkesttext.Render(" • ")) return strings.Join(keys, darkesttext.Render(" • "))
@ -279,13 +279,13 @@ func (m model) header() string {
right, left string right, left string
spacerWidth int spacerWidth int
keys = []string{ keys = []string{
fmt.Sprintf("%s %s", darktext.Render(m.keys.rstr.Help().Key), darkertext.Render(m.keys.rstr.Help().Desc)), styleKey(m.keys.rstr),
fmt.Sprintf("%s %s", darktext.Render(m.keys.clen.Help().Key), darkertext.Render(m.keys.clen.Help().Desc)), styleKey(m.keys.clen),
} }
selectKeys = []string{ selectKeys = []string{
fmt.Sprintf("%s %s", darktext.Render(m.keys.todo.Help().Key), darkertext.Render(m.keys.todo.Help().Desc)), styleKey(m.keys.todo),
fmt.Sprintf("%s %s", darktext.Render(m.keys.nada.Help().Key), darkertext.Render(m.keys.nada.Help().Desc)), styleKey(m.keys.nada),
fmt.Sprintf("%s %s", darktext.Render(m.keys.invr.Help().Key), darkertext.Render(m.keys.invr.Help().Desc)), styleKey(m.keys.invr),
} }
dot = darkesttext.Render("•") dot = darkesttext.Render("•")
wideDot = darkesttext.Render(" • ") wideDot = darkesttext.Render(" • ")
@ -599,3 +599,7 @@ func makeUnselectedStyle() table.Styles {
Bold(false) Bold(false)
return style return style
} }
func styleKey(key key.Binding) string {
return fmt.Sprintf("%s %s", darktext.Render(key.Help().Key), darkertext.Render(key.Help().Desc))
}