keys.go

 1package editor
 2
 3import (
 4	"github.com/charmbracelet/bubbles/v2/key"
 5)
 6
 7type EditorKeyMap struct {
 8	AddFile     key.Binding
 9	SendMessage key.Binding
10	OpenEditor  key.Binding
11}
12
13func DefaultEditorKeyMap() EditorKeyMap {
14	return EditorKeyMap{
15		AddFile: key.NewBinding(
16			key.WithKeys("/"),
17			key.WithHelp("/", "add file"),
18		),
19		SendMessage: key.NewBinding(
20			key.WithKeys("enter"),
21			key.WithHelp("enter", "send"),
22		),
23		OpenEditor: key.NewBinding(
24			key.WithKeys("ctrl+e"),
25			key.WithHelp("ctrl+e", "open editor"),
26		),
27	}
28}
29
30// TODO: update this to use the new keymap concepts
31var AttachmentsKeyMaps = DeleteAttachmentKeyMaps{
32	AttachmentDeleteMode: key.NewBinding(
33		key.WithKeys("ctrl+r"),
34		key.WithHelp("ctrl+r+{i}", "delete attachment at index i"),
35	),
36	Escape: key.NewBinding(
37		key.WithKeys("esc"),
38		key.WithHelp("esc", "cancel delete mode"),
39	),
40	DeleteAllAttachments: key.NewBinding(
41		key.WithKeys("r"),
42		key.WithHelp("ctrl+r+r", "delete all attachments"),
43	),
44}