-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopywin.c
51 lines (43 loc) · 1.62 KB
/
copywin.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "curses.h"
#include "window.h"
/*AT&T
AT&T This routine provides finer control over the overlay() and
AT&T overwrite() routines. As in the prefresh() routine, a rectangle
AT&T is spedified in the destination window, (dminrow, dmincol) and
AT&T (dmaxrow, dmaxcol), and the upper-left-corner coordinates of the
AT&T source window (sminrow, smincol). If the arguments overlay is
AT&T TRUE, then copying is non-destructive, as in overlay().
AT&T */
int
copywin(WINDOW *srcwin, WINDOW *dstwin, int sminrow, int smincol,
int dminrow, int dmincol, int dmaxrow, int dmaxcol, int ovrlay)
{
_LINE *ystart, *yend, *yptr;
chtype *xstart, *xend, *xptr;
chtype ch;
int smaxrow, smaxcol;
if((srcwin == 0) || (dstwin == 0)) return(ERR);
if(dmaxrow > dstwin->_rows) dmaxrow = dstwin->_rows;
if(dmaxcol > dstwin->_cols) dmaxcol = dstwin->_cols;
smaxrow = sminrow + (dmaxrow - dminrow);
smaxcol = smincol + (dmaxcol - dmincol);
if(smaxrow > srcwin->_rows) smaxrow = srcwin->_rows;
if(smaxcol > srcwin->_cols) smaxcol = srcwin->_cols;
dmaxrow = dminrow + (smaxrow - sminrow);
dmaxcol = dmincol + (smaxcol - smincol);
ystart = srcwin->_lines + sminrow;
yend = srcwin->_lines + smaxrow + 1;
yptr = dstwin->_lines + dmincol;
for(; ystart != yend; ystart++, yptr++)
{
xstart = ystart->line + smincol;
xend = ystart->line + smaxcol + 1;
xptr = yptr->line + dmincol;
for(; xstart != xend; xstart++, xptr++)
{
ch = *xstart & A_CHARTEXT;
if(ovrlay && (ch == (chtype) ' ')) *xptr = ch | dstwin->_attr;
}
}
return wtouchln(dstwin, dminrow, dmaxrow - dminrow + 1, (int)TRUE);
}