BSD 4 release
[unix-history] / usr / src / cmd / ex / ex_vadj.c
index 7837339..47a4868 100644 (file)
@@ -1,4 +1,5 @@
-/* Copyright (c) 1979 Regents of the University of California */
+/* Copyright (c) 1980 Regents of the University of California */
+static char *sccsid = "@(#)ex_vadj.c   6.2 10/23/80";
 #include "ex.h"
 #include "ex_tty.h"
 #include "ex_vis.h"
 #include "ex.h"
 #include "ex_tty.h"
 #include "ex_vis.h"
@@ -88,10 +89,6 @@ vreopen(p, lineno, l)
        register int d;
        register struct vlinfo *vp = &vlinfo[l];
 
        register int d;
        register struct vlinfo *vp = &vlinfo[l];
 
-#ifdef ADEBUG
-       if (trace)
-               tfixnl(), fprintf(trace, "vreopen(%d, %d, %d)\n", p, lineno, l);
-#endif
        d = vp->vdepth;
        if (d == 0 || (vp->vflags & VDIRT))
                vp->vdepth = d = vdepth();
        d = vp->vdepth;
        if (d == 0 || (vp->vflags & VDIRT))
                vp->vdepth = d = vdepth();
@@ -233,21 +230,11 @@ vinslin(p, cnt, l)
                vgoto(p, 0), vputp(CD, cnt);
                vclrech(1);
                vadjAL(p, cnt);
                vgoto(p, 0), vputp(CD, cnt);
                vclrech(1);
                vadjAL(p, cnt);
-       } else if (AL) {
-               /*
-                * Use insert line.
-                */
-               vgoto(p, 0), vputp(AL, WECHO + 1 - p);
-               for (i = cnt - 1; i > 0; i--) {
-                       vgoto(outline+1, 0), vputp(AL, WECHO + 1 - outline);
-                       if ((hold & HOLDAT) == 0)
-                               putchar('@');
-               }
-               vadjAL(p, cnt);
-       } else if (SR && p == WTOP) {
+       } else if (SR && p == WTOP && costSR < costAL) {
                /*
                 * Use reverse scroll mode of the terminal, at
                /*
                 * Use reverse scroll mode of the terminal, at
-                * the top of the window.
+                * the top of the window.  Reverse linefeed works
+                * too, since we only use it from line WTOP.
                 */
                for (i = cnt; i > 0; i--) {
                        vgoto(p, 0), vputp(SR, 0);
                 */
                for (i = cnt; i > 0; i--) {
                        vgoto(p, 0), vputp(SR, 0);
@@ -264,6 +251,17 @@ vinslin(p, cnt, l)
                                vputp(CE, 1);
                }
                vadjAL(p, cnt);
                                vputp(CE, 1);
                }
                vadjAL(p, cnt);
+       } else if (AL) {
+               /*
+                * Use insert line.
+                */
+               vgoto(p, 0), vputp(AL, WECHO + 1 - p);
+               for (i = cnt - 1; i > 0; i--) {
+                       vgoto(outline+1, 0), vputp(AL, WECHO + 1 - outline);
+                       if ((hold & HOLDAT) == 0)
+                               putchar('@');
+               }
+               vadjAL(p, cnt);
        } else
                could = 0;
        vopenup(cnt, could, l);
        } else
                could = 0;
        vopenup(cnt, could, l);
@@ -362,8 +360,8 @@ vrollup(dl)
        cnt = dl - (splitw ? WECHO : WBOT);
        if (splitw && (state == VISUAL || state == CRTOPEN))
                holdupd = 1;
        cnt = dl - (splitw ? WECHO : WBOT);
        if (splitw && (state == VISUAL || state == CRTOPEN))
                holdupd = 1;
-       vscroll(cnt);
        vmoveitup(cnt, 1);
        vmoveitup(cnt, 1);
+       vscroll(cnt);
        destline = dl - cnt, destcol = dc;
 }
 
        destline = dl - cnt, destcol = dc;
 }