2023-09-07 23:53:51 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "github.com/charmbracelet/bubbles/key"
|
|
|
|
|
|
|
|
type KeyMap struct {
|
|
|
|
Quit key.Binding
|
|
|
|
PageDown key.Binding
|
|
|
|
PageUp key.Binding
|
|
|
|
HalfPageUp key.Binding
|
|
|
|
HalfPageDown key.Binding
|
|
|
|
GotoTop key.Binding
|
|
|
|
GotoBottom key.Binding
|
|
|
|
Down key.Binding
|
|
|
|
Up key.Binding
|
|
|
|
Expand key.Binding
|
|
|
|
Collapse key.Binding
|
|
|
|
ExpandRecursively key.Binding
|
|
|
|
CollapseRecursively key.Binding
|
|
|
|
ExpandAll key.Binding
|
|
|
|
CollapseAll key.Binding
|
|
|
|
NextSibling key.Binding
|
|
|
|
PrevSibling key.Binding
|
|
|
|
ToggleWrap key.Binding
|
2023-09-15 11:39:10 +03:00
|
|
|
Yank key.Binding
|
2023-09-07 23:53:51 +03:00
|
|
|
Search key.Binding
|
2023-09-14 18:25:27 +03:00
|
|
|
SearchNext key.Binding
|
|
|
|
SearchPrev key.Binding
|
2023-09-12 14:06:48 +03:00
|
|
|
Dig key.Binding
|
2023-09-07 23:53:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
var keyMap KeyMap
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
keyMap = KeyMap{
|
|
|
|
Quit: key.NewBinding(
|
|
|
|
key.WithKeys("q", "ctrl+c", "esc"),
|
|
|
|
key.WithHelp("", "exit program"),
|
|
|
|
),
|
|
|
|
PageDown: key.NewBinding(
|
|
|
|
key.WithKeys("pgdown", " ", "f"),
|
|
|
|
key.WithHelp("pgdown, space, f", "page down"),
|
|
|
|
),
|
|
|
|
PageUp: key.NewBinding(
|
|
|
|
key.WithKeys("pgup", "b"),
|
|
|
|
key.WithHelp("pgup, b", "page up"),
|
|
|
|
),
|
|
|
|
HalfPageUp: key.NewBinding(
|
|
|
|
key.WithKeys("u", "ctrl+u"),
|
|
|
|
key.WithHelp("", "half page up"),
|
|
|
|
),
|
|
|
|
HalfPageDown: key.NewBinding(
|
|
|
|
key.WithKeys("d", "ctrl+d"),
|
|
|
|
key.WithHelp("", "half page down"),
|
|
|
|
),
|
|
|
|
GotoTop: key.NewBinding(
|
2023-09-22 15:22:51 +03:00
|
|
|
key.WithKeys("g", "home"),
|
2023-09-07 23:53:51 +03:00
|
|
|
key.WithHelp("", "goto top"),
|
|
|
|
),
|
|
|
|
GotoBottom: key.NewBinding(
|
2023-09-22 15:22:51 +03:00
|
|
|
key.WithKeys("G", "end"),
|
2023-09-07 23:53:51 +03:00
|
|
|
key.WithHelp("", "goto bottom"),
|
|
|
|
),
|
|
|
|
Down: key.NewBinding(
|
|
|
|
key.WithKeys("down", "j"),
|
|
|
|
key.WithHelp("", "down"),
|
|
|
|
),
|
|
|
|
Up: key.NewBinding(
|
|
|
|
key.WithKeys("up", "k"),
|
|
|
|
key.WithHelp("", "up"),
|
|
|
|
),
|
|
|
|
Expand: key.NewBinding(
|
2023-09-10 16:57:12 +03:00
|
|
|
key.WithKeys("right", "l", "enter"),
|
2023-09-07 23:53:51 +03:00
|
|
|
key.WithHelp("", "expand"),
|
|
|
|
),
|
|
|
|
Collapse: key.NewBinding(
|
2023-09-10 16:57:12 +03:00
|
|
|
key.WithKeys("left", "h", "backspace"),
|
2023-09-07 23:53:51 +03:00
|
|
|
key.WithHelp("", "collapse"),
|
|
|
|
),
|
|
|
|
ExpandRecursively: key.NewBinding(
|
2023-09-11 18:50:38 +03:00
|
|
|
key.WithKeys("L", "shift+right"),
|
2023-09-07 23:53:51 +03:00
|
|
|
key.WithHelp("", "expand recursively"),
|
|
|
|
),
|
|
|
|
CollapseRecursively: key.NewBinding(
|
2023-09-11 18:50:38 +03:00
|
|
|
key.WithKeys("H", "shift+left"),
|
2023-09-07 23:53:51 +03:00
|
|
|
key.WithHelp("", "collapse recursively"),
|
|
|
|
),
|
|
|
|
ExpandAll: key.NewBinding(
|
|
|
|
key.WithKeys("e"),
|
|
|
|
key.WithHelp("", "expand all"),
|
|
|
|
),
|
|
|
|
CollapseAll: key.NewBinding(
|
|
|
|
key.WithKeys("E"),
|
|
|
|
key.WithHelp("", "collapse all"),
|
|
|
|
),
|
|
|
|
NextSibling: key.NewBinding(
|
2023-09-09 01:14:46 +03:00
|
|
|
key.WithKeys("J", "shift+down"),
|
2023-09-07 23:53:51 +03:00
|
|
|
key.WithHelp("", "next sibling"),
|
|
|
|
),
|
|
|
|
PrevSibling: key.NewBinding(
|
2023-09-09 01:14:46 +03:00
|
|
|
key.WithKeys("K", "shift+up"),
|
2023-09-07 23:53:51 +03:00
|
|
|
key.WithHelp("", "previous sibling"),
|
|
|
|
),
|
|
|
|
ToggleWrap: key.NewBinding(
|
|
|
|
key.WithKeys("z"),
|
|
|
|
key.WithHelp("", "toggle strings wrap"),
|
|
|
|
),
|
2023-09-15 11:39:10 +03:00
|
|
|
Yank: key.NewBinding(
|
|
|
|
key.WithKeys("y"),
|
|
|
|
key.WithHelp("", "yank/copy"),
|
|
|
|
),
|
2023-09-07 23:53:51 +03:00
|
|
|
Search: key.NewBinding(
|
|
|
|
key.WithKeys("/"),
|
|
|
|
key.WithHelp("", "search regexp"),
|
|
|
|
),
|
2023-09-14 18:25:27 +03:00
|
|
|
SearchNext: key.NewBinding(
|
2023-09-07 23:53:51 +03:00
|
|
|
key.WithKeys("n"),
|
|
|
|
key.WithHelp("", "next search result"),
|
|
|
|
),
|
2023-09-14 18:25:27 +03:00
|
|
|
SearchPrev: key.NewBinding(
|
2023-09-07 23:53:51 +03:00
|
|
|
key.WithKeys("N"),
|
|
|
|
key.WithHelp("", "prev search result"),
|
|
|
|
),
|
2023-09-12 14:06:48 +03:00
|
|
|
Dig: key.NewBinding(
|
|
|
|
key.WithKeys("."),
|
|
|
|
key.WithHelp("", "dig json"),
|
|
|
|
),
|
2023-09-07 23:53:51 +03:00
|
|
|
}
|
|
|
|
}
|
2023-09-15 22:55:21 +03:00
|
|
|
|
|
|
|
var (
|
|
|
|
yankValue = key.NewBinding(key.WithKeys("y"))
|
|
|
|
yankKey = key.NewBinding(key.WithKeys("k"))
|
|
|
|
yankPath = key.NewBinding(key.WithKeys("p"))
|
2023-09-19 10:57:51 +03:00
|
|
|
arrowUp = key.NewBinding(key.WithKeys("up"))
|
|
|
|
arrowDown = key.NewBinding(key.WithKeys("down"))
|
2023-09-15 22:55:21 +03:00
|
|
|
)
|