Commit | Line | Data |
---|---|---|
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 | |
5e8b0e60 KB |
6 | * provided that the above copyright notice and this paragraph are |
7 | * duplicated in all such forms and that any documentation, | |
8 | * advertising materials, and other materials related to such | |
9 | * distribution and use acknowledge that the software was developed | |
10 | * by the University of California, Berkeley. The name of the | |
11 | * University may not be used to endorse or promote products derived | |
12 | * from this software without specific prior written permission. | |
13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
15 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
60de5df9 EW |
16 | */ |
17 | ||
46e9ea25 | 18 | #ifndef lint |
5e8b0e60 | 19 | static char sccsid[] = "@(#)wwadd.c 3.11 (Berkeley) %G%"; |
46e9ea25 KB |
20 | #endif /* not lint */ |
21 | ||
7c1c9e39 EW |
22 | #include "ww.h" |
23 | ||
24 | /* | |
84ad208b | 25 | * Stick w1 behind w2. |
7c1c9e39 EW |
26 | */ |
27 | wwadd(w1, w2) | |
84ad208b EW |
28 | register struct ww *w1; |
29 | struct ww *w2; | |
7c1c9e39 | 30 | { |
84ad208b | 31 | register i; |
04d70db4 | 32 | register struct ww *w; |
19f9784c | 33 | |
7c1c9e39 EW |
34 | w1->ww_order = w2->ww_order + 1; |
35 | w1->ww_back = w2; | |
36 | w1->ww_forw = w2->ww_forw; | |
37 | w2->ww_forw->ww_back = w1; | |
38 | w2->ww_forw = w1; | |
19f9784c | 39 | |
84ad208b EW |
40 | for (w = w1->ww_forw; w != &wwhead; w = w->ww_forw) |
41 | w->ww_order++; | |
42 | for (i = w1->ww_i.t; i < w1->ww_i.b; i++) { | |
04d70db4 EW |
43 | register j; |
44 | register char *smap = wwsmap[i]; | |
45 | register char *win = w1->ww_win[i]; | |
46 | union ww_char *ns = wwns[i]; | |
47 | union ww_char *buf = w1->ww_buf[i]; | |
84ad208b | 48 | int nvis = 0; |
04d70db4 | 49 | int nchanged = 0; |
7c1c9e39 | 50 | |
84ad208b | 51 | for (j = w1->ww_i.l; j < w1->ww_i.r; j++) { |
04d70db4 EW |
52 | w = wwindex[smap[j]]; |
53 | if (w1->ww_order > w->ww_order) | |
84ad208b | 54 | continue; |
04d70db4 | 55 | if (win[j] & WWM_GLS) |
84ad208b | 56 | continue; |
84ad208b EW |
57 | if (w != &wwnobody && w->ww_win[i][j] == 0) |
58 | w->ww_nvis[i]--; | |
04d70db4 EW |
59 | smap[j] = w1->ww_index; |
60 | if (win[j] == 0) | |
84ad208b | 61 | nvis++; |
04d70db4 EW |
62 | ns[j].c_w = buf[j].c_w ^ win[j] << WWC_MSHIFT; |
63 | nchanged++; | |
7c1c9e39 | 64 | } |
04d70db4 EW |
65 | if (nchanged > 4) |
66 | wwtouched[i] |= WWU_MAJOR|WWU_TOUCHED; | |
67 | else if (nchanged > 0) | |
68 | wwtouched[i] |= WWU_TOUCHED; | |
84ad208b | 69 | w1->ww_nvis[i] = nvis; |
7c1c9e39 EW |
70 | } |
71 | } |