Also rename all the edit ops to something consistent.
weechat-hashes
C. McEnroe 2020-02-09 03:56:18 -05:00
parent 282de9af30
commit d7c96fc81b
4 changed files with 36 additions and 29 deletions

View File

@ -201,12 +201,16 @@ Switch to window by number.
Move to beginning of line. Move to beginning of line.
.It Ic C-b .It Ic C-b
Move left. Move left.
.It Ic C-d
Delete next character.
.It Ic C-e .It Ic C-e
Move to end of line. Move to end of line.
.It Ic C-f .It Ic C-f
Move right. Move right.
.It Ic C-k
Delete to end of line.
.It Ic C-u .It Ic C-u
Delete line. Delete to beginning of line.
.El .El
. .
.Ss Window Keys .Ss Window Keys

15
chat.h
View File

@ -145,13 +145,14 @@ void uiFormat(
) __attribute__((format(printf, 4, 5))); ) __attribute__((format(printf, 4, 5)));
enum Edit { enum Edit {
EditHome, EditHead,
EditEnd, EditTail,
EditLeft, EditPrev,
EditRight, EditNext,
EditKill, EditKillPrev,
EditErase, EditKillNext,
EditDelete, EditDeletePrev,
EditDeleteNext,
EditInsert, EditInsert,
EditComplete, EditComplete,
EditEnter, EditEnter,

15
edit.c
View File

@ -133,14 +133,15 @@ static void tabReject(void) {
void edit(size_t id, enum Edit op, wchar_t ch) { void edit(size_t id, enum Edit op, wchar_t ch) {
size_t init = pos; size_t init = pos;
switch (op) { switch (op) {
break; case EditHome: pos = 0; break; case EditHead: pos = 0;
break; case EditEnd: pos = len; break; case EditTail: pos = len;
break; case EditLeft: if (pos) pos--; break; case EditPrev: if (pos) pos--;
break; case EditRight: if (pos < len) pos++; break; case EditNext: if (pos < len) pos++;
break; case EditKill: len = pos = 0; break; case EditDeletePrev: if (pos) delete(--pos, 1);
break; case EditErase: if (pos) delete(--pos, 1); break; case EditDeleteNext: delete(pos, 1);
break; case EditDelete: delete(pos, 1); break; case EditKillPrev: delete(0, pos); pos = 0;
break; case EditKillNext: delete(pos, len - pos);
break; case EditInsert: { break; case EditInsert: {
reserve(pos, 1); reserve(pos, 1);

29
ui.c
View File

@ -624,13 +624,13 @@ static void keyCode(int code) {
break; case KeyMetaM: waddch(windows.active->pad, '\n'); break; case KeyMetaM: waddch(windows.active->pad, '\n');
break; case KEY_BACKSPACE: edit(id, EditErase, 0); break; case KEY_BACKSPACE: edit(id, EditDeletePrev, 0);
break; case KEY_DC: edit(id, EditDelete, 0); break; case KEY_DC: edit(id, EditDeleteNext, 0);
break; case KEY_END: edit(id, EditEnd, 0); break; case KEY_END: edit(id, EditTail, 0);
break; case KEY_ENTER: edit(id, EditEnter, 0); break; case KEY_ENTER: edit(id, EditEnter, 0);
break; case KEY_HOME: edit(id, EditHome, 0); break; case KEY_HOME: edit(id, EditHead, 0);
break; case KEY_LEFT: edit(id, EditLeft, 0); break; case KEY_LEFT: edit(id, EditPrev, 0);
break; case KEY_RIGHT: edit(id, EditRight, 0); break; case KEY_RIGHT: edit(id, EditNext, 0);
break; default: { break; default: {
if (code >= KeyMeta0 && code <= KeyMeta9) { if (code >= KeyMeta0 && code <= KeyMeta9) {
@ -643,17 +643,18 @@ static void keyCode(int code) {
static void keyCtrl(wchar_t ch) { static void keyCtrl(wchar_t ch) {
size_t id = windows.active->id; size_t id = windows.active->id;
switch (ch ^ L'@') { switch (ch ^ L'@') {
break; case L'?': edit(id, EditErase, 0); break; case L'?': edit(id, EditDeletePrev, 0);
break; case L'A': edit(id, EditHome, 0); break; case L'A': edit(id, EditHead, 0);
break; case L'B': edit(id, EditLeft, 0); break; case L'B': edit(id, EditPrev, 0);
break; case L'D': edit(id, EditDelete, 0); break; case L'D': edit(id, EditDeleteNext, 0);
break; case L'E': edit(id, EditEnd, 0); break; case L'E': edit(id, EditTail, 0);
break; case L'F': edit(id, EditRight, 0); break; case L'F': edit(id, EditNext, 0);
break; case L'H': edit(id, EditErase, 0); break; case L'H': edit(id, EditDeletePrev, 0);
break; case L'I': edit(id, EditComplete, 0); break; case L'I': edit(id, EditComplete, 0);
break; case L'J': edit(id, EditEnter, 0); break; case L'J': edit(id, EditEnter, 0);
break; case L'K': edit(id, EditKillNext, 0);
break; case L'L': clearok(curscr, true); break; case L'L': clearok(curscr, true);
break; case L'U': edit(id, EditKill, 0); break; case L'U': edit(id, EditKillPrev, 0);
} }
} }