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