distrib: let automake add missing files
[nvi.git] / ip / ip_screen.c
blobeadccd12bb264885f140b3c850c2ced1cdf66677
1 /*-
2 * Copyright (c) 1996
3 * Keith Bostic. All rights reserved.
5 * See the LICENSE file for redistribution information.
6 */
8 #include "config.h"
10 #ifndef lint
11 static const char sccsid[] = "$Id: ip_screen.c,v 8.8 2001/06/25 15:19:24 skimo Exp $ (Berkeley) $Date: 2001/06/25 15:19:24 $";
12 #endif /* not lint */
14 #include <sys/types.h>
15 #include <sys/queue.h>
17 #include <bitstring.h>
18 #include <stdio.h>
20 #include "../common/common.h"
21 #include "../ipc/ip.h"
22 #include "extern.h"
25 * ip_screen --
26 * Initialize/shutdown the IP screen.
28 * PUBLIC: int ip_screen __P((SCR *, u_int32_t));
30 int
31 ip_screen(SCR *sp, u_int32_t flags)
33 GS *gp;
34 IP_PRIVATE *ipp;
36 gp = sp->gp;
37 ipp = IPP(sp);
39 /* See if the current information is incorrect. */
40 if (F_ISSET(gp, G_SRESTART)) {
41 if (ip_quit(sp->wp))
42 return (1);
43 F_CLR(gp, G_SRESTART);
46 /* See if we're already in the right mode. */
47 if (LF_ISSET(SC_EX) && F_ISSET(sp, SC_SCR_EX) ||
48 LF_ISSET(SC_VI) && F_ISSET(sp, SC_SCR_VI))
49 return (0);
51 /* Ex isn't possible if there is no terminal. */
52 if (LF_ISSET(SC_EX) && ipp->t_fd == -1)
53 return (1);
55 if (F_ISSET(sp, SC_SCR_EX))
56 F_CLR(sp, SC_SCR_EX);
58 if (F_ISSET(sp, SC_SCR_VI))
59 F_CLR(sp, SC_SCR_VI);
61 if (LF_ISSET(SC_EX)) {
62 F_SET(ipp, IP_IN_EX);
63 } else {
64 /* Initialize terminal based information. */
65 if (ip_term_init(sp))
66 return (1);
68 F_CLR(ipp, IP_IN_EX);
69 F_SET(ipp, IP_SCR_VI_INIT);
71 return (0);
75 * ip_quit --
76 * Shutdown the screens.
78 * PUBLIC: int ip_quit __P((WIN *));
80 int
81 ip_quit(WIN *wp)
83 IP_PRIVATE *ipp;
84 int rval;
86 /* Clean up the terminal mappings. */
87 rval = ip_term_end(wp->gp);
89 ipp = WIPP(wp);
90 F_CLR(ipp, IP_SCR_VI_INIT);
92 return (rval);