added depend label
[unix-history] / usr / src / usr.bin / ex / ex_vadj.c
index 2f1c174..03e8c54 100644 (file)
@@ -1,5 +1,13 @@
-/* Copyright (c) 1981 Regents of the University of California */
-static char *sccsid = "@(#)ex_vadj.c   7.1     %G%";
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef lint
+static char *sccsid = "@(#)ex_vadj.c   7.10 (Berkeley) %G%";
+#endif not lint
+
 #include "ex.h"
 #include "ex_tty.h"
 #include "ex_vis.h"
 #include "ex.h"
 #include "ex_tty.h"
 #include "ex_vis.h"
@@ -64,12 +72,12 @@ vopen(tp, p)
         * If we are opening at the top of the window, can try a window
         * expansion at the top.
         */
         * If we are opening at the top of the window, can try a window
         * expansion at the top.
         */
-       if (state == VISUAL && vcline == 0 && vcnt > 1 && p > ZERO) {
+       if (state == VISUAL && vcline == 0 && vcnt > 1 && p > ex_ZERO) {
                cnt = p + vdepth() - LINE(1);
                if (cnt > 0) {
                        p -= cnt;
                cnt = p + vdepth() - LINE(1);
                if (cnt > 0) {
                        p -= cnt;
-                       if (p < ZERO)
-                               p = ZERO;
+                       if (p < ex_ZERO)
+                               p = ex_ZERO;
                        WTOP = p;
                        WLINES = WBOT - WTOP + 1;
                }
                        WTOP = p;
                        WLINES = WBOT - WTOP + 1;
                }
@@ -120,8 +128,8 @@ vreopen(p, lineno, l)
         */
        if (hold & HOLDDOL)
                return (d);
         */
        if (hold & HOLDDOL)
                return (d);
-       if (Putchar == listchar)
-               putchar('$');
+       if (Put_char == listchar)
+               ex_putchar('$');
 
        /*
         * Optimization of cursor motion may prevent screen rollup if the
 
        /*
         * Optimization of cursor motion may prevent screen rollup if the
@@ -182,7 +190,7 @@ vglitchup(l, o)
        if (l < vcnt - 1) {
                need = p + vp->vdepth - (vp+1)->vliny;
                if (need > 0) {
        if (l < vcnt - 1) {
                need = p + vp->vdepth - (vp+1)->vliny;
                if (need > 0) {
-                       if (state == VISUAL && WTOP - ZERO >= need && AL && DL) {
+                       if (state == VISUAL && WTOP - ex_ZERO >= need && AL && DL) {
                                glitched++;
                                WTOP -= need;
                                WLINES = WBOT - WTOP + 1;
                                glitched++;
                                WTOP -= need;
                                WLINES = WBOT - WTOP + 1;
@@ -239,7 +247,7 @@ vinslin(p, cnt, l)
                for (i = cnt; i > 0; i--) {
                        vgoto(p, 0), vputp(SR, 0);
                        if (i > 1 && (hold & HOLDAT) == 0)
                for (i = cnt; i > 0; i--) {
                        vgoto(p, 0), vputp(SR, 0);
                        if (i > 1 && (hold & HOLDAT) == 0)
-                               putchar('@');
+                               ex_putchar('@');
                        /*
                         * If we are at the top of the screen, and the
                         * terminal retains display above, then we
                        /*
                         * If we are at the top of the screen, and the
                         * terminal retains display above, then we
@@ -256,18 +264,28 @@ vinslin(p, cnt, l)
                 * Use insert line.
                 */
                vgoto(p, 0);
                 * Use insert line.
                 */
                vgoto(p, 0);
-               if (XV)
-                       vputp(tgoto(AL, 0, p), WECHO + 1 - p);
-               else
+               if (AL_PARM && (cnt>1 || *AL==0)) {
+                       /* insert cnt lines.  Should do @'s too. */
+                       vputp(tgoto(AL_PARM, p, cnt), WECHO+1-p);
+               }
+               else if (CS && *AL==0) {
+                       /* vt100 change scrolling region to fake AL */
+                       vputp(SC, 1);
+                       vputp(tgoto(CS, LINES-1,p), 1);
+                       vputp(RC, 1);   /* CS homes stupid cursor */
+                       for (i=cnt; i>0; i--)
+                               vputp(SR, 1);   /* should do @'s */
+                       vputp(tgoto(CS, LINES-1,0), 1);
+                       vputp(RC, 1);   /* Once again put it back */
+               }
+               else {
                        vputp(AL, WECHO + 1 - p);
                        vputp(AL, WECHO + 1 - p);
-               for (i = cnt - 1; i > 0; i--) {
-                       vgoto(outline+1, 0);
-                       if (XV)
-                               vputp(tgoto(AL, 0, outline+1), WECHO + 1 - outline);
-                       else
+                       for (i = cnt - 1; i > 0; i--) {
+                               vgoto(outline+1, 0);
                                vputp(AL, WECHO + 1 - outline);
                                vputp(AL, WECHO + 1 - outline);
-                       if ((hold & HOLDAT) == 0)
-                               putchar('@');
+                               if ((hold & HOLDAT) == 0)
+                                       ex_putchar('@');
+                       }
                }
                vadjAL(p, cnt);
        } else
                }
                vadjAL(p, cnt);
        } else
@@ -398,6 +416,9 @@ vmoveitup(cnt, doclr)
        if (doclr && (SO || SE))
                vclrech(0);
        if (SF) {
        if (doclr && (SO || SE))
                vclrech(0);
        if (SF) {
+               destline = WECHO;
+               destcol = (NONL ? 0 : outcol % WCOLS);
+               fgoto();
                while (cnt > 0)
                        vputp(SF, 0), cnt--;
                return;
                while (cnt > 0)
                        vputp(SF, 0), cnt--;
                return;
@@ -429,9 +450,9 @@ vscroll(cnt)
        if (cnt == 0)
                return;
        copy(tlines, vtube, sizeof vtube);
        if (cnt == 0)
                return;
        copy(tlines, vtube, sizeof vtube);
-       for (to = ZERO, from = ZERO + cnt; to <= WECHO - cnt; to++, from++)
+       for (to = ex_ZERO, from = ex_ZERO + cnt; to <= WECHO - cnt; to++, from++)
                vtube[to] = tlines[from];
                vtube[to] = tlines[from];
-       for (from = ZERO; to <= WECHO; to++, from++) {
+       for (from = ex_ZERO; to <= WECHO; to++, from++) {
                vtube[to] = tlines[from];
                vclrbyte(vtube[to], WCOLS);
        }
                vtube[to] = tlines[from];
                vclrbyte(vtube[to], WCOLS);
        }
@@ -452,7 +473,7 @@ vscrap()
 #endif
        if (splitw)
                return;
 #endif
        if (splitw)
                return;
-       if (vcnt && WBOT != WECHO && LINE(0) < WTOP && LINE(0) >= ZERO) {
+       if (vcnt && WBOT != WECHO && LINE(0) < WTOP && LINE(0) >= ex_ZERO) {
                WTOP = LINE(0);
                WLINES = WBOT - WTOP + 1;
        }
                WTOP = LINE(0);
                WLINES = WBOT - WTOP + 1;
        }
@@ -500,7 +521,7 @@ vrepaint(curs)
        /*
         * In open want to notify first.
         */
        /*
         * In open want to notify first.
         */
-       noteit(0);
+       ignore(noteit(0));
        vscrap();
 
        /*
        vscrap();
 
        /*
@@ -519,7 +540,7 @@ vrepaint(curs)
                if (odol == zero)
                        fixzero();
                vcontext(dot, '.');
                if (odol == zero)
                        fixzero();
                vcontext(dot, '.');
-               noteit(1);
+               ignore(noteit(1));
                if (noteit(1) == 0 && odol == zero) {
                        CATCH
                                error("No lines in buffer");
                if (noteit(1) == 0 && odol == zero) {
                        CATCH
                                error("No lines in buffer");
@@ -569,7 +590,7 @@ vrepaint(curs)
         * has to be done last or we may lose
         * the echo area with redisplay.
         */
         * has to be done last or we may lose
         * the echo area with redisplay.
         */
-       noteit(1);
+       ignore(noteit(1));
 
        /*
         * Finally.  Move the cursor onto the current line.
 
        /*
         * Finally.  Move the cursor onto the current line.
@@ -624,7 +645,7 @@ vredraw(p)
         */
        heldech = 0;
        hold |= HOLDECH;
         */
        heldech = 0;
        hold |= HOLDECH;
-       for (; l < vcnt && Peekkey != ATTN; l++) {
+       for (; l < vcnt && Peek_key != ATTN; l++) {
                if (l == vcline)
                        strcLIN(temp);
                else
                if (l == vcline)
                        strcLIN(temp);
                else
@@ -656,7 +677,7 @@ vredraw(p)
                                break;
                        }
                        FLAGS(l) &= ~VDIRT;
                                break;
                        }
                        FLAGS(l) &= ~VDIRT;
-                       vreopen(p, lineno(tp), l);
+                       ignore(vreopen(p, lineno(tp), l));
                        p = LINE(l) + DEPTH(l);
                } else
                        p += DEPTH(l);
                        p = LINE(l) + DEPTH(l);
                } else
                        p += DEPTH(l);
@@ -671,7 +692,7 @@ vredraw(p)
                int ovcline = vcline;
 
                vcline = l;
                int ovcline = vcline;
 
                vcline = l;
-               for (; tp <= dol && Peekkey != ATTN; tp++) {
+               for (; tp <= dol && Peek_key != ATTN; tp++) {
                        getline(*tp);
                        if (p + vdepth() - 1 > WBOT)
                                break;
                        getline(*tp);
                        if (p + vdepth() - 1 > WBOT)
                                break;
@@ -687,7 +708,7 @@ vredraw(p)
         * Now rest of lines (if any) get either a ~ if they
         * are past end of file, or an @ if the next line won't fit.
         */
         * Now rest of lines (if any) get either a ~ if they
         * are past end of file, or an @ if the next line won't fit.
         */
-       for (; p <= WBOT && Peekkey != ATTN; p++)                       
+       for (; p <= WBOT && Peek_key != ATTN; p++)                      
                vclrlin(p, tp);
        strcLIN(temp);
        hold = oldhold;
                vclrlin(p, tp);
        strcLIN(temp);
        hold = oldhold;
@@ -726,11 +747,23 @@ vdellin(p, cnt, l)
         * and physical internal data structures.
         */
        vgoto(p, 0);
         * and physical internal data structures.
         */
        vgoto(p, 0);
-       for (i = 0; i < cnt; i++)
-               if (XV)
-                       vputp(tgoto(DL, 0, p), WECHO - p);
-               else
+       if (DL_PARM && (cnt>1 || *DL==0)) {
+               vputp(tgoto(DL_PARM, p, cnt), WECHO-p);
+       }
+       else if (CS && *DL==0) {
+               /* vt100: fake DL by changing scrolling region */
+               vputp(SC, 1);   /* Save since CS homes stupid cursor */
+               vputp(tgoto(CS, LINES-1, p), 1);
+               vputp(tgoto(CM, 0, LINES-1), 1);/* Go to lower left corner */
+               for (i=0; i<cnt; i++)           /* .. and scroll cnt times */
+                       putch('\n');            /* should check NL too */
+               vputp(tgoto(CS, LINES-1, 0), 1);/* restore scrolling region */
+               vputp(RC, 1);                   /* put cursor back */
+       }
+       else {
+               for (i = 0; i < cnt; i++)
                        vputp(DL, WECHO - p);
                        vputp(DL, WECHO - p);
+       }
        vadjDL(p, cnt);
        vcloseup(l, cnt);
 }
        vadjDL(p, cnt);
        vcloseup(l, cnt);
 }
@@ -814,7 +847,7 @@ vsync1(p)
                l++, vp++;
        heldech = 0;
        hold |= HOLDECH;
                l++, vp++;
        heldech = 0;
        hold |= HOLDECH;
-       while (p <= WBOT && Peekkey != ATTN) {
+       while (p <= WBOT && Peek_key != ATTN) {
                /*
                 * Want to put a line here if not in visual and first line
                 * or if there are lies left and this line starts before
                /*
                 * Want to put a line here if not in visual and first line
                 * or if there are lies left and this line starts before
@@ -838,7 +871,7 @@ vsync1(p)
                                        if (p + vp->vdepth - 1 > WBOT)
                                                break;
                                }
                                        if (p + vp->vdepth - 1 > WBOT)
                                                break;
                                }
-                               vreopen(p, lineDOT() + (l - vcline), l);
+                               ignore(vreopen(p, lineDOT() + (l - vcline), l));
                        }
                        p = vp->vliny + vp->vdepth;
                        vp++;
                        }
                        p = vp->vliny + vp->vdepth;
                        vp++;
@@ -1035,7 +1068,7 @@ sethard()
        vup1();
        LINE(0) = WBOT;
        if (Pline == numbline)
        vup1();
        LINE(0) = WBOT;
        if (Pline == numbline)
-               vgoto(WBOT, 0), printf("%6d  ", lineDOT());
+               vgoto(WBOT, 0), ex_printf("%6d  ", lineDOT());
 }
 
 /*
 }
 
 /*