removed extra tt_col += n in gen_write
[unix-history] / usr / src / usr.bin / window / tth19.c
index 9d2c703..4469247 100644 (file)
@@ -1,7 +1,13 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)tth19.c     3.11 83/12/17";
+static char sccsid[] = "@(#)tth19.c    3.16 %G%";
 #endif
 
 #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.
+ */
+
 #include "ww.h"
 #include "tt.h"
 
 #include "ww.h"
 #include "tt.h"
 
@@ -28,12 +34,12 @@ short h19_frame[16] = {
        'c'|G,  't'|G,  's'|G,  'b'|G
 };
 
        'c'|G,  't'|G,  's'|G,  'b'|G
 };
 
-extern char *gen_VS;
-extern char *gen_VE;
+extern struct tt_str *gen_VS;
+extern struct tt_str *gen_VE;
 
 int h19_msp10c;
 
 
 int h19_msp10c;
 
-#define pc(c)  putchar('c')
+#define pc(c)  ttputc('c')
 #define esc()  pc(\033)
 #define PAD(ms10) { \
        register i; \
 #define esc()  pc(\033)
 #define PAD(ms10) { \
        register i; \
@@ -43,7 +49,12 @@ int h19_msp10c;
 #define ICPAD() PAD((NCOL - tt.tt_col) * 1)    /* 0.1 ms per char */
 #define ILPAD() PAD((NROW - tt.tt_row) * 10)   /* 1 ms per char */
 
 #define ICPAD() PAD((NCOL - tt.tt_col) * 1)    /* 0.1 ms per char */
 #define ILPAD() PAD((NROW - tt.tt_row) * 10)   /* 1 ms per char */
 
-#define h19_setinsert(m) (esc(), (tt.tt_insert = (m)) ? pc(@) : pc(O))
+#define H19_SETINSERT(m) (esc(), (tt.tt_insert = (m)) ? pc(@) : pc(O))
+
+h19_setinsert(new)
+{
+       H19_SETINSERT(new);
+}
 
 h19_setmodes(new)
 register new;
 
 h19_setmodes(new)
 register new;
@@ -86,10 +97,10 @@ h19_putc(c)
 register char c;
 {
        if (tt.tt_nmodes != tt.tt_modes)
 register char c;
 {
        if (tt.tt_nmodes != tt.tt_modes)
-               h19_setmodes(tt.tt_nmodes);
+               (*tt.tt_setmodes)(tt.tt_nmodes);
        if (tt.tt_ninsert != tt.tt_insert)
        if (tt.tt_ninsert != tt.tt_insert)
-               h19_setinsert(tt.tt_ninsert);
-       putchar(c);
+               H19_SETINSERT(tt.tt_ninsert);
+       ttputc(c);
        if (tt.tt_insert)
                ICPAD();
        if (++tt.tt_col == NCOL)
        if (tt.tt_insert)
                ICPAD();
        if (++tt.tt_col == NCOL)
@@ -101,19 +112,18 @@ register char *p;
 register n;
 {
        if (tt.tt_nmodes != tt.tt_modes)
 register n;
 {
        if (tt.tt_nmodes != tt.tt_modes)
-               h19_setmodes(tt.tt_nmodes);
+               (*tt.tt_setmodes)(tt.tt_nmodes);
        if (tt.tt_ninsert != tt.tt_insert)
        if (tt.tt_ninsert != tt.tt_insert)
-               h19_setinsert(tt.tt_ninsert);
+               H19_SETINSERT(tt.tt_ninsert);
        if (tt.tt_insert) {
                while (--n >= 0) {
        if (tt.tt_insert) {
                while (--n >= 0) {
-                       putchar(*p++);
+                       ttputc(*p++);
                        ICPAD();
                        tt.tt_col++;
                }
        } else {
                tt.tt_col += n;
                        ICPAD();
                        tt.tt_col++;
                }
        } else {
                tt.tt_col += n;
-               while (--n >= 0)
-                       putchar(*p++);
+               ttwrite(p, n);
        }
        if (tt.tt_col == NCOL)
                tt.tt_col = NCOL - 1;
        }
        if (tt.tt_col == NCOL)
                tt.tt_col = NCOL - 1;
@@ -151,8 +161,8 @@ register char row, col;
        }
        esc();
        pc(Y);
        }
        esc();
        pc(Y);
-       putchar(' ' + row);
-       putchar(' ' + col);
+       ttputc(' ' + row);
+       ttputc(' ' + col);
 out:
        tt.tt_col = col;
        tt.tt_row = row;
 out:
        tt.tt_col = col;
        tt.tt_row = row;
@@ -161,7 +171,7 @@ out:
 h19_init()
 {
        if (gen_VS)
 h19_init()
 {
        if (gen_VS)
-               fputs(gen_VS, stdout);
+               ttxputs(gen_VS);
        esc();
        pc(w);
        esc();
        esc();
        pc(w);
        esc();
@@ -173,10 +183,8 @@ h19_init()
 
 h19_end()
 {
 
 h19_end()
 {
-       h19_setmodes(0);
-       h19_setinsert(0);
        if (gen_VE)
        if (gen_VE)
-               fputs(gen_VE, stdout);
+               ttxputs(gen_VE);
        esc();
        pc(v);
 }
        esc();
        pc(v);
 }
@@ -210,8 +218,8 @@ tt_h19()
        float cpms = (float) wwbaud / 10000;    /* char per ms */
 
        h19_msp10c = 10 / cpms;                 /* ms per 10 char */
        float cpms = (float) wwbaud / 10000;    /* char per ms */
 
        h19_msp10c = 10 / cpms;                 /* ms per 10 char */
-       gen_VS = tt_xgetstr("vs");
-       gen_VE = tt_xgetstr("ve");
+       gen_VS = ttxgetstr("vs");
+       gen_VE = ttxgetstr("ve");
 
        tt.tt_init = h19_init;
        tt.tt_end = h19_end;
 
        tt.tt_init = h19_init;
        tt.tt_end = h19_end;
@@ -225,6 +233,8 @@ tt_h19()
        tt.tt_move = h19_move;
        tt.tt_write = h19_write;
        tt.tt_putc = h19_putc;
        tt.tt_move = h19_move;
        tt.tt_write = h19_write;
        tt.tt_putc = h19_putc;
+       tt.tt_setinsert = h19_setinsert;
+       tt.tt_setmodes = h19_setmodes;
 
        tt.tt_ncol = NCOL;
        tt.tt_nrow = NROW;
 
        tt.tt_ncol = NCOL;
        tt.tt_nrow = NROW;