[mw-devel] [Git][arthur/mw][master] Add colour 15 to all incoming IPC_EVENT messages,

Justin Mitchell arthur at sucs.org
Wed Jan 13 16:43:01 GMT 2016


Justin Mitchell pushed to branch master at Justin Mitchell / mw


Commits:
e820321b by Justin Mitchell at 2016-01-13T16:42:01Z
Add colour 15 to all incoming IPC_EVENT messages,
as they should all count as being "user action" messages
fixes #11

- - - - -


1 changed file:

- src/client/incoming.c


Changes:

=====================================
src/client/incoming.c
=====================================
--- a/src/client/incoming.c
+++ b/src/client/incoming.c
@@ -45,6 +45,7 @@ static struct mstack *MesgStack=NULL;
 
 static void accept_pipe_cmd(ipc_message_t *msg, struct user *mesg_user);
 static void force_text(ipc_message_t *msg, const char *text, const char *from);
+static void force_vtext(ipc_message_t *msg, const char *from, const char *format, ...) __attribute__((format (printf, 3, 4)));
 static void force_ipc(char *text, char *from);
 static void force_rpc(char *text, char *from);
 static void force_checkonoff(char *text, char *from);
@@ -640,15 +641,16 @@ static void display_content(ipc_message_t *msg)
 		const char * reason = json_getstring(j, "reason");
 
 		if (verbose) force_text(msg, verbose, whom);
-		force_text(msg, text, whom);
+
+		/* user action messages have colour 15 */
+		force_vtext(msg, whom, "\033%d%s", 15, text);
+
 		if (reason) {
-			_autofree char *excuse = NULL;
 			if (strcasecmp(type, "mrod")==0 || strcasecmp(type, "zod")==0) {
-				asprintf(&excuse, "Zebedee says \"%s\".", reason);
+				force_vtext(msg, whom, "Zebedee says \"%s\".", reason);
 			} else {
-				asprintf(&excuse, "%s gives the reason \"%s\".", whom, reason);
+				force_vtext(msg, whom, "%s gives the reason \"%s\".", whom, reason);
 			}
-			force_text(msg, excuse, whom);
 		}
 	} else {
 		printf("Unknown message type %4.4s", (char *)&msg->head.type);
@@ -765,6 +767,18 @@ static void force_newmail(void)
 	new_mail_waiting++;
 }
 
+
+static void force_vtext(ipc_message_t *msg, const char *from, const char *format, ...)
+{
+	va_list va;
+	_autofree char * text = NULL;
+	va_start(va, format);
+	vasprintf(&text, format, va);
+	va_end(va);
+
+	force_text(msg, text, from);
+}
+
 static void force_text(ipc_message_t *msg, const char *text, const char *from)
 {
 	char tb[MAXTEXTLENGTH];



View it on GitLab: https://projects.sucs.org/arthur/mw/commit/e820321b99c978b3f36a7fb5168eef223a8de9ba
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sucs.org/pipermail/mw-devel/attachments/20160113/cb3a4620/attachment.html>


More information about the mw-devel mailing list