Commit e820321b authored by Justin Mitchell's avatar Justin Mitchell
Browse files

Add colour 15 to all incoming IPC_EVENT messages,

as they should all count as being "user action" messages
fixes #11
parent 7ac3dae8
Loading
Loading
Loading
Loading
+19 −5
Original line number Diff line number Diff line
@@ -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];