generated from charmbracelet/bubbletea-app-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeymap.go
49 lines (44 loc) · 1.04 KB
/
keymap.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"github.com/charmbracelet/bubbles/key"
)
type KeyMap struct {
quit key.Binding
nextTab key.Binding
prevTab key.Binding
Help key.Binding
enter key.Binding
}
var Keys = KeyMap{
quit: key.NewBinding(
key.WithKeys("q", "ctrl+c"), // actual keybindings
key.WithHelp("q", "quit"), // corresponding help text
),
nextTab: key.NewBinding(
key.WithKeys("ctrl+n"),
key.WithHelp("ctrl+n", "next tab"),
),
prevTab: key.NewBinding(
key.WithKeys("ctrl+p"),
key.WithHelp("ctrl+p", "previous tab"),
),
Help: key.NewBinding(
key.WithKeys("?"),
key.WithHelp("?", "toggle help"),
),
enter: key.NewBinding(
key.WithKeys("enter"),
key.WithHelp("enter", "enter input"),
),
}
func (k KeyMap) ShortHelp() []key.Binding {
return []key.Binding{k.Help, k.quit}
}
// FullHelp returns keybindings for the expanded help view. It's part of the
// key.Map interface.
func (k KeyMap) FullHelp() [][]key.Binding {
return [][]key.Binding{
{k.nextTab, k.prevTab}, // first column
{k.Help, k.quit}, // second column
}
}