ww_availmodes and stuff
authorEdward Wang <edward@ucbvax.Berkeley.EDU>
Thu, 18 Aug 1983 05:51:49 +0000 (21:51 -0800)
committerEdward Wang <edward@ucbvax.Berkeley.EDU>
Thu, 18 Aug 1983 05:51:49 +0000 (21:51 -0800)
SCCS-vsn: usr.bin/window/wwspawn.c 3.2
SCCS-vsn: usr.bin/window/wwinit.c 3.5
SCCS-vsn: usr.bin/window/ww.h 3.5
SCCS-vsn: usr.bin/window/wwwrite.c 3.4
SCCS-vsn: usr.bin/window/ttgeneric.c 3.7

usr/src/usr.bin/window/ttgeneric.c
usr/src/usr.bin/window/ww.h
usr/src/usr.bin/window/wwinit.c
usr/src/usr.bin/window/wwspawn.c
usr/src/usr.bin/window/wwwrite.c

index a4909a3..2beed49 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)ttgeneric.c 3.6 83/08/15";
+static char *sccsid = "@(#)ttgeneric.c 3.7 83/08/17";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -17,7 +17,6 @@ char gen_frame[16] = {
 
 int gen_row, gen_col;
 char gen_modes;
 
 int gen_row, gen_col;
 char gen_modes;
-char gen_availmodes;
 char gen_insert;
 
 char *gen_CM;
 char gen_insert;
 
 char *gen_CM;
@@ -85,7 +84,7 @@ register new;
 {
        register diff;
 
 {
        register diff;
 
-       new &= gen_availmodes;
+       new &= tt.tt_availmodes;
        if ((diff = new ^ gen_modes) == 0)
                return;
        if (diff & WWM_REV) {
        if ((diff = new ^ gen_modes) == 0)
                return;
        if (diff & WWM_REV) {
@@ -339,9 +338,9 @@ tt_generic()
        }
 
        if (gen_SO)
        }
 
        if (gen_SO)
-               gen_availmodes |= WWM_REV;
+               tt.tt_availmodes |= WWM_REV;
        if (gen_US)
        if (gen_US)
-               gen_availmodes |= WWM_UL;
+               tt.tt_availmodes |= WWM_UL;
        if (gen_IM)
                tt.tt_setinsert = gen_setinsert;
        if (gen_DC)
        if (gen_IM)
                tt.tt_setinsert = gen_setinsert;
        if (gen_DC)
index ed8f443..7a167f0 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- *     @(#)ww.h        3.4 83/08/16    
+ *     @(#)ww.h        3.5 83/08/17    
  */
 
 #include <stdio.h>
  */
 
 #include <stdio.h>
@@ -24,9 +24,10 @@ struct ww {
        struct ww *ww_back;
        char ww_state;          /* state of window creation */
        char ww_wstate;         /* state for printing charcters */
        struct ww *ww_back;
        char ww_state;          /* state of window creation */
        char ww_wstate;         /* state for printing charcters */
-       int ww_insert :1;       /* insert mode, for printing */
-       int ww_mapnl :1;        /* map \n to \r\n */
-       int ww_haspty :1;       /* has pty */
+       char ww_modes;          /* current printing modes */
+       char ww_insert :1;      /* insert mode, for printing */
+       char ww_mapnl :1;       /* map \n to \r\n */
+       char ww_haspty :1;      /* has pty */
        char ww_index;          /* the index, for wwindex[] */
        char ww_order;          /* the overlapping order */
        struct ww_dim ww_w;     /* window dimemsions */
        char ww_index;          /* the index, for wwindex[] */
        char ww_order;          /* the overlapping order */
        struct ww_dim ww_w;     /* window dimemsions */
@@ -114,6 +115,7 @@ char wwtermcap[1024];               /* place for the termcap */
 char wwkeys[512];              /* termcap fields for the function keys */
 
 int wwnrow, wwncol;            /* the screen size */
 char wwkeys[512];              /* termcap fields for the function keys */
 
 int wwnrow, wwncol;            /* the screen size */
+char wwavailmodes;             /* actually supported modes */
 int wwdtablesize;              /* result of getdtablesize() call */
 char **wwsmap;                 /* the screen map */
 char **wwfmap;                 /* the frame map */
 int wwdtablesize;              /* result of getdtablesize() call */
 char **wwsmap;                 /* the screen map */
 char **wwfmap;                 /* the frame map */
@@ -135,6 +137,16 @@ int wwnupdate, wwntouched, wwnmiss;
 #define wwcurtowin(w)  wwsetcursor(wwcurrow(w), wwcurcol(w))
 #define wwbell()       putchar(CTRL(g))
 
 #define wwcurtowin(w)  wwsetcursor(wwcurrow(w), wwcurcol(w))
 #define wwbell()       putchar(CTRL(g))
 
+       /* the window virtual terminal */
+#define WWT_TERM       "TERM=window"
+#define WWT_TERMCAP    "TERMCAP=WW|window|window package:\
+       :cr=^M:nl=^J:bl=^G:\
+       :al=\\EL:am:le=^H:bs:cd=\\EJ:ce=\\EK:cl=\\EE:cm=\\EY%%+ %%+ :\
+       :co#%d:dc=\\EN:dl=\\EM:do=\\EB:ei=\\EO:ho=\\EH:li#%d:im=\\E@:mi:\
+       :nd=\\EC:ta=^I:pt:up=\\EA:"
+#define WWT_REV                "se=\\Eq:so=\\Ep:"
+#define WWT_UL         "ue=\\Es:us=\\Er:"
+
        /* our functions */
 struct ww *wwopen();
 struct ww *wwfind();
        /* our functions */
 struct ww *wwopen();
 struct ww *wwfind();
index def597d..b2dd8df 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwinit.c    3.4 83/08/16";
+static char *sccsid = "@(#)wwinit.c    3.5 83/08/17";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -41,6 +41,7 @@ wwinit()
                goto bad;
        wwnrow = tt.tt_nrow;
        wwncol = tt.tt_ncol;
                goto bad;
        wwnrow = tt.tt_nrow;
        wwncol = tt.tt_ncol;
+       wwavailmodes = tt.tt_availmodes;
        (*tt.tt_init)();
 
        if ((wwsmap = wwalloc(wwnrow, wwncol, sizeof (char))) == 0)
        (*tt.tt_init)();
 
        if ((wwsmap = wwalloc(wwnrow, wwncol, sizeof (char))) == 0)
index 16d03c4..3a87bc1 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwspawn.c   3.1 83/08/11";
+static char *sccsid = "@(#)wwspawn.c   3.2 83/08/17";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -22,47 +22,3 @@ register struct ww *wp;
                return wp->ww_pid;
        }
 }
                return wp->ww_pid;
        }
 }
-
-#define TERM   "TERM=window"
-#define TERMCAP        "TERMCAP=WW|window|window package:\
-       :cr=^M:nl=^J:bl=^G:\
-       :al=\\EL:am:le=^H:bs:cd=\\EJ:ce=\\EK:cl=\\EE:cm=\\EY%%+ %%+ :\
-       :co#%d:dc=\\EN:dl=\\EM:do=\\EB:ei=\\EO:ho=\\EH:li#%d:im=\\E@:mi:\
-       :nd=\\EC:ta=^I:pt:up=\\EA:"
-static char *env[100];
-static char buf[1024];
-extern char **environ;
-
-wwenviron(wp)
-register struct ww *wp;
-{
-       register i;
-       register char **p, **q;
-       char **termcap = 0;
-
-       (void) dup2(wp->ww_tty, 0);
-       (void) dup2(wp->ww_tty, 1);
-       (void) dup2(wp->ww_tty, 2);
-       for (i = wwdtablesize - 1; i > 2; i--)
-               (void) close(i);
-
-       i = open("/dev/tty");
-       (void) ioctl(i, (int)TIOCNOTTY, (char *)0);
-       (void) close(i);
-       (void) open(wp->ww_ttyname, 0);
-
-       for (p = environ, q = env; *p; p++, q++) {
-               if (strncmp(*p, "TERM=", 5) == 0)
-                       *q = TERM;
-               else if (strncmp(*p, "TERMCAP=", 8) == 0)
-                       termcap = q;
-               else
-                       *q = *p;
-       }
-       if (termcap == 0)
-               termcap = q++;
-       *q = 0;
-       *termcap = sprintf(buf, TERMCAP, wp->ww_w.nc, wp->ww_w.nr);
-       (void) strcat(buf, wwkeys);
-       environ = env;
-}
index 174c8d2..dcc0c76 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwwrite.c   3.3 83/08/16";
+static char *sccsid = "@(#)wwwrite.c   3.4 83/08/17";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -37,10 +37,11 @@ int n;
                                i = w->ww_w.nc - w->ww_cur.c - 1;
                                bp = bq = &w->ww_buf[w->ww_scroll+w->ww_cur.r]
                                        [w->ww_cur.c];
                                i = w->ww_w.nc - w->ww_cur.c - 1;
                                bp = bq = &w->ww_buf[w->ww_scroll+w->ww_cur.r]
                                        [w->ww_cur.c];
-                               bp++->c_w = c;
+                               bp++->c_w = c | w->ww_modes << WWC_MSHIFT;
                                while (n > 0 && --i >= 0 && !ISCTRL(*p)) {
                                        n--;
                                while (n > 0 && --i >= 0 && !ISCTRL(*p)) {
                                        n--;
-                                       bp++->c_w = *p++;
+                                       bp++->c_w = *p++ & 0x7f
+                                               | w->ww_modes << WWC_MSHIFT;
                                }
                                win = &w->ww_win[w->ww_cur.r][w->ww_cur.c];
                                i = wwcurrow(w);
                                }
                                win = &w->ww_win[w->ww_cur.r][w->ww_cur.c];
                                i = wwcurrow(w);
@@ -146,6 +147,18 @@ int n;
                        case 'Y':
                                w->ww_wstate = 2;
                                break;
                        case 'Y':
                                w->ww_wstate = 2;
                                break;
+                       case 'p':
+                               w->ww_modes |= WWM_REV;
+                               break;
+                       case 'q':
+                               w->ww_modes &= ~WWM_REV;
+                               break;
+                       case 'r':
+                               w->ww_modes |= WWM_UL;
+                               break;
+                       case 's':
+                               w->ww_modes &= ~WWM_UL;
+                               break;
                        }
                        break;
                case 2:
                        }
                        break;
                case 2: