Check for addnwstr if --enable-wide and don't build curses frontend
[nvi.git] / ip / ip_screen.c
blob57e8580e7900de0fe5f3de15ed7b49f2a17d148e
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.7 2000/07/11 19:07:19 skimo Exp $ (Berkeley) $Date: 2000/07/11 19:07:19 $";
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(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);