Implement Ctrl-W for deleting word left. Fixes
MODIFY
shortcuts/shortcuts.go
shortcuts/shortcuts.go
@@ -73,6 +73,8 @@ var (
DeleteRight = addShortcut("delete_right", "Delete right",
multilineTextInput, tcell.NewEventKey(tcell.KeyDelete, 0, tcell.ModNone))
+ DeleteWordLeft = addShortcut("delete_word_left", "Delete word left",
+ multilineTextInput, tcell.NewEventKey(tcell.KeyCtrlW, rune(tcell.KeyCtrlW), tcell.ModCtrl))
InputNewLine = addShortcut("add_new_line_character", "Add new line character",
multilineTextInput, tcell.NewEventKey(tcell.KeyEnter, rune(tcell.KeyEnter), tcell.ModAlt))

MODIFY
ui/editor.go
ui/editor.go
@@ -306,6 +306,22 @@ func (editor *Editor) Backspace() {
}
}
+func (editor *Editor) DeleteWordLeft() {
+ if editor.buffer.Cursor.HasSelection() {
+ editor.Backspace()
+ } else {
+ oldLocation := editor.buffer.Cursor.Loc
+ editor.buffer.Cursor.WordLeft()
+ newLocation := editor.buffer.Cursor.Loc
+
+ if oldLocation.X != newLocation.X || oldLocation.Y != newLocation.Y {
+ editor.buffer.Cursor.SetSelectionStart(newLocation)
+ editor.buffer.Cursor.SetSelectionEnd(oldLocation)
+ editor.Backspace()
+ }
+ }
+}
+
func (editor *Editor) DeleteRight() {
if editor.buffer.Cursor.HasSelection() {
editor.buffer.Remove(editor.buffer.Cursor.CurSelection[0], editor.buffer.Cursor.CurSelection[1])
@@ -411,6 +427,8 @@ func NewEditor() *Editor {
event.Key() == tcell.KeyBackspace {
// FIXME Legacy, has to be replaced when there is N-1 Keybind-Mapping.
editor.Backspace()
+ } else if shortcuts.DeleteWordLeft.Equals(event) {
+ editor.DeleteWordLeft()
} else if shortcuts.CopySelection.Equals(event) {
clipboard.WriteAll(editor.buffer.Cursor.GetSelection())
//Returning nil, as copying won't do anything than filling the

Implement Ctrl-W for deleting word left. Fixes #225