BSD 4_3_Reno release
[unix-history] / usr / src / usr.bin / window / tth19.c
index 6aa8368..465a23e 100644 (file)
@@ -2,20 +2,31 @@
  * Copyright (c) 1983 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1983 Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of California at Berkeley. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
+ * This code is derived from software contributed to Berkeley by
+ * Edward Wang at The University of California, Berkeley.
+ *
+ * Redistribution and use in source and binary forms are permitted provided
+ * that: (1) source distributions retain this entire copyright notice and
+ * comment, and (2) distributions including binaries display the following
+ * acknowledgement:  ``This product includes software developed by the
+ * University of California, Berkeley and its contributors'' in the
+ * documentation or other materials provided with the distribution and in
+ * all advertising materials mentioning features or use of this software.
+ * Neither the name of the University nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)tth19.c    3.18 (Berkeley) %G%";
+static char sccsid[] = "@(#)tth19.c    3.25 (Berkeley) 6/6/90";
 #endif /* not lint */
 
 #include "ww.h"
 #include "tt.h"
 #endif /* not lint */
 
 #include "ww.h"
 #include "tt.h"
+#include "char.h"
 
 /*
 kb|h19|heath|h19-b|h19b|heathkit|heath-19|z19|zenith:
 
 /*
 kb|h19|heath|h19-b|h19b|heathkit|heath-19|z19|zenith:
@@ -45,22 +56,15 @@ extern struct tt_str *gen_VE;
 
 int h19_msp10c;
 
 
 int h19_msp10c;
 
-#define pc(c)  ttputc('c')
-#define esc()  pc(\033)
 #define PAD(ms10) { \
        register i; \
        for (i = ((ms10) + 5) / h19_msp10c; --i >= 0;) \
 #define PAD(ms10) { \
        register i; \
        for (i = ((ms10) + 5) / h19_msp10c; --i >= 0;) \
-               pc(\0); \
+               ttputc('\0'); \
 }
 #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))
-
-h19_setinsert(new)
-{
-       H19_SETINSERT(new);
-}
+#define H19_SETINSERT(m) ttesc((tt.tt_insert = (m)) ? '@' : 'O')
 
 h19_setmodes(new)
 register new;
 
 h19_setmodes(new)
 register new;
@@ -68,35 +72,27 @@ register new;
        register diff;
 
        diff = new ^ tt.tt_modes;
        register diff;
 
        diff = new ^ tt.tt_modes;
-       if (diff & WWM_REV) {
-               esc();
-               if (new & WWM_REV)
-                       pc(p);
-               else
-                       pc(q);
-       }
-       if (diff & WWM_GRP) {
-               esc();
-               if (new & WWM_GRP)
-                       pc(F);
-               else
-                       pc(G);
-       }
+       if (diff & WWM_REV)
+               ttesc(new & WWM_REV ? 'p' : 'q');
+       if (diff & WWM_GRP)
+               ttesc(new & WWM_REV ? 'F' : 'G');
        tt.tt_modes = new;
 }
 
        tt.tt_modes = new;
 }
 
-h19_insline()
+h19_insline(n)
 {
 {
-       esc();
-       pc(L);
-       ILPAD();
+       while (--n >= 0) {
+               ttesc('L');
+               ILPAD();
+       }
 }
 
 }
 
-h19_delline()
+h19_delline(n)
 {
 {
-       esc();
-       pc(M);
-       ILPAD();
+       while (--n >= 0) {
+               ttesc('M');
+               ILPAD();
+       }
 }
 
 h19_putc(c)
 }
 
 h19_putc(c)
@@ -104,11 +100,9 @@ register char c;
 {
        if (tt.tt_nmodes != tt.tt_modes)
                (*tt.tt_setmodes)(tt.tt_nmodes);
 {
        if (tt.tt_nmodes != tt.tt_modes)
                (*tt.tt_setmodes)(tt.tt_nmodes);
-       if (tt.tt_ninsert != tt.tt_insert)
-               H19_SETINSERT(tt.tt_ninsert);
-       ttputc(c);
        if (tt.tt_insert)
        if (tt.tt_insert)
-               ICPAD();
+               H19_SETINSERT(0);
+       ttputc(c);
        if (++tt.tt_col == NCOL)
                tt.tt_col = NCOL - 1;
 }
        if (++tt.tt_col == NCOL)
                tt.tt_col = NCOL - 1;
 }
@@ -119,18 +113,10 @@ register n;
 {
        if (tt.tt_nmodes != tt.tt_modes)
                (*tt.tt_setmodes)(tt.tt_nmodes);
 {
        if (tt.tt_nmodes != tt.tt_modes)
                (*tt.tt_setmodes)(tt.tt_nmodes);
-       if (tt.tt_ninsert != tt.tt_insert)
-               H19_SETINSERT(tt.tt_ninsert);
-       if (tt.tt_insert) {
-               while (--n >= 0) {
-                       ttputc(*p++);
-                       ICPAD();
-                       tt.tt_col++;
-               }
-       } else {
-               tt.tt_col += n;
-               ttwrite(p, n);
-       }
+       if (tt.tt_insert)
+               H19_SETINSERT(0);
+       ttwrite(p, n);
+       tt.tt_col += n;
        if (tt.tt_col == NCOL)
                tt.tt_col = NCOL - 1;
 }
        if (tt.tt_col == NCOL)
                tt.tt_col = NCOL - 1;
 }
@@ -142,37 +128,33 @@ register char row, col;
                if (tt.tt_col == col)
                        return;
                if (col == 0) {
                if (tt.tt_col == col)
                        return;
                if (col == 0) {
-                       pc(\r);
+                       ttctrl('m');
                        goto out;
                }
                if (tt.tt_col == col - 1) {
                        goto out;
                }
                if (tt.tt_col == col - 1) {
-                       esc();
-                       pc(C);
+                       ttesc('C');
                        goto out;
                }
                if (tt.tt_col == col + 1) {
                        goto out;
                }
                if (tt.tt_col == col + 1) {
-                       pc(\b);
+                       ttctrl('h');
                        goto out;
                }
        }
        if (tt.tt_col == col) {
                if (tt.tt_row == row + 1) {
                        goto out;
                }
        }
        if (tt.tt_col == col) {
                if (tt.tt_row == row + 1) {
-                       esc();
-                       pc(A);
+                       ttesc('A');
                        goto out;
                }
                if (tt.tt_row == row - 1) {
                        goto out;
                }
                if (tt.tt_row == row - 1) {
-                       pc(\n);
+                       ttctrl('j');
                        goto out;
                }
        }
        if (col == 0 && row == 0) {
                        goto out;
                }
        }
        if (col == 0 && row == 0) {
-               esc();
-               pc(H);
+               ttesc('H');
                goto out;
        }
                goto out;
        }
-       esc();
-       pc(Y);
+       ttesc('Y');
        ttputc(' ' + row);
        ttputc(' ' + col);
 out:
        ttputc(' ' + row);
        ttputc(' ' + col);
 out:
@@ -180,62 +162,73 @@ out:
        tt.tt_row = row;
 }
 
        tt.tt_row = row;
 }
 
-h19_init()
+h19_start()
 {
        if (gen_VS)
                ttxputs(gen_VS);
 {
        if (gen_VS)
                ttxputs(gen_VS);
-       esc();
-       pc(w);
-       esc();
-       pc(E);
+       ttesc('w');
+       ttesc('E');
        tt.tt_col = tt.tt_row = 0;
        tt.tt_col = tt.tt_row = 0;
-       tt.tt_ninsert = tt.tt_insert = 0;
+       tt.tt_insert = 0;
        tt.tt_nmodes = tt.tt_modes = 0;
 }
 
 h19_end()
 {
        tt.tt_nmodes = tt.tt_modes = 0;
 }
 
 h19_end()
 {
+       if (tt.tt_insert)
+               H19_SETINSERT(0);
        if (gen_VE)
                ttxputs(gen_VE);
        if (gen_VE)
                ttxputs(gen_VE);
-       esc();
-       pc(v);
+       ttesc('v');
 }
 
 h19_clreol()
 {
 }
 
 h19_clreol()
 {
-       esc();
-       pc(K);
+       ttesc('K');
 }
 
 h19_clreos()
 {
 }
 
 h19_clreos()
 {
-       esc();
-       pc(J);
+       ttesc('J');
 }
 
 h19_clear()
 {
 }
 
 h19_clear()
 {
-       esc();
-       pc(E);
+       ttesc('E');
+}
+
+h19_inschar(c)
+register char c;
+{
+       if (tt.tt_nmodes != tt.tt_modes)
+               (*tt.tt_setmodes)(tt.tt_nmodes);
+       if (!tt.tt_insert)
+               H19_SETINSERT(1);
+       ttputc(c);
+       if (tt.tt_insert)
+               ICPAD();
+       if (++tt.tt_col == NCOL)
+               tt.tt_col = NCOL - 1;
 }
 
 }
 
-h19_delchar()
+h19_delchar(n)
 {
 {
-       esc();
-       pc(N);
+       while (--n >= 0)
+               ttesc('N');
 }
 
 }
 
-h19_scroll_down()
+h19_scroll_down(n)
 {
        h19_move(NROW - 1, 0);
 {
        h19_move(NROW - 1, 0);
-       pc(\n);
+       while (--n >= 0)
+               ttctrl('j');
 }
 
 }
 
-h19_scroll_up()
+h19_scroll_up(n)
 {
        h19_move(0, 0);
 {
        h19_move(0, 0);
-       esc();
-       pc(I);
+       while (--n >= 0)
+               ttesc('I');
 }
 
 tt_h19()
 }
 
 tt_h19()
@@ -246,11 +239,12 @@ tt_h19()
        gen_VS = ttxgetstr("vs");
        gen_VE = ttxgetstr("ve");
 
        gen_VS = ttxgetstr("vs");
        gen_VE = ttxgetstr("ve");
 
-       tt.tt_init = h19_init;
+       tt.tt_start = h19_start;
        tt.tt_end = h19_end;
 
        tt.tt_insline = h19_insline;
        tt.tt_delline = h19_delline;
        tt.tt_end = h19_end;
 
        tt.tt_insline = h19_insline;
        tt.tt_delline = h19_delline;
+       tt.tt_inschar = h19_inschar;
        tt.tt_delchar = h19_delchar;
        tt.tt_clreol = h19_clreol;
        tt.tt_clreos = h19_clreos;
        tt.tt_delchar = h19_delchar;
        tt.tt_clreol = h19_clreol;
        tt.tt_clreos = h19_clreos;
@@ -260,12 +254,10 @@ tt_h19()
        tt.tt_putc = h19_putc;
        tt.tt_scroll_down = h19_scroll_down;
        tt.tt_scroll_up = h19_scroll_up;
        tt.tt_putc = h19_putc;
        tt.tt_scroll_down = h19_scroll_down;
        tt.tt_scroll_up = h19_scroll_up;
-       tt.tt_setinsert = h19_setinsert;
        tt.tt_setmodes = h19_setmodes;
 
        tt.tt_ncol = NCOL;
        tt.tt_nrow = NROW;
        tt.tt_setmodes = h19_setmodes;
 
        tt.tt_ncol = NCOL;
        tt.tt_nrow = NROW;
-       tt.tt_hasinsert = 1;
        tt.tt_availmodes = WWM_REV|WWM_GRP;
        tt.tt_frame = h19_frame;
        return 0;
        tt.tt_availmodes = WWM_REV|WWM_GRP;
        tt.tt_frame = h19_frame;
        return 0;