123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- package session
- import (
- "github.com/charmbracelet/bubbles/key"
- "github.com/remogatto/sugarfoam/components/form"
- "github.com/remogatto/sugarfoam/components/group"
- "github.com/remogatto/sugarfoam/components/table"
- "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 *table.Model:
- keys = append(
- keys,
- item.KeyMap.LineUp,
- item.KeyMap.LineDown,
- )
- case *viewport.Model:
- keys = append(
- keys,
- item.KeyMap.Up,
- item.KeyMap.Down,
- )
- case *form.Model:
- keys = append(
- keys,
- item.KeyBinds()...,
- )
- }
- keys = append(
- keys,
- k.group.KeyMap.FocusNext,
- k.group.KeyMap.FocusPrev,
- 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"),
- ),
- }
- }
|