about summary refs log tree commit diff
path: root/edit.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-02-12 01:16:40 -0500
committerJune McEnroe <june@causal.agency>2020-02-12 01:16:40 -0500
commit14ae13f781d1ab30d648eaffbace67a9eec36c5b (patch)
treee9d3c451cddf8c35cfd6c6d5e44e0cd32180c184 /edit.c
parentAdd C-v and M-v (diff)
downloadcatgirl-14ae13f781d1ab30d648eaffbace67a9eec36c5b.tar.gz
catgirl-14ae13f781d1ab30d648eaffbace67a9eec36c5b.zip
Add C-t transpose
Also in emacs, weechat.
Diffstat (limited to '')
-rw-r--r--edit.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/edit.c b/edit.c
index d90d558..573e549 100644
--- a/edit.c
+++ b/edit.c
@@ -182,6 +182,15 @@ void edit(size_t id, enum Edit op, wchar_t ch) {
 			}
 		}
 
+		break; case EditTranspose: {
+			if (!pos || len < 2) break;
+			if (pos == len) pos--;
+			wchar_t t = buf[pos];
+			buf[pos] = buf[pos - 1];
+			buf[pos - 1] = t;
+			pos++;
+		}
+
 		break; case EditInsert: {
 			if (reserve(pos, 1)) {
 				buf[pos++] = ch;