summary refs log tree commit diff
path: root/edit.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-02-09 04:32:32 -0500
committerJune McEnroe <june@causal.agency>2020-02-09 04:32:32 -0500
commit5e637324c9f2b16a602c1b66081390624598c703 (patch)
treed3c12f45ff2ab82cf1a07ac7e8d9d769e4f25bb2 /edit.c
parentRename kill ops (diff)
downloadcatgirl-5e637324c9f2b16a602c1b66081390624598c703.tar.gz
catgirl-5e637324c9f2b16a602c1b66081390624598c703.zip
Add C-w and M-d
Diffstat (limited to '')
-rw-r--r--edit.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/edit.c b/edit.c
index 7b20079..47478ec 100644
--- a/edit.c
+++ b/edit.c
@@ -146,10 +146,23 @@ void edit(size_t id, enum Edit op, wchar_t ch) {
 			while (pos < len && buf[pos] != L' ') pos++;
 		}
 
-		break; case EditDeletePrev: if (pos) delete(--pos, 1);
-		break; case EditDeleteNext: delete(pos, 1);
 		break; case EditDeleteHead: delete(0, pos); pos = 0;
 		break; case EditDeleteTail: delete(pos, len - pos);
+		break; case EditDeletePrev: if (pos) delete(--pos, 1);
+		break; case EditDeleteNext: delete(pos, 1);
+		break; case EditDeletePrevWord: {
+			if (!pos) break;
+			size_t word = pos - 1;
+			while (word && buf[word - 1] != L' ') word--;
+			delete(word, pos - word);
+			pos = word;
+		}
+		break; case EditDeleteNextWord: {
+			if (pos == len) break;
+			size_t word = pos + 1;
+			while (word < len && buf[word] != L' ') word++;
+			delete(pos, word - pos);
+		}
 
 		break; case EditInsert: {
 			reserve(pos, 1);