Пример #1
0
static void *
run_editor(void * vp)
{
	GS *gp;
	IP_PRIVATE *ipp;
	WIN *wp;
	EVENT ev;
	int rval;
	IP_BUF ipb;

	wp = (WIN *) vp;
	gp = wp->gp;
	ipp = wp->ip_private;

	/* Add the terminal type to the global structure. */
	if ((OG_D_STR(gp, GO_TERM) =
	    OG_STR(gp, GO_TERM) = strdup("ip_curses")) == NULL)
		perr(gp->progname, NULL);

	/*
	 * Figure out how big the screen is -- read events until we get
	 * the rows and columns.
	 */
	for (;;) {
		if (ip_wevent(wp, NULL, &ev, 0, 0))
			return;
		if (ev.e_event == E_WRESIZE)
			break;
		if (ev.e_event == E_EOF || ev.e_event == E_ERR ||
		    ev.e_event == E_SIGHUP || ev.e_event == E_SIGTERM)
			return;
		if (ev.e_event == E_IPCOMMAND && ev.e_ipcom == VI_QUIT)
			return;
	}

	/* Run ex/vi. */
	rval = editor(wp, ipp->argc, ipp->argv);

	/* Clean up the screen. */
	(void)ip_quit(wp);

	/* Send the quit message. */
	ipb.code = SI_QUIT;
	(void)vi_send(ipp->o_fd, NULL, &ipb);

	/* Give the screen a couple of seconds to deal with it. */
	sleep(2);

	/* Remove window; correct place ? */
	win_end(wp);

#if defined(DEBUG) || defined(PURIFY) || defined(LIBRARY)
	free(ipp);
#endif
	return NULL;
}
Пример #2
0
/*
 * ip_event --
 *	Return a single event.
 *
 * PUBLIC: int ip_event __P((SCR *, EVENT *, u_int32_t, int));
 */
int
ip_event(SCR *sp, EVENT *evp, u_int32_t flags, int ms)
{
	return ip_wevent(sp->wp, sp, evp, flags, ms);
}