summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-02-09 04:20:07 -0500
committerJune McEnroe <june@causal.agency>2020-02-09 04:20:07 -0500
commitb08c2d03efa08bd319a0665d12bef34df08ab283 (patch)
treeb880a35e71127ad3165159df2b53888b2273fc6e
parentAdd C-k (diff)
downloadcatgirl-b08c2d03efa08bd319a0665d12bef34df08ab283.tar.gz
catgirl-b08c2d03efa08bd319a0665d12bef34df08ab283.zip
Add M-b and M-f
Diffstat (limited to '')
-rw-r--r--catgirl.14
-rw-r--r--chat.h2
-rw-r--r--edit.c8
-rw-r--r--ui.c4
4 files changed, 18 insertions, 0 deletions
diff --git a/catgirl.1 b/catgirl.1
index a356fe0..9cb208e 100644
--- a/catgirl.1
+++ b/catgirl.1
@@ -211,6 +211,10 @@ Move right.
 Delete to end of line.
 .It Ic C-u
 Delete to beginning of line.
+.It Ic M-b
+Move to previous word.
+.It Ic M-f
+Move to next word.
 .El
 .
 .Ss Window Keys
diff --git a/chat.h b/chat.h
index aa1bcc1..6b68eae 100644
--- a/chat.h
+++ b/chat.h
@@ -149,6 +149,8 @@ enum Edit {
 	EditTail,
 	EditPrev,
 	EditNext,
+	EditPrevWord,
+	EditNextWord,
 	EditKillPrev,
 	EditKillNext,
 	EditDeletePrev,
diff --git a/edit.c b/edit.c
index 7fcff40..38b2dea 100644
--- a/edit.c
+++ b/edit.c
@@ -137,6 +137,14 @@ void edit(size_t id, enum Edit op, wchar_t ch) {
 		break; case EditTail: pos = len;
 		break; case EditPrev: if (pos) 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 EditDeleteNext: delete(pos, 1);
diff --git a/ui.c b/ui.c
index d83a1f3..7811e88 100644
--- a/ui.c
+++ b/ui.c
@@ -192,6 +192,8 @@ static void errExit(void) {
 	X(KeyMeta7, "\0337") \
 	X(KeyMeta8, "\0338") \
 	X(KeyMeta9, "\0339") \
+	X(KeyMetaB, "\033b") \
+	X(KeyMetaF, "\033f") \
 	X(KeyMetaM, "\33m") \
 	X(KeyFocusIn, "\33[I") \
 	X(KeyFocusOut, "\33[O") \
@@ -622,6 +624,8 @@ static void keyCode(int code) {
 		break; case KeyPasteOn:; // 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 KEY_BACKSPACE: edit(id, EditDeletePrev, 0);