Add C-t transpose

Also in emacs, weechat.
master
C. McEnroe 2020-02-12 01:16:40 -05:00
parent aab9f76fa0
commit 14ae13f781
4 changed files with 14 additions and 1 deletions

View File

@ -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

1
chat.h
View File

@ -176,6 +176,7 @@ enum Edit {
EditDeletePrevWord,
EditDeleteNextWord,
EditPaste,
EditTranspose,
EditInsert,
EditComplete,
EditEnter,

9
edit.c
View File

@ -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;

3
ui.c
View File

@ -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);
}
}