Back to index

tetex-bin  3.0
Functions
lib_overlay.c File Reference
#include <curses.priv.h>

Go to the source code of this file.

Functions

static int overlap (const WINDOW *const s, WINDOW *const d, int const flag)
 overlay (const WINDOW *win1, WINDOW *win2)
 overwrite (const WINDOW *win1, WINDOW *win2)
 copywin (const WINDOW *src, WINDOW *dst, int sminrow, int smincol, int dminrow, int dmincol, int dmaxrow, int dmaxcol, int over)

Function Documentation

copywin ( const WINDOW src,
WINDOW dst,
int  sminrow,
int  smincol,
int  dminrow,
int  dmincol,
int  dmaxrow,
int  dmaxcol,
int  over 
)

Definition at line 128 of file lib_overlay.c.

{
    int sx, sy, dx, dy;
    bool touched;
    attr_t bk = AttrOf(dst->_nc_bkgd);
    attr_t mask = ~(attr_t) ((bk & A_COLOR) ? A_COLOR : 0);

    T((T_CALLED("copywin(%p, %p, %d, %d, %d, %d, %d, %d, %d)"),
       src, dst, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol, over));

    if (!src || !dst)
       returnCode(ERR);

    /* make sure rectangle exists in source */
    if ((sminrow + dmaxrow - dminrow) > (src->_maxy + 1) ||
       (smincol + dmaxcol - dmincol) > (src->_maxx + 1)) {
       returnCode(ERR);
    }

    T(("rectangle exists in source"));

    /* make sure rectangle fits in destination */
    if (dmaxrow > dst->_maxy || dmaxcol > dst->_maxx) {
       returnCode(ERR);
    }

    T(("rectangle fits in destination"));

    for (dy = dminrow, sy = sminrow; dy <= dmaxrow; sy++, dy++) {
       touched = FALSE;
       for (dx = dmincol, sx = smincol; dx <= dmaxcol; sx++, dx++) {
           if (over) {
              if ((CharOf(src->_line[sy].text[sx]) != L(' ')) &&
                  (!CharEq(dst->_line[dy].text[dx], src->_line[sy].text[sx]))) {
                  dst->_line[dy].text[dx] = src->_line[sy].text[sx];
                  SetAttr(dst->_line[dy].text[dx],
                         (AttrOf(src->_line[sy].text[sx]) & mask) | bk);
                  touched = TRUE;
              }
           } else {
              if (!CharEq(dst->_line[dy].text[dx], src->_line[sy].text[sx])) {
                  dst->_line[dy].text[dx] = src->_line[sy].text[sx];
                  touched = TRUE;
              }
           }
       }
       if (touched) {
           touchline(dst, dminrow, (dmaxrow - dminrow + 1));
       }
    }
    T(("finished copywin"));
    returnCode(OK);
}

Here is the caller graph for this function:

static int overlap ( const WINDOW *const  s,
WINDOW *const  d,
int const  flag 
) [static]

Definition at line 46 of file lib_overlay.c.

{
    int sx1, sy1, sx2, sy2;
    int dx1, dy1, dx2, dy2;
    int sminrow, smincol;
    int dminrow, dmincol;
    int dmaxrow, dmaxcol;

    T((T_CALLED("overlap(%p,%p,%d)"), s, d, flag));

    if (s == 0 || d == 0) {
       returnCode(ERR);
    } else {
       T(("src : begy %d, begx %d, maxy %d, maxx %d",
          s->_begy, s->_begx, s->_maxy, s->_maxx));
       T(("dst : begy %d, begx %d, maxy %d, maxx %d",
          d->_begy, d->_begx, d->_maxy, d->_maxx));

       sx1 = s->_begx;
       sy1 = s->_begy;
       sx2 = sx1 + s->_maxx;
       sy2 = sy1 + s->_maxy;

       dx1 = d->_begx;
       dy1 = d->_begy;
       dx2 = dx1 + d->_maxx;
       dy2 = dy1 + d->_maxy;

       if (dx2 < sx1 || dx1 > sx2 || dy2 < sy1 || dy1 > sy2) {
           returnCode(ERR); /* No intersection */
       } else {
           sminrow = max(sy1, dy1) - sy1;
           smincol = max(sx1, dx1) - sx1;
           dminrow = max(sy1, dy1) - dy1;
           dmincol = max(sx1, dx1) - dx1;
           dmaxrow = min(sy2, dy2) - dy1;
           dmaxcol = min(sx2, dx2) - dx1;

           returnCode(copywin(s, d,
                            sminrow, smincol,
                            dminrow, dmincol,
                            dmaxrow, dmaxcol,
                            flag));
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

overlay ( const WINDOW win1,
WINDOW win2 
)

Definition at line 104 of file lib_overlay.c.

{
    T((T_CALLED("overlay(%p,%p)"), win1, win2));
    returnCode(overlap(win1, win2, TRUE));
}

Here is the call graph for this function:

Here is the caller graph for this function:

overwrite ( const WINDOW win1,
WINDOW win2 
)

Definition at line 121 of file lib_overlay.c.

{
    T((T_CALLED("overwrite(%p,%p)"), win1, win2));
    returnCode(overlap(win1, win2, FALSE));
}

Here is the call graph for this function: