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