6811333 Remove prom_printf() message in emlxs driver
[opensolaris.git] / usr / src / lib / libcurses / screen / prefresh.c
blobcac4cb9dfb8ace820022f1e123cc07205e50d807
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
33 * All Rights Reserved
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
37 * contributors.
40 #pragma ident "%Z%%M% %I% %E% SMI"
42 /*LINTLIBRARY*/
44 #include <sys/types.h>
45 #include <stdlib.h>
46 #include "curses_inc.h"
49 * Pad refresh. These routines are provided for upward compatibility
50 * with the 'pad' structure of Sys V.2. Since windows now can be of
51 * arbitrary size and derived windows can be moved within their
52 * parent windows effortlessly, a separate notion of 'pad' as
53 * a larger-than-screen window is no longer necessary.
55 * pminy, pminx: the area (pminy, pminx, maxy, maxx) of pad is refreshed
56 * sminy, sminx, smaxy, smaxx: the screen area to be affected.
59 int
60 prefresh(WINDOW *pad, int pminy, int pminx, int sminy,
61 int sminx, int smaxy, int smaxx)
63 return (_prefresh(wrefresh, pad, pminy, pminx, sminy,
64 sminx, smaxy, smaxx));
67 int
68 _prefresh(int (*func)(WINDOW *), WINDOW *pad, int pminy, int pminx,
69 int sminy, int sminx, int smaxy, int smaxx)
73 * If pad->_padwin doesn't exist(meaning that this is
74 * the first call to p*refresh) create it as a derived window
77 if (!pad->_padwin) {
78 if ((pad->_padwin = derwin(pad, pad->_maxy, pad->_maxx,
79 0, 0)) == NULL) {
80 goto bad;
82 /* else pad->_padwin->_use_idl = TRUE; */
85 * The following makes parent window to run in fast mode
86 * by creating an illusion that it has no derived windows
89 pad->_ndescs--;
92 if (_padjust(pad, pminy, pminx, sminy, sminx, smaxy, smaxx) == ERR)
93 bad:
94 return (ERR);
96 (*func)(pad->_padwin);
97 return (OK);
101 _padjust(WINDOW *pad, int pminy, int pminx, int sminy,
102 int sminx, int smaxy, int smaxx)
104 short prows, pcols, y;
105 WINDOW *padwin = pad->_padwin;
106 chtype **p_y, **o_y;
108 /* make sure the area requested to be updated is on the pad */
110 if ((pminy >= pad->_maxy) || (pminx >= pad->_maxx))
111 return (ERR);
113 /* determine the area of the pad to be updated */
115 if (pminy < 0)
116 pminy = 0;
117 if (pminx < 0)
118 pminx = 0;
120 /* determine the screen area affected */
122 if (sminy < 0)
123 sminy = 0;
124 if (sminx < 0)
125 sminx = 0;
126 if (smaxy < sminy)
127 smaxy = LINES - 1;
128 if (smaxx < sminx)
129 smaxx = COLS - 1;
132 * Modify the area of the pad to be updated taking into
133 * consideration screen parameters.
136 if ((prows = (smaxy - sminy) + 1) > (y = pad->_maxy - pminy))
137 prows = y;
138 if ((pcols = (smaxx - sminx) + 1) > (y = pad->_maxx - pminx))
139 pcols = y;
141 if (((padwin->_cury = pad->_cury - pminy) < 0) ||
142 (padwin->_cury >= prows))
143 padwin->_cury = 0;
144 if (((padwin->_curx = pad->_curx - pminx) < 0) ||
145 (padwin->_curx >= pcols))
146 padwin->_curx = 0;
148 padwin->_leave = pad->_leave;
149 padwin->_use_idl = pad->_use_idl;
153 * If padwin refers to the same derwin, return. Otherwise
154 * update the coordinates and malloc'ed areas of the padwin
157 if ((padwin->_begy == sminy) && (padwin->_begx == sminx) &&
158 (padwin->_maxy == prows) && (padwin->_maxx == pcols) &&
159 (padwin->_y[0] == (pad->_y[pminy] + pminx)) &&
160 (!(pad->_flags & _WINSDEL))) {
161 goto good;
164 /* update the coordinates of the pad */
166 padwin->_maxy = prows;
167 padwin->_maxx = pcols;
168 /* LINTED */
169 padwin->_begy = (short)sminy;
170 /* LINTED */
171 padwin->_begx = (short)sminx;
172 /* LINTED */
173 padwin->_pary = (short)pminy;
174 /* LINTED */
175 padwin->_parx = (short)pminx;
177 /* update the malloc'ed areas */
179 p_y = padwin->_y;
180 o_y = pad->_y;
182 for (y = 0; y < prows; y++, pminy++)
183 p_y[y] = o_y[pminy] + pminx;
185 (void) wtouchln(padwin, 0, prows, TRUE);
186 good:
187 return (OK);