"Fossies" - the Fresh Open Source Software Archive

Member "xterm-356/ptyx.h" (2 May 2020, 101103 Bytes) of package /linux/misc/xterm-356.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ptyx.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 355_vs_356.

    1 /* $XTermId: ptyx.h,v 1.992 2020/05/02 16:11:37 tom Exp $ */
    2 
    3 /*
    4  * Copyright 1999-2019,2020 by Thomas E. Dickey
    5  *
    6  *                         All Rights Reserved
    7  *
    8  * Permission is hereby granted, free of charge, to any person obtaining a
    9  * copy of this software and associated documentation files (the
   10  * "Software"), to deal in the Software without restriction, including
   11  * without limitation the rights to use, copy, modify, merge, publish,
   12  * distribute, sublicense, and/or sell copies of the Software, and to
   13  * permit persons to whom the Software is furnished to do so, subject to
   14  * the following conditions:
   15  *
   16  * The above copyright notice and this permission notice shall be included
   17  * in all copies or substantial portions of the Software.
   18  *
   19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
   20  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
   22  * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
   23  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
   24  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
   25  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   26  *
   27  * Except as contained in this notice, the name(s) of the above copyright
   28  * holders shall not be used in advertising or otherwise to promote the
   29  * sale, use or other dealings in this Software without prior written
   30  * authorization.
   31  *
   32  *
   33  * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
   34  *
   35  *                         All Rights Reserved
   36  *
   37  * Permission to use, copy, modify, and distribute this software and its
   38  * documentation for any purpose and without fee is hereby granted,
   39  * provided that the above copyright notice appear in all copies and that
   40  * both that copyright notice and this permission notice appear in
   41  * supporting documentation, and that the name of Digital Equipment
   42  * Corporation not be used in advertising or publicity pertaining to
   43  * distribution of the software without specific, written prior permission.
   44  *
   45  *
   46  * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
   47  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
   48  * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
   49  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
   50  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
   51  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
   52  * SOFTWARE.
   53  */
   54 
   55 #ifndef included_ptyx_h
   56 #define included_ptyx_h 1
   57 
   58 #ifdef HAVE_CONFIG_H
   59 #include <xtermcfg.h>
   60 #endif
   61 
   62 /* ptyx.h */
   63 /* *INDENT-OFF* */
   64 /* @(#)ptyx.h   X10/6.6 11/10/86 */
   65 
   66 #include <X11/IntrinsicP.h>
   67 #include <X11/Shell.h>      /* for XtNdieCallback, etc. */
   68 #include <X11/StringDefs.h> /* for standard resource names */
   69 #include <X11/Xmu/Misc.h>   /* For Max() and Min(). */
   70 
   71 #undef bcopy
   72 #undef bzero
   73 #include <X11/Xfuncs.h>
   74 
   75 #include <X11/Xosdefs.h>
   76 #include <X11/Xmu/Converters.h>
   77 #ifdef XRENDERFONT
   78 #include <X11/Xft/Xft.h>
   79 #endif
   80 
   81 #include <stdio.h>
   82 
   83 #if defined(HAVE_STDINT_H) || !defined(HAVE_CONFIG_H)
   84 #include <stdint.h>
   85 #define DECONST(type,s) ((type *)(intptr_t)(const type *)(s))
   86 #else
   87 #define DECONST(type,s) ((type *)(s))
   88 #endif
   89 
   90 /* adapted from IntrinsicI.h */
   91 #define MyStackAlloc(size, stack_cache_array)     \
   92     ((size) <= sizeof(stack_cache_array)      \
   93     ?  (XtPointer)(stack_cache_array)         \
   94     :  (XtPointer)malloc((size_t)(size)))
   95 
   96 #define MyStackFree(pointer, stack_cache_array) \
   97     if ((pointer) != ((char *)(stack_cache_array))) free(pointer)
   98 
   99 /* adapted from vile (vi-like-emacs) */
  100 #define TypeCallocN(type,n) (type *)calloc((size_t) (n), sizeof(type))
  101 #define TypeCalloc(type)    TypeCallocN(type, 1)
  102 
  103 #define TypeMallocN(type,n) (type *)malloc(sizeof(type) * (size_t) (n))
  104 #define TypeMalloc(type)    TypeMallocN(type, 1)
  105 
  106 #define TypeRealloc(type,n,p)   (type *)realloc(p, (n) * sizeof(type))
  107 
  108 #define TypeXtReallocN(t,p,n)   (t *)(void *)XtRealloc((char *)(p), (Cardinal)(sizeof(t) * (size_t) (n)))
  109 
  110 #define TypeXtMallocX(type,n)   (type *)(void *)XtMalloc((Cardinal)(sizeof(type) + (size_t) (n)))
  111 #define TypeXtMallocN(type,n)   (type *)(void *)XtMalloc((Cardinal)(sizeof(type) * (size_t) (n)))
  112 #define TypeXtMalloc(type)  TypeXtMallocN(type, 1)
  113 
  114 /* use these to allocate partly-structured data */
  115 #define TextAlloc(n)        (char *)malloc(sizeof(char) * (size_t) ((n) + 1))
  116 #define CastMalloc(type)    (type *)malloc(sizeof(type))
  117 
  118 #define BumpBuffer(type, buffer, size, want) \
  119     if (want >= size) { \
  120         size = 1 + (want * 2); \
  121         buffer = TypeRealloc(type, size, buffer); \
  122     }
  123 
  124 #define BfBuf(type) screen->bf_buf_##type
  125 #define BfLen(type) screen->bf_len_##type
  126 
  127 #define TypedBuffer(type) \
  128     type        *bf_buf_##type; \
  129     Cardinal    bf_len_##type
  130 
  131 #define BumpTypedBuffer(type, want) \
  132     BumpBuffer(type, BfBuf(type), BfLen(type), want)
  133 
  134 #define FreeTypedBuffer(type) \
  135     if (BfBuf(type) != 0) { \
  136         free(BfBuf(type)); \
  137         BfBuf(type) = 0; \
  138     } \
  139     BfLen(type) = 0
  140 
  141 /*
  142 ** System V definitions
  143 */
  144 
  145 #ifdef att
  146 #define ATT
  147 #endif
  148 
  149 #ifdef SVR4
  150 #undef  SYSV            /* predefined on Solaris 2.4 */
  151 #define SYSV            /* SVR4 is (approx) superset of SVR3 */
  152 #define ATT
  153 #endif
  154 
  155 #ifdef SYSV
  156 #ifdef X_NOT_POSIX
  157 #if !defined(CRAY) && !defined(SVR4)
  158 #define dup2(fd1,fd2)   ((fd1 == fd2) ? fd1 : \
  159                 (close(fd2), fcntl(fd1, F_DUPFD, fd2)))
  160 #endif
  161 #endif
  162 #endif /* SYSV */
  163 
  164 /*
  165  * Newer versions of <X11/Xft/Xft.h> have a version number.  We use certain
  166  * features from that.
  167  */
  168 #if defined(XRENDERFONT) && defined(XFT_VERSION) && XFT_VERSION >= 20100
  169 #define HAVE_TYPE_FCCHAR32  1   /* compatible: XftChar16 */
  170 #define HAVE_TYPE_XFTCHARSPEC   1   /* new type XftCharSpec */
  171 #endif
  172 
  173 /*
  174 ** Definitions to simplify ifdef's for pty's.
  175 */
  176 #define USE_PTY_DEVICE 1
  177 #define USE_PTY_SEARCH 1
  178 
  179 #if defined(__osf__) || (defined(linux) && defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
  180 #undef USE_PTY_DEVICE
  181 #undef USE_PTY_SEARCH
  182 #define USE_PTS_DEVICE 1
  183 #elif defined(VMS)
  184 #undef USE_PTY_DEVICE
  185 #undef USE_PTY_SEARCH
  186 #elif defined(PUCC_PTYD)
  187 #undef USE_PTY_SEARCH
  188 #elif (defined(sun) && defined(SVR4)) || defined(_ALL_SOURCE) || defined(__CYGWIN__)
  189 #undef USE_PTY_SEARCH
  190 #elif defined(__OpenBSD__)
  191 #undef USE_PTY_SEARCH
  192 #undef USE_PTY_DEVICE
  193 #endif
  194 
  195 #if (defined (__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1)))
  196 #define USE_HANDSHAKE 0 /* "recent" Linux systems do not require handshaking */
  197 #endif
  198 
  199 #if (defined (__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1)))
  200 #define USE_USG_PTYS
  201 #elif (defined(ATT) && !defined(__sgi)) || defined(__MVS__) || (defined(SYSV) && defined(i386))
  202 #define USE_USG_PTYS
  203 #endif
  204 
  205 /*
  206  * More systems than not require pty-handshaking.
  207  */
  208 #ifndef USE_HANDSHAKE
  209 #define USE_HANDSHAKE 1
  210 #endif
  211 
  212 /*
  213 ** allow for mobility of the pty master/slave directories
  214 */
  215 #ifndef PTYDEV
  216 #if defined(__hpux)
  217 #define PTYDEV      "/dev/ptym/ptyxx"
  218 #elif defined(__MVS__)
  219 #define PTYDEV      "/dev/ptypxxxx"
  220 #else
  221 #define PTYDEV      "/dev/ptyxx"
  222 #endif
  223 #endif  /* !PTYDEV */
  224 
  225 #ifndef TTYDEV
  226 #if defined(__hpux)
  227 #define TTYDEV      "/dev/pty/ttyxx"
  228 #elif defined(__MVS__)
  229 #define TTYDEV      "/dev/ptypxxxx"
  230 #elif defined(USE_PTS_DEVICE)
  231 #define TTYDEV      "/dev/pts/0"
  232 #else
  233 #define TTYDEV      "/dev/ttyxx"
  234 #endif
  235 #endif  /* !TTYDEV */
  236 
  237 #ifndef PTYCHAR1
  238 #ifdef __hpux
  239 #define PTYCHAR1    "zyxwvutsrqp"
  240 #else   /* !__hpux */
  241 #define PTYCHAR1    "pqrstuvwxyzPQRSTUVWXYZ"
  242 #endif  /* !__hpux */
  243 #endif  /* !PTYCHAR1 */
  244 
  245 #ifndef PTYCHAR2
  246 #ifdef __hpux
  247 #define PTYCHAR2    "fedcba9876543210"
  248 #else   /* !__hpux */
  249 #if defined(__DragonFly__) || defined(__FreeBSD__)
  250 #define PTYCHAR2    "0123456789abcdefghijklmnopqrstuv"
  251 #else /* !__FreeBSD__ */
  252 #define PTYCHAR2    "0123456789abcdef"
  253 #endif /* !__FreeBSD__ */
  254 #endif  /* !__hpux */
  255 #endif  /* !PTYCHAR2 */
  256 
  257 #ifndef TTYFORMAT
  258 #if defined(CRAY)
  259 #define TTYFORMAT "/dev/ttyp%03d"
  260 #elif defined(__MVS__)
  261 #define TTYFORMAT "/dev/ttyp%04d"
  262 #else
  263 #define TTYFORMAT "/dev/ttyp%d"
  264 #endif
  265 #endif /* TTYFORMAT */
  266 
  267 #ifndef PTYFORMAT
  268 #ifdef CRAY
  269 #define PTYFORMAT "/dev/pty/%03d"
  270 #elif defined(__MVS__)
  271 #define PTYFORMAT "/dev/ptyp%04d"
  272 #else
  273 #define PTYFORMAT "/dev/ptyp%d"
  274 #endif
  275 #endif /* PTYFORMAT */
  276 
  277 #ifndef PTYCHARLEN
  278 #ifdef CRAY
  279 #define PTYCHARLEN 3
  280 #elif defined(__MVS__)
  281 #define PTYCHARLEN 8     /* OS/390 stores, e.g. ut_id="ttyp1234"  */
  282 #else
  283 #define PTYCHARLEN 2
  284 #endif
  285 #endif
  286 
  287 #ifndef MAXPTTYS
  288 #ifdef CRAY
  289 #define MAXPTTYS 256
  290 #else
  291 #define MAXPTTYS 2048
  292 #endif
  293 #endif
  294 
  295 /* Until the translation manager comes along, I have to do my own translation of
  296  * mouse events into the proper routines. */
  297 
  298 typedef enum {
  299     NORMAL = 0
  300     , LEFTEXTENSION
  301     , RIGHTEXTENSION
  302 } EventMode;
  303 
  304 /*
  305  * The origin of a screen is 0, 0.  Therefore, the number of rows
  306  * on a screen is screen->max_row + 1, and similarly for columns.
  307  */
  308 #define MaxCols(screen)     ((screen)->max_col + 1)
  309 #define MaxRows(screen)     ((screen)->max_row + 1)
  310 
  311 typedef unsigned char Char;     /* to support 8 bit chars */
  312 typedef Char *ScrnPtr;
  313 typedef ScrnPtr *ScrnBuf;
  314 
  315 /*
  316  * Declare an X String, but for unsigned chars.
  317  */
  318 #ifdef _CONST_X_STRING
  319 typedef const Char *UString;
  320 #else
  321 typedef Char *UString;
  322 #endif
  323 
  324 #define IsEmpty(s) ((s) == 0 || *(s) == '\0')
  325 #define IsSpace(c) ((c) == ' ' || (c) == '\t' || (c) == '\r' || (c) == '\n')
  326 
  327 /*
  328  * Check strtol result, using "FullS2L" when no more data is expected, and
  329  * "PartS2L" when more data may follow in the string.
  330  */
  331 #define FullS2L(s,d) (PartS2L(s,d) && (*(d) == '\0'))
  332 #define PartS2L(s,d) (isdigit(CharOf(*(s))) && (d) != (s) && (d) != 0)
  333 
  334 #define CASETYPE(name) case name: result = #name; break
  335 
  336 #define CharOf(n) ((Char)(n))
  337 
  338 typedef struct {
  339     int row;
  340     int col;
  341 } CELL;
  342 
  343 typedef struct {
  344     Char  *data_buffer;         /* the current selection */
  345     size_t data_limit;          /* size of allocated buffer */
  346     size_t data_length;         /* number of significant bytes */
  347 } SelectedCells;
  348 
  349 #define isSameRow(a,b)      ((a)->row == (b)->row)
  350 #define isSameCol(a,b)      ((a)->col == (b)->col)
  351 #define isSameCELL(a,b)     (isSameRow(a,b) && isSameCol(a,b))
  352 
  353 #define xBIT(n)         (1 << (n))
  354 
  355 /*
  356  * ANSI emulation, special character codes
  357  */
  358 #define ANSI_EOT    0x04
  359 #define ANSI_BEL    0x07
  360 #define ANSI_BS     0x08
  361 #define ANSI_HT     0x09
  362 #define ANSI_LF     0x0A
  363 #define ANSI_VT     0x0B
  364 #define ANSI_FF     0x0C        /* C0, C1 control names     */
  365 #define ANSI_CR     0x0D
  366 #define ANSI_SO     0x0E
  367 #define ANSI_SI     0x0F
  368 #define ANSI_XON    0x11        /* DC1 */
  369 #define ANSI_XOFF   0x13        /* DC3 */
  370 #define ANSI_NAK    0x15
  371 #define ANSI_CAN    0x18
  372 #define ANSI_ESC    0x1B
  373 #define ANSI_SPA    0x20
  374 #define XTERM_POUND 0x1E        /* internal mapping for '#' */
  375 #define ANSI_DEL    0x7F
  376 #define ANSI_SS2    0x8E
  377 #define ANSI_SS3    0x8F
  378 #define ANSI_DCS    0x90
  379 #define ANSI_SOS    0x98
  380 #define ANSI_CSI    0x9B
  381 #define ANSI_ST     0x9C
  382 #define ANSI_OSC    0x9D
  383 #define ANSI_PM     0x9E
  384 #define ANSI_APC    0x9F
  385 
  386 #define BAD_ASCII   '?'
  387 #define NonLatin1(c)    (((c) != ANSI_LF) && \
  388              ((c) != ANSI_HT) && \
  389              (((c) < ANSI_SPA) || \
  390               ((c) >= ANSI_DEL && (c) <= ANSI_APC)))
  391 #define OnlyLatin1(c)   (NonLatin1(c) ? BAD_ASCII : (c))
  392 
  393 #define L_CURL      '{'
  394 #define R_CURL      '}'
  395 
  396 #define MIN_DECID  52           /* can emulate VT52 */
  397 #define MAX_DECID 525           /* ...through VT525 */
  398 
  399 #ifndef DFT_DECID
  400 #define DFT_DECID "420"         /* default VT420 */
  401 #endif
  402 
  403 #ifndef DFT_KBD_DIALECT
  404 #define DFT_KBD_DIALECT "B"     /* default USASCII */
  405 #endif
  406 
  407 /* constants used for utf8 mode */
  408 #define UCS_REPL    0xfffd
  409 #define UCS_LIMIT   0x80000000U /* both limit and flag for non-UCS */
  410 
  411 #define TERMCAP_SIZE 1500       /* 1023 is standard; 'screen' exceeds */
  412 
  413 #define MAX_XLFD_FONTS  1
  414 #define MAX_XFT_FONTS   1
  415 #define NMENUFONTS  9       /* font entries in fontMenu */
  416 
  417 #define NBOX    5           /* Number of Points in box  */
  418 #define NPARAM  30          /* Max. parameters      */
  419 
  420 typedef struct {
  421     String opt;
  422     String desc;
  423 } OptionHelp;
  424 
  425 typedef struct {
  426     int count;          /* number of values in params[] */
  427     int has_subparams;      /* true if there are any sub's  */
  428     int is_sub[NPARAM];     /* true for subparam        */
  429     int params[NPARAM];     /* parameter value      */
  430 } PARAMS;
  431 
  432 typedef short ParmType;
  433 typedef unsigned short UParm;       /* unparseputn passes ParmType  */
  434 
  435 typedef struct {
  436     Char        a_type;     /* CSI, etc., see unparseq()    */
  437     Char        a_pintro;   /* private-mode char, if any    */
  438     const char *    a_delim;    /* between parameters (;)   */
  439     Char        a_inters;   /* special (before final-char)  */
  440     Char        a_final;    /* final-char           */
  441     ParmType    a_nparam;   /* # of parameters      */
  442     ParmType    a_param[NPARAM]; /* Parameters          */
  443     Char        a_radix[NPARAM]; /* Parameters          */
  444 } ANSI;
  445 
  446 #define TEK_FONT_LARGE 0
  447 #define TEK_FONT_2 1
  448 #define TEK_FONT_3 2
  449 #define TEK_FONT_SMALL 3
  450 #define TEKNUMFONTS 4
  451 
  452 /* Actually there are 5 types of lines, but four are non-solid lines */
  453 #define TEKNUMLINES 4
  454 
  455 typedef struct {
  456     int x;
  457     int y;
  458     int fontsize;
  459     unsigned linetype;
  460 } Tmodes;
  461 
  462 typedef struct {
  463     int Twidth;
  464     int Theight;
  465 } T_fontsize;
  466 
  467 typedef struct {
  468     short *bits;
  469     int x;
  470     int y;
  471     int width;
  472     int height;
  473 } BitmapBits;
  474 
  475 /* bit-assignments for extensions to DECRQCRA */
  476 typedef enum {
  477     csDEC = 0
  478     ,csPOSITIVE = xBIT(0)
  479     ,csATTRIBS = xBIT(1)
  480     ,csNOTRIM = xBIT(2)
  481     ,csDRAWN = xBIT(3)
  482     ,csBYTE = xBIT(4)
  483     ,cs8TH = xBIT(5)
  484 } CSBITS;
  485 
  486 #define EXCHANGE(a,b,tmp) tmp = a; a = b; b = tmp
  487 
  488 /***====================================================================***/
  489 
  490 #if (XtSpecificationRelease < 6)
  491 #ifndef NO_ACTIVE_ICON
  492 #define NO_ACTIVE_ICON 1 /* Note: code relies on an X11R6 function */
  493 #endif
  494 #endif
  495 
  496 #ifndef OPT_AIX_COLORS
  497 #define OPT_AIX_COLORS  1 /* true if xterm is configured with AIX (16) colors */
  498 #endif
  499 
  500 #ifndef OPT_ALLOW_XXX_OPS
  501 #define OPT_ALLOW_XXX_OPS 1 /* true if xterm adds "Allow XXX Ops" submenu */
  502 #endif
  503 
  504 #ifndef OPT_BLINK_CURS
  505 #define OPT_BLINK_CURS  1 /* true if xterm has blinking cursor capability */
  506 #endif
  507 
  508 #ifndef OPT_BLINK_TEXT
  509 #define OPT_BLINK_TEXT  OPT_BLINK_CURS /* true if xterm has blinking text capability */
  510 #endif
  511 
  512 #ifndef OPT_BOX_CHARS
  513 #define OPT_BOX_CHARS   1 /* true if xterm can simulate box-characters */
  514 #endif
  515 
  516 #ifndef OPT_BUILTIN_XPMS
  517 #define OPT_BUILTIN_XPMS 0 /* true if all xpm data is compiled-in */
  518 #endif
  519 
  520 #ifndef OPT_BROKEN_OSC
  521 #ifdef linux
  522 #define OPT_BROKEN_OSC  1 /* man console_codes, 1st paragraph - cf: ECMA-48 */
  523 #else
  524 #define OPT_BROKEN_OSC  0 /* true if xterm allows Linux's broken OSC parsing */
  525 #endif
  526 #endif
  527 
  528 #ifndef OPT_BROKEN_ST
  529 #define OPT_BROKEN_ST   1 /* true if xterm allows old/broken OSC parsing */
  530 #endif
  531 
  532 #ifndef OPT_C1_PRINT
  533 #define OPT_C1_PRINT    1 /* true if xterm allows C1 controls to be printable */
  534 #endif
  535 
  536 #ifndef OPT_CLIP_BOLD
  537 #define OPT_CLIP_BOLD   1 /* true if xterm uses clipping to avoid bold-trash */
  538 #endif
  539 
  540 #ifndef OPT_COLOR_CLASS
  541 #define OPT_COLOR_CLASS 1 /* true if xterm uses separate color-resource classes */
  542 #endif
  543 
  544 #ifndef OPT_COLOR_RES
  545 #define OPT_COLOR_RES   1 /* true if xterm delays color-resource evaluation */
  546 #endif
  547 
  548 #ifndef OPT_DABBREV
  549 #define OPT_DABBREV 0   /* dynamic abbreviations */
  550 #endif
  551 
  552 #ifndef OPT_DEC_CHRSET
  553 #define OPT_DEC_CHRSET  1 /* true if xterm is configured for DEC charset */
  554 #endif
  555 
  556 #ifndef OPT_DEC_LOCATOR
  557 #define OPT_DEC_LOCATOR 0 /* true if xterm supports VT220-style mouse events */
  558 #endif
  559 
  560 #ifndef OPT_DEC_RECTOPS
  561 #define OPT_DEC_RECTOPS 1 /* true if xterm is configured for VT420 rectangles */
  562 #endif
  563 
  564 #ifndef OPT_SIXEL_GRAPHICS
  565 #define OPT_SIXEL_GRAPHICS 0 /* true if xterm supports VT240-style sixel graphics */
  566 #endif
  567 
  568 #ifndef OPT_SCREEN_DUMPS
  569 #define OPT_SCREEN_DUMPS 1 /* true if xterm supports screen dumps */
  570 #endif
  571 
  572 #ifndef OPT_REGIS_GRAPHICS
  573 #define OPT_REGIS_GRAPHICS 0 /* true if xterm supports VT125/VT240/VT330 ReGIS graphics */
  574 #endif
  575 
  576 #ifndef OPT_GRAPHICS
  577 #define OPT_GRAPHICS 0 /* true if xterm is configured for any type of graphics */
  578 #endif
  579 
  580 #ifndef OPT_DEC_SOFTFONT
  581 #define OPT_DEC_SOFTFONT 0 /* true if xterm is configured for VT220 softfonts */
  582 #endif
  583 
  584 #ifndef OPT_DOUBLE_BUFFER
  585 #define OPT_DOUBLE_BUFFER 0 /* true if using double-buffering */
  586 #endif
  587 
  588 #ifndef OPT_EBCDIC
  589 #ifdef __MVS__
  590 #define OPT_EBCDIC 1
  591 #else
  592 #define OPT_EBCDIC 0
  593 #endif
  594 #endif
  595 
  596 #ifndef OPT_EXEC_XTERM
  597 #define OPT_EXEC_XTERM 0 /* true if xterm can fork/exec copies of itself */
  598 #endif
  599 
  600 #ifndef OPT_EXTRA_PASTE
  601 #define OPT_EXTRA_PASTE 1
  602 #endif
  603 
  604 #ifndef OPT_FIFO_LINES
  605 #define OPT_FIFO_LINES 1 /* optimize save-lines feature using FIFO */
  606 #endif
  607 
  608 #ifndef OPT_FOCUS_EVENT
  609 #define OPT_FOCUS_EVENT 1 /* focus in/out events */
  610 #endif
  611 
  612 #ifndef OPT_HP_FUNC_KEYS
  613 #define OPT_HP_FUNC_KEYS 0 /* true if xterm supports HP-style function keys */
  614 #endif
  615 
  616 #ifndef OPT_I18N_SUPPORT
  617 #if (XtSpecificationRelease >= 5)
  618 #define OPT_I18N_SUPPORT 1 /* true if xterm uses internationalization support */
  619 #else
  620 #define OPT_I18N_SUPPORT 0
  621 #endif
  622 #endif
  623 
  624 #ifndef OPT_INITIAL_ERASE
  625 #define OPT_INITIAL_ERASE 1 /* use pty's erase character if it's not 128 */
  626 #endif
  627 
  628 #ifndef OPT_INPUT_METHOD
  629 #if (XtSpecificationRelease >= 6)
  630 #define OPT_INPUT_METHOD OPT_I18N_SUPPORT /* true if xterm uses input-method support */
  631 #else
  632 #define OPT_INPUT_METHOD 0
  633 #endif
  634 #endif
  635 
  636 #ifndef OPT_ISO_COLORS
  637 #define OPT_ISO_COLORS  1 /* true if xterm is configured with ISO colors */
  638 #endif
  639 
  640 #ifndef OPT_DIRECT_COLOR
  641 #define OPT_DIRECT_COLOR  OPT_ISO_COLORS /* true if xterm is configured with direct-colors */
  642 #endif
  643 
  644 #ifndef OPT_256_COLORS
  645 #define OPT_256_COLORS  1 /* true if xterm is configured with 256 colors */
  646 #endif
  647 
  648 #ifndef OPT_88_COLORS
  649 #define OPT_88_COLORS   1 /* true if xterm is configured with 88 colors */
  650 #endif
  651 
  652 #ifndef OPT_HIGHLIGHT_COLOR
  653 #define OPT_HIGHLIGHT_COLOR 1 /* true if xterm supports color highlighting */
  654 #endif
  655 
  656 #ifndef OPT_LOAD_VTFONTS
  657 #define OPT_LOAD_VTFONTS 0 /* true if xterm has load-vt-fonts() action */
  658 #endif
  659 
  660 #ifndef OPT_LUIT_PROG
  661 #define OPT_LUIT_PROG   1 /* true if xterm supports luit */
  662 #endif
  663 
  664 #ifndef OPT_MAXIMIZE
  665 #define OPT_MAXIMIZE    1 /* add actions for iconify ... maximize */
  666 #endif
  667 
  668 #ifndef OPT_MINI_LUIT
  669 #define OPT_MINI_LUIT   0 /* true if xterm supports built-in mini-luit */
  670 #endif
  671 
  672 #ifndef OPT_MOD_FKEYS
  673 #define OPT_MOD_FKEYS   1 /* modify cursor- and function-keys in normal mode */
  674 #endif
  675 
  676 #ifndef OPT_NUM_LOCK
  677 #define OPT_NUM_LOCK    1 /* use NumLock key only for numeric-keypad */
  678 #endif
  679 
  680 #ifndef OPT_PASTE64
  681 #define OPT_PASTE64 1 /* program control of select/paste via base64 */
  682 #endif
  683 
  684 #ifndef OPT_PC_COLORS
  685 #define OPT_PC_COLORS   1 /* true if xterm supports PC-style (bold) colors */
  686 #endif
  687 
  688 #ifndef OPT_PRINT_ON_EXIT
  689 #define OPT_PRINT_ON_EXIT 1 /* true allows xterm to dump screen on X error */
  690 #endif
  691 
  692 #ifndef OPT_PTY_HANDSHAKE
  693 #define OPT_PTY_HANDSHAKE USE_HANDSHAKE /* avoid pty races on older systems */
  694 #endif
  695 
  696 #ifndef OPT_PRINT_COLORS
  697 #define OPT_PRINT_COLORS 1 /* true if we print color information */
  698 #endif
  699 
  700 #ifndef OPT_READLINE
  701 #define OPT_READLINE    0 /* mouse-click/paste support for readline */
  702 #endif
  703 
  704 #ifndef OPT_RENDERFONT
  705 #ifdef XRENDERFONT
  706 #define OPT_RENDERFONT 1
  707 #else
  708 #define OPT_RENDERFONT 0
  709 #endif
  710 #endif
  711 
  712 #ifndef OPT_RENDERWIDE
  713 #if OPT_RENDERFONT && OPT_WIDE_CHARS && defined(HAVE_TYPE_XFTCHARSPEC)
  714 #define OPT_RENDERWIDE 1
  715 #else
  716 #define OPT_RENDERWIDE 0
  717 #endif
  718 #endif
  719 
  720 #ifndef OPT_REPORT_CCLASS
  721 #define OPT_REPORT_CCLASS  1 /* provide "-report-charclass" option */
  722 #endif
  723 
  724 #ifndef OPT_REPORT_COLORS
  725 #define OPT_REPORT_COLORS  1 /* provide "-report-colors" option */
  726 #endif
  727 
  728 #ifndef OPT_REPORT_FONTS
  729 #define OPT_REPORT_FONTS   1 /* provide "-report-fonts" option */
  730 #endif
  731 
  732 #ifndef OPT_REPORT_ICONS
  733 #define OPT_REPORT_ICONS   1 /* provide "-report-icons" option */
  734 #endif
  735 
  736 #ifndef OPT_SAME_NAME
  737 #define OPT_SAME_NAME   1 /* suppress redundant updates of title, icon, etc. */
  738 #endif
  739 
  740 #ifndef OPT_SAVE_LINES
  741 #define OPT_SAVE_LINES OPT_FIFO_LINES /* optimize save-lines feature */
  742 #endif
  743 
  744 #ifndef OPT_SCO_FUNC_KEYS
  745 #define OPT_SCO_FUNC_KEYS 0 /* true if xterm supports SCO-style function keys */
  746 #endif
  747 
  748 #ifndef OPT_SUN_FUNC_KEYS
  749 #define OPT_SUN_FUNC_KEYS 1 /* true if xterm supports Sun-style function keys */
  750 #endif
  751 
  752 #ifndef OPT_SCROLL_LOCK
  753 #define OPT_SCROLL_LOCK 1 /* true if xterm interprets fontsize-shifting */
  754 #endif
  755 
  756 #ifndef OPT_SELECT_REGEX
  757 #define OPT_SELECT_REGEX 1 /* true if xterm supports regular-expression selects */
  758 #endif
  759 
  760 #ifndef OPT_SELECTION_OPS
  761 #define OPT_SELECTION_OPS 1 /* true if xterm supports operations on selection */
  762 #endif
  763 
  764 #ifndef OPT_SESSION_MGT
  765 #if defined(XtNdieCallback) && defined(XtNsaveCallback)
  766 #define OPT_SESSION_MGT 1
  767 #else
  768 #define OPT_SESSION_MGT 0
  769 #endif
  770 #endif
  771 
  772 #ifndef OPT_SHIFT_FONTS
  773 #define OPT_SHIFT_FONTS 1 /* true if xterm interprets fontsize-shifting */
  774 #endif
  775 
  776 #ifndef OPT_SUNPC_KBD
  777 #define OPT_SUNPC_KBD   1 /* true if xterm supports Sun/PC keyboard map */
  778 #endif
  779 
  780 #ifndef OPT_TCAP_FKEYS
  781 #define OPT_TCAP_FKEYS  1 /* true for termcap function-keys */
  782 #endif
  783 
  784 #ifndef OPT_TCAP_QUERY
  785 #define OPT_TCAP_QUERY  1 /* true for termcap query */
  786 #endif
  787 
  788 #ifndef OPT_TEK4014
  789 #define OPT_TEK4014     1 /* true if we're using tek4014 emulation */
  790 #endif
  791 
  792 #ifndef OPT_TOOLBAR
  793 #define OPT_TOOLBAR 0 /* true if xterm supports toolbar menus */
  794 #endif
  795 
  796 #ifndef OPT_TRACE
  797 #define OPT_TRACE       0 /* true if we're using debugging traces */
  798 #endif
  799 
  800 #ifndef OPT_TRACE_FLAGS
  801 #define OPT_TRACE_FLAGS 0 /* additional tracing used for SCRN_BUF_FLAGS */
  802 #endif
  803 
  804 #ifndef OPT_VT52_MODE
  805 #define OPT_VT52_MODE   1 /* true if xterm supports VT52 emulation */
  806 #endif
  807 
  808 #ifndef OPT_WIDE_ATTRS
  809 #define OPT_WIDE_ATTRS  1 /* true if xterm supports 16-bit attributes */
  810 #endif
  811 
  812 #ifndef OPT_WIDE_CHARS
  813 #define OPT_WIDE_CHARS  1 /* true if xterm supports 16-bit characters */
  814 #endif
  815 
  816 #ifndef OPT_WIDER_ICHAR
  817 #define OPT_WIDER_ICHAR 1 /* true if xterm uses 32-bits for wide-chars */
  818 #endif
  819 
  820 #ifndef OPT_XMC_GLITCH
  821 #define OPT_XMC_GLITCH  0 /* true if xterm supports xmc (magic cookie glitch) */
  822 #endif
  823 
  824 #ifndef OPT_XRES_QUERY
  825 #define OPT_XRES_QUERY  1 /* true for resource query */
  826 #endif
  827 
  828 #ifndef OPT_XTERM_SGR
  829 #define OPT_XTERM_SGR   1 /* true if xterm supports private SGR controls */
  830 #endif
  831 
  832 #ifndef OPT_ZICONBEEP
  833 #define OPT_ZICONBEEP   1 /* true if xterm supports "-ziconbeep" option */
  834 #endif
  835 
  836 /***====================================================================***/
  837 
  838 #if OPT_AIX_COLORS && !OPT_ISO_COLORS
  839 /* You must have ANSI/ISO colors to support AIX colors */
  840 #undef  OPT_AIX_COLORS
  841 #define OPT_AIX_COLORS 0
  842 #endif
  843 
  844 #if OPT_COLOR_RES && !OPT_ISO_COLORS
  845 /* You must have ANSI/ISO colors to support ColorRes logic */
  846 #undef  OPT_COLOR_RES
  847 #define OPT_COLOR_RES 0
  848 #endif
  849 
  850 #if OPT_256_COLORS && (OPT_WIDE_CHARS || OPT_RENDERFONT || OPT_XMC_GLITCH)
  851 /* It's actually more complicated than that - but by trimming options you can
  852  * have 256 color resources though.
  853  */
  854 #define OPT_COLOR_RES2 1
  855 #else
  856 #define OPT_COLOR_RES2 0
  857 #endif
  858 
  859 #if OPT_PC_COLORS && !OPT_ISO_COLORS
  860 /* You must have ANSI/ISO colors to support PC colors */
  861 #undef  OPT_PC_COLORS
  862 #define OPT_PC_COLORS 0
  863 #endif
  864 
  865 #if OPT_PRINT_COLORS && !OPT_ISO_COLORS
  866 /* You must have ANSI/ISO colors to be able to print them */
  867 #undef  OPT_PRINT_COLORS
  868 #define OPT_PRINT_COLORS 0
  869 #endif
  870 
  871 #if OPT_256_COLORS && !OPT_ISO_COLORS
  872 /* You must have ANSI/ISO colors to support 256 colors */
  873 #undef  OPT_256_COLORS
  874 #define OPT_256_COLORS 0
  875 #endif
  876 
  877 #if OPT_88_COLORS && !OPT_ISO_COLORS
  878 /* You must have ANSI/ISO colors to support 88 colors */
  879 #undef  OPT_88_COLORS
  880 #define OPT_88_COLORS 0
  881 #endif
  882 
  883 #if OPT_88_COLORS && OPT_256_COLORS
  884 /* 256 colors supersedes 88 colors */
  885 #undef  OPT_88_COLORS
  886 #define OPT_88_COLORS 0
  887 #endif
  888 
  889 /***====================================================================***/
  890 
  891 /*
  892  * Indices for menu_font_names[][]
  893  */
  894 typedef enum {
  895     fNorm = 0           /* normal font */
  896     , fBold         /* bold font */
  897 #if OPT_WIDE_ATTRS || OPT_RENDERWIDE
  898     , fItal         /* italic font */
  899     , fBtal         /* bold-italic font */
  900 #endif
  901 #if OPT_WIDE_CHARS
  902     , fWide         /* double-width font */
  903     , fWBold            /* double-width bold font */
  904     , fWItal            /* double-width italic font */
  905     , fWBtal            /* double-width bold-italic font */
  906 #endif
  907     , fMAX
  908 } VTFontEnum;
  909 
  910 /*
  911  * Indices for cachedGCs.c (unrelated to VTFontEnum).
  912  */
  913 typedef enum {
  914     gcNorm = 0
  915     , gcBold
  916     , gcNormReverse
  917     , gcBoldReverse
  918     , gcFiller
  919     , gcBorder
  920 #if OPT_BOX_CHARS
  921     , gcLine
  922     , gcDots
  923 #endif
  924 #if OPT_DEC_CHRSET
  925     , gcCNorm
  926     , gcCBold
  927 #endif
  928 #if OPT_WIDE_CHARS
  929     , gcWide
  930     , gcWBold
  931     , gcWideReverse
  932     , gcWBoldReverse
  933 #endif
  934     , gcVTcursNormal
  935     , gcVTcursFilled
  936     , gcVTcursReverse
  937     , gcVTcursOutline
  938 #if OPT_TEK4014
  939     , gcTKcurs
  940 #endif
  941     , gcMAX
  942 } CgsEnum;
  943 
  944 #define for_each_text_gc(n) for (n = gcNorm; n < gcVTcursNormal; ++n)
  945 #define for_each_curs_gc(n) for (n = gcVTcursNormal; n <= gcVTcursOutline; ++n)
  946 #define for_each_gc(n)      for (n = gcNorm; n < gcMAX; ++n)
  947 
  948 /*
  949  * Indices for the normal terminal colors in screen.Tcolors[].
  950  * See also OscTextColors, which has corresponding values.
  951  */
  952 typedef enum {
  953     TEXT_FG = 0         /* text foreground */
  954     , TEXT_BG           /* text background */
  955     , TEXT_CURSOR       /* text cursor */
  956     , MOUSE_FG          /* mouse foreground */
  957     , MOUSE_BG          /* mouse background */
  958 #if OPT_TEK4014
  959     , TEK_FG = 5        /* tektronix foreground */
  960     , TEK_BG            /* tektronix background */
  961 #endif
  962 #if OPT_HIGHLIGHT_COLOR
  963     , HIGHLIGHT_BG = 7      /* highlight background */
  964 #endif
  965 #if OPT_TEK4014
  966     , TEK_CURSOR = 8        /* tektronix cursor */
  967 #endif
  968 #if OPT_HIGHLIGHT_COLOR
  969     , HIGHLIGHT_FG = 9      /* highlight foreground */
  970 #endif
  971     , NCOLORS           /* total number of colors */
  972 } TermColors;
  973 
  974 /*
  975  * Definitions for exec-formatted and insert-formatted actions.
  976  */
  977 typedef void (*FormatSelect) (Widget, char *, char *, CELL *, CELL *);
  978 
  979 typedef struct {
  980     Boolean done;
  981     char *format;
  982     char *buffer;
  983     FormatSelect format_select;
  984 #if OPT_PASTE64
  985     Cardinal base64_paste;
  986 #endif
  987 #if OPT_PASTE64 || OPT_READLINE
  988     unsigned paste_brackets;
  989 #endif
  990 } InternalSelect;
  991 
  992 /*
  993  * Constants for titleModes resource
  994  */
  995 typedef enum {
  996     tmSetBase16 = 1     /* set title using hex-string */
  997     , tmGetBase16 = 2       /* get title using hex-string */
  998 #if OPT_WIDE_CHARS
  999     , tmSetUtf8 = 4     /* like utf8Title, but controllable */
 1000     , tmGetUtf8 = 8     /* retrieve title encoded as UTF-8 */
 1001 #endif
 1002 } TitleModes;
 1003 
 1004 #define IsTitleMode(xw,mode) (((xw)->screen.title_modes & mode) != 0)
 1005 
 1006 #include <xcharmouse.h>
 1007 
 1008 /*
 1009  * For readability...
 1010  */
 1011 #define nrc_percent   100
 1012 #define nrc_dquote    200
 1013 #define nrc_ampersand 300
 1014 typedef enum {
 1015     nrc_ASCII = 0
 1016     ,nrc_British        /* vt100 */
 1017     ,nrc_British_Latin_1    /* vt3xx */
 1018     ,nrc_Cyrillic       /* vt5xx */
 1019     ,nrc_DEC_Spec_Graphic   /* vt100 */
 1020     ,nrc_DEC_Alt_Chars      /* vt100 */
 1021     ,nrc_DEC_Alt_Graphics   /* vt100 */
 1022     ,nrc_DEC_Supp       /* vt2xx */
 1023     ,nrc_DEC_Supp_Graphic   /* vt3xx */
 1024     ,nrc_DEC_Technical      /* vt3xx */
 1025     ,nrc_Dutch          /* vt2xx */
 1026     ,nrc_Finnish        /* vt2xx */
 1027     ,nrc_Finnish2       /* vt2xx */
 1028     ,nrc_French         /* vt2xx */
 1029     ,nrc_French2        /* vt2xx */
 1030     ,nrc_French_Canadian    /* vt2xx */
 1031     ,nrc_French_Canadian2   /* vt3xx */
 1032     ,nrc_German         /* vt2xx */
 1033     ,nrc_Greek          /* vt5xx */
 1034     ,nrc_DEC_Greek_Supp     /* vt5xx */
 1035     ,nrc_ISO_Greek_Supp     /* vt5xx */
 1036     ,nrc_DEC_Hebrew_Supp    /* vt5xx */
 1037     ,nrc_Hebrew         /* vt5xx */
 1038     ,nrc_ISO_Hebrew_Supp    /* vt5xx */
 1039     ,nrc_Italian        /* vt2xx */
 1040     ,nrc_ISO_Latin_5_Supp   /* vt5xx */
 1041     ,nrc_ISO_Latin_Cyrillic /* vt5xx */
 1042     ,nrc_Norwegian_Danish   /* vt3xx */
 1043     ,nrc_Norwegian_Danish2  /* vt2xx */
 1044     ,nrc_Norwegian_Danish3  /* vt2xx */
 1045     ,nrc_Portugese      /* vt3xx */
 1046     ,nrc_Russian        /* vt5xx */
 1047     ,nrc_SCS_NRCS       /* vt5xx - probably Serbo/Croatian */
 1048     ,nrc_Spanish        /* vt2xx */
 1049     ,nrc_Swedish        /* vt2xx */
 1050     ,nrc_Swedish2       /* vt2xx */
 1051     ,nrc_Swiss          /* vt2xx */
 1052     ,nrc_DEC_Turkish_Supp   /* vt5xx */
 1053     ,nrc_Turkish        /* vt5xx */
 1054     ,nrc_Unknown
 1055 } DECNRCM_codes;
 1056 
 1057 /*
 1058  * Use this enumerated type to check consistency among dpmodes(), savemodes()
 1059  * restoremodes() and do_dec_rqm().
 1060  */
 1061 typedef enum {
 1062     srm_DECCKM = 1
 1063     ,srm_DECANM = 2
 1064     ,srm_DECCOLM = 3
 1065     ,srm_DECSCLM = 4
 1066     ,srm_DECSCNM = 5
 1067     ,srm_DECOM = 6
 1068     ,srm_DECAWM = 7
 1069     ,srm_DECARM = 8
 1070     ,srm_X10_MOUSE = SET_X10_MOUSE
 1071 #if OPT_TOOLBAR
 1072     ,srm_RXVT_TOOLBAR = 10
 1073 #endif
 1074 #if OPT_BLINK_CURS
 1075     ,srm_ATT610_BLINK = 12
 1076     ,srm_CURSOR_BLINK_OPS = 13
 1077     ,srm_XOR_CURSOR_BLINKS = 14
 1078 #endif
 1079     ,srm_DECPFF = 18
 1080     ,srm_DECPEX = 19
 1081     ,srm_DECTCEM = 25
 1082     ,srm_RXVT_SCROLLBAR = 30
 1083 #if OPT_SHIFT_FONTS
 1084     ,srm_RXVT_FONTSIZE = 35
 1085 #endif
 1086 #if OPT_TEK4014
 1087     ,srm_DECTEK = 38
 1088 #endif
 1089     ,srm_132COLS = 40
 1090     ,srm_CURSES_HACK = 41
 1091     ,srm_DECNRCM = 42
 1092     ,srm_MARGIN_BELL = 44
 1093     ,srm_REVERSEWRAP = 45
 1094 #ifdef ALLOWLOGGING
 1095     ,srm_ALLOWLOGGING = 46
 1096 #endif
 1097     ,srm_ALTBUF = 47
 1098     ,srm_DECNKM = 66
 1099     ,srm_DECBKM = 67
 1100     ,srm_DECLRMM = 69
 1101 #if OPT_SIXEL_GRAPHICS
 1102     ,srm_DECSDM = 80        /* Sixel Display Mode */
 1103 #endif
 1104     ,srm_DECNCSM = 95
 1105     ,srm_VT200_MOUSE = SET_VT200_MOUSE
 1106     ,srm_VT200_HIGHLIGHT_MOUSE = SET_VT200_HIGHLIGHT_MOUSE
 1107     ,srm_BTN_EVENT_MOUSE = SET_BTN_EVENT_MOUSE
 1108     ,srm_ANY_EVENT_MOUSE = SET_ANY_EVENT_MOUSE
 1109 #if OPT_FOCUS_EVENT
 1110     ,srm_FOCUS_EVENT_MOUSE = SET_FOCUS_EVENT_MOUSE
 1111 #endif
 1112     ,srm_EXT_MODE_MOUSE = SET_EXT_MODE_MOUSE
 1113     ,srm_SGR_EXT_MODE_MOUSE = SET_SGR_EXT_MODE_MOUSE
 1114     ,srm_URXVT_EXT_MODE_MOUSE = SET_URXVT_EXT_MODE_MOUSE
 1115     ,srm_ALTERNATE_SCROLL = SET_ALTERNATE_SCROLL
 1116     ,srm_RXVT_SCROLL_TTY_OUTPUT = 1010
 1117     ,srm_RXVT_SCROLL_TTY_KEYPRESS = 1011
 1118     ,srm_EIGHT_BIT_META = 1034
 1119 #if OPT_NUM_LOCK
 1120     ,srm_REAL_NUMLOCK = 1035
 1121     ,srm_META_SENDS_ESC = 1036
 1122 #endif
 1123     ,srm_DELETE_IS_DEL = 1037
 1124 #if OPT_NUM_LOCK
 1125     ,srm_ALT_SENDS_ESC = 1039
 1126 #endif
 1127     ,srm_KEEP_SELECTION = 1040
 1128     ,srm_SELECT_TO_CLIPBOARD = 1041
 1129     ,srm_BELL_IS_URGENT = 1042
 1130     ,srm_POP_ON_BELL = 1043
 1131     ,srm_KEEP_CLIPBOARD = 1044
 1132     ,srm_ALLOW_ALTBUF = 1046
 1133     ,srm_OPT_ALTBUF = 1047
 1134     ,srm_SAVE_CURSOR = 1048
 1135     ,srm_OPT_ALTBUF_CURSOR = 1049
 1136 #if OPT_TCAP_FKEYS
 1137     ,srm_TCAP_FKEYS = 1050
 1138 #endif
 1139 #if OPT_SUN_FUNC_KEYS
 1140     ,srm_SUN_FKEYS = 1051
 1141 #endif
 1142 #if OPT_HP_FUNC_KEYS
 1143     ,srm_HP_FKEYS = 1052
 1144 #endif
 1145 #if OPT_SCO_FUNC_KEYS
 1146     ,srm_SCO_FKEYS = 1053
 1147 #endif
 1148     ,srm_LEGACY_FKEYS = 1060
 1149 #if OPT_SUNPC_KBD
 1150     ,srm_VT220_FKEYS = 1061
 1151 #endif
 1152 #if OPT_GRAPHICS
 1153     ,srm_PRIVATE_COLOR_REGISTERS = 1070
 1154 #endif
 1155 #if OPT_PASTE64 || OPT_READLINE
 1156     ,srm_PASTE_IN_BRACKET = SET_PASTE_IN_BRACKET
 1157 #endif
 1158 #if OPT_READLINE
 1159     ,srm_BUTTON1_MOVE_POINT = SET_BUTTON1_MOVE_POINT
 1160     ,srm_BUTTON2_MOVE_POINT = SET_BUTTON2_MOVE_POINT
 1161     ,srm_DBUTTON3_DELETE = SET_DBUTTON3_DELETE
 1162     ,srm_PASTE_QUOTE = SET_PASTE_QUOTE
 1163     ,srm_PASTE_LITERAL_NL = SET_PASTE_LITERAL_NL
 1164 #endif              /* OPT_READLINE */
 1165 #if OPT_SIXEL_GRAPHICS
 1166     ,srm_SIXEL_SCROLLS_RIGHT = 8452
 1167 #endif
 1168 } DECSET_codes;
 1169 
 1170 /* internal codes for selection atoms */
 1171 typedef enum {
 1172     PRIMARY_CODE = 0
 1173     ,CLIPBOARD_CODE
 1174     ,SECONDARY_CODE
 1175     ,MAX_SELECTION_CODES
 1176 } SelectionCodes;
 1177 
 1178 /* indices for mapping multiple clicks to selection types */
 1179 typedef enum {
 1180     Select_CHAR=0
 1181     ,Select_WORD
 1182     ,Select_LINE
 1183     ,Select_GROUP
 1184     ,Select_PAGE
 1185     ,Select_ALL
 1186 #if OPT_SELECT_REGEX
 1187     ,Select_REGEX
 1188 #endif
 1189     ,NSELECTUNITS
 1190 } SelectUnit;
 1191 
 1192 #if OPT_BLINK_CURS
 1193 typedef enum {
 1194     cbFalse = 0
 1195     , cbTrue
 1196     , cbAlways
 1197     , cbNever
 1198     , cbLAST
 1199 } BlinkOps;
 1200 #endif
 1201 
 1202 typedef enum {
 1203     ecSetColor = 1
 1204     , ecGetColor
 1205     , ecGetAnsiColor
 1206     , ecLAST
 1207 } ColorOps;
 1208 
 1209 typedef enum {
 1210     efSetFont = 1
 1211     , efGetFont
 1212     , efLAST
 1213 } FontOps;
 1214 
 1215 typedef enum {
 1216     esFalse = 0
 1217     , esTrue
 1218     , esAlways
 1219     , esNever
 1220     , esLAST
 1221 } FullscreenOps;
 1222 
 1223 #ifndef NO_ACTIVE_ICON
 1224 typedef enum {
 1225     eiFalse = 0
 1226     , eiTrue
 1227     , eiDefault
 1228     , eiLAST
 1229 } AIconOps;
 1230 #endif
 1231 
 1232 typedef enum {
 1233     emX10 = 1
 1234     , emLocator
 1235     , emVT200Click
 1236     , emVT200Hilite
 1237     , emAnyButton
 1238     , emAnyEvent
 1239     , emFocusEvent
 1240     , emExtended
 1241     , emSGR
 1242     , emURXVT
 1243     , emAlternateScroll
 1244     , emLAST
 1245 } MouseOps;
 1246 
 1247 typedef enum {
 1248     epC0 = 1
 1249     , epBS
 1250     , epCR
 1251     , epDEL
 1252     , epESC
 1253     , epFF
 1254     , epHT
 1255     , epNL
 1256     , epLAST
 1257 } PasteControls;
 1258 
 1259 /*
 1260  * xterm uses these codes for the its push-SGR feature.  They match where
 1261  * possible the corresponding SGR coding.  The foreground and background colors
 1262  * do not fit into that scheme (because they are a set of ranges), so those are
 1263  * chosen arbitrarily -TD
 1264  */
 1265 typedef enum {
 1266     psBOLD = 1
 1267 #if OPT_WIDE_ATTRS
 1268     , psATR_FAINT = 2
 1269     , psATR_ITALIC = 3
 1270 #endif
 1271     , psUNDERLINE = 4
 1272     , psBLINK = 5
 1273     , psINVERSE = 7
 1274     , psINVISIBLE = 8
 1275 #if OPT_WIDE_ATTRS
 1276     , psATR_STRIKEOUT = 9
 1277 #endif
 1278 #if OPT_ISO_COLORS
 1279     , psFG_COLOR = 10
 1280     , psBG_COLOR = 11
 1281 #endif
 1282 #if OPT_WIDE_ATTRS
 1283     , psATR_DBL_UNDER = 21
 1284 #endif
 1285     , MAX_PUSH_SGR
 1286 } PushSGR;
 1287 
 1288 typedef enum {
 1289     etSetTcap = 1
 1290     , etGetTcap
 1291     , etLAST
 1292 } TcapOps;
 1293 
 1294 typedef enum {
 1295     /* 1-23 are chosen to be the same as the control-sequence coding */
 1296     ewRestoreWin = 1
 1297     , ewMinimizeWin = 2
 1298     , ewSetWinPosition = 3
 1299     , ewSetWinSizePixels = 4
 1300     , ewRaiseWin = 5
 1301     , ewLowerWin = 6
 1302     , ewRefreshWin = 7
 1303     , ewSetWinSizeChars = 8
 1304 #if OPT_MAXIMIZE
 1305     , ewMaximizeWin = 9
 1306     , ewFullscreenWin = 10
 1307 #endif
 1308     , ewGetWinState = 11
 1309     , ewGetWinPosition = 13
 1310     , ewGetWinSizePixels = 14
 1311 #if OPT_MAXIMIZE
 1312     , ewGetScreenSizePixels = 15
 1313     , ewGetCharSizePixels = 16
 1314 #endif
 1315     , ewGetWinSizeChars = 18
 1316 #if OPT_MAXIMIZE
 1317     , ewGetScreenSizeChars = 19
 1318 #endif
 1319     , ewGetIconTitle = 20
 1320     , ewGetWinTitle = 21
 1321     , ewPushTitle = 22
 1322     , ewPopTitle = 23
 1323     /* these do not fit into that scheme, which is why we use an array */
 1324     , ewSetWinLines
 1325     , ewSetXprop
 1326     , ewGetSelection
 1327     , ewSetSelection
 1328     , ewGetChecksum
 1329     , ewSetChecksum
 1330     /* get the size of the array... */
 1331     , ewLAST
 1332 } WindowOps;
 1333 
 1334 /***====================================================================***/
 1335 
 1336 #define COLOR_DEFINED(s,w)  ((s)->which & (unsigned) (1<<(w)))
 1337 #define COLOR_VALUE(s,w)    ((s)->colors[w])
 1338 #define SET_COLOR_VALUE(s,w,v)  (((s)->colors[w] = (v)), UIntSet((s)->which, (1<<(w))))
 1339 
 1340 #define COLOR_NAME(s,w)     ((s)->names[w])
 1341 #define SET_COLOR_NAME(s,w,v)   (((s)->names[w] = (v)), ((s)->which |= (unsigned) (1<<(w))))
 1342 
 1343 #define UNDEFINE_COLOR(s,w) ((s)->which &= (~((w)<<1)))
 1344 
 1345 /***====================================================================***/
 1346 
 1347 #if OPT_ISO_COLORS
 1348 #if OPT_WIDE_ATTRS
 1349 #define COLOR_FLAGS     (FG_COLOR | BG_COLOR | ATR_DIRECT_FG | ATR_DIRECT_BG)
 1350 #else
 1351 #define COLOR_FLAGS     (FG_COLOR | BG_COLOR)
 1352 #endif
 1353 #define TERM_COLOR_FLAGS(xw)    ((xw)->flags & COLOR_FLAGS)
 1354 #define COLOR_0     0
 1355 #define COLOR_1     1
 1356 #define COLOR_2     2
 1357 #define COLOR_3     3
 1358 #define COLOR_4     4
 1359 #define COLOR_5     5
 1360 #define COLOR_6     6
 1361 #define COLOR_7     7
 1362 #define COLOR_8     8
 1363 #define COLOR_9     9
 1364 #define COLOR_10    10
 1365 #define COLOR_11    11
 1366 #define COLOR_12    12
 1367 #define COLOR_13    13
 1368 #define COLOR_14    14
 1369 #define COLOR_15    15
 1370 #define MIN_ANSI_COLORS 16
 1371 
 1372 #if OPT_256_COLORS
 1373 # define NUM_ANSI_COLORS 256
 1374 #elif OPT_88_COLORS
 1375 # define NUM_ANSI_COLORS 88
 1376 #else
 1377 # define NUM_ANSI_COLORS MIN_ANSI_COLORS
 1378 #endif
 1379 
 1380 #define okIndexedColor(n) ((n) >= 0 && (n) < NUM_ANSI_COLORS)
 1381 
 1382 #if NUM_ANSI_COLORS > MIN_ANSI_COLORS
 1383 # define OPT_EXT_COLORS  1
 1384 #else
 1385 # define OPT_EXT_COLORS  0
 1386 #endif
 1387 
 1388 #define COLOR_BD    (NUM_ANSI_COLORS)   /* BOLD */
 1389 #define COLOR_UL    (NUM_ANSI_COLORS+1) /* UNDERLINE */
 1390 #define COLOR_BL    (NUM_ANSI_COLORS+2) /* BLINK */
 1391 #define COLOR_RV    (NUM_ANSI_COLORS+3) /* REVERSE */
 1392 
 1393 #if OPT_WIDE_ATTRS
 1394 #define COLOR_IT    (NUM_ANSI_COLORS+4) /* ITALIC */
 1395 #define MAXCOLORS   (NUM_ANSI_COLORS+5)
 1396 #else
 1397 #define MAXCOLORS   (NUM_ANSI_COLORS+4)
 1398 #endif
 1399 
 1400 #ifndef DFT_COLORMODE
 1401 #define DFT_COLORMODE True  /* default colorMode resource */
 1402 #endif
 1403 
 1404 #define UseItalicFont(screen) (!(screen)->colorITMode)
 1405 
 1406 #define ReverseOrHilite(screen,flags,hilite) \
 1407         (( screen->colorRVMode && hilite ) || \
 1408             ( !screen->colorRVMode && \
 1409               (( (flags & INVERSE) && !hilite) || \
 1410                (!(flags & INVERSE) &&  hilite)) ))
 1411 
 1412 #else   /* !OPT_ISO_COLORS */
 1413 
 1414 #define TERM_COLOR_FLAGS(xw) 0
 1415 
 1416 #define UseItalicFont(screen) True
 1417 #define ReverseOrHilite(screen,flags,hilite) \
 1418               (( (flags & INVERSE) && !hilite) || \
 1419                (!(flags & INVERSE) &&  hilite))
 1420 
 1421 #endif  /* OPT_ISO_COLORS */
 1422 
 1423 typedef enum {
 1424     XK_TCAPNAME = 3
 1425     /* Define fake XK codes, we need those for the fake color response in
 1426      * xtermcapKeycode().
 1427      */
 1428 #if OPT_ISO_COLORS
 1429     , XK_COLORS
 1430     , XK_RGB
 1431 #endif
 1432 } TcapQuery;
 1433 
 1434 #if OPT_AIX_COLORS
 1435 #define if_OPT_AIX_COLORS(screen, code) if(screen->colorMode) code
 1436 #else
 1437 #define if_OPT_AIX_COLORS(screen, code) /* nothing */
 1438 #endif
 1439 
 1440 #if OPT_256_COLORS || OPT_88_COLORS || OPT_ISO_COLORS
 1441 # define if_OPT_ISO_COLORS(screen, code) if (screen->colorMode) code
 1442 #else
 1443 # define if_OPT_ISO_COLORS(screen, code) /* nothing */
 1444 #endif
 1445 
 1446 #if OPT_DIRECT_COLOR
 1447 # define if_OPT_DIRECT_COLOR(screen, code) if (screen->direct_color) code
 1448 # define if_OPT_DIRECT_COLOR2(screen, test, code) if (screen->direct_color && (test)) code
 1449 #else
 1450 # define if_OPT_DIRECT_COLOR(screen, code) /* nothing */
 1451 # define if_OPT_DIRECT_COLOR2(screen, test, code) /* nothing */
 1452 #endif
 1453 
 1454 #define if_OPT_DIRECT_COLOR2_else(cond, test, stmt) \
 1455     if_OPT_DIRECT_COLOR2(cond, test, stmt else)
 1456 
 1457 #define COLOR_RES_NAME(root) "color" root
 1458 
 1459 #if OPT_COLOR_CLASS
 1460 #define COLOR_RES_CLASS(root) "Color" root
 1461 #else
 1462 #define COLOR_RES_CLASS(root) XtCForeground
 1463 #endif
 1464 
 1465 #if OPT_COLOR_RES
 1466 #define COLOR_RES(root,offset,value) Sres(COLOR_RES_NAME(root), COLOR_RES_CLASS(root), offset.resource, value)
 1467 #define COLOR_RES2(name,class,offset,value) Sres(name, class, offset.resource, value)
 1468 #else
 1469 #define COLOR_RES(root,offset,value) Cres(COLOR_RES_NAME(root), COLOR_RES_CLASS(root), offset, value)
 1470 #define COLOR_RES2(name,class,offset,value) Cres(name, class, offset, value)
 1471 #endif
 1472 
 1473 #define CLICK_RES_NAME(count)  "on" count "Clicks"
 1474 #define CLICK_RES_CLASS(count) "On" count "Clicks"
 1475 #define CLICK_RES(count,offset,value) Sres(CLICK_RES_NAME(count), CLICK_RES_CLASS(count), offset, value)
 1476 
 1477 /***====================================================================***/
 1478 
 1479 #if OPT_DEC_CHRSET
 1480 #define if_OPT_DEC_CHRSET(code) code
 1481     /* Use 2 bits for encoding the double high/wide sense of characters */
 1482 #define CSET_SWL        0
 1483 #define CSET_DHL_TOP    1
 1484 #define CSET_DHL_BOT    2
 1485 #define CSET_DWL        3
 1486 #define NUM_CHRSET      8   /* normal/bold and 4 CSET_xxx values */
 1487 
 1488     /* Use remaining bits for encoding the other character-sets */
 1489 #define CSET_NORMAL(code)  ((code) == CSET_SWL)
 1490 #define CSET_DOUBLE(code)  (!CSET_NORMAL(code) && !CSET_EXTEND(code))
 1491 #define CSET_EXTEND(code)  ((int)(code) > CSET_DWL)
 1492 
 1493 #define DBLCS_BITS            4
 1494 #define DBLCS_MASK            BITS2MASK(DBLCS_BITS)
 1495 
 1496 #define GetLineDblCS(ld)      (((ld)->bufHead >> LINEFLAG_BITS) & DBLCS_MASK)
 1497 #define SetLineDblCS(ld,cs)   (ld)->bufHead = (RowData) ((ld->bufHead & LINEFLAG_MASK) | (cs << LINEFLAG_BITS))
 1498 
 1499 #define LineCharSet(screen, ld) \
 1500     (unsigned) ((CSET_DOUBLE(GetLineDblCS(ld))) \
 1501             ? GetLineDblCS(ld) \
 1502             : (screen)->cur_chrset)
 1503 #define LineMaxCol(screen, ld) \
 1504     (CSET_DOUBLE(GetLineDblCS(ld)) \
 1505      ? (screen->max_col / 2) \
 1506      : (screen->max_col))
 1507 #define LineCursorX(screen, ld, col) \
 1508     (CSET_DOUBLE(GetLineDblCS(ld)) \
 1509      ? CursorX(screen, 2*(col)) \
 1510      : CursorX(screen, (col)))
 1511 #define LineFontWidth(screen, ld) \
 1512     (CSET_DOUBLE(GetLineDblCS(ld)) \
 1513      ? 2*FontWidth(screen) \
 1514      : FontWidth(screen))
 1515 #else
 1516 
 1517 #define if_OPT_DEC_CHRSET(code) /*nothing*/
 1518 #define CSET_SWL                        0
 1519 #define GetLineDblCS(ld)                0U
 1520 #define LineCharSet(screen, ld)         0U
 1521 #define LineMaxCol(screen, ld)          screen->max_col
 1522 #define LineCursorX(screen, ld, col)    CursorX(screen, col)
 1523 #define LineFontWidth(screen, ld)       FontWidth(screen)
 1524 
 1525 #endif
 1526 
 1527 #if OPT_LUIT_PROG && !OPT_WIDE_CHARS
 1528 /* Luit requires the wide-chars configuration */
 1529 #undef OPT_LUIT_PROG
 1530 #define OPT_LUIT_PROG 0
 1531 #endif
 1532 
 1533 /***====================================================================***/
 1534 
 1535 #if OPT_EBCDIC
 1536 extern int E2A(int);
 1537 extern int A2E(int);
 1538 #else
 1539 #define E2A(a) (a)
 1540 #define A2E(a) (a)
 1541 #endif
 1542 
 1543 #define CONTROL(a) (A2E(E2A(a)&037))
 1544 
 1545 /***====================================================================***/
 1546 
 1547 #if OPT_TEK4014
 1548 #define TEK4014_ACTIVE(xw)      ((xw)->misc.TekEmu)
 1549 #define TEK4014_SHOWN(xw)       ((xw)->misc.Tshow)
 1550 #define CURRENT_EMU_VAL(tek,vt) (TEK4014_ACTIVE(term) ? tek : vt)
 1551 #define CURRENT_EMU()           CURRENT_EMU_VAL((Widget)tekWidget, (Widget)term)
 1552 #else
 1553 #define TEK4014_ACTIVE(screen)  0
 1554 #define TEK4014_SHOWN(xw)       0
 1555 #define CURRENT_EMU_VAL(tek,vt) (vt)
 1556 #define CURRENT_EMU()           ((Widget)term)
 1557 #endif
 1558 
 1559 /***====================================================================***/
 1560 
 1561 #if OPT_TOOLBAR
 1562 #define SHELL_OF(widget) XtParent(XtParent(widget))
 1563 #else
 1564 #define SHELL_OF(widget) XtParent(widget)
 1565 #endif
 1566 
 1567 /***====================================================================***/
 1568 
 1569 #if OPT_VT52_MODE
 1570 #define if_OPT_VT52_MODE(screen, code) if(screen->vtXX_level == 0) code
 1571 #else
 1572 #define if_OPT_VT52_MODE(screen, code) /* nothing */
 1573 #endif
 1574 
 1575 /***====================================================================***/
 1576 
 1577 #if OPT_XMC_GLITCH
 1578 #define if_OPT_XMC_GLITCH(screen, code) if(screen->xmc_glitch) code
 1579 #define XMC_GLITCH 1    /* the character we'll show */
 1580 #define XMC_FLAGS (INVERSE|UNDERLINE|BOLD|BLINK)
 1581 #else
 1582 #define if_OPT_XMC_GLITCH(screen, code) /* nothing */
 1583 #endif
 1584 
 1585 /***====================================================================***/
 1586 
 1587 typedef unsigned IFlags;    /* at least 32 bits */
 1588 
 1589 #if OPT_WIDE_ATTRS
 1590 typedef unsigned short IAttr;   /* at least 16 bits */
 1591 #else
 1592 typedef unsigned char IAttr;    /* at least 8 bits */
 1593 #endif
 1594 
 1595 /***====================================================================***/
 1596 
 1597 #define LO_BYTE(ch) CharOf((ch) & 0xff)
 1598 #define HI_BYTE(ch) CharOf((ch) >> 8)
 1599 
 1600 #if OPT_WIDE_CHARS
 1601 #define if_OPT_WIDE_CHARS(screen, code) if(screen->wide_chars) code
 1602 #define if_WIDE_OR_NARROW(screen, wide, narrow) if(screen->wide_chars) wide else narrow
 1603 #define NARROW_ICHAR    0xffff
 1604 #if OPT_WIDER_ICHAR
 1605 #define WIDEST_ICHAR    0x1fffff
 1606 typedef unsigned IChar;     /* for 8-21 bit characters */
 1607 #else
 1608 #define WIDEST_ICHAR    NARROW_ICHAR
 1609 typedef unsigned short IChar;   /* for 8-16 bit characters */
 1610 #endif
 1611 #else
 1612 #define if_OPT_WIDE_CHARS(screen, code) /* nothing */
 1613 #define if_WIDE_OR_NARROW(screen, wide, narrow) narrow
 1614 typedef unsigned char IChar;    /* for 8-bit characters */
 1615 #endif
 1616 
 1617 /***====================================================================***/
 1618 
 1619 #ifndef RES_OFFSET
 1620 #define RES_OFFSET(offset) XtOffsetOf(XtermWidgetRec, offset)
 1621 #endif
 1622 
 1623 #define RES_NAME(name) name
 1624 #define RES_CLASS(name) name
 1625 
 1626 #define Bres(name, class, offset, dftvalue) \
 1627     {RES_NAME(name), RES_CLASS(class), XtRBoolean, sizeof(Boolean), \
 1628      RES_OFFSET(offset), XtRImmediate, (XtPointer) dftvalue}
 1629 
 1630 #define Cres(name, class, offset, dftvalue) \
 1631     {RES_NAME(name), RES_CLASS(class), XtRPixel, sizeof(Pixel), \
 1632      RES_OFFSET(offset), XtRString, DECONST(char,dftvalue)}
 1633 
 1634 #define Tres(name, class, offset, dftvalue) \
 1635     COLOR_RES2(name, class, screen.Tcolors[offset], dftvalue) \
 1636 
 1637 #define Fres(name, class, offset, dftvalue) \
 1638     {RES_NAME(name), RES_CLASS(class), XtRFontStruct, sizeof(XFontStruct *), \
 1639      RES_OFFSET(offset), XtRString, DECONST(char,dftvalue)}
 1640 
 1641 #define Ires(name, class, offset, dftvalue) \
 1642     {RES_NAME(name), RES_CLASS(class), XtRInt, sizeof(int), \
 1643      RES_OFFSET(offset), XtRImmediate, (XtPointer) dftvalue}
 1644 
 1645 #define Dres(name, class, offset, dftvalue) \
 1646     {RES_NAME(name), RES_CLASS(class), XtRFloat, sizeof(float), \
 1647      RES_OFFSET(offset), XtRString, DECONST(char,dftvalue)}
 1648 
 1649 #define Sres(name, class, offset, dftvalue) \
 1650     {RES_NAME(name), RES_CLASS(class), XtRString, sizeof(char *), \
 1651      RES_OFFSET(offset), XtRString, DECONST(char,dftvalue)}
 1652 
 1653 #define Wres(name, class, offset, dftvalue) \
 1654     {RES_NAME(name), RES_CLASS(class), XtRWidget, sizeof(Widget), \
 1655      RES_OFFSET(offset), XtRWidget, (XtPointer) dftvalue}
 1656 
 1657 /***====================================================================***/
 1658 
 1659 #define FRG_SIZE resource.minBufSize
 1660 #define BUF_SIZE resource.maxBufSize
 1661 
 1662 typedef struct {
 1663     Char    *next;
 1664     Char    *last;
 1665     int      update;    /* HandleInterpret */
 1666 #if OPT_WIDE_CHARS
 1667     IChar    utf_data;  /* resulting character */
 1668     int      utf_size;  /* ...number of bytes decoded */
 1669     Char    *write_buf;
 1670     unsigned write_len;
 1671 #endif
 1672     Char     buffer[1];
 1673 } PtyData;
 1674 
 1675 /***====================================================================***/
 1676 
 1677 /*
 1678  * Pixel (and its components) are declared as unsigned long, but even for RGB
 1679  * we need no more than 32-bits.
 1680  */
 1681 typedef uint32_t MyPixel;
 1682 typedef int32_t MyColor;
 1683 
 1684 #if OPT_ISO_COLORS
 1685 #if OPT_DIRECT_COLOR
 1686 typedef struct {
 1687     MyColor fg;
 1688     MyColor bg;
 1689 } CellColor;
 1690 
 1691 #define isSameCColor(p,q) (!memcmp(&(p), &(q), sizeof(CellColor)))
 1692 
 1693 #elif OPT_256_COLORS || OPT_88_COLORS
 1694 
 1695 #define COLOR_BITS 8
 1696 typedef unsigned short CellColor;
 1697 
 1698 #else
 1699 
 1700 #define COLOR_BITS 4
 1701 typedef Char CellColor;
 1702 
 1703 #endif
 1704 #else
 1705 typedef unsigned CellColor;
 1706 #endif
 1707 
 1708 #define NO_COLOR        ((unsigned)-1)
 1709 
 1710 #ifndef isSameCColor
 1711 #define isSameCColor(p,q)   ((p) == (q))
 1712 #endif
 1713 
 1714 #define BITS2MASK(b)        ((1 << b) - 1)
 1715 
 1716 #define COLOR_MASK      BITS2MASK(COLOR_BITS)
 1717 
 1718 #if OPT_DIRECT_COLOR
 1719 #define clrDirectFG(flags)  UIntClr(flags, ATR_DIRECT_FG)
 1720 #define clrDirectBG(flags)  UIntClr(flags, ATR_DIRECT_BG)
 1721 #define GetCellColorFG(data)    ((data).fg)
 1722 #define GetCellColorBG(data)    ((data).bg)
 1723 #define hasDirectFG(flags)  ((flags) & ATR_DIRECT_FG)
 1724 #define hasDirectBG(flags)  ((flags) & ATR_DIRECT_BG)
 1725 #define setDirectFG(flags,test) if (test) UIntSet(flags, ATR_DIRECT_FG); else UIntClr(flags, ATR_DIRECT_FG)
 1726 #define setDirectBG(flags,test) if (test) UIntSet(flags, ATR_DIRECT_BG); else UIntClr(flags, ATR_DIRECT_BG)
 1727 #elif OPT_ISO_COLORS
 1728 #define clrDirectFG(flags)  /* nothing */
 1729 #define clrDirectBG(flags)  /* nothing */
 1730 #define GetCellColorFG(data)    ((data) & COLOR_MASK)
 1731 #define GetCellColorBG(data)    (((data) >> COLOR_BITS) & COLOR_MASK)
 1732 #define hasDirectFG(flags)  0
 1733 #define hasDirectBG(flags)  0
 1734 #define setDirectFG(flags,test) (void)(test)
 1735 #define setDirectBG(flags,test) (void)(test)
 1736 #else
 1737 #define GetCellColorFG(data)    7
 1738 #define GetCellColorBG(data)    0
 1739 #endif
 1740 extern CellColor blank_cell_color;
 1741 
 1742 typedef Char RowData;       /* wrap/blink, and DEC single-double chars */
 1743 
 1744 #define LINEFLAG_BITS       4
 1745 #define LINEFLAG_MASK       BITS2MASK(LINEFLAG_BITS)
 1746 
 1747 #define GetLineFlags(ld)    ((ld)->bufHead & LINEFLAG_MASK)
 1748 
 1749 #if OPT_DEC_CHRSET
 1750 #define SetLineFlags(ld,xx) (ld)->bufHead = (RowData) ((ld->bufHead & (DBLCS_MASK << LINEFLAG_BITS)) | (xx & LINEFLAG_MASK))
 1751 #else
 1752 #define SetLineFlags(ld,xx) (ld)->bufHead = (RowData) (xx & LINEFLAG_MASK)
 1753 #endif
 1754 
 1755 typedef IChar CharData;
 1756 
 1757 /*
 1758  * This is the xterm line-data/scrollback structure.
 1759  */
 1760 typedef struct {
 1761     Dimension lineSize; /* number of columns in this row */
 1762     RowData bufHead;    /* flag for wrapped lines */
 1763 #if OPT_WIDE_CHARS
 1764     Char combSize;      /* number of items in combData[] */
 1765 #endif
 1766     IAttr *attribs;     /* video attributes */
 1767 #if OPT_ISO_COLORS
 1768     CellColor *color;   /* foreground+background color numbers */
 1769 #endif
 1770     CharData *charData; /* cell's base character */
 1771     CharData *combData[1];  /* first enum past fixed-offsets */
 1772 } LineData;
 1773 
 1774 typedef const LineData CLineData;
 1775 
 1776 /*
 1777  * We use CellData in a few places, when copying a cell's data to a temporary
 1778  * variable.
 1779  */
 1780 typedef struct {
 1781     IAttr attribs;
 1782 #if OPT_WIDE_CHARS
 1783     Char combSize;      /* number of items in combData[] */
 1784 #endif
 1785 #if OPT_ISO_COLORS
 1786     CellColor color;    /* color-array */
 1787 #endif
 1788     CharData charData;  /* cell's base character */
 1789     CharData combData[1];   /* array of combining chars */
 1790 } CellData;
 1791 
 1792 #define for_each_combData(off, ld) for (off = 0; off < ld->combSize; ++off)
 1793 
 1794 #define Clear1Cell(ld, x) \
 1795     do { \
 1796         ld->charData[x] = ' '; \
 1797         do { \
 1798         if_OPT_WIDE_CHARS(screen, { \
 1799         size_t z; \
 1800         for_each_combData(z, ld) { \
 1801             ld->combData[z][x] = '\0'; \
 1802         } \
 1803         }) } while (0); \
 1804     } while (0)
 1805 
 1806 #define Clear2Cell(dst, src, x) \
 1807     do { \
 1808         dst->charData[x] = ' '; \
 1809         dst->attribs[x] = src->attribs[x]; \
 1810         do { \
 1811         if_OPT_ISO_COLORS(screen, { \
 1812         dst->color[x] = src->color[x]; \
 1813         }) } while (0); \
 1814         do { \
 1815         if_OPT_WIDE_CHARS(screen, { \
 1816         size_t z; \
 1817         for_each_combData(z, dst) { \
 1818             dst->combData[z][x] = '\0'; \
 1819         } \
 1820         }) } while (0); \
 1821     } while (0)
 1822 
 1823 /*
 1824  * Accommodate older compilers by not using variable-length arrays.
 1825  */
 1826 #define SizeOfLineData  offsetof(LineData, combData)
 1827 #define SizeOfCellData  offsetof(CellData, combData)
 1828 
 1829     /*
 1830      * A "row" is the index within the visible part of the screen, and an
 1831      * "inx" is the index within the whole set of scrollable lines.
 1832      */
 1833 #define ROW2INX(screen, row)    ((row) + (screen)->topline)
 1834 #define INX2ROW(screen, inx)    ((inx) - (screen)->topline)
 1835 
 1836 /* these are unused but could be useful for debugging */
 1837 #if 0
 1838 #define ROW2ABS(screen, row)    ((row) + (screen)->savedlines)
 1839 #define INX2ABS(screen, inx)    ROW2ABS(screen, INX2ROW(screen, inx))
 1840 #endif
 1841 
 1842 #define okScrnRow(screen, row) \
 1843     ((row) <= ((screen)->max_row - (screen)->topline) \
 1844       && (row) >= -((screen)->savedlines))
 1845 
 1846     /*
 1847      * Cache data for "proportional" and other fonts containing a mixture
 1848      * of widths.
 1849      */
 1850 typedef struct {
 1851     Bool        mixed;
 1852     Dimension   min_width;  /* nominal cell width for 0..255 */
 1853     Dimension   max_width;  /* maximum cell width */
 1854 } FontMap;
 1855 
 1856 #define KNOWN_MISSING   256
 1857 
 1858 typedef enum {
 1859     fwNever = 0,
 1860     fwResource,
 1861     fwAlways
 1862 } fontWarningTypes;
 1863 
 1864 typedef struct {
 1865     unsigned    chrset;
 1866     unsigned    flags;
 1867     fontWarningTypes warn;
 1868     XFontStruct *   fs;
 1869     char *      fn;
 1870     FontMap     map;
 1871     Char        known_missing[KNOWN_MISSING];
 1872 } XTermFonts;
 1873 
 1874 #if OPT_RENDERFONT
 1875 typedef enum {
 1876     erFalse = 0
 1877     , erTrue
 1878     , erDefault
 1879     , erLast
 1880 } RenderFont;
 1881 
 1882 #define DefaultRenderFont(xw) \
 1883     if ((xw)->work.render_font == erDefault) \
 1884         (xw)->work.render_font = erFalse
 1885 
 1886 typedef enum {
 1887         xcEmpty = 0         /* slot is unused */
 1888     , xcBogus           /* ignore this pattern */
 1889     , xcOpened          /* slot has open font descriptor */
 1890     , xcUnused          /* opened, but unused so far */
 1891 } XftCache;
 1892 
 1893 typedef struct {
 1894     XftFont *   font;
 1895     XftCache    usage;
 1896 } XTermXftCache;
 1897 
 1898 typedef struct {
 1899     XftFont *   font;       /* main font */
 1900     XftPattern *    pattern;    /* pattern for main font */
 1901     XftFontSet *    fontset;    /* ordered list of fallback patterns */
 1902     XTermXftCache * cache;
 1903     unsigned    limit;      /* allocated size of cache[] */
 1904     unsigned    opened;     /* number of slots with xcOpened */
 1905     FontMap     map;
 1906 } XTermXftFonts;
 1907 
 1908 typedef struct _ListXftFonts {
 1909     struct _ListXftFonts *next;
 1910     XftFont *   font;
 1911 } ListXftFonts;
 1912 #endif
 1913 
 1914 typedef struct {
 1915     int     top;
 1916     int     left;
 1917     int     bottom;
 1918     int     right;
 1919 } XTermRect;
 1920 
 1921 /***====================================================================***/
 1922 
 1923     /* indices into save_modes[] */
 1924 typedef enum {
 1925     DP_ALLOW_ALTBUF,
 1926     DP_ALTERNATE_SCROLL,
 1927     DP_ALT_SENDS_ESC,
 1928     DP_BELL_IS_URGENT,
 1929     DP_CRS_VISIBLE,
 1930     DP_DECANM,
 1931     DP_DECARM,
 1932     DP_DECAWM,
 1933     DP_DECBKM,
 1934     DP_DECCKM,
 1935     DP_DECCOLM, /* IN132COLUMNS */
 1936     DP_DECKPAM,
 1937     DP_DECNRCM,
 1938     DP_DECOM,
 1939     DP_DECPEX,
 1940     DP_DECPFF,
 1941     DP_DECSCLM,
 1942     DP_DECSCNM,
 1943     DP_DECTCEM,
 1944     DP_DELETE_IS_DEL,
 1945     DP_EIGHT_BIT_META,
 1946     DP_KEEP_CLIPBOARD,
 1947     DP_KEEP_SELECTION,
 1948     DP_KEYBOARD_TYPE,
 1949     DP_POP_ON_BELL,
 1950     DP_PRN_EXTENT,
 1951     DP_PRN_FORMFEED,
 1952     DP_RXVT_SCROLLBAR,
 1953     DP_RXVT_SCROLL_TTY_KEYPRESS,
 1954     DP_RXVT_SCROLL_TTY_OUTPUT,
 1955     DP_SELECT_TO_CLIPBOARD,
 1956     DP_X_ALTBUF,
 1957     DP_X_DECCOLM,
 1958     DP_X_EXT_MOUSE,
 1959     DP_X_LOGGING,
 1960     DP_X_LRMM,
 1961     DP_X_MARGIN,
 1962     DP_X_MORE,
 1963     DP_X_MOUSE,
 1964     DP_X_NCSM,
 1965     DP_X_REVWRAP,
 1966     DP_X_X10MSE,
 1967 #if OPT_BLINK_CURS
 1968     DP_CRS_BLINK,
 1969 #endif
 1970 #if OPT_FOCUS_EVENT
 1971     DP_X_FOCUS,
 1972 #endif
 1973 #if OPT_NUM_LOCK
 1974     DP_REAL_NUMLOCK,
 1975     DP_META_SENDS_ESC,
 1976 #endif
 1977 #if OPT_SHIFT_FONTS
 1978     DP_RXVT_FONTSIZE,
 1979 #endif
 1980 #if OPT_SIXEL_GRAPHICS
 1981     DP_DECSDM,
 1982 #endif
 1983 #if OPT_TEK4014
 1984     DP_DECTEK,
 1985 #endif
 1986 #if OPT_TOOLBAR
 1987     DP_TOOLBAR,
 1988 #endif
 1989     DP_X_PRIVATE_COLOR_REGISTERS,
 1990 #if OPT_SIXEL_GRAPHICS
 1991     DP_SIXEL_SCROLLS_RIGHT,
 1992 #endif
 1993     DP_LAST
 1994 } SaveModes;
 1995 
 1996 #define DoSM(code,value)  screen->save_modes[code] = (unsigned) (value)
 1997 #define DoRM(code,value)  value = (Boolean) screen->save_modes[code]
 1998 #define DoRM0(code,value) value = screen->save_modes[code]
 1999 
 2000     /* index into vt_shell[] or tek_shell[] */
 2001 typedef enum {
 2002     noMenu = -1
 2003     ,mainMenu
 2004     ,vtMenu
 2005     ,fontMenu
 2006 #if OPT_TEK4014
 2007     ,tekMenu
 2008 #endif
 2009 } MenuIndex;
 2010 
 2011 typedef enum {
 2012     bvOff = -1,
 2013     bvLow = 0,
 2014     bvHigh
 2015 } BellVolume;
 2016 
 2017 #define NUM_POPUP_MENUS 4
 2018 
 2019 #if OPT_COLOR_RES
 2020 typedef struct {
 2021     String      resource;
 2022     Pixel       value;
 2023     unsigned short red, green, blue;
 2024     int     mode;       /* -1=invalid, 0=unset, 1=set   */
 2025 } ColorRes;
 2026 #else
 2027 #define ColorRes Pixel
 2028 #endif
 2029 
 2030 /* these are set in getPrinterFlags */
 2031 typedef struct {
 2032     int printer_extent;     /* print complete page      */
 2033     int printer_formfeed;   /* print formfeed per function  */
 2034     int printer_newline;    /* print newline per function   */
 2035     int print_attributes;   /* 0=off, 1=normal, 2=color */
 2036     int print_everything;   /* 0=all, 1=dft, 2=alt, 3=saved */
 2037 } PrinterFlags;
 2038 
 2039 typedef struct {
 2040     FILE *  fp;         /* output file/pipe used    */
 2041     Boolean isOpen;         /* output was opened/tried  */
 2042     Boolean toFile;         /* true when directly to file   */
 2043     Boolean printer_checked;    /* printer_command is checked   */
 2044     String  printer_command;    /* pipe/shell command string    */
 2045     Boolean printer_autoclose;  /* close printer when offline   */
 2046     Boolean printer_extent;     /* print complete page      */
 2047     Boolean printer_formfeed;   /* print formfeed per function  */
 2048     Boolean printer_newline;    /* print newline per function   */
 2049     int printer_controlmode;    /* 0=off, 1=auto, 2=controller  */
 2050     int print_attributes;   /* 0=off, 1=normal, 2=color */
 2051     int print_everything;   /* 0=all, 1=dft, 2=alt, 3=saved */
 2052 } PrinterState;
 2053 
 2054 typedef struct {
 2055     unsigned    which;      /* must have NCOLORS bits */
 2056     Pixel       colors[NCOLORS];
 2057     char        *names[NCOLORS];
 2058 } ScrnColors;
 2059 
 2060 #define NUM_GSETS 4
 2061 
 2062 typedef struct {
 2063     Boolean     saved;
 2064     int     row;
 2065     int     col;
 2066     IFlags      flags;      /* VTxxx saves graphics rendition */
 2067     Char        curgl;
 2068     Char        curgr;
 2069     DECNRCM_codes   gsets[NUM_GSETS];
 2070     Boolean     wrap_flag;
 2071 #if OPT_ISO_COLORS
 2072     int     cur_foreground;  /* current foreground color    */
 2073     int     cur_background;  /* current background color    */
 2074     int     sgr_foreground;  /* current SGR foreground color */
 2075     int     sgr_background;  /* current SGR background color */
 2076     Boolean     sgr_38_xcolors;  /* true if ISO 8613 extension  */
 2077 #endif
 2078 } SavedCursor;
 2079 
 2080 typedef struct _SaveTitle {
 2081     struct _SaveTitle *next;
 2082     char        *iconName;
 2083     char        *windowName;
 2084 } SaveTitle;
 2085 
 2086 #define SAVED_CURSORS 2
 2087 
 2088 typedef struct {
 2089     int     width;      /* if > 0, width of scrollbar,  */
 2090                     /* and scrollbar is showing */
 2091     Boolean     rv_cached;  /* see ScrollBarReverseVideo    */
 2092     int     rv_active;  /* ...current reverse-video */
 2093     Pixel       bg;     /* ...cached background color   */
 2094     Pixel       fg;     /* ...cached foreground color   */
 2095     Pixel       bdr;        /* ...cached border color   */
 2096     Pixmap      bdpix;      /* ...cached border pixmap  */
 2097 } SbInfo;
 2098 
 2099 #if OPT_TOOLBAR
 2100 typedef struct {
 2101     Widget      menu_bar;   /* toolbar, if initialized  */
 2102     Dimension   menu_height;    /* ...and its height        */
 2103     Dimension   menu_border;    /* ...and its border        */
 2104 } TbInfo;
 2105 #define VT100_TB_INFO(name) screen.fullVwin.tb_info.name
 2106 #endif
 2107 
 2108 typedef struct {
 2109     Window      window;     /* X window id          */
 2110     int     width;      /* width of columns     */
 2111     int     height;     /* height of rows       */
 2112     Dimension   fullwidth;  /* full width of window     */
 2113     Dimension   fullheight; /* full height of window    */
 2114     int     f_width;    /* width of fonts in pixels */
 2115     int     f_height;   /* height of fonts in pixels    */
 2116     int     f_ascent;   /* ascent of font in pixels */
 2117     int     f_descent;  /* descent of font in pixels    */
 2118     SbInfo      sb_info;
 2119     GC      filler_gc;  /* filler's fg/bg       */
 2120     GC      border_gc;  /* inner border's fg/bg     */
 2121 #if USE_DOUBLE_BUFFER
 2122     Drawable    drawable;   /* X drawable id                */
 2123 #endif
 2124 #if OPT_TOOLBAR
 2125     Boolean     active;     /* true if toolbars are used    */
 2126     TbInfo      tb_info;    /* toolbar information      */
 2127 #endif
 2128 } VTwin;
 2129 
 2130 typedef struct {
 2131     Window      window;     /* X window id          */
 2132     int     width;      /* width of columns     */
 2133     int     height;     /* height of rows       */
 2134     Dimension   fullwidth;  /* full width of window     */
 2135     Dimension   fullheight; /* full height of window    */
 2136     double      tekscale;   /* scale factor Tek -> vs100    */
 2137 } TKwin;
 2138 
 2139 typedef struct {
 2140     char *f_n;          /* the normal font */
 2141     char *f_b;          /* the bold font */
 2142 #if OPT_WIDE_CHARS
 2143     char *f_w;          /* the normal wide font */
 2144     char *f_wb;         /* the bold wide font */
 2145 #endif
 2146 } VTFontNames;
 2147 
 2148 typedef struct {
 2149     char **list_n;      /* the normal font */
 2150     char **list_b;      /* the bold font */
 2151 #if OPT_WIDE_ATTRS || OPT_RENDERWIDE
 2152     char **list_i;      /* italic font (Xft only) */
 2153     char **list_bi;     /* bold-italic font (Xft only) */
 2154 #endif
 2155 #if OPT_WIDE_CHARS
 2156     char **list_w;      /* the normal wide font */
 2157     char **list_wb;     /* the bold wide font */
 2158     char **list_wi;     /* wide italic font (Xft only) */
 2159     char **list_wbi;        /* wide bold-italic font (Xft only) */
 2160 #endif
 2161 } VTFontList;
 2162 
 2163 typedef struct {
 2164     VTFontList x11;
 2165 #if OPT_RENDERFONT
 2166     VTFontList xft;
 2167 #endif
 2168 } XtermFontNames;
 2169 
 2170 typedef struct {
 2171     VTFontNames default_font;
 2172     String menu_font_names[NMENUFONTS][fMAX];
 2173     XtermFontNames fonts;
 2174 } SubResourceRec;
 2175 
 2176 #if OPT_INPUT_METHOD
 2177 #define NINPUTWIDGETS   3
 2178 typedef struct {
 2179     Widget      w;
 2180     XIM     xim;        /* input method attached to 'w' */
 2181     XIC     xic;        /* input context attached to 'xim' */
 2182 } TInput;
 2183 #endif
 2184 
 2185 typedef enum {
 2186     CURSOR_BLOCK = 2
 2187     , CURSOR_UNDERLINE = 4
 2188     , CURSOR_BAR = 6
 2189 } XtCursorShape;
 2190 
 2191 #define isCursorBlock(s)    ((s)->cursor_shape == CURSOR_BLOCK)
 2192 #define isCursorUnderline(s)    ((s)->cursor_shape == CURSOR_UNDERLINE)
 2193 #define isCursorBar(s)      ((s)->cursor_shape == CURSOR_BAR)
 2194 
 2195 typedef enum {
 2196     DEFAULT_STYLE = 0
 2197     , BLINK_BLOCK
 2198     , STEADY_BLOCK
 2199     , BLINK_UNDERLINE
 2200     , STEADY_UNDERLINE
 2201     , BLINK_BAR
 2202     , STEADY_BAR
 2203 } XtCursorStyle;
 2204 
 2205 #if OPT_REGIS_GRAPHICS
 2206 #define optRegisGraphics(screen) \
 2207     ((screen)->terminal_id == 240 || \
 2208      (screen)->terminal_id == 241 || \
 2209      (screen)->terminal_id == 330 || \
 2210      (screen)->terminal_id == 340)
 2211 #else
 2212 #define optRegisGraphics(screen) False
 2213 #endif
 2214 
 2215 #if OPT_SIXEL_GRAPHICS
 2216 #define optSixelGraphics(screen) \
 2217     ((screen)->terminal_id == 240 || \
 2218      (screen)->terminal_id == 241 || \
 2219      (screen)->terminal_id == 330 || \
 2220      (screen)->terminal_id == 340 || \
 2221      (screen)->terminal_id == 382)
 2222 #else
 2223 #define optSixelGraphics(screen) False
 2224 #endif
 2225 
 2226 typedef struct {
 2227 /* These parameters apply to both windows */
 2228     Display     *display;   /* X display for screen     */
 2229     int     respond;    /* socket for responses
 2230                        (position report, etc.)  */
 2231     int     nextEventDelay; /* msecs to delay for x-events  */
 2232 /* These parameters apply to VT100 window */
 2233     IChar       *unparse_bfr;
 2234     unsigned    unparse_len;
 2235     unsigned    unparse_max;    /* limitResponse resource   */
 2236 
 2237 #if OPT_TCAP_QUERY
 2238     int     tc_query_code;
 2239     Bool        tc_query_fkey;
 2240 #endif
 2241     pid_t       pid;        /* pid of process on far side   */
 2242     uid_t       uid;        /* user id of actual person */
 2243     gid_t       gid;        /* group id of actual person    */
 2244     ColorRes    Tcolors[NCOLORS]; /* terminal colors        */
 2245 #if OPT_HIGHLIGHT_COLOR
 2246     Boolean     hilite_color;   /* hilite colors override   */
 2247     Boolean     hilite_reverse; /* hilite overrides reverse */
 2248 #endif
 2249 #if OPT_ISO_COLORS
 2250     XColor *    cmap_data;  /* color table          */
 2251     unsigned    cmap_size;
 2252     ColorRes    Acolors[MAXCOLORS]; /* ANSI color emulation */
 2253     int     veryBoldColors; /* modifier for boldColors  */
 2254     Boolean     boldColors; /* can we make bold colors? */
 2255     Boolean     colorMode;  /* are we using color mode? */
 2256     Boolean     colorULMode;    /* use color for underline? */
 2257     Boolean     italicULMode;   /* italic font for underline?   */
 2258     Boolean     colorBDMode;    /* use color for bold?      */
 2259     Boolean     colorBLMode;    /* use color for blink?     */
 2260     Boolean     colorRVMode;    /* use color for reverse?   */
 2261     Boolean     colorAttrMode;  /* prefer colorUL/BD to SGR */
 2262 #if OPT_WIDE_ATTRS
 2263     Boolean     colorITMode;    /* use color for italics?   */
 2264 #endif
 2265 #if OPT_DIRECT_COLOR
 2266     Boolean     direct_color;   /* direct-color enabled?    */
 2267 #endif
 2268 #endif /* OPT_ISO_COLORS */
 2269 #if OPT_DEC_CHRSET
 2270     Boolean     font_doublesize;/* enable font-scaling      */
 2271     int     cache_doublesize;/* limit of our cache      */
 2272     Char        cur_chrset; /* character-set index & code   */
 2273     int     fonts_used; /* count items in double_fonts  */
 2274     XTermFonts  double_fonts[NUM_CHRSET];
 2275 #if OPT_RENDERFONT
 2276     XftFont *   double_xft_fonts[NUM_CHRSET];
 2277 #endif
 2278 #endif /* OPT_DEC_CHRSET */
 2279 #if OPT_DEC_RECTOPS
 2280     int     cur_decsace;    /* parameter for DECSACE    */
 2281     int     checksum_ext;   /* extensions for DECRQCRA  */
 2282     int     checksum_ext0;  /* initial checksumExtension    */
 2283 #endif
 2284 #if OPT_WIDE_CHARS
 2285     Boolean     wide_chars; /* true when 16-bit chars   */
 2286     Boolean     vt100_graphics; /* true to allow vt100-graphics */
 2287     Boolean     utf8_inparse;   /* true to enable UTF-8 parser  */
 2288     Boolean     normalized_c;   /* true to precompose to Form C */
 2289     char *      utf8_mode_s;    /* use UTF-8 decode/encode  */
 2290     char *      utf8_fonts_s;   /* use UTF-8 decode/encode  */
 2291     char *      utf8_title_s;   /* use UTF-8 titles     */
 2292     int     utf8_nrc_mode;  /* saved UTF-8 mode for DECNRCM */
 2293     Boolean     utf8_always;    /* special case for wideChars   */
 2294     int     utf8_mode;  /* use UTF-8 decode/encode: 0-2 */
 2295     int     utf8_fonts; /* use UTF-8 fonts: 0-2     */
 2296     int     utf8_title; /* use UTF-8 EWHM props: 0-2    */
 2297     int     max_combining;  /* maximum # of combining chars */
 2298     Boolean     utf8_latin1;    /* use UTF-8 with Latin-1 bias  */
 2299     int     latin9_mode;    /* poor man's luit, latin9  */
 2300     int     unicode_font;   /* font uses unicode encoding   */
 2301     int     utf_count;  /* state of utf_char        */
 2302     IChar       utf_char;   /* in-progress character    */
 2303     Boolean     char_was_written;
 2304     int     last_written_col;
 2305     int     last_written_row;
 2306     TypedBuffer(XChar2b);
 2307     TypedBuffer(char);
 2308 #endif
 2309 #if OPT_BROKEN_OSC
 2310     Boolean     brokenLinuxOSC; /* true to ignore Linux palette ctls */
 2311 #endif
 2312 #if OPT_BROKEN_ST
 2313     Boolean     brokenStringTerm; /* true to match old OSC parse */
 2314 #endif
 2315 #if OPT_C1_PRINT || OPT_WIDE_CHARS
 2316     Boolean     c1_printable;   /* true if we treat C1 as print */
 2317 #endif
 2318     int     border;     /* inner border         */
 2319     int     scrollBarBorder; /* scrollBar border        */
 2320     long        event_mask;
 2321     unsigned    send_mouse_pos; /* user wants mouse transition  */
 2322                     /* and position information */
 2323     int     extend_coords;  /* support large terminals  */
 2324 #if OPT_FOCUS_EVENT
 2325     Boolean     send_focus_pos; /* user wants focus in/out info */
 2326 #endif
 2327     Boolean     quiet_grab; /* true if no cursor change on focus */
 2328 #if OPT_PASTE64
 2329     Cardinal    base64_paste;   /* set to send paste in base64  */
 2330     int     base64_final;   /* string-terminator for paste  */
 2331     /* _qWriteSelectionData expects these to be initialized to zero.
 2332      * base64_flush() is the last step of the conversion, it clears these
 2333      * variables.
 2334      */
 2335     unsigned    base64_accu;
 2336     unsigned    base64_count;
 2337     unsigned    base64_pad;
 2338 #endif
 2339 #if OPT_PASTE64 || OPT_READLINE
 2340     unsigned    paste_brackets;
 2341     /* not part of bracketed-paste, these are here to simplify ifdefs */
 2342     unsigned    dclick3_deletes;
 2343     unsigned    paste_literal_nl;
 2344 #endif
 2345 #if OPT_READLINE
 2346     unsigned    click1_moves;
 2347     unsigned    paste_moves;
 2348     unsigned    paste_quotes;
 2349 #endif  /* OPT_READLINE */
 2350 #if OPT_DEC_LOCATOR
 2351     Boolean     locator_reset;  /* turn mouse off after 1 report? */
 2352     Boolean     locator_pixels; /* report in pixels?        */
 2353                     /* if false, report in cells    */
 2354     unsigned    locator_events; /* what events to report    */
 2355     Boolean     loc_filter; /* is filter rectangle active?  */
 2356     int     loc_filter_top; /* filter rectangle for DEC Locator */
 2357     int     loc_filter_left;
 2358     int     loc_filter_bottom;
 2359     int     loc_filter_right;
 2360 #endif  /* OPT_DEC_LOCATOR */
 2361     int     mouse_button;   /* current button pressed   */
 2362     int     mouse_row;  /* ...and its row       */
 2363     int     mouse_col;  /* ...and its column        */
 2364     int     select;     /* xterm selected       */
 2365     Boolean     bellOnReset;    /* bellOnReset          */
 2366     Boolean     visualbell; /* visual bell mode     */
 2367     Boolean     poponbell;  /* pop on bell mode     */
 2368 
 2369     Boolean     eraseSavedLines; /* eraseSavedLines option  */
 2370     Boolean     eraseSavedLines0; /* initial eraseSavedLines    */
 2371     Boolean     tabCancelsWrap; /* tabCancelsWrap option    */
 2372 
 2373     Boolean     allowPasteControls; /* PasteControls mode   */
 2374     Boolean     allowColorOps;  /* ColorOps mode        */
 2375     Boolean     allowFontOps;   /* FontOps mode         */
 2376     Boolean     allowMouseOps;  /* MouseOps mode        */
 2377     Boolean     allowSendEvents;/* SendEvent mode       */
 2378     Boolean     allowTcapOps;   /* TcapOps mode         */
 2379     Boolean     allowTitleOps;  /* TitleOps mode        */
 2380     Boolean     allowWindowOps; /* WindowOps mode       */
 2381 
 2382     Boolean     allowPasteControl0; /* PasteControls mode   */
 2383     Boolean     allowColorOp0;  /* initial ColorOps mode    */
 2384     Boolean     allowFontOp0;   /* initial FontOps mode     */
 2385     Boolean     allowMouseOp0;  /* initial MouseOps mode    */
 2386     Boolean     allowSendEvent0;/* initial SendEvent mode   */
 2387     Boolean     allowTcapOp0;   /* initial TcapOps mode     */
 2388     Boolean     allowTitleOp0;  /* initial TitleOps mode    */
 2389     Boolean     allowWindowOp0; /* initial WindowOps mode   */
 2390 
 2391     String      disallowedColorOps;
 2392     char        disallow_color_ops[ecLAST];
 2393 
 2394     String      disallowedFontOps;
 2395     char        disallow_font_ops[efLAST];
 2396 
 2397     String      disallowedMouseOps;
 2398     char        disallow_mouse_ops[emLAST];
 2399 
 2400     String      disallowedPasteControls;
 2401     char        disallow_paste_controls[epLAST];
 2402 
 2403     String      disallowedTcapOps;
 2404     char        disallow_tcap_ops[etLAST];
 2405 
 2406     String      disallowedWinOps;
 2407     char        disallow_win_ops[ewLAST];
 2408 
 2409     Boolean     awaitInput; /* select-timeout mode      */
 2410     Boolean     grabbedKbd; /* keyboard is grabbed      */
 2411 #ifdef ALLOWLOGGING
 2412     int     logging;    /* logging mode         */
 2413     int     logfd;      /* file descriptor of log   */
 2414     char        *logfile;   /* log file name        */
 2415     Char        *logstart;  /* current start of log buffer  */
 2416 #endif
 2417     int     inhibit;    /* flags for inhibiting changes */
 2418 
 2419 /* VT window parameters */
 2420     Boolean     Vshow;      /* VT window showing        */
 2421     VTwin       fullVwin;
 2422     int     needSwap;
 2423 #ifndef NO_ACTIVE_ICON
 2424     VTwin       iconVwin;
 2425     VTwin       *whichVwin;
 2426 #endif /* NO_ACTIVE_ICON */
 2427 
 2428     int     pointer_mode;   /* when to use hidden_cursor    */
 2429     int     pointer_mode0;  /* ...initial value             */
 2430     Boolean     hide_pointer;   /* true to use "hidden_cursor"  */
 2431     Cursor      pointer_cursor; /* pointer cursor in window */
 2432     Cursor      hidden_cursor;  /* hidden cursor in window  */
 2433 
 2434     String  answer_back;        /* response to ENQ      */
 2435 
 2436     PrinterState    printer_state;  /* actual printer state     */
 2437     PrinterFlags    printer_flags;  /* working copy of printer flags */
 2438 #if OPT_PRINT_ON_EXIT
 2439     Boolean     write_error;
 2440 #endif
 2441 
 2442     Boolean     fnt_prop;   /* true if proportional fonts   */
 2443     unsigned    fnt_boxes;  /* 0=no boxes, 1=old, 2=unicode */
 2444     Boolean     force_packed;   /* true to override proportional */
 2445 #if OPT_BOX_CHARS
 2446     Boolean     force_box_chars;/* true if we assume no boxchars */
 2447     Boolean     broken_box_chars;/* true if broken boxchars */
 2448     Boolean     force_all_chars;/* true to outline missing chars */
 2449     Boolean     assume_all_chars;/* true to allow missing chars */
 2450     Boolean     allow_packing;  /* true to allow packed-fonts   */
 2451 #endif
 2452     Dimension   fnt_wide;
 2453     Dimension   fnt_high;
 2454     float       scale_height;   /* scaling for font-height  */
 2455     XTermFonts  fnts[fMAX]; /* normal/bold/etc for terminal */
 2456     Boolean     free_bold_box;  /* same_font_size's austerity   */
 2457     Boolean     allowBoldFonts; /* do we use bold fonts at all? */
 2458 #if OPT_WIDE_ATTRS
 2459     XTermFonts  ifnts[fMAX];    /* normal/bold/etc italic fonts */
 2460     Boolean     ifnts_ok;   /* true if ifnts[] is cached    */
 2461 #endif
 2462 #ifndef NO_ACTIVE_ICON
 2463     XTermFonts  fnt_icon;   /* icon font            */
 2464     String      icon_fontname;  /* name of icon font        */
 2465     int     icon_fontnum;   /* number to use for icon font  */
 2466 #endif /* NO_ACTIVE_ICON */
 2467     int     enbolden;   /* overstrike for bold font */
 2468     XPoint      *box;       /* draw unselected cursor   */
 2469 
 2470     int     cursor_state;   /* ON, OFF, or BLINKED_OFF  */
 2471     int     cursor_busy;    /* do not redraw...     */
 2472     Boolean     cursor_underline; /* true if cursor is in underline mode */
 2473     XtCursorShape   cursor_shape;
 2474 #if OPT_BLINK_CURS
 2475     BlinkOps    cursor_blink;   /* cursor blink enable      */
 2476     BlinkOps    cursor_blink_i; /* save cursor blink enable */
 2477     char *      cursor_blink_s; /* ...resource cursorBlink  */
 2478     int     cursor_blink_esc; /* cursor blink escape-state  */
 2479     Boolean     cursor_blink_xor; /* how to merge menu/escapes  */
 2480 #endif
 2481 #if OPT_BLINK_TEXT
 2482     Boolean     blink_as_bold;  /* text blink disable       */
 2483 #endif
 2484 #if OPT_BLINK_CURS || OPT_BLINK_TEXT
 2485     int     blink_state;    /* ON, OFF, or BLINKED_OFF  */
 2486     int     blink_on;   /* cursor on time (msecs)   */
 2487     int     blink_off;  /* cursor off time (msecs)  */
 2488     XtIntervalId    blink_timer;    /* timer-id for cursor-proc */
 2489 #endif
 2490 #if OPT_ZICONBEEP
 2491     Boolean     zIconBeep_flagged; /* True if icon name was changed */
 2492 #endif /* OPT_ZICONBEEP */
 2493     int     cursor_GC;  /* see ShowCursor()     */
 2494     int     cursor_set; /* requested state      */
 2495     CELL        cursorp;    /* previous cursor row/column   */
 2496     int     cur_col;    /* current cursor column    */
 2497     int     cur_row;    /* current cursor row       */
 2498     int     max_col;    /* rightmost column     */
 2499     int     max_row;    /* bottom row           */
 2500     int     top_marg;   /* top line of scrolling region */
 2501     int     bot_marg;   /* bottom line of  "        "   */
 2502     int     lft_marg;   /* left column of "     "   */
 2503     int     rgt_marg;   /* right column of "        "   */
 2504     Widget      scrollWidget;   /* pointer to scrollbar struct  */
 2505 #if USE_DOUBLE_BUFFER
 2506     int     buffered_sb;    /* nonzero when pending update  */
 2507     struct timeval  buffered_at;    /* reference time, for FPS  */
 2508 #define DbeMsecs(xw)    (1000L / (long) resource.buffered_fps)
 2509 #endif
 2510     /*
 2511      * Indices used to keep track of the top of the vt100 window and
 2512      * the saved lines, taking scrolling into account.
 2513      */
 2514     int     topline;    /* line number of top, <= 0 */
 2515     long        saved_fifo;     /* number of lines that've ever been saved */
 2516     int     savedlines;     /* number of lines that've been saved */
 2517     int     savelines;  /* number of lines off top to save */
 2518     int     scroll_amt; /* amount to scroll     */
 2519     int     refresh_amt;    /* amount to refresh        */
 2520     /*
 2521      * Working variables for getLineData().
 2522      */
 2523     size_t      lineExtra;  /* extra space for combining chars */
 2524     size_t      cellExtra;  /* extra space for combining chars */
 2525     /*
 2526      * Pointer to the current visible buffer.
 2527      */
 2528     ScrnBuf     visbuf;     /* ptr to visible screen buf (main) */
 2529     /*
 2530      * Data for the normal buffer, which may have saved lines to which
 2531      * the user can scroll.
 2532      */
 2533     ScrnBuf     saveBuf_index;
 2534     Char        *saveBuf_data;
 2535     /*
 2536      * Data for visible and alternate buffer.
 2537      */
 2538     ScrnBuf     editBuf_index[2];
 2539     Char        *editBuf_data[2];
 2540     int     whichBuf;   /* 0/1 for normal/alternate buf */
 2541     Boolean     is_running; /* true when buffers are legal  */
 2542     /*
 2543      * Workspace used for screen operations.
 2544      */
 2545     Char        **save_ptr; /* workspace for save-pointers  */
 2546     size_t      save_len;   /* ...and its length        */
 2547 
 2548     int     scrolllines;    /* number of lines to button scroll */
 2549     Boolean     alternateScroll; /* scroll-actions become keys */
 2550     Boolean     scrollttyoutput; /* scroll to bottom on tty output */
 2551     Boolean     scrollkey;  /* scroll to bottom on key  */
 2552     Boolean     cursor_moved;   /* scrolling makes cursor move  */
 2553 
 2554     Boolean     do_wrap;    /* true if cursor in last column
 2555                         and character just output    */
 2556 
 2557     int     incopy;     /* 0 idle; 1 XCopyArea issued;
 2558                         -1 first GraphicsExpose seen,
 2559                         but last not seen       */
 2560     int     copy_src_x; /* params from last XCopyArea ... */
 2561     int     copy_src_y;
 2562     unsigned int    copy_width;
 2563     unsigned int    copy_height;
 2564     int     copy_dest_x;
 2565     int     copy_dest_y;
 2566 
 2567     Dimension   embed_wide;
 2568     Dimension   embed_high;
 2569 
 2570     Boolean     c132;       /* allow change to 132 columns  */
 2571     Boolean     curses;     /* kludge line wrap for more    */
 2572     Boolean     hp_ll_bc;   /* kludge HP-style ll for xdb   */
 2573     Boolean     marginbell; /* true if margin bell on   */
 2574     int     nmarginbell;    /* columns from right margin    */
 2575     int     bellArmed;  /* cursor below bell margin */
 2576     BellVolume  marginVolume;   /* margin-bell volume           */
 2577     BellVolume  warningVolume;  /* warning-bell volume          */
 2578     Boolean     multiscroll;    /* true if multi-scroll     */
 2579     int     scrolls;    /* outstanding scroll count,
 2580                         used only with multiscroll  */
 2581     SavedCursor sc[SAVED_CURSORS]; /* data for restore cursor   */
 2582     IFlags      save_modes[DP_LAST]; /* save dec/xterm private modes */
 2583 
 2584     int     title_modes;    /* control set/get of titles    */
 2585     int     title_modes0;   /* ...initial value             */
 2586     SaveTitle   *save_title;
 2587 
 2588     /* Improved VT100 emulation stuff.              */
 2589     String      keyboard_dialect; /* default keyboard dialect   */
 2590     DECNRCM_codes   gsets[NUM_GSETS]; /* G0 through G3.     */
 2591     Char        curgl;      /* Current GL setting.      */
 2592     Char        curgr;      /* Current GR setting.      */
 2593     Char        curss;      /* Current single shift.    */
 2594     String      term_id;    /* resource for terminal_id */
 2595     int     terminal_id;    /* 100=vt100, 220=vt220, etc.   */
 2596     int     vtXX_level; /* 0=vt52, 1,2,3 = vt100 ... vt320 */
 2597     int     ansi_level; /* dpANSI levels 1,2,3      */
 2598     int     protected_mode; /* 0=off, 1=DEC, 2=ISO      */
 2599     Boolean     always_bold_mode; /* compare normal/bold font   */
 2600     Boolean     always_highlight; /* whether to highlight cursor */
 2601     Boolean     bold_mode;  /* use bold font or overstrike  */
 2602     Boolean     delete_is_del;  /* true for compatible Delete key */
 2603     Boolean     jumpscroll; /* whether we should jumpscroll */
 2604     Boolean     fastscroll; /* whether we should fastscroll */
 2605     Boolean     old_fkeys;  /* true for compatible fkeys    */
 2606     Boolean     old_fkeys0; /* ...initial value             */
 2607     Boolean     underline;  /* whether to underline text    */
 2608 
 2609 #if OPT_MAXIMIZE
 2610     Boolean     restore_data;
 2611     int     restore_x;
 2612     int     restore_y;
 2613     unsigned    restore_width;
 2614     unsigned    restore_height;
 2615 #endif
 2616 
 2617 #if OPT_REGIS_GRAPHICS
 2618     String      graphics_regis_default_font; /* font for "builtin" */
 2619 
 2620     String      graphics_regis_screensize; /* given a size in pixels */
 2621     Dimension   graphics_regis_def_wide; /* ...corresponding width   */
 2622     Dimension   graphics_regis_def_high; /* ...and height            */
 2623 #endif
 2624 
 2625 #if OPT_GRAPHICS
 2626     String      graphics_max_size;  /* given a size in pixels */
 2627     Dimension   graphics_max_wide;  /* ...corresponding width */
 2628     Dimension   graphics_max_high;  /* ...and height          */
 2629 #endif
 2630 
 2631 #if OPT_SCROLL_LOCK
 2632     Boolean     allowScrollLock;/* ScrollLock mode      */
 2633     Boolean     allowScrollLock0;/* initial ScrollLock mode */
 2634     Boolean     scroll_lock;    /* true to keep buffer in view  */
 2635     Boolean     scroll_dirty;   /* scrolling makes screen dirty */
 2636 #endif
 2637 
 2638 #if OPT_SIXEL_GRAPHICS
 2639     Boolean     sixel_scrolling; /* sixel scrolling             */
 2640     Boolean     sixel_scrolls_right; /* sixel scrolling moves cursor to right */
 2641 #endif
 2642 
 2643 #if OPT_GRAPHICS
 2644     int     numcolorregisters; /* number of supported color registers */
 2645     Boolean     privatecolorregisters; /* private color registers for each graphic */
 2646 #endif
 2647 
 2648 #if OPT_VT52_MODE
 2649     IFlags      vt52_save_flags;
 2650     Char        vt52_save_curgl;
 2651     Char        vt52_save_curgr;
 2652     Char        vt52_save_curss;
 2653     DECNRCM_codes   vt52_save_gsets[NUM_GSETS];
 2654 #endif
 2655     /* Testing */
 2656 #if OPT_XMC_GLITCH
 2657     unsigned    xmc_glitch; /* # of spaces to pad on SGR's  */
 2658     IAttr       xmc_attributes; /* attrs that make a glitch */
 2659     Boolean     xmc_inline; /* SGR's propagate only to eol  */
 2660     Boolean     move_sgr_ok;    /* SGR is reset on move     */
 2661 #endif
 2662 
 2663     /*
 2664      * Bell
 2665      */
 2666     int     visualBellDelay; /* msecs to delay for visibleBell */
 2667     int     bellSuppressTime; /* msecs after Bell before another allowed */
 2668     Boolean     bellInProgress; /* still ringing/flashing prev bell? */
 2669     Boolean     bellIsUrgent;   /* set XUrgency WM hint on bell */
 2670     Boolean     flash_line; /* show visualBell as current line */
 2671     /*
 2672      * Select/paste state.
 2673      */
 2674     Boolean     selectToClipboard; /* primary vs clipboard */
 2675     String      *mappedSelect;  /* mapping for "SELECT" to "PRIMARY" */
 2676 
 2677     Boolean     waitingForTrackInfo;
 2678     int     numberOfClicks;
 2679     int     maxClicks;
 2680     int     multiClickTime; /* time between multiclick selects */
 2681     SelectUnit  selectUnit;
 2682     SelectUnit  selectMap[NSELECTUNITS];
 2683     String      onClick[NSELECTUNITS + 1];
 2684 
 2685     char        *charClass; /* for overriding word selection */
 2686     Boolean     cutNewline; /* whether or not line cut has \n */
 2687     Boolean     cutToBeginningOfLine;  /* line cuts to BOL? */
 2688     Boolean     highlight_selection; /* controls appearance of selection */
 2689     Boolean     show_wrap_marks; /* show lines which are wrapped */
 2690     Boolean     trim_selection; /* controls trimming of selection */
 2691     Boolean     i18nSelections;
 2692     Boolean     brokenSelections;
 2693     Boolean     keepClipboard;  /* retain data sent to clipboard */
 2694     Boolean     keepSelection;  /* do not lose selection on output */
 2695     Boolean     replyToEmacs;   /* Send emacs escape code when done selecting or extending? */
 2696 
 2697     SelectedCells   clipboard_data; /* what we sent to the clipboard */
 2698 
 2699     EventMode   eventMode;
 2700     Time        selection_time; /* latest event timestamp */
 2701     Time        lastButtonUpTime;
 2702     unsigned    lastButton;
 2703 
 2704 #define MAX_CUT_BUFFER  8       /* CUT_BUFFER0 to CUT_BUFFER7 */
 2705 #define MAX_SELECTIONS  (MAX_SELECTION_CODES + MAX_CUT_BUFFER)
 2706     SelectedCells   selected_cells[MAX_SELECTIONS];
 2707 
 2708     CELL        rawPos;     /* raw position for selection start */
 2709     CELL        startRaw;   /* area before selectUnit processing */
 2710     CELL        endRaw;     /* " " */
 2711     CELL        startSel;   /* area after selectUnit processing */
 2712     CELL        endSel;     /* " " */
 2713     CELL        startH;     /* start highlighted text */
 2714     CELL        endH;       /* end highlighted text */
 2715     CELL        saveStartW; /* saved WORD state, for LINE */
 2716     CELL        startExt;   /* Start, end of extension */
 2717     CELL        endExt;     /* " " */
 2718     CELL        saveStartR; /* Saved values of raw selection for extend to restore to */
 2719     CELL        saveEndR;   /* " " */
 2720     int     startHCoord, endHCoord;
 2721     int     firstValidRow;  /* Valid rows for selection clipping */
 2722     int     lastValidRow;   /* " " */
 2723 
 2724     Boolean     selectToBuffer; /* copy selection to buffer */
 2725     InternalSelect  internal_select;
 2726 
 2727     String      default_string;
 2728     String      eightbit_select_types;
 2729     Atom*       selection_targets_8bit;
 2730 #if OPT_WIDE_CHARS
 2731     String      utf8_select_types;
 2732     Atom*       selection_targets_utf8;
 2733 #endif
 2734     Atom*       selection_atoms; /* which selections we own */
 2735     Cardinal    sel_atoms_size;  /* how many atoms allocated */
 2736     Cardinal    selection_count; /* how many atoms in use */
 2737 #if OPT_SELECT_REGEX
 2738     char *      selectExpr[NSELECTUNITS];
 2739 #endif
 2740     /*
 2741      * Input/output state.
 2742      */
 2743     Boolean     input_eight_bits;   /* do not send ESC when meta pressed */
 2744     int     eight_bit_meta;     /* use 8th bit when meta pressed */
 2745     char *      eight_bit_meta_s;   /* ...resource eightBitMeta */
 2746     Boolean     output_eight_bits;  /* honor all bits or strip */
 2747     Boolean     control_eight_bits; /* send CSI as 8-bits */
 2748     Boolean     backarrow_key;      /* backspace/delete */
 2749     Boolean     alt_is_not_meta;    /* use both Alt- and Meta-key */
 2750     Boolean     alt_sends_esc;      /* Alt-key sends ESC prefix */
 2751     Boolean     meta_sends_esc;     /* Meta-key sends ESC prefix */
 2752     /*
 2753      * Fonts
 2754      */
 2755     Pixmap      menu_item_bitmap;   /* mask for checking items */
 2756     String      initial_font;
 2757     char *      menu_font_names[NMENUFONTS][fMAX];
 2758 #define MenuFontName(n) menu_font_names[n][fNorm]
 2759 #define EscapeFontName() MenuFontName(fontMenu_fontescape)
 2760 #define SelectFontName() MenuFontName(fontMenu_fontsel)
 2761     long        menu_font_sizes[NMENUFONTS];
 2762     int     menu_font_number;
 2763 #if OPT_LOAD_VTFONTS || OPT_WIDE_CHARS
 2764     Boolean     savedVTFonts;
 2765     Boolean     mergedVTFonts;
 2766     SubResourceRec  cacheVTFonts;
 2767 #endif
 2768 #if OPT_CLIP_BOLD
 2769     Boolean     use_border_clipping;
 2770     Boolean     use_clipping;
 2771 #endif
 2772     void *      main_cgs_cache;
 2773 #ifndef NO_ACTIVE_ICON
 2774     void *      icon_cgs_cache;
 2775 #endif
 2776 #if OPT_RENDERFONT
 2777     Boolean     force_xft_height;
 2778     ListXftFonts    *list_xft_fonts;
 2779     XTermXftFonts   renderFontNorm[NMENUFONTS];
 2780     XTermXftFonts   renderFontBold[NMENUFONTS];
 2781     XTermXftFonts   renderFontItal[NMENUFONTS];
 2782     XTermXftFonts   renderFontBtal[NMENUFONTS];
 2783 #if OPT_RENDERWIDE
 2784     XTermXftFonts   renderWideNorm[NMENUFONTS];
 2785     XTermXftFonts   renderWideBold[NMENUFONTS];
 2786     XTermXftFonts   renderWideItal[NMENUFONTS];
 2787     XTermXftFonts   renderWideBtal[NMENUFONTS];
 2788     TypedBuffer(XftCharSpec);
 2789 #else
 2790     TypedBuffer(XftChar8);
 2791 #endif
 2792     XftDraw *   renderDraw;
 2793 #endif
 2794 #if OPT_DABBREV
 2795     Boolean     dabbrev_working;    /* nonzero during dabbrev process */
 2796     unsigned char   dabbrev_erase_char; /* used for deleting inserted completion */
 2797 #endif
 2798     char        tcapbuf[TERMCAP_SIZE];
 2799     char        tcap_area[TERMCAP_SIZE];
 2800 #if OPT_TCAP_FKEYS
 2801     char **     tcap_fkeys;
 2802 #endif
 2803 } TScreen;
 2804 
 2805 typedef XTermFonts *(*MyGetFont) (TScreen *, int);
 2806 
 2807 typedef struct _TekPart {
 2808     XFontStruct *   Tfont[TEKNUMFONTS];
 2809     int     tobaseline[TEKNUMFONTS]; /* top-baseline, each font */
 2810     char *      initial_font;       /* large, 2, 3, small */
 2811     char *      gin_terminator_str; /* ginTerminator resource */
 2812 #if OPT_TOOLBAR
 2813     TbInfo      tb_info;    /* toolbar information      */
 2814 #endif
 2815 } TekPart;
 2816 
 2817 /* Tektronix window parameters */
 2818 typedef struct _TekScreen {
 2819     GC      TnormalGC;  /* normal painting      */
 2820     GC      TcursorGC;  /* normal cursor painting   */
 2821 
 2822     Boolean     waitrefresh;    /* postpone refresh     */
 2823     TKwin       fullTwin;
 2824 #ifndef NO_ACTIVE_ICON
 2825     TKwin       iconTwin;
 2826     TKwin       *whichTwin;
 2827 #endif /* NO_ACTIVE_ICON */
 2828 
 2829     Cursor      arrow;      /* arrow cursor         */
 2830     GC      linepat[TEKNUMLINES]; /* line patterns      */
 2831     int     cur_X;      /* current x            */
 2832     int     cur_Y;      /* current y            */
 2833     Tmodes      cur;        /* current tek modes        */
 2834     Tmodes      page;       /* starting tek modes on page   */
 2835     int     margin;     /* 0 -> margin 1, 1 -> margin 2 */
 2836     int     pen;        /* current Tektronix pen 0=up, 1=dn */
 2837     char        *TekGIN;    /* nonzero if Tektronix GIN mode*/
 2838     int     gin_terminator; /* Tek strap option */
 2839     char        tcapbuf[TERMCAP_SIZE];
 2840 } TekScreen;
 2841 
 2842 #if OPT_PASTE64 || OPT_READLINE
 2843 #define SCREEN_FLAG(screenp,f)      (1&(screenp)->f)
 2844 #define SCREEN_FLAG_set(screenp,f)  ((screenp)->f |= 1)
 2845 #define SCREEN_FLAG_unset(screenp,f)    ((screenp)->f &= (unsigned) ~1L)
 2846 #define SCREEN_FLAG_save(screenp,f) \
 2847     ((screenp)->f = (((screenp)->f)<<1) | SCREEN_FLAG(screenp,f))
 2848 #define SCREEN_FLAG_restore(screenp,f)  ((screenp)->f = (((screenp)->f)>>1))
 2849 #else
 2850 #define SCREEN_FLAG(screenp,f)      (0)
 2851 #endif
 2852 
 2853 /*
 2854  * After screen-updates, reset the flag that tells us we should do wrapping.
 2855  * Likewise, reset (in wide-character mode) the flag that tells us where the
 2856  * "previous" character was written.
 2857  */
 2858 #if OPT_WIDE_CHARS
 2859 #define ResetWrap(screen) \
 2860     (screen)->do_wrap = \
 2861     (screen)->char_was_written = False
 2862 #else
 2863 #define ResetWrap(screen) \
 2864     (screen)->do_wrap = False
 2865 #endif
 2866 
 2867 /* meaning of bits in screen.select flag */
 2868 #define INWINDOW    01  /* the mouse is in one of the windows */
 2869 #define FOCUS       02  /* one of the windows is the focus window */
 2870 
 2871 #define MULTICLICKTIME 250  /* milliseconds */
 2872 
 2873 typedef struct {
 2874     const char *name;
 2875     int code;
 2876 } FlagList;
 2877 
 2878 typedef enum {
 2879     keyboardIsLegacy,       /* bogus vt220 codes for F1-F4, etc. */
 2880     keyboardIsDefault,
 2881     keyboardIsHP,
 2882     keyboardIsSCO,
 2883     keyboardIsSun,
 2884     keyboardIsTermcap,
 2885     keyboardIsVT220
 2886 } xtermKeyboardType;
 2887 
 2888 typedef enum {          /* legal values for screen.pointer_mode */
 2889     pNever = 0
 2890     , pNoMouse = 1
 2891     , pAlways = 2
 2892     , pFocused = 3
 2893 } pointerModeTypes;
 2894 
 2895 typedef enum {          /* legal values for screen.utf8_mode */
 2896     uFalse = 0
 2897     , uTrue = 1
 2898     , uAlways = 2
 2899     , uDefault = 3
 2900     , uLast
 2901 } utf8ModeTypes;
 2902 
 2903 typedef enum {          /* legal values for screen.eight_bit_meta */
 2904     ebFalse = 0
 2905     , ebTrue = 1
 2906     , ebNever = 2
 2907     , ebLocale = 3
 2908     , ebLast
 2909 } ebMetaModeTypes;
 2910 
 2911 #define NAME_OLD_KT " legacy"
 2912 
 2913 #if OPT_HP_FUNC_KEYS
 2914 #define NAME_HP_KT " hp"
 2915 #else
 2916 #define NAME_HP_KT /*nothing*/
 2917 #endif
 2918 
 2919 #if OPT_SCO_FUNC_KEYS
 2920 #define NAME_SCO_KT " sco"
 2921 #else
 2922 #define NAME_SCO_KT /*nothing*/
 2923 #endif
 2924 
 2925 #if OPT_SUN_FUNC_KEYS
 2926 #define NAME_SUN_KT " sun"
 2927 #else
 2928 #define NAME_SUN_KT /*nothing*/
 2929 #endif
 2930 
 2931 #if OPT_SUNPC_KBD
 2932 #define NAME_VT220_KT " vt220"
 2933 #else
 2934 #define NAME_VT220_KT /*nothing*/
 2935 #endif
 2936 
 2937 #if OPT_TCAP_FKEYS
 2938 #define NAME_TCAP_KT " tcap"
 2939 #else
 2940 #define NAME_TCAP_KT /*nothing*/
 2941 #endif
 2942 
 2943 #define KEYBOARD_TYPES NAME_TCAP_KT NAME_HP_KT NAME_SCO_KT NAME_SUN_KT NAME_VT220_KT
 2944 
 2945 #if OPT_TRACE
 2946 #define TRACE_RC(code,func) code = func
 2947 #else
 2948 #define TRACE_RC(code,func) func
 2949 #endif
 2950 
 2951 extern  const char * visibleKeyboardType(xtermKeyboardType);
 2952 
 2953 typedef struct
 2954 {
 2955     int allow_keys;     /* how to handle legacy/vt220 keyboard */
 2956     int cursor_keys;        /* how to handle cursor-key modifiers */
 2957     int function_keys;      /* how to handle function-key modifiers */
 2958     int keypad_keys;        /* how to handle keypad key-modifiers */
 2959     int other_keys;     /* how to handle other key-modifiers */
 2960     int string_keys;        /* how to handle string() modifiers */
 2961 } TModify;
 2962 
 2963 typedef struct
 2964 {
 2965     xtermKeyboardType type;
 2966     IFlags flags;
 2967     char *shell_translations;
 2968     char *xterm_translations;
 2969     char *extra_translations;
 2970 #if OPT_INITIAL_ERASE
 2971     int reset_DECBKM;       /* reset should set DECBKM */
 2972 #endif
 2973 #if OPT_MOD_FKEYS
 2974     TModify modify_now;     /* current modifier value */
 2975     TModify modify_1st;     /* original modifier value, for resets */
 2976     int format_keys;        /* format of modifyOtherKeys */
 2977 #endif
 2978 } TKeyboard;
 2979 
 2980 #define GravityIsNorthWest(w) ((w)->misc.resizeGravity == NorthWestGravity)
 2981 #define GravityIsSouthWest(w) ((w)->misc.resizeGravity == SouthWestGravity)
 2982 
 2983 typedef struct _Misc {
 2984     VTFontNames default_font;
 2985     char *geo_metry;
 2986     char *T_geometry;
 2987 #if OPT_WIDE_CHARS
 2988     Boolean cjk_width;      /* true for built-in CJK wcwidth() */
 2989     Boolean mk_width;       /* true for simpler built-in wcwidth() */
 2990     int mk_samplesize;
 2991     int mk_samplepass;
 2992 #endif
 2993 #if OPT_LUIT_PROG
 2994     Boolean callfilter;     /* true to invoke luit */
 2995     Boolean use_encoding;   /* true to use -encoding option for luit */
 2996     char *locale_str;       /* "locale" resource */
 2997     char *localefilter;     /* path for luit */
 2998 #endif
 2999     fontWarningTypes fontWarnings;
 3000     int limit_resize;
 3001 #ifdef ALLOWLOGGING
 3002     Boolean log_on;
 3003 #endif
 3004     Boolean color_inner_border;
 3005     Boolean login_shell;
 3006     Boolean re_verse;
 3007     Boolean re_verse0;      /* initial value of "-rv" */
 3008     XtGravity resizeGravity;
 3009     Boolean reverseWrap;
 3010     Boolean autoWrap;
 3011     Boolean logInhibit;
 3012     Boolean signalInhibit;
 3013 #if OPT_TEK4014
 3014     Boolean tekInhibit;
 3015     Boolean tekSmall;       /* start tek window in small size */
 3016     Boolean TekEmu;     /* true if Tektronix emulation  */
 3017     Boolean Tshow;      /* Tek window showing       */
 3018 #endif
 3019     Boolean scrollbar;
 3020 #ifdef SCROLLBAR_RIGHT
 3021     Boolean useRight;
 3022 #endif
 3023     Boolean titeInhibit;
 3024     Boolean tiXtraScroll;   /* scroll on ti/te */
 3025     Boolean cdXtraScroll;   /* scroll on cd (clear-display) */
 3026     Boolean appcursorDefault;
 3027     Boolean appkeypadDefault;
 3028 #if OPT_INPUT_METHOD
 3029     char* f_x;          /* font for XIM */
 3030     char* input_method;
 3031     char* preedit_type;
 3032     Boolean open_im;        /* true if input-method is opened */
 3033     int retry_im;
 3034 #endif
 3035     Boolean dynamicColors;
 3036 #ifndef NO_ACTIVE_ICON
 3037     char *active_icon_s;    /* use application icon window  */
 3038     unsigned icon_border_width;
 3039     Pixel icon_border_pixel;
 3040 #endif /* NO_ACTIVE_ICON */
 3041 #if OPT_DEC_SOFTFONT
 3042     Boolean font_loadable;
 3043 #endif
 3044 #if OPT_SHIFT_FONTS
 3045     Boolean shift_fonts;    /* true if we interpret fontsize-shifting */
 3046 #endif
 3047 #if OPT_SUNPC_KBD
 3048     int ctrl_fkeys;     /* amount to add to XK_F1 for ctrl modifier */
 3049 #endif
 3050 #if OPT_NUM_LOCK
 3051     Boolean real_NumLock;   /* true if we treat NumLock key specially */
 3052     Boolean alwaysUseMods;  /* true if we always want f-key modifiers */
 3053 #endif
 3054 #if OPT_RENDERFONT
 3055     VTFontNames default_xft;
 3056     float face_size[NMENUFONTS];
 3057     char *render_font_s;
 3058     int limit_fontsets;
 3059 #endif
 3060 } Misc;
 3061 
 3062 typedef struct _Work {
 3063     int dummy;
 3064 #ifdef SunXK_F36
 3065 #define MAX_UDK 37
 3066 #else
 3067 #define MAX_UDK 35
 3068 #endif
 3069     struct {
 3070     char *str;
 3071     int len;
 3072     } user_keys[MAX_UDK];
 3073 #ifndef NO_ACTIVE_ICON
 3074     int active_icon;        /* use application icon window  */
 3075     char *wm_name;
 3076 #endif /* NO_ACTIVE_ICON */
 3077 #if OPT_INPUT_METHOD
 3078     Boolean cannot_im;      /* true if we cannot use input-method */
 3079     XFontSet xim_fs;        /* fontset for XIM preedit */
 3080     int xim_fs_ascent;      /* ascent of fs */
 3081     TInput inputs[NINPUTWIDGETS];
 3082 #endif
 3083     Boolean doing_resize;   /* currently in RequestResize */
 3084 #if OPT_MAXIMIZE
 3085 #define MAX_EWMH_MODE 3
 3086 #define MAX_EWMH_DATA (1 + OPT_TEK4014)
 3087     struct {
 3088     int mode;       /* fullscreen, etc.     */
 3089     Boolean checked[MAX_EWMH_MODE + 1];
 3090     Boolean allowed[MAX_EWMH_MODE + 1];
 3091     } ewmh[MAX_EWMH_DATA];
 3092 #endif
 3093 #if OPT_NUM_LOCK
 3094     unsigned num_lock;      /* modifier for Num_Lock */
 3095     unsigned alt_mods;      /* modifier for Alt_L or Alt_R */
 3096     unsigned meta_mods;     /* modifier for Meta_L or Meta_R */
 3097 #endif
 3098     XtermFontNames fonts;
 3099 #if OPT_RENDERFONT
 3100     Boolean render_font;
 3101     unsigned max_fontsets;
 3102 #endif
 3103 #if OPT_DABBREV
 3104 #define MAX_DABBREV 1024    /* maximum word length as in tcsh */
 3105     char dabbrev_data[MAX_DABBREV];
 3106 #endif
 3107     ScrnColors *oldColors;
 3108     Boolean palette_changed;
 3109     Boolean broken_box_chars;
 3110 } Work;
 3111 
 3112 typedef struct {int foo;} XtermClassPart, TekClassPart;
 3113 
 3114 typedef struct _XtermClassRec {
 3115     CoreClassPart  core_class;
 3116     XtermClassPart xterm_class;
 3117 } XtermClassRec;
 3118 
 3119 extern WidgetClass xtermWidgetClass;
 3120 
 3121 #define IsXtermWidget(w) (XtClass(w) == xtermWidgetClass)
 3122 
 3123 #if OPT_TEK4014
 3124 typedef struct _TekClassRec {
 3125     CoreClassPart core_class;
 3126     TekClassPart tek_class;
 3127 } TekClassRec;
 3128 
 3129 extern WidgetClass tekWidgetClass;
 3130 
 3131 #define IsTekWidget(w) (XtClass(w) == tekWidgetClass)
 3132 
 3133 #endif
 3134 
 3135 /* define masks for keyboard.flags */
 3136 #define MODE_KAM    xBIT(0) /* mode 2: keyboard action mode */
 3137 #define MODE_DECKPAM    xBIT(1) /* keypad application mode */
 3138 #define MODE_DECCKM xBIT(2) /* private mode 1: cursor keys */
 3139 #define MODE_SRM    xBIT(3) /* mode 12: send-receive mode */
 3140 #define MODE_DECBKM xBIT(4) /* private mode 67: backarrow */
 3141 #define MODE_DECSDM xBIT(5) /* private mode 80: sixel scrolling mode */
 3142 
 3143 #define N_MARGINBELL    10
 3144 
 3145 #define TAB_BITS_SHIFT  5   /* FIXME: 2**5 == 32 (should derive) */
 3146 #define TAB_BITS_WIDTH  (1 << TAB_BITS_SHIFT)
 3147 #define TAB_ARRAY_SIZE  (1024 / TAB_BITS_WIDTH)
 3148 #define MAX_TABS    (TAB_BITS_WIDTH * TAB_ARRAY_SIZE)
 3149 
 3150 #define OkTAB(c)    ((c) >= 0 && (c) < MAX_TABS)
 3151 
 3152 typedef unsigned Tabs [TAB_ARRAY_SIZE];
 3153 
 3154 #if OPT_XTERM_SGR
 3155 #define MAX_SAVED_SGR   10
 3156 typedef struct {
 3157     int     used;
 3158     struct  {
 3159     IFlags  mask;
 3160     IFlags  flags;
 3161 #if OPT_ISO_COLORS
 3162     int sgr_foreground;
 3163     int sgr_background;
 3164     Boolean sgr_38_xcolors;
 3165 #endif
 3166     } stack[MAX_SAVED_SGR];
 3167 } SavedSGR;
 3168 #endif
 3169 
 3170 typedef struct _XtermWidgetRec {
 3171     CorePart    core;
 3172     XSizeHints  hints;
 3173     XVisualInfo *visInfo;
 3174     int     numVisuals;
 3175     unsigned    rgb_shifts[3];
 3176     unsigned    rgb_widths[3];
 3177     Bool    has_rgb;
 3178     Bool    init_menu;
 3179     TKeyboard   keyboard;   /* terminal keyboard        */
 3180     TScreen screen;     /* terminal screen      */
 3181     IFlags  flags;      /* mode flags           */
 3182     int     cur_foreground; /* current foreground color */
 3183     int     cur_background; /* current background color */
 3184     Pixel   dft_foreground; /* default foreground color */
 3185     Pixel   dft_background; /* default background color */
 3186     Pixel   old_foreground; /* original foreground color    */
 3187     Pixel   old_background; /* original background color    */
 3188 #if OPT_ISO_COLORS
 3189     int     sgr_foreground; /* current SGR foreground color */
 3190     int     sgr_background; /* current SGR background color */
 3191     Boolean sgr_38_xcolors; /* true if ISO 8613 extension   */
 3192 #endif
 3193     IFlags  initflags;  /* initial mode flags       */
 3194     Tabs    tabs;       /* tabstops of the terminal */
 3195     Misc    misc;       /* miscellaneous parameters */
 3196     Work    work;       /* workspace (no resources) */
 3197 #if OPT_XTERM_SGR
 3198     SavedSGR    saved_sgr;
 3199 #endif
 3200 } XtermWidgetRec, *XtermWidget;
 3201 
 3202 #if OPT_TEK4014
 3203 typedef struct _TekWidgetRec {
 3204     CorePart    core;
 3205     XtermWidget vt;     /* main widget has border, etc. */
 3206     TekPart tek;        /* contains resources */
 3207     TekScreen   screen;     /* contains working data (no resources) */
 3208     Bool    init_menu;
 3209     XSizeHints  hints;
 3210 } TekWidgetRec, *TekWidget;
 3211 #endif /* OPT_TEK4014 */
 3212 
 3213 /*
 3214  * terminal flags
 3215  * There are actually two namespaces mixed together here.
 3216  * One is the set of flags that can go in screen->visbuf attributes
 3217  * and which must fit in a char (see OFF_ATTRS).
 3218  * The other is the global setting stored in
 3219  * term->flags and screen->save_modes.  This need only fit in an unsigned.
 3220  */
 3221 
 3222 #define AttrBIT(n)  xBIT(n)     /* text-attributes */
 3223 #define MiscBIT(n)  xBIT(n + 16)    /* miscellaneous state flags */
 3224 
 3225 /* global flags and character flags (visible character attributes) */
 3226 #define INVERSE     AttrBIT(0)  /* invert the characters to be output */
 3227 #define UNDERLINE   AttrBIT(1)  /* true if underlining */
 3228 #define BOLD        AttrBIT(2)
 3229 #define BLINK       AttrBIT(3)
 3230 /* global flags (also character attributes) */
 3231 #define BG_COLOR    AttrBIT(4)  /* true if background set */
 3232 #define FG_COLOR    AttrBIT(5)  /* true if foreground set */
 3233 
 3234 /* character flags (internal attributes) */
 3235 #define PROTECTED   AttrBIT(6)  /* a character that cannot be erased */
 3236 #define CHARDRAWN   AttrBIT(7)  /* a character has been drawn here on
 3237                        the screen.  Used to distinguish
 3238                        blanks from empty parts of the
 3239                        screen when selecting */
 3240 
 3241 #if OPT_WIDE_ATTRS
 3242 #define ATR_FAINT   AttrBIT(8)
 3243 #define ATR_ITALIC  AttrBIT(9)
 3244 #define ATR_STRIKEOUT   AttrBIT(10)
 3245 #define ATR_DBL_UNDER   AttrBIT(11)
 3246 #define ATR_DIRECT_FG   AttrBIT(12)
 3247 #define ATR_DIRECT_BG   AttrBIT(13)
 3248 #define SGR_MASK2       (ATR_FAINT | ATR_ITALIC | ATR_STRIKEOUT | ATR_DBL_UNDER | ATR_DIRECT_FG | ATR_DIRECT_BG)
 3249 #else
 3250 #define SGR_MASK2       0
 3251 #endif
 3252 
 3253 /*
 3254  * Other flags
 3255  */
 3256 #define WRAPAROUND  MiscBIT(0)  /* true if auto wraparound mode */
 3257 #define REVERSEWRAP MiscBIT(1)  /* true if reverse wraparound mode */
 3258 #define REVERSE_VIDEO   MiscBIT(2)  /* true if screen white on black */
 3259 #define LINEFEED    MiscBIT(3)  /* true if in auto linefeed mode */
 3260 #define ORIGIN      MiscBIT(4)  /* true if in origin mode */
 3261 #define INSERT      MiscBIT(5)  /* true if in insert mode */
 3262 #define SMOOTHSCROLL    MiscBIT(6)  /* true if in smooth scroll mode */
 3263 #define IN132COLUMNS    MiscBIT(7)  /* true if in 132 column mode */
 3264 #define INVISIBLE   MiscBIT(8)  /* true if writing invisible text */
 3265 #define NATIONAL        MiscBIT(9)  /* true if writing national charset */
 3266 #define LEFT_RIGHT      MiscBIT(10) /* true if left/right margin mode */
 3267 #define NOCLEAR_COLM    MiscBIT(11) /* true if no clear on DECCOLM change */
 3268 
 3269 #define DrawBIT(n)  xBIT(n + 8) /* XTermDraw.draw_flags */
 3270 /* The following attributes are used in the argument of drawXtermText()  */
 3271 #define NOBACKGROUND    DrawBIT(0)  /* Used for overstrike */
 3272 #define NOTRANSLATION   DrawBIT(1)  /* No scan for chars missing in font */
 3273 #define DOUBLEWFONT DrawBIT(2)  /* The actual X-font is double-width */
 3274 #define DOUBLEHFONT DrawBIT(3)  /* The actual X-font is double-height */
 3275 #define CHARBYCHAR  DrawBIT(4)  /* Draw chars one-by-one */
 3276 
 3277 /* The following attribute is used in the argument of xtermSpecialFont etc */
 3278 #define NORESOLUTION    DrawBIT(5)  /* find the font without resolution */
 3279 
 3280 
 3281 /*
 3282  * Groups of attributes
 3283  */
 3284             /* mask for video-attributes only */
 3285 #define SGR_MASK    (BOLD | BLINK | UNDERLINE | INVERSE)
 3286 
 3287             /* mask: user-visible attributes */
 3288 #define ATTRIBUTES  (SGR_MASK | SGR_MASK2 | BG_COLOR | FG_COLOR | INVISIBLE | PROTECTED)
 3289 
 3290 /* The toplevel-call to drawXtermText() should have text-attributes guarded: */
 3291 #define DRAWX_MASK  (ATTRIBUTES | CHARDRAWN)
 3292 
 3293 /*
 3294  * BOLDATTR is not only nonzero when we will use bold font, but uses the bits
 3295  * for BOLD/BLINK to match against the video attributes which were originally
 3296  * requested.
 3297  */
 3298 #define USE_BOLD(screen) ((screen)->allowBoldFonts)
 3299 
 3300 #if OPT_BLINK_TEXT
 3301 #define BOLDATTR(screen) (unsigned) (USE_BOLD(screen) ? (BOLD | ((screen)->blink_as_bold ? BLINK : 0)) : 0)
 3302 #else
 3303 #define BOLDATTR(screen) (unsigned) (USE_BOLD(screen) ? (BOLD | BLINK) : 0)
 3304 #endif
 3305 
 3306 /*
 3307  * Per-line flags
 3308  */
 3309 #define LINEWRAPPED AttrBIT(0)
 3310 /* used once per line to indicate that it wraps onto the next line so we can
 3311  * tell the difference between lines that have wrapped around and lines that
 3312  * have ended naturally with a CR at column max_col.
 3313  */
 3314 #define LINEBLINKED AttrBIT(1)
 3315 /* set when the line contains blinking text.
 3316  */
 3317 
 3318 #if OPT_ZICONBEEP || OPT_TOOLBAR || (USE_DOUBLE_BUFFER && OPT_RENDERFONT)
 3319 #define HANDLE_STRUCT_NOTIFY 1
 3320 #else
 3321 #define HANDLE_STRUCT_NOTIFY 0
 3322 #endif
 3323 
 3324 /*
 3325  * If we've set protected attributes with the DEC-style DECSCA, then we'll have
 3326  * to use DECSED or DECSEL to erase preserving protected text.  (The normal ED,
 3327  * EL won't preserve protected-text).  If we've used SPA, then normal ED and EL
 3328  * will preserve protected-text.  To keep things simple, just remember the last
 3329  * control that was used to begin protected-text, and use that to determine how
 3330  * erases are performed (otherwise we'd need 2 bits per protected character).
 3331  */
 3332 #define OFF_PROTECT 0
 3333 #define DEC_PROTECT 1
 3334 #define ISO_PROTECT 2
 3335 
 3336 /***====================================================================***/
 3337 
 3338 /*
 3339  * Reduce parameter-count of drawXtermText by putting less-modified data here.
 3340  */
 3341 typedef struct {
 3342     XtermWidget xw;
 3343     unsigned    attr_flags;
 3344     unsigned    draw_flags;
 3345     unsigned    this_chrset;
 3346     unsigned    real_chrset;
 3347     int     on_wide;
 3348 } XTermDraw;
 3349 
 3350 /***====================================================================***/
 3351 
 3352 #define TScreenOf(xw)   (&(xw)->screen)
 3353 #define TekScreenOf(tw) (&(tw)->screen)
 3354 
 3355 #define PrinterOf(screen) (screen)->printer_state
 3356 
 3357 #ifdef SCROLLBAR_RIGHT
 3358 #define OriginX(screen) (((term->misc.useRight)?0:ScrollbarWidth(screen)) + screen->border)
 3359 #else
 3360 #define OriginX(screen) (ScrollbarWidth(screen) + screen->border)
 3361 #endif
 3362 
 3363 #define OriginY(screen) (screen->border)
 3364 
 3365 #define CursorMoved(screen) \
 3366         ((screen)->cursor_moved || \
 3367             ((screen)->cursorp.col != (screen)->cur_col || \
 3368              (screen)->cursorp.row != (screen)->cur_row))
 3369 
 3370 #define CursorX2(screen,col,fw) ((col) * (int)(fw) + OriginX(screen))
 3371 #define CursorX(screen,col)     CursorX2(screen, col, FontWidth(screen))
 3372 #define CursorY2(screen,row)    (((row) * FontHeight(screen)) + screen->border)
 3373 #define CursorY(screen,row)     CursorY2(screen, INX2ROW(screen, row))
 3374 
 3375 /*
 3376  * These definitions depend on whether xterm supports active-icon.
 3377  */
 3378 #ifndef NO_ACTIVE_ICON
 3379 #define IsIconWin(screen,win)   ((win) == &(screen)->iconVwin)
 3380 #define IsIcon(screen)      (WhichVWin(screen) == &(screen)->iconVwin)
 3381 #define WhichVWin(screen)   ((screen)->whichVwin)
 3382 #define WhichTWin(screen)   ((screen)->whichTwin)
 3383 
 3384 #define WhichVFont(screen,name) (IsIcon(screen) ? getIconicFont(screen) \
 3385                         : getNormalFont(screen, (int)(name)))->fs
 3386 #define FontAscent(screen)  (IsIcon(screen) ? getIconicFont(screen)->fs->ascent \
 3387                         : WhichVWin(screen)->f_ascent)
 3388 #define FontDescent(screen) (IsIcon(screen) ? getIconicFont(screen)->fs->descent \
 3389                         : WhichVWin(screen)->f_descent)
 3390 #else /* NO_ACTIVE_ICON */
 3391 
 3392 #define IsIconWin(screen,win)   (False)
 3393 #define IsIcon(screen)      (False)
 3394 #define WhichVWin(screen)   (&((screen)->fullVwin))
 3395 #define WhichTWin(screen)   (&((screen)->fullTwin))
 3396 
 3397 #define WhichVFont(screen,name) getNormalFont(screen, (int)(name))->fs
 3398 #define FontAscent(screen)  WhichVWin(screen)->f_ascent
 3399 #define FontDescent(screen) WhichVWin(screen)->f_descent
 3400 
 3401 #endif /* NO_ACTIVE_ICON */
 3402 
 3403 #define okFont(font) ((font) != 0 && (font)->fid != 0)
 3404 
 3405 /*
 3406  * Macro to check if we are iconified; do not use render for that case.
 3407  */
 3408 #define UsingRenderFont(xw) (((xw)->work.render_font == True) && !IsIcon(TScreenOf(xw)))
 3409 
 3410 /*
 3411  * These definitions do not depend on whether xterm supports active-icon.
 3412  */
 3413 #define VWindow(screen)     WhichVWin(screen)->window
 3414 #define VShellWindow(xw)    XtWindow(SHELL_OF(xw))
 3415 #define TWindow(screen)     WhichTWin(screen)->window
 3416 #define TShellWindow        XtWindow(SHELL_OF(tekWidget))
 3417 
 3418 #if USE_DOUBLE_BUFFER
 3419 extern Window VDrawable(TScreen * /* screen */);
 3420 #else
 3421 #define VDrawable(screen)   VWindow(screen)
 3422 #endif
 3423 
 3424 #define Width(screen)       WhichVWin(screen)->width
 3425 #define Height(screen)      WhichVWin(screen)->height
 3426 #define FullWidth(screen)   WhichVWin(screen)->fullwidth
 3427 #define FullHeight(screen)  WhichVWin(screen)->fullheight
 3428 #define FontWidth(screen)   WhichVWin(screen)->f_width
 3429 #define FontHeight(screen)  WhichVWin(screen)->f_height
 3430 
 3431 #define NormalFont(screen)  WhichVFont(screen, fNorm)
 3432 #define BoldFont(screen)    WhichVFont(screen, fBold)
 3433 
 3434 #if OPT_WIDE_CHARS
 3435 #define NormalWFont(screen) WhichVFont(screen, fWide)
 3436 #define BoldWFont(screen)   WhichVFont(screen, fWBold)
 3437 #endif
 3438 
 3439 #define ScrollbarWidth(screen)  WhichVWin(screen)->sb_info.width
 3440 
 3441 #define BorderGC(w,sp)      WhichVWin(sp)->border_gc
 3442 #define FillerGC(w,sp)      WhichVWin(sp)->filler_gc
 3443 #define NormalGC(w,sp)      getCgsGC(w, WhichVWin(sp), gcNorm)
 3444 #define ReverseGC(w,sp)     getCgsGC(w, WhichVWin(sp), gcNormReverse)
 3445 #define NormalBoldGC(w,sp)  getCgsGC(w, WhichVWin(sp), gcBold)
 3446 #define ReverseBoldGC(w,sp) getCgsGC(w, WhichVWin(sp), gcBoldReverse)
 3447 
 3448 #define TWidth(screen)      WhichTWin(screen)->width
 3449 #define THeight(screen)     WhichTWin(screen)->height
 3450 #define TFullWidth(screen)  WhichTWin(screen)->fullwidth
 3451 #define TFullHeight(screen) WhichTWin(screen)->fullheight
 3452 #define TekScale(screen)    WhichTWin(screen)->tekscale
 3453 
 3454 /* use these before tek4014 is realized, good enough for default "9x15" font */
 3455 #define TDefaultRows        37
 3456 #define TDefaultCols        75
 3457 
 3458 #define BorderWidth(w)      ((w)->core.border_width)
 3459 #define BorderPixel(w)      ((w)->core.border_pixel)
 3460 
 3461 #define AllowXtermOps(w,name)   (TScreenOf(w)->name && !TScreenOf(w)->allowSendEvents)
 3462 
 3463 #define AllowColorOps(w,name)   (AllowXtermOps(w, allowColorOps) || \
 3464                  !TScreenOf(w)->disallow_color_ops[name])
 3465 
 3466 #define AllowFontOps(w,name)    (AllowXtermOps(w, allowFontOps) || \
 3467                  !TScreenOf(w)->disallow_font_ops[name])
 3468 
 3469 #define AllowMouseOps(w,name)   (AllowXtermOps(w, allowMouseOps) || \
 3470                  !TScreenOf(w)->disallow_mouse_ops[name])
 3471 
 3472 #define AllowTcapOps(w,name)    (AllowXtermOps(w, allowTcapOps) || \
 3473                  !TScreenOf(w)->disallow_tcap_ops[name])
 3474 
 3475 #define AllowTitleOps(w)    AllowXtermOps(w, allowTitleOps)
 3476 
 3477 #define AllowXResOps(w)     True
 3478 
 3479 #define SpecialWindowOps(w,name) (!TScreenOf(w)->disallow_win_ops[name])
 3480 #define AllowWindowOps(w,name)  (AllowXtermOps(w, allowWindowOps) || \
 3481                  SpecialWindowOps(w,name))
 3482 
 3483 #if OPT_TOOLBAR
 3484 #define ToolbarHeight(w)    ((resource.toolBar) \
 3485                  ? ((w)->VT100_TB_INFO(menu_height) \
 3486                   + (w)->VT100_TB_INFO(menu_border) * 2) \
 3487                  : 0)
 3488 #else
 3489 #define ToolbarHeight(w) 0
 3490 #endif
 3491 
 3492 #if OPT_TEK4014
 3493 #define TEK_LINK_BLOCK_SIZE 1024
 3494 
 3495 typedef struct Tek_Link
 3496 {
 3497     struct Tek_Link *next;  /* pointer to next TekLink in list
 3498                    NULL <=> this is last TekLink */
 3499     unsigned short fontsize;/* character size, 0-3 */
 3500     unsigned short count;   /* number of chars in data */
 3501     char *ptr;      /* current pointer into data */
 3502     char data [TEK_LINK_BLOCK_SIZE];
 3503 } TekLink;
 3504 #endif /* OPT_TEK4014 */
 3505 
 3506 /* flags for cursors */
 3507 #define OFF     0
 3508 #define ON      1
 3509 #define BLINKED_OFF 2
 3510 #define CLEAR       0
 3511 #define TOGGLE      1
 3512 
 3513 /* flags for inhibit */
 3514 #ifdef ALLOWLOGGING
 3515 #define I_LOG       0x01
 3516 #endif
 3517 #define I_SIGNAL    0x02
 3518 #define I_TEK       0x04
 3519 
 3520 /* *INDENT-ON* */
 3521 
 3522 #endif /* included_ptyx_h */