new user settable buffer size and explanation about SHELL.
[unix-history] / usr / src / usr.bin / window / wwupdate.c
CommitLineData
bbb8329f 1#ifndef lint
d2659050 2static char *sccsid = "@(#)wwupdate.c 3.7 83/08/19";
bbb8329f
EW
3#endif
4
5#include "ww.h"
e908bfac 6#include "tt.h"
bbb8329f
EW
7
8wwupdate()
9{
b7f39bc5
EW
10 int i;
11 register j;
12 int c, x;
bbb8329f 13 register union ww_char *ns, *os;
b7f39bc5
EW
14 register char *p, *q;
15 char m;
16 char *touched;
861cd1ed 17 register didit;
b7f39bc5 18 char buf[512]; /* > wwncol */
5e785082 19 union ww_char lastc;
bbb8329f 20
861cd1ed 21 wwnupdate++;
861cd1ed
EW
22 for (i = 0, touched = wwtouched; i < wwnrow; i++, touched++) {
23 if (!*touched)
24 continue;
25 wwntouched++;
26 *touched = 0;
b7f39bc5 27
bbb8329f
EW
28 ns = wwns[i];
29 os = wwos[i];
861cd1ed 30 didit = 0;
b7f39bc5
EW
31 for (j = 0; j < wwncol;) {
32 for (; j++ < wwncol && ns++->c_w == os++->c_w;)
33 ;
34 if (j > wwncol)
35 break;
36 p = buf;
37 m = ns[-1].c_m;
38 c = j - 1;
39 os[-1] = ns[-1];
40 *p++ = ns[-1].c_c;
41 x = 5;
42 q = p;
43 while (j < wwncol && ns->c_m == m) {
44 *p++ = ns->c_c;
45 if (ns->c_w == os->c_w) {
46 if (--x <= 0)
47 break;
48 os++;
49 ns++;
50 } else {
51 x = 5;
52 q = p;
5e785082 53 lastc = *os;
b7f39bc5
EW
54 *os++ = *ns++;
55 }
56 j++;
bbb8329f 57 }
5e785082
EW
58 if (wwwrap
59 && i == wwnrow - 1 && q - buf + c == wwncol) {
60 if (tt.tt_setinsert != 0) {
61 (*tt.tt_move)(i, c);
62 (*tt.tt_setmodes)(m);
63 (*tt.tt_write)(buf + 1, q - 1);
64 (*tt.tt_move)(i, c);
65 (*tt.tt_setinsert)(1);
66 (*tt.tt_write)(buf, buf);
67 (*tt.tt_setinsert)(0);
68 } else {
69 os[-1] = lastc;
70 (*tt.tt_move)(i, c);
71 (*tt.tt_setmodes)(m);
72 (*tt.tt_write)(buf, q - 2);
73 }
74 } else {
75 (*tt.tt_move)(i, c);
76 (*tt.tt_setmodes)(m);
77 (*tt.tt_write)(buf, q - 1);
78 }
b7f39bc5 79 didit++;
bbb8329f 80 }
861cd1ed
EW
81 if (!didit)
82 wwnmiss++;
bbb8329f
EW
83 }
84}