1: #ifndef lint 2: static char sccsid[] = "@(#)wwframe.c 3.16 4/24/85"; 3: #endif 4: 5: /* 6: * Copyright (c) 1983 Regents of the University of California, 7: * All rights reserved. Redistribution permitted subject to 8: * the terms of the Berkeley Software License Agreement. 9: */ 10: 11: #include "ww.h" 12: #include "tt.h" 13: 14: #define frameok(w, r, c) (w1 = wwindex[wwsmap[r][c]], \ 15: w1->ww_fmap || w1->ww_order > (w)->ww_order) 16: 17: wwframe(w, wframe) 18: register struct ww *w; 19: struct ww *wframe; 20: { 21: register r, c; 22: char a1, a2, a3; 23: char b1, b2, b3; 24: register char *smap; 25: register code; 26: register struct ww *w1; 27: 28: if (w->ww_w.t > 0) { 29: r = w->ww_w.t - 1; 30: c = w->ww_i.l - 1; 31: smap = &wwsmap[r + 1][c + 1]; 32: a1 = 0; 33: a2 = 0; 34: b1 = 0; 35: b2 = c < 0 || frameok(w, r, c); 36: 37: for (; c < w->ww_i.r; c++) { 38: if (c + 1 >= wwncol) { 39: a3 = 1; 40: b3 = 1; 41: } else { 42: a3 = w->ww_index == *smap++; 43: b3 = frameok(w, r, c + 1); 44: } 45: if (b2) { 46: code = 0; 47: if ((a1 || a2) && b1) 48: code |= WWF_L; 49: if ((a2 || a3) && b3) 50: code |= WWF_R; 51: if (code) 52: wwframec(wframe, r, c, code|WWF_TOP); 53: } 54: a1 = a2; 55: a2 = a3; 56: b1 = b2; 57: b2 = b3; 58: } 59: if ((a1 || a2) && b1 && b2) 60: wwframec(wframe, r, c, WWF_L|WWF_TOP); 61: } 62: 63: if (w->ww_w.b < wwnrow) { 64: r = w->ww_w.b; 65: c = w->ww_i.l - 1; 66: smap = &wwsmap[r - 1][c + 1]; 67: a1 = 0; 68: a2 = 0; 69: b1 = 0; 70: b2 = c < 0 || frameok(w, r, c); 71: 72: for (; c < w->ww_i.r; c++) { 73: if (c + 1 >= wwncol) { 74: a3 = 1; 75: b3 = 1; 76: } else { 77: a3 = w->ww_index == *smap++; 78: b3 = frameok(w, r, c + 1); 79: } 80: if (b2) { 81: code = 0; 82: if ((a1 || a2) && b1) 83: code |= WWF_L; 84: if ((a2 || a3) && b3) 85: code |= WWF_R; 86: if (code) 87: wwframec(wframe, r, c, code); 88: } 89: a1 = a2; 90: a2 = a3; 91: b1 = b2; 92: b2 = b3; 93: } 94: if ((a1 || a2) && b1 && b2) 95: wwframec(wframe, r, c, WWF_L); 96: } 97: 98: if (w->ww_w.l > 0) { 99: r = w->ww_i.t - 1; 100: c = w->ww_w.l - 1; 101: a1 = 0; 102: a2 = 0; 103: b1 = 0; 104: b2 = r < 0 || frameok(w, r, c); 105: 106: for (; r < w->ww_i.b; r++) { 107: if (r + 1 >= wwnrow) { 108: a3 = 1; 109: b3 = 1; 110: } else { 111: a3 = w->ww_index == wwsmap[r + 1][c + 1]; 112: b3 = frameok(w, r + 1, c); 113: } 114: if (b2) { 115: code = 0; 116: if ((a1 || a2) && b1) 117: code |= WWF_U; 118: if ((a2 || a3) && b3) 119: code |= WWF_D; 120: if (code) 121: wwframec(wframe, r, c, code); 122: } 123: a1 = a2; 124: a2 = a3; 125: b1 = b2; 126: b2 = b3; 127: } 128: if ((a1 || a2) && b1 && b2) 129: wwframec(wframe, r, c, WWF_U); 130: } 131: 132: if (w->ww_w.r < wwncol) { 133: r = w->ww_i.t - 1; 134: c = w->ww_w.r; 135: a1 = 0; 136: a2 = 0; 137: b1 = 0; 138: b2 = r < 0 || frameok(w, r, c); 139: 140: for (; r < w->ww_i.b; r++) { 141: if (r + 1 >= wwnrow) { 142: a3 = 1; 143: b3 = 1; 144: } else { 145: a3 = w->ww_index == wwsmap[r + 1][c - 1]; 146: b3 = frameok(w, r + 1, c); 147: } 148: if (b2) { 149: code = 0; 150: if ((a1 || a2) && b1) 151: code |= WWF_U; 152: if ((a2 || a3) && b3) 153: code |= WWF_D; 154: if (code) 155: wwframec(wframe, r, c, code); 156: } 157: a1 = a2; 158: a2 = a3; 159: b1 = b2; 160: b2 = b3; 161: } 162: if ((a1 || a2) && b1 && b2) 163: wwframec(wframe, r, c, WWF_U); 164: } 165: } 166: 167: wwframec(f, r, c, code) 168: register struct ww *f; 169: register r, c; 170: char code; 171: { 172: char oldcode; 173: register char *smap; 174: 175: if (r < f->ww_i.t || r >= f->ww_i.b || c < f->ww_i.l || c >= f->ww_i.r) 176: return; 177: 178: smap = &wwsmap[r][c]; 179: 180: { 181: register struct ww *w; 182: 183: w = wwindex[*smap]; 184: if (w->ww_order > f->ww_order) { 185: if (w != &wwnobody && w->ww_win[r][c] == 0) 186: w->ww_nvis[r]--; 187: *smap = f->ww_index; 188: } 189: } 190: 191: if (f->ww_fmap != 0) { 192: register char *fmap; 193: 194: fmap = &f->ww_fmap[r][c]; 195: oldcode = *fmap; 196: *fmap |= code; 197: if (code & WWF_TOP) 198: *fmap &= ~WWF_LABEL; 199: code = *fmap; 200: } else 201: oldcode = 0; 202: { 203: register char *win = &f->ww_win[r][c]; 204: 205: if (*win == WWM_GLS && *smap == f->ww_index) 206: f->ww_nvis[r]++; 207: *win &= ~WWM_GLS; 208: } 209: if (oldcode != code && (code & WWF_LABEL) == 0) { 210: register short frame; 211: 212: frame = tt.tt_frame[code & WWF_MASK]; 213: f->ww_buf[r][c].c_w = frame; 214: if (wwsmap[r][c] == f->ww_index) { 215: wwtouched[r] |= WWU_TOUCHED; 216: wwns[r][c].c_w = frame; 217: } 218: } 219: }