[BACK]Return to wwdelete.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / window

Annotation of src/usr.bin/window/wwdelete.c, Revision 1.2

1.2     ! niklas      1: /*     $NetBSD: wwdelete.c,v 1.4 1996/02/08 21:49:01 mycroft Exp $     */
1.1       deraadt     2:
                      3: /*
                      4:  * Copyright (c) 1983, 1993
                      5:  *     The Regents of the University of California.  All rights reserved.
                      6:  *
                      7:  * This code is derived from software contributed to Berkeley by
                      8:  * Edward Wang at The University of California, Berkeley.
                      9:  *
                     10:  * Redistribution and use in source and binary forms, with or without
                     11:  * modification, are permitted provided that the following conditions
                     12:  * are met:
                     13:  * 1. Redistributions of source code must retain the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer.
                     15:  * 2. Redistributions in binary form must reproduce the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer in the
                     17:  *    documentation and/or other materials provided with the distribution.
                     18:  * 3. All advertising materials mentioning features or use of this software
                     19:  *    must display the following acknowledgement:
                     20:  *     This product includes software developed by the University of
                     21:  *     California, Berkeley and its contributors.
                     22:  * 4. Neither the name of the University nor the names of its contributors
                     23:  *    may be used to endorse or promote products derived from this software
                     24:  *    without specific prior written permission.
                     25:  *
                     26:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     27:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     28:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     29:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     30:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     31:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     32:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     33:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     34:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     35:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     36:  * SUCH DAMAGE.
                     37:  */
                     38:
                     39: #ifndef lint
                     40: #if 0
                     41: static char sccsid[] = "@(#)wwdelete.c 8.1 (Berkeley) 6/6/93";
                     42: #else
1.2     ! niklas     43: static char rcsid[] = "$NetBSD: wwdelete.c,v 1.4 1996/02/08 21:49:01 mycroft Exp $";
1.1       deraadt    44: #endif
                     45: #endif /* not lint */
                     46:
                     47: #include "ww.h"
                     48:
                     49: /*
                     50:  * Pull w free from the cover list.
                     51:  */
                     52: wwdelete(w)
                     53: register struct ww *w;
                     54: {
                     55:        register i;
                     56:
                     57:        for (i = w->ww_i.t; i < w->ww_i.b; i++) {
                     58:                register j;
1.2     ! niklas     59:                register unsigned char *smap = wwsmap[i];
1.1       deraadt    60:                register union ww_char *ns = wwns[i];
                     61:                register int nchanged = 0;
                     62:
                     63:                for (j = w->ww_i.l; j < w->ww_i.r; j++)
                     64:                        if (smap[j] == w->ww_index) {
                     65:                                smap[j] = WWX_NOBODY;
                     66:                                ns[j].c_w = ' ';
                     67:                                nchanged++;
                     68:                        }
                     69:                if (nchanged > 0)
                     70:                        wwtouched[i] |= WWU_TOUCHED;
                     71:        }
                     72:
                     73:        {
                     74:                register struct ww *wp;
                     75:
                     76:                for (wp = w->ww_forw; wp != &wwhead; wp = wp->ww_forw)
                     77:                        wp->ww_order--;
                     78:        }
                     79:
                     80:        if (w->ww_forw != &wwhead)
                     81:                wwdelete1(w->ww_forw,
                     82:                        w->ww_i.t, w->ww_i.b, w->ww_i.l, w->ww_i.r);
                     83:
                     84:        w->ww_back->ww_forw = w->ww_forw;
                     85:        w->ww_forw->ww_back = w->ww_back;
                     86:        w->ww_forw = w->ww_back = 0;
                     87: }
                     88:
                     89: wwdelete1(w, t, b, l, r)
                     90: register struct ww *w;
                     91: {
                     92:        int i;
                     93:        int tt, bb, ll, rr;
                     94:        char hasglass;
                     95:
                     96: again:
                     97:        hasglass = 0;
                     98:        tt = MAX(t, w->ww_i.t);
                     99:        bb = MIN(b, w->ww_i.b);
                    100:        ll = MAX(l, w->ww_i.l);
                    101:        rr = MIN(r, w->ww_i.r);
                    102:        if (tt >= bb || ll >= rr) {
                    103:                if ((w = w->ww_forw) == &wwhead)
                    104:                        return;
                    105:                goto again;
                    106:        }
                    107:        for (i = tt; i < bb; i++) {
                    108:                register j;
1.2     ! niklas    109:                register unsigned char *smap = wwsmap[i];
1.1       deraadt   110:                register union ww_char *ns = wwns[i];
                    111:                register char *win = w->ww_win[i];
                    112:                register union ww_char *buf = w->ww_buf[i];
                    113:                int nvis = w->ww_nvis[i];
                    114:                int nchanged = 0;
                    115:
                    116:                for (j = ll; j < rr; j++) {
                    117:                        if (smap[j] != WWX_NOBODY)
                    118:                                continue;
                    119:                        if (win[j] & WWM_GLS) {
                    120:                                hasglass = 1;
                    121:                                continue;
                    122:                        }
                    123:                        smap[j] = w->ww_index;
                    124:                        ns[j].c_w = buf[j].c_w ^ win[j] << WWC_MSHIFT;
                    125:                        nchanged++;
                    126:                        if (win[j] == 0)
                    127:                                nvis++;
                    128:                }
                    129:                if (nchanged > 0)
                    130:                        wwtouched[i] |= WWU_TOUCHED;
                    131:                w->ww_nvis[i] = nvis;
                    132:        }
                    133:        if ((w = w->ww_forw) == &wwhead)
                    134:                return;
                    135:        if (hasglass)
                    136:                goto again;
                    137:        if (tt > t)
                    138:                wwdelete1(w, t, tt, l, r);
                    139:        if (bb < b)
                    140:                wwdelete1(w, bb, b, l, r);
                    141:        if (ll > l)
                    142:                wwdelete1(w, tt, bb, l, ll);
                    143:        if (rr < r)
                    144:                wwdelete1(w, tt, bb, rr, r);
                    145: }