12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- package filter
- import (
- "github.com/charmbracelet/bubbles/key"
- "github.com/remogatto/sugarfoam/components/group"
- "github.com/remogatto/sugarfoam/components/viewport"
- )
- type keyBindings struct {
- group *group.Model
- quit, enter key.Binding
- }
- func (k *keyBindings) ShortHelp() []key.Binding {
- keys := make([]key.Binding, 0)
- current := k.group.Current()
- switch item := current.(type) {
- case *viewport.Model:
- keys = append(
- keys,
- item.KeyMap.Up,
- item.KeyMap.Down,
- )
- }
- keys = append(
- keys,
- k.quit,
- )
- return keys
- }
- func (k keyBindings) FullHelp() [][]key.Binding {
- return [][]key.Binding{
- {
- k.quit,
- },
- }
- }
- func newBindings(g *group.Model) *keyBindings {
- return &keyBindings{
- group: g,
- quit: key.NewBinding(
- key.WithKeys("esc"), key.WithHelp("esc", "Quit app"),
- ),
- enter: key.NewBinding(
- key.WithKeys("enter"), key.WithHelp("enter", "Quit app and return the results"),
- ),
- }
- }
|