gen_strings and gen_strp left over from before.
[unix-history] / usr / src / usr.bin / window / wwupdate.c
CommitLineData
bbb8329f 1#ifndef lint
5e785082 2static char *sccsid = "@(#)wwupdate.c 3.6 83/08/17";
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++;
bbb8329f 22 (*tt.tt_setinsert)(0);
861cd1ed
EW
23 for (i = 0, touched = wwtouched; i < wwnrow; i++, touched++) {
24 if (!*touched)
25 continue;
26 wwntouched++;
27 *touched = 0;
b7f39bc5 28
bbb8329f
EW
29 ns = wwns[i];
30 os = wwos[i];
861cd1ed 31 didit = 0;
b7f39bc5
EW
32 for (j = 0; j < wwncol;) {
33 for (; j++ < wwncol && ns++->c_w == os++->c_w;)
34 ;
35 if (j > wwncol)
36 break;
37 p = buf;
38 m = ns[-1].c_m;
39 c = j - 1;
40 os[-1] = ns[-1];
41 *p++ = ns[-1].c_c;
42 x = 5;
43 q = p;
44 while (j < wwncol && ns->c_m == m) {
45 *p++ = ns->c_c;
46 if (ns->c_w == os->c_w) {
47 if (--x <= 0)
48 break;
49 os++;
50 ns++;
51 } else {
52 x = 5;
53 q = p;
5e785082 54 lastc = *os;
b7f39bc5
EW
55 *os++ = *ns++;
56 }
57 j++;
bbb8329f 58 }
5e785082
EW
59 if (wwwrap
60 && i == wwnrow - 1 && q - buf + c == wwncol) {
61 if (tt.tt_setinsert != 0) {
62 (*tt.tt_move)(i, c);
63 (*tt.tt_setmodes)(m);
64 (*tt.tt_write)(buf + 1, q - 1);
65 (*tt.tt_move)(i, c);
66 (*tt.tt_setinsert)(1);
67 (*tt.tt_write)(buf, buf);
68 (*tt.tt_setinsert)(0);
69 } else {
70 os[-1] = lastc;
71 (*tt.tt_move)(i, c);
72 (*tt.tt_setmodes)(m);
73 (*tt.tt_write)(buf, q - 2);
74 }
75 } else {
76 (*tt.tt_move)(i, c);
77 (*tt.tt_setmodes)(m);
78 (*tt.tt_write)(buf, q - 1);
79 }
b7f39bc5 80 didit++;
bbb8329f 81 }
861cd1ed
EW
82 if (!didit)
83 wwnmiss++;
bbb8329f
EW
84 }
85}