Пример #1
0
void				tcont(void)
{
	tsignal();
	treset(g_old_term, 1);
	tresize(0, 0);
	free(g_old_term);
	g_old_term = NULL;
}
Пример #2
0
void
cresize(int width, int height)
{
	int col, row;

	if (width != 0)
		win.w = width;
	if (height != 0)
		win.h = height;

	col = (win.w - 2 * borderpx) / win.cw;
	row = (win.h - 2 * borderpx) / win.ch;

	tresize(col, row);
	xresize(col, row);
	ttyresize(win.tw, win.th);
}
Пример #3
0
int					tselected_all(t_dlist *list)
{
	t_dcell			*tmp;
	int				all;

	if (list->all == 0)
		all = 1;
	else
		all = 0;
	tmp = list->head;
	while (tmp->next != list->head)
	{
		tmp->dswitch = all;
		tmp = tmp->next;
	}
	tmp->dswitch = all;
	list->all = all;
	tresize(0, 0);
	return (1);
}
Пример #4
0
int
main(int argc, char *argv[])
{
	const char *user = getenv("USER");
	const char *ircnick = getenv("IRCNICK");
	const char *server = SRV;
	unsigned short port = PORT;
	int o;

	while ((o=getopt(argc, argv, "hn:u:s:p:"))>=0)
		switch (o) {
		case 'h':
		case '?':
		usage:
			fputs("Usage: irc [-n NICK] [-u USER] [-s SERVER] [-p PORT] [-h]\n", stderr);
			exit(0);
		case 'n':
			if (strlen(optarg)>=sizeof nick) goto usage;
			strcpy(nick, optarg);
			break;
		case 'u':
			user = optarg;
			break;
		case 's':
			server = optarg;
			break;
		case 'p':
			if (!(port=strtol(optarg, 0, 0))) goto usage;
			break;
		}
	if (!nick[0] && ircnick && strlen(ircnick)<sizeof nick)
		strcpy(nick, ircnick);
	if (!nick[0]) goto usage;
	if (!user) user = "******";
	tinit();
	sfd = dial(server, port);
	chadd("*server*");
	sndf("NICK %s", nick);
	sndf("USER %s 8 * :%s", user, user);
	sndf("MODE %s +i", nick);
	while (!quit) {
		fd_set rfs, wfs;
		int ret;

		if (winchg)
			tresize();
		FD_ZERO(&wfs);
		FD_ZERO(&rfs);
		FD_SET(0, &rfs);
		FD_SET(sfd, &rfs);
		if (outp!=outb)
			FD_SET(sfd, &wfs);
		ret=select(sfd+1, &rfs, &wfs, 0, 0);
		if (ret<0) {
			if (errno==EINTR) continue;
			panic("Select failed.");
		}
		if (FD_ISSET(sfd, &rfs)) {
			if (!srd())
				quit=1;
		}
		if (FD_ISSET(sfd, &wfs)) {
			int wr;

			wr=write(sfd, outb, outp-outb);
			if (wr<0) {
				if (errno==EINTR) continue;
				panic("Write error.");
			}
			if (wr==0) continue;
			outp-=wr;
			memmove(outb, outb+wr, outp-outb);
		}
		if (FD_ISSET(0, &rfs)) {
			tgetch();
			wrefresh(scr.iw);
		}
	}
	close(sfd);
	while (nch--)
		free(chl[nch].buf);
	treset();
	exit(0);
}