forked from c-bata/go-prompt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
key_bind_default.go
103 lines (92 loc) · 2.1 KB
/
key_bind_default.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
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
package prompt
/*
Navigate
--------
* [x] Ctrl + f Move to the next character (->)
* [x] Ctrl + b Move to the previous character (<-)
* [x] Meta + f Move to the start of the next word
* [x] Meta + b Move to the start of the previous word
* [x] Ctrl + e Move to the end of the line (End)
* [x] Ctrl + a Move to the beginning of the line (Home)
Edit
----
* [x] Ctrl + d Cut the character after the cursor (Delete)
* [x] Ctrl + h Cut the character before the cursor (Backspace)
* [x] Meta + d Cut the word after the cursor
* [x] Ctrl + w Cut the word before the cursor
* [x] Ctrl + k Cut the line after the cursor
* [x] Ctrl + u Cut the line before the cursor
Utility
-------
* [x] Ctrl + l Clear the Screen, similar to the clear command
* [x] Ctrl + y Paste the last thing to be cut
TBD
---
* [ ] Meta + backspace Cut the word before the cursor
* [ ] Ctrl + t Swap the last two characters before the cursor
* [ ] Meta + t Swap the current word with the previous word
* [ ] Ctrl + _ Undo
*/
func defaultKeyBindings() []KeyBind {
return append([]KeyBind{
// Navigate
{
Key: ControlF,
Fn: KeyBindMoveCharNext,
},
{
Key: ControlB,
Fn: KeyBindMoveCharPrev,
},
{
Key: MetaF,
Fn: KeyBindMoveWordNext,
},
{
Key: MetaB,
Fn: KeyBindMoveWordPrev,
},
{
Key: ControlE,
Fn: KeyBindMoveLineEnd,
},
{
Key: ControlA,
Fn: KeyBindMoveLineStart,
},
// Edit
{
Key: ControlD,
Fn: KeyBindCutCharAfter,
},
{
Key: ControlH,
Fn: KeyBindCutCharBefore,
},
{
Key: MetaD,
Fn: KeyBindCutWordAfter,
},
{
Key: ControlW,
Fn: KeyBindCutWordBefore,
},
{
Key: ControlK,
Fn: KeyBindCutLineAfter,
},
{
Key: ControlU,
Fn: KeyBindCutLineBefore,
},
{
Key: ControlY,
Fn: KeyBindInsertLastCutAfter,
},
// Util
{
Key: ControlL,
Fn: KeyBindUtilScreenClear,
},
}, defaultPlatformKeyBindings()...)
}