Support Alt+Backspace for word deletion in text areas (#4741)

- **PR Description**
Add support for Alt+Backspace (Option+Backspace on macOS) to delete
entire words in text input areas, matching common text editor behavior.
This commit is contained in:
Stefan Haller 2025-07-17 19:20:52 +02:00 committed by GitHub
commit d159b28dc0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,6 +8,9 @@ import (
func (gui *Gui) handleEditorKeypress(textArea *gocui.TextArea, key gocui.Key, ch rune, mod gocui.Modifier, allowMultiline bool) bool {
switch {
case (key == gocui.KeyBackspace || key == gocui.KeyBackspace2) && (mod&gocui.ModAlt) != 0,
key == gocui.KeyCtrlW:
textArea.BackSpaceWord()
case key == gocui.KeyBackspace || key == gocui.KeyBackspace2:
textArea.BackSpaceChar()
case key == gocui.KeyCtrlD || key == gocui.KeyDelete:
@ -42,8 +45,6 @@ func (gui *Gui) handleEditorKeypress(textArea *gocui.TextArea, key gocui.Key, ch
textArea.GoToStartOfLine()
case key == gocui.KeyCtrlE || key == gocui.KeyEnd:
textArea.GoToEndOfLine()
case key == gocui.KeyCtrlW:
textArea.BackSpaceWord()
case key == gocui.KeyCtrlY:
textArea.Yank()