bug with improper redraw
[unix-history] / usr / src / usr.bin / window / wwclreol.c
CommitLineData
a43a8870 1#ifndef lint
744cb84a 2static char *sccsid = "@(#)wwclreol.c 3.7 83/08/18";
a43a8870
EW
3#endif
4
5#include "ww.h"
e908bfac 6#include "tt.h"
a43a8870 7
14f251df
EW
8wwclreol(w, line, col)
9struct ww *w;
10{
11 wwclreol1(w, line, col, 0);
12}
13
a43a8870
EW
14/*
15 * Clear w to the end of line.
16 * If cleared is true, then the screen line has already been cleared
17 * previously.
18 */
14f251df 19wwclreol1(w, line, col, cleared)
a43a8870 20register struct ww *w;
14f251df
EW
21int line, col;
22char cleared;
a43a8870
EW
23{
24 register i;
25 int row = line - w->ww_scroll;
26 int srow = w->ww_w.t + row;
27 int scol = w->ww_w.l + col;
28 register union ww_char *s, *buf;
29 register char *smap, *win;
861cd1ed 30 char *touched;
a43a8870
EW
31 int nblank, ncleared;
32
33 if (row < 0 || row >= w->ww_w.nr) {
34 /* can't even see it, so just clear the buffer */
35 buf = &w->ww_buf[line][col];
36 for (i = w->ww_w.nc - col; --i >= 0;)
37 buf++->c_w = ' ';
38 return;
39 }
40 smap = &wwsmap[srow][scol];
41 s = &wwns[srow][scol];
861cd1ed 42 touched = &wwtouched[srow];
a43a8870 43 win = &w->ww_win[row][col];
744cb84a 44 buf = &w->ww_buf[line][col];
a43a8870
EW
45 ncleared = nblank = 0;
46 for (i = w->ww_w.nc - col; --i >= 0;) {
0f10967d 47 buf++->c_w = ' ';
a43a8870
EW
48 if (*smap++ != w->ww_index) {
49 if (s++->c_w == ' ')
50 nblank++;
a43a8870
EW
51 win++;
52 continue;
53 }
54 ncleared++;
861cd1ed 55 *touched = 1;
a43a8870
EW
56 if (*win == 0) {
57 nblank++;
58 s++->c_w = ' ';
59 win++;
60 } else
61 s++->c_w = ' ' | *win++ << WWC_MSHIFT;
62 }
63 if (!cleared && tt.tt_clreol != 0
64 && ncleared > wwncol - scol - nblank
65 && nblank > (wwncol - scol) / 2) {
66 /* clear to the end */
67 (*tt.tt_move)(srow, scol);
68 (*tt.tt_clreol)();
69 s = &wwos[srow][scol];
b1db5e4e 70 for (i = wwncol - scol; --i >= 0;)
a43a8870
EW
71 s++->c_w = ' ';
72 }
73}