...
1 package prompt
2
3 import "github.com/c-bata/go-prompt/internal/debug"
4
5
40
41 var emacsKeyBindings = []KeyBind{
42
43 {
44 Key: ControlE,
45 Fn: func(buf *Buffer) {
46 x := []rune(buf.Document().TextAfterCursor())
47 buf.CursorRight(len(x))
48 },
49 },
50
51 {
52 Key: ControlA,
53 Fn: func(buf *Buffer) {
54 x := []rune(buf.Document().TextBeforeCursor())
55 buf.CursorLeft(len(x))
56 },
57 },
58
59 {
60 Key: ControlK,
61 Fn: func(buf *Buffer) {
62 x := []rune(buf.Document().TextAfterCursor())
63 buf.Delete(len(x))
64 },
65 },
66
67 {
68 Key: ControlU,
69 Fn: func(buf *Buffer) {
70 x := []rune(buf.Document().TextBeforeCursor())
71 buf.DeleteBeforeCursor(len(x))
72 },
73 },
74
75 {
76 Key: ControlD,
77 Fn: func(buf *Buffer) {
78 if buf.Text() != "" {
79 buf.Delete(1)
80 }
81 },
82 },
83
84 {
85 Key: ControlH,
86 Fn: func(buf *Buffer) {
87 buf.DeleteBeforeCursor(1)
88 },
89 },
90
91 {
92 Key: ControlF,
93 Fn: func(buf *Buffer) {
94 buf.CursorRight(1)
95 },
96 },
97
98 {
99 Key: ControlB,
100 Fn: func(buf *Buffer) {
101 buf.CursorLeft(1)
102 },
103 },
104
105 {
106 Key: ControlW,
107 Fn: func(buf *Buffer) {
108 buf.DeleteBeforeCursor(len([]rune(buf.Document().GetWordBeforeCursorWithSpace())))
109 },
110 },
111
112 {
113 Key: ControlL,
114 Fn: func(buf *Buffer) {
115 consoleWriter.EraseScreen()
116 consoleWriter.CursorGoTo(0, 0)
117 debug.AssertNoError(consoleWriter.Flush())
118 },
119 },
120 }
121
View as plain text