date and time created 88/06/29 21:19:25 by bostic
[unix-history] / usr / src / usr.bin / window / wwadd.c
CommitLineData
60de5df9 1/*
46e9ea25
KB
2 * Copyright (c) 1983 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are permitted
6 * provided that this notice is preserved and that due credit is given
7 * to the University of California at Berkeley. The name of the University
8 * may not be used to endorse or promote products derived from this
9 * software without specific prior written permission. This software
10 * is provided ``as is'' without express or implied warranty.
60de5df9
EW
11 */
12
46e9ea25
KB
13#ifndef lint
14static char sccsid[] = "@(#)wwadd.c 3.10 (Berkeley) %G%";
15#endif /* not lint */
16
7c1c9e39
EW
17#include "ww.h"
18
19/*
84ad208b 20 * Stick w1 behind w2.
7c1c9e39
EW
21 */
22wwadd(w1, w2)
84ad208b
EW
23register struct ww *w1;
24struct ww *w2;
7c1c9e39 25{
84ad208b 26 register i;
04d70db4 27 register struct ww *w;
19f9784c 28
7c1c9e39
EW
29 w1->ww_order = w2->ww_order + 1;
30 w1->ww_back = w2;
31 w1->ww_forw = w2->ww_forw;
32 w2->ww_forw->ww_back = w1;
33 w2->ww_forw = w1;
19f9784c 34
84ad208b
EW
35 for (w = w1->ww_forw; w != &wwhead; w = w->ww_forw)
36 w->ww_order++;
37 for (i = w1->ww_i.t; i < w1->ww_i.b; i++) {
04d70db4
EW
38 register j;
39 register char *smap = wwsmap[i];
40 register char *win = w1->ww_win[i];
41 union ww_char *ns = wwns[i];
42 union ww_char *buf = w1->ww_buf[i];
84ad208b 43 int nvis = 0;
04d70db4 44 int nchanged = 0;
7c1c9e39 45
84ad208b 46 for (j = w1->ww_i.l; j < w1->ww_i.r; j++) {
04d70db4
EW
47 w = wwindex[smap[j]];
48 if (w1->ww_order > w->ww_order)
84ad208b 49 continue;
04d70db4 50 if (win[j] & WWM_GLS)
84ad208b 51 continue;
84ad208b
EW
52 if (w != &wwnobody && w->ww_win[i][j] == 0)
53 w->ww_nvis[i]--;
04d70db4
EW
54 smap[j] = w1->ww_index;
55 if (win[j] == 0)
84ad208b 56 nvis++;
04d70db4
EW
57 ns[j].c_w = buf[j].c_w ^ win[j] << WWC_MSHIFT;
58 nchanged++;
7c1c9e39 59 }
04d70db4
EW
60 if (nchanged > 4)
61 wwtouched[i] |= WWU_MAJOR|WWU_TOUCHED;
62 else if (nchanged > 0)
63 wwtouched[i] |= WWU_TOUCHED;
84ad208b 64 w1->ww_nvis[i] = nvis;
7c1c9e39
EW
65 }
66}