diff options
author | C. McEnroe | 2020-02-09 04:32:32 -0500 |
---|---|---|
committer | C. McEnroe | 2020-02-09 04:32:32 -0500 |
commit | 5e637324c9f2b16a602c1b66081390624598c703 (patch) | |
tree | d3c12f45ff2ab82cf1a07ac7e8d9d769e4f25bb2 /edit.c | |
parent | 3cd830681e25022a8a3936ca9fe58d149fbe493a (diff) |
Add C-w and M-d
Diffstat (limited to 'edit.c')
-rw-r--r-- | edit.c | 17 |
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); |