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// KeyBindings implements layout.KeyMapProvider
31func (k EditorKeyMap) KeyBindings() []key.Binding {
32 return []key.Binding{
33 k.AddFile,
34 k.SendMessage,
35 k.OpenEditor,
36 }
37}
38
39type DeleteAttachmentKeyMaps struct {
40 AttachmentDeleteMode key.Binding
41 Escape key.Binding
42 DeleteAllAttachments key.Binding
43}
44
45// TODO: update this to use the new keymap concepts
46var AttachmentsKeyMaps = DeleteAttachmentKeyMaps{
47 AttachmentDeleteMode: key.NewBinding(
48 key.WithKeys("ctrl+r"),
49 key.WithHelp("ctrl+r+{i}", "delete attachment at index i"),
50 ),
51 Escape: key.NewBinding(
52 key.WithKeys("esc"),
53 key.WithHelp("esc", "cancel delete mode"),
54 ),
55 DeleteAllAttachments: key.NewBinding(
56 key.WithKeys("r"),
57 key.WithHelp("ctrl+r+r", "delete all attachments"),
58 ),
59}