WWU_MAJOR, clreol in wwupdate(), and more optimizations.
authorEdward Wang <edward@ucbvax.Berkeley.EDU>
Sat, 3 Dec 1983 14:46:20 +0000 (06:46 -0800)
committerEdward Wang <edward@ucbvax.Berkeley.EDU>
Sat, 3 Dec 1983 14:46:20 +0000 (06:46 -0800)
SCCS-vsn: usr.bin/window/wwinit.c 3.12
SCCS-vsn: usr.bin/window/ww.h 3.21
SCCS-vsn: usr.bin/window/wwwrite.c 3.14
SCCS-vsn: usr.bin/window/cmd2.c 3.14
SCCS-vsn: usr.bin/window/wwframe.c 3.12
SCCS-vsn: usr.bin/window/wwlabel.c 3.10
SCCS-vsn: usr.bin/window/wwredraw.c 3.5
SCCS-vsn: usr.bin/window/wwadd.c 3.7
SCCS-vsn: usr.bin/window/wwdelete.c 3.11
SCCS-vsn: usr.bin/window/wwclreol.c 3.11
SCCS-vsn: usr.bin/window/wwinschar.c 3.12
SCCS-vsn: usr.bin/window/wwunframe.c 3.12
SCCS-vsn: usr.bin/window/wwupdate.c 3.9
SCCS-vsn: usr.bin/window/wwdelchar.c 3.9
SCCS-vsn: usr.bin/window/wwscroll.c 3.11
SCCS-vsn: usr.bin/window/wwredrawwin.c 3.8
SCCS-vsn: usr.bin/window/wwcursor.c 3.5

17 files changed:
usr/src/usr.bin/window/cmd2.c
usr/src/usr.bin/window/ww.h
usr/src/usr.bin/window/wwadd.c
usr/src/usr.bin/window/wwclreol.c
usr/src/usr.bin/window/wwcursor.c
usr/src/usr.bin/window/wwdelchar.c
usr/src/usr.bin/window/wwdelete.c
usr/src/usr.bin/window/wwframe.c
usr/src/usr.bin/window/wwinit.c
usr/src/usr.bin/window/wwinschar.c
usr/src/usr.bin/window/wwlabel.c
usr/src/usr.bin/window/wwredraw.c
usr/src/usr.bin/window/wwredrawwin.c
usr/src/usr.bin/window/wwscroll.c
usr/src/usr.bin/window/wwunframe.c
usr/src/usr.bin/window/wwupdate.c
usr/src/usr.bin/window/wwwrite.c

index 0140a04..bba985a 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)cmd2.c      3.13 83/11/02";
+static char *sccsid = "@(#)cmd2.c      3.14 83/12/02";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
@@ -122,14 +122,16 @@ c_stat()
 {
        register struct ww *w;
 
 {
        register struct ww *w;
 
-       if ((w = openiwin(4, "IO Statics")) == 0) {
+       if ((w = openiwin(6, "IO Statics")) == 0) {
                error("Can't open statistics window: %s.", wwerror());
                return;
        }
                error("Can't open statistics window: %s.", wwerror());
                return;
        }
-       (void) wwprintf(w, "nread\tnreadz\tnreade\tnreadc\tnwrite\tnwritec\tnupdate\tntouchd\tnmiss\n");
-       (void) wwprintf(w, "%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n",
-               nread, nreadz, nreade, nreadc, wwnwrite, wwnwritec,
-               wwnupdate, wwntouched, wwnmiss);
+       (void) wwprintf(w, "nread\tnreadz\tnreade\tnreadc\tnwrite\tnwritec\n");
+       (void) wwprintf(w, "%d\t%d\t%d\t%d\t%d\t%d\n",
+               nread, nreadz, nreade, nreadc, wwnwrite, wwnwritec);
+       (void) wwprintf(w, "nupdate\tnupdlin\tnupdmis\tnmajlin\tnmajmis\n");
+       (void) wwprintf(w, "%d\t%d\t%d\t%d\t%d\n",
+               wwnupdate, wwnupdline, wwnupdmiss, wwnmajline, wwnmajmiss);
        waitnl(w);
        closeiwin(w);
 }
        waitnl(w);
        closeiwin(w);
 }
index 3ffdaeb..82ec065 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- *     @(#)ww.h        3.20 83/12/01   
+ *     @(#)ww.h        3.21 83/12/02   
  */
 
 #include <stdio.h>
  */
 
 #include <stdio.h>
@@ -115,6 +115,7 @@ union ww_char {
        /* special ww_index value */
 #define WWX_NOBODY     NWW
 
        /* special ww_index value */
 #define WWX_NOBODY     NWW
 
+       /* error codes */
 #define WWE_NOERR      0
 #define WWE_SYS                1               /* system error */
 #define WWE_NOMEM      2               /* out of memory */
 #define WWE_NOERR      0
 #define WWE_SYS                1               /* system error */
 #define WWE_NOMEM      2               /* out of memory */
@@ -124,6 +125,10 @@ union ww_char {
 #define WWE_BADTERM    6               /* bad terminal type */
 #define WWE_CANTDO     7               /* dumb terminal */
 
 #define WWE_BADTERM    6               /* bad terminal type */
 #define WWE_CANTDO     7               /* dumb terminal */
 
+       /* wwtouched[] bits */
+#define WWU_TOUCHED    0x01            /* touched */
+#define WWU_MAJOR      0x02            /* major change */
+
 struct ww wwhead;
 struct ww *wwindex[NWW + 1];           /* last location is for wwnobody */
 struct ww wwnobody;
 struct ww wwhead;
 struct ww *wwindex[NWW + 1];           /* last location is for wwnobody */
 struct ww wwnobody;
@@ -151,7 +156,7 @@ int wwerrno;                        /* error number */
 
        /* statistics */
 int wwnwrite, wwnwritec;
 
        /* statistics */
 int wwnwrite, wwnwritec;
-int wwnupdate, wwntouched, wwnmiss;
+int wwnupdate, wwnupdline, wwnupdmiss, wwnmajline, wwnmajmiss;
 
        /* quicky macros */
 #define wwsetcursor(r,c) (wwcursorrow = (r), wwcursorcol = (c))
 
        /* quicky macros */
 #define wwsetcursor(r,c) (wwcursorrow = (r), wwcursorcol = (c))
index 9ea336b..c9509fb 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwadd.c     3.6 83/11/23";
+static char *sccsid = "@(#)wwadd.c     3.7 83/12/02";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -11,8 +11,8 @@ wwadd(w1, w2)
 register struct ww *w1;
 struct ww *w2;
 {
 register struct ww *w1;
 struct ww *w2;
 {
-       register struct ww *w;
        register i;
        register i;
+       register struct ww *w;
 
        w1->ww_order = w2->ww_order + 1;
        w1->ww_back = w2;
 
        w1->ww_order = w2->ww_order + 1;
        w1->ww_back = w2;
@@ -23,32 +23,32 @@ struct ww *w2;
        for (w = w1->ww_forw; w != &wwhead; w = w->ww_forw)
                w->ww_order++;
        for (i = w1->ww_i.t; i < w1->ww_i.b; i++) {
        for (w = w1->ww_forw; w != &wwhead; w = w->ww_forw)
                w->ww_order++;
        for (i = w1->ww_i.t; i < w1->ww_i.b; i++) {
-               register j = w1->ww_i.l;
-               register char *smap = &wwsmap[i][j];
-               register char *win = &w1->ww_win[i][j];
+               register j;
+               register char *smap = wwsmap[i];
+               register char *win = w1->ww_win[i];
+               union ww_char *ns = wwns[i];
+               union ww_char *buf = w1->ww_buf[i];
                int nvis = 0;
                int nvis = 0;
+               int nchanged = 0;
 
                for (j = w1->ww_i.l; j < w1->ww_i.r; j++) {
 
                for (j = w1->ww_i.l; j < w1->ww_i.r; j++) {
-                       w = wwindex[*smap];
-                       if (w1->ww_order > w->ww_order) {
-                               win++;
-                               smap++;
+                       w = wwindex[smap[j]];
+                       if (w1->ww_order > w->ww_order)
                                continue;
                                continue;
-                       }
-                       if (*win & WWM_GLS) {
-                               win++;
-                               smap++;
+                       if (win[j] & WWM_GLS)
                                continue;
                                continue;
-                       }
                        if (w != &wwnobody && w->ww_win[i][j] == 0)
                                w->ww_nvis[i]--;
                        if (w != &wwnobody && w->ww_win[i][j] == 0)
                                w->ww_nvis[i]--;
-                       *smap++ = w1->ww_index;
-                       if (*win == 0)
+                       smap[j] = w1->ww_index;
+                       if (win[j] == 0)
                                nvis++;
                                nvis++;
-                       wwns[i][j].c_w = w1->ww_buf[i][j].c_w ^
-                               *win++ << WWC_MSHIFT;
-                       wwtouched[i] = 1;
+                       ns[j].c_w = buf[j].c_w ^ win[j] << WWC_MSHIFT;
+                       nchanged++;
                }
                }
+               if (nchanged > 4)
+                       wwtouched[i] |= WWU_MAJOR|WWU_TOUCHED;
+               else if (nchanged > 0)
+                       wwtouched[i] |= WWU_TOUCHED;
                w1->ww_nvis[i] = nvis;
        }
 }
                w1->ww_nvis[i] = nvis;
        }
 }
index 8eaaff2..b3558a4 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwclreol.c  3.10 83/12/02";
+static char *sccsid = "@(#)wwclreol.c  3.11 83/12/02";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -45,37 +45,35 @@ char cleared;
        {
                register union ww_char *s;
                register char *smap, *win;
        {
                register union ww_char *s;
                register char *smap, *win;
-               register char *touched;
 
                i = col;
                smap = &wwsmap[row][i];
 
                i = col;
                smap = &wwsmap[row][i];
-               s = &wwns[row][i];
+               s = wwns[row];
                win = w->ww_win[row];
                win = w->ww_win[row];
-               touched = &wwtouched[row];
                ncleared = nblank = 0;
 
                for (; i < w->ww_i.r; i++) {
                        if (*smap++ != w->ww_index) {
                ncleared = nblank = 0;
 
                for (; i < w->ww_i.r; i++) {
                        if (*smap++ != w->ww_index) {
-                               if (s++->c_w == ' ')
+                               if (s[i].c_w == ' ')
                                        nblank++;
                                        nblank++;
-                               continue;
-                       }
-                       ncleared++; 
-                       *touched = 1;
-                       if (win[i] == 0) {
+                       } else if (win[i] == 0) {
                                nblank++;
                                nblank++;
-                               s++->c_w = ' ';
+                               if (s[i].c_w != ' ') {
+                                       ncleared++; 
+                                       s[i].c_w = ' ';
+                               }
                        } else
                        } else
-                               s++->c_w = ' ' | win[i] << WWC_MSHIFT;
+                               s[i].c_w = ' ' | win[i] << WWC_MSHIFT;
                }
                }
+               if (ncleared > 0)
+                       wwtouched[row] |= WWU_TOUCHED;
        }
 
        /*
         * Can/Should we use clear eol?
         */
        if (!cleared && tt.tt_clreol != 0
        }
 
        /*
         * Can/Should we use clear eol?
         */
        if (!cleared && tt.tt_clreol != 0
-           && ncleared > wwncol - col - nblank
-           && nblank > (wwncol - col) / 2) {
+           && ncleared > wwncol - col - nblank + 4) {
                register union ww_char *s;
 
                /* clear to the end */
                register union ww_char *s;
 
                /* clear to the end */
index b393ffe..785f837 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwcursor.c  3.4 83/11/23";
+static char *sccsid = "@(#)wwcursor.c  3.5 83/12/02";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -30,7 +30,7 @@ register struct ww *w;
                        else if (*win == wwcursormodes)
                                w->ww_nvis[w->ww_cur.r]--;
                        wwns[w->ww_cur.r][w->ww_cur.c].c_m ^= wwcursormodes;
                        else if (*win == wwcursormodes)
                                w->ww_nvis[w->ww_cur.r]--;
                        wwns[w->ww_cur.r][w->ww_cur.c].c_m ^= wwcursormodes;
-                       wwtouched[w->ww_cur.r] = 1;
+                       wwtouched[w->ww_cur.r] |= WWU_TOUCHED;
                }
        }
 }
                }
        }
 }
index c5bb62f..0d69a9b 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwdelchar.c 3.8 83/12/02";
+static char *sccsid = "@(#)wwdelchar.c 3.9 83/12/02";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -59,7 +59,7 @@ register struct ww *w;
                for (; i < w->ww_i.r; i++) {
                        if (*smap++ != w->ww_index)
                                continue;
                for (; i < w->ww_i.r; i++) {
                        if (*smap++ != w->ww_index)
                                continue;
-                       touched = 1;
+                       touched |= WWU_TOUCHED;
                        if (win[i])
                                ns[i].c_w =
                                        buf[i].c_w ^ win[i] << WWC_MSHIFT;
                        if (win[i])
                                ns[i].c_w =
                                        buf[i].c_w ^ win[i] << WWC_MSHIFT;
index 04099a5..28b8a90 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwdelete.c  3.10 83/11/29";
+static char *sccsid = "@(#)wwdelete.c  3.11 83/12/02";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -16,14 +16,18 @@ register struct ww *w;
                register j;
                register char *smap = wwsmap[i];
                register struct ww_char *ns = wwns[i];
                register j;
                register char *smap = wwsmap[i];
                register struct ww_char *ns = wwns[i];
-               register char *touched = &wwtouched[i];
+               register int nchanged = 0;
 
                for (j = w->ww_i.l; j < w->ww_i.r; j++)
                        if (smap[j] == w->ww_index) {
                                smap[j] = WWX_NOBODY;
                                ns[j].c_w = ' ';
 
                for (j = w->ww_i.l; j < w->ww_i.r; j++)
                        if (smap[j] == w->ww_index) {
                                smap[j] = WWX_NOBODY;
                                ns[j].c_w = ' ';
-                               *touched = 1;
+                               nchanged++;
                        }
                        }
+               if (nchanged > 4)
+                       wwtouched[i] |= WWU_MAJOR|WWU_TOUCHED;
+               else if (nchanged > 0)
+                       wwtouched[i] |= WWU_TOUCHED;
        }
 
        {
        }
 
        {
@@ -67,7 +71,7 @@ again:
                register char *win = w->ww_win[i];
                register union ww_char *buf = w->ww_buf[i];
                int nvis = w->ww_nvis[i];
                register char *win = w->ww_win[i];
                register union ww_char *buf = w->ww_buf[i];
                int nvis = w->ww_nvis[i];
-               char touched = wwtouched[i];
+               int nchanged = 0;
 
                for (j = ll; j < rr; j++) {
                        if (smap[j] != WWX_NOBODY)
 
                for (j = ll; j < rr; j++) {
                        if (smap[j] != WWX_NOBODY)
@@ -78,11 +82,14 @@ again:
                        }
                        smap[j] = w->ww_index;
                        ns[j].c_w = buf[j].c_w ^ win[j] << WWC_MSHIFT;
                        }
                        smap[j] = w->ww_index;
                        ns[j].c_w = buf[j].c_w ^ win[j] << WWC_MSHIFT;
-                       touched = 1;
+                       nchanged++;
                        if (win[j] == 0)
                                nvis++;
                }
                        if (win[j] == 0)
                                nvis++;
                }
-               wwtouched[i] = touched;
+               if (nchanged > 4)
+                       wwtouched[i] |= WWU_MAJOR|WWU_TOUCHED;
+               else if (nchanged > 0)
+                       wwtouched[i] |= WWU_TOUCHED;
                w->ww_nvis[i] = nvis;
        }
        if ((w = w->ww_forw) == &wwhead)
                w->ww_nvis[i] = nvis;
        }
        if ((w = w->ww_forw) == &wwhead)
index 5190cce..4995897 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwframe.c   3.11 83/11/23";
+static char *sccsid = "@(#)wwframe.c   3.12 83/12/02";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -206,7 +206,7 @@ char code;
                frame = tt.tt_frame[code & WWF_MASK] & WWC_CMASK;
                f->ww_buf[r][c].c_w = frame;
                if (wwsmap[r][c] == f->ww_index) {
                frame = tt.tt_frame[code & WWF_MASK] & WWC_CMASK;
                f->ww_buf[r][c].c_w = frame;
                if (wwsmap[r][c] == f->ww_index) {
-                       wwtouched[r] = 1;
+                       wwtouched[r] |= WWU_TOUCHED;
                        wwns[r][c].c_w = frame;
                }
        }
                        wwns[r][c].c_w = frame;
                }
        }
index 5f0ce20..c92c127 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwinit.c    3.11 83/11/02";
+static char *sccsid = "@(#)wwinit.c    3.12 83/12/02";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
index 58740aa..3036a1c 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwinschar.c 3.11 83/12/02";
+static char *sccsid = "@(#)wwinschar.c 3.12 83/12/02";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -60,7 +60,7 @@ short c;
                for (; i < w->ww_i.r; i++) {
                        if (*smap++ != w->ww_index)
                                continue;
                for (; i < w->ww_i.r; i++) {
                        if (*smap++ != w->ww_index)
                                continue;
-                       touched = 1;
+                       touched |= WWU_TOUCHED;
                        if (win[i])
                                ns[i].c_w =
                                        buf[i].c_w ^ win[i] << WWC_MSHIFT;
                        if (win[i])
                                ns[i].c_w =
                                        buf[i].c_w ^ win[i] << WWC_MSHIFT;
index c160dfa..ebbc00b 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwlabel.c   3.9 83/12/02";
+static char *sccsid = "@(#)wwlabel.c   3.10 83/12/02";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -51,7 +51,7 @@ char *l;
                        else {
                                ns[j].c_w = (buf[j].c_w = mode | *p)
                                                ^ win[j] << WWC_MSHIFT;
                        else {
                                ns[j].c_w = (buf[j].c_w = mode | *p)
                                                ^ win[j] << WWC_MSHIFT;
-                               touched = 1;
+                               touched |= WWU_TOUCHED;
                        }
                        fmap[j] |= WWF_LABEL;
                }
                        }
                        fmap[j] |= WWF_LABEL;
                }
index 77457a6..08bcd41 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwredraw.c  3.4 83/08/16";
+static char *sccsid = "@(#)wwredraw.c  3.5 83/12/02";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -12,7 +12,7 @@ wwredraw()
 
        (*tt.tt_clear)();
        for (i = 0; i < wwnrow; i++) {
 
        (*tt.tt_clear)();
        for (i = 0; i < wwnrow; i++) {
-               wwtouched[i] = 1;
+               wwtouched[i] = WWU_TOUCHED;
                os = wwos[i];
                for (j = wwncol; --j >= 0;)
                        (os++)->c_w = ' ';
                os = wwos[i];
                for (j = wwncol; --j >= 0;)
                        (os++)->c_w = ' ';
index cdb6d14..a84c8b0 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwredrawwin.c       3.7 83/12/02";
+static char *sccsid = "@(#)wwredrawwin.c       3.8 83/12/02";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -14,20 +14,24 @@ int row1, row2, offset;
        register union ww_char *buf;
        register char *win;
        register union ww_char *ns;
        register union ww_char *buf;
        register char *win;
        register union ww_char *ns;
-       char *touched;
+       int nchanged;
 
 
-       touched = &wwtouched[row1];
-       for (row = row1; row < row2; row++, touched++) {
+       for (row = row1; row < row2; row++) {
                col = w->ww_i.l;
                ns = wwns[row];
                smap = &wwsmap[row][col];
                buf = w->ww_buf[row + offset];
                win = w->ww_win[row];
                col = w->ww_i.l;
                ns = wwns[row];
                smap = &wwsmap[row][col];
                buf = w->ww_buf[row + offset];
                win = w->ww_win[row];
+               nchanged = 0;
                for (; col < w->ww_i.r; col++)
                        if (*smap++ == w->ww_index) {
                for (; col < w->ww_i.r; col++)
                        if (*smap++ == w->ww_index) {
-                               *touched = 1;
+                               nchanged++;
                                ns[col].c_w =
                                        buf[col].c_w ^ win[col] << WWC_MSHIFT;
                        }
                                ns[col].c_w =
                                        buf[col].c_w ^ win[col] << WWC_MSHIFT;
                        }
+               if (nchanged > 4)
+                       wwtouched[row] |= WWU_MAJOR|WWU_TOUCHED;
+               else if (nchanged > 0)
+                       wwtouched[row] |= WWU_TOUCHED;
        }
 }
        }
 }
index 9e6936c..6ef0f4e 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwscroll.c  3.10 83/09/15";
+static char *sccsid = "@(#)wwscroll.c  3.11 83/12/02";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -151,13 +151,13 @@ int leaveit;
                                q = p + 1;
                                for (i = row2x - row1x; --i > 0;)
                                        *p++ = *q++;
                                q = p + 1;
                                for (i = row2x - row1x; --i > 0;)
                                        *p++ = *q++;
-                               *p = 1;
+                               *p |= WWU_TOUCHED;
                        } else {
                                register char *p;
 
                                p = &wwtouched[row1x];
                                for (i = row2x - row1x; --i >= 0;)
                        } else {
                                register char *p;
 
                                p = &wwtouched[row1x];
                                for (i = row2x - row1x; --i >= 0;)
-                                       *p++ = 1;
+                                       *p++ |= WWU_MAJOR|WWU_TOUCHED;
                        }
                        wwredrawwin1(w, row1, row1x, dir);
                        wwredrawwin1(w, row2x - 1, row2 - leaveit, dir);
                        }
                        wwredrawwin1(w, row1, row1x, dir);
                        wwredrawwin1(w, row2x - 1, row2 - leaveit, dir);
@@ -180,13 +180,13 @@ int leaveit;
                                q = p - 1;
                                for (i = row2x - row1x; --i > 0;)
                                        *--p = *--q;
                                q = p - 1;
                                for (i = row2x - row1x; --i > 0;)
                                        *--p = *--q;
-                               *q = 1;
+                               *q |= WWU_MAJOR|WWU_TOUCHED;
                        } else {
                                register char *p;
 
                                p = &wwtouched[row1x];
                                for (i = row2x - row1x; --i >= 0;)
                        } else {
                                register char *p;
 
                                p = &wwtouched[row1x];
                                for (i = row2x - row1x; --i >= 0;)
-                                       *p++ = 1;
+                                       *p++ |= WWU_TOUCHED;
                        }
                        wwredrawwin1(w, row1 + leaveit, row1x + 1, dir);
                        wwredrawwin1(w, row2x, row2, dir);
                        }
                        wwredrawwin1(w, row1 + leaveit, row1x + 1, dir);
                        wwredrawwin1(w, row2x, row2, dir);
index b718554..05e5b8a 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwunframe.c 3.11 83/11/28";
+static char *sccsid = "@(#)wwunframe.c 3.12 83/12/02";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -15,7 +15,7 @@ register struct ww *w;
                register char *fmap = w->ww_fmap ? w->ww_fmap[i] : 0;
                register char *smap = wwsmap[i];
                register struct ww_char *ns = wwns[i];
                register char *fmap = w->ww_fmap ? w->ww_fmap[i] : 0;
                register char *smap = wwsmap[i];
                register struct ww_char *ns = wwns[i];
-               char touched = wwtouched[i];
+               int nchanged = 0;
 
                for (j = w->ww_i.l; j < w->ww_i.r; j++) {
                        if (win[j] & WWM_GLS)
 
                for (j = w->ww_i.l; j < w->ww_i.r; j++) {
                        if (win[j] & WWM_GLS)
@@ -26,10 +26,13 @@ register struct ww *w;
                        if (smap[j] == w->ww_index) {
                                smap[j] = WWX_NOBODY;
                                ns[j].c_w = ' ';
                        if (smap[j] == w->ww_index) {
                                smap[j] = WWX_NOBODY;
                                ns[j].c_w = ' ';
-                               touched = 1;
+                               nchanged++;
                        }
                }
                        }
                }
-               wwtouched[i] = touched;
+               if (nchanged > 4)
+                       wwtouched[i] |= WWU_MAJOR|WWU_TOUCHED;
+               else if (nchanged > 0)
+                       wwtouched[i] |= WWU_TOUCHED;
                w->ww_nvis[i] = 0;
        }
 
                w->ww_nvis[i] = 0;
        }
 
index 6cc0dda..2025b08 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwupdate.c  3.8 83/09/15";
+static char *sccsid = "@(#)wwupdate.c  3.9 83/12/02";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -22,12 +22,36 @@ wwupdate()
        for (i = 0, touched = wwtouched; i < wwnrow; i++, touched++) {
                if (!*touched)
                        continue;
        for (i = 0, touched = wwtouched; i < wwnrow; i++, touched++) {
                if (!*touched)
                        continue;
-               wwntouched++;
-               *touched = 0;
+               if (*touched & WWU_MAJOR) {
+                       int ncleared = 0;
+                       int nsame = 0;
 
 
+                       wwnmajline++;
+                       j = wwncol;
+                       ns = wwns[i];
+                       os = wwos[i];
+                       while (--j >= 0) {
+                               if (ns->c_w == ' ') {
+                                       if (ns->c_w != os->c_w)
+                                               ncleared++;
+                               } else
+                                       if (ns->c_w == os->c_w)
+                                               nsame++;
+                               ns++;
+                               os++;
+                       }
+                       if (tt.tt_clreol != 0 && ncleared > nsame + 4) {
+                               (*tt.tt_move)(i, 0);
+                               (*tt.tt_clreol)();
+                               for (j = wwncol, os = wwos[i]; --j >= 0;)
+                                       os++->c_w = ' ';
+                       } else
+                               wwnmajmiss++;
+               }
+               wwnupdline++;
+               didit = 0;
                ns = wwns[i];
                os = wwos[i];
                ns = wwns[i];
                os = wwos[i];
-               didit = 0;
                for (j = 0; j < wwncol;) {
                        for (; j++ < wwncol && ns++->c_w == os++->c_w;)
                                ;
                for (j = 0; j < wwncol;) {
                        for (; j++ < wwncol && ns++->c_w == os++->c_w;)
                                ;
@@ -74,6 +98,7 @@ wwupdate()
                        didit++;
                }
                if (!didit)
                        didit++;
                }
                if (!didit)
-                       wwnmiss++;
+                       wwnupdmiss++;
+               *touched = 0;
        }
 }
        }
 }
index d1c282e..80465dc 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwwrite.c   3.13 83/09/15";
+static char *sccsid = "@(#)wwwrite.c   3.14 83/12/02";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -20,9 +20,9 @@ int n;
                        register i;
                        register union ww_char *bp;
                        union ww_char *bq;
                        register i;
                        register union ww_char *bp;
                        union ww_char *bq;
-                       int col;
+                       int col, col1;
 
 
-                       if (w->ww_insert) {
+                       if (w->ww_insert) {     /* this is very slow */
                                n--;
                                wwinschar(w, w->ww_cur.r, w->ww_cur.c,
                                        *p++ | w->ww_modes << WWC_MSHIFT);
                                n--;
                                wwinschar(w, w->ww_cur.r, w->ww_cur.c,
                                        *p++ | w->ww_modes << WWC_MSHIFT);
@@ -37,40 +37,25 @@ int n;
 
                        i = bp - bq;
                        n -= i;
 
                        i = bp - bq;
                        n -= i;
-                       col = w->ww_cur.c;
+                       col = MAX(w->ww_cur.c, w->ww_i.l);
                        w->ww_cur.c += i;
                        w->ww_cur.c += i;
-                       bp = bq;
-                       if (col < w->ww_i.l) {
-                               /* use col as a temporary */
-                               col = w->ww_i.l - col;
-                               bp += col;
-                               i -= col;
-                               col = w->ww_i.l;
-                       }
-                       if (i > w->ww_i.r - col)
-                               i = w->ww_i.r - col;
+                       col1 = MIN(w->ww_cur.c, w->ww_i.r);
 
                        if (w->ww_cur.r >= w->ww_i.t && w->ww_cur.r < w->ww_i.b)
                        {
 
                        if (w->ww_cur.r >= w->ww_i.t && w->ww_cur.r < w->ww_i.b)
                        {
-                               register union ww_char *ns;
-                               register char *smap;
-                               register char *win;
-                               char *touched;
+                               register union ww_char *ns = wwns[w->ww_cur.r];
+                               register char *smap = &wwsmap[w->ww_cur.r][col];
+                               register char *win = w->ww_win[w->ww_cur.r];
+                               char touched = wwtouched[w->ww_cur.r];
 
 
-                               win = &w->ww_win[w->ww_cur.r][col];
-                               smap = &wwsmap[w->ww_cur.r][col];
-                               ns = &wwns[w->ww_cur.r][col];
-                               touched = &wwtouched[w->ww_cur.r];
-                               while (--i >= 0)
+                               bp = w->ww_buf[w->ww_cur.r];
+                               for (i = col; i < col1; i++)
                                        if (*smap++ == w->ww_index) {
                                        if (*smap++ == w->ww_index) {
-                                               *touched = 1;
-                                               ns++->c_w = bp++->c_w
-                                                       ^ *win++ << WWC_MSHIFT;
-                                       } else {
-                                               ns++;
-                                               bp++;
-                                               win++;
+                                               touched |= WWU_TOUCHED;
+                                               ns[i].c_w = bp[i].c_w
+                                                       ^ win[i] << WWC_MSHIFT;
                                        }
                                        }
+                               wwtouched[w->ww_cur.r] = touched;
                        }
                        if (w->ww_cur.c >= w->ww_w.r) {
                                w->ww_cur.c = w->ww_w.l;
                        }
                        if (w->ww_cur.c >= w->ww_w.r) {
                                w->ww_cur.c = w->ww_w.l;