about summary refs log tree commit diff
path: root/edit.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-09-12 22:55:02 -0400
committerJune McEnroe <june@causal.agency>2018-09-12 22:55:02 -0400
commitb36a1347022965fdbe1b61298dc6a05be2d2a34d (patch)
treeb758829545252a09cac25ac7e89774faa36ae186 /edit.c
parentFactor out IRC formatting parsing (diff)
downloadcatgirl-b36a1347022965fdbe1b61298dc6a05be2d2a34d.tar.gz
catgirl-b36a1347022965fdbe1b61298dc6a05be2d2a34d.zip
Use formatParse split to position input cursor
Diffstat (limited to 'edit.c')
-rw-r--r--edit.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/edit.c b/edit.c
index 5aca61f..38ee843 100644
--- a/edit.c
+++ b/edit.c
@@ -33,17 +33,10 @@ static struct {
 	.end = line.buf,
 };
 
-// XXX: editTail must always be called after editHead.
-static wchar_t tail;
 const wchar_t *editHead(void) {
-	tail = *line.ptr;
-	*line.ptr = L'\0';
 	return line.buf;
 }
 const wchar_t *editTail(void) {
-	if (tail) *line.ptr = tail;
-	*line.end = L'\0';
-	tail = L'\0';
 	return line.ptr;
 }
 
@@ -180,10 +173,12 @@ void edit(struct Tag tag, enum Edit op, wchar_t ch) {
 
 		break; case EditKillBackWord: reject(); killBackWord();
 		break; case EditKillForeWord: reject(); killForeWord();
-		break; case EditKillLine:      reject(); line.end = line.ptr;
+		break; case EditKillLine:     reject(); line.end = line.ptr;
 
 		break; case EditComplete: complete(tag);
 
 		break; case EditEnter: accept(); enter(tag);
 	}
+
+	*line.end = L'\0';
 }