BSD 4 release
[unix-history] / usr / src / cmd / ex / ex_vput.c
index cadd33a..9411f83 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_vput.c   6.1 10/18/80";
 #include "ex.h"
 #include "ex_tty.h"
 #include "ex_vis.h"
 #include "ex.h"
 #include "ex_tty.h"
 #include "ex_vis.h"
@@ -115,10 +116,28 @@ vclrech(didphys)
                 * since we don't really know whats out there.
                 * Vigoto might decide (incorrectly) to do nothing.
                 */
                 * since we don't really know whats out there.
                 * Vigoto might decide (incorrectly) to do nothing.
                 */
-               if (DB)
-                       vgoto(WECHO, 0), vputp(CD ? CD : CE, 1);
-               else
-                       vigoto(WECHO, 0), vclreol();
+               if (DB) {
+                       vgoto(WECHO, 0);
+                       vputp(CD ? CD : CE, 1);
+               } else {
+                       if (XT) {
+                               /*
+                                * This code basically handles the t1061
+                                * where positioning at (0, 0) won't work
+                                * because the terminal won't let you put
+                                * the cursor on it's magic cookie.
+                                *
+                                * Should probably be XS above, or even a
+                                * new X? glitch, but right now t1061 is the
+                                * only terminal with XT.
+                                */
+                               vgoto(WECHO, 0);
+                               vputp(DL, 1);
+                       } else {
+                               vigoto(WECHO, 0);
+                               vclreol();
+                       }
+               }
                splitw = 0;
                didphys = 1;
        }
                splitw = 0;
                didphys = 1;
        }
@@ -399,11 +418,11 @@ vgoto(y, x)
  */
 vgotab()
 {
  */
 vgotab()
 {
-       register int i = (LINE(vcline) - destline) * WCOLS + destcol;
+       register int i = tabcol(destcol, value(TABSTOP)) - destcol;
 
        do
                (*Outchar)(QUOTE);
 
        do
                (*Outchar)(QUOTE);
-       while (++i % value(TABSTOP));
+       while (--i);
 }
 
 /*
 }
 
 /*
@@ -443,7 +462,7 @@ vmaktop(p, cp)
        register int i;
        char temp[TUBECOLS];
 
        register int i;
        char temp[TUBECOLS];
 
-       if (vtube[p] == cp)
+       if (p < 0 || vtube[p] == cp)
                return;
        for (i = ZERO; i <= WECHO; i++)
                if (vtube[i] == cp) {
                return;
        for (i = ZERO; i <= WECHO; i++)
                if (vtube[i] == cp) {
@@ -542,7 +561,7 @@ vinschar(c)
                 * use QUOTE here since we really need to print blanks.
                 * QUOTE|' ' is the representation of this.
                 */
                 * use QUOTE here since we really need to print blanks.
                 * QUOTE|' ' is the representation of this.
                 */
-               inssiz = value(TABSTOP) - inscol % value(TABSTOP);
+               inssiz = tabcol(inscol, value(TABSTOP)) - inscol;
                c = ' ' | QUOTE;
        } else
                inssiz = 1;
                c = ' ' | QUOTE;
        } else
                inssiz = 1;
@@ -618,7 +637,7 @@ vinschar(c)
                 * line is now deeper.  We then do the shift
                 * implied by the insertion.
                 */
                 * line is now deeper.  We then do the shift
                 * implied by the insertion.
                 */
-               if (inssiz >= doomed + value(TABSTOP) - tabstart % value(TABSTOP)) {
+               if (inssiz >= doomed + tabcol(tabstart, value(TABSTOP)) - tabstart) {
                        if (IN)
                                vrigid();
                        vneedpos(value(TABSTOP));
                        if (IN)
                                vrigid();
                        vneedpos(value(TABSTOP));
@@ -696,9 +715,10 @@ vnpins(dosync)
                e = vglitchup(vcline, d);
                vigoto(e, 0); vclreol();
                if (dosync) {
                e = vglitchup(vcline, d);
                vigoto(e, 0); vclreol();
                if (dosync) {
+                       int (*Ooutchar)() = Outchar;
                        Outchar = vputchar;
                        vsync(e + 1);
                        Outchar = vputchar;
                        vsync(e + 1);
-                       Outchar = vinschar;
+                       Outchar = Ooutchar;
                }
        } else {
                vup1();
                }
        } else {
                vup1();
@@ -767,9 +787,12 @@ vishft()
                        goim();
                        up = tp + j * WCOLS - shft;
                        i = shft;
                        goim();
                        up = tp + j * WCOLS - shft;
                        i = shft;
-                       do
-                               vputchar(*up++);
-                       while (--i);
+                       do {
+                               if (*up)
+                                       vputchar(*up++);
+                               else
+                                       break;
+                       } while (--i);
                }
                vigotoCL(tabstart);
                i = shft - (inssiz - doomed);
                }
                vigotoCL(tabstart);
                i = shft - (inssiz - doomed);
@@ -1029,9 +1052,9 @@ vputchar(c)
        if (trace)
                tracec(c);
 #endif
        if (trace)
                tracec(c);
 #endif
-       /* Patch to fix problem of >79 chars on echo line: don't echo extras */
+       /* Fix problem of >79 chars on echo line. */
        if (destcol >= WCOLS-1 && splitw && destline == WECHO)
        if (destcol >= WCOLS-1 && splitw && destline == WECHO)
-               return;
+               pofix();
        if (destcol >= WCOLS) {
                destline += destcol / WCOLS;
                destcol %= WCOLS;
        if (destcol >= WCOLS) {
                destline += destcol / WCOLS;
                destcol %= WCOLS;