~foura/wired

14f9b603b69995c787579f2b66020748b0fd4e3b — james palmer 1 year, 1 month ago a61225e
add actions again
1 files changed, 35 insertions(+), 3 deletions(-)

M main.c
M main.c => main.c +35 -3
@@ 120,7 120,7 @@ filter(char *s)
}

void
sendmessage(AWin *win)
writemessage(char *prefix, AWin *win)
{
	int fd;
	char *file;


@@ 145,7 145,7 @@ sendmessage(AWin *win)
	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 @@ sendmessage(AWin *win)
}

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 @@ threadmain(int argc, char *argv[])

	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 @@ threadmain(int argc, char *argv[])
			if(strcmp(ev.text, "Send") == 0)
				sendmessage(input);
			if(strcmp(ev.text, "Act") == 0)
				sendmessage(input);
				sendaction(input);

			break;
		case 'I':