update from From: Sven Verdoolaege <skimo@breughel.ufsia.ac.be>
[nvi.git] / ip / ip_screen.c
blobb6d4d0f1db235b1cf716475ea4aebc1f1391b5fc
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.4 1996/12/18 10:28:03 bostic Exp $ (Berkeley) $Date: 1996/12/18 10:28:03 $";
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(sp, flags)
32 SCR *sp;
33 u_int32_t flags;
35 GS *gp;
36 IP_PRIVATE *ipp;
38 gp = sp->gp;
39 ipp = IPP(sp);
41 /* See if the current information is incorrect. */
42 if (F_ISSET(gp, G_SRESTART)) {
43 if (ip_quit(gp))
44 return (1);
45 F_CLR(gp, G_SRESTART);
48 /* See if we're already in the right mode. */
49 if (LF_ISSET(SC_VI) && F_ISSET(ipp, IP_SCR_VI_INIT))
50 return (0);
52 /* Ex isn't possible. */
53 if (LF_ISSET(SC_EX))
54 return (1);
56 /* Initialize terminal based information. */
57 if (ip_term_init(sp))
58 return (1);
60 F_SET(ipp, IP_SCR_VI_INIT);
61 return (0);
65 * ip_quit --
66 * Shutdown the screens.
68 * PUBLIC: int ip_quit __P((GS *));
70 int
71 ip_quit(gp)
72 GS *gp;
74 IP_PRIVATE *ipp;
75 int rval;
77 /* Clean up the terminal mappings. */
78 rval = ip_term_end(gp);
80 ipp = GIPP(gp);
81 F_CLR(ipp, IP_SCR_VI_INIT);
83 return (rval);