nicer termcap interface and use vs and ve strings in tth19.c
authorEdward Wang <edward@ucbvax.Berkeley.EDU>
Thu, 18 Aug 1983 06:35:35 +0000 (22:35 -0800)
committerEdward Wang <edward@ucbvax.Berkeley.EDU>
Thu, 18 Aug 1983 06:35:35 +0000 (22:35 -0800)
SCCS-vsn: usr.bin/window/tt.h 3.5
SCCS-vsn: usr.bin/window/tth19.c 3.6
SCCS-vsn: usr.bin/window/wwdata.c 3.4
SCCS-vsn: usr.bin/window/ttgeneric.c 3.8

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

index 74e3544..798fe79 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- *     @(#)tt.h        3.4 83/08/17
+ *     @(#)tt.h        3.5 83/08/17
  */
 
 struct tt {
  */
 
 struct tt {
@@ -32,3 +32,16 @@ struct tt_tab {
 };
 
 struct tt_tab tt_tab[];
 };
 
 struct tt_tab tt_tab[];
+
+/*
+ * nicer interface to termcap routines
+ */
+char tt_strings[1024];         /* string buffer */
+char *tt_strp;                 /* pointer for it */
+
+int tt_pc();                   /* just putchar() */
+int tt_sc();                   /* *tt_strp++ = c */
+char *tt_xgetstr();            /* tgetstr() and expand delays */
+
+#define tt_tgetstr(s)  tgetstr((s), &tt_strp)
+#define tt_tputs(s, n) tputs((s), (n), tt_pc)
index 2beed49..c990511 100644 (file)
@@ -1,11 +1,10 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)ttgeneric.c 3.7 83/08/17";
+static char *sccsid = "@(#)ttgeneric.c 3.8 83/08/17";
 #endif
 
 #include "ww.h"
 #include "tt.h"
 
 #endif
 
 #include "ww.h"
 #include "tt.h"
 
-char *tgetstr();
 char *tgoto();
 
 char gen_frame[16] = {
 char *tgoto();
 
 char gen_frame[16] = {
@@ -55,16 +54,6 @@ char *gen_strp = gen_strings;
 #define pc(c) putchar('c')
 #define ps(s) fputs((s), stdout)
 
 #define pc(c) putchar('c')
 #define ps(s) fputs((s), stdout)
 
-gen_pc(c)
-{
-       putchar(c);
-}
-
-gen_sc(c)
-{
-       *gen_strp++ = c;
-}
-
 gen_setinsert(new)
 char new;
 {
 gen_setinsert(new)
 char new;
 {
@@ -109,13 +98,13 @@ register new;
 gen_insline()
 {
        if (gen_AL)
 gen_insline()
 {
        if (gen_AL)
-               tputs(gen_AL, gen_LI - gen_row, gen_pc);
+               tt_tputs(gen_AL, gen_LI - gen_row);
 }
 
 gen_delline()
 {
        if (gen_DL)
 }
 
 gen_delline()
 {
        if (gen_DL)
-               tputs(gen_DL, gen_LI - gen_row, gen_pc);
+               tt_tputs(gen_DL, gen_LI - gen_row);
 }
 
 gen_putc(c)
 }
 
 gen_putc(c)
@@ -123,10 +112,10 @@ register char c;
 {
        if (gen_insert) {
                if (gen_IC)
 {
        if (gen_insert) {
                if (gen_IC)
-                       tputs(gen_IC, gen_CO - gen_col, gen_pc);
+                       tt_tputs(gen_IC, gen_CO - gen_col);
                putchar(c);
                if (gen_IP)
                putchar(c);
                if (gen_IP)
-                       tputs(gen_IP, gen_CO - gen_col, gen_pc);
+                       tt_tputs(gen_IP, gen_CO - gen_col);
        } else
                putchar(c);
        gen_col++;
        } else
                putchar(c);
        gen_col++;
@@ -138,10 +127,10 @@ register char *start, *end;
        if (gen_insert) {
                while (start <= end) {
                        if (gen_IC)
        if (gen_insert) {
                while (start <= end) {
                        if (gen_IC)
-                               tputs(gen_IC, gen_CO - gen_col, gen_pc);
+                               tt_tputs(gen_IC, gen_CO - gen_col);
                        putchar(*start++);
                        if (gen_IP)
                        putchar(*start++);
                        if (gen_IP)
-                               tputs(gen_IP, gen_CO - gen_col, gen_pc);
+                               tt_tputs(gen_IP, gen_CO - gen_col);
                        gen_col++;
                }
        } else {
                        gen_col++;
                }
        } else {
@@ -159,10 +148,10 @@ register n;
        if (gen_insert) {
                while (--n >= 0) {
                        if (gen_IC)
        if (gen_insert) {
                while (--n >= 0) {
                        if (gen_IC)
-                               tputs(gen_IC, gen_CO - gen_col, gen_pc);
+                               tt_tputs(gen_IC, gen_CO - gen_col);
                        putchar(' ');
                        if (gen_IP)
                        putchar(' ');
                        if (gen_IP)
-                               tputs(gen_IP, gen_CO - gen_col, gen_pc);
+                               tt_tputs(gen_IP, gen_CO - gen_col);
                        gen_col++;
                }
        } else {
                        gen_col++;
                }
        } else {
@@ -215,7 +204,7 @@ register char row, col;
                ps(gen_HO);
                goto out;
        }
                ps(gen_HO);
                goto out;
        }
-       tputs(tgoto(gen_CM, col, row), 1, gen_pc);
+       ps(tgoto(gen_CM, col, row));
 out:
        gen_col = col;
        gen_row = row;
 out:
        gen_col = col;
        gen_row = row;
@@ -249,13 +238,13 @@ gen_end()
 gen_clreol()
 {
        if (gen_CE)
 gen_clreol()
 {
        if (gen_CE)
-               tputs(gen_CE, gen_CO - gen_col, gen_pc);
+               tt_tputs(gen_CE, gen_CO - gen_col);
 }
 
 gen_clreos()
 {
        if (gen_CD)
 }
 
 gen_clreos()
 {
        if (gen_CD)
-               tputs(gen_CD, gen_LI - gen_row, gen_pc);
+               tt_tputs(gen_CD, gen_LI - gen_row);
 }
 
 gen_clear()
 }
 
 gen_clear()
@@ -267,50 +256,34 @@ gen_clear()
 gen_delchar()
 {
        if (gen_DC)
 gen_delchar()
 {
        if (gen_DC)
-               tputs(gen_DC, gen_CO - gen_col, gen_pc);
-}
-
-char *
-gen_getstr(str)
-char *str;
-{
-       char buf[100];
-       char *bufp = buf;
-
-       str = tgetstr(str, &bufp);
-       if (str == 0)
-               return 0;
-       str = gen_strp;
-       tputs(buf, 1, gen_sc);
-       gen_sc(0);
-       return str;
+               tt_tputs(gen_DC, gen_CO - gen_col);
 }
 
 tt_generic()
 {
 }
 
 tt_generic()
 {
-       gen_CM = tgetstr("cm", &gen_strp);
-       gen_IM = gen_getstr("im");
-       gen_IC = tgetstr("ic", &gen_strp);
-       gen_IP = tgetstr("ip", &gen_strp);
-       gen_EI = gen_getstr("ei");
-       gen_DC = tgetstr("dc", &gen_strp);
-       gen_AL = tgetstr("al", &gen_strp);
-       gen_DL = tgetstr("dl", &gen_strp);
-       gen_CE = tgetstr("ce", &gen_strp);
-       gen_CD = tgetstr("cd", &gen_strp);
-       gen_CL = gen_getstr("cl");
-       gen_VS = gen_getstr("vs");
-       gen_VE = gen_getstr("ve");
-       gen_SO = gen_getstr("so");
-       gen_SE = gen_getstr("se");
-       gen_US = gen_getstr("us");
-       gen_UE = gen_getstr("ue");
-       gen_UP = gen_getstr("up");
-       gen_PC = tgetstr("pc", &gen_strp);
-       gen_BC = gen_getstr("bc");
-       gen_ND = gen_getstr("nd");
-       gen_HO = gen_getstr("ho");
-       gen_NL = gen_getstr("nl");
+       gen_CM = tt_xgetstr("cm");              /* may not work */
+       gen_IM = tt_xgetstr("im");
+       gen_IC = tt_tgetstr("ic");
+       gen_IP = tt_tgetstr("ip");
+       gen_EI = tt_xgetstr("ei");
+       gen_DC = tt_tgetstr("dc");
+       gen_AL = tt_tgetstr("al");
+       gen_DL = tt_tgetstr("dl");
+       gen_CE = tt_tgetstr("ce");
+       gen_CD = tt_tgetstr("cd");
+       gen_CL = tt_xgetstr("cl");
+       gen_VS = tt_xgetstr("vs");
+       gen_VE = tt_xgetstr("ve");
+       gen_SO = tt_xgetstr("so");
+       gen_SE = tt_xgetstr("se");
+       gen_US = tt_xgetstr("us");
+       gen_UE = tt_xgetstr("ue");
+       gen_UP = tt_xgetstr("up");
+       gen_PC = tt_tgetstr("pc");
+       gen_BC = tt_xgetstr("bc");
+       gen_ND = tt_xgetstr("nd");
+       gen_HO = tt_xgetstr("ho");
+       gen_NL = tt_xgetstr("nl");
        gen_MI = tgetflag("mi");
        gen_MS = tgetflag("ms");
        gen_AM = tgetflag("am");
        gen_MI = tgetflag("mi");
        gen_MS = tgetflag("ms");
        gen_AM = tgetflag("am");
index c5275b2..eb59b73 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)tth19.c     3.5 83/08/17";
+static char *sccsid = "@(#)tth19.c     3.6 83/08/17";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -29,6 +29,8 @@ char h19_modes, h19_nmodes;
 char h19_insert, h19_ninsert;
 char h19_graphics;
 short h19_msp10c;
 char h19_insert, h19_ninsert;
 char h19_graphics;
 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)
@@ -185,13 +187,12 @@ out:
 
 h19_init()
 {
 
 h19_init()
 {
+       if (h19_VS)
+               fputs(h19_VS, stdout);
        esc();
        esc();
-       pc(x);
-       pc(4);
+       pc(w);
        esc();
        pc(E);
        esc();
        pc(E);
-       esc();
-       pc(w);
        h19_col = h19_row = 0;
        h19_insert = 0;
        h19_graphics = 0;
        h19_col = h19_row = 0;
        h19_insert = 0;
        h19_graphics = 0;
@@ -203,9 +204,8 @@ h19_end()
        SETMODES(0);
        SETINSERT(0);
        SETGRAPHICS(0);
        SETMODES(0);
        SETINSERT(0);
        SETGRAPHICS(0);
-       esc();
-       pc(y);
-       pc(4);
+       if (h19_VE)
+               fputs(h19_VE, stdout);
        esc();
        pc(v);
 }
        esc();
        pc(v);
 }
@@ -239,6 +239,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 */
+       h19_VS = tt_xgetstr("vs");
+       h19_VE = tt_xgetstr("ve");
        tt.tt_setinsert = h19_setinsert;
        tt.tt_setmodes = h19_setmodes;
        tt.tt_insline = h19_insline;
        tt.tt_setinsert = h19_setinsert;
        tt.tt_setmodes = h19_setmodes;
        tt.tt_insline = h19_insline;
index e75f108..84125ca 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwdata.c    3.3 83/08/15";
+static char *sccsid = "@(#)wwdata.c    3.4 83/08/17";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -23,6 +23,7 @@ struct tt_tab tt_tab[] = {
        { "generic", 0, tt_generic },
        0
 };
        { "generic", 0, tt_generic },
        0
 };
+char *tt_strp = tt_strings;
 
 int wwbaudmap[] = {
        0,
 
 int wwbaudmap[] = {
        0,