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