the xx layer added, handle "ic" differently, compression added to zapple
[unix-history] / usr / src / usr.bin / window / wwdelchar.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
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
2d152f42 19static char sccsid[] = "@(#)wwdelchar.c 3.14 (Berkeley) %G%";
46e9ea25
KB
20#endif /* not lint */
21
53069d72 22#include "ww.h"
e908bfac 23#include "tt.h"
53069d72 24
f2a77fe1 25wwdelchar(w, row, col)
53069d72
EW
26register struct ww *w;
27{
14f251df 28 register i;
14f251df
EW
29 int nvis;
30
19f9784c
EW
31 /*
32 * First, shift the line.
33 */
14f251df
EW
34 {
35 register union ww_char *p, *q;
36
f2a77fe1 37 p = &w->ww_buf[row][col];
14f251df 38 q = p + 1;
f2a77fe1 39 for (i = w->ww_b.r - col; --i > 0;)
14f251df
EW
40 *p++ = *q++;
41 p->c_w = ' ';
42 }
19f9784c
EW
43
44 /*
45 * If can't see it, just return.
46 */
f2a77fe1
EW
47 if (row < w->ww_i.t || row >= w->ww_i.b
48 || w->ww_i.r <= 0 || w->ww_i.r <= col)
14f251df 49 return;
19f9784c 50
f2a77fe1
EW
51 if (col < w->ww_i.l)
52 col = w->ww_i.l;
19f9784c
EW
53
54 /*
55 * Now find out how much is actually changed, and fix wwns.
56 */
14f251df
EW
57 {
58 register union ww_char *buf;
59 register char *win;
60 register union ww_char *ns;
61 register char *smap;
d069a508 62 char touched;
14f251df
EW
63
64 nvis = 0;
f2a77fe1 65 smap = &wwsmap[row][col];
d069a508
EW
66 for (i = col; i < w->ww_i.r && *smap++ != w->ww_index; i++)
67 ;
68 if (i >= w->ww_i.r)
14f251df 69 return;
d069a508
EW
70 col = i;
71 buf = w->ww_buf[row];
72 win = w->ww_win[row];
73 ns = wwns[row];
74 smap = &wwsmap[row][i];
75 touched = wwtouched[row];
76 for (; i < w->ww_i.r; i++) {
77 if (*smap++ != w->ww_index)
78 continue;
04d70db4 79 touched |= WWU_TOUCHED;
d069a508
EW
80 if (win[i])
81 ns[i].c_w =
82 buf[i].c_w ^ win[i] << WWC_MSHIFT;
83 else {
14f251df 84 nvis++;
d069a508 85 ns[i] = buf[i];
14f251df 86 }
d069a508
EW
87 }
88 wwtouched[row] = touched;
14f251df 89 }
19f9784c
EW
90
91 /*
92 * Can/Should we use delete character?
93 */
f2a77fe1 94 if (tt.tt_delchar != 0 && nvis > (wwncol - col) / 2) {
14f251df
EW
95 register union ww_char *p, *q;
96
2d152f42 97 xxdelchar(row, col);
f2a77fe1 98 p = &wwos[row][col];
14f251df 99 q = p + 1;
f2a77fe1 100 for (i = wwncol - col; --i > 0;)
14f251df
EW
101 *p++ = *q++;
102 p->c_w = ' ';
103 }
53069d72 104}