reworked tt stuff
authorEdward Wang <edward@ucbvax.Berkeley.EDU>
Fri, 16 Sep 1983 03:23:47 +0000 (19:23 -0800)
committerEdward Wang <edward@ucbvax.Berkeley.EDU>
Fri, 16 Sep 1983 03:23:47 +0000 (19:23 -0800)
SCCS-vsn: usr.bin/window/tt.h 3.8
SCCS-vsn: usr.bin/window/:tt 1.2
SCCS-vsn: usr.bin/window/tth19.c 3.9
SCCS-vsn: usr.bin/window/wwdata.c 3.6
SCCS-vsn: usr.bin/window/wwdump.c 3.6
SCCS-vsn: usr.bin/window/wwinschar.c 3.9
SCCS-vsn: usr.bin/window/wwupdate.c 3.8
SCCS-vsn: usr.bin/window/ttgeneric.c 3.16

usr/src/usr.bin/window/:tt
usr/src/usr.bin/window/tt.h
usr/src/usr.bin/window/ttgeneric.c
usr/src/usr.bin/window/tth19.c
usr/src/usr.bin/window/wwdata.c
usr/src/usr.bin/window/wwdump.c
usr/src/usr.bin/window/wwinschar.c
usr/src/usr.bin/window/wwupdate.c

index dae2f88..ace821c 100644 (file)
@@ -1,7 +1,8 @@
-./"init"16t"end"16t"setinsert"16t"setmodes"n4p
+./"init"16t"end"n2p
 +/"move"16t"insline"16t"delline"16t"delchar"n4p
 +/"move"16t"insline"16t"delline"16t"delchar"n4p
-+/"write"16t"putc"16t"blank"n3p
++/"write"16t"putc"16tn2p
 +/"clreol"16t"clreos"16t"clear"n3p
 +/"clreol"16t"clreos"16t"clear"n3p
-+/"nrow"16t"ncol"16t"availmodes"16t"wrap"n2pb16tb++
++/"modes"8t"nmodes"8t"insert"8t"ninsert"8t"row"16t"col"n4b2D
++/"nrow"16t"ncol"16t"hasins"8t"avlmods"8t"wrap"8t"retain"n2D4b
 +/"frame"
 *./16b
 +/"frame"
 *./16b
index eebe93e..5011da9 100644 (file)
@@ -1,42 +1,59 @@
 /*
 /*
- *     @(#)tt.h        3.7 83/08/24
+ *     @(#)tt.h        3.8 83/09/15
  */
 
  */
 
+/*
+ * Interface structure for the terminal drivers.
+ */
 struct tt {
 struct tt {
+               /* startup and cleanup */
        int (*tt_init)();
        int (*tt_end)();
        int (*tt_init)();
        int (*tt_end)();
-       int (*tt_setinsert)();
-       int (*tt_setmodes)();
+
+               /* terminal functions */
        int (*tt_move)();
        int (*tt_insline)();
        int (*tt_delline)();
        int (*tt_delchar)();
        int (*tt_move)();
        int (*tt_insline)();
        int (*tt_delline)();
        int (*tt_delchar)();
-       int (*tt_write)();
-       int (*tt_putc)();
-       int (*tt_blank)();
+       int (*tt_write)();              /* write a whole block */
+       int (*tt_putc)();               /* write one character */
        int (*tt_clreol)();
        int (*tt_clreos)();
        int (*tt_clear)();
        int (*tt_clreol)();
        int (*tt_clreos)();
        int (*tt_clear)();
-       int tt_nrow;
-       int tt_ncol;
-       char tt_availmodes;
+
+               /* internal variables */
+       char tt_modes;                  /* the current display modes */
+       char tt_nmodes;                 /* the new modes for next write */
+       char tt_insert;                 /* currently in insert mode */
+       char tt_ninsert;                /* insert mode on next write */
+       int tt_row;                     /* cursor row */
+       int tt_col;                     /* cursor column */
+
+               /* terminal info */
+       int tt_nrow;                    /* number of display rows */
+       int tt_ncol;                    /* number of display columns */
+       char tt_hasinsert;              /* has insert character */
+       char tt_availmodes;             /* the display modes supported */
        char tt_wrap;                   /* has auto wrap around */
        char tt_retain;                 /* can retain below (db flag) */
        char tt_wrap;                   /* has auto wrap around */
        char tt_retain;                 /* can retain below (db flag) */
+
+               /* the frame characters */
        char *tt_frame;
 };
        char *tt_frame;
 };
-
 struct tt tt;
 
 struct tt tt;
 
+/*
+ * List of terminal drivers.
+ */
 struct tt_tab {
        char *tt_name;
        int tt_len;
        int (*tt_func)();
 };
 struct tt_tab {
        char *tt_name;
        int tt_len;
        int (*tt_func)();
 };
-
 struct tt_tab tt_tab[];
 
 /*
 struct tt_tab tt_tab[];
 
 /*
- * nicer interface to termcap routines
+ * Clean interface to termcap routines.
  */
 char tt_strings[1024];         /* string buffer */
 char *tt_strp;                 /* pointer for it */
  */
 char tt_strings[1024];         /* string buffer */
 char *tt_strp;                 /* pointer for it */
index de3b331..4a6efef 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)ttgeneric.c 3.15 83/08/24";
+static char *sccsid = "@(#)ttgeneric.c 3.16 83/09/15";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -14,10 +14,6 @@ char gen_frame[16] = {
        '+', '+', '+', '+'
 };
 
        '+', '+', '+', '+'
 };
 
-int gen_row, gen_col;
-char gen_modes, gen_nmodes;
-char gen_insert, gen_ninsert;
-
 char *gen_CM;
 char *gen_IM;
 char *gen_IC;
 char *gen_CM;
 char *gen_IM;
 char *gen_IC;
@@ -58,37 +54,23 @@ int gen_SG;
 #define ps(s) fputs((s), stdout)
 
 gen_setinsert(new)
 #define ps(s) fputs((s), stdout)
 
 gen_setinsert(new)
-{
-       gen_ninsert = new;
-}
-
-gen_setinsert1(new)
 char new;
 {
 char new;
 {
-       if (gen_insert == new)
-               return;
        if (new) {
                if (gen_IM)
                        ps(gen_IM);
        } else
                if (gen_EI)
                        ps(gen_EI);
        if (new) {
                if (gen_IM)
                        ps(gen_IM);
        } else
                if (gen_EI)
                        ps(gen_EI);
-       gen_insert = new;
+       tt.tt_insert = new;
 }
 
 gen_setmodes(new)
 }
 
 gen_setmodes(new)
-char new;
-{
-       gen_nmodes = new & tt.tt_availmodes;
-}
-
-gen_setmodes1(new)
 register new;
 {
        register diff;
 
 register new;
 {
        register diff;
 
-       if ((diff = new ^ gen_modes) == 0)
-               return;
+       diff = new ^ tt.tt_modes;
        if (diff & WWM_REV) {
                if (new & WWM_REV) {
                        if (gen_SO)
        if (diff & WWM_REV) {
                if (new & WWM_REV) {
                        if (gen_SO)
@@ -105,130 +87,107 @@ register new;
                        if (gen_UE)
                                ps(gen_UE);
        }
                        if (gen_UE)
                                ps(gen_UE);
        }
-       gen_modes = new;
+       tt.tt_modes = new;
 }
 
 gen_insline()
 {
 }
 
 gen_insline()
 {
-       if (gen_modes)                  /* for concept 100 */
-               gen_setmodes1(0);
+       if (tt.tt_modes)                        /* for concept 100 */
+               gen_setmodes(0);
        if (gen_AL)
        if (gen_AL)
-               tt_tputs(gen_AL, gen_LI - gen_row);
+               tt_tputs(gen_AL, gen_LI - tt.tt_row);
 }
 
 gen_delline()
 {
 }
 
 gen_delline()
 {
-       if (gen_modes)                  /* for concept 100 */
-               gen_setmodes1(0);
+       if (tt.tt_modes)                        /* for concept 100 */
+               gen_setmodes(0);
        if (gen_DL)
        if (gen_DL)
-               tt_tputs(gen_DL, gen_LI - gen_row);
+               tt_tputs(gen_DL, gen_LI - tt.tt_row);
 }
 
 gen_putc(c)
 register char c;
 {
 }
 
 gen_putc(c)
 register char c;
 {
-       gen_setinsert1(gen_ninsert);
-       gen_setmodes1(gen_nmodes);
-       if (gen_insert) {
+       if (tt.tt_ninsert != tt.tt_insert)
+               gen_setinsert(tt.tt_ninsert);
+       if (tt.tt_nmodes != tt.tt_modes)
+               gen_setmodes(tt.tt_nmodes);
+       if (tt.tt_insert) {
                if (gen_IC)
                if (gen_IC)
-                       tt_tputs(gen_IC, gen_CO - gen_col);
+                       tt_tputs(gen_IC, gen_CO - tt.tt_col);
                putchar(c);
                if (gen_IP)
                putchar(c);
                if (gen_IP)
-                       tt_tputs(gen_IP, gen_CO - gen_col);
+                       tt_tputs(gen_IP, gen_CO - tt.tt_col);
        } else
                putchar(c);
        } else
                putchar(c);
-       if (++gen_col == gen_CO)
+       if (++tt.tt_col == gen_CO)
                if (gen_AM)
                if (gen_AM)
-                       gen_col = 0, gen_row++;
+                       tt.tt_col = 0, tt.tt_row++;
                else
                else
-                       gen_col--;
+                       tt.tt_col--;
 }
 
 }
 
-gen_write(start, end)
-register char *start, *end;
-{
-       gen_setinsert1(gen_ninsert);
-       gen_setmodes1(gen_nmodes);
-       if (gen_insert) {
-               while (start <= end) {
-                       if (gen_IC)
-                               tt_tputs(gen_IC, gen_CO - gen_col);
-                       putchar(*start++);
-                       if (gen_IP)
-                               tt_tputs(gen_IP, gen_CO - gen_col);
-                       gen_col++;
-               }
-       } else {
-               gen_col += end - start + 1;
-               while (start <= end)
-                       putchar(*start++);
-       }
-       if (gen_col == gen_CO)
-               if (gen_AM)
-                       gen_col = 0, gen_row++;
-               else
-                       gen_col--;
-}
-
-gen_blank(n)
+gen_write(p, n)
+register char *p;
 register n;
 {
 register n;
 {
-       if (n <= 0)
-               return;
-       gen_setinsert1(gen_ninsert);
-       gen_setmodes1(gen_nmodes);
-       if (gen_insert) {
+       if (tt.tt_ninsert != tt.tt_insert)
+               gen_setinsert(tt.tt_ninsert);
+       if (tt.tt_nmodes != tt.tt_modes)
+               gen_setmodes(tt.tt_nmodes);
+       if (tt.tt_insert) {
                while (--n >= 0) {
                        if (gen_IC)
                while (--n >= 0) {
                        if (gen_IC)
-                               tt_tputs(gen_IC, gen_CO - gen_col);
-                       putchar(' ');
+                               tt_tputs(gen_IC, gen_CO - tt.tt_col);
+                       putchar(*p++);
                        if (gen_IP)
                        if (gen_IP)
-                               tt_tputs(gen_IP, gen_CO - gen_col);
-                       gen_col++;
+                               tt_tputs(gen_IP, gen_CO - tt.tt_col);
+                       tt.tt_col++;
                }
        } else {
                }
        } else {
-               gen_col += n;
+               tt.tt_col += n;
                while (--n >= 0)
                while (--n >= 0)
-                       putchar(' ');
+                       putchar(*p++);
        }
        }
-       if (gen_col == gen_CO)
+       if (tt.tt_col == gen_CO)
                if (gen_AM)
                if (gen_AM)
-                       gen_col = 0, gen_row++;
+                       tt.tt_col = 0, tt.tt_row++;
                else
                else
-                       gen_col--;
+                       tt.tt_col--;
 }
 
 gen_move(row, col)
 register char row, col;
 {
 }
 
 gen_move(row, col)
 register char row, col;
 {
-       if (gen_row == row && gen_col == col)
+       if (tt.tt_row == row && tt.tt_col == col)
                return;
                return;
-       if (!gen_MI && gen_insert)
-               gen_setinsert1(0);
-       if (!gen_MS && gen_modes)
-               gen_setmodes1(0);
-       if (gen_row == row) {
-               if (gen_col == col)
+       if (!gen_MI && tt.tt_insert)
+               gen_setinsert(0);
+       if (!gen_MS && tt.tt_modes)
+               gen_setmodes(0);
+       if (tt.tt_row == row) {
+               if (tt.tt_col == col)
                        return;
                        return;
-               if (gen_col == col - 1) {
+               if (tt.tt_col == col - 1) {
                        if (gen_ND) {
                                ps(gen_ND);
                                goto out;
                        }
                        if (gen_ND) {
                                ps(gen_ND);
                                goto out;
                        }
-               } else if (gen_col == col + 1) {
+               } else if (tt.tt_col == col + 1) {
                        if (gen_BC) {
                                ps(gen_BC);
                                goto out;
                        }
                }
        }
                        if (gen_BC) {
                                ps(gen_BC);
                                goto out;
                        }
                }
        }
-       if (gen_col == col) {
-               if (gen_row == row + 1) {
+       if (tt.tt_col == col) {
+               if (tt.tt_row == row + 1) {
                        if (gen_UP) {
                                ps(gen_UP);
                                goto out;
                        }
                        if (gen_UP) {
                                ps(gen_UP);
                                goto out;
                        }
-               } else if (gen_row == row + 1) {
+               } else if (tt.tt_row == row + 1) {
                        if (gen_NL) {
                                ps(gen_NL);
                                goto out;
                        if (gen_NL) {
                                ps(gen_NL);
                                goto out;
@@ -241,8 +200,8 @@ register char row, col;
        }
        ps(tgoto(gen_CM, col, row));
 out:
        }
        ps(tgoto(gen_CM, col, row));
 out:
-       gen_col = col;
-       gen_row = row;
+       tt.tt_col = col;
+       tt.tt_row = row;
 }
 
 gen_init()
 }
 
 gen_init()
@@ -253,15 +212,15 @@ gen_init()
                ps(gen_TI);
        if (gen_CL)
                ps(gen_CL);
                ps(gen_TI);
        if (gen_CL)
                ps(gen_CL);
-       gen_col = gen_row = 0;
-       gen_ninsert = gen_insert = 0;
-       gen_nmodes = gen_modes = 0;
+       tt.tt_col = tt.tt_row = 0;
+       tt.tt_ninsert = tt.tt_insert = 0;
+       tt.tt_nmodes = tt.tt_modes = 0;
 }
 
 gen_end()
 {
 }
 
 gen_end()
 {
-       gen_setmodes1(0);
-       gen_setinsert1(0);
+       gen_setmodes(0);
+       gen_setinsert(0);
        if (gen_TE)
                ps(gen_TE);
        if (gen_VE)
        if (gen_TE)
                ps(gen_TE);
        if (gen_VE)
@@ -270,24 +229,24 @@ gen_end()
 
 gen_clreol()
 {
 
 gen_clreol()
 {
-       if (gen_modes)                  /* for concept 100 */
-               gen_setmodes1(0);
+       if (tt.tt_modes)                        /* for concept 100 */
+               gen_setmodes(0);
        if (gen_CE)
        if (gen_CE)
-               tt_tputs(gen_CE, gen_CO - gen_col);
+               tt_tputs(gen_CE, gen_CO - tt.tt_col);
 }
 
 gen_clreos()
 {
 }
 
 gen_clreos()
 {
-       if (gen_modes)                  /* for concept 100 */
-               gen_setmodes1(0);
+       if (tt.tt_modes)                        /* for concept 100 */
+               gen_setmodes(0);
        if (gen_CD)
        if (gen_CD)
-               tt_tputs(gen_CD, gen_LI - gen_row);
+               tt_tputs(gen_CD, gen_LI - tt.tt_row);
 }
 
 gen_clear()
 {
 }
 
 gen_clear()
 {
-       if (gen_modes)                  /* for concept 100 */
-               gen_setmodes1(0);
+       if (tt.tt_modes)                        /* for concept 100 */
+               gen_setmodes(0);
        if (gen_CL)
                ps(gen_CL);
 }
        if (gen_CL)
                ps(gen_CL);
 }
@@ -295,7 +254,7 @@ gen_clear()
 gen_delchar()
 {
        if (gen_DC)
 gen_delchar()
 {
        if (gen_DC)
-               tt_tputs(gen_DC, gen_CO - gen_col);
+               tt_tputs(gen_DC, gen_CO - tt.tt_col);
 }
 
 tt_generic()
 }
 
 tt_generic()
@@ -354,8 +313,6 @@ tt_generic()
                ospeed = wwoldtty.ww_sgttyb.sg_ospeed;
        }
 
                ospeed = wwoldtty.ww_sgttyb.sg_ospeed;
        }
 
-       if (gen_IM)
-               tt.tt_setinsert = gen_setinsert;
        if (gen_DC)
                tt.tt_delchar = gen_delchar;
        if (gen_AL)
        if (gen_DC)
                tt.tt_delchar = gen_delchar;
        if (gen_AL)
@@ -376,14 +333,13 @@ tt_generic()
                tt.tt_availmodes |= WWM_REV;
        if (gen_US)
                tt.tt_availmodes |= WWM_UL;
                tt.tt_availmodes |= WWM_REV;
        if (gen_US)
                tt.tt_availmodes |= WWM_UL;
+       tt.tt_hasinsert = gen_IM != 0;
        tt.tt_wrap = gen_AM;
        tt.tt_retain = gen_DB;
        tt.tt_ncol = gen_CO;
        tt.tt_nrow = gen_LI;
        tt.tt_init = gen_init;
        tt.tt_end = gen_end;
        tt.tt_wrap = gen_AM;
        tt.tt_retain = gen_DB;
        tt.tt_ncol = gen_CO;
        tt.tt_nrow = gen_LI;
        tt.tt_init = gen_init;
        tt.tt_end = gen_end;
-       tt.tt_setmodes = gen_setmodes;
-       tt.tt_blank = gen_blank;
        tt.tt_write = gen_write;
        tt.tt_putc = gen_putc;
        tt.tt_move = gen_move;
        tt.tt_write = gen_write;
        tt.tt_putc = gen_putc;
        tt.tt_move = gen_move;
index bad08d3..92b37d8 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)tth19.c     3.8 83/08/17";
+static char *sccsid = "@(#)tth19.c     3.9 83/09/15";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -17,6 +17,9 @@ kb|h19|heath|h19-b|h19b|heathkit|heath-19|z19|zenith:
        es:hs:ts=\Ej\Ex5\Ex1\EY8%+ \Eo:fs=\Ek\Ey5:ds=\Ey1:
 */
 
        es:hs:ts=\Ej\Ex5\Ex1\EY8%+ \Eo:fs=\Ek\Ey5:ds=\Ey1:
 */
 
+#define NCOL   80
+#define NROW   24
+
 char h19_frame[16] = {
        ' ',      '`'|0x80, 'a'|0x80, 'e'|0x80,
        '`'|0x80, '`'|0x80, 'f'|0x80, 'v'|0x80,
 char h19_frame[16] = {
        ' ',      '`'|0x80, 'a'|0x80, 'e'|0x80,
        '`'|0x80, '`'|0x80, 'f'|0x80, 'v'|0x80,
@@ -24,13 +27,11 @@ char h19_frame[16] = {
        'c'|0x80, 't'|0x80, 's'|0x80, 'b'|0x80
 };
 
        'c'|0x80, 't'|0x80, 's'|0x80, 'b'|0x80
 };
 
-char h19_row, h19_col;
-char h19_modes, h19_nmodes;
-char h19_insert, h19_ninsert;
-char h19_graphics;
+extern char *gen_VS;
+extern char *gen_VE;
+
+char h19_graphics;                     /* in graphics mode */
 short h19_msp10c;
 short h19_msp10c;
-char *h19_VS;
-char *h19_VE;
 
 #define pc(c)  putchar('c')
 #define esc()  pc(\033)
 
 #define pc(c)  putchar('c')
 #define esc()  pc(\033)
@@ -39,30 +40,19 @@ char *h19_VE;
        for (i = ((ms10) + 5) / h19_msp10c; --i >= 0;) \
                pc(\0); \
 }
        for (i = ((ms10) + 5) / h19_msp10c; --i >= 0;) \
                pc(\0); \
 }
-#define ICPAD() PAD((80 - h19_col) * 1)                /* 0.1 ms per char */
-#define ILPAD() PAD((24 - h19_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 SETINSERT(m) \
 
 #define SETINSERT(m) \
-       ((m) != h19_insert \
-               ? (esc(), (h19_insert = (m)) ? pc(@) : pc(O)) : 0)
+       ((m) != tt.tt_insert \
+               ? (esc(), (tt.tt_insert = (m)) ? pc(@) : pc(O)) : 0)
 #define SETMODES(m) \
 #define SETMODES(m) \
-       ((m) != h19_modes \
-               ? (esc(), (h19_modes = (m)) ? pc(p) : pc(q)) : 0)
+       ((m) != tt.tt_modes \
+               ? (esc(), (tt.tt_modes = (m)) ? pc(p) : pc(q)) : 0)
 #define SETGRAPHICS(m) \
        ((m) != h19_graphics \
                ? (esc(), (h19_graphics = (m)) ? pc(F) : pc(G)) : 0)
 
 #define SETGRAPHICS(m) \
        ((m) != h19_graphics \
                ? (esc(), (h19_graphics = (m)) ? pc(F) : pc(G)) : 0)
 
-h19_setinsert(new)
-char new;
-{
-       h19_ninsert = new;
-}
-
-h19_setmodes(new)
-{
-       h19_nmodes = new & WWM_REV;
-}
-
 h19_insline()
 {
        esc();
 h19_insline()
 {
        esc();
@@ -80,8 +70,8 @@ h19_delline()
 h19_putc(c)
 register char c;
 {
 h19_putc(c)
 register char c;
 {
-       SETMODES(h19_nmodes);
-       SETINSERT(h19_ninsert);
+       SETMODES(tt.tt_nmodes);
+       SETINSERT(tt.tt_ninsert);
        if (c & 0x80) {
                SETGRAPHICS(1);
                putchar(c & 0x7f);
        if (c & 0x80) {
                SETGRAPHICS(1);
                putchar(c & 0x7f);
@@ -89,22 +79,23 @@ register char c;
                SETGRAPHICS(0);
                putchar(c);
        }
                SETGRAPHICS(0);
                putchar(c);
        }
-       if (h19_insert)
+       if (tt.tt_insert)
                ICPAD();
                ICPAD();
-       if (++h19_col == 80)
-               h19_col = 79;
+       if (++tt.tt_col == NCOL)
+               tt.tt_col = NCOL - 1;
 }
 
 }
 
-h19_write(start, end)
-register char *start, *end;
+h19_write(p, n)
+register char *p;
+register n;
 {
        register char c;
 
 {
        register char c;
 
-       SETMODES(h19_nmodes);
-       SETINSERT(h19_ninsert);
-       if (h19_insert) {
-               while (start <= end) {
-                       if ((c = *start++) & 0x80) {
+       SETMODES(tt.tt_nmodes);
+       SETINSERT(tt.tt_ninsert);
+       if (tt.tt_insert) {
+               while (--n >= 0) {
+                       if ((c = *p++) & 0x80) {
                                SETGRAPHICS(1);
                                putchar(c & 0x7f);
                        } else {
                                SETGRAPHICS(1);
                                putchar(c & 0x7f);
                        } else {
@@ -112,12 +103,12 @@ register char *start, *end;
                                putchar(c);
                        }
                        ICPAD();
                                putchar(c);
                        }
                        ICPAD();
-                       h19_col++;
+                       tt.tt_col++;
                }
        } else {
                }
        } else {
-               h19_col += end - start + 1;
-               while (start <= end)
-                       if ((c = *start++) & 0x80) {
+               tt.tt_col += n;
+               while (--n >= 0)
+                       if ((c = *p++) & 0x80) {
                                SETGRAPHICS(1);
                                putchar(c & 0x7f);
                        } else {
                                SETGRAPHICS(1);
                                putchar(c & 0x7f);
                        } else {
@@ -125,53 +116,31 @@ register char *start, *end;
                                putchar(c);
                        }
        }
                                putchar(c);
                        }
        }
-       if (h19_col == 80)
-               h19_col = 79;
-}
-
-h19_blank(n)
-register n;
-{
-       if (n <= 0)
-               return;
-       SETMODES(h19_nmodes);
-       SETINSERT(h19_ninsert);
-       if (h19_insert) {
-               while (--n >= 0) {
-                       putchar(' ');
-                       ICPAD();
-                       h19_col++;
-               }
-       } else {
-               h19_col += n;
-               while (--n >= 0)
-                       putchar(' ');
-       }
-       if (h19_col == 80)
-               h19_col = 79;
+       if (tt.tt_col == NCOL)
+               tt.tt_col = NCOL - 1;
 }
 
 h19_move(row, col)
 register char row, col;
 {
 }
 
 h19_move(row, col)
 register char row, col;
 {
-       if (h19_row == row) {
-               if (h19_col == col)
+       if (tt.tt_row == row) {
+               if (tt.tt_col == col)
                        return;
                        return;
-               if (h19_col == col - 1) {
+               if (tt.tt_col == col - 1) {
                        esc();
                        pc(C);
                        goto out;
                        esc();
                        pc(C);
                        goto out;
-               } else if (h19_col == col + 1) {
+               } else if (tt.tt_col == col + 1) {
                        pc(\b);
                        goto out;
                }
        }
                        pc(\b);
                        goto out;
                }
        }
-       if (h19_col == col) {
-               if (h19_row == row + 1) {
+       if (tt.tt_col == col) {
+               if (tt.tt_row == row + 1) {
                        esc();
                        pc(A);
                        goto out;
                        esc();
                        pc(A);
                        goto out;
-               } else if (h19_row == row + 1) {
+               } else if (tt.tt_row == row + 1) {
                        pc(\n);
                        goto out;
                }
                        pc(\n);
                        goto out;
                }
@@ -186,22 +155,22 @@ register char row, col;
        putchar(' ' + row);
        putchar(' ' + col);
 out:
        putchar(' ' + row);
        putchar(' ' + col);
 out:
-       h19_col = col;
-       h19_row = row;
+       tt.tt_col = col;
+       tt.tt_row = row;
 }
 
 h19_init()
 {
 }
 
 h19_init()
 {
-       if (h19_VS)
-               fputs(h19_VS, stdout);
+       if (gen_VS)
+               fputs(gen_VS, stdout);
        esc();
        pc(w);
        esc();
        pc(E);
        esc();
        pc(w);
        esc();
        pc(E);
-       h19_col = h19_row = 0;
-       h19_insert = 0;
+       tt.tt_col = tt.tt_row = 0;
+       tt.tt_ninsert = tt.tt_insert = 0;
+       tt.tt_nmodes = tt.tt_modes = 0;
        h19_graphics = 0;
        h19_graphics = 0;
-       h19_modes = 0;
 }
 
 h19_end()
 }
 
 h19_end()
@@ -209,8 +178,8 @@ h19_end()
        SETMODES(0);
        SETINSERT(0);
        SETGRAPHICS(0);
        SETMODES(0);
        SETINSERT(0);
        SETGRAPHICS(0);
-       if (h19_VE)
-               fputs(h19_VE, stdout);
+       if (gen_VE)
+               fputs(gen_VE, stdout);
        esc();
        pc(v);
 }
        esc();
        pc(v);
 }
@@ -244,24 +213,25 @@ 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 */
-       h19_VS = tt_xgetstr("vs");
-       h19_VE = tt_xgetstr("ve");
-       tt.tt_setinsert = h19_setinsert;
-       tt.tt_setmodes = h19_setmodes;
+       gen_VS = tt_xgetstr("vs");
+       gen_VE = tt_xgetstr("ve");
+
+       tt.tt_init = h19_init;
+       tt.tt_end = h19_end;
+
        tt.tt_insline = h19_insline;
        tt.tt_delline = h19_delline;
        tt.tt_delchar = h19_delchar;
        tt.tt_insline = h19_insline;
        tt.tt_delline = h19_delline;
        tt.tt_delchar = h19_delchar;
-       tt.tt_blank = h19_blank;
-       tt.tt_init = h19_init;
-       tt.tt_end = h19_end;
        tt.tt_clreol = h19_clreol;
        tt.tt_clreos = h19_clreos;
        tt.tt_clear = h19_clear;
        tt.tt_move = h19_move;
        tt.tt_write = h19_write;
        tt.tt_putc = h19_putc;
        tt.tt_clreol = h19_clreol;
        tt.tt_clreos = h19_clreos;
        tt.tt_clear = h19_clear;
        tt.tt_move = h19_move;
        tt.tt_write = h19_write;
        tt.tt_putc = h19_putc;
-       tt.tt_ncol = 80;
-       tt.tt_nrow = 24;
+
+       tt.tt_ncol = NCOL;
+       tt.tt_nrow = NROW;
+       tt.tt_hasinsert = 1;
        tt.tt_availmodes = WWM_REV;
        tt.tt_frame = h19_frame;
        return 0;
        tt.tt_availmodes = WWM_REV;
        tt.tt_frame = h19_frame;
        return 0;
index 4e1d32b..dade03e 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwdata.c    3.5 83/09/15";
+static char *sccsid = "@(#)wwdata.c    3.6 83/09/15";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -19,8 +19,8 @@ struct ww_tty wwnewtty = {
 int tt_h19();
 int tt_generic();
 struct tt_tab tt_tab[] = {
 int tt_h19();
 int tt_generic();
 struct tt_tab tt_tab[] = {
-       { "h19", 3, tt_h19 },
-       { "generic", 0, tt_generic },
+       { "h19",        3, tt_h19 },
+       { "generic",    0, tt_generic },
        0
 };
 char *tt_strp = tt_strings;
        0
 };
 char *tt_strp = tt_strings;
index 27c77ef..430e0a7 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwdump.c    3.5 83/09/15";
+static char *sccsid = "@(#)wwdump.c    3.6 83/09/15";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -12,7 +12,7 @@ register struct ww *w;
 {
        register i, j;
 
 {
        register i, j;
 
-       (*tt.tt_setmodes)(0);
+       tt.tt_nmodes = 0;
        (*tt.tt_clear)();
        for (i = w->ww_i.t; i < w->ww_i.b; i++) {
                (*tt.tt_move)(i, w->ww_i.l);
        (*tt.tt_clear)();
        for (i = w->ww_i.t; i < w->ww_i.b; i++) {
                (*tt.tt_move)(i, w->ww_i.l);
@@ -26,7 +26,7 @@ register struct ww *w;
 {
        register i, j;
 
 {
        register i, j;
 
-       (*tt.tt_setmodes)(0);
+       tt.tt_nmodes = 0;
        (*tt.tt_clear)();
        for (i = w->ww_i.t; i < w->ww_i.b; i++) {
                (*tt.tt_move)(i, w->ww_i.l);
        (*tt.tt_clear)();
        for (i = w->ww_i.t; i < w->ww_i.b; i++) {
                (*tt.tt_move)(i, w->ww_i.l);
@@ -40,7 +40,7 @@ register struct ww *w;
 {
        register i;
 
 {
        register i;
 
-       (*tt.tt_setmodes)(0);
+       tt.tt_nmodes = 0;
        (*tt.tt_clear)();
        for (i = 0; i < w->ww_w.nr; i++) {
                (*tt.tt_move)(i, w->ww_w.l);
        (*tt.tt_clear)();
        for (i = 0; i < w->ww_w.nr; i++) {
                (*tt.tt_move)(i, w->ww_w.l);
@@ -54,7 +54,7 @@ wwdumpsmap()
 {
        register i, j;
 
 {
        register i, j;
 
-       (*tt.tt_setmodes)(0);
+       tt.tt_nmodes = 0;
        (*tt.tt_clear)();
        for (i = 0; i < wwnrow; i++) {
                (*tt.tt_move)(i, 0);
        (*tt.tt_clear)();
        for (i = 0; i < wwnrow; i++) {
                (*tt.tt_move)(i, 0);
@@ -72,7 +72,7 @@ wwdumpns()
        for (i = 0; i < wwnrow; i++) {
                (*tt.tt_move)(i, 0);
                for (j = 0; j < wwncol; j++) {
        for (i = 0; i < wwnrow; i++) {
                (*tt.tt_move)(i, 0);
                for (j = 0; j < wwncol; j++) {
-                       (*tt.tt_setmodes)(wwns[i][j].c_m);
+                       tt.tt_nmodes = wwns[i][j].c_m & tt.tt_availmodes;
                        (*tt.tt_putc)(wwns[i][j].c_c);
                }
        }
                        (*tt.tt_putc)(wwns[i][j].c_c);
                }
        }
@@ -86,7 +86,7 @@ wwdumpos()
        for (i = 0; i < wwnrow; i++) {
                (*tt.tt_move)(i, 0);
                for (j = 0; j < wwncol; j++) {
        for (i = 0; i < wwnrow; i++) {
                (*tt.tt_move)(i, 0);
                for (j = 0; j < wwncol; j++) {
-                       (*tt.tt_setmodes)(wwns[i][j].c_m);
+                       tt.tt_nmodes = wwos[i][j].c_m & tt.tt_availmodes;
                        (*tt.tt_putc)(wwns[i][j].c_c);
                }
        }
                        (*tt.tt_putc)(wwns[i][j].c_c);
                }
        }
index ddf22cb..a3b0cf8 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwinschar.c 3.8 83/09/15";
+static char *sccsid = "@(#)wwinschar.c 3.9 83/09/15";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -78,14 +78,14 @@ short c;
        /*
         * Can/Should we use delete character?
         */
        /*
         * Can/Should we use delete character?
         */
-       if (tt.tt_setinsert != 0 && nvis > (wwncol - col) / 2) {
+       if (tt.tt_hasinsert && nvis > (wwncol - col) / 2) {
                register union ww_char *p, *q;
 
                register union ww_char *p, *q;
 
-               (*tt.tt_setinsert)(1);
+               tt.tt_ninsert = 1;
+               tt.tt_nmodes = c >> WWC_MSHIFT & tt.tt_availmodes;
                (*tt.tt_move)(row, col);
                (*tt.tt_move)(row, col);
-               (*tt.tt_setmodes)(c >> WWC_MSHIFT);
                (*tt.tt_putc)(c & WWC_CMASK);
                (*tt.tt_putc)(c & WWC_CMASK);
-               (*tt.tt_setinsert)(0);
+               tt.tt_ninsert = 0;
 
                p = &wwos[row][wwncol];
                q = p - 1;
 
                p = &wwos[row][wwncol];
                q = p - 1;
index cab2e90..6cc0dda 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwupdate.c  3.7 83/08/19";
+static char *sccsid = "@(#)wwupdate.c  3.8 83/09/15";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -34,13 +34,13 @@ wwupdate()
                        if (j > wwncol)
                                break;
                        p = buf;
                        if (j > wwncol)
                                break;
                        p = buf;
-                       m = ns[-1].c_m;
+                       m = ns[-1].c_m & tt.tt_availmodes;
                        c = j - 1;
                        os[-1] = ns[-1];
                        *p++ = ns[-1].c_c;
                        x = 5;
                        q = p;
                        c = j - 1;
                        os[-1] = ns[-1];
                        *p++ = ns[-1].c_c;
                        x = 5;
                        q = p;
-                       while (j < wwncol && ns->c_m == m) {
+                       while (j < wwncol && (ns->c_m&tt.tt_availmodes) == m) {
                                *p++ = ns->c_c;
                                if (ns->c_w == os->c_w) {
                                        if (--x <= 0)
                                *p++ = ns->c_c;
                                if (ns->c_w == os->c_w) {
                                        if (--x <= 0)
@@ -55,27 +55,22 @@ wwupdate()
                                }
                                j++;
                        }
                                }
                                j++;
                        }
+                       tt.tt_nmodes = m;
+                       (*tt.tt_move)(i, c);
                        if (wwwrap
                            && i == wwnrow - 1 && q - buf + c == wwncol) {
                        if (wwwrap
                            && i == wwnrow - 1 && q - buf + c == wwncol) {
-                               if (tt.tt_setinsert != 0) {
+                               if (tt.tt_hasinsert) {
+                                       (*tt.tt_write)(buf + 1, q - buf - 1);
                                        (*tt.tt_move)(i, c);
                                        (*tt.tt_move)(i, c);
-                                       (*tt.tt_setmodes)(m);
-                                       (*tt.tt_write)(buf + 1, q - 1);
-                                       (*tt.tt_move)(i, c);
-                                       (*tt.tt_setinsert)(1);
-                                       (*tt.tt_write)(buf, buf);
-                                       (*tt.tt_setinsert)(0);
+                                       tt.tt_ninsert = 1;
+                                       (*tt.tt_write)(buf, 1);
+                                       tt.tt_ninsert = 0;
                                } else {
                                        os[-1] = lastc;
                                } else {
                                        os[-1] = lastc;
-                                       (*tt.tt_move)(i, c);
-                                       (*tt.tt_setmodes)(m);
-                                       (*tt.tt_write)(buf, q - 2);
+                                       (*tt.tt_write)(buf, q - buf - 1);
                                }
                                }
-                       } else {
-                               (*tt.tt_move)(i, c);
-                               (*tt.tt_setmodes)(m);
-                               (*tt.tt_write)(buf, q - 1);
-                       }
+                       } else
+                               (*tt.tt_write)(buf, q - buf);
                        didit++;
                }
                if (!didit)
                        didit++;
                }
                if (!didit)