2 * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
6 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
10 * Copyright (c) 1980 Regents of the University of California.
11 * All rights reserved. The Berkeley software License Agreement
12 * specifies the terms and conditions for redistribution.
15 #pragma ident "%Z%%M% %I% %E% SMI"
21 sccsid
[] = "@(#)overlay.c 1.9 89/07/13 SMI"; /* from UCB 5.2 86/02/12 */
27 #define min(a, b) ((a) < (b) ? (a) : (b))
28 #define max(a, b) ((a) > (b) ? (a) : (b))
31 * This routine writes win1 on win2 non-destructively.
35 overlay(WINDOW
*win1
, WINDOW
*win2
)
38 int x
, y
, endy
, endx
, starty
, startx
;
42 fprintf(outf
, "OVERLAY(%0.2o, %0.2o);\n", win1
, win2
);
44 starty
= max(win1
->_begy
, win2
->_begy
);
45 startx
= max(win1
->_begx
, win2
->_begx
);
46 endy
= min(win1
->_maxy
+ win1
->_begy
, win2
->_maxy
+ win2
->_begy
);
47 endx
= min(win1
->_maxx
+ win1
->_begx
, win2
->_maxx
+ win2
->_begx
);
49 fprintf(outf
, "OVERLAY:from (%d,%d) to (%d,%d)\n",
50 starty
, startx
, endy
, endx
);
52 if (starty
>= endy
|| startx
>= endx
)
54 y1
= starty
- win1
->_begy
;
55 y2
= starty
- win2
->_begy
;
56 for (y
= starty
; y
< endy
; y
++, y1
++, y2
++) {
57 end
= &win1
->_y
[y1
][endx
- win1
->_begx
];
58 x
= startx
- win2
->_begx
;
59 for (sp
= &win1
->_y
[y1
][startx
- win1
->_begx
]; sp
< end
; sp
++) {
61 (void) mvwaddch(win2
, y2
, x
, *sp
);