Add M-b and M-f

weechat-hashes
C. McEnroe 2020-02-09 04:20:07 -05:00
parent d7c96fc81b
commit b08c2d03ef
4 changed files with 18 additions and 0 deletions

View File

@ -211,6 +211,10 @@ Move right.
Delete to end of line. Delete to end of line.
.It Ic C-u .It Ic C-u
Delete to beginning of line. Delete to beginning of line.
.It Ic M-b
Move to previous word.
.It Ic M-f
Move to next word.
.El .El
. .
.Ss Window Keys .Ss Window Keys

2
chat.h
View File

@ -149,6 +149,8 @@ enum Edit {
EditTail, EditTail,
EditPrev, EditPrev,
EditNext, EditNext,
EditPrevWord,
EditNextWord,
EditKillPrev, EditKillPrev,
EditKillNext, EditKillNext,
EditDeletePrev, EditDeletePrev,

8
edit.c
View File

@ -137,6 +137,14 @@ void edit(size_t id, enum Edit op, wchar_t ch) {
break; case EditTail: pos = len; break; case EditTail: pos = len;
break; case EditPrev: if (pos) pos--; break; case EditPrev: if (pos) pos--;
break; case EditNext: if (pos < len) pos++; break; case EditNext: if (pos < len) pos++;
break; case EditPrevWord: {
if (pos) pos--;
while (pos && buf[pos - 1] != L' ') pos--;
}
break; case EditNextWord: {
if (pos < len) pos++;
while (pos < len && buf[pos] != L' ') pos++;
}
break; case EditDeletePrev: if (pos) delete(--pos, 1); break; case EditDeletePrev: if (pos) delete(--pos, 1);
break; case EditDeleteNext: delete(pos, 1); break; case EditDeleteNext: delete(pos, 1);

4
ui.c
View File

@ -192,6 +192,8 @@ static void errExit(void) {
X(KeyMeta7, "\0337") \ X(KeyMeta7, "\0337") \
X(KeyMeta8, "\0338") \ X(KeyMeta8, "\0338") \
X(KeyMeta9, "\0339") \ X(KeyMeta9, "\0339") \
X(KeyMetaB, "\033b") \
X(KeyMetaF, "\033f") \
X(KeyMetaM, "\33m") \ X(KeyMetaM, "\33m") \
X(KeyFocusIn, "\33[I") \ X(KeyFocusIn, "\33[I") \
X(KeyFocusOut, "\33[O") \ X(KeyFocusOut, "\33[O") \
@ -622,6 +624,8 @@ static void keyCode(int code) {
break; case KeyPasteOn:; // TODO break; case KeyPasteOn:; // TODO
break; case KeyPasteOff:; // TODO break; case KeyPasteOff:; // TODO
break; case KeyMetaB: edit(id, EditPrevWord, 0);
break; case KeyMetaF: edit(id, EditNextWord, 0);
break; case KeyMetaM: waddch(windows.active->pad, '\n'); break; case KeyMetaM: waddch(windows.active->pad, '\n');
break; case KEY_BACKSPACE: edit(id, EditDeletePrev, 0); break; case KEY_BACKSPACE: edit(id, EditDeletePrev, 0);