|
|
1.1 root 1: /*
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
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.
16: */
17:
18: #ifndef lint
19: static char sccsid[] = "@(#)wwclreol.c 3.17 (Berkeley) 6/29/88";
20: #endif /* not lint */
21:
22: #include "ww.h"
23: #include "tt.h"
24:
25: /*
26: * Clear w to the end of line.
27: * If cleared is true, then the screen line has already been cleared
28: * previously.
29: */
30: wwclreol1(w, row, col, cleared)
31: register struct ww *w;
32: int row, col;
33: char cleared;
34: {
35: register i;
36:
37: /*
38: * Clear the buffer right off
39: */
40: {
41: register union ww_char *buf;
42:
43: buf = &w->ww_buf[row][col];
44: for (i = w->ww_b.r - col; --i >= 0;)
45: buf++->c_w = ' ';
46: }
47:
48: /*
49: * If can't see it, just return.
50: */
51: if (row < w->ww_i.t || row >= w->ww_i.b
52: || w->ww_i.r <= 0 || w->ww_i.r <= col)
53: return;
54:
55: if (col < w->ww_i.l)
56: col = w->ww_i.l;
57:
58: /*
59: * Now find out how much is actually cleared, and fix wwns.
60: */
61: if (cleared) {
62: register union ww_char *s;
63: register char *smap, *win;
64:
65: i = col;
66: smap = &wwsmap[row][i];
67: s = &wwns[row][i];
68: win = &w->ww_win[row][i];
69: for (i = w->ww_i.r - i; --i >= 0;) {
70: if (*smap++ != w->ww_index)
71: continue;
72: s++->c_w = ' ' | *win++ << WWC_MSHIFT;
73: }
74: } else {
75: register union ww_char *s;
76: register char *smap, *win;
77: int ntouched = 0;
78: int gain = 0;
79:
80: i = col;
81: smap = &wwsmap[row][i];
82: s = wwns[row];
83: win = w->ww_win[row];
84: for (; i < w->ww_i.r; i++) {
85: if (*smap++ != w->ww_index) {
86: if (s[i].c_w != ' ')
87: gain--;
88: } else if (win[i] == 0) {
89: if (s[i].c_w != ' ') {
90: gain++;
91: ntouched++;
92: s[i].c_w = ' ';
93: }
94: } else {
95: short c = ' ' | win[i] << WWC_MSHIFT;
96: if (s[i].c_w == c)
97: gain--;
98: else {
99: s[i].c_w = c;
100: ntouched++;
101: }
102: }
103: }
104: s += i;
105: for (i = wwncol - i; --i >= 0;)
106: if (s++->c_w != ' ')
107: gain--;
108: if (ntouched > 0)
109: wwtouched[row] |= WWU_TOUCHED;
110: /*
111: * Can/should we use clear eol?
112: */
113: if (tt.tt_clreol != 0 && gain > 4) {
114: /* clear to the end */
115: (*tt.tt_move)(row, col);
116: (*tt.tt_clreol)();
117: s = &wwos[row][col];
118: for (i = wwncol - col; --i >= 0;)
119: s++->c_w = ' ';
120: }
121: }
122: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.