1 /* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Edward Wang at The University of California, Berkeley. 7 * 8 * %sccs.include.redist.c% 9 */ 10 11 #ifndef lint 12 static char sccsid[] = "@(#)wwdelchar.c 8.1 (Berkeley) 06/06/93"; 13 #endif /* not lint */ 14 15 #include "ww.h" 16 #include "tt.h" 17 18 wwdelchar(w, row, col) 19 register struct ww *w; 20 { 21 register i; 22 int nvis; 23 24 /* 25 * First, shift the line. 26 */ 27 { 28 register union ww_char *p, *q; 29 30 p = &w->ww_buf[row][col]; 31 q = p + 1; 32 for (i = w->ww_b.r - col; --i > 0;) 33 *p++ = *q++; 34 p->c_w = ' '; 35 } 36 37 /* 38 * If can't see it, just return. 39 */ 40 if (row < w->ww_i.t || row >= w->ww_i.b 41 || w->ww_i.r <= 0 || w->ww_i.r <= col) 42 return; 43 44 if (col < w->ww_i.l) 45 col = w->ww_i.l; 46 47 /* 48 * Now find out how much is actually changed, and fix wwns. 49 */ 50 { 51 register union ww_char *buf; 52 register char *win; 53 register union ww_char *ns; 54 register char *smap; 55 char touched; 56 57 nvis = 0; 58 smap = &wwsmap[row][col]; 59 for (i = col; i < w->ww_i.r && *smap++ != w->ww_index; i++) 60 ; 61 if (i >= w->ww_i.r) 62 return; 63 col = i; 64 buf = w->ww_buf[row]; 65 win = w->ww_win[row]; 66 ns = wwns[row]; 67 smap = &wwsmap[row][i]; 68 touched = wwtouched[row]; 69 for (; i < w->ww_i.r; i++) { 70 if (*smap++ != w->ww_index) 71 continue; 72 touched |= WWU_TOUCHED; 73 if (win[i]) 74 ns[i].c_w = 75 buf[i].c_w ^ win[i] << WWC_MSHIFT; 76 else { 77 nvis++; 78 ns[i] = buf[i]; 79 } 80 } 81 wwtouched[row] = touched; 82 } 83 84 /* 85 * Can/Should we use delete character? 86 */ 87 if (tt.tt_delchar != 0 && nvis > (wwncol - col) / 2) { 88 register union ww_char *p, *q; 89 90 xxdelchar(row, col); 91 p = &wwos[row][col]; 92 q = p + 1; 93 for (i = wwncol - col; --i > 0;) 94 *p++ = *q++; 95 p->c_w = ' '; 96 } 97 } 98