Annotation of 43BSD/ucb/window/ww.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * @(#)ww.h    3.37 5/2/86     
                      3:  */
                      4: 
                      5: /*
                      6:  * Copyright (c) 1983 Regents of the University of California,
                      7:  * All rights reserved.  Redistribution permitted subject to
                      8:  * the terms of the Berkeley Software License Agreement.
                      9:  */
                     10: 
                     11: #include <sgtty.h>
                     12: #include <setjmp.h>
                     13: 
                     14: #define NWW    30              /* maximum number of windows */
                     15: 
                     16:        /* a rectangle */
                     17: struct ww_dim {
                     18:        int nr;                 /* number of rows */
                     19:        int nc;                 /* number of columns */
                     20:        int t, b;               /* top, bottom */
                     21:        int l, r;               /* left, right */
                     22: };
                     23: 
                     24:        /* a coordinate */
                     25: struct ww_pos {
                     26:        int r;                  /* row */
                     27:        int c;                  /* column */
                     28: };
                     29: 
                     30:        /* the window structure */
                     31: struct ww {
                     32:                /* general flags and states */
                     33:        char ww_state;          /* state of window */
                     34:        char ww_oflags;         /* wwopen flags */
                     35: 
                     36:                /* information for overlap */
                     37:        struct ww *ww_forw;     /* doubly linked list, for overlapping info */
                     38:        struct ww *ww_back;
                     39:        char ww_index;          /* the window index, for wwindex[] */
                     40:        char ww_order;          /* the overlapping order */
                     41: 
                     42:                /* sizes and positions */
                     43:        struct ww_dim ww_w;     /* window size and pos */
                     44:        struct ww_dim ww_b;     /* buffer size and pos */
                     45:        struct ww_dim ww_i;     /* the part inside the screen */
                     46:        struct ww_pos ww_cur;   /* the cursor position, relative to ww_w */
                     47: 
                     48:                /* arrays */
                     49:        char **ww_win;          /* the window */
                     50:        union ww_char **ww_buf; /* the buffer */
                     51:        char **ww_fmap;         /* map for frame and box windows */
                     52:        short *ww_nvis;         /* how many ww_buf chars are visible per row */
                     53: 
                     54:                /* information for wwwrite() and company */
                     55:        char ww_wstate;         /* state for outputting characters */
                     56:        char ww_modes;          /* current display modes */
                     57:        char ww_insert;         /* insert mode */
                     58:        char ww_mapnl;          /* map \n to \r\n */
                     59:        char ww_noupdate;       /* don't do updates in wwwrite() */
                     60:        char ww_unctrl;         /* expand control characters */
                     61:        char ww_nointr;         /* wwwrite() not interruptable */
                     62:        char ww_hascursor;      /* has fake cursor */
                     63: 
                     64:                /* things for the window process and io */
                     65:        char ww_ispty;          /* ww_pty is really a pty, not socket pair */
                     66:        char ww_stopped;        /* output stopped */
                     67:        int ww_pty;             /* file descriptor of pty or socket pair */
                     68:        int ww_socket;          /* other end of socket pair */
                     69:        int ww_pid;             /* pid of process, if WWS_HASPROC true */
                     70:        char ww_ttyname[11];    /* "/dev/ttyp?" */
                     71:        char *ww_ob;            /* output buffer */
                     72:        char *ww_obe;           /* end of ww_ob */
                     73:        char *ww_obp;           /* current read position in ww_ob */
                     74:        char *ww_obq;           /* current write position in ww_ob */
                     75: 
                     76:                /* things for the user, they really don't belong here */
                     77:        char ww_id;             /* the user window id */
                     78:        char ww_center;         /* center the label */
                     79:        char ww_hasframe;       /* frame it */
                     80:        char *ww_label;         /* the user supplied label */
                     81:        struct ww_dim ww_alt;   /* alternate position and size */
                     82: };
                     83: 
                     84:        /* state of a tty */
                     85: struct ww_tty {
                     86:        struct sgttyb ww_sgttyb;
                     87:        struct tchars ww_tchars;
                     88:        struct ltchars ww_ltchars;
                     89:        int ww_lmode;
                     90:        int ww_ldisc;
                     91:        int ww_fflags;
                     92: };
                     93: 
                     94: union ww_char {
                     95:        short c_w;              /* as a word */
                     96:        struct {
                     97: #ifndef mc68000
                     98:                char C_c;       /* the character part */
                     99:                char C_m;       /* the mode part */
                    100: #else
                    101:                char C_m;       /* the mode part */
                    102:                char C_c;       /* the character part */
                    103: #endif
                    104:        } c_un;
                    105: };
                    106: #define c_c c_un.C_c
                    107: #define c_m c_un.C_m
                    108: 
                    109:        /* parts of ww_char */
                    110: #define WWC_CMASK      0x00ff
                    111: #define WWC_MMASK      0xff00
                    112: #define WWC_MSHIFT     8
                    113: 
                    114:        /* c_m bits */
                    115: #define WWM_REV                0x01    /* reverse video */
                    116: #define WWM_BLK                0x02    /* blinking */
                    117: #define WWM_UL         0x04    /* underlined */
                    118: #define WWM_GRP                0x08    /* graphics */
                    119: #define WWM_USR                0x10    /* user specified mode */
                    120: #define WWM_GLS                0x40    /* window only, glass, i.e. transparent */
                    121: 
                    122:        /* ww_state values */
                    123: #define WWS_INITIAL    0       /* just opened */
                    124: #define WWS_HASPROC    1       /* has process on pty */
                    125: #define WWS_DEAD       3       /* child died */
                    126: 
                    127:        /* flags for ww_fmap */
                    128: #define WWF_U          0x01
                    129: #define WWF_R          0x02
                    130: #define WWF_D          0x04
                    131: #define WWF_L          0x08
                    132: #define WWF_MASK       (WWF_U|WWF_R|WWF_D|WWF_L)
                    133: #define WWF_LABEL      0x40
                    134: #define WWF_TOP                0x80
                    135: 
                    136:        /* flags to wwopen() */
                    137: #define WWO_PTY                0x01            /* want pty */
                    138: #define WWO_SOCKET     0x02            /* want socket pair */
                    139: #define WWO_REVERSE    0x04            /* make it all reverse video */
                    140: #define WWO_GLASS      0x08            /* make it all glass */
                    141: #define WWO_FRAME      0x10            /* this is a frame window */
                    142: 
                    143:        /* special ww_index value */
                    144: #define WWX_NOBODY     NWW
                    145: 
                    146:        /* error codes */
                    147: #define WWE_NOERR      0
                    148: #define WWE_SYS                1               /* system error */
                    149: #define WWE_NOMEM      2               /* out of memory */
                    150: #define WWE_TOOMANY    3               /* too many windows */
                    151: #define WWE_NOPTY      4               /* no more ptys */
                    152: #define WWE_SIZE       5               /* bad window size */
                    153: #define WWE_BADTERM    6               /* bad terminal type */
                    154: #define WWE_CANTDO     7               /* dumb terminal */
                    155: 
                    156:        /* wwtouched[] bits */
                    157: #define WWU_TOUCHED    0x01            /* touched */
                    158: #define WWU_MAJOR      0x02            /* major change */
                    159: 
                    160:        /* the window structures */
                    161: struct ww wwhead;
                    162: struct ww *wwindex[NWW + 1];           /* last location is for wwnobody */
                    163: struct ww wwnobody;
                    164: 
                    165:        /* tty things */
                    166: struct ww_tty wwoldtty;                /* the old (saved) terminal settings */
                    167: struct ww_tty wwnewtty;                /* the new (current) terminal settings */
                    168: struct ww_tty wwwintty;                /* the terminal settings for windows */
                    169: char *wwterm;                  /* the terminal name */
                    170: char wwtermcap[1024];          /* place for the termcap */
                    171: char wwkeys[512];              /* termcap fields for the function keys */
                    172: char wwwintermcap[1024];       /* termcap for windows */
                    173: 
                    174:        /* generally useful variables */
                    175: int wwnrow, wwncol;            /* the screen size */
                    176: char wwavailmodes;             /* actually supported modes */
                    177: char wwcursormodes;            /* the modes for the fake cursor */
                    178: char wwwrap;                   /* terminal has auto wrap around */
                    179: int wwdtablesize;              /* result of getdtablesize() call */
                    180: char **wwsmap;                 /* the screen map */
                    181: union ww_char **wwos;          /* the old (current) screen */
                    182: union ww_char **wwns;          /* the new (desired) screen */
                    183: char *wwtouched;               /* wwns changed flags */
                    184: int wwbaudmap[];               /* maps stty() baud rate code into number */
                    185: int wwbaud;                    /* wwbaudmap[wwoldtty.ww_sgttyb.sg_ospeed] */
                    186: int wwcursorrow, wwcursorcol;  /* where we want the cursor to be */
                    187: int wwerrno;                   /* error number */
                    188: 
                    189:        /* statistics */
                    190: int wwnflush, wwnwr, wwnwre, wwnwrz, wwnwrc;
                    191: int wwnwwr, wwnwwra, wwnwwrc;
                    192: int wwnupdate, wwnupdline, wwnupdmiss, wwnmajline, wwnmajmiss;
                    193: int wwnread, wwnreade, wwnreadz, wwnreadc;
                    194: int wwnwread, wwnwreade, wwnwreadz, wwnwreadd, wwnwreadc, wwnwreadp;
                    195: int wwnselect, wwnselecte, wwnselectz;
                    196: 
                    197:        /* quicky macros */
                    198: #define wwsetcursor(r,c) (wwcursorrow = (r), wwcursorcol = (c))
                    199: #define wwcurtowin(w)  wwsetcursor((w)->ww_cur.r, (w)->ww_cur.c)
                    200: #define wwunbox(w)     wwunframe(w)
                    201: #define wwclreol(w,r,c)        wwclreol1((w), (r), (c), 0)
                    202: #define wwredrawwin(w) wwredrawwin1((w), (w)->ww_i.t, (w)->ww_i.b, 0)
                    203: #define wwupdate()     wwupdate1(0, wwnrow);
                    204: 
                    205:        /* things for handling input */
                    206: int wwrint();          /* interrupt handler */
                    207: struct ww *wwcurwin;   /* window to copy input into */
                    208: char wwsetjmp;         /* want a longjmp() from wwrint() */
                    209: jmp_buf wwjmpbuf;      /* jmpbuf for above */
                    210: char *wwib;            /* input (keyboard) buffer */
                    211: char *wwibe;           /* wwib + sizeof buffer */
                    212: char *wwibp;           /* current read position in buffer */
                    213: char *wwibq;           /* current write position in buffer */
                    214: #define wwgetc()       (wwibp < wwibq ? *wwibp++ & 0x7f : -1)
                    215: #define wwpeekc()      (wwibp < wwibq ? *wwibp & 0x7f : -1)
                    216: #define wwungetc(c)    (wwibp > wwib ? *--wwibp = (c) : -1)
                    217: #define wwinterrupt()  (wwibp < wwibq)
                    218: 
                    219:        /* the window virtual terminal */
                    220: #define WWT_TERM       "TERM=window"
                    221: #define WWT_TERMCAP    "WW|window|window package:\
                    222:        :cr=^M:nl=^J:bl=^G:\
                    223:        :al=\\EL:am:le=^H:bs:cd=\\EJ:ce=\\EK:cl=\\EE:cm=\\EY%+ %+ :\
                    224:        :da:db:dc=\\EN:dl=\\EM:do=\\EB:ei=\\EO:ho=\\EH:im=\\E@:mi:\
                    225:        :nd=\\EC:ta=^I:pt:up=\\EA:"
                    226: #define WWT_REV                "se=\\Eq:so=\\Ep:"
                    227: #define WWT_UL         "ue=\\Es:us=\\Er:"
                    228: #define WWT_GRP                "ae=\\EG:as=\\EF:"
                    229: #define WWT_USR                "XE=\\EQ:XS=\\EP:"
                    230: 
                    231:        /* our functions */
                    232: struct ww *wwopen();
                    233: int wwchild();
                    234: int wwsuspend();
                    235: char **wwalloc();
                    236: char *wwerror();
                    237: 
                    238:        /* c library functions */
                    239: char *malloc();
                    240: char *calloc();
                    241: char *getenv();
                    242: char *tgetstr();
                    243: char *rindex();
                    244: char *strcpy();
                    245: char *strcat();
                    246: char *sprintf();
                    247: 
                    248: #undef MIN
                    249: #undef MAX
                    250: #define MIN(x, y)      ((x) > (y) ? (y) : (x))
                    251: #define MAX(x, y)      ((x) > (y) ? (x) : (y))

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.