2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License, Version 1.0 only
2N/A * (the "License"). You may not use this file except in compliance
2N/A * with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A/* Copyright (c) 1988 AT&T */
2N/A/* All Rights Reserved */
2N/A
2N/A/*
2N/A * University Copyright- Copyright (c) 1982, 1986, 1988
2N/A * The Regents of the University of California
2N/A * All Rights Reserved
2N/A *
2N/A * University Acknowledgment- Portions of this document are derived from
2N/A * software developed by the University of California, Berkeley, and its
2N/A * contributors.
2N/A */
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A/*LINTLIBRARY*/
2N/A
2N/A/* Clean things up before exiting. */
2N/A
2N/A#include <stdlib.h>
2N/A#include <sys/types.h>
2N/A#include "curses_inc.h"
2N/A
2N/A#ifdef _VR2_COMPAT_CODE
2N/Achar _endwin = 0;
2N/A#endif /* _VR2_COMPAT_CODE */
2N/A
2N/Aint
2N/Aisendwin(void)
2N/A{
2N/A /*
2N/A * The test below must stay at TRUE because the value of 2
2N/A * has special meaning to wrefresh but does not mean that
2N/A * endwin has been called.
2N/A */
2N/A if (SP && (SP->fl_endwin == TRUE))
2N/A return (TRUE);
2N/A else
2N/A return (FALSE);
2N/A}
2N/A
2N/Aint
2N/Aendwin(void)
2N/A{
2N/A /* make sure we're in program mode */
2N/A if (SP->fl_endwin) {
2N/A /* If endwin is equal to 2 it means we just did a newscreen. */
2N/A if (SP->fl_endwin == TRUE) {
2N/A (void) reset_prog_mode();
2N/A if (SP->kp_state)
2N/A (void) tputs(keypad_xmit, 1, _outch);
2N/A if (SP->fl_meta)
2N/A (void) tputs(meta_on, 1, _outch);
2N/A if (cur_term->_cursorstate != 1)
2N/A _PUTS(cur_term->cursor_seq
2N/A [cur_term->_cursorstate], 0);
2N/A }
2N/A _PUTS(enter_ca_mode, 1);
2N/A (void) tputs(ena_acs, 1, _outch);
2N/A if (exit_attribute_mode)
2N/A _PUTS(tparm_p0(exit_attribute_mode), 1);
2N/A else
2N/A /*
2N/A * If there is no exit_attribute mode, then vidupdate
2N/A * could only possibly turn off one of the below three
2N/A * so that's all we ask it turn off.
2N/A */
2N/A vidupdate(A_NORMAL,
2N/A (A_ALTCHARSET | A_STANDOUT | A_UNDERLINE), _outch);
2N/A
2N/A SP->fl_endwin = FALSE;
2N/A
2N/A#ifdef _VR2_COMPAT_CODE
2N/A _endwin = (char) FALSE;
2N/A#endif /* _VR2_COMPAT_CODE */
2N/A }
2N/A
2N/A /* See comment above why this test is explicitly against TRUE. */
2N/A if (SP->fl_endwin == TRUE)
2N/A return (ERR);
2N/A
2N/A /* Flush out any output not output due to typeahead. */
2N/A if (_INPUTPENDING)
2N/A (void) force_doupdate();
2N/A
2N/A /* Close things down. */
2N/A (void) ttimeout(-1);
2N/A if (SP->fl_meta)
2N/A (void) tputs(meta_off, 1, _outch);
2N/A (void) mvcur(curscr->_cury, curscr->_curx, curscr->_maxy - 1, 0);
2N/A
2N/A if (SP->kp_state)
2N/A (void) tputs(keypad_local, 1, _outch);
2N/A if (cur_term->_cursorstate != 1)
2N/A (void) tputs(cursor_normal, 0, _outch);
2N/A
2N/A /* don't bother turning off colors: it will be done later anyway */
2N/A curscr->_attrs &= ~A_COLOR; /* SS: colors */
2N/A
2N/A if ((curscr->_attrs != A_NORMAL) &&
2N/A (magic_cookie_glitch < 0) && (!ceol_standout_glitch))
2N/A _VIDS(A_NORMAL, curscr->_attrs);
2N/A
2N/A if (SP->phys_irm)
2N/A _OFFINSERT();
2N/A
2N/A SP->fl_endwin = TRUE;
2N/A
2N/A#ifdef _VR2_COMPAT_CODE
2N/A _endwin = TRUE;
2N/A#endif /* _VR2_COMPAT_CODE */
2N/A
2N/A curscr->_clear = TRUE;
2N/A (void) reset_shell_mode();
2N/A (void) tputs(exit_ca_mode, 0, _outch);
2N/A
2N/A /* restore colors and default color pair. SS: colors */
2N/A if (orig_colors)
2N/A (void) tputs(orig_colors, 1, _outch);
2N/A if (orig_pair)
2N/A (void) tputs(tparm_p0(orig_pair), 1, _outch);
2N/A
2N/A /* SS-mouse: free the mouse. */
2N/A
2N/A if (get_mouse)
2N/A (void) tputs(tparm_p1(get_mouse, 0), 1, _outch);
2N/A
2N/A (void) fflush(SP->term_file);
2N/A
2N/A return (OK);
2N/A}
2N/A
2N/Aint
2N/Aforce_doupdate(void)
2N/A{
2N/A char chars_onQ = cur_term->_chars_on_queue;
2N/A int ret;
2N/A
2N/A /*
2N/A * This will cause _chkinput to return FALSE which will force wrefresh
2N/A * to think there is no input waiting and it will finish its refresh.
2N/A */
2N/A
2N/A cur_term->_chars_on_queue = INP_QSIZE;
2N/A ret = doupdate();
2N/A cur_term->_chars_on_queue = chars_onQ;
2N/A return (ret);
2N/A}