shithub: wired

Download patch

ref: 14f9b603b69995c787579f2b66020748b0fd4e3b
parent: a61225ef49bd5e0e89e101ab3cfe0550628e500c
author: james palmer <[email protected]>
date: Fri Jun 25 10:04:18 EDT 2021

add actions again

--- a/main.c
+++ b/main.c
@@ -120,7 +120,7 @@
 }
 
 void
-sendmessage(AWin *win)
+writemessage(char *prefix, AWin *win)
 {
 	int fd;
 	char *file;
@@ -145,7 +145,7 @@
 	fprint(win->addrfd, ",");
 	while((n = read(win->datafd, buf, sizeof(buf)-1)) > 0) {
 		buf[n] = '\0'; filter(buf); /* null terminate and filter */
-		fprint(fd, "%s %s %s\n", nick, sep, buf);
+		fprint(fd, "%s %s\n", prefix, buf);
 	};
 
 
@@ -156,6 +156,36 @@
 }
 
 void
+sendmessage(AWin *win)
+{
+	char *prefix;
+
+	prefix = smprint("%s %s", nick, sep);
+	if(!prefix) {
+		awincloseall();
+		sysfatal("smprint failed");
+	}
+
+	writemessage(prefix, win);
+	free(prefix);
+}
+
+void
+sendaction(AWin *win)
+{
+	char *prefix;
+	
+	prefix = smprint("* %s", nick);
+	if(!prefix) {
+		awincloseall();
+		sysfatal("smprint failed");
+	}
+	
+	writemessage(prefix, win);
+	free(prefix);
+}
+
+void
 usage(void)
 {
 	fprint(2, "usage: %s [-s srv] [-n nick] [channel...]", argv0);
@@ -188,6 +218,8 @@
 
 	log = makewin("log", events);
 	input = makewin("input", events);
+	
+	awinsettag(input, " Send Act ");
 
 	proccreate(readproc, log, 16*1024);
 	proccreate(eventproc, log, 8*1024);
@@ -202,7 +234,7 @@
 			if(strcmp(ev.text, "Send") == 0)
 				sendmessage(input);
 			if(strcmp(ev.text, "Act") == 0)
-				sendmessage(input);
+				sendaction(input);
 
 			break;
 		case 'I':