BSD 1 development
authorBill Joy <wnj@ucbvax.Berkeley.EDU>
Tue, 31 Jan 1978 10:10:18 +0000 (02:10 -0800)
committerBill Joy <wnj@ucbvax.Berkeley.EDU>
Tue, 31 Jan 1978 10:10:18 +0000 (02:10 -0800)
Work on file ex-1.1/ex_vcolumn.c

Synthesized-from: 1bsd

ex-1.1/ex_vcolumn.c [new file with mode: 0644]

diff --git a/ex-1.1/ex_vcolumn.c b/ex-1.1/ex_vcolumn.c
new file mode 100644 (file)
index 0000000..2c7c4b4
--- /dev/null
@@ -0,0 +1,57 @@
+#include "ex.h"
+#include "ex_tty.h"
+#include "ex_vis.h"
+/*
+ * Ex - a text editor
+ * Bill Joy UCB October, 1977
+ */
+
+/*
+ * Column returns the number of
+ * columns occupied by printing the
+ * characters through position cp of the
+ * current line.
+ */
+column(cp)
+       register char *cp;
+{
+
+       if (cp == 0)
+               cp = &linebuf[LBSIZE - 2];
+       return (qcolumn(cp, 0));
+}
+
+qcolumn(lim, gp)
+       register char *lim, *gp;
+{
+       register int x;
+       int (*OO)();
+
+       OO = Outchar;
+       Outchar = &qcount;
+       vcntcol = 0;
+       if (lim != NIL)
+               x = lim[1], lim[1] = 0;
+       pline(0);
+       if (lim != NIL)
+               lim[1] = x;
+       if (gp)
+               while (*gp)
+                       putchar(*gp++);
+       Outchar = OO;
+       return (vcntcol);
+}
+
+qcount(c)
+       char c;
+{
+
+       switch (c) {
+               case '\t':
+                       vcntcol =+ 8;
+                       vcntcol =& ~07;
+                       break;
+               default:
+                       vcntcol++;
+       }
+}