The 'M' command and rearranged debugging commands ('&')
[unix-history] / usr / src / usr.bin / window / wwupdate.c
CommitLineData
bbb8329f 1#ifndef lint
3130283e 2static char *sccsid = "@(#)wwupdate.c 3.8 83/09/15";
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;
3130283e 37 m = ns[-1].c_m & tt.tt_availmodes;
b7f39bc5
EW
38 c = j - 1;
39 os[-1] = ns[-1];
40 *p++ = ns[-1].c_c;
41 x = 5;
42 q = p;
3130283e 43 while (j < wwncol && (ns->c_m&tt.tt_availmodes) == m) {
b7f39bc5
EW
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 }
3130283e
EW
58 tt.tt_nmodes = m;
59 (*tt.tt_move)(i, c);
5e785082
EW
60 if (wwwrap
61 && i == wwnrow - 1 && q - buf + c == wwncol) {
3130283e
EW
62 if (tt.tt_hasinsert) {
63 (*tt.tt_write)(buf + 1, q - buf - 1);
5e785082 64 (*tt.tt_move)(i, c);
3130283e
EW
65 tt.tt_ninsert = 1;
66 (*tt.tt_write)(buf, 1);
67 tt.tt_ninsert = 0;
5e785082
EW
68 } else {
69 os[-1] = lastc;
3130283e 70 (*tt.tt_write)(buf, q - buf - 1);
5e785082 71 }
3130283e
EW
72 } else
73 (*tt.tt_write)(buf, q - buf);
b7f39bc5 74 didit++;
bbb8329f 75 }
861cd1ed
EW
76 if (!didit)
77 wwnmiss++;
bbb8329f
EW
78 }
79}