예제 #1
0
파일: output.c 프로젝트: BitchX/BitchX1.2
/*
 * refresh_screen: Whenever the REFRESH_SCREEN function is activated, this
 * swoops into effect 
 */
void refresh_screen (unsigned char dumb, char *dumber)
{
extern int need_redraw;

#if !defined(WINNT) && !defined(__EMX__)
	term_clear_screen();
	unflash();
#else
	xterm_settitle();
	term_clear_screen();
#endif

#if 0
	for (tmp = screen_list; tmp; tmp = tmp->next)
		tmp->co = TI_cols, tmp->li = TI_lines;
#endif
	if (term_resize())
		recalculate_windows(current_window->screen);
	else
		redraw_all_windows();
	if (need_redraw)
		need_redraw = 0;
	update_all_windows();
	update_input(UPDATE_ALL);
}
예제 #2
0
파일: output.c 프로젝트: Cloudxtreme/epic5
void	redraw_all_screens (void)
{
	Screen *s, *old_os;

	old_os = output_screen;
	for (s = screen_list; s; s = s->next)
	{
		if (!s->alive)
			continue;

		output_screen = s;
		unflash();
		term_clear_screen();
		if (s == main_screen && term_resize())
			recalculate_windows(current_window->screen);
	}

	/* Logically mark all windows as needing a redraw */
	redraw_all_windows();

	/* Physically redraw all windows and status bars */
	update_all_windows();

	/* Physically redraw all input lines */
	update_input(NULL, UPDATE_ALL);

	output_screen = old_os;
	need_redraw = 0;
}
예제 #3
0
파일: output.c 프로젝트: choppsv1/ircii
/*
 * refresh_screen: Whenever the REFRESH_SCREEN function is activated, this
 * swoops into effect 
 */
void
refresh_screen(u_int key, u_char *ptr)
{
	term_clear_screen();
	if (term_resize())
#if 1
		balance_windows();
#else
		recalculate_windows();
#endif
	else
예제 #4
0
파일: output.c 프로젝트: BitchX/BitchX1.2
/* init_windows:  */
int init_screen (void)
{
extern int term_initialized;
	term_initialized = 1;
	term_clear_screen();
	term_resize();
	create_new_screen();
	new_window(main_screen);
	update_all_windows();
	term_move_cursor(0, 0);
	return 0;
}
예제 #5
0
void	refresh_a_screen (Screen *screen)
{
	unflash();
	term_clear_screen();

	if (screen != main_screen || term_resize())
		recalculate_windows(screen);
	else
		redraw_all_windows();

	if (need_redraw)
		need_redraw = 0;

	update_all_windows();
	update_input(UPDATE_ALL);
}
예제 #6
0
파일: output.c 프로젝트: Cloudxtreme/epic5
/*
 * init_screen() sets up a full screen display for normal display mode.
 * It will fail if your TERM setting doesn't have all of the necessary
 * capabilities to run in full screen mode.  The client is expected to 
 * fail-over to dumb mode in this case.
 * This may only be called once, at initial startup (by main()).
 */
int	init_screen (void)
{
	/* Investigate TERM and put the console in full-screen mode */
	if (term_init())
		return -1;

	term_clear_screen();
	term_resize();

	/*
	 * System independant stuff
	 */
	create_new_screen();
	new_window(main_screen);
	update_all_windows();

	term_move_cursor(0, 0);
	return 0;
}
예제 #7
0
/* init_windows:  */
int	init_screen (void)
{
	/*
	 * System dependant stuff
	 */
	if (term_init())
		return -1;

	term_clear_screen();
	term_resize();

	/*
	 * System independant stuff
	 */
	create_new_screen();
	new_window(main_screen);
	update_all_windows();

	term_move_cursor(0, 0);
	return 0;
}
예제 #8
0
void
reattach_tty(char *tty, char *password)
{
	int s = -1;
	char *name;
	struct sockaddr_in addr;
	struct hostent *hp;
	int len = 0;
	fd_set rd_fd;
	struct timeval tm = {0};
	char chr_c[] = "\003";

/*
 * this buffer has to be big enough to handle a full screen of
 * information from the detached process.
 */
	unsigned char buffer[6 * BIG_BUFFER_SIZE + 1];
	char *p;
	int port = 0;

#if defined (TIOCGWINSZ)
	struct winsize window;

#endif
	memset(&parm, 0, sizeof(struct param));

	if (!(name = find_detach_socket(socket_path, tty))) {
		fprintf(stderr, "No detached process to attach to.\r\n");
		_exit(1);
	}
	strcpy(parm.cookie, get_cookie(name));
	if (!*parm.cookie)
		_exit(1);
	if ((p = strrchr(name, '/')))
		p++;
	sscanf(p, "%d.%*s.%*s", &port);
	displays = 1;
	if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
		displays = 0;
		_exit(1);
	}
	chmod(name, SOCKMODE);
	set_socket_options(s);
	memset(&addr, 0, sizeof(struct sockaddr_in));
	addr.sin_port = htons(port);
	addr.sin_family = AF_INET;
	if ((hp = gethostbyname("localhost")))
		memcpy(&addr.sin_addr, hp->h_addr, hp->h_length);
	else
		inet_aton("127.0.0.1", (struct in_addr *)&addr.sin_addr);
	if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
		fprintf(stderr, "connection refused for %s\r\n", name);
		_exit(1);
	}
	parm.pid = getpid();
	parm.pgrp = getpgrp();
	parm.uid = getuid();
	strcpy(parm.tty, ttyname(0));
	strncpy(parm.termid, getenv("TERM"), 80);
	if (password)
		strncpy(parm.password, password, 60);
	fprintf(stderr, "attempting to wakeup %s\r\n", find_tty_name(name));
#if defined (TIOCGWINSZ)
	if (ioctl(0, TIOCGWINSZ, &window) > -1) {
		parm.cols = window.ws_col;
		parm.rows = window.ws_row;
	} else
#endif
	{
		parm.cols = 79;
		parm.rows = 25;
	}
	write(s, &parm, sizeof(struct param));
	sleep(2);
	alarm(15);
	len = read(s, &parm, sizeof(struct param));
	alarm(0);
	if (len <= 0) {
		fprintf(stderr, "error reconnecting to %s\r\n", find_tty_name(name));
		displays = 0;
		chmod(name, SOCKMODE);
		exit(1);
	}
	unlink(name);

	term_init(parm.termid);
	set_term_eight_bit(1);
	charset_ibmpc();
	term_clear_screen();
	term_resize();
	term_move_cursor(0, 0);

	my_signal(SIGPIPE, handle_pipe, 0);
	my_signal(SIGINT, handle_ctrlc, 0);
	my_signal(SIGHUP, handle_hup, 0);

	/*
	 * according to MHacker we need to set errno to 0 under BSD.
	 * for some reason we get a address in use from a socket
	 *
	 */
	errno = 0;
	while (1) {
		FD_ZERO(&rd_fd);
		FD_SET(0, &rd_fd);
		FD_SET(s, &rd_fd);
		tm.tv_sec = 2;

		switch (select(s + 1, &rd_fd, NULL, NULL, &tm)) {
		case -1:
			if (ctrl_c) {
				write(s, chr_c, 1);
				ctrl_c = 0;
			} else if (errno != EINTR) {
				close(s);
				_exit(1);
			}
			break;
		case 0:
			break;
		default:
		{
			if (FD_ISSET(0, &rd_fd)) {
				len = read(0, buffer, sizeof(buffer) - 1);
				write(s, buffer, len);
			}
			if (FD_ISSET(s, &rd_fd)) {
				len = read(s, buffer, sizeof(buffer) - 1);
				write(1, buffer, len);
			}
		}
		}
	}
	close(s);
	fprintf(stderr, "Never should have got here");
	_exit(1);

	return;                         /* error return */
}