date and time created 85/05/01 18:17:37 by bloom
[unix-history] / usr / src / lib / libcurses / overwrite.c
... / ...
CommitLineData
1# include "curses.ext"
2# include <ctype.h>
3
4# define min(a,b) (a < b ? a : b)
5# define max(a,b) (a > b ? a : b)
6
7/*
8 * This routine writes win1 on win2 destructively.
9 *
10 * @(#)overwrite.c 1.4 (Berkeley) %G%
11 */
12overwrite(win1, win2)
13reg WINDOW *win1, *win2; {
14
15 reg char *sp, *end;
16 reg int x, y, endy, endx, starty, startx;
17
18# ifdef DEBUG
19 fprintf(outf, "OVERWRITE(%0.2o, %0.2o);\n", win1, win2);
20# endif
21 starty = max(win1->_begy, win2->_begy);
22 startx = max(win1->_begx, win2->_begx);
23 endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begx);
24 endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx);
25 if (starty >= endy || startx >= endx)
26 return;
27# ifdef DEBUG
28 fprintf(outf, "OVERWRITE:from (%d,%d) to (%d,%d)\n", starty, startx, endy, endx);
29# endif
30 x = endx - startx;
31 for (y = starty; y < endy; y++) {
32 bcopy(&win1->_y[y - win1->_begy][startx - win1->_begx],
33 &win2->_y[y - win2->_begy][startx - win2->_begx], x);
34 touchline(win2, y, startx - win2->_begx, endx - win2->_begx);
35 }
36}