-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeys.go
More file actions
242 lines (215 loc) · 4.77 KB
/
Copy pathkeys.go
File metadata and controls
242 lines (215 loc) · 4.77 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
package main
import "github.com/charmbracelet/bubbles/key"
// KeyMap defines the keybindings for the application.
type KeyMap struct {
// Navigation
Up key.Binding
Down key.Binding
Left key.Binding
Right key.Binding
Bottom key.Binding
PageUp key.Binding
PageDown key.Binding
// File operations
Copy key.Binding
Cut key.Binding
Paste key.Binding
Delete key.Binding
Rename key.Binding
// Create
CreateFile key.Binding
CreateDir key.Binding
// Selection
Select key.Binding
SelectAll key.Binding
// Git
Stage key.Binding
Unstage key.Binding
Diff key.Binding
// View
TogglePreview key.Binding
ToggleHidden key.Binding
SortMode key.Binding
Refresh key.Binding
// Filter
Filter key.Binding
// Shell
Shell key.Binding
// Bookmarks
BookmarkAdd key.Binding
BookmarkShow key.Binding
BookmarkRemove key.Binding
// Command palette
CommandPalette key.Binding
// Undo
Undo key.Binding
// Other
Quit key.Binding
Help key.Binding
}
// DefaultKeyMap returns the default keybindings (Vi style).
func DefaultKeyMap() KeyMap {
return KeyMap{
// Navigation
Up: key.NewBinding(
key.WithKeys("k", "up"),
key.WithHelp("k/↑", "up"),
),
Down: key.NewBinding(
key.WithKeys("j", "down"),
key.WithHelp("j/↓", "down"),
),
Left: key.NewBinding(
key.WithKeys("h", "left"),
key.WithHelp("h/←", "back"),
),
Right: key.NewBinding(
key.WithKeys("l", "right", "enter"),
key.WithHelp("l/→/enter", "open"),
),
Bottom: key.NewBinding(
key.WithKeys("G"),
key.WithHelp("G", "bottom"),
),
PageUp: key.NewBinding(
key.WithKeys("ctrl+u"),
key.WithHelp("ctrl+u", "page up"),
),
PageDown: key.NewBinding(
key.WithKeys("ctrl+d"),
key.WithHelp("ctrl+d", "page down"),
),
// File operations
Copy: key.NewBinding(
key.WithKeys("y"),
key.WithHelp("y", "copy"),
),
Cut: key.NewBinding(
key.WithKeys("d"),
key.WithHelp("d", "cut"),
),
Paste: key.NewBinding(
key.WithKeys("p"),
key.WithHelp("p", "paste"),
),
Delete: key.NewBinding(
key.WithKeys("x"),
key.WithHelp("x", "delete"),
),
Rename: key.NewBinding(
key.WithKeys("r"),
key.WithHelp("r", "rename"),
),
// Create
CreateFile: key.NewBinding(
key.WithKeys("n"),
key.WithHelp("n", "new file"),
),
CreateDir: key.NewBinding(
key.WithKeys("N"),
key.WithHelp("N", "new directory"),
),
// Selection
Select: key.NewBinding(
key.WithKeys(" "),
key.WithHelp("space", "select"),
),
SelectAll: key.NewBinding(
key.WithKeys("a"),
key.WithHelp("a", "select all"),
),
// Git
Stage: key.NewBinding(
key.WithKeys("s"),
key.WithHelp("s", "stage"),
),
Unstage: key.NewBinding(
key.WithKeys("S"),
key.WithHelp("S", "unstage"),
),
Diff: key.NewBinding(
key.WithKeys("D"),
key.WithHelp("D", "diff"),
),
// View
TogglePreview: key.NewBinding(
key.WithKeys("tab"),
key.WithHelp("tab", "preview"),
),
ToggleHidden: key.NewBinding(
key.WithKeys("."),
key.WithHelp(".", "hidden files"),
),
SortMode: key.NewBinding(
key.WithKeys("o"),
key.WithHelp("o", "cycle sort"),
),
Refresh: key.NewBinding(
key.WithKeys("R"),
key.WithHelp("R", "refresh"),
),
// Filter
Filter: key.NewBinding(
key.WithKeys("/"),
key.WithHelp("/", "filter"),
),
// Shell
Shell: key.NewBinding(
key.WithKeys("ctrl+z"),
key.WithHelp("ctrl+z", "shell"),
),
// Bookmarks
BookmarkAdd: key.NewBinding(
key.WithKeys("B"),
key.WithHelp("B", "add bookmark"),
),
BookmarkShow: key.NewBinding(
key.WithKeys("b"),
key.WithHelp("b", "bookmarks"),
),
BookmarkRemove: key.NewBinding(
key.WithKeys("ctrl+b"),
key.WithHelp("ctrl+b", "remove bookmark"),
),
// Command palette
CommandPalette: key.NewBinding(
key.WithKeys(":"),
key.WithHelp(":", "command palette"),
),
// Undo
Undo: key.NewBinding(
key.WithKeys("u"),
key.WithHelp("u", "undo"),
),
// Other
Quit: key.NewBinding(
key.WithKeys("q", "ctrl+c"),
key.WithHelp("q", "quit"),
),
Help: key.NewBinding(
key.WithKeys("?"),
key.WithHelp("?", "help"),
),
}
}
// ShortHelp returns the short help text for the status bar.
func (k KeyMap) ShortHelp() []key.Binding {
return []key.Binding{k.Help, k.Quit}
}
// FullHelp returns the full help text for the help view.
func (k KeyMap) FullHelp() [][]key.Binding {
return [][]key.Binding{
{k.Up, k.Down, k.Left, k.Right, k.Bottom, k.PageUp, k.PageDown},
{k.Filter},
{k.Copy, k.Cut, k.Paste, k.Delete, k.Rename, k.CreateFile, k.CreateDir},
{k.Select, k.SelectAll},
{k.SortMode},
{k.Stage, k.Unstage, k.Diff},
{k.TogglePreview, k.ToggleHidden},
{k.BookmarkAdd, k.BookmarkShow, k.BookmarkRemove},
{k.CommandPalette},
{k.Undo},
{k.Shell},
{k.Help, k.Quit},
}
}