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