if (F_ISSET(gp, G_STDIN_TTY) &&
if (F_ISSET(clp, CL_STDIN_TTY) &&
cl_quit(gp)	GS *gp;{	CL_PRIVATE *clp;	int rval;	rval = 0;	clp = GCLP(gp);	/*	 * If we weren't really running, ignore it.  This happens if the	 * screen changes size before we've called curses.	 */	if (!F_ISSET(clp, CL_SCR_EX_INIT | CL_SCR_VI_INIT))		return (0);	/* Clean up the terminal mappings. */	if (cl_term_end(gp))		rval = 1;	/* Really leave vi mode. */	if (F_ISSET(gp, G_STDIN_TTY) &&	    F_ISSET(clp, CL_SCR_VI_INIT) && cl_vi_end(gp))		rval = 1;	/* Really leave ex mode. */	if (F_ISSET(gp, G_STDIN_TTY) &&	    F_ISSET(clp, CL_SCR_EX_INIT) && cl_ex_end(gp))		rval = 1;	/*	 * If we were running ex when we quit, or we're using an implementation	 * of curses where endwin() doesn't get this right, restore the original	 * terminal modes.	 *	 * XXX	 * We always do this because it's too hard to figure out what curses	 * implementations get it wrong.  It may discard type-ahead characters	 * from the tty queue.	 */	(void)tcsetattr(STDIN_FILENO, TCSADRAIN | TCSASOFT, &clp->orig);	F_CLR(clp, CL_SCR_EX_INIT | CL_SCR_VI_INIT);	return (rval);}