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#include <string.h>
2N/A#include <sys/types.h>
2N/A#include "curses_inc.h"
2N/A
2N/A/* Like refresh but does not output */
2N/A
2N/Aint
2N/Awnoutrefresh(WINDOW *win)
2N/A{
2N/A short *bch, *ech, *sbch, *sech;
2N/A chtype **wcp, **scp, *wc, *sc;
2N/A int *hash;
2N/A short y, x, xorg, yorg, scrli, scrco,
2N/A boty, sminy, smaxy, minx, maxx, lo, hi;
2N/A bool doall;
2N/A
2N/A if (win->_parent)
2N/A wsyncdown(win);
2N/A
2N/A doall = win->_clear;
2N/A
2N/A sminy = SP->Yabove;
2N/A smaxy = sminy + LINES;
2N/A scrli = curscr->_maxy;
2N/A scrco = curscr->_maxx;
2N/A
2N/A yorg = win->_begy + win->_yoffset;
2N/A xorg = win->_begx;
2N/A
2N/A /* save flags, cursor positions */
2N/A SP->virt_scr->_leave = win->_leave;
2N/A if ((!win->_leave && (win->_flags & (_WINCHANGED | _WINMOVED))) &&
2N/A ((y = win->_cury + yorg) >= 0) && (y < scrli) &&
2N/A ((x = win->_curx + xorg) >= 0) && (x < scrco)) {
2N/A _virtscr->_cury = y;
2N/A _virtscr->_curx = x;
2N/A }
2N/A if (!(win->_use_idc))
2N/A _virtscr->_use_idc = FALSE;
2N/A if (win->_use_idl)
2N/A _virtscr->_use_idl = TRUE;
2N/A if (win->_clear) {
2N/A _virtscr->_clear = TRUE;
2N/A win->_clear = FALSE;
2N/A win->_flags |= _WINCHANGED;
2N/A }
2N/A
2N/A if (!(win->_flags & _WINCHANGED))
2N/A goto done;
2N/A
2N/A /* region to update */
2N/A boty = win->_maxy+yorg;
2N/A if (yorg >= sminy && yorg < smaxy && boty >= smaxy)
2N/A boty = smaxy;
2N/A else
2N/A if (boty > scrli)
2N/A boty = scrli;
2N/A boty -= yorg;
2N/A
2N/A minx = 0;
2N/A if ((maxx = win->_maxx+xorg) > scrco)
2N/A maxx = scrco;
2N/A maxx -= xorg + 1;
2N/A
2N/A /* update structure */
2N/A bch = win->_firstch;
2N/A ech = win->_lastch;
2N/A wcp = win->_y;
2N/A
2N/A hash = _VIRTHASH + yorg;
2N/A sbch = _virtscr->_firstch + yorg;
2N/A sech = _virtscr->_lastch + yorg;
2N/A scp = _virtscr->_y + yorg;
2N/A
2N/A /* first time around, set proper top/bottom changed lines */
2N/A if (curscr->_sync) {
2N/A _VIRTTOP = scrli;
2N/A _VIRTBOT = -1;
2N/A }
2N/A
2N/A /* update each line */
2N/A for (y = 0; y < boty; ++y, ++hash, ++bch, ++ech, ++sbch,
2N/A ++sech, ++wcp, ++scp) {
2N/A if (!doall && *bch == _INFINITY)
2N/A continue;
2N/A
2N/A lo = (doall || *bch == _REDRAW || *bch < minx) ? minx : *bch;
2N/A hi = (doall || *bch == _REDRAW || *ech > maxx) ? maxx : *ech;
2N/A
2N/A wc = *wcp;
2N/A sc = *scp;
2N/A /* adjust lo and hi so they contain whole characters */
2N/A if (_scrmax > 1) {
2N/A if (ISCBIT(wc[lo])) {
2N/A for (x = lo - 1; x >= minx; --x)
2N/A if (!ISCBIT(wc[x]))
2N/A break;
2N/A if (x < minx) {
2N/A for (x = lo+1; x <= maxx; ++x)
2N/A if (!ISCBIT(wc[x]))
2N/A break;
2N/A if (x > maxx)
2N/A goto nextline;
2N/A }
2N/A lo = x;
2N/A }
2N/A if (ISMBIT(wc[hi])) {
2N/A int w;
2N/A unsigned char rb;
2N/A for (x = hi; x >= lo; --x)
2N/A if (!ISCBIT(wc[x]))
2N/A break;
2N/A /* LINTED */
2N/A rb = (unsigned char) RBYTE(wc[x]);
2N/A w = _curs_scrwidth[TYPE(rb)];
2N/A hi = (x+w) <= maxx+1 ? x+w-1 : x;
2N/A }
2N/A }
2N/A
2N/A if (hi < lo)
2N/A continue;
2N/A
2N/A /* clear partial multi-chars about to be overwritten */
2N/A if (_scrmax > 1) {
2N/A if (ISMBIT(sc[lo + xorg]))
2N/A (void) _mbclrch(_virtscr, y + yorg, lo + xorg);
2N/A if (ISMBIT(sc[hi + xorg]))
2N/A (void) _mbclrch(_virtscr, y + yorg, hi + xorg);
2N/A }
2N/A
2N/A /* update the change structure */
2N/A if (*bch == _REDRAW || *sbch == _REDRAW)
2N/A *sbch = _REDRAW;
2N/A else {
2N/A if (*sbch > lo+xorg)
2N/A *sbch = lo+xorg;
2N/A if (*sech < hi+xorg)
2N/A *sech = hi+xorg;
2N/A }
2N/A if ((y + yorg) < _VIRTTOP)
2N/A _VIRTTOP = y+yorg;
2N/A if ((y + yorg) > _VIRTBOT)
2N/A _VIRTBOT = y + yorg;
2N/A
2N/A /* update the image */
2N/A wc = *wcp + lo;
2N/A sc = *scp + lo + xorg;
2N/A (void) memcpy((char *) sc, (char *) wc, (size_t)
2N/A (((hi - lo) + 1) * sizeof (chtype)));
2N/A
2N/A /* the hash value of the line */
2N/A *hash = _NOHASH;
2N/A
2N/Anextline:
2N/A *bch = _INFINITY;
2N/A *ech = -1;
2N/A }
2N/A
2N/Adone:
2N/A _virtscr->_flags |= _WINCHANGED;
2N/A win->_flags &= ~(_WINCHANGED | _WINMOVED | _WINSDEL);
2N/A return (OK);
2N/A}