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-1998 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/* LINTLIBRARY */
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[] =
2N/A"$Header: /team/ps/sun_xcurses/archive/local_changes/xcurses/src/lib/"
2N/A"libxcurses/src/libc/xcurses/rcs/prefresh.c 1.4 1998/06/03 16:06:14 "
2N/A"cbates Exp $";
2N/A#endif
2N/A#endif
2N/A
2N/A#include <private.h>
2N/A
2N/A/*
2N/A * Update newscr with the given pad then display to the terminal.
2N/A */
2N/Aint
2N/Aprefresh(WINDOW *w, int pminr, int pminc, int sminr, int sminc,
2N/A int smaxr, int smaxc)
2N/A{
2N/A int code;
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 (code);
2N/A}
2N/A
2N/A/*
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(WINDOW *pad, int pminr, int pminc, int sminr, int sminc,
2N/A int smaxr, int smaxc)
2N/A{
2N/A WINDOW *ns;
2N/A int row, dy, dx;
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 smaxc = ns->_maxx-1;
2N/A
2N/A if (pad->_maxy <= pminr || pad->_maxx <= pminc ||
2N/A smaxr < sminr || smaxc < sminc)
2N/A return (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
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 :
2N/A ((ns->_maxy <= dy) ? ns->_maxy - 1 : (short) dy);
2N/A ns->_curx = (dx < 0) ? 0 :
2N/A ((ns->_maxx <= dx) ? ns->_maxx - 1 : (short) dx);
2N/A
2N/A return (OK);
2N/A}