mirror of
https://github.com/anotherhadi/spilltea.git
synced 2026-05-20 01:32:33 +02:00
385b6e84e0
[37m- New global keybindings: GotoTop (Home), GotoBottom (G/End), PrevPage ([), NextPage (])[0m [37m- Wired in history, findings, and intercept update handlers[0m [37m- Removes duplicate tea.Quit case in intercept/update.go[0m [37mCo-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>[0m
71 lines
2.3 KiB
Go
71 lines
2.3 KiB
Go
package keys
|
|
|
|
import (
|
|
"charm.land/bubbles/v2/key"
|
|
"github.com/anotherhadi/spilltea/internal/config"
|
|
)
|
|
|
|
type GlobalKeyMap struct {
|
|
Quit key.Binding
|
|
OpenLogs key.Binding
|
|
ToggleSidebar key.Binding
|
|
Help key.Binding
|
|
Up key.Binding
|
|
Down key.Binding
|
|
Left key.Binding
|
|
Right key.Binding
|
|
CycleFocus key.Binding
|
|
CopyAs key.Binding
|
|
Copy key.Binding
|
|
Escape key.Binding
|
|
SendToReplay key.Binding
|
|
ScrollUp key.Binding
|
|
ScrollDown key.Binding
|
|
SendToDiff key.Binding
|
|
GotoTop key.Binding
|
|
GotoBottom key.Binding
|
|
PrevPage key.Binding
|
|
NextPage key.Binding
|
|
}
|
|
|
|
func newGlobalKeyMap(cfg config.GlobalKeys) GlobalKeyMap {
|
|
return GlobalKeyMap{
|
|
Quit: binding(cfg.Quit, "quit"),
|
|
OpenLogs: binding(cfg.OpenLogs, "open logs"),
|
|
ToggleSidebar: binding(cfg.ToggleSidebar, "toggle sidebar"),
|
|
Help: binding(cfg.Help, "help"),
|
|
Up: binding(cfg.Up, "up"),
|
|
Down: binding(cfg.Down, "down"),
|
|
Left: binding(cfg.Left, "scroll left"),
|
|
Right: binding(cfg.Right, "scroll right"),
|
|
CycleFocus: binding(cfg.CycleFocus, "cycle focus"),
|
|
CopyAs: binding(cfg.CopyAs, "copy as..."),
|
|
Copy: binding(cfg.Copy, "copy..."),
|
|
Escape: key.NewBinding(key.WithKeys("esc"), key.WithHelp("esc", "cancel")),
|
|
SendToReplay: binding(cfg.SendToReplay, "send to replay"),
|
|
ScrollUp: binding(cfg.ScrollUp, "scroll up"),
|
|
ScrollDown: binding(cfg.ScrollDown, "scroll down"),
|
|
SendToDiff: binding(cfg.SendToDiff, "send to diff"),
|
|
GotoTop: binding(cfg.GotoTop, "go to top"),
|
|
GotoBottom: binding(cfg.GotoBottom, "go to bottom"),
|
|
PrevPage: binding(cfg.PrevPage, "prev page"),
|
|
NextPage: binding(cfg.NextPage, "next page"),
|
|
}
|
|
}
|
|
|
|
func (g GlobalKeyMap) Bindings() []key.Binding {
|
|
return []key.Binding{
|
|
g.Up, g.Down, g.Left, g.Right, g.CycleFocus,
|
|
g.Quit, g.Escape, g.Help,
|
|
g.OpenLogs, g.ToggleSidebar, g.CopyAs, g.Copy,
|
|
g.SendToReplay, g.SendToDiff,
|
|
g.ScrollUp, g.ScrollDown,
|
|
g.GotoTop, g.GotoBottom, g.PrevPage, g.NextPage,
|
|
}
|
|
}
|
|
|
|
// CommonBindings returns keys available on every page.
|
|
func (g GlobalKeyMap) CommonBindings() []key.Binding {
|
|
return []key.Binding{g.Quit, g.Help, g.OpenLogs, g.ToggleSidebar}
|
|
}
|