Initial revision
[nvi.git] / ip / ip_screen.c
blob51473028c8b9366512320f3adfd929cc63a80d95
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.3 1996/12/10 21:02:27 bostic Exp $ (Berkeley) $Date: 1996/12/10 21:02:27 $";
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 "ip.h"
24 * ip_screen --
25 * Initialize/shutdown the IP screen.
27 * PUBLIC: int ip_screen __P((SCR *, u_int32_t));
29 int
30 ip_screen(sp, flags)
31 SCR *sp;
32 u_int32_t flags;
34 GS *gp;
35 IP_PRIVATE *ipp;
37 gp = sp->gp;
38 ipp = IPP(sp);
40 /* See if the current information is incorrect. */
41 if (F_ISSET(gp, G_SRESTART)) {
42 if (ip_quit(gp))
43 return (1);
44 F_CLR(gp, G_SRESTART);
47 /* See if we're already in the right mode. */
48 if (LF_ISSET(SC_VI) && F_ISSET(ipp, IP_SCR_VI_INIT))
49 return (0);
51 /* Ex isn't possible. */
52 if (LF_ISSET(SC_EX))
53 return (1);
55 /* Initialize terminal based information. */
56 if (ip_term_init(sp))
57 return (1);
59 F_SET(ipp, IP_SCR_VI_INIT);
60 return (0);
64 * ip_quit --
65 * Shutdown the screens.
67 * PUBLIC: int ip_quit __P((GS *));
69 int
70 ip_quit(gp)
71 GS *gp;
73 IP_PRIVATE *ipp;
74 int rval;
76 /* Clean up the terminal mappings. */
77 rval = ip_term_end(gp);
79 ipp = GIPP(gp);
80 F_CLR(ipp, IP_SCR_VI_INIT);
82 return (rval);