reorganize window management to allow display routines to set
[unix-history] / usr / src / usr.bin / window / ww.h
index 7a167f0..8866b0f 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- *     @(#)ww.h        3.5 83/08/17    
+ *     @(#)ww.h        3.16 83/09/15   
  */
 
 #include <stdio.h>
  */
 
 #include <stdio.h>
@@ -28,25 +28,35 @@ struct ww {
        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_insert :1;      /* insert mode, for printing */
        char ww_mapnl :1;       /* map \n to \r\n */
        char ww_haspty :1;      /* has pty */
+       char ww_hascursor :1;   /* has fake cursor */
+       char ww_hasframe :1;    /* frame it */
        char ww_index;          /* the index, for wwindex[] */
        char ww_order;          /* the overlapping order */
        char ww_index;          /* the index, for wwindex[] */
        char ww_order;          /* the overlapping order */
-       struct ww_dim ww_w;     /* window dimemsions */
-       short ww_nline;         /* size of the buffer */
-       short ww_scroll;        /* where the window is relative to the buffer */
+
+               /* sizes and positions */
+       struct ww_dim ww_w;     /* window size and pos */
+       struct ww_dim ww_b;     /* buffer size and pos */
+       struct ww_dim ww_i;     /* the part inside the screen */
        struct ww_pos ww_cur;   /* the cursor position, relative to ww_w */
        struct ww_pos ww_cur;   /* the cursor position, relative to ww_w */
+
+               /* arrays */
        char **ww_win;          /* the window */
        union ww_char **ww_buf; /* the buffer */
        char **ww_cov;          /* the covered-by array */
        char **ww_win;          /* the window */
        union ww_char **ww_buf; /* the buffer */
        char **ww_cov;          /* the covered-by array */
+       char **ww_fmap;         /* map for frame and box windows */
        short *ww_nvis;         /* how many ww_buf chars are visible per row */
        short *ww_nvis;         /* how many ww_buf chars are visible per row */
+
+               /* things for the window process */
        int ww_pty;             /* file descriptor of pty */
        int ww_tty;             /* . . . tty */
        int ww_pid;             /* pid of process, if WWS_HASPROC true */
        char ww_ttyname[11];    /* "/dev/ttyp?" */
        int ww_pty;             /* file descriptor of pty */
        int ww_tty;             /* . . . tty */
        int ww_pid;             /* pid of process, if WWS_HASPROC true */
        char ww_ttyname[11];    /* "/dev/ttyp?" */
-       /* below are things for the user */
-       char ww_hasframe :1;    /* frame it */
+
+               /* things for the user, they really don't belong here */
        char ww_center :1;      /* center the label */
        char ww_center :1;      /* center the label */
-       int ww_id;              /* the user id */
+       int ww_id;              /* the user window id */
        char *ww_label;         /* the user supplied label */
        char *ww_label;         /* the user supplied label */
+       struct ww_pos ww_altpos;/* alternate position */
 };
 
 struct ww_tty {
 };
 
 struct ww_tty {
@@ -86,12 +96,7 @@ union ww_char {
 #define WWS_INCHILD    2       /* forked, in child */
 #define WWS_DEAD       3       /* child died */
 
 #define WWS_INCHILD    2       /* forked, in child */
 #define WWS_DEAD       3       /* child died */
 
-       /* flags to wwopen() */
-#define WWO_PTY                0x01            /* want pty */
-#define WWO_REVERSE    0x02            /* make it all reverse video */
-#define WWO_GLASS      0x04            /* make it all glass */
-
-       /* flags for wwfmap */
+       /* flags for ww_fmap */
 #define WWF_U          0x01
 #define WWF_R          0x02
 #define WWF_D          0x04
 #define WWF_U          0x01
 #define WWF_R          0x02
 #define WWF_D          0x04
@@ -100,9 +105,24 @@ union ww_char {
 #define WWF_LABEL      0x40
 #define WWF_TOP                0x80
 
 #define WWF_LABEL      0x40
 #define WWF_TOP                0x80
 
+       /* flags to wwopen() */
+#define WWO_PTY                0x01            /* want pty */
+#define WWO_REVERSE    0x02            /* make it all reverse video */
+#define WWO_GLASS      0x04            /* make it all glass */
+#define WWO_FRAME      0x08            /* this is a frame window */
+
        /* special ww_index value */
 #define WWX_NOBODY     NWW
 
        /* special ww_index value */
 #define WWX_NOBODY     NWW
 
+#define WWE_NOERR      0
+#define WWE_SYS                1               /* system error */
+#define WWE_NOMEM      2               /* out of memory */
+#define WWE_TOOMANY    3               /* too many windows */
+#define WWE_NOPTY      4               /* no more ptys */
+#define WWE_SIZE       5               /* bad window size */
+#define WWE_BADTERM    6               /* bad terminal type */
+#define WWE_CANTDO     7               /* dumb terminal */
+
 struct ww wwhead;
 struct ww *wwindex[NWW + 1];           /* last location is for wwnobody */
 struct ww wwnobody;
 struct ww wwhead;
 struct ww *wwindex[NWW + 1];           /* last location is for wwnobody */
 struct ww wwnobody;
@@ -116,33 +136,36 @@ char wwkeys[512];         /* termcap fields for the function keys */
 
 int wwnrow, wwncol;            /* the screen size */
 char wwavailmodes;             /* actually supported modes */
 
 int wwnrow, wwncol;            /* the screen size */
 char wwavailmodes;             /* actually supported modes */
+char wwcursormodes;            /* the modes for the fake cursor */
+char wwwrap;                   /* terminal has auto wrap around */
 int wwdtablesize;              /* result of getdtablesize() call */
 char **wwsmap;                 /* the screen map */
 int wwdtablesize;              /* result of getdtablesize() call */
 char **wwsmap;                 /* the screen map */
-char **wwfmap;                 /* the frame map */
 union ww_char **wwos;          /* the old (current) screen */
 union ww_char **wwns;          /* the new (desired) screen */
 char *wwtouched;               /* wwns changed flags */
 int wwbaudmap[];               /* maps stty() baud rate code into number */
 int wwbaud;                    /* wwbaudmap[wwoldtty.ww_sgttyb.sg_ospeed] */
 int wwcursorrow, wwcursorcol;  /* where we want the cursor to be */
 union ww_char **wwos;          /* the old (current) screen */
 union ww_char **wwns;          /* the new (desired) screen */
 char *wwtouched;               /* wwns changed flags */
 int wwbaudmap[];               /* maps stty() baud rate code into number */
 int wwbaud;                    /* wwbaudmap[wwoldtty.ww_sgttyb.sg_ospeed] */
 int wwcursorrow, wwcursorcol;  /* where we want the cursor to be */
+int wwerrno;                   /* error number */
 
        /* statistics */
 int wwnwrite, wwnwritec;
 int wwnupdate, wwntouched, wwnmiss;
 
        /* quicky macros */
 
        /* statistics */
 int wwnwrite, wwnwritec;
 int wwnupdate, wwntouched, wwnmiss;
 
        /* quicky macros */
-#define wwcurrow(w)    ((w)->ww_cur.r + (w)->ww_w.t)
-#define wwcurcol(w)    ((w)->ww_cur.c + (w)->ww_w.l)
 #define wwsetcursor(r,c) (wwcursorrow = (r), wwcursorcol = (c))
 #define wwsetcursor(r,c) (wwcursorrow = (r), wwcursorcol = (c))
-#define wwcurtowin(w)  wwsetcursor(wwcurrow(w), wwcurcol(w))
+#define wwcurtowin(w)  wwsetcursor((w)->ww_cur.r, (w)->ww_cur.c)
 #define wwbell()       putchar(CTRL(g))
 #define wwbell()       putchar(CTRL(g))
+#define wwunbox(w)     wwunframe(w)
+#define wwclreol(w,r,c)        wwclreol1((w), (r), (c), 0)
+#define wwredrawwin(w) wwredrawwin1((w), (w)->ww_i.t, (w)->ww_i.b, 0)
 
        /* the window virtual terminal */
 #define WWT_TERM       "TERM=window"
 
        /* the window virtual terminal */
 #define WWT_TERM       "TERM=window"
-#define WWT_TERMCAP    "TERMCAP=WW|window|window package:\
+#define WWT_TERMCAP    "WW|window|window package:\
        :cr=^M:nl=^J:bl=^G:\
        :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:\
+       :al=\\EL:am:le=^H:bs:cd=\\EJ:ce=\\EK:cl=\\EE:cm=\\EY%%+ :\
+       :da:db:dc=\\EN:dl=\\EM:do=\\EB:ei=\\EO:ho=\\EH:im=\\E@:mi:\
        :nd=\\EC:ta=^I:pt:up=\\EA:"
 #define WWT_REV                "se=\\Eq:so=\\Ep:"
 #define WWT_UL         "ue=\\Es:us=\\Er:"
        :nd=\\EC:ta=^I:pt:up=\\EA:"
 #define WWT_REV                "se=\\Eq:so=\\Ep:"
 #define WWT_UL         "ue=\\Es:us=\\Er:"
@@ -154,6 +177,7 @@ int wwchild();
 int wwsuspend();
 char *unctrl();
 char **wwalloc();
 int wwsuspend();
 char *unctrl();
 char **wwalloc();
+char *wwerror();
 
        /* c library functions */
 char *malloc();
 
        /* c library functions */
 char *malloc();