mirror of
https://github.com/mrusme/neonmodem.git
synced 2024-12-04 14:46:37 -05:00
31 lines
498 B
Go
31 lines
498 B
Go
package toolkit
|
|
|
|
import "github.com/charmbracelet/bubbles/key"
|
|
|
|
func (tk *ToolKit) KeymapAdd(id string, help string, keys ...string) {
|
|
keysview := ""
|
|
for i, k := range keys {
|
|
if i > 0 {
|
|
keysview += "/"
|
|
}
|
|
keysview += k
|
|
}
|
|
|
|
binding := key.NewBinding(
|
|
key.WithKeys(keys...),
|
|
key.WithHelp(keysview, help),
|
|
)
|
|
|
|
tk.keybindings[id] = binding
|
|
|
|
return
|
|
}
|
|
|
|
func (tk *ToolKit) KeymapGet(id string) key.Binding {
|
|
if k, ok := tk.keybindings[id]; ok {
|
|
return k
|
|
}
|
|
|
|
return key.NewBinding()
|
|
}
|