6811333 Remove prom_printf() message in emlxs driver
[opensolaris.git] / usr / src / lib / libcurses / screen / endwin.c
blob391c0e115c512626c0d4e4a558f434d1297dc47c
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
33 * All Rights Reserved
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
37 * contributors.
40 #pragma ident "%Z%%M% %I% %E% SMI"
42 /*LINTLIBRARY*/
44 /* Clean things up before exiting. */
46 #include <stdlib.h>
47 #include <sys/types.h>
48 #include "curses_inc.h"
50 #ifdef _VR2_COMPAT_CODE
51 char _endwin = 0;
52 #endif /* _VR2_COMPAT_CODE */
54 int
55 isendwin(void)
58 * The test below must stay at TRUE because the value of 2
59 * has special meaning to wrefresh but does not mean that
60 * endwin has been called.
62 if (SP && (SP->fl_endwin == TRUE))
63 return (TRUE);
64 else
65 return (FALSE);
68 int
69 endwin(void)
71 /* make sure we're in program mode */
72 if (SP->fl_endwin) {
73 /* If endwin is equal to 2 it means we just did a newscreen. */
74 if (SP->fl_endwin == TRUE) {
75 (void) reset_prog_mode();
76 if (SP->kp_state)
77 (void) tputs(keypad_xmit, 1, _outch);
78 if (SP->fl_meta)
79 (void) tputs(meta_on, 1, _outch);
80 if (cur_term->_cursorstate != 1)
81 _PUTS(cur_term->cursor_seq
82 [cur_term->_cursorstate], 0);
84 _PUTS(enter_ca_mode, 1);
85 (void) tputs(ena_acs, 1, _outch);
86 if (exit_attribute_mode)
87 _PUTS(tparm_p0(exit_attribute_mode), 1);
88 else
90 * If there is no exit_attribute mode, then vidupdate
91 * could only possibly turn off one of the below three
92 * so that's all we ask it turn off.
94 vidupdate(A_NORMAL,
95 (A_ALTCHARSET | A_STANDOUT | A_UNDERLINE), _outch);
97 SP->fl_endwin = FALSE;
99 #ifdef _VR2_COMPAT_CODE
100 _endwin = (char) FALSE;
101 #endif /* _VR2_COMPAT_CODE */
104 /* See comment above why this test is explicitly against TRUE. */
105 if (SP->fl_endwin == TRUE)
106 return (ERR);
108 /* Flush out any output not output due to typeahead. */
109 if (_INPUTPENDING)
110 (void) force_doupdate();
112 /* Close things down. */
113 (void) ttimeout(-1);
114 if (SP->fl_meta)
115 (void) tputs(meta_off, 1, _outch);
116 (void) mvcur(curscr->_cury, curscr->_curx, curscr->_maxy - 1, 0);
118 if (SP->kp_state)
119 (void) tputs(keypad_local, 1, _outch);
120 if (cur_term->_cursorstate != 1)
121 (void) tputs(cursor_normal, 0, _outch);
123 /* don't bother turning off colors: it will be done later anyway */
124 curscr->_attrs &= ~A_COLOR; /* SS: colors */
126 if ((curscr->_attrs != A_NORMAL) &&
127 (magic_cookie_glitch < 0) && (!ceol_standout_glitch))
128 _VIDS(A_NORMAL, curscr->_attrs);
130 if (SP->phys_irm)
131 _OFFINSERT();
133 SP->fl_endwin = TRUE;
135 #ifdef _VR2_COMPAT_CODE
136 _endwin = TRUE;
137 #endif /* _VR2_COMPAT_CODE */
139 curscr->_clear = TRUE;
140 (void) reset_shell_mode();
141 (void) tputs(exit_ca_mode, 0, _outch);
143 /* restore colors and default color pair. SS: colors */
144 if (orig_colors)
145 (void) tputs(orig_colors, 1, _outch);
146 if (orig_pair)
147 (void) tputs(tparm_p0(orig_pair), 1, _outch);
149 /* SS-mouse: free the mouse. */
151 if (get_mouse)
152 (void) tputs(tparm_p1(get_mouse, 0), 1, _outch);
154 (void) fflush(SP->term_file);
156 return (OK);
160 force_doupdate(void)
162 char chars_onQ = cur_term->_chars_on_queue;
163 int ret;
166 * This will cause _chkinput to return FALSE which will force wrefresh
167 * to think there is no input waiting and it will finish its refresh.
170 cur_term->_chars_on_queue = INP_QSIZE;
171 ret = doupdate();
172 cur_term->_chars_on_queue = chars_onQ;
173 return (ret);