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