summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--catgirl.12
-rw-r--r--chat.h1
-rw-r--r--edit.c9
-rw-r--r--ui.c3
4 files changed, 14 insertions, 1 deletions
diff --git a/catgirl.1 b/catgirl.1
index ad62f83..518f830 100644
--- a/catgirl.1
+++ b/catgirl.1
@@ -265,6 +265,8 @@ Move to end of line.
Move right.
.It Ic C-k
Delete to end of line.
+.It Ic C-t
+Transpose characters.
.It Ic C-u
Delete to beginning of line.
.It Ic C-w
diff --git a/chat.h b/chat.h
index 4e9a230..aa2f87c 100644
--- a/chat.h
+++ b/chat.h
@@ -176,6 +176,7 @@ enum Edit {
EditDeletePrevWord,
EditDeleteNextWord,
EditPaste,
+ EditTranspose,
EditInsert,
EditComplete,
EditEnter,
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;
diff --git a/ui.c b/ui.c
index 328db1b..e6041cc 100644
--- a/ui.c
+++ b/ui.c
@@ -844,9 +844,10 @@ static void keyCtrl(wchar_t ch) {
break; case L'N': windowShow(windows.active->next);
break; case L'O': windowShow(windows.other);
break; case L'P': windowShow(windows.active->prev);
+ break; case L'T': edit(id, EditTranspose, 0);
break; case L'U': edit(id, EditDeleteHead, 0);
- break; case L'W': edit(id, EditDeletePrevWord, 0);
break; case L'V': windowScroll(windows.active, -(PAGE_LINES - 2));
+ break; case L'W': edit(id, EditDeletePrevWord, 0);
break; case L'Y': edit(id, EditPaste, 0);
}
}