Sync usage with man page.
[netbsd-mini2440.git] / dist / nvi / ip / ip_screen.c
blobb6aa51c82858b53e1c05a0a69dcd6427d1177637
1 /* $NetBSD$ */
3 /*-
4 * Copyright (c) 1996
5 * Keith Bostic. All rights reserved.
7 * See the LICENSE file for redistribution information.
8 */
10 #include "config.h"
12 #ifndef lint
13 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";
14 #endif /* not lint */
16 #include <sys/types.h>
17 #include <sys/queue.h>
19 #include <bitstring.h>
20 #include <stdio.h>
22 #include "../common/common.h"
23 #include "../ipc/ip.h"
24 #include "extern.h"
27 * ip_screen --
28 * Initialize/shutdown the IP screen.
30 * PUBLIC: int ip_screen __P((SCR *, u_int32_t));
32 int
33 ip_screen(SCR *sp, 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(sp->wp))
44 return (1);
45 F_CLR(gp, G_SRESTART);
48 /* See if we're already in the right mode. */
49 if (LF_ISSET(SC_EX) && F_ISSET(sp, SC_SCR_EX) ||
50 LF_ISSET(SC_VI) && F_ISSET(sp, SC_SCR_VI))
51 return (0);
53 /* Ex isn't possible if there is no terminal. */
54 if (LF_ISSET(SC_EX) && ipp->t_fd == -1)
55 return (1);
57 if (F_ISSET(sp, SC_SCR_EX))
58 F_CLR(sp, SC_SCR_EX);
60 if (F_ISSET(sp, SC_SCR_VI))
61 F_CLR(sp, SC_SCR_VI);
63 if (LF_ISSET(SC_EX)) {
64 F_SET(ipp, IP_IN_EX);
65 } else {
66 /* Initialize terminal based information. */
67 if (ip_term_init(sp))
68 return (1);
70 F_CLR(ipp, IP_IN_EX);
71 F_SET(ipp, IP_SCR_VI_INIT);
73 return (0);
77 * ip_quit --
78 * Shutdown the screens.
80 * PUBLIC: int ip_quit __P((WIN *));
82 int
83 ip_quit(WIN *wp)
85 IP_PRIVATE *ipp;
86 int rval;
88 /* Clean up the terminal mappings. */
89 rval = ip_term_end(wp->gp);
91 ipp = WIPP(wp);
92 F_CLR(ipp, IP_SCR_VI_INIT);
94 return (rval);