summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--chat.h1
-rw-r--r--complete.c13
-rw-r--r--handle.c8
3 files changed, 21 insertions, 1 deletions
diff --git a/chat.h b/chat.h
index f164e7a..aec5a68 100644
--- a/chat.h
+++ b/chat.h
@@ -153,6 +153,7 @@ void completeAccept(void);
 void completeReject(void);
 void completeAdd(size_t id, const char *str, enum Color color);
 void completeTouch(size_t id, const char *str, enum Color color);
+void completeRemove(size_t id, const char *str);
 
 FILE *configOpen(const char *path, const char *mode);
 int getopt_config(
diff --git a/complete.c b/complete.c
index 8247149..5067512 100644
--- a/complete.c
+++ b/complete.c
@@ -109,3 +109,16 @@ void completeAccept(void) {
 void completeReject(void) {
 	match = NULL;
 }
+
+void completeRemove(size_t id, const char *str) {
+	struct Node *next = NULL;
+	for (struct Node *node = head; node; node = next) {
+		next = node->next;
+		if (id && node->id != id) continue;
+		if (strcmp(node->str, str)) continue;
+		if (match == node) match = NULL;
+		detach(node);
+		free(node->str);
+		free(node);
+	}
+}
diff --git a/handle.c b/handle.c
index fb49206..4faabba 100644
--- a/handle.c
+++ b/handle.c
@@ -154,6 +154,7 @@ static void handleErrorSASLFail(struct Message *msg) {
 static void handleReplyWelcome(struct Message *msg) {
 	require(msg, false, 1);
 	set(&self.nick, msg->params[0]);
+	completeTouch(None, self.nick, Default);
 	if (self.join) ircFormat("JOIN %s\r\n", self.join);
 }
 
@@ -197,8 +198,10 @@ static void handleJoin(struct Message *msg) {
 			self.color = hash(msg->user);
 		}
 		idColors[id] = hash(msg->params[0]);
+		completeTouch(None, msg->params[0], idColors[id]);
 		uiShowID(id);
 	}
+	completeTouch(id, msg->nick, hash(msg->user));
 	uiFormat(
 		id, Cold, tagTime(msg),
 		"\3%02d%s\3\tarrives in \3%02d%s\3",
@@ -208,8 +211,10 @@ static void handleJoin(struct Message *msg) {
 
 static void handlePart(struct Message *msg) {
 	require(msg, true, 1);
+	size_t id = idFor(msg->params[0]);
+	completeRemove(id, msg->nick);
 	uiFormat(
-		idFor(msg->params[0]), Cold, tagTime(msg),
+		id, Cold, tagTime(msg),
 		"\3%02d%s\3\tleaves \3%02d%s\3%s%s",
 		hash(msg->user), msg->nick, hash(msg->params[0]), msg->params[0],
 		(msg->params[1] ? ": " : ""),
@@ -294,6 +299,7 @@ static void handlePrivmsg(struct Message *msg) {
 	bool notice = (msg->cmd[0] == 'N');
 	bool action = isAction(msg);
 	bool mention = !mine && isMention(msg);
+	if (!notice && !mine) completeTouch(id, msg->nick, hash(msg->user));
 	if (notice) {
 		uiFormat(
 			id, Warm, tagTime(msg),
e='2019-12-23 17:51:56 -0500'>2019-12-23Reformat music.txtJune McEnroe 2019-12-23Rename music.md to music.txtJune McEnroe 2019-12-23Add DO YOU DOUBT ME TRAITORJune McEnroe 2019-12-22Add license header to cgit CSSJune McEnroe As requested. Funny that its license header capitalizes You. 2019-12-22Add The Book of EttaJune McEnroe 2019-12-21Revert "Add first working version of imbox"June McEnroe Moved to <https://git.causal.agency/imbox>. This reverts commit 6aa7f2f6bf47fa9df9c749ce665171fa30800937. 2019-12-21Add first working version of imboxJune McEnroe 2019-12-20Respect mailmap in gl pretty formatJune McEnroe 2019-12-20Set LANG in cgit filtersJune McEnroe ttpre needs to know about UTF-8 too so it can bold/italic non-ASCII chars. 2019-12-20Source .editrc before applying -v or -eJune McEnroe Otherwise a bind -v in .editrc will take precedence and overwrite the ^I binding for sh-complete. 2019-12-20Disable signing commitsJune McEnroe Why did I ever turn this on? This gets me nothing but inconvenience. RIP to all the wasted bytes in my git repos. 2019-12-19Ignore about-filterJune McEnroe 2019-12-19Fix matching make tags with no sourcesJune McEnroe 2019-12-19Avoid matching := assignments as tagsJune McEnroe 2019-12-18Hide line numbers when rendering mdocJune McEnroe Hack: output an extra <td> after rendering mdoc so that line numbers can be hidden based on there being three. This required splitting source-filter and about-filter since on about pages there is no table. 2019-12-18Customize cgit CSSJune McEnroe 2019-12-18Use :target rather than :focus pseudo-classJune McEnroe :target persists after you click on something else. 2019-12-18Copy cgit auxiliary binaries properlyJune McEnroe 2019-12-18Add git.causal.agency cgit configJune McEnroe 2019-12-18Bail from hi if input is binaryJune McEnroe NULs in the input cause an infinite loop in htmlEscape, not to mention regexes obviously not working, etc. 2019-12-16Post "cgit setup"June McEnroe