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 (c) 1995, by Sun Microsystems, Inc.
2N/A * All rights reserved.
2N/A */
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A/*
2N/A * prefresh.c
2N/A *
2N/A * XCurses Library
2N/A *
2N/A * Copyright 1990, 1995 by Mortice Kern Systems Inc. All rights reserved.
2N/A *
2N/A */
2N/A
2N/A#ifdef M_RCSID
2N/A#ifndef lint
2N/Astatic char rcsID[] = "$Header: /rd/src/libc/xcurses/rcs/prefresh.c 1.3 1995/06/20 14:34:10 ant Exp $";
2N/A#endif
2N/A#endif
2N/A
2N/A#include <private.h>
2N/A
2N/A/*f
2N/A * Update newscr with the given pad then display to the terminal.
2N/A */
2N/Aint
2N/Aprefresh(w, pminr, pminc, sminr, sminc, smaxr, smaxc)
2N/AWINDOW *w;
2N/Aint pminr, pminc, sminr, sminc, smaxr, smaxc;
2N/A{
2N/A int code;
2N/A
2N/A#ifdef M_CURSES_TRACE
2N/A __m_trace(
2N/A "prefresh(%p, %d, %d, %d, %d, %d, %d)",
2N/A w, pminr, pminc, sminr, sminc, smaxr, smaxc
2N/A );
2N/A#endif
2N/A
2N/A code = pnoutrefresh(w, pminr, pminc, sminr, sminc, smaxr, smaxc);
2N/A if (code == OK)
2N/A code = doupdate();
2N/A
2N/A return __m_return_code("prefresh", code);
2N/A}
2N/A
2N/A/*f
2N/A * Update newscr with the given pad. This allows newscr to
2N/A * be updated with several windows before doing a doupdate().
2N/A *
2N/A * MKS extension permits windows that are not pads to be refreshed
2N/A * using this function.
2N/A */
2N/Aint
2N/Apnoutrefresh(pad, pminr, pminc, sminr, sminc, smaxr, smaxc)
2N/AWINDOW *pad;
2N/Aint pminr, pminc, sminr, sminc, smaxr, smaxc;
2N/A{
2N/A WINDOW *ns;
2N/A int row, dy, dx;
2N/A
2N/A#ifdef M_CURSES_TRACE
2N/A __m_trace(
2N/A "pnoutrefresh(%p, %d, %d, %d, %d, %d, %d)",
2N/A pad, pminr, pminc, sminr, sminc, smaxr, smaxc
2N/A );
2N/A#endif
2N/A
2N/A ns = __m_screen->_newscr;
2N/A
2N/A /* Adjust regions to be within bounds. */
2N/A if (pminr < 0)
2N/A pminr = 0;
2N/A if (pminc < 0)
2N/A pminc = 0;
2N/A if (sminr < 0)
2N/A sminr = 0;
2N/A if (sminc < 0)
2N/A sminc = 0;
2N/A if (ns->_maxy <= smaxr)
2N/A smaxr = ns->_maxy-1;
2N/A if (ns->_maxx <= smaxc)
2N/A smaxr = ns->_maxx-1;
2N/A
2N/A if (pad->_maxy <= pminr || pad->_maxx <= pminc
2N/A || smaxr < sminr || smaxc < sminc)
2N/A return __m_return_code("pnoutrefresh", ERR);
2N/A
2N/A /* Clear displayed region. */
2N/A for (row = sminr; row <= smaxr; ++row)
2N/A (void) __m_cc_erase(ns, row, sminc, row, smaxc);
2N/A
2N/A /* Determine the proper maximums in case smaxr and smaxc mapped
2N/A * beyond the bottom and right-hand edges of the pad.
2N/A */
2N/A if (pad->_maxx <= pminc + smaxc-sminc+1)
2N/A smaxc = sminc + pad->_maxx - 1 - pminc;
2N/A if (pad->_maxy <= pminr + smaxr-sminr+1)
2N/A smaxr = sminr + pad->_maxy - 1 - pminr;
2N/A
2N/A /* Remember refresh region (inclusive). */
2N/A pad->_refy = (short) pminr;
2N/A pad->_refx = (short) pminc;
2N/A pad->_sminy = (short) sminr;
2N/A pad->_sminx = (short) sminc;
2N/A pad->_smaxy = (short) smaxr;
2N/A pad->_smaxx = (short) smaxc;
2N/A
2N/A (void) copywin(pad, ns, pminr, pminc, sminr, sminc, smaxr, smaxc, 0);
2N/A
2N/A /* Last refreshed window controls W_LEAVE_CURSOR flag. */
2N/A ns->_flags &= ~W_LEAVE_CURSOR;
2N/A ns->_flags |= pad->_flags
2N/A & (W_CLEAR_WINDOW | W_REDRAW_WINDOW | W_LEAVE_CURSOR);
2N/A pad->_flags &= ~(W_CLEAR_WINDOW | W_REDRAW_WINDOW);
2N/A
2N/A /* Figure out where to leave the cursor. */
2N/A dy = pad->_cury - pminr + pad->_begy;
2N/A dx = pad->_curx - pminc + pad->_begx;
2N/A
2N/A ns->_cury = dy < 0 ? 0 : ns->_maxy <= dy ? ns->_maxy-1 : dy;
2N/A ns->_curx = dx < 0 ? 0 : ns->_maxx <= dx ? ns->_maxx-1 : dx;
2N/A
2N/A return __m_return_code("pnoutrefresh", OK);
2N/A}