home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume9 / xterm / part01 / ptyx.h < prev    next >
Encoding:
C/C++ Source or Header  |  1987-04-19  |  13.4 KB  |  416 lines

  1. /*
  2.  *    $Source: /u1/X/xterm/RCS/ptyx.h,v $
  3.  *    $Header: ptyx.h,v 10.101 86/12/01 16:57:15 swick Rel $
  4.  */
  5.  
  6. #include <X/mit-copyright.h>
  7.  
  8. /*    Copyright    Massachusetts Institute of Technology    1984, 1985 */
  9.  
  10. /* ptyx.h */
  11. /* @(#)ptyx.h       X10/6.6B 12/26/86 */
  12.  
  13. #define    FALSE        0
  14. #define    TRUE        1
  15.  
  16. #define MAX_COLS    200
  17. #define MAX_ROWS    128
  18.  
  19. /*
  20.  * The origin of a screen is 0, 0.  Therefore, the number of rows
  21.  * on a screen is screen->max_row + 1, and similarly for columns.
  22.  */
  23.  
  24. typedef char **ScrnBuf;
  25.  
  26. /*
  27.  * ANSI emulation.
  28.  */
  29. #define INQ    0x05
  30. #define    FF    0x0C            /* C0, C1 control names        */
  31. #define    LS1    0x0E
  32. #define    LS0    0x0F
  33. #define    CAN    0x18
  34. #define    SUB    0x1A
  35. #define    ESC    0x1B
  36. #define US    0x1F
  37. #define    DEL    0x7F
  38. #define HTS     ('H'+0x40')
  39. #define    SS2    0x8E
  40. #define    SS3    0x8F
  41. #define    DCS    0x90
  42. #define    OLDID    0x9A            /* ESC Z            */
  43. #define    CSI    0x9B
  44. #define    ST    0x9C
  45. #define    OSC    0x9D
  46. #define    PM    0x9E
  47. #define    APC    0x9F
  48. #define    RDEL    0xFF
  49.  
  50. #define    NBOX    5            /* Number of Vertices in box    */
  51. #define    NPARAM    10            /* Max. parameters        */
  52.  
  53. #define    MINHILITE    32
  54. #define    TITLEPAD    4
  55.  
  56. typedef struct {
  57.     unsigned char    a_type;
  58.     unsigned char    a_pintro;
  59.     unsigned char    a_final;
  60.     unsigned char    a_inters;
  61.     char    a_nparam;        /* # of parameters        */
  62.     char    a_dflt[NPARAM];        /* Default value flags        */
  63.     short    a_param[NPARAM];    /* Parameters            */
  64.     char    a_nastyf;        /* Error flag            */
  65. } ANSI;
  66.  
  67. typedef struct {
  68.     int        row;
  69.     int        col;
  70.     unsigned    flags;    /* Vt100 saves graphics rendition. Ugh! */
  71.     char        curgl;
  72.     char        curgr;
  73.     char        gsets[4];
  74. } SavedCursor;
  75.  
  76. #define    TEKNUMFONTS    5
  77. /* Actually there are 5 types of lines, but four are non-solid lines */
  78. #define    TEKNUMLINES    4
  79.  
  80. typedef struct {
  81.     int    x;
  82.     int    y;
  83.     int    fontsize;
  84.     int    linetype;
  85. } Tmodes;
  86.  
  87. typedef struct {
  88.     int Twidth;
  89.     int Theight;
  90. } T_fontsize;
  91.  
  92. typedef struct {
  93.     Window tbar;            /* major window            */
  94.     Window left;            /* left hilited window        */
  95.     Window right;            /* right hilited window        */
  96.     int hilited;            /* in hilite state        */
  97.     int x;                /* x position of title        */
  98.     int y;                /* y position of title        */
  99.     int fullwidth;            /* full width of title        */
  100.     int width;            /* width of visible part of title */
  101. } TitleBar;
  102.  
  103. typedef struct {
  104.     short *bits;
  105.     int x;
  106.     int y;
  107.     int width;
  108.     int height;
  109. } BitmapBits;
  110.  
  111. typedef struct {
  112. /* These parameters apply to both windows */
  113.     Display        *display;    /* X display for screen        */
  114.     int        respond;    /* socket for responses
  115.                        (position report, etc.)    */
  116.     long        pid;        /* pid of process on far side   */
  117.     int        uid;        /* user id of actual person    */
  118.     int        gid;        /* group id of actual person    */
  119.     int        color;        /* colors used            */
  120.     int        foreground;    /* foreground color        */
  121.     int        background;    /* Background color        */
  122.     int        cursorcolor;    /* Cursor color            */
  123.     int        mousecolor;    /* Mouse color            */
  124.     Pixmap        bgndtile;    /* background tile pixmap    */
  125.     int        border;        /* inner border            */
  126.     int             borderwidth;    /* outer border                    */
  127.     Pixmap        bordertile;    /* tile pixmap for border    */
  128.     Pixmap        graybordertile;    /* tile pixmap for border when
  129.                         window is unselected    */
  130.     Cursor        arrow;        /* arrow cursor            */
  131.     unsigned short    send_mouse_pos;    /* user wants mouse transition  */
  132.                     /* and position information    */
  133.     int        select;        /* xterm selected        */
  134.     struct timeval    *timeout;    /* timeout value for select    */
  135.     FontInfo    *titlefont;    /* font info for title font    */
  136.     int        titleheight;    /* height of title        */
  137.     int        title_n_size;    /* width on 'n' in title font    */
  138.     Pixmap        hilitetile;    /* tile pixmap for title hilite    */
  139.     int        autoraise;    /* auto raise window mode    */
  140.     Window        autowindow;    /* the window to autoraise    */
  141.     int        timer;        /* timer function        */
  142.     int        holdoff;    /* delay select and unselects    */
  143.     int        visualbell;    /* visual bell mode        */
  144.     int        icon_show;    /* icon currently showing    */
  145.         int             textundericon;  /* text under icon              */
  146.         int             bitmapwidth;    /* width of icon bitmap         */
  147.         int             bitmapheight;   /* height of icon bitmap        */
  148.         int             icon_text_x;    /* x position of text           */
  149.         int             icon_text_y;    /* y position of text           */
  150.     BitmapBits    iconbitmap;    /* bitmap for icon        */
  151.         int             iconinput;      /* got input while iconified    */
  152.     int        active_icon;    /* icon is miniature copy    */
  153.     int        deiconwarp;    /* warp mouse on deiconify    */
  154.     int        logging;    /* logging mode            */
  155.     int        logfd;        /* file descriptor of log    */
  156.     char        *logfile;    /* log file name        */
  157.     char        *logstart;    /* current start of log buffer    */
  158.     int        inhibit;    /* flags for inhibiting changes    */
  159.  
  160. /* VT window parameters */
  161.     int        show;        /* window showing        */
  162.     int        iconunmap;    /* unmapped because of icon    */
  163.     struct {
  164.         Window    window;        /* X window id            */
  165.         int    width;        /* width of columns        */
  166.         int    height;        /* height of rows        */
  167.         int    fullwidth;    /* full width of window        */
  168.         int    fullheight;    /* full height of window    */
  169.         int    f_width;    /* width of fonts in pixels    */
  170.         int    f_height;    /* height of fonts in pixels    */
  171.         int    titlebar;    /* title bar(s) showing        */
  172.     } fullVwin, iconVwin, *mappedVwin;
  173.     Font        fnt_icon;    /* icon font            */
  174.     int        minrows;    /* minimun number of rows to
  175.                         accommodate scrollbar    */
  176.     Cursor        curs;        /* cursor resource from X    */
  177.     /* Terminal fonts must be of the same size and of fixed width */
  178.     Font        fnt_norm;    /* normal font of terminal    */
  179.     Font        fnt_bold;    /* bold font of terminal    */
  180.     int        enbolden;    /* overstrike for bold font    */
  181.     Vertex        *box;        /* draw unselected cursor    */
  182.  
  183.     int        cursor_state;    /* ON or OFF            */
  184.     int        cursor_set;    /* requested state        */
  185.     int        cursor_col;    /* previous cursor column    */
  186.     int        cursor_row;    /* previous cursor row        */
  187.     int        cur_col;    /* current cursor column    */
  188.     int        cur_row;    /* current cursor row        */
  189.     int        max_col;    /* rightmost column        */
  190.     int        max_row;    /* bottom row            */
  191.     int        top_marg;    /* top line of scrolling region */
  192.     int        bot_marg;    /* bottom line of  "        "    */
  193.     int        scrollbar;    /* if > 0, width of scrollbar, and
  194.                         scrollbar showing    */
  195.     int        topline;    /* line number of top, <= 0    */
  196.     int        savelines;    /* number of lines off top to save */
  197.     int        scrollinput;    /* scroll to bottom on input    */
  198.     int        scrollkey;    /* scroll to bottom on key    */
  199.     
  200.     ScrnBuf        buf;        /* screen buffer (main)        */
  201.     ScrnBuf        allbuf;        /* screen buffer (may include
  202.                        lines scrolled off top    */
  203.     ScrnBuf        altbuf;        /* alternate screen buffer    */
  204.     int        alternate;    /* true if using alternate buf    */
  205.     ScrollBar    *sb;        /* pointer to scrollbar struct    */
  206.     unsigned short    do_wrap;    /* true if cursor in last column
  207.                        and character just output    */
  208.     int        incopy;        /* 0 if no RasterCopy exposure
  209.                        event processed since last
  210.                        RasterCopy            */
  211.     int        c132;        /* allow change to 132 columns    */
  212.     int        curses;        /* cludge-ups for more and vi    */
  213.     int        marginbell;    /* true if margin bell on    */
  214.     int        nmarginbell;    /* columns from right margin    */
  215.     int        bellarmed;    /* cursor below bell margin    */
  216. #ifdef CROCKSCROLL
  217.     int        scrollincr;    /* scroll increment        */
  218. #endif
  219.     unsigned int    multiscroll;    /* true if multi-scroll        */
  220.     int        scrolls;    /* outstanding scroll count    */
  221.     SavedCursor    sc;        /* data for restore cursor    */
  222.     TitleBar    title;        /* title bar            */
  223.     int        statusline;    /* status line showing        */
  224.     int        statusheight;    /* status line height        */
  225.     int        instatus;    /* cursor in status line    */
  226.     SavedCursor    statussc;    /* status line restore cursor    */
  227.     int        reversestatus;    /* status line reversed        */
  228.     char        *winname;    /* name of window (and icons)    */
  229.     int        winnamelen;    /* length of window name    */
  230.     int        save_modes[19];    /* save dec private modes    */
  231.     int        pagemode;    /* true if page mode        */
  232.     int        pagecnt;    /* count of lines in page mode    */
  233.     int        pageoverlap;    /* lines to overlap (less one)    */
  234.  
  235.     /* Improved VT100 emulation stuff.                */
  236.     char        gsets[4];    /* G0 through G3.        */
  237.     char        curgl;        /* Current GL setting.        */
  238.     char        curgr;        /* Current GR setting.        */
  239.     char        curss;        /* Current single shift.    */
  240.     int        scroll_amt;    /* amount to scroll        */
  241.     int        refresh_amt;    /* amount to refresh        */
  242.     int        jumpscroll;    /* whether we should jumpscroll */
  243.  
  244. /* Tektronix window parameters */
  245.     int        Tforeground;    /* foreground color        */
  246.     int        Tbackground;    /* Background color        */
  247.     int        Tcursorcolor;    /* Cursor color            */
  248.     Pixmap        Tbgndtile;    /* background tile pixmap    */
  249.     int        Tcolor;        /* colors used            */
  250.     int        planeused;    /* is xorplane being used    */
  251.     int        cellsused;    /* are color cells being used    */
  252.     Color        colorcells[3];    /* color cells for Tek        */
  253.     int        Tshow;        /* Tek window showing        */
  254.     int        Ticonunmap;    /* unmapped because of icon    */
  255.     int        waitrefresh;    /* postpone refresh        */
  256.     struct {
  257.         Window    window;        /* X window id            */
  258.         int    width;        /* width of columns        */
  259.         int    height;        /* height of rows        */
  260.         int    fullwidth;    /* full width of window        */
  261.         int    fullheight;    /* full height of window    */
  262.         int    titlebar;    /* title bar(s) showing        */
  263.         double    tekscale;    /* scale factor Tek -> vs100    */
  264.     } fullTwin, iconTwin, *mappedTwin;
  265.     BitmapBits    Ticonbitmap;    /* bitmap for icon        */
  266.     Vertex        **Tbox;        /* draw unselected cursor    */
  267.     int        xorplane;    /* z plane for inverts        */
  268.     Pattern        linepat[TEKNUMLINES]; /* line patterns        */
  269.     Font        Tfont[TEKNUMFONTS]; /* Tek fonts        */
  270.     int        tobaseline[TEKNUMFONTS]; /* top to baseline for
  271.                             each font    */
  272.     int        TekEmu;        /* true if Tektronix emulation    */
  273.     int        cur_X;        /* current x            */
  274.     int        cur_Y;        /* current y            */
  275.     Tmodes        cur;        /* current tek modes        */
  276.     Tmodes        page;        /* starting tek modes on page    */
  277.     int        margin;        /* 0 -> margin 1, 1 -> margin 2    */
  278.     int        pen;        /* current Tektronix pen 0=up, 1=dn */
  279.     char        *TekGIN;    /* nonzero if Tektronix GIN mode*/
  280.     TitleBar    Ttitle;        /* title bar            */
  281.     char        *Twinname;    /* name of window        */
  282.     int        Twinnamelen;    /* length of window name    */
  283. } Screen;
  284.  
  285. /* meaning of bits in screen.select flag */
  286. #define    INWINDOW    01    /* the mouse is in one of the windows */
  287. #define    FOCUS        02    /* one of the windows is the focus window */
  288.  
  289. typedef struct
  290. {
  291.     unsigned    offset;        /* status of shift, control, meta */
  292. #define SHIFT    0x0001
  293. #define META    0x0002
  294. #define CONTROL    0x0004
  295.  
  296.     unsigned    flags;
  297. } Keyboard;
  298.  
  299. /* define masks for flags */
  300. #define CAPS_LOCK    0x01
  301. #define KYPD_APL    0x02
  302. #define CURSOR_APL    0x04
  303.  
  304.  
  305. #define N_MARGINBELL    10
  306. #define MAX_TABS    320
  307. #define TAB_ARRAY_SIZE    10    /* number of ints to provide MAX_TABS bits */
  308.  
  309. typedef unsigned Tabs [TAB_ARRAY_SIZE];
  310.  
  311.  
  312. #define BUF_SIZE 4096
  313.  
  314. typedef struct
  315. {
  316.     Keyboard    keyboard;    /* terminal keyboard        */
  317.     Screen        screen;        /* terminal screeen        */
  318.     unsigned    flags;        /* mode flags            */
  319.     unsigned    initflags;    /* initial mode flags        */
  320.     Tabs        tabs;        /* tabstops of the terminal    */
  321. } Terminal;
  322.  
  323.  
  324. /* masks for terminal flags */
  325.  
  326. #define INVERSE        0x01    /* invert the characters to be output */
  327. #define UNDERLINE    0x02    /* true if underlining */
  328. #define BOLD        0x04
  329. #define WRAPAROUND    0x08
  330. #define REVERSE_VIDEO    0x10    /* true if screen white on black */
  331. #define ORIGIN        0x20    /* true if in origin mode */
  332. #define INSERT        0x40    /* true if in insert mode */
  333. #define SMOOTHSCROLL    0x80    /* true if in smooth scroll mode */
  334. #define AUTOREPEAT    0x100    /* true if in autorepeat mode */
  335. #define IN132COLUMNS    0x200    /* true if in 132 column mode */
  336. #define LINEFEED    0x400
  337. #define    REVERSEWRAP    0x800    /* true if reverse wraparound mode */
  338. #define ICONINPUT    0x1000    /* true if mini icon accepts kbd input */
  339.  
  340. #define    ATTRIBUTES    0x07    /* attributes mask */
  341. #define CHAR        0177
  342.  
  343. #define VWindow(screen)        (screen->mappedVwin->window)
  344. #define TWindow(screen)        (screen->mappedTwin->window)
  345. #define Width(screen)        (screen->mappedVwin->width)
  346. #define Height(screen)        (screen->mappedVwin->height)
  347. #define FullWidth(screen)    (screen->mappedVwin->fullwidth)
  348. #define FullHeight(screen)    (screen->mappedVwin->fullheight)
  349. #define FontWidth(screen)    (screen->mappedVwin->f_width)
  350. #define FontHeight(screen)    (screen->mappedVwin->f_height)
  351. #define TWidth(screen)        (screen->mappedTwin->width)
  352. #define THeight(screen)        (screen->mappedTwin->height)
  353. #define TFullWidth(screen)    (screen->mappedTwin->fullwidth)
  354. #define TFullHeight(screen)    (screen->mappedTwin->fullheight)
  355. #define TekScale(screen)    (screen->mappedTwin->tekscale)
  356. #define Titlebar(screen)    (screen->mappedVwin->titlebar)
  357. #define TTitlebar(screen)    (screen->mappedTwin->titlebar)
  358. #define ActiveIcon(screen)    (screen->active_icon && \
  359.                 (screen->mappedVwin == &screen->iconVwin))
  360. #define TActiveIcon(screen)    (screen->active_icon && \
  361.                 (screen->mappedTwin == &screen->iconTwin))
  362.  
  363. #define CursorX(screen,col) ((col) * FontWidth(screen) + screen->border)
  364. #define CursorY(screen,row) ((screen->instatus ? \
  365.             ((row) * FontHeight(screen) + 1)\
  366.             : (((row) - screen->topline) * FontHeight(screen))) +\
  367.             screen->border + Titlebar(screen))
  368.  
  369. #define TICONWINDOWEVENTS  (ExposeWindow | ButtonPressed)
  370.  
  371. #define    ICONWINDOWEVENTS   (TICONWINDOWEVENTS | ExposeRegion | ExposeCopy)
  372.                  
  373. #define ICONINPUTEVENTS    (KeyPressed | EnterWindow | LeaveWindow | FocusChange)
  374.  
  375. #define    TWINDOWEVENTS    (KeyPressed | ExposeWindow | ButtonPressed |\
  376.              ButtonReleased | UnmapWindow | EnterWindow |\
  377.              LeaveWindow | FocusChange)
  378.  
  379. #define    WINDOWEVENTS    (TWINDOWEVENTS | ExposeRegion | ExposeCopy)
  380.  
  381. #define TEK_LINK_BLOCK_SIZE 1024
  382.  
  383. typedef struct Tek_Link
  384. {
  385.     struct Tek_Link    *next;    /* pointer to next TekLink in list
  386.                    NULL <=> this is last TekLink */
  387.     short count;
  388.     char *ptr;
  389.     char data [TEK_LINK_BLOCK_SIZE];
  390. } TekLink;
  391.  
  392. /* flags for cursors */
  393. #define    OFF        0
  394. #define    ON        1
  395. #define    CLEAR        0
  396. #define    TOGGLE        1
  397.  
  398. /* flags for color */
  399. #define    C_FOREGROUND    0x01
  400. #define    C_BACKGROUND    0x02
  401. #define    C_FBMASK    0x03
  402. #define    C_CURSOR    0x04
  403. #define    C_MOUSE        0x08
  404. #define    C_BORDER    0x10
  405.  
  406. /* flags for inhibit */
  407. #define    I_LOG        0x01
  408. #define    I_SIGNAL    0x02
  409. #define    I_TEK        0x04
  410.  
  411. extern Bitmap make_icon();
  412. extern Cursor make_tcross();
  413. extern Cursor make_xterm();
  414. extern Cursor make_wait();
  415. extern Cursor make_arrow();
  416.