mirror of
https://github.com/anotherhadi/spilltea.git
synced 2026-05-20 09:42:34 +02:00
e8e64eff12
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
35 lines
919 B
Go
35 lines
919 B
Go
package intercept
|
|
|
|
import (
|
|
"charm.land/bubbles/v2/help"
|
|
"charm.land/bubbles/v2/key"
|
|
"github.com/anotherhadi/spilltea/internal/icons"
|
|
"github.com/anotherhadi/spilltea/internal/keys"
|
|
"github.com/anotherhadi/spilltea/internal/style"
|
|
)
|
|
|
|
func newHelp() help.Model { return style.NewHelp() }
|
|
|
|
type interceptKeyMap struct{ width int }
|
|
|
|
func iconBinding(b key.Binding, icon string) key.Binding {
|
|
h := b.Help()
|
|
return key.NewBinding(key.WithKeys(b.Keys()...), key.WithHelp(h.Key, icon+h.Desc))
|
|
}
|
|
|
|
func (interceptKeyMap) ShortHelp() []key.Binding {
|
|
ic := keys.Keys.Intercept
|
|
i := icons.I
|
|
return []key.Binding{
|
|
iconBinding(ic.Forward, i.Forward),
|
|
iconBinding(ic.Drop, i.Drop),
|
|
iconBinding(ic.Edit, i.Edit),
|
|
keys.Keys.Global.Help,
|
|
}
|
|
}
|
|
|
|
func (m interceptKeyMap) FullHelp() [][]key.Binding {
|
|
all := append(keys.Keys.Intercept.Bindings(), keys.Keys.Global.Bindings()...)
|
|
return keys.ChunkByWidth(all, m.width)
|
|
}
|