ptyx.h revision c219fbeb
1/* $XTermId: ptyx.h,v 1.684 2011/02/17 00:13:06 tom Exp $ */ 2 3/* 4 * Copyright 1999-2010,2011 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/Xfuncs.h> 71#include <X11/Xosdefs.h> 72#include <X11/Xmu/Converters.h> 73#ifdef XRENDERFONT 74#include <X11/Xft/Xft.h> 75#endif 76 77/* adapted from IntrinsicI.h */ 78#define MyStackAlloc(size, stack_cache_array) \ 79 ((size) <= sizeof(stack_cache_array) \ 80 ? (XtPointer)(stack_cache_array) \ 81 : (XtPointer)malloc((size_t)(size))) 82 83#define MyStackFree(pointer, stack_cache_array) \ 84 if ((pointer) != ((char *)(stack_cache_array))) free(pointer) 85 86/* adapted from vile (vi-like-emacs) */ 87#define TypeCallocN(type,n) (type *)calloc((size_t) (n), sizeof(type)) 88#define TypeCalloc(type) TypeCallocN(type, 1) 89 90#define TypeMallocN(type,n) (type *)malloc(sizeof(type) * (size_t) (n)) 91#define TypeMalloc(type) TypeMallocN(type, 1) 92 93#define TypeRealloc(type,n,p) (type *)realloc(p, (n) * sizeof(type)) 94 95#define TypeXtReallocN(t,p,n) (t *)(void *)XtRealloc((char *)(p), (Cardinal)(sizeof(t) * (size_t) (n))) 96 97#define TypeXtMallocX(type,n) (type *)(void *)XtMalloc((Cardinal)(sizeof(type) + (size_t) (n))) 98#define TypeXtMallocN(type,n) (type *)(void *)XtMalloc((Cardinal)(sizeof(type) * (size_t) (n))) 99#define TypeXtMalloc(type) TypeXtMallocN(type, 1) 100 101/* use these to allocate partly-structured data */ 102#define CastMallocN(type,n) (type *)malloc(sizeof(type) + (size_t) (n)) 103#define CastMalloc(type) CastMallocN(type,0) 104 105#define BumpBuffer(type, buffer, size, want) \ 106 if (want >= size) { \ 107 size = 1 + (want * 2); \ 108 buffer = TypeRealloc(type, size, buffer); \ 109 } 110 111#define BfBuf(type) screen->bf_buf_##type 112#define BfLen(type) screen->bf_len_##type 113 114#define TypedBuffer(type) \ 115 type *bf_buf_##type; \ 116 Cardinal bf_len_##type 117 118#define BumpTypedBuffer(type, want) \ 119 BumpBuffer(type, BfBuf(type), BfLen(type), want) 120 121#define FreeTypedBuffer(type) \ 122 if (BfBuf(type) != 0) { \ 123 free(BfBuf(type)); \ 124 BfBuf(type) = 0; \ 125 } \ 126 BfLen(type) = 0 127 128/* 129** System V definitions 130*/ 131 132#ifdef att 133#define ATT 134#endif 135 136#ifdef SVR4 137#undef SYSV /* predefined on Solaris 2.4 */ 138#define SYSV /* SVR4 is (approx) superset of SVR3 */ 139#define ATT 140#endif 141 142#ifdef SYSV 143#ifdef X_NOT_POSIX 144#if !defined(CRAY) && !defined(SVR4) 145#define dup2(fd1,fd2) ((fd1 == fd2) ? fd1 : \ 146 (close(fd2), fcntl(fd1, F_DUPFD, fd2))) 147#endif 148#endif 149#endif /* SYSV */ 150 151/* 152 * Newer versions of <X11/Xft/Xft.h> have a version number. We use certain 153 * features from that. 154 */ 155#if defined(XRENDERFONT) && defined(XFT_VERSION) && XFT_VERSION >= 20100 156#define HAVE_TYPE_FCCHAR32 1 /* compatible: XftChar16 */ 157#define HAVE_TYPE_XFTCHARSPEC 1 /* new type XftCharSpec */ 158#endif 159 160/* 161** Definitions to simplify ifdef's for pty's. 162*/ 163#define USE_PTY_DEVICE 1 164#define USE_PTY_SEARCH 1 165 166#if defined(__osf__) || (defined(linux) && defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) 167#undef USE_PTY_DEVICE 168#undef USE_PTY_SEARCH 169#define USE_PTS_DEVICE 1 170#elif defined(VMS) 171#undef USE_PTY_DEVICE 172#undef USE_PTY_SEARCH 173#elif defined(PUCC_PTYD) 174#undef USE_PTY_SEARCH 175#elif (defined(sun) && defined(SVR4)) || defined(_ALL_SOURCE) || defined(__CYGWIN__) 176#undef USE_PTY_SEARCH 177#endif 178 179#if defined(SYSV) && defined(i386) && !defined(SVR4) 180#define ATT 181#define USE_HANDSHAKE 1 182#define USE_ISPTS_FLAG 1 183#endif 184 185#if (defined (__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1))) 186#define USE_USG_PTYS 187#define USE_HANDSHAKE 0 /* "recent" Linux systems do not require handshaking */ 188#elif (defined(ATT) && !defined(__sgi)) || defined(__MVS__) || (defined(SYSV) && defined(i386)) 189#define USE_USG_PTYS 190#else 191#define USE_HANDSHAKE 1 192#endif 193 194/* 195 * More systems than not require pty-handshaking. 196 */ 197#ifndef USE_HANDSHAKE 198#define USE_HANDSHAKE 1 199#endif 200 201/* 202** allow for mobility of the pty master/slave directories 203*/ 204#ifndef PTYDEV 205#if defined(__hpux) 206#define PTYDEV "/dev/ptym/ptyxx" 207#elif defined(__MVS__) 208#define PTYDEV "/dev/ptypxxxx" 209#else 210#define PTYDEV "/dev/ptyxx" 211#endif 212#endif /* !PTYDEV */ 213 214#ifndef TTYDEV 215#if defined(__hpux) 216#define TTYDEV "/dev/pty/ttyxx" 217#elif defined(__MVS__) 218#define TTYDEV "/dev/ptypxxxx" 219#elif defined(USE_PTS_DEVICE) 220#define TTYDEV "/dev/pts/0" 221#else 222#define TTYDEV "/dev/ttyxx" 223#endif 224#endif /* !TTYDEV */ 225 226#ifndef PTYCHAR1 227#ifdef __hpux 228#define PTYCHAR1 "zyxwvutsrqp" 229#else /* !__hpux */ 230#ifdef __UNIXOS2__ 231#define PTYCHAR1 "pq" 232#else 233#define PTYCHAR1 "pqrstuvwxyzPQRSTUVWXYZ" 234#endif /* !__UNIXOS2__ */ 235#endif /* !__hpux */ 236#endif /* !PTYCHAR1 */ 237 238#ifndef PTYCHAR2 239#ifdef __hpux 240#define PTYCHAR2 "fedcba9876543210" 241#else /* !__hpux */ 242#if defined(__DragonFly__) || defined(__FreeBSD__) 243#define PTYCHAR2 "0123456789abcdefghijklmnopqrstuv" 244#else /* !__FreeBSD__ */ 245#define PTYCHAR2 "0123456789abcdef" 246#endif /* !__FreeBSD__ */ 247#endif /* !__hpux */ 248#endif /* !PTYCHAR2 */ 249 250#ifndef TTYFORMAT 251#if defined(CRAY) 252#define TTYFORMAT "/dev/ttyp%03d" 253#elif defined(__MVS__) 254#define TTYFORMAT "/dev/ttyp%04d" 255#else 256#define TTYFORMAT "/dev/ttyp%d" 257#endif 258#endif /* TTYFORMAT */ 259 260#ifndef PTYFORMAT 261#ifdef CRAY 262#define PTYFORMAT "/dev/pty/%03d" 263#elif defined(__MVS__) 264#define PTYFORMAT "/dev/ptyp%04d" 265#else 266#define PTYFORMAT "/dev/ptyp%d" 267#endif 268#endif /* PTYFORMAT */ 269 270#ifndef PTYCHARLEN 271#ifdef CRAY 272#define PTYCHARLEN 3 273#elif defined(__MVS__) 274#define PTYCHARLEN 8 /* OS/390 stores, e.g. ut_id="ttyp1234" */ 275#else 276#define PTYCHARLEN 2 277#endif 278#endif 279 280#ifndef MAXPTTYS 281#ifdef CRAY 282#define MAXPTTYS 256 283#else 284#define MAXPTTYS 2048 285#endif 286#endif 287 288/* Until the translation manager comes along, I have to do my own translation of 289 * mouse events into the proper routines. */ 290 291typedef enum { 292 NORMAL = 0 293 , LEFTEXTENSION 294 , RIGHTEXTENSION 295} EventMode; 296 297/* 298 * The origin of a screen is 0, 0. Therefore, the number of rows 299 * on a screen is screen->max_row + 1, and similarly for columns. 300 */ 301#define MaxCols(screen) ((screen)->max_col + 1) 302#define MaxRows(screen) ((screen)->max_row + 1) 303 304typedef unsigned char Char; /* to support 8 bit chars */ 305typedef Char *ScrnPtr; 306typedef ScrnPtr *ScrnBuf; 307 308/* 309 * Declare an X String, but for unsigned chars. 310 */ 311#ifdef _CONST_X_STRING 312typedef const Char *UString; 313#else 314typedef Char *UString; 315#endif 316 317#define IsEmpty(s) ((s) == 0 || *(s) == '\0') 318 319#define CharOf(n) ((unsigned char)(n)) 320 321typedef struct { 322 int row; 323 int col; 324} CELL; 325 326#define isSameRow(a,b) ((a)->row == (b)->row) 327#define isSameCol(a,b) ((a)->col == (b)->col) 328#define isSameCELL(a,b) (isSameRow(a,b) && isSameCol(a,b)) 329 330#define xBIT(n) (1 << (n)) 331 332/* 333 * ANSI emulation, special character codes 334 */ 335#define ANSI_EOT 0x04 336#define ANSI_BEL 0x07 337#define ANSI_BS 0x08 338#define ANSI_HT 0x09 339#define ANSI_LF 0x0A 340#define ANSI_VT 0x0B 341#define ANSI_FF 0x0C /* C0, C1 control names */ 342#define ANSI_CR 0x0D 343#define ANSI_SO 0x0E 344#define ANSI_SI 0x0F 345#define ANSI_XON 0x11 /* DC1 */ 346#define ANSI_XOFF 0x13 /* DC3 */ 347#define ANSI_NAK 0x15 348#define ANSI_CAN 0x18 349#define ANSI_ESC 0x1B 350#define ANSI_SPA 0x20 351#define XTERM_POUND 0x1E /* internal mapping for '#' */ 352#define ANSI_DEL 0x7F 353#define ANSI_SS2 0x8E 354#define ANSI_SS3 0x8F 355#define ANSI_DCS 0x90 356#define ANSI_SOS 0x98 357#define ANSI_CSI 0x9B 358#define ANSI_ST 0x9C 359#define ANSI_OSC 0x9D 360#define ANSI_PM 0x9E 361#define ANSI_APC 0x9F 362 363#define MIN_DECID 52 /* can emulate VT52 */ 364#define MAX_DECID 420 /* ...through VT420 */ 365 366#ifndef DFT_DECID 367#define DFT_DECID "vt100" /* default VT100 */ 368#endif 369 370#ifndef DFT_KBD_DIALECT 371#define DFT_KBD_DIALECT "B" /* default USASCII */ 372#endif 373 374/* constants used for utf8 mode */ 375#define UCS_REPL 0xfffd 376#define UCS_LIMIT 0x80000000U /* both limit and flag for non-UCS */ 377 378#define TERMCAP_SIZE 1500 /* 1023 is standard; 'screen' exceeds */ 379 380#define NMENUFONTS 9 /* font entries in fontMenu */ 381 382#define NBOX 5 /* Number of Points in box */ 383#define NPARAM 30 /* Max. parameters */ 384 385typedef struct { 386 String opt; 387 String desc; 388} OptionHelp; 389 390typedef short ParmType; 391 392typedef struct { 393 Char a_type; /* CSI, etc., see unparseq() */ 394 Char a_pintro; /* private-mode char, if any */ 395 Char a_inters; /* special (before final-char) */ 396 Char a_final; /* final-char */ 397 ParmType a_nparam; /* # of parameters */ 398 ParmType a_param[NPARAM]; /* Parameters */ 399} ANSI; 400 401#define TEK_FONT_LARGE 0 402#define TEK_FONT_2 1 403#define TEK_FONT_3 2 404#define TEK_FONT_SMALL 3 405#define TEKNUMFONTS 4 406 407/* Actually there are 5 types of lines, but four are non-solid lines */ 408#define TEKNUMLINES 4 409 410typedef struct { 411 int x; 412 int y; 413 int fontsize; 414 unsigned linetype; 415} Tmodes; 416 417typedef struct { 418 int Twidth; 419 int Theight; 420} T_fontsize; 421 422typedef struct { 423 short *bits; 424 int x; 425 int y; 426 int width; 427 int height; 428} BitmapBits; 429 430#define SAVELINES 64 /* default # lines to save */ 431#define SCROLLLINES 1 /* default # lines to scroll */ 432 433#define EXCHANGE(a,b,tmp) tmp = a; a = b; b = tmp 434 435/***====================================================================***/ 436 437#if (XtSpecificationRelease < 6) 438#ifndef NO_ACTIVE_ICON 439#define NO_ACTIVE_ICON 1 /* Note: code relies on an X11R6 function */ 440#endif 441#endif 442 443#ifndef OPT_AIX_COLORS 444#define OPT_AIX_COLORS 1 /* true if xterm is configured with AIX (16) colors */ 445#endif 446 447#ifndef OPT_ALLOW_XXX_OPS 448#define OPT_ALLOW_XXX_OPS 1 /* true if xterm adds "Allow XXX Ops" submenu */ 449#endif 450 451#ifndef OPT_BLINK_CURS 452#define OPT_BLINK_CURS 1 /* true if xterm has blinking cursor capability */ 453#endif 454 455#ifndef OPT_BLINK_TEXT 456#define OPT_BLINK_TEXT OPT_BLINK_CURS /* true if xterm has blinking text capability */ 457#endif 458 459#ifndef OPT_BOX_CHARS 460#define OPT_BOX_CHARS 1 /* true if xterm can simulate box-characters */ 461#endif 462 463#ifndef OPT_BROKEN_OSC 464#ifdef linux 465#define OPT_BROKEN_OSC 1 /* man console_codes, 1st paragraph - cf: ECMA-48 */ 466#else 467#define OPT_BROKEN_OSC 0 /* true if xterm allows Linux's broken OSC parsing */ 468#endif 469#endif 470 471#ifndef OPT_BROKEN_ST 472#define OPT_BROKEN_ST 1 /* true if xterm allows old/broken OSC parsing */ 473#endif 474 475#ifndef OPT_C1_PRINT 476#define OPT_C1_PRINT 1 /* true if xterm allows C1 controls to be printable */ 477#endif 478 479#ifndef OPT_CLIP_BOLD 480#define OPT_CLIP_BOLD 1 /* true if xterm uses clipping to avoid bold-trash */ 481#endif 482 483#ifndef OPT_COLOR_CLASS 484#define OPT_COLOR_CLASS 1 /* true if xterm uses separate color-resource classes */ 485#endif 486 487#ifndef OPT_COLOR_RES 488#define OPT_COLOR_RES 1 /* true if xterm delays color-resource evaluation */ 489#endif 490 491#ifndef OPT_DABBREV 492#define OPT_DABBREV 0 /* dynamic abbreviations */ 493#endif 494 495#ifndef OPT_DEC_CHRSET 496#define OPT_DEC_CHRSET 1 /* true if xterm is configured for DEC charset */ 497#endif 498 499#ifndef OPT_DEC_LOCATOR 500#define OPT_DEC_LOCATOR 0 /* true if xterm supports VT220-style mouse events */ 501#endif 502 503#ifndef OPT_DEC_RECTOPS 504#define OPT_DEC_RECTOPS 0 /* true if xterm is configured for VT420 rectangles */ 505#endif 506 507#ifndef OPT_DEC_SOFTFONT 508#define OPT_DEC_SOFTFONT 0 /* true if xterm is configured for VT220 softfonts */ 509#endif 510 511#ifndef OPT_EBCDIC 512#ifdef __MVS__ 513#define OPT_EBCDIC 1 514#else 515#define OPT_EBCDIC 0 516#endif 517#endif 518 519#ifndef OPT_EXEC_XTERM 520#define OPT_EXEC_XTERM 0 /* true if xterm can fork/exec copies of itself */ 521#endif 522 523#ifndef OPT_EXTRA_PASTE 524#define OPT_EXTRA_PASTE 1 525#endif 526 527#ifndef OPT_FIFO_LINES 528#define OPT_FIFO_LINES 0 /* optimize save-lines feature using FIFO */ 529#endif 530 531#ifndef OPT_FOCUS_EVENT 532#define OPT_FOCUS_EVENT 1 /* focus in/out events */ 533#endif 534 535#ifndef OPT_HP_FUNC_KEYS 536#define OPT_HP_FUNC_KEYS 0 /* true if xterm supports HP-style function keys */ 537#endif 538 539#ifndef OPT_I18N_SUPPORT 540#if (XtSpecificationRelease >= 5) 541#define OPT_I18N_SUPPORT 1 /* true if xterm uses internationalization support */ 542#else 543#define OPT_I18N_SUPPORT 0 544#endif 545#endif 546 547#ifndef OPT_INITIAL_ERASE 548#define OPT_INITIAL_ERASE 1 /* use pty's erase character if it's not 128 */ 549#endif 550 551#ifndef OPT_INPUT_METHOD 552#if (XtSpecificationRelease >= 6) 553#define OPT_INPUT_METHOD 1 /* true if xterm uses input-method support */ 554#else 555#define OPT_INPUT_METHOD 0 556#endif 557#endif 558 559#ifndef OPT_ISO_COLORS 560#define OPT_ISO_COLORS 1 /* true if xterm is configured with ISO colors */ 561#endif 562 563#ifndef OPT_256_COLORS 564#define OPT_256_COLORS 0 /* true if xterm is configured with 256 colors */ 565#endif 566 567#ifndef OPT_88_COLORS 568#define OPT_88_COLORS 0 /* true if xterm is configured with 88 colors */ 569#endif 570 571#ifndef OPT_HIGHLIGHT_COLOR 572#define OPT_HIGHLIGHT_COLOR 1 /* true if xterm supports color highlighting */ 573#endif 574 575#ifndef OPT_LOAD_VTFONTS 576#define OPT_LOAD_VTFONTS 0 /* true if xterm has load-vt-fonts() action */ 577#endif 578 579#ifndef OPT_LUIT_PROG 580#define OPT_LUIT_PROG 0 /* true if xterm supports luit */ 581#endif 582 583#ifndef OPT_MAXIMIZE 584#define OPT_MAXIMIZE 1 /* add actions for iconify ... maximize */ 585#endif 586 587#ifndef OPT_MINI_LUIT 588#define OPT_MINI_LUIT 0 /* true if xterm supports built-in mini-luit */ 589#endif 590 591#ifndef OPT_MOD_FKEYS 592#define OPT_MOD_FKEYS 1 /* modify cursor- and function-keys in normal mode */ 593#endif 594 595#ifndef OPT_NUM_LOCK 596#define OPT_NUM_LOCK 1 /* use NumLock key only for numeric-keypad */ 597#endif 598 599#ifndef OPT_PASTE64 600#define OPT_PASTE64 0 /* program control of select/paste via base64 */ 601#endif 602 603#ifndef OPT_PC_COLORS 604#define OPT_PC_COLORS 1 /* true if xterm supports PC-style (bold) colors */ 605#endif 606 607#ifndef OPT_PTY_HANDSHAKE 608#define OPT_PTY_HANDSHAKE USE_HANDSHAKE /* avoid pty races on older systems */ 609#endif 610 611#ifndef OPT_PRINT_COLORS 612#define OPT_PRINT_COLORS 1 /* true if we print color information */ 613#endif 614 615#ifndef OPT_READLINE 616#define OPT_READLINE 0 /* mouse-click/paste support for readline */ 617#endif 618 619#ifndef OPT_RENDERFONT 620#ifdef XRENDERFONT 621#define OPT_RENDERFONT 1 622#else 623#define OPT_RENDERFONT 0 624#endif 625#endif 626 627#ifndef OPT_RENDERWIDE 628#if OPT_RENDERFONT && OPT_WIDE_CHARS && defined(HAVE_TYPE_XFTCHARSPEC) 629#define OPT_RENDERWIDE 1 630#else 631#define OPT_RENDERWIDE 0 632#endif 633#endif 634 635#ifndef OPT_SAME_NAME 636#define OPT_SAME_NAME 1 /* suppress redundant updates of title, icon, etc. */ 637#endif 638 639#ifndef OPT_SAVE_LINES 640#define OPT_SAVE_LINES OPT_FIFO_LINES /* optimize save-lines feature */ 641#endif 642 643#ifndef OPT_SCO_FUNC_KEYS 644#define OPT_SCO_FUNC_KEYS 0 /* true if xterm supports SCO-style function keys */ 645#endif 646 647#ifndef OPT_SUN_FUNC_KEYS 648#define OPT_SUN_FUNC_KEYS 1 /* true if xterm supports Sun-style function keys */ 649#endif 650 651#ifndef OPT_SCROLL_LOCK 652#define OPT_SCROLL_LOCK 1 /* true if xterm interprets fontsize-shifting */ 653#endif 654 655#ifndef OPT_SELECT_REGEX 656#define OPT_SELECT_REGEX 0 /* true if xterm supports regular-expression selects */ 657#endif 658 659#ifndef OPT_SESSION_MGT 660#if defined(XtNdieCallback) && defined(XtNsaveCallback) 661#define OPT_SESSION_MGT 1 662#else 663#define OPT_SESSION_MGT 0 664#endif 665#endif 666 667#ifndef OPT_SHIFT_FONTS 668#define OPT_SHIFT_FONTS 0 /* true if xterm interprets fontsize-shifting */ 669#endif 670 671#ifndef OPT_SUNPC_KBD 672#define OPT_SUNPC_KBD 1 /* true if xterm supports Sun/PC keyboard map */ 673#endif 674 675#ifndef OPT_TCAP_FKEYS 676#define OPT_TCAP_FKEYS 0 /* true for experimental termcap function-keys */ 677#endif 678 679#ifndef OPT_TCAP_QUERY 680#define OPT_TCAP_QUERY 0 /* true for experimental termcap query */ 681#endif 682 683#ifndef OPT_TEK4014 684#define OPT_TEK4014 1 /* true if we're using tek4014 emulation */ 685#endif 686 687#ifndef OPT_TOOLBAR 688#define OPT_TOOLBAR 0 /* true if xterm supports toolbar menus */ 689#endif 690 691#ifndef OPT_TRACE 692#define OPT_TRACE 0 /* true if we're using debugging traces */ 693#endif 694 695#ifndef OPT_TRACE_FLAGS 696#define OPT_TRACE_FLAGS 0 /* additional tracing used for SCRN_BUF_FLAGS */ 697#endif 698 699#ifndef OPT_VT52_MODE 700#define OPT_VT52_MODE 1 /* true if xterm supports VT52 emulation */ 701#endif 702 703#ifndef OPT_WIDE_CHARS 704#define OPT_WIDE_CHARS 0 /* true if xterm supports 16-bit characters */ 705#endif 706 707#ifndef OPT_WIDER_ICHAR 708#define OPT_WIDER_ICHAR 1 /* true if xterm uses 32-bits for wide-chars */ 709#endif 710 711#ifndef OPT_XMC_GLITCH 712#define OPT_XMC_GLITCH 0 /* true if xterm supports xmc (magic cookie glitch) */ 713#endif 714 715#ifndef OPT_ZICONBEEP 716#define OPT_ZICONBEEP 1 /* true if xterm supports "-ziconbeep" option */ 717#endif 718 719/***====================================================================***/ 720 721#if OPT_AIX_COLORS && !OPT_ISO_COLORS 722/* You must have ANSI/ISO colors to support AIX colors */ 723#undef OPT_AIX_COLORS 724#define OPT_AIX_COLORS 0 725#endif 726 727#if OPT_COLOR_RES && !OPT_ISO_COLORS 728/* You must have ANSI/ISO colors to support ColorRes logic */ 729#undef OPT_COLOR_RES 730#define OPT_COLOR_RES 0 731#endif 732 733#if OPT_256_COLORS && (OPT_WIDE_CHARS || OPT_RENDERFONT || OPT_XMC_GLITCH) 734/* It's actually more complicated than that - but by trimming options you can 735 * have 256 color resources though. 736 */ 737#define OPT_COLOR_RES2 1 738#else 739#define OPT_COLOR_RES2 0 740#endif 741 742#if OPT_PASTE64 && !OPT_READLINE 743/* OPT_PASTE64 uses logic from OPT_READLINE */ 744#undef OPT_READLINE 745#define OPT_READLINE 1 746#endif 747 748#if OPT_PC_COLORS && !OPT_ISO_COLORS 749/* You must have ANSI/ISO colors to support PC colors */ 750#undef OPT_PC_COLORS 751#define OPT_PC_COLORS 0 752#endif 753 754#if OPT_PRINT_COLORS && !OPT_ISO_COLORS 755/* You must have ANSI/ISO colors to be able to print them */ 756#undef OPT_PRINT_COLORS 757#define OPT_PRINT_COLORS 0 758#endif 759 760#if OPT_256_COLORS && !OPT_ISO_COLORS 761/* You must have ANSI/ISO colors to support 256 colors */ 762#undef OPT_256_COLORS 763#define OPT_256_COLORS 0 764#endif 765 766#if OPT_88_COLORS && !OPT_ISO_COLORS 767/* You must have ANSI/ISO colors to support 88 colors */ 768#undef OPT_88_COLORS 769#define OPT_88_COLORS 0 770#endif 771 772#if OPT_88_COLORS && OPT_256_COLORS 773/* 256 colors supersedes 88 colors */ 774#undef OPT_88_COLORS 775#define OPT_88_COLORS 0 776#endif 777 778/***====================================================================***/ 779 780/* 781 * Indices for menu_font_names[][] 782 */ 783typedef enum { 784 fNorm = 0 /* normal font */ 785 , fBold /* bold font */ 786#if OPT_WIDE_CHARS 787 , fWide /* double-width font */ 788 , fWBold /* double-width bold font */ 789#endif 790 , fMAX 791} VTFontEnum; 792 793/* 794 * Indices for cachedGCs.c (unrelated to VTFontEnum). 795 */ 796typedef enum { 797 gcNorm = 0 798 , gcBold 799 , gcNormReverse 800 , gcBoldReverse 801#if OPT_BOX_CHARS 802 , gcLine 803 , gcDots 804#endif 805#if OPT_DEC_CHRSET 806 , gcCNorm 807 , gcCBold 808#endif 809#if OPT_WIDE_CHARS 810 , gcWide 811 , gcWBold 812 , gcWideReverse 813 , gcWBoldReverse 814#endif 815 , gcVTcursNormal 816 , gcVTcursFilled 817 , gcVTcursReverse 818 , gcVTcursOutline 819#if OPT_TEK4014 820 , gcTKcurs 821#endif 822 , gcMAX 823} CgsEnum; 824 825#define for_each_text_gc(n) for (n = gcNorm; n < gcVTcursNormal; ++n) 826#define for_each_curs_gc(n) for (n = gcVTcursNormal; n <= gcVTcursOutline; ++n) 827#define for_each_gc(n) for (n = gcNorm; n < gcMAX; ++n) 828 829/* 830 * Indices for the normal terminal colors in screen.Tcolors[]. 831 * See also OscTextColors, which has corresponding values. 832 */ 833typedef enum { 834 TEXT_FG = 0 /* text foreground */ 835 , TEXT_BG /* text background */ 836 , TEXT_CURSOR /* text cursor */ 837 , MOUSE_FG /* mouse foreground */ 838 , MOUSE_BG /* mouse background */ 839#if OPT_TEK4014 840 , TEK_FG /* tektronix foreground */ 841 , TEK_BG /* tektronix background */ 842 , TEK_CURSOR /* tektronix cursor */ 843#endif 844#if OPT_HIGHLIGHT_COLOR 845 , HIGHLIGHT_BG /* highlight background */ 846 , HIGHLIGHT_FG /* highlight foreground */ 847#endif 848 , NCOLORS /* total number of colors */ 849} TermColors; 850 851/* 852 * Constants for titleModes resource 853 */ 854typedef enum { 855 tmSetBase16 = 1 /* set title using hex-string */ 856 , tmGetBase16 = 2 /* get title using hex-string */ 857#if OPT_WIDE_CHARS 858 , tmSetUtf8 = 4 /* like utf8Title, but controllable */ 859 , tmGetUtf8 = 8 /* retrieve title encoded as UTF-8 */ 860#endif 861} TitleModes; 862 863#define IsTitleMode(xw,mode) (((xw)->screen.title_modes & mode) != 0) 864 865/* indices for mapping multiple clicks to selection types */ 866typedef enum { 867 Select_CHAR=0 868 ,Select_WORD 869 ,Select_LINE 870 ,Select_GROUP 871 ,Select_PAGE 872 ,Select_ALL 873#if OPT_SELECT_REGEX 874 ,Select_REGEX 875#endif 876 ,NSELECTUNITS 877} SelectUnit; 878 879typedef enum { 880 ecSetColor = 1 881 , ecGetColor 882 , ecGetAnsiColor 883 , ecLAST 884} ColorOps; 885 886typedef enum { 887 efSetFont = 1 888 , efGetFont 889 , efLAST 890} FontOps; 891 892typedef enum { 893 esFalse = 0 894 , esTrue 895 , esAlways 896 , esNever 897} FullscreenOps; 898 899typedef enum { 900 etSetTcap = 1 901 , etGetTcap 902 , etLAST 903} TcapOps; 904 905typedef enum { 906 /* 1-21 are chosen to be the same as the control-sequence coding */ 907 ewRestoreWin = 1 908 , ewMinimizeWin = 2 909 , ewSetWinPosition = 3 910 , ewSetWinSizePixels = 4 911 , ewRaiseWin = 5 912 , ewLowerWin = 6 913 , ewRefreshWin = 7 914 , ewSetWinSizeChars = 8 915#if OPT_MAXIMIZE 916 , ewMaximizeWin = 9 917 , ewFullscreenWin = 10 918#endif 919 , ewGetWinState = 11 920 , ewGetWinPosition = 13 921 , ewGetWinSizePixels = 14 922 , ewGetWinSizeChars = 18 923#if OPT_MAXIMIZE 924 , ewGetScreenSizeChars = 19 925#endif 926 , ewGetIconTitle = 20 927 , ewGetWinTitle = 21 928 , ewPushTitle = 22 929 , ewPopTitle = 23 930 /* these do not fit into that scheme, which is why we use an array */ 931 , ewSetWinLines 932 , ewSetXprop 933 , ewGetSelection 934 , ewSetSelection 935 /* get the size of the array... */ 936 , ewLAST 937} WindowOps; 938 939#define COLOR_DEFINED(s,w) ((s)->which & (unsigned) (1<<(w))) 940#define COLOR_VALUE(s,w) ((s)->colors[w]) 941#define SET_COLOR_VALUE(s,w,v) (((s)->colors[w] = (v)), UIntSet((s)->which, (1<<(w)))) 942 943#define COLOR_NAME(s,w) ((s)->names[w]) 944#define SET_COLOR_NAME(s,w,v) (((s)->names[w] = (v)), ((s)->which |= (unsigned) (1<<(w)))) 945 946#define UNDEFINE_COLOR(s,w) ((s)->which &= (~((w)<<1))) 947 948/***====================================================================***/ 949 950#if OPT_ISO_COLORS 951#define TERM_COLOR_FLAGS(xw) ((xw)->flags & (FG_COLOR|BG_COLOR)) 952#define COLOR_0 0 953#define COLOR_1 1 954#define COLOR_2 2 955#define COLOR_3 3 956#define COLOR_4 4 957#define COLOR_5 5 958#define COLOR_6 6 959#define COLOR_7 7 960#define COLOR_8 8 961#define COLOR_9 9 962#define COLOR_10 10 963#define COLOR_11 11 964#define COLOR_12 12 965#define COLOR_13 13 966#define COLOR_14 14 967#define COLOR_15 15 968#define MIN_ANSI_COLORS 16 969 970#if OPT_256_COLORS 971# define NUM_ANSI_COLORS 256 972#elif OPT_88_COLORS 973# define NUM_ANSI_COLORS 88 974#else 975# define NUM_ANSI_COLORS MIN_ANSI_COLORS 976#endif 977 978#if NUM_ANSI_COLORS > MIN_ANSI_COLORS 979# define OPT_EXT_COLORS 1 980#else 981# define OPT_EXT_COLORS 0 982#endif 983 984#define COLOR_BD (NUM_ANSI_COLORS) /* BOLD */ 985#define COLOR_UL (NUM_ANSI_COLORS+1) /* UNDERLINE */ 986#define COLOR_BL (NUM_ANSI_COLORS+2) /* BLINK */ 987#define COLOR_RV (NUM_ANSI_COLORS+3) /* REVERSE */ 988#define MAXCOLORS (NUM_ANSI_COLORS+4) 989#ifndef DFT_COLORMODE 990#define DFT_COLORMODE True /* default colorMode resource */ 991#endif 992 993#define ReverseOrHilite(screen,flags,hilite) \ 994 (( screen->colorRVMode && hilite ) || \ 995 ( !screen->colorRVMode && \ 996 (( (flags & INVERSE) && !hilite) || \ 997 (!(flags & INVERSE) && hilite)) )) 998 999/* Define a fake XK code, we need it for the fake color response in 1000 * xtermcapKeycode(). */ 1001#if OPT_TCAP_QUERY && OPT_ISO_COLORS 1002# define XK_COLORS 0x0003 1003#endif 1004 1005#else /* !OPT_ISO_COLORS */ 1006 1007#define TERM_COLOR_FLAGS(xw) 0 1008 1009#define ReverseOrHilite(screen,flags,hilite) \ 1010 (( (flags & INVERSE) && !hilite) || \ 1011 (!(flags & INVERSE) && hilite)) 1012 1013#endif /* OPT_ISO_COLORS */ 1014 1015# define XK_TCAPNAME 0x0004 1016 1017#if OPT_AIX_COLORS 1018#define if_OPT_AIX_COLORS(screen, code) if(screen->colorMode) code 1019#else 1020#define if_OPT_AIX_COLORS(screen, code) /* nothing */ 1021#endif 1022 1023#if OPT_256_COLORS || OPT_88_COLORS || OPT_ISO_COLORS 1024# define if_OPT_ISO_COLORS(screen, code) if (screen->colorMode) code 1025#else 1026# define if_OPT_ISO_COLORS(screen, code) /* nothing */ 1027#endif 1028 1029#define COLOR_RES_NAME(root) "color" root 1030 1031#if OPT_COLOR_CLASS 1032#define COLOR_RES_CLASS(root) "Color" root 1033#else 1034#define COLOR_RES_CLASS(root) XtCForeground 1035#endif 1036 1037#if OPT_COLOR_RES 1038#define COLOR_RES(root,offset,value) Sres(COLOR_RES_NAME(root), COLOR_RES_CLASS(root), offset.resource, value) 1039#define COLOR_RES2(name,class,offset,value) Sres(name, class, offset.resource, value) 1040#else 1041#define COLOR_RES(root,offset,value) Cres(COLOR_RES_NAME(root), COLOR_RES_CLASS(root), offset, value) 1042#define COLOR_RES2(name,class,offset,value) Cres(name, class, offset, value) 1043#endif 1044 1045#define CLICK_RES_NAME(count) "on" count "Clicks" 1046#define CLICK_RES_CLASS(count) "On" count "Clicks" 1047#define CLICK_RES(count,offset,value) Sres(CLICK_RES_NAME(count), CLICK_RES_CLASS(count), offset, value) 1048 1049/***====================================================================***/ 1050 1051#if OPT_DEC_CHRSET 1052#define if_OPT_DEC_CHRSET(code) code 1053 /* Use 2 bits for encoding the double high/wide sense of characters */ 1054#define CSET_SWL 0 1055#define CSET_DHL_TOP 1 1056#define CSET_DHL_BOT 2 1057#define CSET_DWL 3 1058#define NUM_CHRSET 8 /* normal/bold and 4 CSET_xxx values */ 1059 1060 /* Use remaining bits for encoding the other character-sets */ 1061#define CSET_NORMAL(code) ((code) == CSET_SWL) 1062#define CSET_DOUBLE(code) (!CSET_NORMAL(code) && !CSET_EXTEND(code)) 1063#define CSET_EXTEND(code) ((int)(code) > CSET_DWL) 1064 1065#define DBLCS_BITS 4 1066#define DBLCS_MASK BITS2MASK(DBLCS_BITS) 1067 1068#define GetLineDblCS(ld) (((ld)->bufHead >> LINEFLAG_BITS) & DBLCS_MASK) 1069#define SetLineDblCS(ld,cs) (ld)->bufHead = (RowData) ((ld->bufHead & LINEFLAG_MASK) | (cs << LINEFLAG_BITS)) 1070 1071#define LineCharSet(screen, ld) \ 1072 ((CSET_DOUBLE(GetLineDblCS(ld))) \ 1073 ? GetLineDblCS(ld) \ 1074 : (screen)->cur_chrset) 1075#define LineMaxCol(screen, ld) \ 1076 (CSET_DOUBLE(GetLineDblCS(ld)) \ 1077 ? (screen->max_col / 2) \ 1078 : (screen->max_col)) 1079#define LineCursorX(screen, ld, col) \ 1080 (CSET_DOUBLE(GetLineDblCS(ld)) \ 1081 ? CursorX(screen, 2*(col)) \ 1082 : CursorX(screen, (col))) 1083#define LineFontWidth(screen, ld) \ 1084 (CSET_DOUBLE(GetLineDblCS(ld)) \ 1085 ? 2*FontWidth(screen) \ 1086 : FontWidth(screen)) 1087#else 1088 1089#define if_OPT_DEC_CHRSET(code) /*nothing*/ 1090 1091#define GetLineDblCS(ld) 0 1092 1093#define LineCharSet(screen, ld) 0 1094#define LineMaxCol(screen, ld) screen->max_col 1095#define LineCursorX(screen, ld, col) CursorX(screen, col) 1096#define LineFontWidth(screen, ld) FontWidth(screen) 1097 1098#endif 1099 1100#if OPT_LUIT_PROG && !OPT_WIDE_CHARS 1101#error Luit requires the wide-chars configuration 1102#endif 1103 1104/***====================================================================***/ 1105 1106#if OPT_EBCDIC 1107extern int E2A(int); 1108extern int A2E(int); 1109#else 1110#define E2A(a) (a) 1111#define A2E(a) (a) 1112#endif 1113 1114#define CONTROL(a) (A2E(E2A(a)&037)) 1115 1116/***====================================================================***/ 1117 1118#if OPT_TEK4014 1119#define TEK4014_ACTIVE(xw) ((xw)->misc.TekEmu) 1120#define TEK4014_SHOWN(xw) ((xw)->misc.Tshow) 1121#define CURRENT_EMU_VAL(tek,vt) (TEK4014_ACTIVE(term) ? tek : vt) 1122#define CURRENT_EMU() CURRENT_EMU_VAL((Widget)tekWidget, (Widget)term) 1123#else 1124#define TEK4014_ACTIVE(screen) 0 1125#define TEK4014_SHOWN(xw) 0 1126#define CURRENT_EMU_VAL(tek,vt) (vt) 1127#define CURRENT_EMU() ((Widget)term) 1128#endif 1129 1130/***====================================================================***/ 1131 1132#if OPT_TOOLBAR 1133#define SHELL_OF(widget) XtParent(XtParent(widget)) 1134#else 1135#define SHELL_OF(widget) XtParent(widget) 1136#endif 1137 1138/***====================================================================***/ 1139 1140#if OPT_VT52_MODE 1141#define if_OPT_VT52_MODE(screen, code) if(screen->vtXX_level == 0) code 1142#else 1143#define if_OPT_VT52_MODE(screen, code) /* nothing */ 1144#endif 1145 1146/***====================================================================***/ 1147 1148#if OPT_XMC_GLITCH 1149#define if_OPT_XMC_GLITCH(screen, code) if(screen->xmc_glitch) code 1150#define XMC_GLITCH 1 /* the character we'll show */ 1151#define XMC_FLAGS (INVERSE|UNDERLINE|BOLD|BLINK) 1152#else 1153#define if_OPT_XMC_GLITCH(screen, code) /* nothing */ 1154#endif 1155 1156/***====================================================================***/ 1157 1158#define LO_BYTE(ch) CharOf((ch) & 0xff) 1159#define HI_BYTE(ch) CharOf((ch) >> 8) 1160 1161#if OPT_WIDE_CHARS 1162#define if_OPT_WIDE_CHARS(screen, code) if(screen->wide_chars) code 1163#define if_WIDE_OR_NARROW(screen, wide, narrow) if(screen->wide_chars) wide else narrow 1164#if OPT_WIDER_ICHAR 1165typedef unsigned IChar; /* for 8-21 bit characters */ 1166#else 1167typedef unsigned short IChar; /* for 8-16 bit characters */ 1168#endif 1169#else 1170#define if_OPT_WIDE_CHARS(screen, code) /* nothing */ 1171#define if_WIDE_OR_NARROW(screen, wide, narrow) narrow 1172typedef unsigned char IChar; /* for 8-bit characters */ 1173#endif 1174 1175/***====================================================================***/ 1176 1177#ifndef RES_OFFSET 1178#define RES_OFFSET(offset) XtOffsetOf(XtermWidgetRec, offset) 1179#endif 1180 1181#define RES_NAME(name) name 1182#define RES_CLASS(name) name 1183 1184#define Bres(name, class, offset, dftvalue) \ 1185 {RES_NAME(name), RES_CLASS(class), XtRBoolean, sizeof(Boolean), \ 1186 RES_OFFSET(offset), XtRImmediate, (XtPointer) dftvalue} 1187 1188#define Cres(name, class, offset, dftvalue) \ 1189 {RES_NAME(name), RES_CLASS(class), XtRPixel, sizeof(Pixel), \ 1190 RES_OFFSET(offset), XtRString, (XtPointer) dftvalue} 1191 1192#define Tres(name, class, offset, dftvalue) \ 1193 COLOR_RES2(name, class, screen.Tcolors[offset], dftvalue) \ 1194 1195#define Fres(name, class, offset, dftvalue) \ 1196 {RES_NAME(name), RES_CLASS(class), XtRFontStruct, sizeof(XFontStruct *), \ 1197 RES_OFFSET(offset), XtRString, (XtPointer) dftvalue} 1198 1199#define Ires(name, class, offset, dftvalue) \ 1200 {RES_NAME(name), RES_CLASS(class), XtRInt, sizeof(int), \ 1201 RES_OFFSET(offset), XtRImmediate, (XtPointer) dftvalue} 1202 1203#define Dres(name, class, offset, dftvalue) \ 1204 {RES_NAME(name), RES_CLASS(class), XtRFloat, sizeof(float), \ 1205 RES_OFFSET(offset), XtRString, (XtPointer) dftvalue} 1206 1207#define Sres(name, class, offset, dftvalue) \ 1208 {RES_NAME(name), RES_CLASS(class), XtRString, sizeof(char *), \ 1209 RES_OFFSET(offset), XtRString, (XtPointer) dftvalue} 1210 1211#define Wres(name, class, offset, dftvalue) \ 1212 {RES_NAME(name), RES_CLASS(class), XtRWidget, sizeof(Widget), \ 1213 RES_OFFSET(offset), XtRWidget, (XtPointer) dftvalue} 1214 1215/***====================================================================***/ 1216 1217#define FRG_SIZE resource.minBufSize 1218#define BUF_SIZE resource.maxBufSize 1219 1220typedef struct { 1221 Char * next; 1222 Char * last; 1223 int update; /* HandleInterpret */ 1224#if OPT_WIDE_CHARS 1225 IChar utf_data; /* resulting character */ 1226 int utf_size; /* ...number of bytes decoded */ 1227 Char *write_buf; 1228 unsigned write_len; 1229#endif 1230 Char buffer[1]; 1231} PtyData; 1232 1233/***====================================================================***/ 1234 1235#if OPT_ISO_COLORS 1236#if OPT_256_COLORS || OPT_88_COLORS 1237#define COLOR_BITS 8 1238typedef unsigned short CellColor; 1239#else 1240#define COLOR_BITS 4 1241typedef Char CellColor; 1242#endif 1243#else 1244typedef int CellColor; 1245#endif 1246 1247#define BITS2MASK(b) ((1 << b) - 1) 1248 1249#define COLOR_MASK BITS2MASK(COLOR_BITS) 1250 1251#define GetCellColorFG(src) ((src) & COLOR_MASK) 1252#define GetCellColorBG(src) (((src) >> COLOR_BITS) & COLOR_MASK) 1253 1254typedef Char RowData; /* wrap/blink, and DEC single-double chars */ 1255 1256#define LINEFLAG_BITS 4 1257#define LINEFLAG_MASK BITS2MASK(LINEFLAG_BITS) 1258 1259#define GetLineFlags(ld) ((ld)->bufHead & LINEFLAG_MASK) 1260 1261#if OPT_DEC_CHRSET 1262#define SetLineFlags(ld,xx) (ld)->bufHead = (RowData) ((ld->bufHead & (DBLCS_MASK << LINEFLAG_BITS)) | (xx & LINEFLAG_MASK)) 1263#else 1264#define SetLineFlags(ld,xx) (ld)->bufHead = (RowData) (xx & LINEFLAG_MASK) 1265#endif 1266 1267typedef IChar CharData; 1268 1269/* 1270 * This is the xterm line-data/scrollback structure. 1271 */ 1272typedef struct { 1273 Dimension lineSize; /* number of columns in this row */ 1274 RowData bufHead; /* flag for wrapped lines */ 1275#if OPT_WIDE_CHARS 1276 Char combSize; /* number of items in combData[] */ 1277#endif 1278 Char *attribs; /* video attributes */ 1279#if OPT_ISO_COLORS 1280 CellColor *color; /* foreground+background color numbers */ 1281#endif 1282 CharData *charData; /* cell's base character */ 1283 CharData *combData[1]; /* first enum past fixed-offsets */ 1284} LineData; 1285 1286/* 1287 * We use CellData in a few places, when copying a cell's data to a temporary 1288 * variable. 1289 */ 1290typedef struct { 1291 Char attribs; 1292#if OPT_WIDE_CHARS 1293 Char combSize; /* number of items in combData[] */ 1294#endif 1295#if OPT_ISO_COLORS 1296 CellColor color; /* color-array */ 1297#endif 1298 CharData charData; /* cell's base character */ 1299 CharData combData[1]; /* array of combining chars */ 1300} CellData; 1301 1302#define for_each_combData(off, ld) for (off = 0; off < ld->combSize; ++off) 1303 1304/* 1305 * Accommodate older compilers by not using variable-length arrays. 1306 */ 1307#define SizeOfLineData offsetof(LineData, combData) 1308#define SizeOfCellData offsetof(CellData, combData) 1309 1310 /* 1311 * A "row" is the index within the visible part of the screen, and an 1312 * "inx" is the index within the whole set of scrollable lines. 1313 */ 1314#define ROW2INX(screen, row) ((row) + (screen)->topline) 1315#define INX2ROW(screen, inx) ((inx) - (screen)->topline) 1316 1317#define ROW2ABS(screen, row) ((row) + (screen)->savedlines) 1318#define INX2ABS(screen, inx) ROW2ABS(screen, INX2ROW(screen, inx)) 1319 1320#define okScrnRow(screen, row) \ 1321 ((row) <= ((screen)->max_row - (screen)->topline) \ 1322 && (row) >= -((screen)->savedlines)) 1323 1324 /* 1325 * Cache data for "proportional" and other fonts containing a mixture 1326 * of widths. 1327 */ 1328typedef struct { 1329 Bool mixed; 1330 Dimension min_width; /* nominal cell width for 0..255 */ 1331 Dimension max_width; /* maximum cell width */ 1332} FontMap; 1333 1334typedef struct { 1335 unsigned chrset; 1336 unsigned flags; 1337 XFontStruct * fs; 1338 char * fn; 1339 FontMap map; 1340 Char known_missing[256]; 1341} XTermFonts; 1342 1343#if OPT_RENDERFONT 1344typedef enum { 1345 erFalse = 0 1346 , erTrue 1347 , erDefault 1348 , erLast 1349} RenderFont; 1350 1351#define DefaultRenderFont(xw) \ 1352 if ((xw)->misc.render_font == erDefault) \ 1353 (xw)->misc.render_font = erFalse 1354 1355typedef struct { 1356 XftFont * font; 1357 FontMap map; 1358} XTermXftFonts; 1359#endif 1360 1361typedef struct { 1362 int top; 1363 int left; 1364 int bottom; 1365 int right; 1366} XTermRect; 1367 1368 /* indices into save_modes[] */ 1369typedef enum { 1370 DP_CRS_VISIBLE, 1371 DP_DECANM, 1372 DP_DECARM, 1373 DP_DECAWM, 1374 DP_DECBKM, 1375 DP_DECCKM, 1376 DP_DECCOLM, /* IN132COLUMNS */ 1377 DP_DECOM, 1378 DP_DECPEX, 1379 DP_DECPFF, 1380 DP_DECSCLM, 1381 DP_DECSCNM, 1382 DP_DECTCEM, 1383 DP_DECTEK, 1384 DP_PRN_EXTENT, 1385 DP_PRN_FORMFEED, 1386 DP_X_ALTSCRN, 1387 DP_X_DECCOLM, 1388 DP_X_LOGGING, 1389 DP_X_MARGIN, 1390 DP_X_MORE, 1391 DP_X_MOUSE, 1392 DP_X_EXT_MOUSE, 1393 DP_X_REVWRAP, 1394 DP_X_X10MSE, 1395#if OPT_BLINK_CURS 1396 DP_CRS_BLINK, 1397#endif 1398#if OPT_FOCUS_EVENT 1399 DP_X_FOCUS, 1400#endif 1401#if OPT_TOOLBAR 1402 DP_TOOLBAR, 1403#endif 1404 DP_LAST 1405} SaveModes; 1406 1407#define DoSM(code,value) screen->save_modes[code] = (unsigned) (value) 1408#define DoRM(code,value) value = (Boolean) screen->save_modes[code] 1409#define DoRM0(code,value) value = screen->save_modes[code] 1410 1411 /* index into vt_shell[] or tek_shell[] */ 1412typedef enum { 1413 noMenu = -1, 1414 mainMenu, 1415 vtMenu, 1416 fontMenu, 1417#if OPT_TEK4014 1418 tekMenu 1419#endif 1420} MenuIndex; 1421 1422typedef enum { 1423 bvOff = -1, 1424 bvLow = 0, 1425 bvHigh 1426} BellVolume; 1427 1428#define NUM_POPUP_MENUS 4 1429 1430#if OPT_COLOR_RES 1431typedef struct { 1432 String resource; 1433 Pixel value; 1434 int mode; /* -1=invalid, 0=unset, 1=set */ 1435} ColorRes; 1436#else 1437#define ColorRes Pixel 1438#endif 1439 1440/* these are set in getPrinterFlags */ 1441typedef struct { 1442 int printer_extent; /* print complete page */ 1443 int printer_formfeed; /* print formfeed per function */ 1444 int printer_newline; /* print newline per function */ 1445 int print_attributes; /* 0=off, 1=normal, 2=color */ 1446} PrinterFlags; 1447 1448typedef struct { 1449 unsigned which; /* must have NCOLORS bits */ 1450 Pixel colors[NCOLORS]; 1451 char *names[NCOLORS]; 1452} ScrnColors; 1453 1454typedef struct { 1455 Boolean saved; 1456 int row; 1457 int col; 1458 unsigned flags; /* VTxxx saves graphics rendition */ 1459 Char curgl; 1460 Char curgr; 1461 Char gsets[4]; 1462#if OPT_ISO_COLORS 1463 int cur_foreground; /* current foreground color */ 1464 int cur_background; /* current background color */ 1465 int sgr_foreground; /* current SGR foreground color */ 1466 int sgr_background; /* current SGR background color */ 1467 Boolean sgr_extended; /* SGR set with extended codes? */ 1468#endif 1469} SavedCursor; 1470 1471typedef struct _SaveTitle { 1472 struct _SaveTitle *next; 1473 char *iconName; 1474 char *windowName; 1475} SaveTitle; 1476 1477#define SAVED_CURSORS 2 1478 1479typedef struct { 1480 int width; /* if > 0, width of scrollbar, */ 1481 /* and scrollbar is showing */ 1482 Boolean rv_cached; /* see ScrollBarReverseVideo */ 1483 int rv_active; /* ...current reverse-video */ 1484 Pixel bg; /* ...cached background color */ 1485 Pixel fg; /* ...cached foreground color */ 1486 Pixel bdr; /* ...cached border color */ 1487 Pixmap bdpix; /* ...cached border pixmap */ 1488} SbInfo; 1489 1490#if OPT_TOOLBAR 1491typedef struct { 1492 Widget menu_bar; /* toolbar, if initialized */ 1493 Dimension menu_height; /* ...and its height */ 1494 Dimension menu_border; /* ...and its border */ 1495} TbInfo; 1496#define VT100_TB_INFO(name) screen.fullVwin.tb_info.name 1497#endif 1498 1499typedef struct { 1500 Window window; /* X window id */ 1501 int width; /* width of columns */ 1502 int height; /* height of rows */ 1503 Dimension fullwidth; /* full width of window */ 1504 Dimension fullheight; /* full height of window */ 1505 int f_width; /* width of fonts in pixels */ 1506 int f_height; /* height of fonts in pixels */ 1507 int f_ascent; /* ascent of font in pixels */ 1508 int f_descent; /* descent of font in pixels */ 1509 SbInfo sb_info; 1510#if OPT_TOOLBAR 1511 Boolean active; /* true if toolbars are used */ 1512 TbInfo tb_info; /* toolbar information */ 1513#endif 1514} VTwin; 1515 1516typedef struct { 1517 Window window; /* X window id */ 1518 int width; /* width of columns */ 1519 int height; /* height of rows */ 1520 Dimension fullwidth; /* full width of window */ 1521 Dimension fullheight; /* full height of window */ 1522 double tekscale; /* scale factor Tek -> vs100 */ 1523} TKwin; 1524 1525typedef struct { 1526/* These parameters apply to both windows */ 1527 Display *display; /* X display for screen */ 1528 int respond; /* socket for responses 1529 (position report, etc.) */ 1530/* These parameters apply to VT100 window */ 1531 IChar unparse_bfr[256]; 1532 unsigned unparse_len; 1533 1534#if OPT_TCAP_QUERY 1535 int tc_query_code; 1536 Bool tc_query_fkey; 1537#endif 1538 pid_t pid; /* pid of process on far side */ 1539 uid_t uid; /* user id of actual person */ 1540 gid_t gid; /* group id of actual person */ 1541 ColorRes Tcolors[NCOLORS]; /* terminal colors */ 1542#if OPT_HIGHLIGHT_COLOR 1543 Boolean hilite_color; /* hilite colors override */ 1544 Boolean hilite_reverse; /* hilite overrides reverse */ 1545#endif 1546#if OPT_ISO_COLORS 1547 ColorRes Acolors[MAXCOLORS]; /* ANSI color emulation */ 1548 int veryBoldColors; /* modifier for boldColors */ 1549 Boolean boldColors; /* can we make bold colors? */ 1550 Boolean colorMode; /* are we using color mode? */ 1551 Boolean colorULMode; /* use color for underline? */ 1552 Boolean italicULMode; /* italic font for underline? */ 1553 Boolean colorBDMode; /* use color for bold? */ 1554 Boolean colorBLMode; /* use color for blink? */ 1555 Boolean colorRVMode; /* use color for reverse? */ 1556 Boolean colorAttrMode; /* prefer colorUL/BD to SGR */ 1557#endif 1558#if OPT_DEC_CHRSET 1559 Boolean font_doublesize;/* enable font-scaling */ 1560 int cache_doublesize;/* limit of our cache */ 1561 Char cur_chrset; /* character-set index & code */ 1562 int fonts_used; /* count items in double_fonts */ 1563 XTermFonts double_fonts[NUM_CHRSET]; 1564#endif 1565#if OPT_DEC_RECTOPS 1566 int cur_decsace; /* parameter for DECSACE */ 1567#endif 1568#if OPT_WIDE_CHARS 1569 Boolean wide_chars; /* true when 16-bit chars */ 1570 Boolean vt100_graphics; /* true to allow vt100-graphics */ 1571 Boolean utf8_inparse; /* true to enable UTF-8 parser */ 1572 int utf8_mode; /* use UTF-8 decode/encode: 0-2 */ 1573 int max_combining; /* maximum # of combining chars */ 1574 Boolean utf8_latin1; /* use UTF-8 with Latin-1 bias */ 1575 Boolean utf8_title; /* use UTF-8 titles */ 1576 int latin9_mode; /* poor man's luit, latin9 */ 1577 int unicode_font; /* font uses unicode encoding */ 1578 int utf_count; /* state of utf_char */ 1579 IChar utf_char; /* in-progress character */ 1580 int last_written_col; 1581 int last_written_row; 1582 TypedBuffer(XChar2b); 1583 TypedBuffer(char); 1584#endif 1585#if OPT_BROKEN_OSC 1586 Boolean brokenLinuxOSC; /* true to ignore Linux palette ctls */ 1587#endif 1588#if OPT_BROKEN_ST 1589 Boolean brokenStringTerm; /* true to match old OSC parse */ 1590#endif 1591#if OPT_C1_PRINT || OPT_WIDE_CHARS 1592 Boolean c1_printable; /* true if we treat C1 as print */ 1593#endif 1594 int border; /* inner border */ 1595 int scrollBarBorder; /* scrollBar border */ 1596 long event_mask; 1597 unsigned send_mouse_pos; /* user wants mouse transition */ 1598 /* and position information */ 1599 Boolean ext_mode_mouse; /* support large terminals */ 1600 Boolean send_focus_pos; /* user wants focus in/out info */ 1601 Boolean quiet_grab; /* true if no cursor change on focus */ 1602#if OPT_PASTE64 1603 Cardinal base64_paste; /* set to send paste in base64 */ 1604 int base64_final; /* string-terminator for paste */ 1605 /* _qWriteSelectionData expects these to be initialized to zero. 1606 * base64_flush() is the last step of the conversion, it clears these 1607 * variables. 1608 */ 1609 unsigned base64_accu; 1610 unsigned base64_count; 1611 unsigned base64_pad; 1612#endif 1613#if OPT_READLINE 1614 unsigned click1_moves; 1615 unsigned paste_moves; 1616 unsigned dclick3_deletes; 1617 unsigned paste_brackets; 1618 unsigned paste_quotes; 1619 unsigned paste_literal_nl; 1620#endif /* OPT_READLINE */ 1621#if OPT_DEC_LOCATOR 1622 Boolean locator_reset; /* turn mouse off after 1 report? */ 1623 Boolean locator_pixels; /* report in pixels? */ 1624 /* if false, report in cells */ 1625 unsigned locator_events; /* what events to report */ 1626 Boolean loc_filter; /* is filter rectangle active? */ 1627 int loc_filter_top; /* filter rectangle for DEC Locator */ 1628 int loc_filter_left; 1629 int loc_filter_bottom; 1630 int loc_filter_right; 1631#endif /* OPT_DEC_LOCATOR */ 1632 int mouse_button; /* current button pressed */ 1633 int mouse_row; /* ...and its row */ 1634 int mouse_col; /* ...and its column */ 1635 int select; /* xterm selected */ 1636 Boolean bellOnReset; /* bellOnReset */ 1637 Boolean visualbell; /* visual bell mode */ 1638 Boolean poponbell; /* pop on bell mode */ 1639 1640 Boolean allowColorOps; /* ColorOps mode */ 1641 Boolean allowFontOps; /* FontOps mode */ 1642 Boolean allowSendEvents;/* SendEvent mode */ 1643 Boolean allowTcapOps; /* TcapOps mode */ 1644 Boolean allowTitleOps; /* TitleOps mode */ 1645 Boolean allowWindowOps; /* WindowOps mode */ 1646 1647 Boolean allowColorOp0; /* initial ColorOps mode */ 1648 Boolean allowFontOp0; /* initial FontOps mode */ 1649 Boolean allowSendEvent0;/* initial SendEvent mode */ 1650 Boolean allowTcapOp0; /* initial TcapOps mode */ 1651 Boolean allowTitleOp0; /* initial TitleOps mode */ 1652 Boolean allowWindowOp0; /* initial WindowOps mode */ 1653 1654 String disallowedColorOps; 1655 char disallow_color_ops[ecLAST]; 1656 1657 String disallowedFontOps; 1658 char disallow_font_ops[efLAST]; 1659 1660 String disallowedTcapOps; 1661 char disallow_tcap_ops[etLAST]; 1662 1663 String disallowedWinOps; 1664 char disallow_win_ops[ewLAST]; 1665 1666 Boolean awaitInput; /* select-timeout mode */ 1667 Boolean grabbedKbd; /* keyboard is grabbed */ 1668#if OPT_MAXIMIZE 1669 Boolean fullscreen; /* window is fullscreen */ 1670#endif 1671#ifdef ALLOWLOGGING 1672 int logging; /* logging mode */ 1673 int logfd; /* file descriptor of log */ 1674 char *logfile; /* log file name */ 1675 Char *logstart; /* current start of log buffer */ 1676#endif 1677 int inhibit; /* flags for inhibiting changes */ 1678 1679/* VT window parameters */ 1680 Boolean Vshow; /* VT window showing */ 1681 VTwin fullVwin; 1682#ifndef NO_ACTIVE_ICON 1683 VTwin iconVwin; 1684 VTwin *whichVwin; 1685#endif /* NO_ACTIVE_ICON */ 1686 1687 int pointer_mode; /* when to use hidden_cursor */ 1688 Boolean hide_pointer; /* true to use "hidden_cursor" */ 1689 Cursor pointer_cursor; /* pointer cursor in window */ 1690 Cursor hidden_cursor; /* hidden cursor in window */ 1691 1692 String answer_back; /* response to ENQ */ 1693 String printer_command; /* pipe/shell command string */ 1694 Boolean printer_autoclose; /* close printer when offline */ 1695 Boolean printer_extent; /* print complete page */ 1696 Boolean printer_formfeed; /* print formfeed per function */ 1697 Boolean printer_newline; /* print newline per function */ 1698 int printer_controlmode; /* 0=off, 1=auto, 2=controller */ 1699 int print_attributes; /* 0=off, 1=normal, 2=color */ 1700 1701 PrinterFlags printer_flags; /* working copy of printer flags */ 1702 1703 Boolean fnt_prop; /* true if proportional fonts */ 1704 Boolean fnt_boxes; /* true if font has box-chars */ 1705 Boolean force_packed; /* true to override proportional */ 1706#if OPT_BOX_CHARS 1707 Boolean force_box_chars;/* true if we assume that */ 1708 Boolean force_all_chars;/* true to outline missing chars */ 1709 Boolean allow_packing; /* true to allow packed-fonts */ 1710#endif 1711 Dimension fnt_wide; 1712 Dimension fnt_high; 1713 XTermFonts fnts[fMAX]; /* normal/bold/etc for terminal */ 1714 Boolean free_bold_box; /* same_font_size's austerity */ 1715#ifndef NO_ACTIVE_ICON 1716 XTermFonts fnt_icon; /* icon font */ 1717 String icon_fontname; /* name of icon font */ 1718 int icon_fontnum; /* number to use for icon font */ 1719#endif /* NO_ACTIVE_ICON */ 1720 int enbolden; /* overstrike for bold font */ 1721 XPoint *box; /* draw unselected cursor */ 1722 1723 int cursor_state; /* ON, OFF, or BLINKED_OFF */ 1724 int cursor_busy; /* do not redraw... */ 1725 Boolean cursor_underline; /* true if cursor is in underline mode */ 1726#if OPT_BLINK_CURS 1727 Boolean cursor_blink; /* cursor blink enable */ 1728 Boolean cursor_blink_res; /* initial cursor blink value */ 1729 Boolean cursor_blink_esc; /* cursor blink escape-state */ 1730#endif 1731#if OPT_BLINK_TEXT 1732 Boolean blink_as_bold; /* text blink disable */ 1733#endif 1734#if OPT_BLINK_CURS || OPT_BLINK_TEXT 1735 int blink_state; /* ON, OFF, or BLINKED_OFF */ 1736 int blink_on; /* cursor on time (msecs) */ 1737 int blink_off; /* cursor off time (msecs) */ 1738 XtIntervalId blink_timer; /* timer-id for cursor-proc */ 1739#endif 1740#if OPT_ZICONBEEP 1741 Boolean zIconBeep_flagged; /* True if icon name was changed */ 1742#endif /* OPT_ZICONBEEP */ 1743 int cursor_GC; /* see ShowCursor() */ 1744 int cursor_set; /* requested state */ 1745 CELL cursorp; /* previous cursor row/column */ 1746 int cur_col; /* current cursor column */ 1747 int cur_row; /* current cursor row */ 1748 int max_col; /* rightmost column */ 1749 int max_row; /* bottom row */ 1750 int top_marg; /* top line of scrolling region */ 1751 int bot_marg; /* bottom line of " " */ 1752 Widget scrollWidget; /* pointer to scrollbar struct */ 1753 /* 1754 * Indices used to keep track of the top of the vt100 window and 1755 * the saved lines, taking scrolling into account. 1756 */ 1757 int topline; /* line number of top, <= 0 */ 1758 long saved_fifo; /* number of lines that've been saved */ 1759 int savedlines; /* number of lines that've been saved */ 1760 int savelines; /* number of lines off top to save */ 1761 int scroll_amt; /* amount to scroll */ 1762 int refresh_amt; /* amount to refresh */ 1763 /* 1764 * Working variables for getLineData(). 1765 */ 1766 size_t lineExtra; /* extra space for combining chars */ 1767 /* 1768 * Pointer to the current visible buffer. 1769 */ 1770 ScrnBuf visbuf; /* ptr to visible screen buf (main) */ 1771 /* 1772 * Data for the normal buffer, which may have saved lines to which 1773 * the user can scroll. 1774 */ 1775 ScrnBuf saveBuf_index; 1776 Char *saveBuf_data; 1777 /* 1778 * Data for visible and alternate buffer. 1779 */ 1780 ScrnBuf editBuf_index[2]; 1781 Char *editBuf_data[2]; 1782 int whichBuf; /* 0/1 for normal/alternate buf */ 1783 Boolean is_running; /* true when buffers are legal */ 1784 /* 1785 * Workspace used for screen operations. 1786 */ 1787 Char **save_ptr; /* workspace for save-pointers */ 1788 size_t save_len; /* ...and its length */ 1789 1790 int scrolllines; /* number of lines to button scroll */ 1791 Boolean scrollttyoutput; /* scroll to bottom on tty output */ 1792 Boolean scrollkey; /* scroll to bottom on key */ 1793 Boolean cursor_moved; /* scrolling makes cursor move */ 1794 1795 Boolean do_wrap; /* true if cursor in last column 1796 and character just output */ 1797 1798 int incopy; /* 0 idle; 1 XCopyArea issued; 1799 -1 first GraphicsExpose seen, 1800 but last not seen */ 1801 int copy_src_x; /* params from last XCopyArea ... */ 1802 int copy_src_y; 1803 unsigned int copy_width; 1804 unsigned int copy_height; 1805 int copy_dest_x; 1806 int copy_dest_y; 1807 1808 Boolean c132; /* allow change to 132 columns */ 1809 Boolean curses; /* kludge line wrap for more */ 1810 Boolean hp_ll_bc; /* kludge HP-style ll for xdb */ 1811 Boolean marginbell; /* true if margin bell on */ 1812 int nmarginbell; /* columns from right margin */ 1813 int bellArmed; /* cursor below bell margin */ 1814 BellVolume marginVolume; /* margin-bell volume */ 1815 BellVolume warningVolume; /* warning-bell volume */ 1816 Boolean multiscroll; /* true if multi-scroll */ 1817 int scrolls; /* outstanding scroll count, 1818 used only with multiscroll */ 1819 SavedCursor sc[SAVED_CURSORS]; /* data for restore cursor */ 1820 unsigned save_modes[DP_LAST]; /* save dec/xterm private modes */ 1821 1822 int title_modes; /* control set/get of titles */ 1823 SaveTitle *save_title; 1824 1825 /* Improved VT100 emulation stuff. */ 1826 String keyboard_dialect; /* default keyboard dialect */ 1827 Char gsets[4]; /* G0 through G3. */ 1828 Char curgl; /* Current GL setting. */ 1829 Char curgr; /* Current GR setting. */ 1830 Char curss; /* Current single shift. */ 1831 String term_id; /* resource for terminal_id */ 1832 int terminal_id; /* 100=vt100, 220=vt220, etc. */ 1833 int vtXX_level; /* 0=vt52, 1,2,3 = vt100 ... vt320 */ 1834 int ansi_level; /* levels 1,2,3 */ 1835 int protected_mode; /* 0=off, 1=DEC, 2=ISO */ 1836 Boolean always_bold_mode; /* compare normal/bold font */ 1837 Boolean always_highlight; /* whether to highlight cursor */ 1838 Boolean bold_mode; /* use bold font or overstrike */ 1839 Boolean delete_is_del; /* true for compatible Delete key */ 1840 Boolean jumpscroll; /* whether we should jumpscroll */ 1841 Boolean fastscroll; /* whether we should fastscroll */ 1842 Boolean old_fkeys; /* true for compatible fkeys */ 1843 Boolean underline; /* whether to underline text */ 1844 1845#if OPT_MAXIMIZE 1846 Boolean restore_data; 1847 int restore_x; 1848 int restore_y; 1849 unsigned restore_width; 1850 unsigned restore_height; 1851#endif 1852 1853#if OPT_SCROLL_LOCK 1854 Boolean allowScrollLock;/* ScrollLock mode */ 1855 Boolean allowScrollLock0;/* initial ScrollLock mode */ 1856 Boolean scroll_lock; /* true to keep buffer in view */ 1857 Boolean scroll_dirty; /* scrolling makes screen dirty */ 1858#endif 1859 1860#if OPT_VT52_MODE 1861 int vt52_save_level; /* save-area for DECANM */ 1862 Char vt52_save_curgl; 1863 Char vt52_save_curgr; 1864 Char vt52_save_curss; 1865 Char vt52_save_gsets[4]; 1866#endif 1867 /* Testing */ 1868#if OPT_XMC_GLITCH 1869 unsigned xmc_glitch; /* # of spaces to pad on SGR's */ 1870 int xmc_attributes; /* attrs that make a glitch */ 1871 Boolean xmc_inline; /* SGR's propagate only to eol */ 1872 Boolean move_sgr_ok; /* SGR is reset on move */ 1873#endif 1874 1875 /* 1876 * Bell 1877 */ 1878 int visualBellDelay; /* msecs to delay for visibleBell */ 1879 int bellSuppressTime; /* msecs after Bell before another allowed */ 1880 Boolean bellInProgress; /* still ringing/flashing prev bell? */ 1881 Boolean bellIsUrgent; /* set XUrgency WM hint on bell */ 1882 /* 1883 * Select/paste state. 1884 */ 1885 Boolean selectToClipboard; /* primary vs clipboard */ 1886 String *mappedSelect; /* mapping for "SELECT" to "PRIMARY" */ 1887 1888 Boolean waitingForTrackInfo; 1889 int numberOfClicks; 1890 int maxClicks; 1891 int multiClickTime; /* time between multiclick selects */ 1892 SelectUnit selectUnit; 1893 SelectUnit selectMap[NSELECTUNITS]; 1894 String onClick[NSELECTUNITS + 1]; 1895 1896 char *charClass; /* for overriding word selection */ 1897 Boolean cutNewline; /* whether or not line cut has \n */ 1898 Boolean cutToBeginningOfLine; /* line cuts to BOL? */ 1899 Boolean highlight_selection; /* controls appearance of selection */ 1900 Boolean show_wrap_marks; /* show lines which are wrapped */ 1901 Boolean trim_selection; /* controls trimming of selection */ 1902 Boolean i18nSelections; 1903 Boolean brokenSelections; 1904 Boolean keepSelection; /* do not lose selection on output */ 1905 Boolean replyToEmacs; /* Send emacs escape code when done selecting or extending? */ 1906 Char *selection_data; /* the current selection */ 1907 int selection_size; /* size of allocated buffer */ 1908 unsigned long selection_length; /* number of significant bytes */ 1909 EventMode eventMode; 1910 Time selection_time; /* latest event timestamp */ 1911 Time lastButtonUpTime; 1912 unsigned lastButton; 1913 1914 CELL rawPos; /* raw position for selection start */ 1915 CELL startRaw; /* area before selectUnit processing */ 1916 CELL endRaw; /* " " */ 1917 CELL startSel; /* area after selectUnit processing */ 1918 CELL endSel; /* " " */ 1919 CELL startH; /* start highlighted text */ 1920 CELL endH; /* end highlighted text */ 1921 CELL saveStartW; /* saved WORD state, for LINE */ 1922 CELL startExt; /* Start, end of extension */ 1923 CELL endExt; /* " " */ 1924 CELL saveStartR; /* Saved values of raw selection for extend to restore to */ 1925 CELL saveEndR; /* " " */ 1926 int startHCoord, endHCoord; 1927 int firstValidRow; /* Valid rows for selection clipping */ 1928 int lastValidRow; /* " " */ 1929 1930 String default_string; 1931 String eightbit_select_types; 1932 Atom* selection_targets_8bit; 1933#if OPT_WIDE_CHARS 1934 String utf8_select_types; 1935 Atom* selection_targets_utf8; 1936#endif 1937 Atom* selection_atoms; /* which selections we own */ 1938 Cardinal sel_atoms_size; /* how many atoms allocated */ 1939 Cardinal selection_count; /* how many atoms in use */ 1940#if OPT_SELECT_REGEX 1941 char * selectExpr[NSELECTUNITS]; 1942#endif 1943 /* 1944 * Input/output state. 1945 */ 1946 Boolean input_eight_bits;/* use 8th bit instead of ESC prefix */ 1947 Boolean output_eight_bits; /* honor all bits or strip */ 1948 Boolean control_eight_bits; /* send CSI as 8-bits */ 1949 Boolean backarrow_key; /* backspace/delete */ 1950 Boolean alt_is_not_meta; /* use both Alt- and Meta-key */ 1951 Boolean alt_sends_esc; /* Alt-key sends ESC prefix */ 1952 Boolean meta_sends_esc; /* Meta-key sends ESC prefix */ 1953 /* 1954 * Fonts 1955 */ 1956 Pixmap menu_item_bitmap; /* mask for checking items */ 1957 String initial_font; 1958 String menu_font_names[NMENUFONTS][fMAX]; 1959#define MenuFontName(n) menu_font_names[n][fNorm] 1960 long menu_font_sizes[NMENUFONTS]; 1961 int menu_font_number; 1962#if OPT_CLIP_BOLD 1963 Boolean use_clipping; 1964#endif 1965 void * main_cgs_cache; 1966#ifndef NO_ACTIVE_ICON 1967 void * icon_cgs_cache; 1968#endif 1969#if OPT_RENDERFONT 1970 XTermXftFonts renderFontNorm[NMENUFONTS]; 1971 XTermXftFonts renderFontBold[NMENUFONTS]; 1972 XTermXftFonts renderFontItal[NMENUFONTS]; 1973#if OPT_RENDERWIDE 1974 XTermXftFonts renderWideNorm[NMENUFONTS]; 1975 XTermXftFonts renderWideBold[NMENUFONTS]; 1976 XTermXftFonts renderWideItal[NMENUFONTS]; 1977 TypedBuffer(XftCharSpec); 1978#else 1979 TypedBuffer(XftChar8); 1980#endif 1981 XftDraw * renderDraw; 1982#endif 1983#if OPT_INPUT_METHOD 1984 XIM xim; 1985 XFontSet fs; /* fontset for XIM preedit */ 1986 int fs_ascent; /* ascent of fs */ 1987#endif 1988 XIC xic; /* this is used even without XIM */ 1989#if OPT_DABBREV 1990 Boolean dabbrev_working; /* nonzero during dabbrev process */ 1991 unsigned char dabbrev_erase_char; /* used for deleting inserted completion */ 1992#endif 1993 char tcapbuf[TERMCAP_SIZE]; 1994#if OPT_TCAP_FKEYS 1995 char ** tcap_fkeys; 1996 char tcap_area[TERMCAP_SIZE]; 1997#endif 1998} TScreen; 1999 2000typedef struct _TekPart { 2001 XFontStruct * Tfont[TEKNUMFONTS]; 2002 int tobaseline[TEKNUMFONTS]; /* top-baseline, each font */ 2003 char * initial_font; /* large, 2, 3, small */ 2004 char * gin_terminator_str; /* ginTerminator resource */ 2005#if OPT_TOOLBAR 2006 TbInfo tb_info; /* toolbar information */ 2007#endif 2008} TekPart; 2009 2010/* Tektronix window parameters */ 2011typedef struct _TekScreen { 2012 GC TnormalGC; /* normal painting */ 2013 GC TcursorGC; /* normal cursor painting */ 2014 2015 Boolean waitrefresh; /* postpone refresh */ 2016 TKwin fullTwin; 2017#ifndef NO_ACTIVE_ICON 2018 TKwin iconTwin; 2019 TKwin *whichTwin; 2020#endif /* NO_ACTIVE_ICON */ 2021 2022 Cursor arrow; /* arrow cursor */ 2023 GC linepat[TEKNUMLINES]; /* line patterns */ 2024 int cur_X; /* current x */ 2025 int cur_Y; /* current y */ 2026 Tmodes cur; /* current tek modes */ 2027 Tmodes page; /* starting tek modes on page */ 2028 int margin; /* 0 -> margin 1, 1 -> margin 2 */ 2029 int pen; /* current Tektronix pen 0=up, 1=dn */ 2030 char *TekGIN; /* nonzero if Tektronix GIN mode*/ 2031 int gin_terminator; /* Tek strap option */ 2032 char tcapbuf[TERMCAP_SIZE]; 2033} TekScreen; 2034 2035#if OPT_READLINE 2036#define SCREEN_FLAG(screenp,f) (1&(screenp)->f) 2037#define SCREEN_FLAG_set(screenp,f) ((screenp)->f |= 1) 2038#define SCREEN_FLAG_unset(screenp,f) ((screenp)->f &= (unsigned) ~1L) 2039#define SCREEN_FLAG_save(screenp,f) \ 2040 ((screenp)->f = (((screenp)->f)<<1) | SCREEN_FLAG(screenp,f)) 2041#define SCREEN_FLAG_restore(screenp,f) ((screenp)->f = (((screenp)->f)>>1)) 2042#else 2043#define SCREEN_FLAG(screenp,f) (0) 2044#endif 2045 2046/* meaning of bits in screen.select flag */ 2047#define INWINDOW 01 /* the mouse is in one of the windows */ 2048#define FOCUS 02 /* one of the windows is the focus window */ 2049 2050#define MULTICLICKTIME 250 /* milliseconds */ 2051 2052typedef struct { 2053 const char *name; 2054 int code; 2055} FlagList; 2056 2057typedef enum { 2058 fwNever = 0, 2059 fwResource, 2060 fwAlways 2061} fontWarningTypes; 2062 2063typedef enum { 2064 keyboardIsLegacy, /* bogus vt220 codes for F1-F4, etc. */ 2065 keyboardIsDefault, 2066 keyboardIsHP, 2067 keyboardIsSCO, 2068 keyboardIsSun, 2069 keyboardIsTermcap, 2070 keyboardIsVT220 2071} xtermKeyboardType; 2072 2073typedef enum { /* legal values for screen.pointer_mode */ 2074 pNever = 0, 2075 pNoMouse = 1, 2076 pAlways = 2 2077} pointerModeTypes; 2078 2079typedef enum { /* legal values for screen.utf8_mode */ 2080 uFalse = 0, 2081 uTrue = 1, 2082 uAlways = 2, 2083 uDefault = 3 2084} utf8ModeTypes; 2085 2086#if OPT_HP_FUNC_KEYS 2087#define NAME_HP_KT " hp" 2088#else 2089#define NAME_HP_KT /*nothing*/ 2090#endif 2091 2092#if OPT_SCO_FUNC_KEYS 2093#define NAME_SCO_KT " sco" 2094#else 2095#define NAME_SCO_KT /*nothing*/ 2096#endif 2097 2098#if OPT_SUN_FUNC_KEYS 2099#define NAME_SUN_KT " sun" 2100#else 2101#define NAME_SUN_KT /*nothing*/ 2102#endif 2103 2104#if OPT_SUNPC_KBD 2105#define NAME_VT220_KT " vt220" 2106#else 2107#define NAME_VT220_KT /*nothing*/ 2108#endif 2109 2110#if OPT_TCAP_FKEYS 2111#define NAME_TCAP_KT " tcap" 2112#else 2113#define NAME_TCAP_KT /*nothing*/ 2114#endif 2115 2116#define KEYBOARD_TYPES NAME_TCAP_KT NAME_HP_KT NAME_SCO_KT NAME_SUN_KT NAME_VT220_KT 2117 2118#if OPT_TRACE 2119#define TRACE_RC(code,func) code = func 2120#else 2121#define TRACE_RC(code,func) func 2122#endif 2123 2124#if OPT_TRACE 2125extern const char * visibleKeyboardType(xtermKeyboardType); 2126#endif 2127 2128typedef struct 2129{ 2130 int cursor_keys; /* how to handle cursor-key modifiers */ 2131 int function_keys; /* how to handle function-key modifiers */ 2132 int keypad_keys; /* how to handle keypad key-modifiers */ 2133 int other_keys; /* how to handle other key-modifiers */ 2134 int string_keys; /* how to handle string() modifiers */ 2135} TModify; 2136 2137typedef struct 2138{ 2139 xtermKeyboardType type; 2140 unsigned flags; 2141 char *shell_translations; 2142 char *xterm_translations; 2143 char *extra_translations; 2144#if OPT_INITIAL_ERASE 2145 int reset_DECBKM; /* reset should set DECBKM */ 2146#endif 2147#if OPT_MOD_FKEYS 2148 TModify modify_now; /* current modifier value */ 2149 TModify modify_1st; /* original modifier value, for resets */ 2150 int format_keys; /* format of modifyOtherKeys */ 2151#endif 2152} TKeyboard; 2153 2154typedef struct { 2155 String f_n; /* the normal font */ 2156 String f_b; /* the bold font */ 2157#if OPT_WIDE_CHARS 2158 String f_w; /* the normal wide font */ 2159 String f_wb; /* the bold wide font */ 2160#endif 2161} VTFontNames; 2162 2163#define GravityIsNorthWest(w) ((w)->misc.resizeGravity == NorthWestGravity) 2164#define GravityIsSouthWest(w) ((w)->misc.resizeGravity == SouthWestGravity) 2165 2166typedef struct _Misc { 2167 VTFontNames default_font; 2168 char *geo_metry; 2169 char *T_geometry; 2170#if OPT_WIDE_CHARS 2171 Boolean cjk_width; /* true for built-in CJK wcwidth() */ 2172 Boolean mk_width; /* true for simpler built-in wcwidth() */ 2173 int mk_samplesize; 2174 int mk_samplepass; 2175#endif 2176#if OPT_LUIT_PROG 2177 Boolean callfilter; /* true to invoke luit */ 2178 Boolean use_encoding; /* true to use -encoding option for luit */ 2179 char *locale_str; /* "locale" resource */ 2180 char *localefilter; /* path for luit */ 2181#endif 2182 fontWarningTypes fontWarnings; 2183 int limit_resize; 2184#ifdef ALLOWLOGGING 2185 Boolean log_on; 2186#endif 2187 Boolean login_shell; 2188 Boolean re_verse; 2189 Boolean re_verse0; /* initial value of "-rv" */ 2190 XtGravity resizeGravity; 2191 Boolean reverseWrap; 2192 Boolean autoWrap; 2193 Boolean logInhibit; 2194 Boolean signalInhibit; 2195#if OPT_TEK4014 2196 Boolean tekInhibit; 2197 Boolean tekSmall; /* start tek window in small size */ 2198 Boolean TekEmu; /* true if Tektronix emulation */ 2199 Boolean Tshow; /* Tek window showing */ 2200#endif 2201 Boolean scrollbar; 2202#ifdef SCROLLBAR_RIGHT 2203 Boolean useRight; 2204#endif 2205 Boolean titeInhibit; 2206 Boolean tiXtraScroll; 2207 Boolean appcursorDefault; 2208 Boolean appkeypadDefault; 2209#if OPT_INPUT_METHOD 2210 char* f_x; /* font for XIM */ 2211 char* input_method; 2212 char* preedit_type; 2213 Boolean open_im; /* true if input-method is opened */ 2214 Boolean cannot_im; /* true if we cannot use input-method */ 2215 int retry_im; 2216#endif 2217 Boolean dynamicColors; 2218 Boolean shared_ic; 2219#ifndef NO_ACTIVE_ICON 2220 Boolean active_icon; /* use application icon window */ 2221 unsigned icon_border_width; 2222 Pixel icon_border_pixel; 2223#endif /* NO_ACTIVE_ICON */ 2224#if OPT_DEC_SOFTFONT 2225 Boolean font_loadable; 2226#endif 2227#if OPT_SHIFT_FONTS 2228 Boolean shift_fonts; /* true if we interpret fontsize-shifting */ 2229#endif 2230#if OPT_SUNPC_KBD 2231 int ctrl_fkeys; /* amount to add to XK_F1 for ctrl modifier */ 2232#endif 2233#if OPT_NUM_LOCK 2234 Boolean real_NumLock; /* true if we treat NumLock key specially */ 2235 Boolean alwaysUseMods; /* true if we always want f-key modifiers */ 2236 unsigned num_lock; /* modifier for Num_Lock */ 2237 unsigned alt_mods; /* modifier for Alt_L or Alt_R */ 2238 unsigned meta_mods; /* modifier for Meta_L or Meta_R */ 2239 unsigned other_mods; /* conflicting modifiers, e.g., Mode_Switch */ 2240#endif 2241#if OPT_RENDERFONT 2242 char *face_name; 2243 char *face_wide_name; 2244 float face_size[NMENUFONTS]; 2245 char *render_font_s; 2246 Boolean render_font; 2247#endif 2248} Misc; 2249 2250typedef struct {int foo;} XtermClassPart, TekClassPart; 2251 2252typedef struct _XtermClassRec { 2253 CoreClassPart core_class; 2254 XtermClassPart xterm_class; 2255} XtermClassRec; 2256 2257extern WidgetClass xtermWidgetClass; 2258 2259#define IsXtermWidget(w) (XtClass(w) == xtermWidgetClass) 2260 2261#if OPT_TEK4014 2262typedef struct _TekClassRec { 2263 CoreClassPart core_class; 2264 TekClassPart tek_class; 2265} TekClassRec; 2266 2267extern WidgetClass tekWidgetClass; 2268 2269#define IsTekWidget(w) (XtClass(w) == tekWidgetClass) 2270 2271#endif 2272 2273/* define masks for keyboard.flags */ 2274#define MODE_KAM xBIT(0) /* keyboard action mode */ 2275#define MODE_DECKPAM xBIT(1) /* keypad application mode */ 2276#define MODE_DECCKM xBIT(2) /* cursor keys */ 2277#define MODE_SRM xBIT(3) /* send-receive mode */ 2278#define MODE_DECBKM xBIT(4) /* backarrow */ 2279 2280 2281#define N_MARGINBELL 10 2282 2283#define TAB_BITS_SHIFT 5 /* FIXME: 2**5 == 32 (should derive) */ 2284#define TAB_BITS_WIDTH (1 << TAB_BITS_SHIFT) 2285#define TAB_ARRAY_SIZE (1024 / TAB_BITS_WIDTH) 2286#define MAX_TABS (TAB_BITS_WIDTH * TAB_ARRAY_SIZE) 2287 2288typedef unsigned Tabs [TAB_ARRAY_SIZE]; 2289 2290typedef struct _XtermWidgetRec { 2291 CorePart core; 2292 XSizeHints hints; 2293 Bool init_menu; 2294 TKeyboard keyboard; /* terminal keyboard */ 2295 TScreen screen; /* terminal screen */ 2296 unsigned flags; /* mode flags */ 2297 int cur_foreground; /* current foreground color */ 2298 int cur_background; /* current background color */ 2299 Pixel dft_foreground; /* default foreground color */ 2300 Pixel dft_background; /* default background color */ 2301#if OPT_ISO_COLORS 2302 int sgr_foreground; /* current SGR foreground color */ 2303 int sgr_background; /* current SGR background color */ 2304 Boolean sgr_extended; /* SGR set with extended codes? */ 2305#endif 2306 unsigned initflags; /* initial mode flags */ 2307 Tabs tabs; /* tabstops of the terminal */ 2308 Misc misc; /* miscellaneous parameters */ 2309} XtermWidgetRec, *XtermWidget; 2310 2311#if OPT_TEK4014 2312typedef struct _TekWidgetRec { 2313 CorePart core; 2314 TekPart tek; /* contains resources */ 2315 TekScreen screen; /* contains working data (no resources) */ 2316 Bool init_menu; 2317 XSizeHints hints; 2318} TekWidgetRec, *TekWidget; 2319#endif /* OPT_TEK4014 */ 2320 2321/* 2322 * terminal flags 2323 * There are actually two namespaces mixed together here. 2324 * One is the set of flags that can go in screen->visbuf attributes 2325 * and which must fit in a char (see OFF_ATTRS). 2326 * The other is the global setting stored in 2327 * term->flags and screen->save_modes. This need only fit in an unsigned. 2328 */ 2329 2330#define AttrBIT(n) xBIT(n) /* text-attributes */ 2331#define DrawBIT(n) xBIT(n + 8) /* drawXtermText flags */ 2332#define MiscBIT(n) xBIT(n + 16) /* miscellaneous state flags */ 2333 2334/* global flags and character flags (visible character attributes) */ 2335#define INVERSE AttrBIT(0) /* invert the characters to be output */ 2336#define UNDERLINE AttrBIT(1) /* true if underlining */ 2337#define BOLD AttrBIT(2) 2338#define BLINK AttrBIT(3) 2339/* global flags (also character attributes) */ 2340#define BG_COLOR AttrBIT(4) /* true if background set */ 2341#define FG_COLOR AttrBIT(5) /* true if foreground set */ 2342 2343/* character flags (internal attributes) */ 2344#define PROTECTED AttrBIT(6) /* a character that cannot be erased */ 2345#define CHARDRAWN AttrBIT(7) /* a character has been drawn here on 2346 the screen. Used to distinguish 2347 blanks from empty parts of the 2348 screen when selecting */ 2349 2350/* The following attributes are used in the argument of drawXtermText() */ 2351#define NOBACKGROUND DrawBIT(0) /* Used for overstrike */ 2352#define NOTRANSLATION DrawBIT(1) /* No scan for chars missing in font */ 2353#define DOUBLEWFONT DrawBIT(2) /* The actual X-font is double-width */ 2354#define DOUBLEHFONT DrawBIT(3) /* The actual X-font is double-height */ 2355#define CHARBYCHAR DrawBIT(4) /* Draw chars one-by-one */ 2356 2357/* The following attribute is used in the argument of xtermSpecialFont etc */ 2358#define NORESOLUTION DrawBIT(5) /* find the font without resolution */ 2359 2360/* 2361 * Other flags 2362 */ 2363#define WRAPAROUND MiscBIT(0) /* true if auto wraparound mode */ 2364#define REVERSEWRAP MiscBIT(1) /* true if reverse wraparound mode */ 2365#define REVERSE_VIDEO MiscBIT(2) /* true if screen white on black */ 2366#define LINEFEED MiscBIT(3) /* true if in auto linefeed mode */ 2367#define ORIGIN MiscBIT(4) /* true if in origin mode */ 2368#define INSERT MiscBIT(5) /* true if in insert mode */ 2369#define SMOOTHSCROLL MiscBIT(6) /* true if in smooth scroll mode */ 2370#define IN132COLUMNS MiscBIT(7) /* true if in 132 column mode */ 2371#define INVISIBLE MiscBIT(8) /* true if writing invisible text */ 2372#define NATIONAL MiscBIT(9) /* true if writing national charset */ 2373 2374/* 2375 * Groups of attributes 2376 */ 2377 /* mask for video-attributes only */ 2378#define SGR_MASK (BOLD | BLINK | UNDERLINE | INVERSE) 2379 2380 /* mask: user-visible attributes */ 2381#define ATTRIBUTES (SGR_MASK | BG_COLOR | FG_COLOR | INVISIBLE | PROTECTED) 2382 2383/* The toplevel-call to drawXtermText() should have text-attributes guarded: */ 2384#define DRAWX_MASK (ATTRIBUTES | CHARDRAWN) 2385 2386#if OPT_BLINK_TEXT 2387#define BOLDATTR(screen) (BOLD | ((screen)->blink_as_bold ? BLINK : 0)) 2388#else 2389#define BOLDATTR(screen) (BOLD | BLINK) 2390#endif 2391 2392/* 2393 * Per-line flags 2394 */ 2395#define LINEWRAPPED AttrBIT(0) 2396/* used once per line to indicate that it wraps onto the next line so we can 2397 * tell the difference between lines that have wrapped around and lines that 2398 * have ended naturally with a CR at column max_col. 2399 */ 2400#define LINEBLINKED AttrBIT(1) 2401/* set when the line contains blinking text. 2402 */ 2403 2404#if OPT_ZICONBEEP || OPT_TOOLBAR 2405#define HANDLE_STRUCT_NOTIFY 1 2406#else 2407#define HANDLE_STRUCT_NOTIFY 0 2408#endif 2409 2410/* 2411 * If we've set protected attributes with the DEC-style DECSCA, then we'll have 2412 * to use DECSED or DECSEL to erase preserving protected text. (The normal ED, 2413 * EL won't preserve protected-text). If we've used SPA, then normal ED and EL 2414 * will preserve protected-text. To keep things simple, just remember the last 2415 * control that was used to begin protected-text, and use that to determine how 2416 * erases are performed (otherwise we'd need 2 bits per protected character). 2417 */ 2418#define OFF_PROTECT 0 2419#define DEC_PROTECT 1 2420#define ISO_PROTECT 2 2421 2422#define TScreenOf(xw) (&(xw)->screen) 2423#define TekScreenOf(tw) (&(tw)->screen) 2424 2425#ifdef SCROLLBAR_RIGHT 2426#define OriginX(screen) (((term->misc.useRight)?0:ScrollbarWidth(screen)) + screen->border) 2427#else 2428#define OriginX(screen) (ScrollbarWidth(screen) + screen->border) 2429#endif 2430 2431#define OriginY(screen) (screen->border) 2432 2433#define CursorMoved(screen) \ 2434 ((screen)->cursor_moved || \ 2435 ((screen)->cursorp.col != (screen)->cur_col || \ 2436 (screen)->cursorp.row != (screen)->cur_row)) 2437 2438#define CursorX(screen,col) ((col) * FontWidth(screen) + OriginX(screen)) 2439#define CursorY(screen,row) ((INX2ROW(screen, row) * FontHeight(screen)) \ 2440 + screen->border) 2441 2442/* 2443 * These definitions depend on whether xterm supports active-icon. 2444 */ 2445#ifndef NO_ACTIVE_ICON 2446#define IsIconWin(screen,win) ((win) == &(screen)->iconVwin) 2447#define IsIcon(screen) (WhichVWin(screen) == &(screen)->iconVwin) 2448#define WhichVWin(screen) ((screen)->whichVwin) 2449#define WhichTWin(screen) ((screen)->whichTwin) 2450 2451#define WhichVFont(screen,name) (IsIcon(screen) ? (screen)->fnt_icon.fs \ 2452 : (screen)->name) 2453#define FontAscent(screen) (IsIcon(screen) ? (screen)->fnt_icon.fs->ascent \ 2454 : WhichVWin(screen)->f_ascent) 2455#define FontDescent(screen) (IsIcon(screen) ? (screen)->fnt_icon.fs->descent \ 2456 : WhichVWin(screen)->f_descent) 2457#else /* NO_ACTIVE_ICON */ 2458 2459#define IsIconWin(screen,win) (False) 2460#define IsIcon(screen) (False) 2461#define WhichVWin(screen) (&((screen)->fullVwin)) 2462#define WhichTWin(screen) (&((screen)->fullTwin)) 2463 2464#define WhichVFont(screen,name) ((screen)->name) 2465#define FontAscent(screen) WhichVWin(screen)->f_ascent 2466#define FontDescent(screen) WhichVWin(screen)->f_descent 2467 2468#endif /* NO_ACTIVE_ICON */ 2469 2470#define okFont(font) ((font) != 0 && (font)->fid != 0) 2471 2472/* 2473 * Macro to check if we are iconified; do not use render for that case. 2474 */ 2475#define UsingRenderFont(xw) (((xw)->misc.render_font == True) && !IsIcon(TScreenOf(xw))) 2476 2477/* 2478 * These definitions do not depend on whether xterm supports active-icon. 2479 */ 2480#define VWindow(screen) WhichVWin(screen)->window 2481#define VShellWindow(xw) XtWindow(SHELL_OF(xw)) 2482#define TWindow(screen) WhichTWin(screen)->window 2483#define TShellWindow XtWindow(SHELL_OF(tekWidget)) 2484 2485#define Width(screen) WhichVWin(screen)->width 2486#define Height(screen) WhichVWin(screen)->height 2487#define FullWidth(screen) WhichVWin(screen)->fullwidth 2488#define FullHeight(screen) WhichVWin(screen)->fullheight 2489#define FontWidth(screen) WhichVWin(screen)->f_width 2490#define FontHeight(screen) WhichVWin(screen)->f_height 2491 2492#define NormalFont(screen) WhichVFont(screen, fnts[fNorm].fs) 2493#define BoldFont(screen) WhichVFont(screen, fnts[fBold].fs) 2494 2495#if OPT_WIDE_CHARS 2496#define NormalWFont(screen) WhichVFont(screen, fnts[fWide].fs) 2497#define BoldWFont(screen) WhichVFont(screen, fnts[fWBold].fs) 2498#endif 2499 2500#define ScrollbarWidth(screen) WhichVWin(screen)->sb_info.width 2501 2502#define NormalGC(w,sp) getCgsGC(w, WhichVWin(sp), gcNorm) 2503#define ReverseGC(w,sp) getCgsGC(w, WhichVWin(sp), gcNormReverse) 2504#define NormalBoldGC(w,sp) getCgsGC(w, WhichVWin(sp), gcBold) 2505#define ReverseBoldGC(w,sp) getCgsGC(w, WhichVWin(sp), gcBoldReverse) 2506 2507#define TWidth(screen) WhichTWin(screen)->width 2508#define THeight(screen) WhichTWin(screen)->height 2509#define TFullWidth(screen) WhichTWin(screen)->fullwidth 2510#define TFullHeight(screen) WhichTWin(screen)->fullheight 2511#define TekScale(screen) WhichTWin(screen)->tekscale 2512 2513#define BorderWidth(w) ((w)->core.border_width) 2514#define BorderPixel(w) ((w)->core.border_pixel) 2515 2516#define AllowXtermOps(w,name) (TScreenOf(w)->name && !TScreenOf(w)->allowSendEvents) 2517 2518#define AllowColorOps(w,name) (AllowXtermOps(w, allowColorOps) || \ 2519 !TScreenOf(w)->disallow_color_ops[name]) 2520 2521#define AllowFontOps(w,name) (AllowXtermOps(w, allowFontOps) || \ 2522 !TScreenOf(w)->disallow_font_ops[name]) 2523 2524#define AllowTcapOps(w,name) (AllowXtermOps(w, allowTcapOps) || \ 2525 !TScreenOf(w)->disallow_tcap_ops[name]) 2526 2527#define AllowTitleOps(w) AllowXtermOps(w, allowTitleOps) 2528 2529#define AllowWindowOps(w,name) (AllowXtermOps(w, allowWindowOps) || \ 2530 !TScreenOf(w)->disallow_win_ops[name]) 2531 2532#if OPT_TOOLBAR 2533#define ToolbarHeight(w) ((resource.toolBar) \ 2534 ? ((w)->VT100_TB_INFO(menu_height) \ 2535 + (w)->VT100_TB_INFO(menu_border) * 2) \ 2536 : 0) 2537#else 2538#define ToolbarHeight(w) 0 2539#endif 2540 2541#if OPT_TEK4014 2542#define TEK_LINK_BLOCK_SIZE 1024 2543 2544typedef struct Tek_Link 2545{ 2546 struct Tek_Link *next; /* pointer to next TekLink in list 2547 NULL <=> this is last TekLink */ 2548 unsigned short fontsize;/* character size, 0-3 */ 2549 unsigned short count; /* number of chars in data */ 2550 char *ptr; /* current pointer into data */ 2551 char data [TEK_LINK_BLOCK_SIZE]; 2552} TekLink; 2553#endif /* OPT_TEK4014 */ 2554 2555/* flags for cursors */ 2556#define OFF 0 2557#define ON 1 2558#define BLINKED_OFF 2 2559#define CLEAR 0 2560#define TOGGLE 1 2561 2562/* flags for inhibit */ 2563#ifdef ALLOWLOGGING 2564#define I_LOG 0x01 2565#endif 2566#define I_SIGNAL 0x02 2567#define I_TEK 0x04 2568 2569/***====================================================================***/ 2570 2571#if OPT_TRACE 2572#undef NDEBUG /* turn on assert's */ 2573#else 2574#ifndef NDEBUG 2575#define NDEBUG /* not debugging, don't do assert's */ 2576#endif 2577#endif 2578 2579#include <trace.h> 2580 2581#ifndef TRACE 2582#define TRACE(p) /*nothing*/ 2583#endif 2584 2585#ifndef TRACE_CLOSE 2586#define TRACE_CLOSE() /*nothing*/ 2587#endif 2588 2589#ifndef TRACE_ARGV 2590#define TRACE_ARGV(tag,argv) /*nothing*/ 2591#endif 2592 2593#ifndef TRACE_CHILD 2594#define TRACE_CHILD /*nothing*/ 2595#endif 2596 2597#ifndef TRACE_FOCUS 2598#define TRACE_FOCUS(w,e) /*nothing*/ 2599#endif 2600 2601#ifndef TRACE_HINTS 2602#define TRACE_HINTS(hints) /*nothing*/ 2603#endif 2604 2605#ifndef TRACE_IDS 2606#define TRACE_IDS /*nothing*/ 2607#endif 2608 2609#ifndef TRACE_OPTS 2610#define TRACE_OPTS(opts,ress,lens) /*nothing*/ 2611#endif 2612 2613#ifndef TRACE_TRANS 2614#define TRACE_TRANS(name,w) /*nothing*/ 2615#endif 2616 2617#ifndef TRACE_WM_HINTS 2618#define TRACE_WM_HINTS(w) /*nothing*/ 2619#endif 2620 2621#ifndef TRACE_XRES 2622#define TRACE_XRES() /*nothing*/ 2623#endif 2624 2625#ifndef TRACE2 2626#define TRACE2(p) /*nothing*/ 2627#endif 2628 2629/* *INDENT-ON* */ 2630 2631#endif /* included_ptyx_h */ 2632