From 7f9b439e0a0e4ace676e9cd1540aec3ec79e1387 Mon Sep 17 00:00:00 2001 From: Curtis Date: Thu, 19 Feb 2026 11:55:20 -0700 Subject: [PATCH 1/3] feat: add ctrl+arrow for word jumping --- edit.go | 4 ++++ keybinding.go | 4 ++++ tcell_driver.go | 16 ++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/edit.go b/edit.go index ac1827ae..725d3ff1 100644 --- a/edit.go +++ b/edit.go @@ -40,10 +40,14 @@ func SimpleEditor(v *View, key Key, ch rune, mod Modifier) bool { v.TextArea.MoveLeftWord() case key == KeyArrowLeft || key == KeyCtrlB: v.TextArea.MoveCursorLeft() + case key == KeyCtrlArrowLeft: + v.TextArea.MoveLeftWord() case (key == KeyArrowRight || ch == 'f') && (mod&ModAlt) != 0: v.TextArea.MoveRightWord() case key == KeyArrowRight || key == KeyCtrlF: v.TextArea.MoveCursorRight() + case key == KeyCtrlArrowRight: + v.TextArea.MoveRightWord() case key == KeyEnter: v.TextArea.TypeCharacter("\n") case key == KeySpace: diff --git a/keybinding.go b/keybinding.go index 0ad5dbe5..51821702 100644 --- a/keybinding.go +++ b/keybinding.go @@ -229,6 +229,10 @@ const ( KeyShiftArrowDown = Key(tcell.KeyF63) KeyArrowLeft = Key(tcell.KeyLeft) KeyArrowRight = Key(tcell.KeyRight) + KeyCtrlArrowLeft = Key(tcell.KeyF52) + KeyCtrlArrowRight = Key(tcell.KeyF53) + KeyCtrlArrowUp = Key(tcell.KeyF54) + KeyCtrlArrowDown = Key(tcell.KeyF55) ) // Keys combinations. diff --git a/tcell_driver.go b/tcell_driver.go index 6e9c12b4..125ba4f3 100644 --- a/tcell_driver.go +++ b/tcell_driver.go @@ -311,6 +311,22 @@ func (g *Gui) pollEvent() GocuiEvent { mod = 0 ch = rune(0) k = tcell.KeyF63 + } else if mod == tcell.ModCtrl && k == tcell.KeyLeft { + mod = 0 + ch = rune(0) + k = tcell.KeyF52 + } else if mod == tcell.ModCtrl && k == tcell.KeyRight { + mod = 0 + ch = rune(0) + k = tcell.KeyF53 + } else if mod == tcell.ModCtrl && k == tcell.KeyUp { + mod = 0 + ch = rune(0) + k = tcell.KeyF54 + } else if mod == tcell.ModCtrl && k == tcell.KeyDown { + mod = 0 + ch = rune(0) + k = tcell.KeyF55 } else if mod == tcell.ModCtrl || mod == tcell.ModShift { // remove Ctrl or Shift if specified // - shift - will be translated to the final code of rune From 84f859f4eb65dc9b1d89634fa95eead1de70a63b Mon Sep 17 00:00:00 2001 From: Curtis Date: Thu, 19 Feb 2026 14:53:51 -0700 Subject: [PATCH 2/3] feat: add ctrl+backspace and ctrl+del support --- edit.go | 4 ++++ keybinding.go | 2 ++ tcell_driver.go | 8 ++++++++ text_area.go | 25 +++++++++++++++++++++---- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/edit.go b/edit.go index 725d3ff1..61b3a8d4 100644 --- a/edit.go +++ b/edit.go @@ -64,6 +64,10 @@ func SimpleEditor(v *View, key Key, ch rune, mod Modifier) bool { v.TextArea.GoToEndOfLine() case key == KeyCtrlW: v.TextArea.BackSpaceWord() + case key == KeyCtrlBackspace: + v.TextArea.BackSpaceWord() + case key == KeyCtrlDelete: + v.TextArea.DeleteWord() case key == KeyCtrlY: v.TextArea.Yank() case ch != 0: diff --git a/keybinding.go b/keybinding.go index 51821702..369a75e2 100644 --- a/keybinding.go +++ b/keybinding.go @@ -233,6 +233,8 @@ const ( KeyCtrlArrowRight = Key(tcell.KeyF53) KeyCtrlArrowUp = Key(tcell.KeyF54) KeyCtrlArrowDown = Key(tcell.KeyF55) + KeyCtrlBackspace = Key(tcell.KeyF56) + KeyCtrlDelete = Key(tcell.KeyF57) ) // Keys combinations. diff --git a/tcell_driver.go b/tcell_driver.go index 125ba4f3..187c8b77 100644 --- a/tcell_driver.go +++ b/tcell_driver.go @@ -327,6 +327,14 @@ func (g *Gui) pollEvent() GocuiEvent { mod = 0 ch = rune(0) k = tcell.KeyF55 + } else if mod == tcell.ModCtrl && k == tcell.KeyBackspace { + mod = 0 + ch = rune(0) + k = tcell.KeyF56 + } else if mod == tcell.ModCtrl && k == tcell.KeyDelete { + mod = 0 + ch = rune(0) + k = tcell.KeyF57 } else if mod == tcell.ModCtrl || mod == tcell.ModShift { // remove Ctrl or Shift if specified // - shift - will be translated to the final code of rune diff --git a/text_area.go b/text_area.go index 9c88e983..4e0db91a 100644 --- a/text_area.go +++ b/text_area.go @@ -341,12 +341,15 @@ func (self *TextArea) MoveLeftWord() { } func (self *TextArea) MoveRightWord() { + self.cursor = self.newCursorForMoveRightWord() +} + +func (self *TextArea) newCursorForMoveRightWord() int { if self.atEnd() { - return + return self.cursor } if self.atLineEnd() { - self.cursor++ - return + return self.cursor + 1 } cellCursor := self.contentCursorToCellCursor(self.cursor) @@ -364,7 +367,7 @@ func (self *TextArea) MoveRightWord() { } } - self.cursor = self.cellCursorToContentCursor(cellCursor) + return self.cellCursorToContentCursor(cellCursor) } func (self *TextArea) MoveCursorUp() { @@ -559,6 +562,20 @@ func (self *TextArea) BackSpaceWord() { self.updateCells() } +func (self *TextArea) DeleteWord() { + newCursor := self.newCursorForMoveRightWord() + if newCursor == self.cursor { + return + } + + clipboard := self.content[self.cursor:newCursor] + if clipboard != "\n" { + self.clipboard = clipboard + } + self.content = self.content[:self.cursor] + self.content[newCursor:] + self.updateCells() +} + func (self *TextArea) Yank() { self.TypeString(self.clipboard) } From aee519d4fd7087ea311c72e55ef272ced9fb4f03 Mon Sep 17 00:00:00 2001 From: Curtis Date: Thu, 19 Feb 2026 15:08:50 -0700 Subject: [PATCH 3/3] fix: Add alt+delete support --- edit.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/edit.go b/edit.go index 61b3a8d4..328ce12d 100644 --- a/edit.go +++ b/edit.go @@ -30,6 +30,8 @@ func SimpleEditor(v *View, key Key, ch rune, mod Modifier) bool { v.TextArea.BackSpaceWord() case key == KeyBackspace || key == KeyBackspace2 || key == KeyCtrlH: v.TextArea.BackSpaceChar() + case key == KeyDelete && (mod&ModAlt) != 0: + v.TextArea.DeleteWord() case key == KeyCtrlD || key == KeyDelete: v.TextArea.DeleteChar() case key == KeyArrowDown: