lint
[unix-history] / usr / src / usr.bin / window / wwscroll.c
index d7dde86..7b7b3a9 100644 (file)
@@ -1,13 +1,24 @@
-#ifndef lint
-static char sccsid[] = "@(#)wwscroll.c 3.16 %G%";
-#endif
-
 /*
 /*
- * Copyright (c) 1983 Regents of the University of California,
- * All rights reserved.  Redistribution permitted subject to
- * the terms of the Berkeley Software License Agreement.
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
  */
 
+#ifndef lint
+static char sccsid[] = "@(#)wwscroll.c 3.22 (Berkeley) %G%";
+#endif /* not lint */
+
 #include "ww.h"
 #include "tt.h"
 
 #include "ww.h"
 #include "tt.h"
 
@@ -56,7 +67,7 @@ int leaveit;
        int row1x, row2x;
        int nvis;
        int nvismax;
        int row1x, row2x;
        int nvis;
        int nvismax;
-       int deleted = 0;
+       int scrolled = 0;
 
        /*
         * See how many lines on the screen are affected.
 
        /*
         * See how many lines on the screen are affected.
@@ -84,45 +95,19 @@ int leaveit;
        /*
         * If it's a good idea to scroll and the terminal can, then do it.
         */
        /*
         * If it's a good idea to scroll and the terminal can, then do it.
         */
-       if (nvis < nvismax) {
-       } else if (!tt.tt_noscroll && row1x == 0 && row2x == wwnrow && dir > 0)
-       {
-               /*
-                * We're going to assume that a line feed at the
-                * bottom of the screen will cause a scroll, unless
-                * "ns" is set.  This should work at least 99%
-                * of the time.  At any rate, vi seems to do it.
-                */
-               if (tt.tt_row != wwnrow - 1)
-                       (*tt.tt_move)(wwnrow - 1, 0);
-               ttputc('\n');
-               deleted++;
-       } else if (tt.tt_delline && tt.tt_insline) {
-               /*
-                * Don't worry about retain when scrolling down,
-                * but do worry when scrolling up, for hp2621.
-                */
-               if (dir > 0) {
-                       (*tt.tt_move)(row1x, 0);
-                       (*tt.tt_delline)();
-                       if (row2x < wwnrow) {
-                               (*tt.tt_move)(row2x - 1, 0);
-                               (*tt.tt_insline)();
-                       }
-               } else {
-                       if (tt.tt_retain || row2x != wwnrow) {
-                               (*tt.tt_move)(row2x - 1, 0);
-                               (*tt.tt_delline)();
-                       }
-                       (*tt.tt_move)(row1x, 0);
-                       (*tt.tt_insline)();
-               }
-               deleted++;
-       }
+       if (nvis < nvismax / 2)
+               goto no_scroll;         /* not worth it */
+       if ((dir > 0 ? tt.tt_scroll_down == 0 : tt.tt_scroll_up == 0) ||
+           (tt.tt_scroll_top != row1x || tt.tt_scroll_bot != row2x - 1) &&
+           tt.tt_setscroll == 0)
+               if (tt.tt_delline == 0 || tt.tt_insline == 0)
+                       goto no_scroll;
+       xxscroll(dir, row1x, row2x);
+       scrolled = 1;
        /*
         * Fix up the old screen.
         */
        /*
         * Fix up the old screen.
         */
-       if (deleted) {
+       {
                register union ww_char *tmp;
                register union ww_char **cpp, **cqq;
 
                register union ww_char *tmp;
                register union ww_char **cpp, **cqq;
 
@@ -145,6 +130,7 @@ int leaveit;
                        tmp++->c_w = ' ';
        }
 
                        tmp++->c_w = ' ';
        }
 
+no_scroll:
        /*
         * Fix the new screen.
         */
        /*
         * Fix the new screen.
         */
@@ -164,7 +150,7 @@ int leaveit;
                                        *cpp++ = *cqq++;
                                *cpp = tmp;
                        }
                                        *cpp++ = *cqq++;
                                *cpp = tmp;
                        }
-                       if (deleted) {
+                       if (scrolled) {
                                register char *p, *q;
 
                                p = &wwtouched[row1x];
                                register char *p, *q;
 
                                p = &wwtouched[row1x];
@@ -177,7 +163,7 @@ int leaveit;
 
                                p = &wwtouched[row1x];
                                for (i = row2x - row1x; --i >= 0;)
 
                                p = &wwtouched[row1x];
                                for (i = row2x - row1x; --i >= 0;)
-                                       *p++ |= WWU_MAJOR|WWU_TOUCHED;
+                                       *p++ |= 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);
@@ -193,7 +179,7 @@ int leaveit;
                                        *--cpp = *--cqq;
                                *cqq = tmp;
                        }
                                        *--cpp = *--cqq;
                                *cqq = tmp;
                        }
-                       if (deleted) {
+                       if (scrolled) {
                                register char *p, *q;
 
                                p = &wwtouched[row2x];
                                register char *p, *q;
 
                                p = &wwtouched[row2x];
@@ -206,18 +192,18 @@ int leaveit;
 
                                p = &wwtouched[row1x];
                                for (i = row2x - row1x; --i >= 0;)
 
                                p = &wwtouched[row1x];
                                for (i = row2x - row1x; --i >= 0;)
-                                       *p++ |= WWU_MAJOR|WWU_TOUCHED;
+                                       *p++ |= WWU_TOUCHED;
                        }
                        wwredrawwin1(w, row1 + leaveit, row1x + 1, dir);
                        wwredrawwin1(w, row2x, row2, dir);
                }
        } else {
                        }
                        wwredrawwin1(w, row1 + leaveit, row1x + 1, dir);
                        wwredrawwin1(w, row2x, row2, dir);
                }
        } else {
-               if (deleted) {
+               if (scrolled) {
                        register char *p;
 
                        p = &wwtouched[row1x];
                        for (i = row2x - row1x; --i >= 0;)
                        register char *p;
 
                        p = &wwtouched[row1x];
                        for (i = row2x - row1x; --i >= 0;)
-                               *p++ |= WWU_MAJOR|WWU_TOUCHED;
+                               *p++ |= WWU_TOUCHED;
                }
 out:
                if (dir > 0)
                }
 out:
                if (dir > 0)
@@ -225,5 +211,5 @@ out:
                else
                        wwredrawwin1(w, row1 + leaveit, row2, dir);
        }
                else
                        wwredrawwin1(w, row1 + leaveit, row2, dir);
        }
-       return deleted;
+       return scrolled;
 }
 }