home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume7 / xdm / patch1.02 / ptyx.h next >
Encoding:
C/C++ Source or Header  |  1990-06-08  |  14.7 KB  |  489 lines

  1. /*
  2.  *    $XConsortium: ptyx.h,v 1.18 88/10/07 14:12:29 swick Exp $
  3.  */
  4.  
  5. #include <X11/copyright.h>
  6.  
  7. /*
  8.  * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
  9.  *
  10.  *                         All Rights Reserved
  11.  *
  12.  * Permission to use, copy, modify, and distribute this software and its
  13.  * documentation for any purpose and without fee is hereby granted,
  14.  * provided that the above copyright notice appear in all copies and that
  15.  * both that copyright notice and this permission notice appear in
  16.  * supporting documentation, and that the name of Digital Equipment
  17.  * Corporation not be used in advertising or publicity pertaining to
  18.  * distribution of the software without specific, written prior permission.
  19.  *
  20.  *
  21.  * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  22.  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  23.  * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  24.  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  25.  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  26.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  27.  * SOFTWARE.
  28.  */
  29.  
  30. /* ptyx.h */
  31. /* @(#)ptyx.h    X10/6.6    11/10/86 */
  32.  
  33. #include <X11/Xos.h>
  34. #include <X11/Xlib.h>
  35. #include <X11/IntrinsicP.h>
  36.  
  37. /* Extra Xlib definitions */
  38. #define AllButtonsUp(detail, ignore)  (\
  39.         ((ignore) == Button1) ? \
  40.                 (((detail)&(Button2Mask|Button3Mask)) == 0) \
  41.                 : \
  42.          (((ignore) == Button2) ? \
  43.                   (((detail)&(Button1Mask|Button3Mask)) == 0) \
  44.                 : \
  45.                   (((detail)&(Button1Mask|Button2Mask)) == 0)) \
  46.         )
  47.  
  48.  
  49. #define Max(i, j)       ((i) > (j) ? (i) : (j))
  50. #define Min(i, j)       ((i) < (j) ? (i) : (j))
  51.  
  52. #define MAX_COLS    200
  53. #define MAX_ROWS    128
  54.  
  55. /*
  56. ** System V definitions
  57. */
  58.  
  59. #ifdef SYSV
  60.  
  61. #ifdef JOBCONTROL
  62. #define    getpgrp        getpgrp2
  63. #else    /* !JOBCONTROL */
  64. #define    getpgrp(x)    (x)
  65. #endif    /* !JOBCONTROL */
  66.  
  67. #define    killpg(x,sig)    kill(-x,sig)
  68.  
  69. #define    dup2(fd1,fd2)    ((fd1 == fd2) ? fd1 : \
  70.                 (close(fd2), fcntl(fd1, F_DUPFD, fd2)))
  71.  
  72. #endif    /* !SYSV */
  73.  
  74. /*
  75. ** allow for mobility of the pty master/slave directories
  76. */
  77. #ifndef PTYDEV
  78. #ifdef hpux
  79. #define    PTYDEV        "/dev/ptym/ptyxx"
  80. #else    /* !hpux */
  81. #define    PTYDEV        "/dev/ptyxx"
  82. #endif    /* !hpux */
  83. #endif    /* !PTYDEV */
  84.  
  85. #ifndef TTYDEV
  86. #ifdef hpux
  87. #define TTYDEV        "/dev/pty/ttyxx"
  88. #else    /* !hpux */
  89. #define    TTYDEV        "/dev/ttyxx"
  90. #endif    /* !hpux */
  91. #endif    /* !TTYDEV */
  92.  
  93. #ifndef PTYCHAR1
  94. #ifdef hpux
  95. #define PTYCHAR1    "zyxwvutsrqp"
  96. #else    /* !hpux */
  97. #define    PTYCHAR1    "pqrstuvwxyz"
  98. #endif    /* !hpux */
  99. #endif    /* !PTYCHAR1 */
  100.  
  101. #ifndef PTYCHAR2
  102. #ifdef hpux
  103. #define    PTYCHAR2    "fedcba9876543210"
  104. #else    /* !hpux */
  105. #define    PTYCHAR2    "0123456789abcdef"
  106. #endif    /* !hpux */
  107. #endif    /* !PTYCHAR2 */
  108.  
  109. /* Until the translation manager comes along, I have to do my own translation of
  110.  * mouse events into the proper routines. */
  111.  
  112. typedef enum {NORMAL, LEFTEXTENSION, RIGHTEXTENSION} EventMode;
  113.  
  114. /*
  115.  * The origin of a screen is 0, 0.  Therefore, the number of rows
  116.  * on a screen is screen->max_row + 1, and similarly for columns.
  117.  */
  118.  
  119. typedef char **ScrnBuf;
  120.  
  121. /*
  122.  * ANSI emulation.
  123.  */
  124. #define INQ    0x05
  125. #define    FF    0x0C            /* C0, C1 control names        */
  126. #define    LS1    0x0E
  127. #define    LS0    0x0F
  128. #define    CAN    0x18
  129. #define    SUB    0x1A
  130. #define    ESC    0x1B
  131. #define US    0x1F
  132. #define    DEL    0x7F
  133. #define HTS     ('H'+0x40)
  134. #define    SS2    0x8E
  135. #define    SS3    0x8F
  136. #define    DCS    0x90
  137. #define    OLDID    0x9A            /* ESC Z            */
  138. #define    CSI    0x9B
  139. #define    ST    0x9C
  140. #define    OSC    0x9D
  141. #define    PM    0x9E
  142. #define    APC    0x9F
  143. #define    RDEL    0xFF
  144.  
  145. #define    NBOX    5            /* Number of Points in box    */
  146. #define    NPARAM    10            /* Max. parameters        */
  147.  
  148. #define    MINHILITE    32
  149.  
  150. typedef struct {
  151.     unsigned char    a_type;
  152.     unsigned char    a_pintro;
  153.     unsigned char    a_final;
  154.     unsigned char    a_inters;
  155.     char    a_nparam;        /* # of parameters        */
  156.     char    a_dflt[NPARAM];        /* Default value flags        */
  157.     short    a_param[NPARAM];    /* Parameters            */
  158.     char    a_nastyf;        /* Error flag            */
  159. } ANSI;
  160.  
  161. typedef struct {
  162.     int        row;
  163.     int        col;
  164.     unsigned    flags;    /* Vt100 saves graphics rendition. Ugh! */
  165.     char        curgl;
  166.     char        curgr;
  167.     char        gsets[4];
  168. } SavedCursor;
  169.  
  170. #define    TEKNUMFONTS    4
  171. /* Actually there are 5 types of lines, but four are non-solid lines */
  172. #define    TEKNUMLINES    4
  173.  
  174. typedef struct {
  175.     int    x;
  176.     int    y;
  177.     int    fontsize;
  178.     int    linetype;
  179. } Tmodes;
  180.  
  181. typedef struct {
  182.     int Twidth;
  183.     int Theight;
  184. } T_fontsize;
  185.  
  186. typedef struct {
  187.     short *bits;
  188.     int x;
  189.     int y;
  190.     int width;
  191.     int height;
  192. } BitmapBits;
  193.  
  194. #define    SAVELINES        64      /* default # lines to save      */
  195.  
  196. typedef struct {
  197. /* These parameters apply to both windows */
  198.     Display        *display;    /* X display for screen        */
  199.     int        respond;    /* socket for responses
  200.                        (position report, etc.)    */
  201.     long        pid;        /* pid of process on far side   */
  202.     int        uid;        /* user id of actual person    */
  203.     int        gid;        /* group id of actual person    */
  204.     GC        normalGC;    /* normal painting        */
  205.     GC        reverseGC;    /* reverse painting        */
  206.     GC        normalboldGC;    /* normal painting, bold font    */
  207.     GC        reverseboldGC;    /* reverse painting, bold font    */
  208.     GC        cursorGC;    /* normal cursor painting    */
  209.     GC        reversecursorGC;/* reverse cursor painting    */
  210.     GC        cursoroutlineGC;/* for painting lines around    */
  211.     Pixel        foreground;    /* foreground color        */
  212.     Pixel        cursorcolor;    /* Cursor color            */
  213.     Pixel        mousecolor;    /* Mouse color            */
  214.     int        border;        /* inner border            */
  215.     Pixmap        graybordertile;    /* tile pixmap for border when
  216.                         window is unselected    */
  217.     Cursor        arrow;        /* arrow cursor            */
  218.     unsigned short    send_mouse_pos;    /* user wants mouse transition  */
  219.                     /* and position information    */
  220.     int        select;        /* xterm selected        */
  221.     Boolean        visualbell;    /* visual bell mode        */
  222.     int        logging;    /* logging mode            */
  223.     int        logfd;        /* file descriptor of log    */
  224.     char        *logfile;    /* log file name        */
  225.     char        *logstart;    /* current start of log buffer    */
  226.     int        inhibit;    /* flags for inhibiting changes    */
  227.  
  228. /* VT window parameters */
  229.     struct {
  230.         Window    window;        /* X window id            */
  231.         int    width;        /* width of columns        */
  232.         int    height;        /* height of rows        */
  233.         int    fullwidth;    /* full width of window        */
  234.         int    fullheight;    /* full height of window    */
  235.         int    f_width;    /* width of fonts in pixels    */
  236.         int    f_height;    /* height of fonts in pixels    */
  237.     } fullVwin;
  238.     Cursor pointer_cursor;        /* pointer cursor in window    */
  239.  
  240.     /* Terminal fonts must be of the same size and of fixed width */
  241.     XFontStruct    *fnt_norm;    /* normal font of terminal    */
  242.     XFontStruct    *fnt_bold;    /* bold font of terminal    */
  243.     int        enbolden;    /* overstrike for bold font    */
  244.     XPoint        *box;        /* draw unselected cursor    */
  245.  
  246.     int        cursor_state;    /* ON or OFF            */
  247.     int        cursor_set;    /* requested state        */
  248.     int        cursor_col;    /* previous cursor column    */
  249.     int        cursor_row;    /* previous cursor row        */
  250.     int        cur_col;    /* current cursor column    */
  251.     int        cur_row;    /* current cursor row        */
  252.     int        max_col;    /* rightmost column        */
  253.     int        max_row;    /* bottom row            */
  254.     int        top_marg;    /* top line of scrolling region */
  255.     int        bot_marg;    /* bottom line of  "        "    */
  256.     Widget        scrollWidget;    /* pointer to scrollbar struct    */
  257.     int        scrollbar;    /* if > 0, width of scrollbar, and
  258.                         scrollbar is showing    */
  259.     int        topline;    /* line number of top, <= 0    */
  260.     int        savedlines;     /* number of lines that've been saved */
  261.     int        savelines;    /* number of lines off top to save */
  262.     Boolean        scrollinput;    /* scroll to bottom on input    */
  263.     Boolean        scrollkey;    /* scroll to bottom on key    */
  264.     
  265.     ScrnBuf        buf;        /* screen buffer (main)        */
  266.     ScrnBuf        allbuf;        /* screen buffer (may include
  267.                        lines scrolled off top    */
  268.     ScrnBuf        altbuf;        /* alternate screen buffer    */
  269.     Boolean        alternate;    /* true if using alternate buf    */
  270.     unsigned short    do_wrap;    /* true if cursor in last column
  271.                        and character just output    */
  272.     int        incopy;        /* 0 if no RasterCopy exposure
  273.                        event processed since last
  274.                        RasterCopy            */
  275.     Boolean        c132;        /* allow change to 132 columns    */
  276.     Boolean        curses;        /* cludge-ups for more and vi    */
  277.     Boolean        marginbell;    /* true if margin bell on    */
  278.     int        nmarginbell;    /* columns from right margin    */
  279.     int        bellarmed;    /* cursor below bell margin    */
  280.     Boolean     multiscroll;    /* true if multi-scroll        */
  281.     int        scrolls;    /* outstanding scroll count    */
  282.     SavedCursor    sc;        /* data for restore cursor    */
  283.     int        save_modes[19];    /* save dec private modes    */
  284.  
  285.     /* Improved VT100 emulation stuff.                */
  286.     char        gsets[4];    /* G0 through G3.        */
  287.     char        curgl;        /* Current GL setting.        */
  288.     char        curgr;        /* Current GR setting.        */
  289.     char        curss;        /* Current single shift.    */
  290.     int        scroll_amt;    /* amount to scroll        */
  291.     int        refresh_amt;    /* amount to refresh        */
  292.     Boolean        jumpscroll;    /* whether we should jumpscroll */
  293.     Boolean         always_highlight; /* whether to highlight cursor */
  294.  
  295. /* Tektronix window parameters */
  296.     GC        TnormalGC;    /* normal painting        */
  297.     GC        TcursorGC;    /* normal cursor painting    */
  298.     Pixel        Tforeground;    /* foreground color        */
  299.     Pixel        Tbackground;    /* Background color        */
  300.     Pixel        Tcursorcolor;    /* Cursor color            */
  301.     Pixmap        Tbgndtile;    /* background tile pixmap    */
  302.     int        Tcolor;        /* colors used            */
  303.     Boolean        planeused;    /* is xorplane being used    */
  304.     Boolean        cellsused;    /* are color cells being used    */
  305.     XColor        colorcells[3];    /* color cells for Tek        */
  306.     Boolean        Vshow;        /* VT window showing        */
  307.     Boolean        Tshow;        /* Tek window showing        */
  308.     Boolean        waitrefresh;    /* postpone refresh        */
  309.     struct {
  310.         Window    window;        /* X window id            */
  311.         int    width;        /* width of columns        */
  312.         int    height;        /* height of rows        */
  313.         int    fullwidth;    /* full width of window        */
  314.         int    fullheight;    /* full height of window    */
  315.         double    tekscale;    /* scale factor Tek -> vs100    */
  316.     } fullTwin;
  317.     XPoint        **Tbox;        /* draw unselected cursor    */
  318.     int        xorplane;    /* z plane for inverts        */
  319.     GC        linepat[TEKNUMLINES]; /* line patterns        */
  320.     XFontStruct     *Tfont[TEKNUMFONTS]; /* Tek fonts        */
  321.     int        tobaseline[TEKNUMFONTS]; /* top to baseline for
  322.                             each font    */
  323.     Boolean        TekEmu;        /* true if Tektronix emulation    */
  324.     int        cur_X;        /* current x            */
  325.     int        cur_Y;        /* current y            */
  326.     Tmodes        cur;        /* current tek modes        */
  327.     Tmodes        page;        /* starting tek modes on page    */
  328.     int        margin;        /* 0 -> margin 1, 1 -> margin 2    */
  329.     int        pen;        /* current Tektronix pen 0=up, 1=dn */
  330.     char        *TekGIN;    /* nonzero if Tektronix GIN mode*/
  331.     int        multiClickTime;     /* time between multiclick selects */
  332.     char        *charClass;    /* for overriding word selection */
  333.     Boolean        cutNewline;    /* whether or not line cut has \n */
  334.     Boolean        cutToBeginningOfLine;  /* line cuts to BOL? */
  335.     char        *selection;    /* the current selection */
  336.     int        selection_size; /* size of allocated buffer */
  337.     int        selection_length; /* number of significant bytes */
  338.     int        selection_time;    /* latest event timestamp */
  339.     int        startHRow, startHCol, /* highlighted text */
  340.             endHRow, endHCol,
  341.             startHCoord, endHCoord;
  342.     Atom*        selection_atoms; /* which selections we own */
  343.     Cardinal    sel_atoms_size;    /*  how many atoms allocated */
  344.     Cardinal    selection_count; /* how many atoms in use */
  345. } TScreen;
  346.  
  347. /* meaning of bits in screen.select flag */
  348. #define    INWINDOW    01    /* the mouse is in one of the windows */
  349. #define    FOCUS        02    /* one of the windows is the focus window */
  350.  
  351. #define MULTICLICKTIME 250    /* milliseconds */
  352.  
  353. typedef struct
  354. {
  355.     unsigned    flags;
  356. } TKeyboard;
  357.  
  358. typedef struct _Misc {
  359.     char *geo_metry;
  360.     char *T_geometry;
  361.     char *f_n;
  362.     char *f_b;
  363.     Boolean log_on;
  364.     Boolean login_shell;
  365.     Boolean re_verse;
  366.     Boolean reverseWrap;
  367.     Boolean logInhibit;
  368.     Boolean signalInhibit;
  369.     Boolean tekInhibit;
  370.     Boolean scrollbar;
  371.     Boolean titeInhibit;
  372. } Misc;
  373.  
  374. typedef struct {int foo;} XtermClassPart, TekClassPart;
  375.  
  376. typedef struct _XtermClassRec {
  377.     CoreClassPart  core_class;
  378.     XtermClassPart xterm_class;
  379. } XtermClassRec;
  380.  
  381. typedef struct _TekClassRec {
  382.     CoreClassPart core_class;
  383.     TekClassPart tek_class;
  384. } TekClassRec;
  385.  
  386. /* define masks for flags */
  387. #define CAPS_LOCK    0x01
  388. #define KYPD_APL    0x02
  389. #define CURSOR_APL    0x04
  390.  
  391.  
  392. #define N_MARGINBELL    10
  393. #define MAX_TABS    320
  394. #define TAB_ARRAY_SIZE    10    /* number of ints to provide MAX_TABS bits */
  395.  
  396. typedef unsigned Tabs [TAB_ARRAY_SIZE];
  397.  
  398. typedef struct _XtermWidgetRec {
  399.     CorePart    core;
  400.     TKeyboard    keyboard;    /* terminal keyboard        */
  401.     TScreen    screen;        /* terminal screen        */
  402.     unsigned    flags;        /* mode flags            */
  403.     unsigned    initflags;    /* initial mode flags        */
  404.     Tabs    tabs;        /* tabstops of the terminal    */
  405.     Misc    misc;        /* miscelaneous parameters    */
  406. } XtermWidgetRec, *XtermWidget;
  407.  
  408. typedef struct _TekWidgetRec {
  409.     CorePart core;
  410. } TekWidgetRec, *TekWidget;
  411.  
  412. #define BUF_SIZE 4096
  413.  
  414. /* masks for terminal flags */
  415.  
  416. #define INVERSE        0x01    /* invert the characters to be output */
  417. #define UNDERLINE    0x02    /* true if underlining */
  418. #define BOLD        0x04
  419. #define WRAPAROUND    0x08
  420. #define REVERSE_VIDEO    0x10    /* true if screen white on black */
  421. #define ORIGIN        0x20    /* true if in origin mode */
  422. #define INSERT        0x40    /* true if in insert mode */
  423. #define SMOOTHSCROLL    0x80    /* true if in smooth scroll mode */
  424. #ifdef DO_AUTOREPEAT
  425. #define AUTOREPEAT    0x100    /* true if in autorepeat mode */
  426. #endif /* DO_AUTOREPEAT */
  427. #define IN132COLUMNS    0x200    /* true if in 132 column mode */
  428. #define LINEFEED    0x400
  429. #define    REVERSEWRAP    0x800    /* true if reverse wraparound mode */
  430.  
  431. #define    ATTRIBUTES    0x07    /* attributes mask */
  432. #define CHAR        0177
  433.  
  434. #define VWindow(screen)        (screen->fullVwin.window)
  435. #define VShellWindow        term->core.parent->core.window
  436. #define TextWindow(screen)      (screen->fullVwin.window)
  437. #define TWindow(screen)        (screen->fullTwin.window)
  438. #define TShellWindow        tekWidget->core.parent->core.window
  439. #define Width(screen)        (screen->fullVwin.width)
  440. #define Height(screen)        (screen->fullVwin.height)
  441. #define FullWidth(screen)    (screen->fullVwin.fullwidth)
  442. #define FullHeight(screen)    (screen->fullVwin.fullheight)
  443. #define FontWidth(screen)    (screen->fullVwin.f_width)
  444. #define FontHeight(screen)    (screen->fullVwin.f_height)
  445. #define TWidth(screen)        (screen->fullTwin.width)
  446. #define THeight(screen)        (screen->fullTwin.height)
  447. #define TFullWidth(screen)    (screen->fullTwin.fullwidth)
  448. #define TFullHeight(screen)    (screen->fullTwin.fullheight)
  449. #define TekScale(screen)    (screen->fullTwin.tekscale)
  450.  
  451. #define CursorX(screen,col) ((col) * FontWidth(screen) + screen->border \
  452.             + screen->scrollbar)
  453. #define CursorY(screen,row) ((((row) - screen->topline) * FontHeight(screen)) \
  454.             + screen->border)
  455.  
  456. #define    TWINDOWEVENTS    (KeyPressMask | ExposureMask | ButtonPressMask |\
  457.              ButtonReleaseMask | StructureNotifyMask |\
  458.              EnterWindowMask | LeaveWindowMask | FocusChangeMask)
  459.  
  460. #define    WINDOWEVENTS    (TWINDOWEVENTS | PointerMotionMask)
  461.  
  462.  
  463. #define TEK_LINK_BLOCK_SIZE 1024
  464.  
  465. typedef struct Tek_Link
  466. {
  467.     struct Tek_Link    *next;    /* pointer to next TekLink in list
  468.                    NULL <=> this is last TekLink */
  469.     short count;
  470.     char *ptr;
  471.     char data [TEK_LINK_BLOCK_SIZE];
  472. } TekLink;
  473.  
  474. /* flags for cursors */
  475. #define    OFF        0
  476. #define    ON        1
  477. #define    CLEAR        0
  478. #define    TOGGLE        1
  479.  
  480. /* flags for inhibit */
  481. #define    I_LOG        0x01
  482. #define    I_SIGNAL    0x02
  483. #define    I_TEK        0x04
  484.  
  485. extern Cursor make_tcross();
  486. extern Cursor make_xterm();
  487. extern Cursor make_wait();
  488. extern Cursor make_arrow();
  489.