BSD 4_4 release
[unix-history] / usr / src / usr.bin / window / tth19.c
index ab1ebbd..b6dbcfe 100644 (file)
@@ -1,26 +1,46 @@
 /*
 /*
- * Copyright (c) 1983 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1983, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, 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'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * 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, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. 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 BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)tth19.c    3.22 (Berkeley) %G%";
+static char sccsid[] = "@(#)tth19.c    8.1 (Berkeley) 6/6/93";
 #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:
@@ -50,17 +70,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'))
+#define H19_SETINSERT(m) ttesc((tt.tt_insert = (m)) ? '@' : 'O')
 
 h19_setmodes(new)
 register new;
 
 h19_setmodes(new)
 register new;
@@ -68,28 +86,17 @@ 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;
 }
 
 h19_insline(n)
 {
        while (--n >= 0) {
        tt.tt_modes = new;
 }
 
 h19_insline(n)
 {
        while (--n >= 0) {
-               esc();
-               pc('L');
+               ttesc('L');
                ILPAD();
        }
 }
                ILPAD();
        }
 }
@@ -97,8 +104,7 @@ h19_insline(n)
 h19_delline(n)
 {
        while (--n >= 0) {
 h19_delline(n)
 {
        while (--n >= 0) {
-               esc();
-               pc('M');
+               ttesc('M');
                ILPAD();
        }
 }
                ILPAD();
        }
 }
@@ -110,7 +116,7 @@ register char c;
                (*tt.tt_setmodes)(tt.tt_nmodes);
        if (tt.tt_insert)
                H19_SETINSERT(0);
                (*tt.tt_setmodes)(tt.tt_nmodes);
        if (tt.tt_insert)
                H19_SETINSERT(0);
-       pc(c);
+       ttputc(c);
        if (++tt.tt_col == NCOL)
                tt.tt_col = NCOL - 1;
 }
        if (++tt.tt_col == NCOL)
                tt.tt_col = NCOL - 1;
 }
@@ -136,39 +142,35 @@ 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');
-       pc(' ' + row);
-       pc(' ' + col);
+       ttesc('Y');
+       ttputc(' ' + row);
+       ttputc(' ' + col);
 out:
        tt.tt_col = col;
        tt.tt_row = row;
 out:
        tt.tt_col = col;
        tt.tt_row = row;
@@ -178,10 +180,8 @@ 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_insert = 0;
        tt.tt_nmodes = tt.tt_modes = 0;
        tt.tt_col = tt.tt_row = 0;
        tt.tt_insert = 0;
        tt.tt_nmodes = tt.tt_modes = 0;
@@ -193,26 +193,22 @@ h19_end()
                H19_SETINSERT(0);
        if (gen_VE)
                ttxputs(gen_VE);
                H19_SETINSERT(0);
        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)
 }
 
 h19_inschar(c)
@@ -222,7 +218,7 @@ register char c;
                (*tt.tt_setmodes)(tt.tt_nmodes);
        if (!tt.tt_insert)
                H19_SETINSERT(1);
                (*tt.tt_setmodes)(tt.tt_nmodes);
        if (!tt.tt_insert)
                H19_SETINSERT(1);
-       pc(c);
+       ttputc(c);
        if (tt.tt_insert)
                ICPAD();
        if (++tt.tt_col == NCOL)
        if (tt.tt_insert)
                ICPAD();
        if (++tt.tt_col == NCOL)
@@ -231,26 +227,22 @@ register char c;
 
 h19_delchar(n)
 {
 
 h19_delchar(n)
 {
-       while (--n >= 0) {
-               esc();
-               pc('N');
-       }
+       while (--n >= 0)
+               ttesc('N');
 }
 
 h19_scroll_down(n)
 {
        h19_move(NROW - 1, 0);
        while (--n >= 0)
 }
 
 h19_scroll_down(n)
 {
        h19_move(NROW - 1, 0);
        while (--n >= 0)
-               pc('\n');
+               ttctrl('j');
 }
 
 h19_scroll_up(n)
 {
        h19_move(0, 0);
 }
 
 h19_scroll_up(n)
 {
        h19_move(0, 0);
-       while (--n >= 0) {
-               esc();
-               pc('I');
-       }
+       while (--n >= 0)
+               ttesc('I');
 }
 
 tt_h19()
 }
 
 tt_h19()