commit f8898af
delthas
·
2026-03-08 13:09:45 +0000 UTC
parent 6a9a5a0
Add cursor-delete-next-word on Alt+Suppr At the request of rnkn on IRC. Thanks!
4 files changed,
+33,
-0
M
app.go
+5,
-0
1@@ -964,6 +964,10 @@ func (app *App) handleAction(action string, args ...string) {
2 if app.win.InputDeleteWord() {
3 app.typing()
4 }
5+ case "cursor-delete-next-word":
6+ if app.win.InputDeleteNextWord() {
7+ app.typing()
8+ }
9 case "cursor-delete-previous":
10 if app.win.InputBackspace() {
11 app.typing()
12@@ -1067,6 +1071,7 @@ var defaultCommands = map[string][]string{
13 "Alt+End": {"buffer", "last"},
14 "End": {"cursor-end"},
15 "Alt+BackSpace": {"cursor-delete-previous-word"},
16+ "Alt+Delete": {"cursor-delete-next-word"},
17 "BackSpace": {"cursor-delete-previous"},
18 "Shift+BackSpace": {"cursor-delete-previous"},
19 "Delete": {"cursor-delete-next"},
+2,
-0
1@@ -229,6 +229,8 @@ shortcuts {
2 : scroll forward one line in the editor
3 | cursor-delete-previous-word
4 : delete the previous word in the editor
5+| cursor-delete-next-word
6+: delete the next word in the editor
7 | cursor-delete-previous
8 : delete the previous character in the editor
9 | cursor-delete-next
+22,
-0
1@@ -281,6 +281,28 @@ func (e *Editor) RemWord() (ok bool) {
2 return
3 }
4
5+func (e *Editor) RemWordForward() (ok bool) {
6+ ok = e.cursorIdx < len(e.text[e.lineIdx].clusters)-1
7+ if !ok {
8+ return
9+ }
10+
11+ for e.cursorIdx < len(e.text[e.lineIdx].clusters)-1 && e.text[e.lineIdx].runes[e.text[e.lineIdx].clusters[e.cursorIdx]] == ' ' {
12+ e.remClusterAt(e.cursorIdx)
13+ }
14+
15+ for e.cursorIdx < len(e.text[e.lineIdx].clusters)-1 {
16+ if e.text[e.lineIdx].runes[e.text[e.lineIdx].clusters[e.cursorIdx]] == ' ' {
17+ break
18+ }
19+ e.remClusterAt(e.cursorIdx)
20+ }
21+
22+ e.autoCache = nil
23+ e.backsearchEnd()
24+ return
25+}
26+
27 func (e *Editor) Flush() string {
28 l := e.text[e.lineIdx]
29 content := string(l.runes)
M
ui/ui.go
+4,
-0
1@@ -684,6 +684,10 @@ func (ui *UI) InputDeleteWord() (ok bool) {
2 return ui.e.RemWord()
3 }
4
5+func (ui *UI) InputDeleteNextWord() (ok bool) {
6+ return ui.e.RemWordForward()
7+}
8+
9 func (ui *UI) InputAutoComplete() (ok bool) {
10 return ui.e.AutoComplete()
11 }