1190d7dceSmrg/* $XTermId: ptyx.h,v 1.1135 2025/01/05 20:36:10 tom Exp $ */ 2d522f475Smrg 3d522f475Smrg/* 4190d7dceSmrg * Copyright 1999-2024,2025 by Thomas E. Dickey 5d522f475Smrg * 6d522f475Smrg * All Rights Reserved 7d522f475Smrg * 8d522f475Smrg * Permission is hereby granted, free of charge, to any person obtaining a 9d522f475Smrg * copy of this software and associated documentation files (the 10d522f475Smrg * "Software"), to deal in the Software without restriction, including 11d522f475Smrg * without limitation the rights to use, copy, modify, merge, publish, 12d522f475Smrg * distribute, sublicense, and/or sell copies of the Software, and to 13d522f475Smrg * permit persons to whom the Software is furnished to do so, subject to 14d522f475Smrg * the following conditions: 15d522f475Smrg * 16d522f475Smrg * The above copyright notice and this permission notice shall be included 17d522f475Smrg * in all copies or substantial portions of the Software. 18d522f475Smrg * 19d522f475Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 20d522f475Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21d522f475Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22d522f475Smrg * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY 23d522f475Smrg * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24d522f475Smrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25d522f475Smrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26d522f475Smrg * 27d522f475Smrg * Except as contained in this notice, the name(s) of the above copyright 28d522f475Smrg * holders shall not be used in advertising or otherwise to promote the 29d522f475Smrg * sale, use or other dealings in this Software without prior written 30d522f475Smrg * authorization. 31d522f475Smrg * 32d522f475Smrg * 33d522f475Smrg * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. 34d522f475Smrg * 35d522f475Smrg * All Rights Reserved 36d522f475Smrg * 37d522f475Smrg * Permission to use, copy, modify, and distribute this software and its 38d522f475Smrg * documentation for any purpose and without fee is hereby granted, 39d522f475Smrg * provided that the above copyright notice appear in all copies and that 40d522f475Smrg * both that copyright notice and this permission notice appear in 41d522f475Smrg * supporting documentation, and that the name of Digital Equipment 42d522f475Smrg * Corporation not be used in advertising or publicity pertaining to 43d522f475Smrg * distribution of the software without specific, written prior permission. 44d522f475Smrg * 45d522f475Smrg * 46d522f475Smrg * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 47d522f475Smrg * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 48d522f475Smrg * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 49d522f475Smrg * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 50d522f475Smrg * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 51d522f475Smrg * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 52d522f475Smrg * SOFTWARE. 53d522f475Smrg */ 54d522f475Smrg 55d522f475Smrg#ifndef included_ptyx_h 56d522f475Smrg#define included_ptyx_h 1 57d522f475Smrg 58d522f475Smrg#ifdef HAVE_CONFIG_H 59d522f475Smrg#include <xtermcfg.h> 60d522f475Smrg#endif 61d522f475Smrg 62d522f475Smrg/* ptyx.h */ 63c219fbebSmrg/* *INDENT-OFF* */ 64d522f475Smrg/* @(#)ptyx.h X10/6.6 11/10/86 */ 65d522f475Smrg 66d522f475Smrg#include <X11/IntrinsicP.h> 67d522f475Smrg#include <X11/Shell.h> /* for XtNdieCallback, etc. */ 68d522f475Smrg#include <X11/StringDefs.h> /* for standard resource names */ 69d522f475Smrg#include <X11/Xmu/Misc.h> /* For Max() and Min(). */ 708f44fb3bSmrg#include <X11/cursorfont.h> 718f44fb3bSmrg 723367019cSmrg 733367019cSmrg#undef bcopy 743367019cSmrg#undef bzero 75d522f475Smrg#include <X11/Xfuncs.h> 763367019cSmrg 77d522f475Smrg#include <X11/Xosdefs.h> 78d522f475Smrg#include <X11/Xmu/Converters.h> 79d522f475Smrg#ifdef XRENDERFONT 80d522f475Smrg#include <X11/Xft/Xft.h> 81d522f475Smrg#endif 82d522f475Smrg 83712a7ff4Smrg#include <stdio.h> 84d1603babSmrg#include <limits.h> 85712a7ff4Smrg 86d4fba8b9Smrg#if defined(HAVE_STDINT_H) || !defined(HAVE_CONFIG_H) 87fa3f02f3Smrg#include <stdint.h> 88fa3f02f3Smrg#define DECONST(type,s) ((type *)(intptr_t)(const type *)(s)) 89fa3f02f3Smrg#else 90fa3f02f3Smrg#define DECONST(type,s) ((type *)(s)) 91fa3f02f3Smrg#endif 92fa3f02f3Smrg 93d522f475Smrg/* adapted from IntrinsicI.h */ 94d522f475Smrg#define MyStackAlloc(size, stack_cache_array) \ 95d522f475Smrg ((size) <= sizeof(stack_cache_array) \ 96d1603babSmrg ? (stack_cache_array) \ 97d1603babSmrg : (char*)malloc((size_t)(size))) 98d522f475Smrg 99d522f475Smrg#define MyStackFree(pointer, stack_cache_array) \ 100d522f475Smrg if ((pointer) != ((char *)(stack_cache_array))) free(pointer) 101d522f475Smrg 102d522f475Smrg/* adapted from vile (vi-like-emacs) */ 103cd3331d0Smrg#define TypeCallocN(type,n) (type *)calloc((size_t) (n), sizeof(type)) 104cd3331d0Smrg#define TypeCalloc(type) TypeCallocN(type, 1) 105d522f475Smrg 106cd3331d0Smrg#define TypeMallocN(type,n) (type *)malloc(sizeof(type) * (size_t) (n)) 107cd3331d0Smrg#define TypeMalloc(type) TypeMallocN(type, 1) 108d522f475Smrg 109d522f475Smrg#define TypeRealloc(type,n,p) (type *)realloc(p, (n) * sizeof(type)) 110d522f475Smrg 111c219fbebSmrg#define TypeXtReallocN(t,p,n) (t *)(void *)XtRealloc((char *)(p), (Cardinal)(sizeof(t) * (size_t) (n))) 112c219fbebSmrg 113c219fbebSmrg#define TypeXtMallocX(type,n) (type *)(void *)XtMalloc((Cardinal)(sizeof(type) + (size_t) (n))) 114c219fbebSmrg#define TypeXtMallocN(type,n) (type *)(void *)XtMalloc((Cardinal)(sizeof(type) * (size_t) (n))) 115c219fbebSmrg#define TypeXtMalloc(type) TypeXtMallocN(type, 1) 116c219fbebSmrg 117dfb07bc7Smrg#define CastMalloc(type) (type *)malloc(sizeof(type)) 118d522f475Smrg 119b7c89284Ssnj#define BumpBuffer(type, buffer, size, want) \ 120b7c89284Ssnj if (want >= size) { \ 121b7c89284Ssnj size = 1 + (want * 2); \ 122b7c89284Ssnj buffer = TypeRealloc(type, size, buffer); \ 123b7c89284Ssnj } 124b7c89284Ssnj 125b7c89284Ssnj#define BfBuf(type) screen->bf_buf_##type 126b7c89284Ssnj#define BfLen(type) screen->bf_len_##type 127b7c89284Ssnj 128b7c89284Ssnj#define TypedBuffer(type) \ 129b7c89284Ssnj type *bf_buf_##type; \ 130b7c89284Ssnj Cardinal bf_len_##type 131b7c89284Ssnj 132b7c89284Ssnj#define BumpTypedBuffer(type, want) \ 133b7c89284Ssnj BumpBuffer(type, BfBuf(type), BfLen(type), want) 134b7c89284Ssnj 135b7c89284Ssnj#define FreeTypedBuffer(type) \ 136d4fba8b9Smrg do { \ 137d4fba8b9Smrg FreeAndNull(BfBuf(type)); \ 138d4fba8b9Smrg BfLen(type) = 0; \ 139d4fba8b9Smrg } while (0) 140d4fba8b9Smrg 141d4fba8b9Smrg#define FreeAndNull(value) \ 142d4fba8b9Smrg do { \ 143d4fba8b9Smrg free((void *)(value)); \ 144d4fba8b9Smrg value = NULL; \ 145d4fba8b9Smrg } while (0) 146b7c89284Ssnj 147d522f475Smrg/* 148d522f475Smrg** System V definitions 149d522f475Smrg*/ 150d522f475Smrg 151d522f475Smrg#ifdef att 152d522f475Smrg#define ATT 153d522f475Smrg#endif 154d522f475Smrg 155d522f475Smrg#ifdef SVR4 156d522f475Smrg#undef SYSV /* predefined on Solaris 2.4 */ 157d522f475Smrg#define SYSV /* SVR4 is (approx) superset of SVR3 */ 158d522f475Smrg#define ATT 159d522f475Smrg#endif 160d522f475Smrg 161d522f475Smrg#ifdef SYSV 162d522f475Smrg#ifdef X_NOT_POSIX 163d522f475Smrg#if !defined(CRAY) && !defined(SVR4) 164d522f475Smrg#define dup2(fd1,fd2) ((fd1 == fd2) ? fd1 : \ 165d522f475Smrg (close(fd2), fcntl(fd1, F_DUPFD, fd2))) 166d522f475Smrg#endif 167d522f475Smrg#endif 168d522f475Smrg#endif /* SYSV */ 169d522f475Smrg 170d522f475Smrg/* 171d522f475Smrg * Newer versions of <X11/Xft/Xft.h> have a version number. We use certain 172d522f475Smrg * features from that. 173d522f475Smrg */ 174d522f475Smrg#if defined(XRENDERFONT) && defined(XFT_VERSION) && XFT_VERSION >= 20100 175d522f475Smrg#define HAVE_TYPE_FCCHAR32 1 /* compatible: XftChar16 */ 176d522f475Smrg#define HAVE_TYPE_XFTCHARSPEC 1 /* new type XftCharSpec */ 177d522f475Smrg#endif 178d522f475Smrg 179d522f475Smrg/* 180d522f475Smrg** Definitions to simplify ifdef's for pty's. 181d522f475Smrg*/ 182d522f475Smrg#define USE_PTY_DEVICE 1 183d522f475Smrg#define USE_PTY_SEARCH 1 184d522f475Smrg 185b7c89284Ssnj#if defined(__osf__) || (defined(linux) && defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) 186d522f475Smrg#undef USE_PTY_DEVICE 187d522f475Smrg#undef USE_PTY_SEARCH 188d522f475Smrg#define USE_PTS_DEVICE 1 189d522f475Smrg#elif defined(PUCC_PTYD) 190d522f475Smrg#undef USE_PTY_SEARCH 191d522f475Smrg#elif (defined(sun) && defined(SVR4)) || defined(_ALL_SOURCE) || defined(__CYGWIN__) 192d522f475Smrg#undef USE_PTY_SEARCH 1933367019cSmrg#elif defined(__OpenBSD__) 1943367019cSmrg#undef USE_PTY_SEARCH 1953367019cSmrg#undef USE_PTY_DEVICE 196d522f475Smrg#endif 197d522f475Smrg 1983367019cSmrg#if (defined (__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1))) 1993367019cSmrg#define USE_HANDSHAKE 0 /* "recent" Linux systems do not require handshaking */ 200d522f475Smrg#endif 201d522f475Smrg 202d522f475Smrg#if (defined (__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1))) 203d522f475Smrg#define USE_USG_PTYS 204190d7dceSmrg#elif (defined(ATT) && !defined(__sgi)) || (defined(SYSV) && defined(i386)) 205d522f475Smrg#define USE_USG_PTYS 206d522f475Smrg#endif 207d522f475Smrg 208d522f475Smrg/* 209d522f475Smrg * More systems than not require pty-handshaking. 210d522f475Smrg */ 211d522f475Smrg#ifndef USE_HANDSHAKE 212d522f475Smrg#define USE_HANDSHAKE 1 213d522f475Smrg#endif 214d522f475Smrg 215d522f475Smrg/* 216d522f475Smrg** allow for mobility of the pty master/slave directories 217d522f475Smrg*/ 218d522f475Smrg#ifndef PTYDEV 219d522f475Smrg#if defined(__hpux) 220d522f475Smrg#define PTYDEV "/dev/ptym/ptyxx" 221d522f475Smrg#else 222d522f475Smrg#define PTYDEV "/dev/ptyxx" 223d522f475Smrg#endif 224d522f475Smrg#endif /* !PTYDEV */ 225d522f475Smrg 226d522f475Smrg#ifndef TTYDEV 227d522f475Smrg#if defined(__hpux) 228d522f475Smrg#define TTYDEV "/dev/pty/ttyxx" 229d522f475Smrg#elif defined(USE_PTS_DEVICE) 230d522f475Smrg#define TTYDEV "/dev/pts/0" 231d522f475Smrg#else 232d522f475Smrg#define TTYDEV "/dev/ttyxx" 233d522f475Smrg#endif 234d522f475Smrg#endif /* !TTYDEV */ 235d522f475Smrg 236d522f475Smrg#ifndef PTYCHAR1 237d522f475Smrg#ifdef __hpux 238d522f475Smrg#define PTYCHAR1 "zyxwvutsrqp" 239d522f475Smrg#else /* !__hpux */ 240d522f475Smrg#define PTYCHAR1 "pqrstuvwxyzPQRSTUVWXYZ" 241d522f475Smrg#endif /* !__hpux */ 242d522f475Smrg#endif /* !PTYCHAR1 */ 243d522f475Smrg 244d522f475Smrg#ifndef PTYCHAR2 245d522f475Smrg#ifdef __hpux 246d522f475Smrg#define PTYCHAR2 "fedcba9876543210" 247d522f475Smrg#else /* !__hpux */ 248d522f475Smrg#if defined(__DragonFly__) || defined(__FreeBSD__) 249d522f475Smrg#define PTYCHAR2 "0123456789abcdefghijklmnopqrstuv" 250d522f475Smrg#else /* !__FreeBSD__ */ 251d522f475Smrg#define PTYCHAR2 "0123456789abcdef" 252d522f475Smrg#endif /* !__FreeBSD__ */ 253d522f475Smrg#endif /* !__hpux */ 254d522f475Smrg#endif /* !PTYCHAR2 */ 255d522f475Smrg 256d522f475Smrg#ifndef TTYFORMAT 257d522f475Smrg#if defined(CRAY) 258d522f475Smrg#define TTYFORMAT "/dev/ttyp%03d" 259d522f475Smrg#else 260d522f475Smrg#define TTYFORMAT "/dev/ttyp%d" 261d522f475Smrg#endif 262d522f475Smrg#endif /* TTYFORMAT */ 263d522f475Smrg 264d522f475Smrg#ifndef PTYFORMAT 265d522f475Smrg#ifdef CRAY 266d522f475Smrg#define PTYFORMAT "/dev/pty/%03d" 267d522f475Smrg#else 268d522f475Smrg#define PTYFORMAT "/dev/ptyp%d" 269d522f475Smrg#endif 270d522f475Smrg#endif /* PTYFORMAT */ 271d522f475Smrg 272d522f475Smrg#ifndef PTYCHARLEN 273d522f475Smrg#ifdef CRAY 274d522f475Smrg#define PTYCHARLEN 3 275d522f475Smrg#else 276d522f475Smrg#define PTYCHARLEN 2 277d522f475Smrg#endif 278d522f475Smrg#endif 279d522f475Smrg 280d522f475Smrg#ifndef MAXPTTYS 281d522f475Smrg#ifdef CRAY 282d522f475Smrg#define MAXPTTYS 256 283d522f475Smrg#else 284d522f475Smrg#define MAXPTTYS 2048 285d522f475Smrg#endif 286d522f475Smrg#endif 287d522f475Smrg 288d522f475Smrg/* Until the translation manager comes along, I have to do my own translation of 289d522f475Smrg * mouse events into the proper routines. */ 290d522f475Smrg 291d522f475Smrgtypedef enum { 292d522f475Smrg NORMAL = 0 293d522f475Smrg , LEFTEXTENSION 294d522f475Smrg , RIGHTEXTENSION 295d522f475Smrg} EventMode; 296d522f475Smrg 297d522f475Smrg/* 298d522f475Smrg * The origin of a screen is 0, 0. Therefore, the number of rows 299d522f475Smrg * on a screen is screen->max_row + 1, and similarly for columns. 300d522f475Smrg */ 301d522f475Smrg#define MaxCols(screen) ((screen)->max_col + 1) 302d522f475Smrg#define MaxRows(screen) ((screen)->max_row + 1) 303d522f475Smrg 304d1603babSmrg#define MaxUChar 255 305d522f475Smrgtypedef unsigned char Char; /* to support 8 bit chars */ 306d522f475Smrgtypedef Char *ScrnPtr; 307d522f475Smrgtypedef ScrnPtr *ScrnBuf; 308d522f475Smrg 309cd3331d0Smrg/* 310cd3331d0Smrg * Declare an X String, but for unsigned chars. 311cd3331d0Smrg */ 312cd3331d0Smrg#ifdef _CONST_X_STRING 313cd3331d0Smrgtypedef const Char *UString; 314cd3331d0Smrg#else 315cd3331d0Smrgtypedef Char *UString; 316cd3331d0Smrg#endif 317cd3331d0Smrg 318190d7dceSmrg#define IsEmpty(s) ((s) == NULL || *(s) == '\0') 3199a64e1c5Smrg#define IsSpace(c) ((c) == ' ' || (c) == '\t' || (c) == '\r' || (c) == '\n') 320cd3331d0Smrg 321037a25ddSmrg/* 322037a25ddSmrg * Check strtol result, using "FullS2L" when no more data is expected, and 323037a25ddSmrg * "PartS2L" when more data may follow in the string. 324037a25ddSmrg */ 325037a25ddSmrg#define FullS2L(s,d) (PartS2L(s,d) && (*(d) == '\0')) 326190d7dceSmrg#define PartS2L(s,d) (isdigit(CharOf(*(s))) && (d) != (s) && (d) != NULL) 327037a25ddSmrg 328037a25ddSmrg#define CASETYPE(name) case name: result = #name; break 329037a25ddSmrg 330190d7dceSmrg#define AsciiOf(n) (0x7f & (n)) /* extract 7-bit character */ 331190d7dceSmrg#define CharOf(n) ((Char)(n)) /* extract 8-bit character */ 332d522f475Smrg 333d522f475Smrgtypedef struct { 334d522f475Smrg int row; 335d522f475Smrg int col; 336d522f475Smrg} CELL; 337d522f475Smrg 338d4fba8b9Smrgtypedef struct { 339d4fba8b9Smrg Char *data_buffer; /* the current selection */ 340d4fba8b9Smrg size_t data_limit; /* size of allocated buffer */ 341d4fba8b9Smrg size_t data_length; /* number of significant bytes */ 342d4fba8b9Smrg} SelectedCells; 343d4fba8b9Smrg 344d522f475Smrg#define isSameRow(a,b) ((a)->row == (b)->row) 345d522f475Smrg#define isSameCol(a,b) ((a)->col == (b)->col) 346d522f475Smrg#define isSameCELL(a,b) (isSameRow(a,b) && isSameCol(a,b)) 347d522f475Smrg 348d522f475Smrg#define xBIT(n) (1 << (n)) 349d522f475Smrg 350d522f475Smrg/* 351d522f475Smrg * ANSI emulation, special character codes 352d522f475Smrg */ 353cd3331d0Smrg#define ANSI_EOT 0x04 354d522f475Smrg#define ANSI_BEL 0x07 355cd3331d0Smrg#define ANSI_BS 0x08 356cd3331d0Smrg#define ANSI_HT 0x09 357cd3331d0Smrg#define ANSI_LF 0x0A 358cd3331d0Smrg#define ANSI_VT 0x0B 359d522f475Smrg#define ANSI_FF 0x0C /* C0, C1 control names */ 360cd3331d0Smrg#define ANSI_CR 0x0D 361cd3331d0Smrg#define ANSI_SO 0x0E 362cd3331d0Smrg#define ANSI_SI 0x0F 363cd3331d0Smrg#define ANSI_XON 0x11 /* DC1 */ 364cd3331d0Smrg#define ANSI_XOFF 0x13 /* DC3 */ 365d522f475Smrg#define ANSI_NAK 0x15 366d522f475Smrg#define ANSI_CAN 0x18 367d522f475Smrg#define ANSI_ESC 0x1B 368d522f475Smrg#define ANSI_SPA 0x20 369d522f475Smrg#define XTERM_POUND 0x1E /* internal mapping for '#' */ 370d522f475Smrg#define ANSI_DEL 0x7F 371d522f475Smrg#define ANSI_SS2 0x8E 372d522f475Smrg#define ANSI_SS3 0x8F 373d522f475Smrg#define ANSI_DCS 0x90 374d522f475Smrg#define ANSI_SOS 0x98 375d522f475Smrg#define ANSI_CSI 0x9B 376d522f475Smrg#define ANSI_ST 0x9C 377d522f475Smrg#define ANSI_OSC 0x9D 378d522f475Smrg#define ANSI_PM 0x9E 379d522f475Smrg#define ANSI_APC 0x9F 380980988aeSmrg#define XTERM_PUA 0xEEEE /* internal mapping for DEC Technical */ 381d522f475Smrg 382d4fba8b9Smrg#define BAD_ASCII '?' 383d4fba8b9Smrg#define NonLatin1(c) (((c) != ANSI_LF) && \ 384d4fba8b9Smrg ((c) != ANSI_HT) && \ 385d4fba8b9Smrg (((c) < ANSI_SPA) || \ 386d4fba8b9Smrg ((c) >= ANSI_DEL && (c) <= ANSI_APC))) 387d4fba8b9Smrg#define OnlyLatin1(c) (NonLatin1(c) ? BAD_ASCII : (c)) 388d4fba8b9Smrg 389d1603babSmrg#define L_BLOK '[' 390d1603babSmrg#define R_BLOK ']' 391d1603babSmrg 39294644356Smrg#define L_CURL '{' 39394644356Smrg#define R_CURL '}' 39494644356Smrg 395d522f475Smrg#define MIN_DECID 52 /* can emulate VT52 */ 3963367019cSmrg#define MAX_DECID 525 /* ...through VT525 */ 397d522f475Smrg 398d522f475Smrg#ifndef DFT_DECID 399d4fba8b9Smrg#define DFT_DECID "420" /* default VT420 */ 400d522f475Smrg#endif 401d522f475Smrg 402d522f475Smrg#ifndef DFT_KBD_DIALECT 403d522f475Smrg#define DFT_KBD_DIALECT "B" /* default USASCII */ 404d522f475Smrg#endif 405d522f475Smrg 4068f44fb3bSmrg#define MAX_I_PARAM 65535 /* parameters */ 4078f44fb3bSmrg#define MAX_I_DELAY 32767 /* time-delay in ReGIS */ 4088f44fb3bSmrg#define MAX_U_COLOR 65535u /* colors */ 4098f44fb3bSmrg#define MAX_U_COORD 32767u /* coordinates */ 4108f44fb3bSmrg#define MAX_U_STRING 65535u /* string-length */ 4118f44fb3bSmrg 412d522f475Smrg/* constants used for utf8 mode */ 413d522f475Smrg#define UCS_REPL 0xfffd 414d522f475Smrg#define UCS_LIMIT 0x80000000U /* both limit and flag for non-UCS */ 415d522f475Smrg 416d522f475Smrg#define TERMCAP_SIZE 1500 /* 1023 is standard; 'screen' exceeds */ 417d522f475Smrg 418dfb07bc7Smrg#define MAX_XLFD_FONTS 1 419d1603babSmrg#define MAX_XFT_FONTS 2 420d4fba8b9Smrg#define NMENUFONTS 10 /* font entries in fontMenu */ 421d522f475Smrg 422d522f475Smrg#define NBOX 5 /* Number of Points in box */ 423d522f475Smrg#define NPARAM 30 /* Max. parameters */ 424d522f475Smrg 425d522f475Smrgtypedef struct { 426cd3331d0Smrg String opt; 427cd3331d0Smrg String desc; 428d522f475Smrg} OptionHelp; 429d522f475Smrg 4303367019cSmrgtypedef struct { 4313367019cSmrg int count; /* number of values in params[] */ 4323367019cSmrg int has_subparams; /* true if there are any sub's */ 4333367019cSmrg int is_sub[NPARAM]; /* true for subparam */ 4343367019cSmrg int params[NPARAM]; /* parameter value */ 4353367019cSmrg} PARAMS; 4363367019cSmrg 4370d92cbfdSchristostypedef short ParmType; 438d4fba8b9Smrgtypedef unsigned short UParm; /* unparseputn passes ParmType */ 4390d92cbfdSchristos 440d1603babSmrg#define MaxSParm 0x7fff /* limit if a signed value is needed */ 441d1603babSmrg#define MaxUParm 0xffff /* limit if unsigned value is needed */ 442d1603babSmrg 443d1603babSmrg#define SParmOf(n) ((int)(ParmType)(n)) 444d1603babSmrg#define UParmOf(n) ((unsigned)(UParm)(n)) 445d1603babSmrg 446d522f475Smrgtypedef struct { 4470d92cbfdSchristos Char a_type; /* CSI, etc., see unparseq() */ 4480d92cbfdSchristos Char a_pintro; /* private-mode char, if any */ 4493367019cSmrg const char * a_delim; /* between parameters (;) */ 4500d92cbfdSchristos Char a_inters; /* special (before final-char) */ 4510d92cbfdSchristos Char a_final; /* final-char */ 4520d92cbfdSchristos ParmType a_nparam; /* # of parameters */ 4530d92cbfdSchristos ParmType a_param[NPARAM]; /* Parameters */ 4543367019cSmrg Char a_radix[NPARAM]; /* Parameters */ 455d522f475Smrg} ANSI; 456d522f475Smrg 457d522f475Smrg#define TEK_FONT_LARGE 0 458d522f475Smrg#define TEK_FONT_2 1 459d522f475Smrg#define TEK_FONT_3 2 460d522f475Smrg#define TEK_FONT_SMALL 3 461d522f475Smrg#define TEKNUMFONTS 4 462d522f475Smrg 463d522f475Smrg/* Actually there are 5 types of lines, but four are non-solid lines */ 464d522f475Smrg#define TEKNUMLINES 4 465d522f475Smrg 466d522f475Smrgtypedef struct { 467d522f475Smrg int x; 468d522f475Smrg int y; 469d522f475Smrg int fontsize; 470d522f475Smrg unsigned linetype; 471d522f475Smrg} Tmodes; 472d522f475Smrg 473d522f475Smrgtypedef struct { 474d522f475Smrg int Twidth; 475d522f475Smrg int Theight; 476d522f475Smrg} T_fontsize; 477d522f475Smrg 478d522f475Smrgtypedef struct { 479d522f475Smrg short *bits; 480d522f475Smrg int x; 481d522f475Smrg int y; 482d522f475Smrg int width; 483d522f475Smrg int height; 484d522f475Smrg} BitmapBits; 485d522f475Smrg 486980988aeSmrg/* bit-assignments for extensions to DECRQCRA, to omit DEC features */ 487d4fba8b9Smrgtypedef enum { 488d4fba8b9Smrg csDEC = 0 489980988aeSmrg ,csPOSITIVE = xBIT(0) /* do not negate the result */ 490980988aeSmrg ,csATTRIBS = xBIT(1) /* do not report the VT100 video attributes */ 491980988aeSmrg ,csNOTRIM = xBIT(2) /* do not omit checksum for blanks */ 492980988aeSmrg ,csDRAWN = xBIT(3) /* do not skip uninitialized cells */ 493980988aeSmrg ,csBYTE = xBIT(4) /* do not mask cell value to 8 bits or ignore combining chars */ 494d4fba8b9Smrg} CSBITS; 495d522f475Smrg 496d522f475Smrg#define EXCHANGE(a,b,tmp) tmp = a; a = b; b = tmp 497d522f475Smrg 498d522f475Smrg/***====================================================================***/ 499d522f475Smrg 500d522f475Smrg#if (XtSpecificationRelease < 6) 501d522f475Smrg#ifndef NO_ACTIVE_ICON 502d522f475Smrg#define NO_ACTIVE_ICON 1 /* Note: code relies on an X11R6 function */ 503d522f475Smrg#endif 504d522f475Smrg#endif 505d522f475Smrg 506d522f475Smrg#ifndef OPT_AIX_COLORS 507d522f475Smrg#define OPT_AIX_COLORS 1 /* true if xterm is configured with AIX (16) colors */ 508d522f475Smrg#endif 509d522f475Smrg 510b7c89284Ssnj#ifndef OPT_ALLOW_XXX_OPS 511b7c89284Ssnj#define OPT_ALLOW_XXX_OPS 1 /* true if xterm adds "Allow XXX Ops" submenu */ 512b7c89284Ssnj#endif 513b7c89284Ssnj 514d522f475Smrg#ifndef OPT_BLINK_CURS 515d522f475Smrg#define OPT_BLINK_CURS 1 /* true if xterm has blinking cursor capability */ 516d522f475Smrg#endif 517d522f475Smrg 518d522f475Smrg#ifndef OPT_BLINK_TEXT 519d522f475Smrg#define OPT_BLINK_TEXT OPT_BLINK_CURS /* true if xterm has blinking text capability */ 520d522f475Smrg#endif 521d522f475Smrg 522190d7dceSmrg#ifndef OPT_BLOCK_SELECT 523190d7dceSmrg#define OPT_BLOCK_SELECT 0 /* true if block-select is supported */ 524190d7dceSmrg#endif 525190d7dceSmrg 526d522f475Smrg#ifndef OPT_BOX_CHARS 527d522f475Smrg#define OPT_BOX_CHARS 1 /* true if xterm can simulate box-characters */ 528d522f475Smrg#endif 529d522f475Smrg 5303367019cSmrg#ifndef OPT_BUILTIN_XPMS 5313367019cSmrg#define OPT_BUILTIN_XPMS 0 /* true if all xpm data is compiled-in */ 5323367019cSmrg#endif 5333367019cSmrg 534d522f475Smrg#ifndef OPT_BROKEN_OSC 535d522f475Smrg#ifdef linux 536d522f475Smrg#define OPT_BROKEN_OSC 1 /* man console_codes, 1st paragraph - cf: ECMA-48 */ 537d522f475Smrg#else 538d522f475Smrg#define OPT_BROKEN_OSC 0 /* true if xterm allows Linux's broken OSC parsing */ 539d522f475Smrg#endif 540d522f475Smrg#endif 541d522f475Smrg 542d522f475Smrg#ifndef OPT_BROKEN_ST 543d522f475Smrg#define OPT_BROKEN_ST 1 /* true if xterm allows old/broken OSC parsing */ 544d522f475Smrg#endif 545d522f475Smrg 546d522f475Smrg#ifndef OPT_C1_PRINT 547d522f475Smrg#define OPT_C1_PRINT 1 /* true if xterm allows C1 controls to be printable */ 548d522f475Smrg#endif 549d522f475Smrg 550d522f475Smrg#ifndef OPT_CLIP_BOLD 551d522f475Smrg#define OPT_CLIP_BOLD 1 /* true if xterm uses clipping to avoid bold-trash */ 552d522f475Smrg#endif 553d522f475Smrg 554d522f475Smrg#ifndef OPT_COLOR_CLASS 555d522f475Smrg#define OPT_COLOR_CLASS 1 /* true if xterm uses separate color-resource classes */ 556d522f475Smrg#endif 557d522f475Smrg 558d522f475Smrg#ifndef OPT_DABBREV 559d522f475Smrg#define OPT_DABBREV 0 /* dynamic abbreviations */ 560d522f475Smrg#endif 561d522f475Smrg 562d522f475Smrg#ifndef OPT_DEC_CHRSET 563d522f475Smrg#define OPT_DEC_CHRSET 1 /* true if xterm is configured for DEC charset */ 564d522f475Smrg#endif 565d522f475Smrg 566d522f475Smrg#ifndef OPT_DEC_LOCATOR 567d522f475Smrg#define OPT_DEC_LOCATOR 0 /* true if xterm supports VT220-style mouse events */ 568d522f475Smrg#endif 569d522f475Smrg 570d522f475Smrg#ifndef OPT_DEC_RECTOPS 571d4fba8b9Smrg#define OPT_DEC_RECTOPS 1 /* true if xterm is configured for VT420 rectangles */ 572d522f475Smrg#endif 573d522f475Smrg 574d1603babSmrg#ifndef OPT_SGR2_HASH 575d1603babSmrg#define OPT_SGR2_HASH 1 /* true if xterm hashes color-lookups for faint color */ 576d1603babSmrg#endif 577d1603babSmrg 578fa3f02f3Smrg#ifndef OPT_SIXEL_GRAPHICS 5799a64e1c5Smrg#define OPT_SIXEL_GRAPHICS 0 /* true if xterm supports VT240-style sixel graphics */ 5809a64e1c5Smrg#endif 5819a64e1c5Smrg 582d4fba8b9Smrg#ifndef OPT_PRINT_GRAPHICS 583d4fba8b9Smrg#define OPT_PRINT_GRAPHICS 0 /* true if xterm supports screen dumps as sixel graphics */ 584d4fba8b9Smrg#endif 585d4fba8b9Smrg 586037a25ddSmrg#ifndef OPT_SCREEN_DUMPS 587d4fba8b9Smrg#define OPT_SCREEN_DUMPS 1 /* true if xterm supports screen dumps */ 588037a25ddSmrg#endif 589037a25ddSmrg 5909a64e1c5Smrg#ifndef OPT_REGIS_GRAPHICS 5919a64e1c5Smrg#define OPT_REGIS_GRAPHICS 0 /* true if xterm supports VT125/VT240/VT330 ReGIS graphics */ 5929a64e1c5Smrg#endif 5939a64e1c5Smrg 5949a64e1c5Smrg#ifndef OPT_GRAPHICS 5959a64e1c5Smrg#define OPT_GRAPHICS 0 /* true if xterm is configured for any type of graphics */ 596fa3f02f3Smrg#endif 597fa3f02f3Smrg 598d522f475Smrg#ifndef OPT_DEC_SOFTFONT 599d522f475Smrg#define OPT_DEC_SOFTFONT 0 /* true if xterm is configured for VT220 softfonts */ 600d522f475Smrg#endif 601d522f475Smrg 6023367019cSmrg#ifndef OPT_DOUBLE_BUFFER 6033367019cSmrg#define OPT_DOUBLE_BUFFER 0 /* true if using double-buffering */ 6043367019cSmrg#endif 6053367019cSmrg 606d1603babSmrg#ifndef OPT_EXEC_SELECTION 607d1603babSmrg#define OPT_EXEC_SELECTION 1 /* true if xterm can exec to process selection */ 608d1603babSmrg#endif 609d1603babSmrg 610d522f475Smrg#ifndef OPT_EXEC_XTERM 611d522f475Smrg#define OPT_EXEC_XTERM 0 /* true if xterm can fork/exec copies of itself */ 612d522f475Smrg#endif 613d522f475Smrg 614d522f475Smrg#ifndef OPT_EXTRA_PASTE 615d522f475Smrg#define OPT_EXTRA_PASTE 1 616d522f475Smrg#endif 617d522f475Smrg 618d522f475Smrg#ifndef OPT_FOCUS_EVENT 619d522f475Smrg#define OPT_FOCUS_EVENT 1 /* focus in/out events */ 620d522f475Smrg#endif 621d522f475Smrg 622d522f475Smrg#ifndef OPT_HP_FUNC_KEYS 623d522f475Smrg#define OPT_HP_FUNC_KEYS 0 /* true if xterm supports HP-style function keys */ 624d522f475Smrg#endif 625d522f475Smrg 626d522f475Smrg#ifndef OPT_I18N_SUPPORT 627d522f475Smrg#if (XtSpecificationRelease >= 5) 628d522f475Smrg#define OPT_I18N_SUPPORT 1 /* true if xterm uses internationalization support */ 629d522f475Smrg#else 630d522f475Smrg#define OPT_I18N_SUPPORT 0 631d522f475Smrg#endif 632d522f475Smrg#endif 633d522f475Smrg 634d522f475Smrg#ifndef OPT_INITIAL_ERASE 635d522f475Smrg#define OPT_INITIAL_ERASE 1 /* use pty's erase character if it's not 128 */ 636d522f475Smrg#endif 637d522f475Smrg 638d522f475Smrg#ifndef OPT_INPUT_METHOD 639d522f475Smrg#if (XtSpecificationRelease >= 6) 640d4fba8b9Smrg#define OPT_INPUT_METHOD OPT_I18N_SUPPORT /* true if xterm uses input-method support */ 641d522f475Smrg#else 642d522f475Smrg#define OPT_INPUT_METHOD 0 643d522f475Smrg#endif 644d522f475Smrg#endif 645d522f475Smrg 646d522f475Smrg#ifndef OPT_ISO_COLORS 647d522f475Smrg#define OPT_ISO_COLORS 1 /* true if xterm is configured with ISO colors */ 648d522f475Smrg#endif 649d522f475Smrg 650d4fba8b9Smrg#ifndef OPT_DIRECT_COLOR 651d4fba8b9Smrg#define OPT_DIRECT_COLOR OPT_ISO_COLORS /* true if xterm is configured with direct-colors */ 652d4fba8b9Smrg#endif 653d4fba8b9Smrg 654d522f475Smrg#ifndef OPT_256_COLORS 655d4fba8b9Smrg#define OPT_256_COLORS 1 /* true if xterm is configured with 256 colors */ 656d522f475Smrg#endif 657d522f475Smrg 658d522f475Smrg#ifndef OPT_88_COLORS 659d4fba8b9Smrg#define OPT_88_COLORS 1 /* true if xterm is configured with 88 colors */ 660d522f475Smrg#endif 661d522f475Smrg 662d522f475Smrg#ifndef OPT_HIGHLIGHT_COLOR 663d522f475Smrg#define OPT_HIGHLIGHT_COLOR 1 /* true if xterm supports color highlighting */ 664d522f475Smrg#endif 665d522f475Smrg 666d522f475Smrg#ifndef OPT_LOAD_VTFONTS 667d522f475Smrg#define OPT_LOAD_VTFONTS 0 /* true if xterm has load-vt-fonts() action */ 668d522f475Smrg#endif 669d522f475Smrg 670d522f475Smrg#ifndef OPT_LUIT_PROG 671d4fba8b9Smrg#define OPT_LUIT_PROG 1 /* true if xterm supports luit */ 672d522f475Smrg#endif 673d522f475Smrg 674d522f475Smrg#ifndef OPT_MAXIMIZE 675d522f475Smrg#define OPT_MAXIMIZE 1 /* add actions for iconify ... maximize */ 676d522f475Smrg#endif 677d522f475Smrg 678d522f475Smrg#ifndef OPT_MINI_LUIT 679d522f475Smrg#define OPT_MINI_LUIT 0 /* true if xterm supports built-in mini-luit */ 680d522f475Smrg#endif 681d522f475Smrg 682d522f475Smrg#ifndef OPT_MOD_FKEYS 683d522f475Smrg#define OPT_MOD_FKEYS 1 /* modify cursor- and function-keys in normal mode */ 684d522f475Smrg#endif 685d522f475Smrg 686d522f475Smrg#ifndef OPT_NUM_LOCK 687d522f475Smrg#define OPT_NUM_LOCK 1 /* use NumLock key only for numeric-keypad */ 688d522f475Smrg#endif 689d522f475Smrg 690d522f475Smrg#ifndef OPT_PASTE64 691d4fba8b9Smrg#define OPT_PASTE64 1 /* program control of select/paste via base64 */ 692d522f475Smrg#endif 693d522f475Smrg 694d522f475Smrg#ifndef OPT_PC_COLORS 695d522f475Smrg#define OPT_PC_COLORS 1 /* true if xterm supports PC-style (bold) colors */ 696d522f475Smrg#endif 697d522f475Smrg 698712a7ff4Smrg#ifndef OPT_PRINT_ON_EXIT 699712a7ff4Smrg#define OPT_PRINT_ON_EXIT 1 /* true allows xterm to dump screen on X error */ 700712a7ff4Smrg#endif 701712a7ff4Smrg 702d522f475Smrg#ifndef OPT_PTY_HANDSHAKE 703d522f475Smrg#define OPT_PTY_HANDSHAKE USE_HANDSHAKE /* avoid pty races on older systems */ 704d522f475Smrg#endif 705d522f475Smrg 706d522f475Smrg#ifndef OPT_PRINT_COLORS 707d522f475Smrg#define OPT_PRINT_COLORS 1 /* true if we print color information */ 708d522f475Smrg#endif 709d522f475Smrg 710d522f475Smrg#ifndef OPT_READLINE 711d522f475Smrg#define OPT_READLINE 0 /* mouse-click/paste support for readline */ 712d522f475Smrg#endif 713d522f475Smrg 714d522f475Smrg#ifndef OPT_RENDERFONT 715d522f475Smrg#ifdef XRENDERFONT 716d522f475Smrg#define OPT_RENDERFONT 1 717d522f475Smrg#else 718d522f475Smrg#define OPT_RENDERFONT 0 719d522f475Smrg#endif 720d522f475Smrg#endif 721d522f475Smrg 722d522f475Smrg#ifndef OPT_RENDERWIDE 723d522f475Smrg#if OPT_RENDERFONT && OPT_WIDE_CHARS && defined(HAVE_TYPE_XFTCHARSPEC) 724d522f475Smrg#define OPT_RENDERWIDE 1 725d522f475Smrg#else 726d522f475Smrg#define OPT_RENDERWIDE 0 727d522f475Smrg#endif 728d522f475Smrg#endif 729d522f475Smrg 730dfb07bc7Smrg#ifndef OPT_REPORT_CCLASS 731dfb07bc7Smrg#define OPT_REPORT_CCLASS 1 /* provide "-report-charclass" option */ 732dfb07bc7Smrg#endif 733dfb07bc7Smrg 734fa3f02f3Smrg#ifndef OPT_REPORT_COLORS 735fa3f02f3Smrg#define OPT_REPORT_COLORS 1 /* provide "-report-colors" option */ 736fa3f02f3Smrg#endif 737fa3f02f3Smrg 738fa3f02f3Smrg#ifndef OPT_REPORT_FONTS 739fa3f02f3Smrg#define OPT_REPORT_FONTS 1 /* provide "-report-fonts" option */ 740fa3f02f3Smrg#endif 741fa3f02f3Smrg 742d4fba8b9Smrg#ifndef OPT_REPORT_ICONS 743d4fba8b9Smrg#define OPT_REPORT_ICONS 1 /* provide "-report-icons" option */ 744d4fba8b9Smrg#endif 745d4fba8b9Smrg 746d522f475Smrg#ifndef OPT_SAME_NAME 747d522f475Smrg#define OPT_SAME_NAME 1 /* suppress redundant updates of title, icon, etc. */ 748d522f475Smrg#endif 749d522f475Smrg 750d522f475Smrg#ifndef OPT_SCO_FUNC_KEYS 751d522f475Smrg#define OPT_SCO_FUNC_KEYS 0 /* true if xterm supports SCO-style function keys */ 752d522f475Smrg#endif 753d522f475Smrg 754d522f475Smrg#ifndef OPT_SUN_FUNC_KEYS 755d522f475Smrg#define OPT_SUN_FUNC_KEYS 1 /* true if xterm supports Sun-style function keys */ 756d522f475Smrg#endif 757d522f475Smrg 758cd3331d0Smrg#ifndef OPT_SCROLL_LOCK 759cd3331d0Smrg#define OPT_SCROLL_LOCK 1 /* true if xterm interprets fontsize-shifting */ 760cd3331d0Smrg#endif 761cd3331d0Smrg 762d522f475Smrg#ifndef OPT_SELECT_REGEX 763d4fba8b9Smrg#define OPT_SELECT_REGEX 1 /* true if xterm supports regular-expression selects */ 764d522f475Smrg#endif 765d522f475Smrg 7663367019cSmrg#ifndef OPT_SELECTION_OPS 7673367019cSmrg#define OPT_SELECTION_OPS 1 /* true if xterm supports operations on selection */ 7683367019cSmrg#endif 7693367019cSmrg 770d522f475Smrg#ifndef OPT_SESSION_MGT 771d522f475Smrg#if defined(XtNdieCallback) && defined(XtNsaveCallback) 772d522f475Smrg#define OPT_SESSION_MGT 1 773d522f475Smrg#else 774d522f475Smrg#define OPT_SESSION_MGT 0 775d522f475Smrg#endif 776d522f475Smrg#endif 777d522f475Smrg 778d522f475Smrg#ifndef OPT_SHIFT_FONTS 779781b53c7Schristos#define OPT_SHIFT_FONTS 0 /* true if xterm interprets fontsize-shifting */ 780d522f475Smrg#endif 781d522f475Smrg 78250027b5bSmrg#ifndef OPT_STATUS_LINE 78350027b5bSmrg#define OPT_STATUS_LINE 0 /* true if xterm supports status-line controls */ 78450027b5bSmrg#endif 78550027b5bSmrg 786d522f475Smrg#ifndef OPT_SUNPC_KBD 787d522f475Smrg#define OPT_SUNPC_KBD 1 /* true if xterm supports Sun/PC keyboard map */ 788d522f475Smrg#endif 789d522f475Smrg 790d522f475Smrg#ifndef OPT_TCAP_FKEYS 791d4fba8b9Smrg#define OPT_TCAP_FKEYS 1 /* true for termcap function-keys */ 792d522f475Smrg#endif 793d522f475Smrg 794d522f475Smrg#ifndef OPT_TCAP_QUERY 795d4fba8b9Smrg#define OPT_TCAP_QUERY 1 /* true for termcap query */ 796d522f475Smrg#endif 797d522f475Smrg 798d522f475Smrg#ifndef OPT_TEK4014 799d522f475Smrg#define OPT_TEK4014 1 /* true if we're using tek4014 emulation */ 800d522f475Smrg#endif 801d522f475Smrg 802d522f475Smrg#ifndef OPT_TOOLBAR 803d522f475Smrg#define OPT_TOOLBAR 0 /* true if xterm supports toolbar menus */ 804d522f475Smrg#endif 805d522f475Smrg 806d522f475Smrg#ifndef OPT_TRACE 807d522f475Smrg#define OPT_TRACE 0 /* true if we're using debugging traces */ 808d522f475Smrg#endif 809d522f475Smrg 810d522f475Smrg#ifndef OPT_TRACE_FLAGS 811d522f475Smrg#define OPT_TRACE_FLAGS 0 /* additional tracing used for SCRN_BUF_FLAGS */ 812d522f475Smrg#endif 813d522f475Smrg 814d4fba8b9Smrg#ifndef OPT_TRACE_UNIQUE 815d4fba8b9Smrg#define OPT_TRACE_UNIQUE 0 /* true if we're using multiple trace files */ 816d4fba8b9Smrg#endif 817d4fba8b9Smrg 818d522f475Smrg#ifndef OPT_VT52_MODE 819d522f475Smrg#define OPT_VT52_MODE 1 /* true if xterm supports VT52 emulation */ 820d522f475Smrg#endif 821d522f475Smrg 8229a64e1c5Smrg#ifndef OPT_WIDE_ATTRS 8239a64e1c5Smrg#define OPT_WIDE_ATTRS 1 /* true if xterm supports 16-bit attributes */ 8249a64e1c5Smrg#endif 8259a64e1c5Smrg 826980988aeSmrg#ifndef OPT_VT525_COLORS 827980988aeSmrg#define OPT_VT525_COLORS 1 /* true if xterm is configured for VT525 colors */ 828980988aeSmrg#endif 829980988aeSmrg 830d522f475Smrg#ifndef OPT_WIDE_CHARS 831d4fba8b9Smrg#define OPT_WIDE_CHARS 1 /* true if xterm supports 16-bit characters */ 832d522f475Smrg#endif 833d522f475Smrg 834b7c89284Ssnj#ifndef OPT_WIDER_ICHAR 835b7c89284Ssnj#define OPT_WIDER_ICHAR 1 /* true if xterm uses 32-bits for wide-chars */ 836b7c89284Ssnj#endif 837b7c89284Ssnj 838d522f475Smrg#ifndef OPT_XMC_GLITCH 839d522f475Smrg#define OPT_XMC_GLITCH 0 /* true if xterm supports xmc (magic cookie glitch) */ 840d522f475Smrg#endif 841d522f475Smrg 842d4fba8b9Smrg#ifndef OPT_XRES_QUERY 843d4fba8b9Smrg#define OPT_XRES_QUERY 1 /* true for resource query */ 844d4fba8b9Smrg#endif 845d4fba8b9Smrg 846d4fba8b9Smrg#ifndef OPT_XTERM_SGR 847d4fba8b9Smrg#define OPT_XTERM_SGR 1 /* true if xterm supports private SGR controls */ 848d4fba8b9Smrg#endif 849d4fba8b9Smrg 850d522f475Smrg#ifndef OPT_ZICONBEEP 851d522f475Smrg#define OPT_ZICONBEEP 1 /* true if xterm supports "-ziconbeep" option */ 852d522f475Smrg#endif 853d522f475Smrg 854d522f475Smrg/***====================================================================***/ 855d522f475Smrg 856d522f475Smrg#if OPT_AIX_COLORS && !OPT_ISO_COLORS 857d522f475Smrg/* You must have ANSI/ISO colors to support AIX colors */ 858d522f475Smrg#undef OPT_AIX_COLORS 859d522f475Smrg#define OPT_AIX_COLORS 0 860d522f475Smrg#endif 861d522f475Smrg 862d522f475Smrg#if OPT_PC_COLORS && !OPT_ISO_COLORS 863d522f475Smrg/* You must have ANSI/ISO colors to support PC colors */ 864d522f475Smrg#undef OPT_PC_COLORS 865d522f475Smrg#define OPT_PC_COLORS 0 866d522f475Smrg#endif 867d522f475Smrg 868d522f475Smrg#if OPT_PRINT_COLORS && !OPT_ISO_COLORS 869d522f475Smrg/* You must have ANSI/ISO colors to be able to print them */ 870d522f475Smrg#undef OPT_PRINT_COLORS 871d522f475Smrg#define OPT_PRINT_COLORS 0 872d522f475Smrg#endif 873d522f475Smrg 874d522f475Smrg#if OPT_256_COLORS && !OPT_ISO_COLORS 875d522f475Smrg/* You must have ANSI/ISO colors to support 256 colors */ 876d522f475Smrg#undef OPT_256_COLORS 877d522f475Smrg#define OPT_256_COLORS 0 878d522f475Smrg#endif 879d522f475Smrg 880d522f475Smrg#if OPT_88_COLORS && !OPT_ISO_COLORS 881d522f475Smrg/* You must have ANSI/ISO colors to support 88 colors */ 882d522f475Smrg#undef OPT_88_COLORS 883d522f475Smrg#define OPT_88_COLORS 0 884d522f475Smrg#endif 885d522f475Smrg 886d522f475Smrg#if OPT_88_COLORS && OPT_256_COLORS 887d522f475Smrg/* 256 colors supersedes 88 colors */ 888d522f475Smrg#undef OPT_88_COLORS 889d522f475Smrg#define OPT_88_COLORS 0 890d522f475Smrg#endif 891d522f475Smrg 892d522f475Smrg/***====================================================================***/ 893d522f475Smrg 894d522f475Smrg/* 895d522f475Smrg * Indices for menu_font_names[][] 896d522f475Smrg */ 897d522f475Smrgtypedef enum { 898d522f475Smrg fNorm = 0 /* normal font */ 899d522f475Smrg , fBold /* bold font */ 900dfb07bc7Smrg#if OPT_WIDE_ATTRS || OPT_RENDERWIDE 901dfb07bc7Smrg , fItal /* italic font */ 902d4fba8b9Smrg , fBtal /* bold-italic font */ 903dfb07bc7Smrg#endif 904d522f475Smrg#if OPT_WIDE_CHARS 905d522f475Smrg , fWide /* double-width font */ 906d522f475Smrg , fWBold /* double-width bold font */ 907dfb07bc7Smrg , fWItal /* double-width italic font */ 908d4fba8b9Smrg , fWBtal /* double-width bold-italic font */ 909d522f475Smrg#endif 910d522f475Smrg , fMAX 911d522f475Smrg} VTFontEnum; 912d522f475Smrg 913d522f475Smrg/* 914d522f475Smrg * Indices for cachedGCs.c (unrelated to VTFontEnum). 915d522f475Smrg */ 916d522f475Smrgtypedef enum { 917d522f475Smrg gcNorm = 0 918d522f475Smrg , gcBold 919d522f475Smrg , gcNormReverse 920d522f475Smrg , gcBoldReverse 921d4fba8b9Smrg , gcFiller 922d4fba8b9Smrg , gcBorder 923980988aeSmrg#if OPT_BOX_CHARS || OPT_WIDE_CHARS 924d522f475Smrg , gcLine 925d522f475Smrg , gcDots 926d522f475Smrg#endif 927d522f475Smrg#if OPT_DEC_CHRSET 928d522f475Smrg , gcCNorm 929d522f475Smrg , gcCBold 930d522f475Smrg#endif 931d522f475Smrg#if OPT_WIDE_CHARS 932d522f475Smrg , gcWide 933d522f475Smrg , gcWBold 934d522f475Smrg , gcWideReverse 935d522f475Smrg , gcWBoldReverse 936d522f475Smrg#endif 937d522f475Smrg , gcVTcursNormal 938d522f475Smrg , gcVTcursFilled 939d522f475Smrg , gcVTcursReverse 940d522f475Smrg , gcVTcursOutline 941d522f475Smrg#if OPT_TEK4014 942d522f475Smrg , gcTKcurs 943d522f475Smrg#endif 944d522f475Smrg , gcMAX 945d522f475Smrg} CgsEnum; 946d522f475Smrg 947d522f475Smrg#define for_each_text_gc(n) for (n = gcNorm; n < gcVTcursNormal; ++n) 948d522f475Smrg#define for_each_curs_gc(n) for (n = gcVTcursNormal; n <= gcVTcursOutline; ++n) 949d522f475Smrg#define for_each_gc(n) for (n = gcNorm; n < gcMAX; ++n) 950d522f475Smrg 951cd3331d0Smrg/* 952cd3331d0Smrg * Indices for the normal terminal colors in screen.Tcolors[]. 953cd3331d0Smrg * See also OscTextColors, which has corresponding values. 954cd3331d0Smrg */ 955d522f475Smrgtypedef enum { 956d522f475Smrg TEXT_FG = 0 /* text foreground */ 957d522f475Smrg , TEXT_BG /* text background */ 958d522f475Smrg , TEXT_CURSOR /* text cursor */ 959d522f475Smrg , MOUSE_FG /* mouse foreground */ 960d522f475Smrg , MOUSE_BG /* mouse background */ 961d522f475Smrg#if OPT_TEK4014 9623367019cSmrg , TEK_FG = 5 /* tektronix foreground */ 963d522f475Smrg , TEK_BG /* tektronix background */ 964d522f475Smrg#endif 965d522f475Smrg#if OPT_HIGHLIGHT_COLOR 9663367019cSmrg , HIGHLIGHT_BG = 7 /* highlight background */ 9673367019cSmrg#endif 9683367019cSmrg#if OPT_TEK4014 9693367019cSmrg , TEK_CURSOR = 8 /* tektronix cursor */ 9703367019cSmrg#endif 9713367019cSmrg#if OPT_HIGHLIGHT_COLOR 9723367019cSmrg , HIGHLIGHT_FG = 9 /* highlight foreground */ 973d522f475Smrg#endif 974d522f475Smrg , NCOLORS /* total number of colors */ 975d522f475Smrg} TermColors; 976d522f475Smrg 97794644356Smrg/* 97894644356Smrg * Definitions for exec-formatted and insert-formatted actions. 97994644356Smrg */ 98094644356Smrgtypedef void (*FormatSelect) (Widget, char *, char *, CELL *, CELL *); 98194644356Smrg 98294644356Smrgtypedef struct { 983d4fba8b9Smrg Boolean done; 98494644356Smrg char *format; 98594644356Smrg char *buffer; 98694644356Smrg FormatSelect format_select; 98794644356Smrg#if OPT_PASTE64 98894644356Smrg Cardinal base64_paste; 98994644356Smrg#endif 990d4fba8b9Smrg#if OPT_PASTE64 || OPT_READLINE 99194644356Smrg unsigned paste_brackets; 99294644356Smrg#endif 99394644356Smrg} InternalSelect; 99494644356Smrg 995cd3331d0Smrg/* 996cd3331d0Smrg * Constants for titleModes resource 997cd3331d0Smrg */ 998cd3331d0Smrgtypedef enum { 999cd3331d0Smrg tmSetBase16 = 1 /* set title using hex-string */ 1000cd3331d0Smrg , tmGetBase16 = 2 /* get title using hex-string */ 1001cd3331d0Smrg#if OPT_WIDE_CHARS 1002190d7dceSmrg#define MAX_TITLEMODE 3 1003cd3331d0Smrg , tmSetUtf8 = 4 /* like utf8Title, but controllable */ 1004cd3331d0Smrg , tmGetUtf8 = 8 /* retrieve title encoded as UTF-8 */ 1005190d7dceSmrg#else 1006190d7dceSmrg#define MAX_TITLEMODE 1 1007cd3331d0Smrg#endif 1008cd3331d0Smrg} TitleModes; 1009cd3331d0Smrg 1010190d7dceSmrg#define ValidTitleMode(code) ((code) >= 0 && (code) <= MAX_TITLEMODE) 1011cd3331d0Smrg#define IsTitleMode(xw,mode) (((xw)->screen.title_modes & mode) != 0) 1012cd3331d0Smrg 1013190d7dceSmrg#define IsSetUtf8Title(xw) (IsTitleMode(xw, tmSetUtf8) \ 1014190d7dceSmrg || ((xw)->screen.utf8_title) \ 1015190d7dceSmrg || ((xw)->screen.c1_printable)) 1016190d7dceSmrg 1017fa3f02f3Smrg#include <xcharmouse.h> 1018fa3f02f3Smrg 1019fa3f02f3Smrg/* 1020fa3f02f3Smrg * For readability... 1021fa3f02f3Smrg */ 1022fa3f02f3Smrg#define nrc_percent 100 1023fa3f02f3Smrg#define nrc_dquote 200 1024fa3f02f3Smrg#define nrc_ampersand 300 1025fa3f02f3Smrgtypedef enum { 1026fa3f02f3Smrg nrc_ASCII = 0 1027fa3f02f3Smrg ,nrc_British /* vt100 */ 1028fa3f02f3Smrg ,nrc_British_Latin_1 /* vt3xx */ 1029d4fba8b9Smrg ,nrc_DEC_Cyrillic /* vt5xx */ 1030fa3f02f3Smrg ,nrc_DEC_Spec_Graphic /* vt100 */ 1031fa3f02f3Smrg ,nrc_DEC_Alt_Chars /* vt100 */ 1032fa3f02f3Smrg ,nrc_DEC_Alt_Graphics /* vt100 */ 1033fa3f02f3Smrg ,nrc_DEC_Supp /* vt2xx */ 1034fa3f02f3Smrg ,nrc_DEC_Supp_Graphic /* vt3xx */ 1035fa3f02f3Smrg ,nrc_DEC_Technical /* vt3xx */ 1036980988aeSmrg ,nrc_DEC_UPSS /* vt3xx */ 1037fa3f02f3Smrg ,nrc_Dutch /* vt2xx */ 1038fa3f02f3Smrg ,nrc_Finnish /* vt2xx */ 1039fa3f02f3Smrg ,nrc_Finnish2 /* vt2xx */ 1040fa3f02f3Smrg ,nrc_French /* vt2xx */ 1041fa3f02f3Smrg ,nrc_French2 /* vt2xx */ 1042fa3f02f3Smrg ,nrc_French_Canadian /* vt2xx */ 1043fa3f02f3Smrg ,nrc_French_Canadian2 /* vt3xx */ 1044fa3f02f3Smrg ,nrc_German /* vt2xx */ 1045fa3f02f3Smrg ,nrc_Greek /* vt5xx */ 1046d4fba8b9Smrg ,nrc_DEC_Greek_Supp /* vt5xx */ 1047d4fba8b9Smrg ,nrc_ISO_Greek_Supp /* vt5xx */ 1048d4fba8b9Smrg ,nrc_DEC_Hebrew_Supp /* vt5xx */ 1049fa3f02f3Smrg ,nrc_Hebrew /* vt5xx */ 1050d4fba8b9Smrg ,nrc_ISO_Hebrew_Supp /* vt5xx */ 1051fa3f02f3Smrg ,nrc_Italian /* vt2xx */ 1052980988aeSmrg ,nrc_ISO_Latin_1_Supp /* vt3xx */ 1053d4fba8b9Smrg ,nrc_ISO_Latin_2_Supp /* vt5xx */ 1054d4fba8b9Smrg ,nrc_ISO_Latin_5_Supp /* vt5xx */ 1055d4fba8b9Smrg ,nrc_ISO_Latin_Cyrillic /* vt5xx */ 1056190d7dceSmrg ,nrc_JIS_Katakana /* vt382 */ 1057190d7dceSmrg ,nrc_JIS_Roman /* vt382 */ 1058fa3f02f3Smrg ,nrc_Norwegian_Danish /* vt3xx */ 1059fa3f02f3Smrg ,nrc_Norwegian_Danish2 /* vt2xx */ 1060fa3f02f3Smrg ,nrc_Norwegian_Danish3 /* vt2xx */ 1061fa3f02f3Smrg ,nrc_Portugese /* vt3xx */ 1062fa3f02f3Smrg ,nrc_Russian /* vt5xx */ 1063fa3f02f3Smrg ,nrc_SCS_NRCS /* vt5xx - probably Serbo/Croatian */ 1064fa3f02f3Smrg ,nrc_Spanish /* vt2xx */ 1065fa3f02f3Smrg ,nrc_Swedish /* vt2xx */ 1066fa3f02f3Smrg ,nrc_Swedish2 /* vt2xx */ 1067fa3f02f3Smrg ,nrc_Swiss /* vt2xx */ 1068d4fba8b9Smrg ,nrc_DEC_Turkish_Supp /* vt5xx */ 1069fa3f02f3Smrg ,nrc_Turkish /* vt5xx */ 1070fa3f02f3Smrg ,nrc_Unknown 1071fa3f02f3Smrg} DECNRCM_codes; 1072fa3f02f3Smrg 1073980988aeSmrg/* 1074980988aeSmrg * Default and alternate codes for user-preferred supplemental set. 1075980988aeSmrg */ 1076980988aeSmrg#define DFT_UPSS nrc_DEC_Supp_Graphic 1077980988aeSmrg#define ALT_UPSS nrc_ISO_Latin_1_Supp 1078980988aeSmrg#define PreferredUPSS(screen) ((screen)->prefer_latin1 ? ALT_UPSS : DFT_UPSS) 1079980988aeSmrg 1080fa3f02f3Smrg/* 1081fa3f02f3Smrg * Use this enumerated type to check consistency among dpmodes(), savemodes() 1082d4fba8b9Smrg * restoremodes() and do_dec_rqm(). 1083fa3f02f3Smrg */ 1084fa3f02f3Smrgtypedef enum { 1085980988aeSmrg srm_DECCKM = 1 /* Cursor Keys Mode */ 1086980988aeSmrg ,srm_DECANM = 2 /* ANSI Mode */ 1087980988aeSmrg ,srm_DECCOLM = 3 /* Column Mode */ 1088980988aeSmrg ,srm_DECSCLM = 4 /* Scrolling Mode */ 1089980988aeSmrg ,srm_DECSCNM = 5 /* Screen Mode */ 1090980988aeSmrg ,srm_DECOM = 6 /* Origin Mode */ 1091980988aeSmrg ,srm_DECAWM = 7 /* Autowrap Mode */ 1092980988aeSmrg ,srm_DECARM = 8 /* Autorepeat Mode */ 1093fa3f02f3Smrg ,srm_X10_MOUSE = SET_X10_MOUSE 1094fa3f02f3Smrg#if OPT_TOOLBAR 1095fa3f02f3Smrg ,srm_RXVT_TOOLBAR = 10 1096190d7dceSmrg#else 1097190d7dceSmrg ,srm_DECEDM = 10 /* vt330:edit */ 1098fa3f02f3Smrg#endif 1099190d7dceSmrg ,srm_DECLTM = 11 /* vt330:line transmit */ 1100fa3f02f3Smrg#if OPT_BLINK_CURS 1101fa3f02f3Smrg ,srm_ATT610_BLINK = 12 1102d4fba8b9Smrg ,srm_CURSOR_BLINK_OPS = 13 1103d4fba8b9Smrg ,srm_XOR_CURSOR_BLINKS = 14 1104190d7dceSmrg#else 1105190d7dceSmrg ,srm_DECKANAM = 12 /* vt382:Katakana shift */ 1106190d7dceSmrg ,srm_DECSCFDM = 13 /* vt330:space compression field delimiter */ 1107190d7dceSmrg ,srm_DECTEM = 14 /* vt330:transmission execution */ 1108fa3f02f3Smrg#endif 1109190d7dceSmrg ,srm_DECEKEM = 16 /* vt330:edit key execution */ 1110190d7dceSmrg ,srm_DECPFF = 18 /* vt220:Print Form Feed Mode */ 1111190d7dceSmrg ,srm_DECPEX = 19 /* vt220:Printer Extent Mode */ 1112980988aeSmrg ,srm_DECTCEM = 25 /* Text Cursor Enable Mode */ 1113fa3f02f3Smrg ,srm_RXVT_SCROLLBAR = 30 1114980988aeSmrg ,srm_DECRLM = 34 /* vt510:Cursor Right to Left Mode */ 1115fa3f02f3Smrg#if OPT_SHIFT_FONTS 1116980988aeSmrg ,srm_RXVT_FONTSIZE = 35 /* also vt520:DECHEBM */ 1117190d7dceSmrg#else 1118190d7dceSmrg ,srm_DECHEBM = 35 /* vt520:Hebrew keyboard mapping */ 1119fa3f02f3Smrg#endif 1120980988aeSmrg ,srm_DECHEM = 36 /* vt510:Hebrew Encoding Mode */ 1121fa3f02f3Smrg#if OPT_TEK4014 1122fa3f02f3Smrg ,srm_DECTEK = 38 1123fa3f02f3Smrg#endif 1124fa3f02f3Smrg ,srm_132COLS = 40 1125fa3f02f3Smrg ,srm_CURSES_HACK = 41 1126980988aeSmrg ,srm_DECNRCM = 42 /* National Replacement Character Set Mode */ 1127d4fba8b9Smrg#if OPT_PRINT_GRAPHICS 1128d4fba8b9Smrg ,srm_DECGEPM = 43 /* Graphics Expanded Print Mode */ 1129d4fba8b9Smrg#endif 1130d4fba8b9Smrg ,srm_MARGIN_BELL = 44 /* also DECGPCM (Graphics Print Color Mode) */ 1131d4fba8b9Smrg ,srm_REVERSEWRAP = 45 /* also DECGPCS (Graphics Print Color Syntax) */ 1132fa3f02f3Smrg#ifdef ALLOWLOGGING 1133d4fba8b9Smrg ,srm_ALLOWLOGGING = 46 /* also DECGPBM (Graphics Print Background Mode) */ 1134d4fba8b9Smrg#elif OPT_PRINT_GRAPHICS 1135d4fba8b9Smrg ,srm_DECGPBM = 46 /* Graphics Print Background Mode */ 1136fa3f02f3Smrg#endif 1137d4fba8b9Smrg ,srm_ALTBUF = 47 /* also DECGRPM (Graphics Rotated Print Mode) */ 1138190d7dceSmrg ,srm_DEC131TM = 53 /* vt330:VT131 transmit */ 1139980988aeSmrg ,srm_DECNAKB = 57 /* vt510:Greek/N-A Keyboard Mapping */ 1140980988aeSmrg ,srm_DECIPEM = 58 /* vt510:IBM ProPrinter Emulation Mode */ 1141190d7dceSmrg ,srm_DECKKDM = 59 /* vt382:Kanji/Katakana */ 1142980988aeSmrg ,srm_DECHCCM = 60 /* vt420:Horizontal Cursor-Coupling Mode */ 1143980988aeSmrg ,srm_DECVCCM = 61 /* vt420:Vertical Cursor-Coupling Mode */ 1144980988aeSmrg ,srm_DECPCCM = 64 /* vt420:Page Cursor-Coupling Mode */ 1145980988aeSmrg ,srm_DECNKM = 66 /* vt420:Numeric Keypad Mode */ 1146980988aeSmrg ,srm_DECBKM = 67 /* vt420:Backarrow Key mode */ 1147980988aeSmrg ,srm_DECKBUM = 68 /* vt420:Keyboard Usage mode */ 1148980988aeSmrg ,srm_DECLRMM = 69 /* vt420:Vertical Split Screen Mode (DECVSSM) */ 1149980988aeSmrg ,srm_DECXRLM = 73 /* vt420:Transmit Rate Limiting */ 1150fa3f02f3Smrg#if OPT_SIXEL_GRAPHICS 1151190d7dceSmrg ,srm_DECSDM = 80 /* vt320:Sixel Display Mode */ 1152fa3f02f3Smrg#endif 1153980988aeSmrg ,srm_DECKPM = 81 /* vt420:Key Position Mode */ 1154980988aeSmrg ,srm_DECNCSM = 95 /* vt510:No Clearing Screen On Column Change */ 1155980988aeSmrg ,srm_DECRLCM = 96 /* vt510:Right-to-Left Copy */ 1156980988aeSmrg ,srm_DECCRTSM = 97 /* vt510:CRT Save Mode */ 1157980988aeSmrg ,srm_DECARSM = 98 /* vt510:Auto Resize Mode */ 1158980988aeSmrg ,srm_DECMCM = 99 /* vt510:Modem Control Mode */ 1159190d7dceSmrg ,srm_DECAAM = 100 /* vt510:Auto Answerback Mode */ 1160980988aeSmrg ,srm_DECCANSM = 101 /* vt510:Conceal Answerback Message Mode */ 1161980988aeSmrg ,srm_DECNULM = 102 /* vt510:Ignoring Null Mode */ 1162980988aeSmrg ,srm_DECHDPXM = 103 /* vt510:Half-Duplex Mode */ 1163190d7dceSmrg ,srm_DECESKM = 104 /* vt510:enable secondary keyboard language */ 1164980988aeSmrg ,srm_DECOSCNM = 106 /* vt510:Overscan Mode */ 1165980988aeSmrg ,srm_DECNUMLK = 108 /* vt510:Num Lock Mode */ 1166980988aeSmrg ,srm_DECCAPSLK = 109 /* vt510:Caps Lock Mode */ 1167980988aeSmrg ,srm_DECKLHIM = 110 /* vt510:Keyboard LEDs Host Indicator Mode */ 1168980988aeSmrg ,srm_DECFWM = 111 /* vt520:Framed Windows Mode */ 1169980988aeSmrg ,srm_DECRPL = 112 /* vt520:Review Previous Lines */ 1170980988aeSmrg ,srm_DECHWUM = 113 /* vt520:Host Wake-Up */ 1171980988aeSmrg ,srm_DECATCUM = 114 /* vt520:Alternate Text Color Underline */ 1172980988aeSmrg ,srm_DECATCBM = 115 /* vt520:Alternate Text Color Blink */ 1173980988aeSmrg ,srm_DECBBSM = 116 /* vt520:Bold and Blink Style Mode */ 1174980988aeSmrg ,srm_DECECM = 117 /* vt520:Erase Color Mode */ 1175fa3f02f3Smrg ,srm_VT200_MOUSE = SET_VT200_MOUSE 1176fa3f02f3Smrg ,srm_VT200_HIGHLIGHT_MOUSE = SET_VT200_HIGHLIGHT_MOUSE 1177fa3f02f3Smrg ,srm_BTN_EVENT_MOUSE = SET_BTN_EVENT_MOUSE 1178fa3f02f3Smrg ,srm_ANY_EVENT_MOUSE = SET_ANY_EVENT_MOUSE 1179fa3f02f3Smrg#if OPT_FOCUS_EVENT 1180fa3f02f3Smrg ,srm_FOCUS_EVENT_MOUSE = SET_FOCUS_EVENT_MOUSE 1181fa3f02f3Smrg#endif 1182fa3f02f3Smrg ,srm_EXT_MODE_MOUSE = SET_EXT_MODE_MOUSE 1183fa3f02f3Smrg ,srm_SGR_EXT_MODE_MOUSE = SET_SGR_EXT_MODE_MOUSE 1184fa3f02f3Smrg ,srm_URXVT_EXT_MODE_MOUSE = SET_URXVT_EXT_MODE_MOUSE 1185d4fba8b9Smrg ,srm_PIXEL_POSITION_MOUSE = SET_PIXEL_POSITION_MOUSE 1186fa3f02f3Smrg ,srm_ALTERNATE_SCROLL = SET_ALTERNATE_SCROLL 1187fa3f02f3Smrg ,srm_RXVT_SCROLL_TTY_OUTPUT = 1010 1188fa3f02f3Smrg ,srm_RXVT_SCROLL_TTY_KEYPRESS = 1011 1189980988aeSmrg ,srm_FAST_SCROLL = 1014 1190fa3f02f3Smrg ,srm_EIGHT_BIT_META = 1034 1191fa3f02f3Smrg#if OPT_NUM_LOCK 1192fa3f02f3Smrg ,srm_REAL_NUMLOCK = 1035 1193fa3f02f3Smrg ,srm_META_SENDS_ESC = 1036 1194fa3f02f3Smrg#endif 1195fa3f02f3Smrg ,srm_DELETE_IS_DEL = 1037 1196fa3f02f3Smrg#if OPT_NUM_LOCK 1197fa3f02f3Smrg ,srm_ALT_SENDS_ESC = 1039 1198fa3f02f3Smrg#endif 1199fa3f02f3Smrg ,srm_KEEP_SELECTION = 1040 1200fa3f02f3Smrg ,srm_SELECT_TO_CLIPBOARD = 1041 1201fa3f02f3Smrg ,srm_BELL_IS_URGENT = 1042 1202fa3f02f3Smrg ,srm_POP_ON_BELL = 1043 1203037a25ddSmrg ,srm_KEEP_CLIPBOARD = 1044 1204980988aeSmrg ,srm_REVERSEWRAP2 = 1045 /* reverse-wrap without limits */ 1205d4fba8b9Smrg ,srm_ALLOW_ALTBUF = 1046 1206d4fba8b9Smrg ,srm_OPT_ALTBUF = 1047 1207d4fba8b9Smrg ,srm_SAVE_CURSOR = 1048 1208d4fba8b9Smrg ,srm_OPT_ALTBUF_CURSOR = 1049 1209fa3f02f3Smrg#if OPT_TCAP_FKEYS 1210fa3f02f3Smrg ,srm_TCAP_FKEYS = 1050 1211fa3f02f3Smrg#endif 1212fa3f02f3Smrg#if OPT_SUN_FUNC_KEYS 1213fa3f02f3Smrg ,srm_SUN_FKEYS = 1051 1214fa3f02f3Smrg#endif 1215fa3f02f3Smrg#if OPT_HP_FUNC_KEYS 1216fa3f02f3Smrg ,srm_HP_FKEYS = 1052 1217fa3f02f3Smrg#endif 1218fa3f02f3Smrg#if OPT_SCO_FUNC_KEYS 1219fa3f02f3Smrg ,srm_SCO_FKEYS = 1053 1220fa3f02f3Smrg#endif 1221fa3f02f3Smrg ,srm_LEGACY_FKEYS = 1060 1222fa3f02f3Smrg#if OPT_SUNPC_KBD 1223fa3f02f3Smrg ,srm_VT220_FKEYS = 1061 1224fa3f02f3Smrg#endif 12259a64e1c5Smrg#if OPT_GRAPHICS 1226fa3f02f3Smrg ,srm_PRIVATE_COLOR_REGISTERS = 1070 1227fa3f02f3Smrg#endif 1228d4fba8b9Smrg#if OPT_PASTE64 || OPT_READLINE 1229d4fba8b9Smrg ,srm_PASTE_IN_BRACKET = SET_PASTE_IN_BRACKET 1230d4fba8b9Smrg#endif 1231fa3f02f3Smrg#if OPT_READLINE 1232fa3f02f3Smrg ,srm_BUTTON1_MOVE_POINT = SET_BUTTON1_MOVE_POINT 1233fa3f02f3Smrg ,srm_BUTTON2_MOVE_POINT = SET_BUTTON2_MOVE_POINT 1234fa3f02f3Smrg ,srm_DBUTTON3_DELETE = SET_DBUTTON3_DELETE 1235fa3f02f3Smrg ,srm_PASTE_QUOTE = SET_PASTE_QUOTE 1236fa3f02f3Smrg ,srm_PASTE_LITERAL_NL = SET_PASTE_LITERAL_NL 1237fa3f02f3Smrg#endif /* OPT_READLINE */ 12389a64e1c5Smrg#if OPT_SIXEL_GRAPHICS 12399a64e1c5Smrg ,srm_SIXEL_SCROLLS_RIGHT = 8452 12409a64e1c5Smrg#endif 1241fa3f02f3Smrg} DECSET_codes; 1242fa3f02f3Smrg 1243d4fba8b9Smrg/* internal codes for selection atoms */ 1244d4fba8b9Smrgtypedef enum { 1245d4fba8b9Smrg PRIMARY_CODE = 0 1246d4fba8b9Smrg ,CLIPBOARD_CODE 1247d4fba8b9Smrg ,SECONDARY_CODE 1248d4fba8b9Smrg ,MAX_SELECTION_CODES 1249d4fba8b9Smrg} SelectionCodes; 1250d4fba8b9Smrg 1251d522f475Smrg/* indices for mapping multiple clicks to selection types */ 1252d522f475Smrgtypedef enum { 1253d522f475Smrg Select_CHAR=0 1254d522f475Smrg ,Select_WORD 1255d522f475Smrg ,Select_LINE 1256d522f475Smrg ,Select_GROUP 1257d522f475Smrg ,Select_PAGE 1258d522f475Smrg ,Select_ALL 1259d522f475Smrg#if OPT_SELECT_REGEX 1260d522f475Smrg ,Select_REGEX 1261d522f475Smrg#endif 1262d522f475Smrg ,NSELECTUNITS 1263d522f475Smrg} SelectUnit; 1264d522f475Smrg 1265d4fba8b9Smrg#if OPT_BLINK_CURS 1266d4fba8b9Smrgtypedef enum { 1267d4fba8b9Smrg cbFalse = 0 1268d4fba8b9Smrg , cbTrue 1269d4fba8b9Smrg , cbAlways 1270d4fba8b9Smrg , cbNever 1271d4fba8b9Smrg , cbLAST 1272d4fba8b9Smrg} BlinkOps; 1273d4fba8b9Smrg#endif 1274d4fba8b9Smrg 1275cd3331d0Smrgtypedef enum { 1276cd3331d0Smrg ecSetColor = 1 1277cd3331d0Smrg , ecGetColor 1278cd3331d0Smrg , ecGetAnsiColor 1279cd3331d0Smrg , ecLAST 1280cd3331d0Smrg} ColorOps; 1281cd3331d0Smrg 1282cd3331d0Smrgtypedef enum { 1283cd3331d0Smrg efSetFont = 1 1284cd3331d0Smrg , efGetFont 1285cd3331d0Smrg , efLAST 1286cd3331d0Smrg} FontOps; 1287cd3331d0Smrg 1288c219fbebSmrgtypedef enum { 1289c219fbebSmrg esFalse = 0 1290c219fbebSmrg , esTrue 1291c219fbebSmrg , esAlways 1292c219fbebSmrg , esNever 1293d4fba8b9Smrg , esLAST 1294c219fbebSmrg} FullscreenOps; 1295c219fbebSmrg 12963367019cSmrg#ifndef NO_ACTIVE_ICON 12973367019cSmrgtypedef enum { 12983367019cSmrg eiFalse = 0 12993367019cSmrg , eiTrue 13003367019cSmrg , eiDefault 13013367019cSmrg , eiLAST 13023367019cSmrg} AIconOps; 13033367019cSmrg#endif 13043367019cSmrg 1305dfb07bc7Smrgtypedef enum { 1306dfb07bc7Smrg emX10 = 1 1307dfb07bc7Smrg , emLocator 1308dfb07bc7Smrg , emVT200Click 1309dfb07bc7Smrg , emVT200Hilite 1310dfb07bc7Smrg , emAnyButton 1311dfb07bc7Smrg , emAnyEvent 1312dfb07bc7Smrg , emFocusEvent 1313dfb07bc7Smrg , emExtended 1314dfb07bc7Smrg , emSGR 1315dfb07bc7Smrg , emURXVT 1316dfb07bc7Smrg , emAlternateScroll 1317dfb07bc7Smrg , emLAST 1318dfb07bc7Smrg} MouseOps; 1319dfb07bc7Smrg 1320d4fba8b9Smrgtypedef enum { 1321d4fba8b9Smrg#define DATA(name) ep##name 1322d4fba8b9Smrg DATA(NUL) = 0 1323d4fba8b9Smrg , DATA(SOH) = 1 1324d4fba8b9Smrg , DATA(STX) = 2 1325d4fba8b9Smrg , DATA(ETX) = 3 1326d4fba8b9Smrg , DATA(EOT) = 4 1327d4fba8b9Smrg , DATA(ENQ) = 5 1328d4fba8b9Smrg , DATA(ACK) = 6 1329d4fba8b9Smrg , DATA(BEL) = 7 1330d4fba8b9Smrg , DATA(BS) = 8 1331d4fba8b9Smrg , DATA(HT) = 9 1332d4fba8b9Smrg , DATA(LF) = 10 1333d4fba8b9Smrg , DATA(VT) = 11 1334d4fba8b9Smrg , DATA(FF) = 12 1335d4fba8b9Smrg , DATA(CR) = 13 1336d4fba8b9Smrg , DATA(SO) = 14 1337d4fba8b9Smrg , DATA(SI) = 15 1338d4fba8b9Smrg , DATA(DLE) = 16 1339d4fba8b9Smrg , DATA(DC1) = 17 1340d4fba8b9Smrg , DATA(DC2) = 18 1341d4fba8b9Smrg , DATA(DC3) = 19 1342d4fba8b9Smrg , DATA(DC4) = 20 1343d4fba8b9Smrg , DATA(NAK) = 21 1344d4fba8b9Smrg , DATA(SYN) = 22 1345d4fba8b9Smrg , DATA(ETB) = 23 1346d4fba8b9Smrg , DATA(CAN) = 24 1347d4fba8b9Smrg , DATA(EM) = 25 1348d4fba8b9Smrg , DATA(SUB) = 26 1349d4fba8b9Smrg , DATA(ESC) = 27 1350d4fba8b9Smrg , DATA(FS) = 28 1351d4fba8b9Smrg , DATA(GS) = 29 1352d4fba8b9Smrg , DATA(RS) = 30 1353d4fba8b9Smrg , DATA(US) = 31 1354d4fba8b9Smrg /* aliases */ 1355d4fba8b9Smrg , DATA(C0) 1356d4fba8b9Smrg , DATA(DEL) 1357980988aeSmrg , DATA(STTY) 1358d4fba8b9Smrg#undef DATA 1359d4fba8b9Smrg , epLAST 1360d4fba8b9Smrg} PasteControls; 1361d4fba8b9Smrg 1362d4fba8b9Smrgtypedef enum { /* legal values for keyboard.shift_escape */ 1363d4fba8b9Smrg ssFalse = 0 1364d4fba8b9Smrg , ssTrue = 1 1365d4fba8b9Smrg , ssAlways = 2 1366d4fba8b9Smrg , ssNever = 3 1367d4fba8b9Smrg , ssLAST 1368d4fba8b9Smrg} ShiftEscapeOps; 1369d4fba8b9Smrg 1370d4fba8b9Smrg/* 1371d4fba8b9Smrg * xterm uses these codes for the its push-SGR feature. They match where 1372d4fba8b9Smrg * possible the corresponding SGR coding. The foreground and background colors 1373d4fba8b9Smrg * do not fit into that scheme (because they are a set of ranges), so those are 1374d4fba8b9Smrg * chosen arbitrarily -TD 1375d4fba8b9Smrg */ 1376d4fba8b9Smrgtypedef enum { 1377d4fba8b9Smrg psBOLD = 1 1378d4fba8b9Smrg#if OPT_WIDE_ATTRS 1379d4fba8b9Smrg , psATR_FAINT = 2 1380d4fba8b9Smrg , psATR_ITALIC = 3 1381d4fba8b9Smrg#endif 1382d4fba8b9Smrg , psUNDERLINE = 4 1383d4fba8b9Smrg , psBLINK = 5 1384d4fba8b9Smrg , psINVERSE = 7 1385d4fba8b9Smrg , psINVISIBLE = 8 1386d4fba8b9Smrg#if OPT_WIDE_ATTRS 1387d4fba8b9Smrg , psATR_STRIKEOUT = 9 1388d4fba8b9Smrg#endif 1389d4fba8b9Smrg /* SGR 10-19 correspond to primary/alternate fonts, currently unused */ 1390d4fba8b9Smrg#if OPT_ISO_COLORS 1391d4fba8b9Smrg , psFG_COLOR_obs = 10 1392d4fba8b9Smrg , psBG_COLOR_obs = 11 1393d4fba8b9Smrg#endif 1394d4fba8b9Smrg#if OPT_WIDE_ATTRS 1395d4fba8b9Smrg , psATR_DBL_UNDER = 21 1396d4fba8b9Smrg#endif 1397d4fba8b9Smrg /* SGR 22-29 mostly are used to reset SGR 1-9 */ 1398d4fba8b9Smrg#if OPT_ISO_COLORS 1399d4fba8b9Smrg , psFG_COLOR = 30 /* stack maps many colors to one state */ 1400d4fba8b9Smrg , psBG_COLOR = 31 1401d4fba8b9Smrg#endif 1402d4fba8b9Smrg , MAX_PUSH_SGR 1403d4fba8b9Smrg} PushSGR; 1404d4fba8b9Smrg 1405cd3331d0Smrgtypedef enum { 1406cd3331d0Smrg etSetTcap = 1 1407cd3331d0Smrg , etGetTcap 1408cd3331d0Smrg , etLAST 1409cd3331d0Smrg} TcapOps; 1410cd3331d0Smrg 1411cd3331d0Smrgtypedef enum { 14123367019cSmrg /* 1-23 are chosen to be the same as the control-sequence coding */ 1413cd3331d0Smrg ewRestoreWin = 1 1414cd3331d0Smrg , ewMinimizeWin = 2 1415cd3331d0Smrg , ewSetWinPosition = 3 1416cd3331d0Smrg , ewSetWinSizePixels = 4 1417cd3331d0Smrg , ewRaiseWin = 5 1418cd3331d0Smrg , ewLowerWin = 6 1419cd3331d0Smrg , ewRefreshWin = 7 1420cd3331d0Smrg , ewSetWinSizeChars = 8 1421cd3331d0Smrg#if OPT_MAXIMIZE 1422cd3331d0Smrg , ewMaximizeWin = 9 1423c219fbebSmrg , ewFullscreenWin = 10 1424cd3331d0Smrg#endif 1425cd3331d0Smrg , ewGetWinState = 11 1426cd3331d0Smrg , ewGetWinPosition = 13 1427cd3331d0Smrg , ewGetWinSizePixels = 14 1428d4fba8b9Smrg#if OPT_MAXIMIZE 1429d4fba8b9Smrg , ewGetScreenSizePixels = 15 1430d4fba8b9Smrg , ewGetCharSizePixels = 16 1431d4fba8b9Smrg#endif 1432cd3331d0Smrg , ewGetWinSizeChars = 18 1433cd3331d0Smrg#if OPT_MAXIMIZE 1434cd3331d0Smrg , ewGetScreenSizeChars = 19 1435cd3331d0Smrg#endif 1436cd3331d0Smrg , ewGetIconTitle = 20 1437cd3331d0Smrg , ewGetWinTitle = 21 1438cd3331d0Smrg , ewPushTitle = 22 1439cd3331d0Smrg , ewPopTitle = 23 1440cd3331d0Smrg /* these do not fit into that scheme, which is why we use an array */ 1441cd3331d0Smrg , ewSetWinLines 1442cd3331d0Smrg , ewSetXprop 1443cd3331d0Smrg , ewGetSelection 1444cd3331d0Smrg , ewSetSelection 1445d4fba8b9Smrg , ewGetChecksum 1446d4fba8b9Smrg , ewSetChecksum 1447cd3331d0Smrg /* get the size of the array... */ 1448cd3331d0Smrg , ewLAST 1449cd3331d0Smrg} WindowOps; 1450cd3331d0Smrg 1451d4fba8b9Smrg/***====================================================================***/ 1452d4fba8b9Smrg 1453cd3331d0Smrg#define COLOR_DEFINED(s,w) ((s)->which & (unsigned) (1<<(w))) 1454d522f475Smrg#define COLOR_VALUE(s,w) ((s)->colors[w]) 1455cd3331d0Smrg#define SET_COLOR_VALUE(s,w,v) (((s)->colors[w] = (v)), UIntSet((s)->which, (1<<(w)))) 1456d522f475Smrg 1457d522f475Smrg#define COLOR_NAME(s,w) ((s)->names[w]) 1458cd3331d0Smrg#define SET_COLOR_NAME(s,w,v) (((s)->names[w] = (v)), ((s)->which |= (unsigned) (1<<(w)))) 1459d522f475Smrg 1460d522f475Smrg#define UNDEFINE_COLOR(s,w) ((s)->which &= (~((w)<<1))) 1461d522f475Smrg 1462d522f475Smrg/***====================================================================***/ 1463d522f475Smrg 1464d522f475Smrg#if OPT_ISO_COLORS 1465d4fba8b9Smrg#if OPT_WIDE_ATTRS 1466d4fba8b9Smrg#define COLOR_FLAGS (FG_COLOR | BG_COLOR | ATR_DIRECT_FG | ATR_DIRECT_BG) 1467d4fba8b9Smrg#else 1468d4fba8b9Smrg#define COLOR_FLAGS (FG_COLOR | BG_COLOR) 1469d4fba8b9Smrg#endif 1470d4fba8b9Smrg#define TERM_COLOR_FLAGS(xw) ((xw)->flags & COLOR_FLAGS) 1471d522f475Smrg#define COLOR_0 0 1472d522f475Smrg#define COLOR_1 1 1473d522f475Smrg#define COLOR_2 2 1474d522f475Smrg#define COLOR_3 3 1475d522f475Smrg#define COLOR_4 4 1476d522f475Smrg#define COLOR_5 5 1477d522f475Smrg#define COLOR_6 6 1478d522f475Smrg#define COLOR_7 7 1479d522f475Smrg#define COLOR_8 8 1480d522f475Smrg#define COLOR_9 9 1481d522f475Smrg#define COLOR_10 10 1482d522f475Smrg#define COLOR_11 11 1483d522f475Smrg#define COLOR_12 12 1484d522f475Smrg#define COLOR_13 13 1485d522f475Smrg#define COLOR_14 14 1486d522f475Smrg#define COLOR_15 15 1487d522f475Smrg#define MIN_ANSI_COLORS 16 1488d522f475Smrg 1489d522f475Smrg#if OPT_256_COLORS 1490d522f475Smrg# define NUM_ANSI_COLORS 256 1491d522f475Smrg#elif OPT_88_COLORS 1492d522f475Smrg# define NUM_ANSI_COLORS 88 1493d522f475Smrg#else 1494d522f475Smrg# define NUM_ANSI_COLORS MIN_ANSI_COLORS 1495d522f475Smrg#endif 1496d522f475Smrg 1497d4fba8b9Smrg#define okIndexedColor(n) ((n) >= 0 && (n) < NUM_ANSI_COLORS) 1498d4fba8b9Smrg 1499d522f475Smrg#if NUM_ANSI_COLORS > MIN_ANSI_COLORS 1500d522f475Smrg# define OPT_EXT_COLORS 1 1501d522f475Smrg#else 1502d522f475Smrg# define OPT_EXT_COLORS 0 1503d522f475Smrg#endif 1504d522f475Smrg 1505d522f475Smrg#define COLOR_BD (NUM_ANSI_COLORS) /* BOLD */ 1506d522f475Smrg#define COLOR_UL (NUM_ANSI_COLORS+1) /* UNDERLINE */ 1507d522f475Smrg#define COLOR_BL (NUM_ANSI_COLORS+2) /* BLINK */ 1508d522f475Smrg#define COLOR_RV (NUM_ANSI_COLORS+3) /* REVERSE */ 150994644356Smrg 151094644356Smrg#if OPT_WIDE_ATTRS 151194644356Smrg#define COLOR_IT (NUM_ANSI_COLORS+4) /* ITALIC */ 151294644356Smrg#define MAXCOLORS (NUM_ANSI_COLORS+5) 151394644356Smrg#else 1514d522f475Smrg#define MAXCOLORS (NUM_ANSI_COLORS+4) 151594644356Smrg#endif 151694644356Smrg 1517d522f475Smrg#ifndef DFT_COLORMODE 1518d522f475Smrg#define DFT_COLORMODE True /* default colorMode resource */ 1519d522f475Smrg#endif 1520d522f475Smrg 152194644356Smrg#define UseItalicFont(screen) (!(screen)->colorITMode) 152294644356Smrg 1523d522f475Smrg#define ReverseOrHilite(screen,flags,hilite) \ 1524d522f475Smrg (( screen->colorRVMode && hilite ) || \ 1525d522f475Smrg ( !screen->colorRVMode && \ 1526d522f475Smrg (( (flags & INVERSE) && !hilite) || \ 1527d522f475Smrg (!(flags & INVERSE) && hilite)) )) 1528d522f475Smrg 1529d522f475Smrg#else /* !OPT_ISO_COLORS */ 1530d522f475Smrg 1531d522f475Smrg#define TERM_COLOR_FLAGS(xw) 0 1532d522f475Smrg 153394644356Smrg#define UseItalicFont(screen) True 1534d522f475Smrg#define ReverseOrHilite(screen,flags,hilite) \ 1535d522f475Smrg (( (flags & INVERSE) && !hilite) || \ 1536d522f475Smrg (!(flags & INVERSE) && hilite)) 1537d522f475Smrg 1538d522f475Smrg#endif /* OPT_ISO_COLORS */ 1539d522f475Smrg 1540d4fba8b9Smrgtypedef enum { 1541d4fba8b9Smrg XK_TCAPNAME = 3 1542d4fba8b9Smrg /* Define fake XK codes, we need those for the fake color response in 1543d4fba8b9Smrg * xtermcapKeycode(). 1544d4fba8b9Smrg */ 1545d4fba8b9Smrg#if OPT_ISO_COLORS 1546d4fba8b9Smrg , XK_COLORS 1547d4fba8b9Smrg , XK_RGB 1548d4fba8b9Smrg#endif 1549d4fba8b9Smrg} TcapQuery; 1550cd3331d0Smrg 1551d522f475Smrg#if OPT_AIX_COLORS 1552d522f475Smrg#define if_OPT_AIX_COLORS(screen, code) if(screen->colorMode) code 1553d522f475Smrg#else 1554d522f475Smrg#define if_OPT_AIX_COLORS(screen, code) /* nothing */ 1555d522f475Smrg#endif 1556d522f475Smrg 1557b7c89284Ssnj#if OPT_256_COLORS || OPT_88_COLORS || OPT_ISO_COLORS 1558b7c89284Ssnj# define if_OPT_ISO_COLORS(screen, code) if (screen->colorMode) code 1559d522f475Smrg#else 1560b7c89284Ssnj# define if_OPT_ISO_COLORS(screen, code) /* nothing */ 1561d522f475Smrg#endif 1562d522f475Smrg 1563d4fba8b9Smrg#if OPT_DIRECT_COLOR 1564d4fba8b9Smrg# define if_OPT_DIRECT_COLOR(screen, code) if (screen->direct_color) code 1565d4fba8b9Smrg# define if_OPT_DIRECT_COLOR2(screen, test, code) if (screen->direct_color && (test)) code 1566d4fba8b9Smrg#else 1567d4fba8b9Smrg# define if_OPT_DIRECT_COLOR(screen, code) /* nothing */ 1568d4fba8b9Smrg# define if_OPT_DIRECT_COLOR2(screen, test, code) /* nothing */ 1569d4fba8b9Smrg#endif 1570d4fba8b9Smrg 1571d4fba8b9Smrg#define if_OPT_DIRECT_COLOR2_else(cond, test, stmt) \ 1572d4fba8b9Smrg if_OPT_DIRECT_COLOR2(cond, test, stmt else) 1573d4fba8b9Smrg 1574d522f475Smrg#define COLOR_RES_NAME(root) "color" root 1575d522f475Smrg 1576d522f475Smrg#if OPT_COLOR_CLASS 1577d522f475Smrg#define COLOR_RES_CLASS(root) "Color" root 1578d522f475Smrg#else 1579d522f475Smrg#define COLOR_RES_CLASS(root) XtCForeground 1580d522f475Smrg#endif 1581d522f475Smrg 1582d522f475Smrg#define COLOR_RES(root,offset,value) Sres(COLOR_RES_NAME(root), COLOR_RES_CLASS(root), offset.resource, value) 1583d522f475Smrg#define COLOR_RES2(name,class,offset,value) Sres(name, class, offset.resource, value) 1584d522f475Smrg 1585d522f475Smrg#define CLICK_RES_NAME(count) "on" count "Clicks" 1586d522f475Smrg#define CLICK_RES_CLASS(count) "On" count "Clicks" 1587d522f475Smrg#define CLICK_RES(count,offset,value) Sres(CLICK_RES_NAME(count), CLICK_RES_CLASS(count), offset, value) 1588d522f475Smrg 1589d522f475Smrg/***====================================================================***/ 1590d522f475Smrg 1591d522f475Smrg#if OPT_DEC_CHRSET 1592d522f475Smrg#define if_OPT_DEC_CHRSET(code) code 1593d522f475Smrg /* Use 2 bits for encoding the double high/wide sense of characters */ 1594d1603babSmrg#define CSET_SWL 0 /* character set: single-width line */ 1595d1603babSmrg#define CSET_DHL_TOP 1 /* character set: double-height top line */ 1596d1603babSmrg#define CSET_DHL_BOT 2 /* character set: double-height bottom line */ 1597d1603babSmrg#define CSET_DWL 3 /* character set: double-width line */ 1598d522f475Smrg#define NUM_CHRSET 8 /* normal/bold and 4 CSET_xxx values */ 1599b7c89284Ssnj 1600d522f475Smrg /* Use remaining bits for encoding the other character-sets */ 1601d522f475Smrg#define CSET_NORMAL(code) ((code) == CSET_SWL) 1602d522f475Smrg#define CSET_DOUBLE(code) (!CSET_NORMAL(code) && !CSET_EXTEND(code)) 1603cd3331d0Smrg#define CSET_EXTEND(code) ((int)(code) > CSET_DWL) 1604b7c89284Ssnj 1605b7c89284Ssnj#define DBLCS_BITS 4 1606b7c89284Ssnj#define DBLCS_MASK BITS2MASK(DBLCS_BITS) 1607b7c89284Ssnj 1608190d7dceSmrg#define GetLineDblCS(ld) ((ld) != NULL ? (((ld)->bufHead >> LINEFLAG_BITS) & DBLCS_MASK) : 0) 1609b7c89284Ssnj#define SetLineDblCS(ld,cs) (ld)->bufHead = (RowData) ((ld->bufHead & LINEFLAG_MASK) | (cs << LINEFLAG_BITS)) 1610b7c89284Ssnj 1611b7c89284Ssnj#define LineCharSet(screen, ld) \ 1612d4fba8b9Smrg (unsigned) ((CSET_DOUBLE(GetLineDblCS(ld))) \ 1613d4fba8b9Smrg ? GetLineDblCS(ld) \ 1614d4fba8b9Smrg : (screen)->cur_chrset) 1615b7c89284Ssnj#define LineMaxCol(screen, ld) \ 1616b7c89284Ssnj (CSET_DOUBLE(GetLineDblCS(ld)) \ 1617b7c89284Ssnj ? (screen->max_col / 2) \ 1618b7c89284Ssnj : (screen->max_col)) 1619b7c89284Ssnj#define LineCursorX(screen, ld, col) \ 1620b7c89284Ssnj (CSET_DOUBLE(GetLineDblCS(ld)) \ 1621b7c89284Ssnj ? CursorX(screen, 2*(col)) \ 1622b7c89284Ssnj : CursorX(screen, (col))) 1623b7c89284Ssnj#define LineFontWidth(screen, ld) \ 1624b7c89284Ssnj (CSET_DOUBLE(GetLineDblCS(ld)) \ 1625b7c89284Ssnj ? 2*FontWidth(screen) \ 1626b7c89284Ssnj : FontWidth(screen)) 1627d522f475Smrg#else 1628b7c89284Ssnj 1629d522f475Smrg#define if_OPT_DEC_CHRSET(code) /*nothing*/ 1630d4fba8b9Smrg#define CSET_SWL 0 1631d4fba8b9Smrg#define GetLineDblCS(ld) 0U 1632d4fba8b9Smrg#define LineCharSet(screen, ld) 0U 1633b7c89284Ssnj#define LineMaxCol(screen, ld) screen->max_col 1634b7c89284Ssnj#define LineCursorX(screen, ld, col) CursorX(screen, col) 1635b7c89284Ssnj#define LineFontWidth(screen, ld) FontWidth(screen) 1636b7c89284Ssnj 1637d522f475Smrg#endif 1638d522f475Smrg 1639d522f475Smrg#if OPT_LUIT_PROG && !OPT_WIDE_CHARS 1640d4fba8b9Smrg/* Luit requires the wide-chars configuration */ 1641d4fba8b9Smrg#undef OPT_LUIT_PROG 1642d4fba8b9Smrg#define OPT_LUIT_PROG 0 1643d522f475Smrg#endif 1644d522f475Smrg 1645d522f475Smrg/***====================================================================***/ 1646d522f475Smrg 1647980988aeSmrg#if OPT_DEC_RECTOPS 1648980988aeSmrg#define if_OPT_DEC_RECTOPS(stmt) stmt 1649980988aeSmrg#else 1650980988aeSmrg#define if_OPT_DEC_RECTOPS(stmt) /* nothing */ 1651980988aeSmrg#endif 1652980988aeSmrg 1653980988aeSmrg/***====================================================================***/ 1654980988aeSmrg 1655190d7dceSmrg#define CONTROL(a) ((a) & 037) 1656d522f475Smrg 1657190d7dceSmrg#define XTERM_ERASE CONTROL('H') 1658190d7dceSmrg#define XTERM_LNEXT CONTROL('V') 1659d1603babSmrg 1660d522f475Smrg/***====================================================================***/ 1661d522f475Smrg 1662d522f475Smrg#if OPT_TEK4014 1663d522f475Smrg#define TEK4014_ACTIVE(xw) ((xw)->misc.TekEmu) 1664d522f475Smrg#define TEK4014_SHOWN(xw) ((xw)->misc.Tshow) 1665d522f475Smrg#define CURRENT_EMU_VAL(tek,vt) (TEK4014_ACTIVE(term) ? tek : vt) 1666d522f475Smrg#define CURRENT_EMU() CURRENT_EMU_VAL((Widget)tekWidget, (Widget)term) 1667d522f475Smrg#else 1668d522f475Smrg#define TEK4014_ACTIVE(screen) 0 1669d522f475Smrg#define TEK4014_SHOWN(xw) 0 1670d522f475Smrg#define CURRENT_EMU_VAL(tek,vt) (vt) 1671d522f475Smrg#define CURRENT_EMU() ((Widget)term) 1672d522f475Smrg#endif 1673d522f475Smrg 1674d522f475Smrg/***====================================================================***/ 1675d522f475Smrg 1676d522f475Smrg#if OPT_TOOLBAR 1677d522f475Smrg#define SHELL_OF(widget) XtParent(XtParent(widget)) 1678d522f475Smrg#else 1679d522f475Smrg#define SHELL_OF(widget) XtParent(widget) 1680d522f475Smrg#endif 1681d522f475Smrg 1682d522f475Smrg/***====================================================================***/ 1683d522f475Smrg 1684d522f475Smrg#if OPT_VT52_MODE 1685d522f475Smrg#define if_OPT_VT52_MODE(screen, code) if(screen->vtXX_level == 0) code 1686d522f475Smrg#else 1687d522f475Smrg#define if_OPT_VT52_MODE(screen, code) /* nothing */ 1688d522f475Smrg#endif 1689d522f475Smrg 1690d522f475Smrg/***====================================================================***/ 1691d522f475Smrg 1692d522f475Smrg#if OPT_XMC_GLITCH 1693d522f475Smrg#define if_OPT_XMC_GLITCH(screen, code) if(screen->xmc_glitch) code 1694d522f475Smrg#define XMC_GLITCH 1 /* the character we'll show */ 1695d522f475Smrg#define XMC_FLAGS (INVERSE|UNDERLINE|BOLD|BLINK) 1696d522f475Smrg#else 1697d522f475Smrg#define if_OPT_XMC_GLITCH(screen, code) /* nothing */ 1698d522f475Smrg#endif 1699d522f475Smrg 1700d522f475Smrg/***====================================================================***/ 1701d522f475Smrg 17029a64e1c5Smrgtypedef unsigned IFlags; /* at least 32 bits */ 17039a64e1c5Smrg 17049a64e1c5Smrg#if OPT_WIDE_ATTRS 17059a64e1c5Smrgtypedef unsigned short IAttr; /* at least 16 bits */ 17069a64e1c5Smrg#else 17079a64e1c5Smrgtypedef unsigned char IAttr; /* at least 8 bits */ 17089a64e1c5Smrg#endif 17099a64e1c5Smrg 17109a64e1c5Smrg/***====================================================================***/ 17119a64e1c5Smrg 17120d92cbfdSchristos#define LO_BYTE(ch) CharOf((ch) & 0xff) 17130d92cbfdSchristos#define HI_BYTE(ch) CharOf((ch) >> 8) 17140d92cbfdSchristos 1715d522f475Smrg#if OPT_WIDE_CHARS 1716d522f475Smrg#define if_OPT_WIDE_CHARS(screen, code) if(screen->wide_chars) code 1717d522f475Smrg#define if_WIDE_OR_NARROW(screen, wide, narrow) if(screen->wide_chars) wide else narrow 1718980988aeSmrg#define NARROW_ICHAR 0xffff 1719b7c89284Ssnj#if OPT_WIDER_ICHAR 1720980988aeSmrg#define is_NON_CHAR(c) (((c) >= 0xffd0 && (c) <= 0xfdef) || \ 1721980988aeSmrg (((c) & 0xffff) >= 0xfffe)) 1722980988aeSmrg#define is_UCS_SPECIAL(c) ((c) >= 0xfff0 && (c) <= 0xffff) 1723980988aeSmrg#define WIDEST_ICHAR 0x1fffff 1724980988aeSmrgtypedef unsigned IChar; /* for 8-21 bit characters */ 1725b7c89284Ssnj#else 1726980988aeSmrg#define is_NON_CHAR(c) (((c) >= 0xffd0 && (c) <= 0xfdef) || \ 1727980988aeSmrg ((c) >= 0xfffe && (c) <= 0xffff)) 1728980988aeSmrg#define is_UCS_SPECIAL(c) ((c) >= 0xfff0) 1729980988aeSmrg#define WIDEST_ICHAR NARROW_ICHAR 1730b7c89284Ssnjtypedef unsigned short IChar; /* for 8-16 bit characters */ 1731b7c89284Ssnj#endif 1732d1603babSmrg#else /* !OPT_WIDE_CHARS */ 1733d1603babSmrg#undef OPT_WIDER_ICHAR 1734d1603babSmrg#define OPT_WIDER_ICHAR 0 1735980988aeSmrg#define is_NON_CHAR(c) ((c) > 255) 1736d522f475Smrg#define if_OPT_WIDE_CHARS(screen, code) /* nothing */ 1737d522f475Smrg#define if_WIDE_OR_NARROW(screen, wide, narrow) narrow 1738d522f475Smrgtypedef unsigned char IChar; /* for 8-bit characters */ 1739d522f475Smrg#endif 1740d522f475Smrg 1741d522f475Smrg/***====================================================================***/ 1742d522f475Smrg 1743d522f475Smrg#ifndef RES_OFFSET 1744d522f475Smrg#define RES_OFFSET(offset) XtOffsetOf(XtermWidgetRec, offset) 1745d522f475Smrg#endif 1746d522f475Smrg 1747d522f475Smrg#define RES_NAME(name) name 1748d522f475Smrg#define RES_CLASS(name) name 1749d522f475Smrg 1750d522f475Smrg#define Bres(name, class, offset, dftvalue) \ 1751d522f475Smrg {RES_NAME(name), RES_CLASS(class), XtRBoolean, sizeof(Boolean), \ 1752d522f475Smrg RES_OFFSET(offset), XtRImmediate, (XtPointer) dftvalue} 1753d522f475Smrg 1754d522f475Smrg#define Cres(name, class, offset, dftvalue) \ 1755d522f475Smrg {RES_NAME(name), RES_CLASS(class), XtRPixel, sizeof(Pixel), \ 1756fa3f02f3Smrg RES_OFFSET(offset), XtRString, DECONST(char,dftvalue)} 1757d522f475Smrg 1758d522f475Smrg#define Tres(name, class, offset, dftvalue) \ 1759d522f475Smrg COLOR_RES2(name, class, screen.Tcolors[offset], dftvalue) \ 1760d522f475Smrg 1761d522f475Smrg#define Fres(name, class, offset, dftvalue) \ 1762d522f475Smrg {RES_NAME(name), RES_CLASS(class), XtRFontStruct, sizeof(XFontStruct *), \ 1763fa3f02f3Smrg RES_OFFSET(offset), XtRString, DECONST(char,dftvalue)} 1764d522f475Smrg 1765d522f475Smrg#define Ires(name, class, offset, dftvalue) \ 1766d522f475Smrg {RES_NAME(name), RES_CLASS(class), XtRInt, sizeof(int), \ 1767d522f475Smrg RES_OFFSET(offset), XtRImmediate, (XtPointer) dftvalue} 1768d522f475Smrg 1769d522f475Smrg#define Dres(name, class, offset, dftvalue) \ 1770d522f475Smrg {RES_NAME(name), RES_CLASS(class), XtRFloat, sizeof(float), \ 1771fa3f02f3Smrg RES_OFFSET(offset), XtRString, DECONST(char,dftvalue)} 1772d522f475Smrg 1773d522f475Smrg#define Sres(name, class, offset, dftvalue) \ 1774d522f475Smrg {RES_NAME(name), RES_CLASS(class), XtRString, sizeof(char *), \ 1775fa3f02f3Smrg RES_OFFSET(offset), XtRString, DECONST(char,dftvalue)} 1776d522f475Smrg 1777d522f475Smrg#define Wres(name, class, offset, dftvalue) \ 1778d522f475Smrg {RES_NAME(name), RES_CLASS(class), XtRWidget, sizeof(Widget), \ 1779d522f475Smrg RES_OFFSET(offset), XtRWidget, (XtPointer) dftvalue} 1780d522f475Smrg 1781d522f475Smrg/***====================================================================***/ 1782d522f475Smrg 1783d522f475Smrg#define FRG_SIZE resource.minBufSize 1784d522f475Smrg#define BUF_SIZE resource.maxBufSize 1785d522f475Smrg 1786d522f475Smrgtypedef struct { 178794644356Smrg Char *next; 178894644356Smrg Char *last; 178994644356Smrg int update; /* HandleInterpret */ 1790d522f475Smrg#if OPT_WIDE_CHARS 179194644356Smrg IChar utf_data; /* resulting character */ 1792d1603babSmrg size_t utf_size; /* ...number of bytes decoded */ 179394644356Smrg Char *write_buf; 1794d1603babSmrg size_t write_len; 1795d522f475Smrg#endif 179694644356Smrg Char buffer[1]; 1797d522f475Smrg} PtyData; 1798d522f475Smrg 1799d522f475Smrg/***====================================================================***/ 1800d522f475Smrg 1801d4fba8b9Smrg/* 1802d4fba8b9Smrg * Pixel (and its components) are declared as unsigned long, but even for RGB 1803d4fba8b9Smrg * we need no more than 32-bits. 1804d4fba8b9Smrg */ 1805d4fba8b9Smrgtypedef uint32_t MyPixel; 1806d4fba8b9Smrgtypedef int32_t MyColor; 1807d4fba8b9Smrg 1808d522f475Smrg#if OPT_ISO_COLORS 1809d4fba8b9Smrg#if OPT_DIRECT_COLOR 1810d4fba8b9Smrgtypedef struct { 1811d4fba8b9Smrg MyColor fg; 1812d4fba8b9Smrg MyColor bg; 1813d4fba8b9Smrg} CellColor; 1814d4fba8b9Smrg 1815d4fba8b9Smrg#define isSameCColor(p,q) (!memcmp(&(p), &(q), sizeof(CellColor))) 1816d4fba8b9Smrg 1817d4fba8b9Smrg#elif OPT_256_COLORS || OPT_88_COLORS 1818d4fba8b9Smrg 1819b7c89284Ssnj#define COLOR_BITS 8 1820b7c89284Ssnjtypedef unsigned short CellColor; 1821d4fba8b9Smrg 1822d522f475Smrg#else 1823d4fba8b9Smrg 1824b7c89284Ssnj#define COLOR_BITS 4 1825b7c89284Ssnjtypedef Char CellColor; 1826d4fba8b9Smrg 1827d522f475Smrg#endif 1828b7c89284Ssnj#else 18299a64e1c5Smrgtypedef unsigned CellColor; 1830d522f475Smrg#endif 1831b7c89284Ssnj 1832d4fba8b9Smrg#define NO_COLOR ((unsigned)-1) 1833d4fba8b9Smrg 1834d4fba8b9Smrg#ifndef isSameCColor 1835d4fba8b9Smrg#define isSameCColor(p,q) ((p) == (q)) 1836d4fba8b9Smrg#endif 1837d4fba8b9Smrg 1838190d7dceSmrg#define BITS2MASK(b) (xBIT(b) - 1) 1839b7c89284Ssnj 1840d4fba8b9Smrg#define COLOR_MASK BITS2MASK(COLOR_BITS) 1841b7c89284Ssnj 1842d4fba8b9Smrg#if OPT_DIRECT_COLOR 1843d4fba8b9Smrg#define clrDirectFG(flags) UIntClr(flags, ATR_DIRECT_FG) 1844d4fba8b9Smrg#define clrDirectBG(flags) UIntClr(flags, ATR_DIRECT_BG) 1845d4fba8b9Smrg#define GetCellColorFG(data) ((data).fg) 1846d4fba8b9Smrg#define GetCellColorBG(data) ((data).bg) 1847d4fba8b9Smrg#define hasDirectFG(flags) ((flags) & ATR_DIRECT_FG) 1848d4fba8b9Smrg#define hasDirectBG(flags) ((flags) & ATR_DIRECT_BG) 1849d4fba8b9Smrg#define setDirectFG(flags,test) if (test) UIntSet(flags, ATR_DIRECT_FG); else UIntClr(flags, ATR_DIRECT_FG) 1850d4fba8b9Smrg#define setDirectBG(flags,test) if (test) UIntSet(flags, ATR_DIRECT_BG); else UIntClr(flags, ATR_DIRECT_BG) 1851d4fba8b9Smrg#elif OPT_ISO_COLORS 1852d4fba8b9Smrg#define clrDirectFG(flags) /* nothing */ 1853d4fba8b9Smrg#define clrDirectBG(flags) /* nothing */ 1854d4fba8b9Smrg#define GetCellColorFG(data) ((data) & COLOR_MASK) 1855d4fba8b9Smrg#define GetCellColorBG(data) (((data) >> COLOR_BITS) & COLOR_MASK) 1856d4fba8b9Smrg#define hasDirectFG(flags) 0 1857d4fba8b9Smrg#define hasDirectBG(flags) 0 1858d4fba8b9Smrg#define setDirectFG(flags,test) (void)(test) 1859d4fba8b9Smrg#define setDirectBG(flags,test) (void)(test) 1860d4fba8b9Smrg#else 1861d4fba8b9Smrg#define GetCellColorFG(data) 7 1862d4fba8b9Smrg#define GetCellColorBG(data) 0 1863d4fba8b9Smrg#endif 1864d4fba8b9Smrgextern CellColor blank_cell_color; 1865b7c89284Ssnj 1866b7c89284Ssnjtypedef Char RowData; /* wrap/blink, and DEC single-double chars */ 1867b7c89284Ssnj 1868d4fba8b9Smrg#define LINEFLAG_BITS 4 1869d4fba8b9Smrg#define LINEFLAG_MASK BITS2MASK(LINEFLAG_BITS) 1870b7c89284Ssnj 1871d4fba8b9Smrg#define GetLineFlags(ld) ((ld)->bufHead & LINEFLAG_MASK) 1872b7c89284Ssnj 1873d522f475Smrg#if OPT_DEC_CHRSET 1874d4fba8b9Smrg#define SetLineFlags(ld,xx) (ld)->bufHead = (RowData) ((ld->bufHead & (DBLCS_MASK << LINEFLAG_BITS)) | (xx & LINEFLAG_MASK)) 1875b7c89284Ssnj#else 1876d4fba8b9Smrg#define SetLineFlags(ld,xx) (ld)->bufHead = (RowData) (xx & LINEFLAG_MASK) 1877d522f475Smrg#endif 1878b7c89284Ssnj 1879b7c89284Ssnjtypedef IChar CharData; 1880b7c89284Ssnj 1881b7c89284Ssnj/* 1882b7c89284Ssnj * This is the xterm line-data/scrollback structure. 1883b7c89284Ssnj */ 1884b7c89284Ssnjtypedef struct { 1885b7c89284Ssnj Dimension lineSize; /* number of columns in this row */ 1886980988aeSmrg RowData bufHead; /* flag for wrapped lines */ 1887d522f475Smrg#if OPT_WIDE_CHARS 1888980988aeSmrg Char combSize; /* number of items in combData[] */ 1889b7c89284Ssnj#endif 1890980988aeSmrg#if OPT_DEC_RECTOPS 1891980988aeSmrg Char *charSets; /* SCS code (DECNRCM_codes) */ 1892980988aeSmrg Char *charSeen; /* pre-SCS value */ 1893980988aeSmrg#endif 1894980988aeSmrg IAttr *attribs; /* video attributes */ 1895b7c89284Ssnj#if OPT_ISO_COLORS 1896b7c89284Ssnj CellColor *color; /* foreground+background color numbers */ 1897b7c89284Ssnj#endif 1898b7c89284Ssnj CharData *charData; /* cell's base character */ 1899980988aeSmrg CharData *combData[1]; /* first field past fixed-offsets */ 1900b7c89284Ssnj} LineData; 1901b7c89284Ssnj 190294644356Smrgtypedef const LineData CLineData; 190394644356Smrg 1904b7c89284Ssnj/* 1905b7c89284Ssnj * We use CellData in a few places, when copying a cell's data to a temporary 1906b7c89284Ssnj * variable. 1907b7c89284Ssnj */ 1908b7c89284Ssnjtypedef struct { 1909980988aeSmrg IAttr attribs; /* video attributes */ 1910b7c89284Ssnj#if OPT_WIDE_CHARS 1911980988aeSmrg Char combSize; /* number of items in combData[] */ 1912980988aeSmrg#endif 1913980988aeSmrg#if OPT_DEC_RECTOPS 1914980988aeSmrg Char charSets; /* SCS code (DECNRCM_codes) */ 1915980988aeSmrg Char charSeen; /* pre-SCS value */ 1916b7c89284Ssnj#endif 1917b7c89284Ssnj#if OPT_ISO_COLORS 1918980988aeSmrg CellColor color; /* foreground+background color numbers */ 1919d522f475Smrg#endif 1920b7c89284Ssnj CharData charData; /* cell's base character */ 1921b7c89284Ssnj CharData combData[1]; /* array of combining chars */ 1922b7c89284Ssnj} CellData; 1923b7c89284Ssnj 1924b7c89284Ssnj#define for_each_combData(off, ld) for (off = 0; off < ld->combSize; ++off) 1925b7c89284Ssnj 1926d4fba8b9Smrg#define Clear1Cell(ld, x) \ 1927d4fba8b9Smrg do { \ 1928d4fba8b9Smrg ld->charData[x] = ' '; \ 1929d4fba8b9Smrg do { \ 1930d4fba8b9Smrg if_OPT_WIDE_CHARS(screen, { \ 1931d4fba8b9Smrg size_t z; \ 1932d4fba8b9Smrg for_each_combData(z, ld) { \ 1933d4fba8b9Smrg ld->combData[z][x] = '\0'; \ 1934d4fba8b9Smrg } \ 1935d4fba8b9Smrg }) } while (0); \ 1936d4fba8b9Smrg } while (0) 1937d4fba8b9Smrg 1938d4fba8b9Smrg#define Clear2Cell(dst, src, x) \ 1939d4fba8b9Smrg do { \ 1940d4fba8b9Smrg dst->charData[x] = ' '; \ 1941d4fba8b9Smrg dst->attribs[x] = src->attribs[x]; \ 1942d4fba8b9Smrg do { \ 1943d4fba8b9Smrg if_OPT_ISO_COLORS(screen, { \ 1944d4fba8b9Smrg dst->color[x] = src->color[x]; \ 1945d4fba8b9Smrg }) } while (0); \ 1946d4fba8b9Smrg do { \ 1947d4fba8b9Smrg if_OPT_WIDE_CHARS(screen, { \ 1948d4fba8b9Smrg size_t z; \ 1949d4fba8b9Smrg for_each_combData(z, dst) { \ 1950d4fba8b9Smrg dst->combData[z][x] = '\0'; \ 1951d4fba8b9Smrg } \ 1952d4fba8b9Smrg }) } while (0); \ 1953d4fba8b9Smrg } while (0) 1954d4fba8b9Smrg 1955b7c89284Ssnj/* 1956b7c89284Ssnj * Accommodate older compilers by not using variable-length arrays. 1957b7c89284Ssnj */ 1958b7c89284Ssnj#define SizeOfLineData offsetof(LineData, combData) 1959b7c89284Ssnj#define SizeOfCellData offsetof(CellData, combData) 1960d522f475Smrg 1961d522f475Smrg /* 1962d522f475Smrg * A "row" is the index within the visible part of the screen, and an 1963d522f475Smrg * "inx" is the index within the whole set of scrollable lines. 1964d522f475Smrg */ 1965d522f475Smrg#define ROW2INX(screen, row) ((row) + (screen)->topline) 1966d522f475Smrg#define INX2ROW(screen, inx) ((inx) - (screen)->topline) 1967d522f475Smrg 196894644356Smrg/* these are unused but could be useful for debugging */ 196994644356Smrg#if 0 1970d522f475Smrg#define ROW2ABS(screen, row) ((row) + (screen)->savedlines) 1971d522f475Smrg#define INX2ABS(screen, inx) ROW2ABS(screen, INX2ROW(screen, inx)) 197294644356Smrg#endif 1973d522f475Smrg 1974d522f475Smrg#define okScrnRow(screen, row) \ 1975b7c89284Ssnj ((row) <= ((screen)->max_row - (screen)->topline) \ 1976d522f475Smrg && (row) >= -((screen)->savedlines)) 1977d522f475Smrg 1978b7c89284Ssnj /* 1979b7c89284Ssnj * Cache data for "proportional" and other fonts containing a mixture 1980b7c89284Ssnj * of widths. 1981b7c89284Ssnj */ 1982b7c89284Ssnjtypedef struct { 19833367019cSmrg Bool mixed; 1984b7c89284Ssnj Dimension min_width; /* nominal cell width for 0..255 */ 1985b7c89284Ssnj Dimension max_width; /* maximum cell width */ 1986d1603babSmrg} XTermFontInfo; 1987d522f475Smrg 1988d1603babSmrg /* 1989d1603babSmrg * Map of characters to simplify/speed-up the checks for missing glyphs 1990d1603babSmrg * at runtime. 1991d1603babSmrg * 1992d1603babSmrg * FIXME: initially implement for Xft, but replace known_missing[] in 1993d1603babSmrg * X11 fonts as well. 1994d1603babSmrg */ 1995d1603babSmrgtypedef Char XTfontNum; 1996d1603babSmrgtypedef struct { 1997d1603babSmrg int depth; /* number of fonts merged for map */ 1998d1603babSmrg size_t limit; /* allocated size of per_font, etc */ 1999d1603babSmrg size_t first_char; /* merged first-character index */ 2000d1603babSmrg size_t last_char; /* merged last-character index */ 2001d1603babSmrg XTfontNum * per_font; /* index 1-n of first font with char */ 2002d1603babSmrg} XTermFontMap; 2003fa3f02f3Smrg 2004dfb07bc7Smrgtypedef enum { 2005dfb07bc7Smrg fwNever = 0, 2006dfb07bc7Smrg fwResource, 2007dfb07bc7Smrg fwAlways 2008dfb07bc7Smrg} fontWarningTypes; 2009dfb07bc7Smrg 2010d522f475Smrgtypedef struct { 2011d522f475Smrg unsigned chrset; 2012d522f475Smrg unsigned flags; 2013dfb07bc7Smrg fontWarningTypes warn; 2014d522f475Smrg XFontStruct * fs; 2015d522f475Smrg char * fn; 2016d1603babSmrg XTermFontInfo font_info; 2017d1603babSmrg Char known_missing[MaxUChar + 1]; 2018d522f475Smrg} XTermFonts; 2019d522f475Smrg 2020b7c89284Ssnj#if OPT_RENDERFONT 2021cd3331d0Smrgtypedef enum { 2022cd3331d0Smrg erFalse = 0 2023cd3331d0Smrg , erTrue 2024cd3331d0Smrg , erDefault 2025636d5e9fSmrg , erDefaultOff 2026cd3331d0Smrg , erLast 2027cd3331d0Smrg} RenderFont; 2028cd3331d0Smrg 2029cd3331d0Smrg#define DefaultRenderFont(xw) \ 20303367019cSmrg if ((xw)->work.render_font == erDefault) \ 20313367019cSmrg (xw)->work.render_font = erFalse 2032cd3331d0Smrg 2033d4fba8b9Smrgtypedef enum { 2034d4fba8b9Smrg xcEmpty = 0 /* slot is unused */ 2035d4fba8b9Smrg , xcBogus /* ignore this pattern */ 2036d4fba8b9Smrg , xcOpened /* slot has open font descriptor */ 2037d4fba8b9Smrg , xcUnused /* opened, but unused so far */ 2038d1603babSmrg} XTermXftState; 2039d4fba8b9Smrg 2040b7c89284Ssnjtypedef struct { 2041b7c89284Ssnj XftFont * font; 2042d1603babSmrg XTermXftState usage; 2043d4fba8b9Smrg} XTermXftCache; 2044d4fba8b9Smrg 2045d1603babSmrg#define MaxXftCache MaxUChar 2046d1603babSmrg 2047d4fba8b9Smrgtypedef struct { 2048d4fba8b9Smrg XftPattern * pattern; /* pattern for main font */ 2049d4fba8b9Smrg XftFontSet * fontset; /* ordered list of fallback patterns */ 2050d1603babSmrg XTermXftCache cache[MaxXftCache + 1]; /* list of open font pointers */ 2051d1603babSmrg int fs_size; /* last usable index of cache[] */ 2052d1603babSmrg Char opened; /* number in cache[] with xcOpened */ 2053d1603babSmrg XTermFontInfo font_info; /* summary of font metrics */ 2054d1603babSmrg XTermFontMap font_map; /* map of glyphs provided in fontset */ 2055b7c89284Ssnj} XTermXftFonts; 2056d4fba8b9Smrg 2057d1603babSmrg#define XftFpN(p,n) (p)->cache[(n)].font 2058d1603babSmrg#define XftIsN(p,n) (p)->cache[(n)].usage 2059d1603babSmrg 2060d1603babSmrg#define XftFp(p) XftFpN(p,0) 2061d1603babSmrg#define XftIs(p) XftIsN(p,0) 2062d1603babSmrg 2063d4fba8b9Smrgtypedef struct _ListXftFonts { 2064d4fba8b9Smrg struct _ListXftFonts *next; 2065d4fba8b9Smrg XftFont * font; 2066d4fba8b9Smrg} ListXftFonts; 2067b7c89284Ssnj#endif 2068b7c89284Ssnj 2069d522f475Smrgtypedef struct { 2070d522f475Smrg int top; 2071d522f475Smrg int left; 2072d522f475Smrg int bottom; 2073d522f475Smrg int right; 2074d522f475Smrg} XTermRect; 2075d522f475Smrg 2076d4fba8b9Smrg/***====================================================================***/ 2077d4fba8b9Smrg 2078d522f475Smrg /* indices into save_modes[] */ 2079d522f475Smrgtypedef enum { 2080d4fba8b9Smrg DP_ALLOW_ALTBUF, 20813367019cSmrg DP_ALTERNATE_SCROLL, 20823367019cSmrg DP_ALT_SENDS_ESC, 20833367019cSmrg DP_BELL_IS_URGENT, 2084d522f475Smrg DP_CRS_VISIBLE, 2085d522f475Smrg DP_DECANM, 2086d522f475Smrg DP_DECARM, 2087d522f475Smrg DP_DECAWM, 2088d522f475Smrg DP_DECBKM, 2089d522f475Smrg DP_DECCKM, 2090d522f475Smrg DP_DECCOLM, /* IN132COLUMNS */ 20913367019cSmrg DP_DECKPAM, 20923367019cSmrg DP_DECNRCM, 2093d522f475Smrg DP_DECOM, 2094d522f475Smrg DP_DECPEX, 2095d522f475Smrg DP_DECPFF, 2096d522f475Smrg DP_DECSCLM, 2097d522f475Smrg DP_DECSCNM, 2098d522f475Smrg DP_DECTCEM, 20993367019cSmrg DP_DELETE_IS_DEL, 21003367019cSmrg DP_EIGHT_BIT_META, 2101980988aeSmrg DP_FAST_SCROLL, 2102037a25ddSmrg DP_KEEP_CLIPBOARD, 21033367019cSmrg DP_KEEP_SELECTION, 21043367019cSmrg DP_KEYBOARD_TYPE, 21053367019cSmrg DP_POP_ON_BELL, 2106d522f475Smrg DP_PRN_EXTENT, 2107d522f475Smrg DP_PRN_FORMFEED, 21083367019cSmrg DP_RXVT_SCROLLBAR, 21093367019cSmrg DP_RXVT_SCROLL_TTY_KEYPRESS, 21103367019cSmrg DP_RXVT_SCROLL_TTY_OUTPUT, 21113367019cSmrg DP_SELECT_TO_CLIPBOARD, 2112d4fba8b9Smrg DP_X_ALTBUF, 2113d522f475Smrg DP_X_DECCOLM, 21143367019cSmrg DP_X_EXT_MOUSE, 2115d522f475Smrg DP_X_LOGGING, 21163367019cSmrg DP_X_LRMM, 2117d522f475Smrg DP_X_MARGIN, 2118d522f475Smrg DP_X_MORE, 2119d522f475Smrg DP_X_MOUSE, 21203367019cSmrg DP_X_NCSM, 2121d522f475Smrg DP_X_REVWRAP, 2122980988aeSmrg DP_X_REVWRAP2, 2123d522f475Smrg DP_X_X10MSE, 2124d522f475Smrg#if OPT_BLINK_CURS 2125d522f475Smrg DP_CRS_BLINK, 2126d522f475Smrg#endif 2127d522f475Smrg#if OPT_FOCUS_EVENT 2128d522f475Smrg DP_X_FOCUS, 2129d522f475Smrg#endif 21303367019cSmrg#if OPT_NUM_LOCK 21313367019cSmrg DP_REAL_NUMLOCK, 21323367019cSmrg DP_META_SENDS_ESC, 21333367019cSmrg#endif 21343367019cSmrg#if OPT_SHIFT_FONTS 21353367019cSmrg DP_RXVT_FONTSIZE, 21363367019cSmrg#endif 2137fa3f02f3Smrg#if OPT_SIXEL_GRAPHICS 2138fa3f02f3Smrg DP_DECSDM, 2139fa3f02f3Smrg#endif 21403367019cSmrg#if OPT_TEK4014 21413367019cSmrg DP_DECTEK, 21423367019cSmrg#endif 2143d522f475Smrg#if OPT_TOOLBAR 2144d522f475Smrg DP_TOOLBAR, 2145d522f475Smrg#endif 2146d4fba8b9Smrg#if OPT_GRAPHICS 2147fa3f02f3Smrg DP_X_PRIVATE_COLOR_REGISTERS, 2148d4fba8b9Smrg#endif 21499a64e1c5Smrg#if OPT_SIXEL_GRAPHICS 21509a64e1c5Smrg DP_SIXEL_SCROLLS_RIGHT, 2151d4fba8b9Smrg#endif 2152d4fba8b9Smrg#if OPT_PRINT_GRAPHICS 2153d4fba8b9Smrg DP_DECGEPM, /* Graphics Expanded Print Mode */ 2154d4fba8b9Smrg DP_DECGPCM, /* Graphics Print Color Mode */ 2155d4fba8b9Smrg DP_DECGPCS, /* Graphics Print Color Syntax */ 2156d4fba8b9Smrg DP_DECGPBM, /* Graphics Print Background Mode */ 2157d4fba8b9Smrg DP_DECGRPM, /* Graphics Rotated Print Mode */ 21589a64e1c5Smrg#endif 2159d522f475Smrg DP_LAST 2160d522f475Smrg} SaveModes; 2161d522f475Smrg 21620d92cbfdSchristos#define DoSM(code,value) screen->save_modes[code] = (unsigned) (value) 21630d92cbfdSchristos#define DoRM(code,value) value = (Boolean) screen->save_modes[code] 21640d92cbfdSchristos#define DoRM0(code,value) value = screen->save_modes[code] 2165d522f475Smrg 2166d522f475Smrg /* index into vt_shell[] or tek_shell[] */ 2167d522f475Smrgtypedef enum { 2168dfb07bc7Smrg noMenu = -1 2169dfb07bc7Smrg ,mainMenu 2170dfb07bc7Smrg ,vtMenu 2171dfb07bc7Smrg ,fontMenu 2172b7c89284Ssnj#if OPT_TEK4014 2173dfb07bc7Smrg ,tekMenu 2174b7c89284Ssnj#endif 2175d522f475Smrg} MenuIndex; 2176d522f475Smrg 2177cd3331d0Smrgtypedef enum { 2178cd3331d0Smrg bvOff = -1, 2179cd3331d0Smrg bvLow = 0, 2180cd3331d0Smrg bvHigh 2181cd3331d0Smrg} BellVolume; 2182cd3331d0Smrg 2183d522f475Smrg#define NUM_POPUP_MENUS 4 2184d522f475Smrg 2185d522f475Smrgtypedef struct { 2186d522f475Smrg String resource; 2187d522f475Smrg Pixel value; 21883367019cSmrg unsigned short red, green, blue; 2189cd3331d0Smrg int mode; /* -1=invalid, 0=unset, 1=set */ 2190d522f475Smrg} ColorRes; 2191d522f475Smrg 2192cd3331d0Smrg/* these are set in getPrinterFlags */ 2193cd3331d0Smrgtypedef struct { 2194cd3331d0Smrg int printer_extent; /* print complete page */ 2195cd3331d0Smrg int printer_formfeed; /* print formfeed per function */ 2196cd3331d0Smrg int printer_newline; /* print newline per function */ 2197cd3331d0Smrg int print_attributes; /* 0=off, 1=normal, 2=color */ 2198712a7ff4Smrg int print_everything; /* 0=all, 1=dft, 2=alt, 3=saved */ 2199cd3331d0Smrg} PrinterFlags; 2200cd3331d0Smrg 2201712a7ff4Smrgtypedef struct { 2202712a7ff4Smrg FILE * fp; /* output file/pipe used */ 2203712a7ff4Smrg Boolean isOpen; /* output was opened/tried */ 2204712a7ff4Smrg Boolean toFile; /* true when directly to file */ 22053367019cSmrg Boolean printer_checked; /* printer_command is checked */ 2206712a7ff4Smrg String printer_command; /* pipe/shell command string */ 2207712a7ff4Smrg Boolean printer_autoclose; /* close printer when offline */ 2208712a7ff4Smrg Boolean printer_extent; /* print complete page */ 2209712a7ff4Smrg Boolean printer_formfeed; /* print formfeed per function */ 2210712a7ff4Smrg Boolean printer_newline; /* print newline per function */ 2211712a7ff4Smrg int printer_controlmode; /* 0=off, 1=auto, 2=controller */ 2212712a7ff4Smrg int print_attributes; /* 0=off, 1=normal, 2=color */ 2213712a7ff4Smrg int print_everything; /* 0=all, 1=dft, 2=alt, 3=saved */ 2214712a7ff4Smrg} PrinterState; 2215712a7ff4Smrg 2216d522f475Smrgtypedef struct { 2217d522f475Smrg unsigned which; /* must have NCOLORS bits */ 2218d522f475Smrg Pixel colors[NCOLORS]; 2219d522f475Smrg char *names[NCOLORS]; 2220d522f475Smrg} ScrnColors; 2221d522f475Smrg 2222d4fba8b9Smrg#define NUM_GSETS 4 2223980988aeSmrg#define NUM_GSETS2 (NUM_GSETS + 1) /* include user-preferred */ 2224980988aeSmrg#define gsets_upss gsets[4] 2225980988aeSmrg 2226980988aeSmrg#define SAVED_CURSORS 2 2227d4fba8b9Smrg 2228d522f475Smrgtypedef struct { 2229d522f475Smrg Boolean saved; 2230d522f475Smrg int row; 2231d522f475Smrg int col; 22329a64e1c5Smrg IFlags flags; /* VTxxx saves graphics rendition */ 22330d92cbfdSchristos Char curgl; 22340d92cbfdSchristos Char curgr; 2235980988aeSmrg DECNRCM_codes gsets[NUM_GSETS2]; 2236dfb07bc7Smrg Boolean wrap_flag; 2237d522f475Smrg#if OPT_ISO_COLORS 2238d4fba8b9Smrg int cur_foreground; /* current foreground color */ 2239d4fba8b9Smrg int cur_background; /* current background color */ 2240d4fba8b9Smrg int sgr_foreground; /* current SGR foreground color */ 2241d4fba8b9Smrg int sgr_background; /* current SGR background color */ 2242d4fba8b9Smrg Boolean sgr_38_xcolors; /* true if ISO 8613 extension */ 2243d522f475Smrg#endif 2244d522f475Smrg} SavedCursor; 2245d522f475Smrg 2246cd3331d0Smrgtypedef struct _SaveTitle { 22473367019cSmrg struct _SaveTitle *next; 2248cd3331d0Smrg char *iconName; 2249cd3331d0Smrg char *windowName; 2250cd3331d0Smrg} SaveTitle; 2251cd3331d0Smrg 2252980988aeSmrg#define MAX_SAVED_TITLES 10 2253980988aeSmrg 2254980988aeSmrgtypedef struct { 2255980988aeSmrg int used; /* index to current item */ 2256980988aeSmrg SaveTitle data[MAX_SAVED_TITLES]; 2257980988aeSmrg} SavedTitles; 2258d522f475Smrg 2259d522f475Smrgtypedef struct { 2260d522f475Smrg int width; /* if > 0, width of scrollbar, */ 2261d522f475Smrg /* and scrollbar is showing */ 2262d522f475Smrg Boolean rv_cached; /* see ScrollBarReverseVideo */ 2263d522f475Smrg int rv_active; /* ...current reverse-video */ 2264d522f475Smrg Pixel bg; /* ...cached background color */ 2265d522f475Smrg Pixel fg; /* ...cached foreground color */ 2266d522f475Smrg Pixel bdr; /* ...cached border color */ 2267d522f475Smrg Pixmap bdpix; /* ...cached border pixmap */ 2268d522f475Smrg} SbInfo; 2269d522f475Smrg 2270d522f475Smrg#if OPT_TOOLBAR 2271d522f475Smrgtypedef struct { 2272d522f475Smrg Widget menu_bar; /* toolbar, if initialized */ 2273d522f475Smrg Dimension menu_height; /* ...and its height */ 2274d522f475Smrg Dimension menu_border; /* ...and its border */ 2275d522f475Smrg} TbInfo; 2276d522f475Smrg#define VT100_TB_INFO(name) screen.fullVwin.tb_info.name 2277d522f475Smrg#endif 2278d522f475Smrg 2279d522f475Smrgtypedef struct { 2280d522f475Smrg Window window; /* X window id */ 2281d4fba8b9Smrg int width; /* width of columns in pixels */ 2282d4fba8b9Smrg int height; /* height of rows in pixels */ 2283d522f475Smrg Dimension fullwidth; /* full width of window */ 2284d522f475Smrg Dimension fullheight; /* full height of window */ 2285d522f475Smrg int f_width; /* width of fonts in pixels */ 2286d522f475Smrg int f_height; /* height of fonts in pixels */ 2287d522f475Smrg int f_ascent; /* ascent of font in pixels */ 2288d522f475Smrg int f_descent; /* descent of font in pixels */ 2289d522f475Smrg SbInfo sb_info; 2290d4fba8b9Smrg GC filler_gc; /* filler's fg/bg */ 2291d4fba8b9Smrg GC border_gc; /* inner border's fg/bg */ 2292d4fba8b9Smrg GC marker_gc[2]; /* wrap-marks */ 2293d4fba8b9Smrg#if USE_DOUBLE_BUFFER 22943367019cSmrg Drawable drawable; /* X drawable id */ 22953367019cSmrg#endif 2296d522f475Smrg#if OPT_TOOLBAR 2297d522f475Smrg Boolean active; /* true if toolbars are used */ 2298d522f475Smrg TbInfo tb_info; /* toolbar information */ 2299d522f475Smrg#endif 2300d522f475Smrg} VTwin; 2301d522f475Smrg 2302d522f475Smrgtypedef struct { 2303d522f475Smrg Window window; /* X window id */ 2304d522f475Smrg int width; /* width of columns */ 2305d522f475Smrg int height; /* height of rows */ 2306d522f475Smrg Dimension fullwidth; /* full width of window */ 2307d522f475Smrg Dimension fullheight; /* full height of window */ 2308d522f475Smrg double tekscale; /* scale factor Tek -> vs100 */ 2309d522f475Smrg} TKwin; 2310d522f475Smrg 2311712a7ff4Smrgtypedef struct { 2312dfb07bc7Smrg char *f_n; /* the normal font */ 2313dfb07bc7Smrg char *f_b; /* the bold font */ 2314712a7ff4Smrg#if OPT_WIDE_CHARS 2315dfb07bc7Smrg char *f_w; /* the normal wide font */ 2316dfb07bc7Smrg char *f_wb; /* the bold wide font */ 2317712a7ff4Smrg#endif 2318712a7ff4Smrg} VTFontNames; 2319712a7ff4Smrg 2320dfb07bc7Smrgtypedef struct { 2321dfb07bc7Smrg char **list_n; /* the normal font */ 2322dfb07bc7Smrg char **list_b; /* the bold font */ 2323dfb07bc7Smrg#if OPT_WIDE_ATTRS || OPT_RENDERWIDE 2324dfb07bc7Smrg char **list_i; /* italic font (Xft only) */ 2325d4fba8b9Smrg char **list_bi; /* bold-italic font (Xft only) */ 2326dfb07bc7Smrg#endif 2327dfb07bc7Smrg#if OPT_WIDE_CHARS 2328dfb07bc7Smrg char **list_w; /* the normal wide font */ 2329dfb07bc7Smrg char **list_wb; /* the bold wide font */ 2330dfb07bc7Smrg char **list_wi; /* wide italic font (Xft only) */ 2331d4fba8b9Smrg char **list_wbi; /* wide bold-italic font (Xft only) */ 2332dfb07bc7Smrg#endif 2333dfb07bc7Smrg} VTFontList; 2334dfb07bc7Smrg 2335dfb07bc7Smrgtypedef struct { 2336dfb07bc7Smrg VTFontList x11; 2337dfb07bc7Smrg#if OPT_RENDERFONT 2338dfb07bc7Smrg VTFontList xft; 2339dfb07bc7Smrg#endif 2340dfb07bc7Smrg} XtermFontNames; 2341dfb07bc7Smrg 2342712a7ff4Smrgtypedef struct { 2343712a7ff4Smrg VTFontNames default_font; 2344712a7ff4Smrg String menu_font_names[NMENUFONTS][fMAX]; 2345dfb07bc7Smrg XtermFontNames fonts; 2346712a7ff4Smrg} SubResourceRec; 2347712a7ff4Smrg 23483367019cSmrg#if OPT_INPUT_METHOD 23493367019cSmrg#define NINPUTWIDGETS 3 23503367019cSmrgtypedef struct { 23513367019cSmrg Widget w; 23523367019cSmrg XIM xim; /* input method attached to 'w' */ 23533367019cSmrg XIC xic; /* input context attached to 'xim' */ 23543367019cSmrg} TInput; 23553367019cSmrg#endif 23563367019cSmrg 23573367019cSmrgtypedef enum { 23583367019cSmrg CURSOR_BLOCK = 2 23593367019cSmrg , CURSOR_UNDERLINE = 4 23603367019cSmrg , CURSOR_BAR = 6 23613367019cSmrg} XtCursorShape; 23623367019cSmrg 23633367019cSmrg#define isCursorBlock(s) ((s)->cursor_shape == CURSOR_BLOCK) 23643367019cSmrg#define isCursorUnderline(s) ((s)->cursor_shape == CURSOR_UNDERLINE) 23653367019cSmrg#define isCursorBar(s) ((s)->cursor_shape == CURSOR_BAR) 23663367019cSmrg 23673367019cSmrgtypedef enum { 23683367019cSmrg DEFAULT_STYLE = 0 23693367019cSmrg , BLINK_BLOCK 23703367019cSmrg , STEADY_BLOCK 23713367019cSmrg , BLINK_UNDERLINE 23723367019cSmrg , STEADY_UNDERLINE 23733367019cSmrg , BLINK_BAR 23743367019cSmrg , STEADY_BAR 23753367019cSmrg} XtCursorStyle; 23763367019cSmrg 2377d4fba8b9Smrg#if OPT_GRAPHICS 2378d4fba8b9Smrg#define GraphicsTermId(screen) (\ 2379d4fba8b9Smrg (screen)->graphics_termid \ 2380d4fba8b9Smrg ? (screen)->graphics_termid \ 2381d4fba8b9Smrg : (screen)->terminal_id) 2382d4fba8b9Smrg#else 2383d4fba8b9Smrg#define GraphicsTermId(screen) (screen)->terminal_id 2384d4fba8b9Smrg#endif 2385d4fba8b9Smrg 2386d4fba8b9Smrg#if OPT_REGIS_GRAPHICS 2387d4fba8b9Smrg#define optRegisGraphics(screen) \ 2388d4fba8b9Smrg (GraphicsTermId(screen) == 125 || \ 2389d4fba8b9Smrg GraphicsTermId(screen) == 240 || \ 2390d4fba8b9Smrg GraphicsTermId(screen) == 241 || \ 2391d4fba8b9Smrg GraphicsTermId(screen) == 330 || \ 2392d4fba8b9Smrg GraphicsTermId(screen) == 340) 2393d4fba8b9Smrg#else 2394d4fba8b9Smrg#define optRegisGraphics(screen) False 2395d4fba8b9Smrg#endif 2396d4fba8b9Smrg 2397d4fba8b9Smrg#if OPT_SIXEL_GRAPHICS 2398d4fba8b9Smrg#define optSixelGraphics(screen) \ 2399d4fba8b9Smrg (GraphicsTermId(screen) == 240 || \ 2400d4fba8b9Smrg GraphicsTermId(screen) == 241 || \ 2401d4fba8b9Smrg GraphicsTermId(screen) == 330 || \ 2402d4fba8b9Smrg GraphicsTermId(screen) == 340 || \ 2403d4fba8b9Smrg GraphicsTermId(screen) == 382) 2404d4fba8b9Smrg#else 2405d4fba8b9Smrg#define optSixelGraphics(screen) False 2406d4fba8b9Smrg#endif 2407d4fba8b9Smrg 2408d4fba8b9Smrg#if OPT_PRINT_GRAPHICS 2409d4fba8b9Smrg#define if_PRINT_GRAPHICS2(statement) if (optRegisGraphics(screen)) { statement; } else 2410d4fba8b9Smrg#else 2411d4fba8b9Smrg#define if_PRINT_GRAPHICS2(statement) /* nothing */ 2412d4fba8b9Smrg#endif 2413d4fba8b9Smrg 2414d522f475Smrgtypedef struct { 2415d522f475Smrg/* These parameters apply to both windows */ 2416d522f475Smrg Display *display; /* X display for screen */ 2417d522f475Smrg int respond; /* socket for responses 2418d522f475Smrg (position report, etc.) */ 2419d4fba8b9Smrg int nextEventDelay; /* msecs to delay for x-events */ 2420d522f475Smrg/* These parameters apply to VT100 window */ 2421d4fba8b9Smrg IChar *unparse_bfr; 2422d522f475Smrg unsigned unparse_len; 2423d4fba8b9Smrg unsigned unparse_max; /* limitResponse resource */ 2424980988aeSmrg unsigned strings_max; /* maxStringParse resource */ 2425d522f475Smrg 2426d522f475Smrg#if OPT_TCAP_QUERY 2427d522f475Smrg int tc_query_code; 2428d522f475Smrg Bool tc_query_fkey; 2429d522f475Smrg#endif 2430d522f475Smrg pid_t pid; /* pid of process on far side */ 2431d522f475Smrg uid_t uid; /* user id of actual person */ 2432d522f475Smrg gid_t gid; /* group id of actual person */ 2433d522f475Smrg ColorRes Tcolors[NCOLORS]; /* terminal colors */ 2434d522f475Smrg#if OPT_HIGHLIGHT_COLOR 2435d522f475Smrg Boolean hilite_color; /* hilite colors override */ 2436d522f475Smrg Boolean hilite_reverse; /* hilite overrides reverse */ 2437d522f475Smrg#endif 2438d522f475Smrg#if OPT_ISO_COLORS 24393367019cSmrg XColor * cmap_data; /* color table */ 24403367019cSmrg unsigned cmap_size; 2441d522f475Smrg ColorRes Acolors[MAXCOLORS]; /* ANSI color emulation */ 2442d522f475Smrg int veryBoldColors; /* modifier for boldColors */ 2443d522f475Smrg Boolean boldColors; /* can we make bold colors? */ 2444d522f475Smrg Boolean colorMode; /* are we using color mode? */ 2445d522f475Smrg Boolean colorULMode; /* use color for underline? */ 2446d522f475Smrg Boolean italicULMode; /* italic font for underline? */ 2447d522f475Smrg Boolean colorBDMode; /* use color for bold? */ 2448d522f475Smrg Boolean colorBLMode; /* use color for blink? */ 2449d522f475Smrg Boolean colorRVMode; /* use color for reverse? */ 2450d522f475Smrg Boolean colorAttrMode; /* prefer colorUL/BD to SGR */ 245194644356Smrg#if OPT_WIDE_ATTRS 245294644356Smrg Boolean colorITMode; /* use color for italics? */ 245394644356Smrg#endif 2454d4fba8b9Smrg#if OPT_DIRECT_COLOR 2455d4fba8b9Smrg Boolean direct_color; /* direct-color enabled? */ 2456d522f475Smrg#endif 2457d1603babSmrg#if OPT_WIDE_ATTRS && OPT_SGR2_HASH 2458d1603babSmrg Boolean faint_relative; /* faint is relative? */ 2459d1603babSmrg#endif 2460980988aeSmrg#if OPT_VT525_COLORS 2461980988aeSmrg int assigned_fg; /* DECAC */ 2462980988aeSmrg int assigned_bg; 2463980988aeSmrg struct { 2464980988aeSmrg int fg; /* 0..15 */ 2465980988aeSmrg int bg; /* 0..15 */ 2466980988aeSmrg } alt_colors[16]; /* DECATC if DECSTGLT is 1 or 2 */ 2467980988aeSmrg#endif 2468d4fba8b9Smrg#endif /* OPT_ISO_COLORS */ 2469d522f475Smrg#if OPT_DEC_CHRSET 2470d522f475Smrg Boolean font_doublesize;/* enable font-scaling */ 2471d522f475Smrg int cache_doublesize;/* limit of our cache */ 2472d522f475Smrg Char cur_chrset; /* character-set index & code */ 2473d522f475Smrg int fonts_used; /* count items in double_fonts */ 2474d522f475Smrg XTermFonts double_fonts[NUM_CHRSET]; 2475d4fba8b9Smrg#if OPT_RENDERFONT 2476d1603babSmrg XTermXftFonts double_xft_fonts[NUM_CHRSET]; 2477d522f475Smrg#endif 2478d4fba8b9Smrg#endif /* OPT_DEC_CHRSET */ 2479d522f475Smrg#if OPT_DEC_RECTOPS 2480d522f475Smrg int cur_decsace; /* parameter for DECSACE */ 2481d4fba8b9Smrg int checksum_ext; /* extensions for DECRQCRA */ 2482d4fba8b9Smrg int checksum_ext0; /* initial checksumExtension */ 2483d522f475Smrg#endif 2484d522f475Smrg#if OPT_WIDE_CHARS 2485d522f475Smrg Boolean wide_chars; /* true when 16-bit chars */ 2486d522f475Smrg Boolean vt100_graphics; /* true to allow vt100-graphics */ 2487d522f475Smrg Boolean utf8_inparse; /* true to enable UTF-8 parser */ 24883367019cSmrg Boolean normalized_c; /* true to precompose to Form C */ 2489712a7ff4Smrg char * utf8_mode_s; /* use UTF-8 decode/encode */ 2490712a7ff4Smrg char * utf8_fonts_s; /* use UTF-8 decode/encode */ 2491d4fba8b9Smrg char * utf8_title_s; /* use UTF-8 titles */ 2492fa3f02f3Smrg int utf8_nrc_mode; /* saved UTF-8 mode for DECNRCM */ 2493fa3f02f3Smrg Boolean utf8_always; /* special case for wideChars */ 2494d522f475Smrg int utf8_mode; /* use UTF-8 decode/encode: 0-2 */ 2495d4fba8b9Smrg int utf8_fonts; /* use UTF-8 fonts: 0-2 */ 2496d4fba8b9Smrg int utf8_title; /* use UTF-8 EWHM props: 0-2 */ 2497d522f475Smrg int max_combining; /* maximum # of combining chars */ 2498d522f475Smrg Boolean utf8_latin1; /* use UTF-8 with Latin-1 bias */ 2499d4fba8b9Smrg Boolean utf8_weblike; /* use UTF-8 with browser bias */ 2500d522f475Smrg int latin9_mode; /* poor man's luit, latin9 */ 2501d522f475Smrg int unicode_font; /* font uses unicode encoding */ 2502d522f475Smrg int utf_count; /* state of utf_char */ 2503d522f475Smrg IChar utf_char; /* in-progress character */ 25043367019cSmrg Boolean char_was_written; 2505d522f475Smrg int last_written_col; 2506d522f475Smrg int last_written_row; 2507d522f475Smrg#endif 2508d1603babSmrg TypedBuffer(IChar); 2509d1603babSmrg TypedBuffer(Char); 2510d1603babSmrg TypedBuffer(XChar2b); 2511d522f475Smrg#if OPT_BROKEN_OSC 2512d522f475Smrg Boolean brokenLinuxOSC; /* true to ignore Linux palette ctls */ 2513d522f475Smrg#endif 2514d522f475Smrg#if OPT_BROKEN_ST 2515d522f475Smrg Boolean brokenStringTerm; /* true to match old OSC parse */ 2516d522f475Smrg#endif 2517d522f475Smrg#if OPT_C1_PRINT || OPT_WIDE_CHARS 2518d522f475Smrg Boolean c1_printable; /* true if we treat C1 as print */ 2519d522f475Smrg#endif 2520d522f475Smrg int border; /* inner border */ 2521d522f475Smrg int scrollBarBorder; /* scrollBar border */ 25220d92cbfdSchristos long event_mask; 25230d92cbfdSchristos unsigned send_mouse_pos; /* user wants mouse transition */ 2524d522f475Smrg /* and position information */ 25253367019cSmrg int extend_coords; /* support large terminals */ 2526dfb07bc7Smrg#if OPT_FOCUS_EVENT 2527d522f475Smrg Boolean send_focus_pos; /* user wants focus in/out info */ 2528dfb07bc7Smrg#endif 2529d522f475Smrg Boolean quiet_grab; /* true if no cursor change on focus */ 2530d522f475Smrg#if OPT_PASTE64 2531b7c89284Ssnj Cardinal base64_paste; /* set to send paste in base64 */ 2532d522f475Smrg int base64_final; /* string-terminator for paste */ 2533d522f475Smrg /* _qWriteSelectionData expects these to be initialized to zero. 2534d522f475Smrg * base64_flush() is the last step of the conversion, it clears these 2535d522f475Smrg * variables. 2536d522f475Smrg */ 25370d92cbfdSchristos unsigned base64_accu; 25380d92cbfdSchristos unsigned base64_count; 25390d92cbfdSchristos unsigned base64_pad; 2540d522f475Smrg#endif 2541d4fba8b9Smrg#if OPT_PASTE64 || OPT_READLINE 2542d4fba8b9Smrg unsigned paste_brackets; 2543d4fba8b9Smrg /* not part of bracketed-paste, these are here to simplify ifdefs */ 2544d4fba8b9Smrg unsigned dclick3_deletes; 2545d4fba8b9Smrg unsigned paste_literal_nl; 2546d4fba8b9Smrg#endif 2547d522f475Smrg#if OPT_READLINE 2548d522f475Smrg unsigned click1_moves; 2549d522f475Smrg unsigned paste_moves; 2550d522f475Smrg unsigned paste_quotes; 2551d522f475Smrg#endif /* OPT_READLINE */ 2552d522f475Smrg#if OPT_DEC_LOCATOR 2553d522f475Smrg Boolean locator_reset; /* turn mouse off after 1 report? */ 2554d522f475Smrg Boolean locator_pixels; /* report in pixels? */ 2555d522f475Smrg /* if false, report in cells */ 25560d92cbfdSchristos unsigned locator_events; /* what events to report */ 2557d522f475Smrg Boolean loc_filter; /* is filter rectangle active? */ 2558d522f475Smrg int loc_filter_top; /* filter rectangle for DEC Locator */ 2559d522f475Smrg int loc_filter_left; 2560d522f475Smrg int loc_filter_bottom; 2561d522f475Smrg int loc_filter_right; 2562d522f475Smrg#endif /* OPT_DEC_LOCATOR */ 2563d522f475Smrg int mouse_button; /* current button pressed */ 2564d522f475Smrg int mouse_row; /* ...and its row */ 2565d522f475Smrg int mouse_col; /* ...and its column */ 2566d522f475Smrg int select; /* xterm selected */ 2567d522f475Smrg Boolean bellOnReset; /* bellOnReset */ 2568d522f475Smrg Boolean visualbell; /* visual bell mode */ 2569d522f475Smrg Boolean poponbell; /* pop on bell mode */ 25700d92cbfdSchristos 2571dfb07bc7Smrg Boolean eraseSavedLines; /* eraseSavedLines option */ 2572dfb07bc7Smrg Boolean eraseSavedLines0; /* initial eraseSavedLines */ 2573dfb07bc7Smrg Boolean tabCancelsWrap; /* tabCancelsWrap option */ 2574dfb07bc7Smrg 25753367019cSmrg Boolean allowPasteControls; /* PasteControls mode */ 2576cd3331d0Smrg Boolean allowColorOps; /* ColorOps mode */ 25770d92cbfdSchristos Boolean allowFontOps; /* FontOps mode */ 2578dfb07bc7Smrg Boolean allowMouseOps; /* MouseOps mode */ 2579d522f475Smrg Boolean allowSendEvents;/* SendEvent mode */ 25800d92cbfdSchristos Boolean allowTcapOps; /* TcapOps mode */ 2581d522f475Smrg Boolean allowTitleOps; /* TitleOps mode */ 2582d522f475Smrg Boolean allowWindowOps; /* WindowOps mode */ 25830d92cbfdSchristos 258494644356Smrg Boolean allowPasteControl0; /* PasteControls mode */ 2585cd3331d0Smrg Boolean allowColorOp0; /* initial ColorOps mode */ 25860d92cbfdSchristos Boolean allowFontOp0; /* initial FontOps mode */ 2587dfb07bc7Smrg Boolean allowMouseOp0; /* initial MouseOps mode */ 2588d522f475Smrg Boolean allowSendEvent0;/* initial SendEvent mode */ 25890d92cbfdSchristos Boolean allowTcapOp0; /* initial TcapOps mode */ 2590d522f475Smrg Boolean allowTitleOp0; /* initial TitleOps mode */ 2591d522f475Smrg Boolean allowWindowOp0; /* initial WindowOps mode */ 25920d92cbfdSchristos 2593cd3331d0Smrg String disallowedColorOps; 2594cd3331d0Smrg char disallow_color_ops[ecLAST]; 2595cd3331d0Smrg 2596cd3331d0Smrg String disallowedFontOps; 2597cd3331d0Smrg char disallow_font_ops[efLAST]; 2598cd3331d0Smrg 2599dfb07bc7Smrg String disallowedMouseOps; 2600dfb07bc7Smrg char disallow_mouse_ops[emLAST]; 2601dfb07bc7Smrg 2602d1603babSmrg String disallowedPasteOps; 2603d1603babSmrg char disallow_paste_ops[epLAST]; 2604d4fba8b9Smrg 2605cd3331d0Smrg String disallowedTcapOps; 2606cd3331d0Smrg char disallow_tcap_ops[etLAST]; 2607cd3331d0Smrg 2608cd3331d0Smrg String disallowedWinOps; 2609cd3331d0Smrg char disallow_win_ops[ewLAST]; 2610cd3331d0Smrg 2611d522f475Smrg Boolean awaitInput; /* select-timeout mode */ 2612d522f475Smrg Boolean grabbedKbd; /* keyboard is grabbed */ 2613d522f475Smrg#ifdef ALLOWLOGGING 2614d522f475Smrg int logging; /* logging mode */ 2615d522f475Smrg int logfd; /* file descriptor of log */ 2616d522f475Smrg char *logfile; /* log file name */ 2617d522f475Smrg Char *logstart; /* current start of log buffer */ 2618d522f475Smrg#endif 2619d522f475Smrg int inhibit; /* flags for inhibiting changes */ 2620d522f475Smrg 2621d522f475Smrg/* VT window parameters */ 2622d522f475Smrg Boolean Vshow; /* VT window showing */ 2623d522f475Smrg VTwin fullVwin; 26243367019cSmrg int needSwap; 2625d522f475Smrg#ifndef NO_ACTIVE_ICON 2626d522f475Smrg VTwin iconVwin; 2627d522f475Smrg VTwin *whichVwin; 2628d522f475Smrg#endif /* NO_ACTIVE_ICON */ 2629d522f475Smrg 2630d522f475Smrg int pointer_mode; /* when to use hidden_cursor */ 26319a64e1c5Smrg int pointer_mode0; /* ...initial value */ 2632d522f475Smrg Boolean hide_pointer; /* true to use "hidden_cursor" */ 2633d4fba8b9Smrg String pointer_shape; /* name of shape in cursor font */ 26348f44fb3bSmrg Cursor pointer_cursor; /* current pointer cursor */ 2635d522f475Smrg Cursor hidden_cursor; /* hidden cursor in window */ 2636d522f475Smrg 2637980988aeSmrg String answer_back; /* response to ENQ */ 2638980988aeSmrg Boolean prefer_latin1; /* preference for UPSS */ 2639d522f475Smrg 2640712a7ff4Smrg PrinterState printer_state; /* actual printer state */ 2641cd3331d0Smrg PrinterFlags printer_flags; /* working copy of printer flags */ 2642190d7dceSmrg Boolean print_rawchars; /* true to ignore printer check */ 2643712a7ff4Smrg#if OPT_PRINT_ON_EXIT 2644712a7ff4Smrg Boolean write_error; 2645712a7ff4Smrg#endif 2646cd3331d0Smrg 2647d522f475Smrg Boolean fnt_prop; /* true if proportional fonts */ 2648d4fba8b9Smrg unsigned fnt_boxes; /* 0=no boxes, 1=old, 2=unicode */ 2649cd3331d0Smrg Boolean force_packed; /* true to override proportional */ 2650d522f475Smrg#if OPT_BOX_CHARS 26513367019cSmrg Boolean force_box_chars;/* true if we assume no boxchars */ 2652d4fba8b9Smrg Boolean broken_box_chars;/* true if broken boxchars */ 2653fa3f02f3Smrg Boolean assume_all_chars;/* true to allow missing chars */ 2654cd3331d0Smrg Boolean allow_packing; /* true to allow packed-fonts */ 2655d522f475Smrg#endif 2656980988aeSmrg#if OPT_BOX_CHARS || OPT_WIDE_CHARS 2657980988aeSmrg Boolean force_all_chars;/* true to outline missing chars */ 2658980988aeSmrg#endif 2659980988aeSmrg 2660d522f475Smrg Dimension fnt_wide; 2661d522f475Smrg Dimension fnt_high; 26623367019cSmrg float scale_height; /* scaling for font-height */ 2663d522f475Smrg XTermFonts fnts[fMAX]; /* normal/bold/etc for terminal */ 2664d522f475Smrg Boolean free_bold_box; /* same_font_size's austerity */ 2665712a7ff4Smrg Boolean allowBoldFonts; /* do we use bold fonts at all? */ 26669a64e1c5Smrg#if OPT_WIDE_ATTRS 26679a64e1c5Smrg XTermFonts ifnts[fMAX]; /* normal/bold/etc italic fonts */ 26689a64e1c5Smrg Boolean ifnts_ok; /* true if ifnts[] is cached */ 26699a64e1c5Smrg#endif 2670d522f475Smrg#ifndef NO_ACTIVE_ICON 2671cb4a1343Smrg XTermFonts fnt_icon; /* icon font */ 2672cb4a1343Smrg String icon_fontname; /* name of icon font */ 2673cb4a1343Smrg int icon_fontnum; /* number to use for icon font */ 2674d522f475Smrg#endif /* NO_ACTIVE_ICON */ 2675d522f475Smrg int enbolden; /* overstrike for bold font */ 2676d522f475Smrg XPoint *box; /* draw unselected cursor */ 2677d522f475Smrg 2678d522f475Smrg int cursor_state; /* ON, OFF, or BLINKED_OFF */ 2679d522f475Smrg int cursor_busy; /* do not redraw... */ 26800d92cbfdSchristos Boolean cursor_underline; /* true if cursor is in underline mode */ 2681d1603babSmrg Boolean cursor_bar; /* true if cursor is in bar mode */ 26823367019cSmrg XtCursorShape cursor_shape; 2683d522f475Smrg#if OPT_BLINK_CURS 2684d4fba8b9Smrg BlinkOps cursor_blink; /* cursor blink enable */ 2685d4fba8b9Smrg BlinkOps cursor_blink_i; /* save cursor blink enable */ 2686d4fba8b9Smrg char * cursor_blink_s; /* ...resource cursorBlink */ 2687d4fba8b9Smrg int cursor_blink_esc; /* cursor blink escape-state */ 2688d4fba8b9Smrg Boolean cursor_blink_xor; /* how to merge menu/escapes */ 2689d522f475Smrg#endif 2690d522f475Smrg#if OPT_BLINK_TEXT 2691d522f475Smrg Boolean blink_as_bold; /* text blink disable */ 2692d522f475Smrg#endif 2693d522f475Smrg#if OPT_BLINK_CURS || OPT_BLINK_TEXT 2694d522f475Smrg int blink_state; /* ON, OFF, or BLINKED_OFF */ 2695d522f475Smrg int blink_on; /* cursor on time (msecs) */ 2696d522f475Smrg int blink_off; /* cursor off time (msecs) */ 2697d522f475Smrg XtIntervalId blink_timer; /* timer-id for cursor-proc */ 2698d522f475Smrg#endif 2699d522f475Smrg#if OPT_ZICONBEEP 2700d522f475Smrg Boolean zIconBeep_flagged; /* True if icon name was changed */ 2701d522f475Smrg#endif /* OPT_ZICONBEEP */ 2702d522f475Smrg int cursor_GC; /* see ShowCursor() */ 2703d522f475Smrg int cursor_set; /* requested state */ 2704d522f475Smrg CELL cursorp; /* previous cursor row/column */ 2705d522f475Smrg int cur_col; /* current cursor column */ 2706d522f475Smrg int cur_row; /* current cursor row */ 2707d522f475Smrg int max_col; /* rightmost column */ 2708d522f475Smrg int max_row; /* bottom row */ 2709d522f475Smrg int top_marg; /* top line of scrolling region */ 2710d522f475Smrg int bot_marg; /* bottom line of " " */ 27113367019cSmrg int lft_marg; /* left column of " " */ 27123367019cSmrg int rgt_marg; /* right column of " " */ 2713d522f475Smrg Widget scrollWidget; /* pointer to scrollbar struct */ 2714d4fba8b9Smrg#if USE_DOUBLE_BUFFER 2715d4fba8b9Smrg int buffered_sb; /* nonzero when pending update */ 2716d4fba8b9Smrg struct timeval buffered_at; /* reference time, for FPS */ 2717d4fba8b9Smrg#define DbeMsecs(xw) (1000L / (long) resource.buffered_fps) 2718d4fba8b9Smrg#endif 2719d522f475Smrg /* 2720d522f475Smrg * Indices used to keep track of the top of the vt100 window and 2721d522f475Smrg * the saved lines, taking scrolling into account. 2722d522f475Smrg */ 2723d522f475Smrg int topline; /* line number of top, <= 0 */ 272494644356Smrg long saved_fifo; /* number of lines that've ever been saved */ 2725d522f475Smrg int savedlines; /* number of lines that've been saved */ 2726d522f475Smrg int savelines; /* number of lines off top to save */ 2727d522f475Smrg int scroll_amt; /* amount to scroll */ 2728d522f475Smrg int refresh_amt; /* amount to refresh */ 2729d522f475Smrg /* 2730b7c89284Ssnj * Working variables for getLineData(). 2731b7c89284Ssnj */ 2732b7c89284Ssnj size_t lineExtra; /* extra space for combining chars */ 2733d4fba8b9Smrg size_t cellExtra; /* extra space for combining chars */ 2734b7c89284Ssnj /* 2735b7c89284Ssnj * Pointer to the current visible buffer. 2736d522f475Smrg */ 2737d522f475Smrg ScrnBuf visbuf; /* ptr to visible screen buf (main) */ 2738d522f475Smrg /* 2739d522f475Smrg * Data for the normal buffer, which may have saved lines to which 2740d522f475Smrg * the user can scroll. 2741d522f475Smrg */ 2742b7c89284Ssnj ScrnBuf saveBuf_index; 2743b7c89284Ssnj Char *saveBuf_data; 2744d522f475Smrg /* 2745b7c89284Ssnj * Data for visible and alternate buffer. 2746d522f475Smrg */ 2747b7c89284Ssnj ScrnBuf editBuf_index[2]; 2748b7c89284Ssnj Char *editBuf_data[2]; 2749b7c89284Ssnj int whichBuf; /* 0/1 for normal/alternate buf */ 2750b7c89284Ssnj Boolean is_running; /* true when buffers are legal */ 2751d522f475Smrg /* 2752d522f475Smrg * Workspace used for screen operations. 2753d522f475Smrg */ 2754d522f475Smrg Char **save_ptr; /* workspace for save-pointers */ 2755d522f475Smrg size_t save_len; /* ...and its length */ 2756d522f475Smrg 2757d522f475Smrg int scrolllines; /* number of lines to button scroll */ 27583367019cSmrg Boolean alternateScroll; /* scroll-actions become keys */ 2759d522f475Smrg Boolean scrollttyoutput; /* scroll to bottom on tty output */ 2760d522f475Smrg Boolean scrollkey; /* scroll to bottom on key */ 2761d522f475Smrg Boolean cursor_moved; /* scrolling makes cursor move */ 2762d522f475Smrg 27630d92cbfdSchristos Boolean do_wrap; /* true if cursor in last column 2764d522f475Smrg and character just output */ 2765d522f475Smrg 2766d522f475Smrg int incopy; /* 0 idle; 1 XCopyArea issued; 2767d522f475Smrg -1 first GraphicsExpose seen, 2768d522f475Smrg but last not seen */ 2769d522f475Smrg int copy_src_x; /* params from last XCopyArea ... */ 2770d522f475Smrg int copy_src_y; 2771d522f475Smrg unsigned int copy_width; 2772d522f475Smrg unsigned int copy_height; 2773d522f475Smrg int copy_dest_x; 2774d522f475Smrg int copy_dest_y; 2775d522f475Smrg 27763367019cSmrg Dimension embed_wide; 27773367019cSmrg Dimension embed_high; 27783367019cSmrg 2779d522f475Smrg Boolean c132; /* allow change to 132 columns */ 2780d522f475Smrg Boolean curses; /* kludge line wrap for more */ 2781d522f475Smrg Boolean hp_ll_bc; /* kludge HP-style ll for xdb */ 2782d522f475Smrg Boolean marginbell; /* true if margin bell on */ 2783d522f475Smrg int nmarginbell; /* columns from right margin */ 2784cd3331d0Smrg int bellArmed; /* cursor below bell margin */ 2785cd3331d0Smrg BellVolume marginVolume; /* margin-bell volume */ 2786cd3331d0Smrg BellVolume warningVolume; /* warning-bell volume */ 2787d522f475Smrg Boolean multiscroll; /* true if multi-scroll */ 2788d522f475Smrg int scrolls; /* outstanding scroll count, 2789d522f475Smrg used only with multiscroll */ 2790d522f475Smrg SavedCursor sc[SAVED_CURSORS]; /* data for restore cursor */ 27919a64e1c5Smrg IFlags save_modes[DP_LAST]; /* save dec/xterm private modes */ 2792d522f475Smrg 2793cd3331d0Smrg int title_modes; /* control set/get of titles */ 27949a64e1c5Smrg int title_modes0; /* ...initial value */ 2795980988aeSmrg SavedTitles saved_titles; 2796cd3331d0Smrg 2797d522f475Smrg /* Improved VT100 emulation stuff. */ 2798d522f475Smrg String keyboard_dialect; /* default keyboard dialect */ 2799980988aeSmrg DECNRCM_codes gsets[NUM_GSETS2]; /* G0 through G3, plus UPSS */ 2800d522f475Smrg Char curgl; /* Current GL setting. */ 2801d522f475Smrg Char curgr; /* Current GR setting. */ 2802d522f475Smrg Char curss; /* Current single shift. */ 2803d522f475Smrg String term_id; /* resource for terminal_id */ 2804d522f475Smrg int terminal_id; /* 100=vt100, 220=vt220, etc. */ 2805980988aeSmrg int display_da1; /* 100=vt100, 220=vt220, etc. */ 2806d522f475Smrg int vtXX_level; /* 0=vt52, 1,2,3 = vt100 ... vt320 */ 28073367019cSmrg int ansi_level; /* dpANSI levels 1,2,3 */ 2808d522f475Smrg int protected_mode; /* 0=off, 1=DEC, 2=ISO */ 2809d522f475Smrg Boolean always_bold_mode; /* compare normal/bold font */ 2810d522f475Smrg Boolean always_highlight; /* whether to highlight cursor */ 2811d522f475Smrg Boolean bold_mode; /* use bold font or overstrike */ 2812d522f475Smrg Boolean delete_is_del; /* true for compatible Delete key */ 2813d522f475Smrg Boolean jumpscroll; /* whether we should jumpscroll */ 2814b7c89284Ssnj Boolean fastscroll; /* whether we should fastscroll */ 2815d522f475Smrg Boolean old_fkeys; /* true for compatible fkeys */ 28169a64e1c5Smrg Boolean old_fkeys0; /* ...initial value */ 2817d522f475Smrg Boolean underline; /* whether to underline text */ 2818d522f475Smrg 2819d522f475Smrg#if OPT_MAXIMIZE 2820d522f475Smrg Boolean restore_data; 2821d522f475Smrg int restore_x; 2822d522f475Smrg int restore_y; 2823d522f475Smrg unsigned restore_width; 2824d522f475Smrg unsigned restore_height; 2825d522f475Smrg#endif 2826d522f475Smrg 282794644356Smrg#if OPT_REGIS_GRAPHICS 282894644356Smrg String graphics_regis_default_font; /* font for "builtin" */ 282994644356Smrg 283094644356Smrg String graphics_regis_screensize; /* given a size in pixels */ 283194644356Smrg Dimension graphics_regis_def_wide; /* ...corresponding width */ 283294644356Smrg Dimension graphics_regis_def_high; /* ...and height */ 283394644356Smrg#endif 283494644356Smrg 283594644356Smrg#if OPT_GRAPHICS 2836d4fba8b9Smrg String graph_termid; /* resource for graphics_termid */ 2837d4fba8b9Smrg int graphics_termid; /* based on terminal_id */ 283894644356Smrg String graphics_max_size; /* given a size in pixels */ 283994644356Smrg Dimension graphics_max_wide; /* ...corresponding width */ 284094644356Smrg Dimension graphics_max_high; /* ...and height */ 284194644356Smrg#endif 284294644356Smrg 2843cd3331d0Smrg#if OPT_SCROLL_LOCK 2844cd3331d0Smrg Boolean allowScrollLock;/* ScrollLock mode */ 2845cd3331d0Smrg Boolean allowScrollLock0;/* initial ScrollLock mode */ 2846636d5e9fSmrg Boolean autoScrollLock; /* Auto ScrollLock mode */ 2847cd3331d0Smrg Boolean scroll_lock; /* true to keep buffer in view */ 2848cd3331d0Smrg Boolean scroll_dirty; /* scrolling makes screen dirty */ 2849cd3331d0Smrg#endif 2850cd3331d0Smrg 2851fa3f02f3Smrg#if OPT_SIXEL_GRAPHICS 2852fa3f02f3Smrg Boolean sixel_scrolling; /* sixel scrolling */ 28539a64e1c5Smrg Boolean sixel_scrolls_right; /* sixel scrolling moves cursor to right */ 2854980988aeSmrg Boolean sixel_scrolls_right0; /* initial sixelScrolling mode */ 28559a64e1c5Smrg#endif 28569a64e1c5Smrg 28579a64e1c5Smrg#if OPT_GRAPHICS 28589a64e1c5Smrg int numcolorregisters; /* number of supported color registers */ 2859fa3f02f3Smrg Boolean privatecolorregisters; /* private color registers for each graphic */ 2860980988aeSmrg Boolean privatecolorregisters0; /* initial privateColorRegisters */ 2861980988aeSmrg Boolean incremental_graphics; /* draw graphics incrementally */ 2862fa3f02f3Smrg#endif 2863fa3f02f3Smrg 2864d4fba8b9Smrg /* Graphics Printing */ 2865d4fba8b9Smrg#if OPT_PRINT_GRAPHICS 2866d4fba8b9Smrg Boolean graphics_print_to_host; 2867d4fba8b9Smrg Boolean graphics_expanded_print_mode; 2868d4fba8b9Smrg Boolean graphics_print_color_mode; 2869d4fba8b9Smrg Boolean graphics_print_color_syntax; 2870d4fba8b9Smrg Boolean graphics_print_background_mode; 2871d4fba8b9Smrg Boolean graphics_rotated_print_mode; 2872d4fba8b9Smrg#endif 2873d4fba8b9Smrg 287450027b5bSmrg#define StatusLineRows 1 /* number of rows in status-line */ 287550027b5bSmrg 287650027b5bSmrg#if OPT_STATUS_LINE 287750027b5bSmrg#define AddStatusLineRows(nrow) nrow += StatusLineRows 287850027b5bSmrg#define LastRowNumber(screen) \ 287950027b5bSmrg ( (screen)->max_row \ 288050027b5bSmrg + (IsStatusShown(screen) ? StatusLineRows : 0) ) 288150027b5bSmrg#define FirstRowNumber(screen) \ 288250027b5bSmrg ( (screen)->status_active \ 288350027b5bSmrg ? LastRowNumber(screen) \ 288450027b5bSmrg : 0 ) 288550027b5bSmrg#define IsStatusShown(screen) \ 288650027b5bSmrg ( ( (screen)->status_type == 2) || \ 288750027b5bSmrg ( (screen)->status_type == 1) ) 288850027b5bSmrg#define PlusStatusLine(screen,expr) \ 288950027b5bSmrg ( (screen)->status_shown \ 289050027b5bSmrg ? (expr) + StatusLineRows \ 289150027b5bSmrg : (expr) ) 289250027b5bSmrg#define if_STATUS_LINE(screen,stmt) \ 289350027b5bSmrg if (IsStatusShown(screen) && (screen)->status_active) stmt 289450027b5bSmrg 289550027b5bSmrg Boolean status_timeout; /* status timeout needs service */ 2896d1603babSmrg int status_active; /* DECSASD */ 289750027b5bSmrg int status_type; /* DECSSDT */ 289850027b5bSmrg int status_shown; /* last-displayed type */ 2899d1603babSmrg SavedCursor status_data[2]; /* main- and status-cursors */ 290050027b5bSmrg char * status_fmt; /* format for indicator-status */ 290150027b5bSmrg 290250027b5bSmrg#else /* !OPT_STATUS_LINE */ 290350027b5bSmrg 290450027b5bSmrg#define AddStatusLineRows(nrow) /* nothing */ 290550027b5bSmrg#define LastRowNumber(screen) (screen)->max_row 290650027b5bSmrg#define FirstRowNumber(screen) 0 2907d1603babSmrg#define IsStatusShown(screen) False 290850027b5bSmrg#define PlusStatusLine(screen,expr) (expr) 290950027b5bSmrg#define if_STATUS_LINE(screen,stmt) /* nothing */ 291050027b5bSmrg 291150027b5bSmrg#endif /* OPT_STATUS_LINE */ 291250027b5bSmrg 2913d522f475Smrg#if OPT_VT52_MODE 2914d4fba8b9Smrg IFlags vt52_save_flags; 29150d92cbfdSchristos Char vt52_save_curgl; 29160d92cbfdSchristos Char vt52_save_curgr; 29170d92cbfdSchristos Char vt52_save_curss; 2918980988aeSmrg DECNRCM_codes vt52_save_gsets[NUM_GSETS2]; 2919d522f475Smrg#endif 2920d522f475Smrg /* Testing */ 2921d522f475Smrg#if OPT_XMC_GLITCH 2922d522f475Smrg unsigned xmc_glitch; /* # of spaces to pad on SGR's */ 29239a64e1c5Smrg IAttr xmc_attributes; /* attrs that make a glitch */ 2924d522f475Smrg Boolean xmc_inline; /* SGR's propagate only to eol */ 2925d522f475Smrg Boolean move_sgr_ok; /* SGR is reset on move */ 2926d522f475Smrg#endif 2927d522f475Smrg 2928d522f475Smrg /* 2929d522f475Smrg * Bell 2930d522f475Smrg */ 2931d522f475Smrg int visualBellDelay; /* msecs to delay for visibleBell */ 2932d522f475Smrg int bellSuppressTime; /* msecs after Bell before another allowed */ 2933d522f475Smrg Boolean bellInProgress; /* still ringing/flashing prev bell? */ 2934d522f475Smrg Boolean bellIsUrgent; /* set XUrgency WM hint on bell */ 29353367019cSmrg Boolean flash_line; /* show visualBell as current line */ 2936d522f475Smrg /* 2937d522f475Smrg * Select/paste state. 2938d522f475Smrg */ 2939d522f475Smrg Boolean selectToClipboard; /* primary vs clipboard */ 2940d522f475Smrg String *mappedSelect; /* mapping for "SELECT" to "PRIMARY" */ 2941d522f475Smrg 2942d522f475Smrg Boolean waitingForTrackInfo; 2943d522f475Smrg int numberOfClicks; 2944d522f475Smrg int maxClicks; 2945d522f475Smrg int multiClickTime; /* time between multiclick selects */ 2946d522f475Smrg SelectUnit selectUnit; 2947d522f475Smrg SelectUnit selectMap[NSELECTUNITS]; 2948d522f475Smrg String onClick[NSELECTUNITS + 1]; 2949d522f475Smrg 2950d522f475Smrg char *charClass; /* for overriding word selection */ 2951d522f475Smrg Boolean cutNewline; /* whether or not line cut has \n */ 2952d522f475Smrg Boolean cutToBeginningOfLine; /* line cuts to BOL? */ 2953d522f475Smrg Boolean highlight_selection; /* controls appearance of selection */ 2954cb4a1343Smrg Boolean show_wrap_marks; /* show lines which are wrapped */ 2955d522f475Smrg Boolean trim_selection; /* controls trimming of selection */ 2956d522f475Smrg Boolean i18nSelections; 2957d522f475Smrg Boolean brokenSelections; 2958037a25ddSmrg Boolean keepClipboard; /* retain data sent to clipboard */ 2959d522f475Smrg Boolean keepSelection; /* do not lose selection on output */ 2960d522f475Smrg Boolean replyToEmacs; /* Send emacs escape code when done selecting or extending? */ 2961d4fba8b9Smrg 2962d4fba8b9Smrg SelectedCells clipboard_data; /* what we sent to the clipboard */ 2963d4fba8b9Smrg 2964d522f475Smrg EventMode eventMode; 2965d522f475Smrg Time selection_time; /* latest event timestamp */ 2966d522f475Smrg Time lastButtonUpTime; 2967d522f475Smrg unsigned lastButton; 2968d522f475Smrg 2969d4fba8b9Smrg#define MAX_CUT_BUFFER 8 /* CUT_BUFFER0 to CUT_BUFFER7 */ 2970d4fba8b9Smrg#define MAX_SELECTIONS (MAX_SELECTION_CODES + MAX_CUT_BUFFER) 2971d4fba8b9Smrg SelectedCells selected_cells[MAX_SELECTIONS]; 2972d4fba8b9Smrg 2973d522f475Smrg CELL rawPos; /* raw position for selection start */ 2974d522f475Smrg CELL startRaw; /* area before selectUnit processing */ 2975d522f475Smrg CELL endRaw; /* " " */ 2976d522f475Smrg CELL startSel; /* area after selectUnit processing */ 2977d522f475Smrg CELL endSel; /* " " */ 2978d522f475Smrg CELL startH; /* start highlighted text */ 2979d522f475Smrg CELL endH; /* end highlighted text */ 2980d522f475Smrg CELL saveStartW; /* saved WORD state, for LINE */ 2981d522f475Smrg CELL startExt; /* Start, end of extension */ 2982d522f475Smrg CELL endExt; /* " " */ 2983d522f475Smrg CELL saveStartR; /* Saved values of raw selection for extend to restore to */ 2984d522f475Smrg CELL saveEndR; /* " " */ 2985d522f475Smrg int startHCoord, endHCoord; 2986d522f475Smrg int firstValidRow; /* Valid rows for selection clipping */ 2987d522f475Smrg int lastValidRow; /* " " */ 2988d522f475Smrg 2989190d7dceSmrg#if OPT_BLOCK_SELECT 2990190d7dceSmrg int lastSelectWasBlock; 2991190d7dceSmrg int blockSelecting; /* non-zero if block selection */ 2992190d7dceSmrg#endif 2993190d7dceSmrg 29943367019cSmrg Boolean selectToBuffer; /* copy selection to buffer */ 299594644356Smrg InternalSelect internal_select; 29963367019cSmrg 2997b7c89284Ssnj String default_string; 2998b7c89284Ssnj String eightbit_select_types; 2999b7c89284Ssnj Atom* selection_targets_8bit; 3000b7c89284Ssnj#if OPT_WIDE_CHARS 3001b7c89284Ssnj String utf8_select_types; 3002b7c89284Ssnj Atom* selection_targets_utf8; 3003b7c89284Ssnj#endif 3004d522f475Smrg Atom* selection_atoms; /* which selections we own */ 30053367019cSmrg Cardinal sel_atoms_size; /* how many atoms allocated */ 3006d522f475Smrg Cardinal selection_count; /* how many atoms in use */ 3007d522f475Smrg#if OPT_SELECT_REGEX 3008d522f475Smrg char * selectExpr[NSELECTUNITS]; 3009d522f475Smrg#endif 3010d522f475Smrg /* 3011d522f475Smrg * Input/output state. 3012d522f475Smrg */ 30133367019cSmrg Boolean input_eight_bits; /* do not send ESC when meta pressed */ 30143367019cSmrg int eight_bit_meta; /* use 8th bit when meta pressed */ 30153367019cSmrg char * eight_bit_meta_s; /* ...resource eightBitMeta */ 30163367019cSmrg Boolean output_eight_bits; /* honor all bits or strip */ 30173367019cSmrg Boolean control_eight_bits; /* send CSI as 8-bits */ 3018d522f475Smrg Boolean backarrow_key; /* backspace/delete */ 3019d522f475Smrg Boolean alt_is_not_meta; /* use both Alt- and Meta-key */ 3020d522f475Smrg Boolean alt_sends_esc; /* Alt-key sends ESC prefix */ 3021d522f475Smrg Boolean meta_sends_esc; /* Meta-key sends ESC prefix */ 3022d522f475Smrg /* 3023d522f475Smrg * Fonts 3024d522f475Smrg */ 3025d522f475Smrg Pixmap menu_item_bitmap; /* mask for checking items */ 3026d522f475Smrg String initial_font; 3027dfb07bc7Smrg char * menu_font_names[NMENUFONTS][fMAX]; 3028d522f475Smrg#define MenuFontName(n) menu_font_names[n][fNorm] 302994644356Smrg#define EscapeFontName() MenuFontName(fontMenu_fontescape) 303094644356Smrg#define SelectFontName() MenuFontName(fontMenu_fontsel) 3031d522f475Smrg long menu_font_sizes[NMENUFONTS]; 3032d522f475Smrg int menu_font_number; 30333367019cSmrg#if OPT_LOAD_VTFONTS || OPT_WIDE_CHARS 3034712a7ff4Smrg Boolean savedVTFonts; 3035712a7ff4Smrg Boolean mergedVTFonts; 3036712a7ff4Smrg SubResourceRec cacheVTFonts; 3037712a7ff4Smrg#endif 3038d522f475Smrg#if OPT_CLIP_BOLD 3039d4fba8b9Smrg Boolean use_border_clipping; 3040d522f475Smrg Boolean use_clipping; 3041d522f475Smrg#endif 3042d522f475Smrg void * main_cgs_cache; 3043d522f475Smrg#ifndef NO_ACTIVE_ICON 3044d522f475Smrg void * icon_cgs_cache; 3045d522f475Smrg#endif 3046d522f475Smrg#if OPT_RENDERFONT 3047d1603babSmrg int xft_max_glyph_memory; 3048d1603babSmrg int xft_max_unref_fonts; 3049d1603babSmrg Boolean xft_track_mem_usage; 3050d4fba8b9Smrg Boolean force_xft_height; 3051d4fba8b9Smrg ListXftFonts *list_xft_fonts; 3052b7c89284Ssnj XTermXftFonts renderFontNorm[NMENUFONTS]; 3053b7c89284Ssnj XTermXftFonts renderFontBold[NMENUFONTS]; 3054d1603babSmrg#if OPT_WIDE_ATTRS || OPT_RENDERWIDE 3055b7c89284Ssnj XTermXftFonts renderFontItal[NMENUFONTS]; 3056d4fba8b9Smrg XTermXftFonts renderFontBtal[NMENUFONTS]; 3057d1603babSmrg#endif 3058b7c89284Ssnj#if OPT_RENDERWIDE 3059b7c89284Ssnj XTermXftFonts renderWideNorm[NMENUFONTS]; 3060b7c89284Ssnj XTermXftFonts renderWideBold[NMENUFONTS]; 3061b7c89284Ssnj XTermXftFonts renderWideItal[NMENUFONTS]; 3062d4fba8b9Smrg XTermXftFonts renderWideBtal[NMENUFONTS]; 3063b7c89284Ssnj TypedBuffer(XftCharSpec); 3064b7c89284Ssnj#else 3065b7c89284Ssnj TypedBuffer(XftChar8); 3066b7c89284Ssnj#endif 3067d522f475Smrg XftDraw * renderDraw; 3068d522f475Smrg#endif 3069d522f475Smrg#if OPT_DABBREV 3070b7c89284Ssnj Boolean dabbrev_working; /* nonzero during dabbrev process */ 3071d522f475Smrg unsigned char dabbrev_erase_char; /* used for deleting inserted completion */ 3072d522f475Smrg#endif 3073d522f475Smrg char tcapbuf[TERMCAP_SIZE]; 3074712a7ff4Smrg char tcap_area[TERMCAP_SIZE]; 3075d522f475Smrg#if OPT_TCAP_FKEYS 3076d522f475Smrg char ** tcap_fkeys; 3077d522f475Smrg#endif 3078d4fba8b9Smrg String cursor_font_name; /* alternate cursor font */ 3079d522f475Smrg} TScreen; 3080d522f475Smrg 3081d4fba8b9Smrgtypedef XTermFonts *(*MyGetFont) (TScreen *, int); 3082d4fba8b9Smrg 3083d522f475Smrgtypedef struct _TekPart { 3084d522f475Smrg XFontStruct * Tfont[TEKNUMFONTS]; 3085d522f475Smrg int tobaseline[TEKNUMFONTS]; /* top-baseline, each font */ 3086d522f475Smrg char * initial_font; /* large, 2, 3, small */ 3087d522f475Smrg char * gin_terminator_str; /* ginTerminator resource */ 3088d522f475Smrg#if OPT_TOOLBAR 3089d522f475Smrg TbInfo tb_info; /* toolbar information */ 3090d522f475Smrg#endif 3091d522f475Smrg} TekPart; 3092d522f475Smrg 3093d522f475Smrg/* Tektronix window parameters */ 3094d522f475Smrgtypedef struct _TekScreen { 3095d522f475Smrg GC TnormalGC; /* normal painting */ 3096d522f475Smrg GC TcursorGC; /* normal cursor painting */ 3097d522f475Smrg 3098d522f475Smrg Boolean waitrefresh; /* postpone refresh */ 3099d522f475Smrg TKwin fullTwin; 3100d522f475Smrg#ifndef NO_ACTIVE_ICON 3101d522f475Smrg TKwin iconTwin; 3102d522f475Smrg TKwin *whichTwin; 3103d522f475Smrg#endif /* NO_ACTIVE_ICON */ 3104d522f475Smrg 3105d522f475Smrg Cursor arrow; /* arrow cursor */ 3106d522f475Smrg GC linepat[TEKNUMLINES]; /* line patterns */ 3107d522f475Smrg int cur_X; /* current x */ 3108d522f475Smrg int cur_Y; /* current y */ 3109d522f475Smrg Tmodes cur; /* current tek modes */ 3110d522f475Smrg Tmodes page; /* starting tek modes on page */ 3111d522f475Smrg int margin; /* 0 -> margin 1, 1 -> margin 2 */ 3112d522f475Smrg int pen; /* current Tektronix pen 0=up, 1=dn */ 3113d522f475Smrg char *TekGIN; /* nonzero if Tektronix GIN mode*/ 3114d522f475Smrg int gin_terminator; /* Tek strap option */ 3115d522f475Smrg char tcapbuf[TERMCAP_SIZE]; 3116d522f475Smrg} TekScreen; 3117d522f475Smrg 3118d4fba8b9Smrg#if OPT_PASTE64 || OPT_READLINE 3119d522f475Smrg#define SCREEN_FLAG(screenp,f) (1&(screenp)->f) 3120d522f475Smrg#define SCREEN_FLAG_set(screenp,f) ((screenp)->f |= 1) 3121cd3331d0Smrg#define SCREEN_FLAG_unset(screenp,f) ((screenp)->f &= (unsigned) ~1L) 3122d522f475Smrg#define SCREEN_FLAG_save(screenp,f) \ 3123d522f475Smrg ((screenp)->f = (((screenp)->f)<<1) | SCREEN_FLAG(screenp,f)) 3124d522f475Smrg#define SCREEN_FLAG_restore(screenp,f) ((screenp)->f = (((screenp)->f)>>1)) 3125d522f475Smrg#else 3126d522f475Smrg#define SCREEN_FLAG(screenp,f) (0) 3127d522f475Smrg#endif 3128d522f475Smrg 31293367019cSmrg/* 31303367019cSmrg * After screen-updates, reset the flag that tells us we should do wrapping. 31313367019cSmrg * Likewise, reset (in wide-character mode) the flag that tells us where the 31323367019cSmrg * "previous" character was written. 31333367019cSmrg */ 31343367019cSmrg#if OPT_WIDE_CHARS 31353367019cSmrg#define ResetWrap(screen) \ 31363367019cSmrg (screen)->do_wrap = \ 31373367019cSmrg (screen)->char_was_written = False 31383367019cSmrg#else 31393367019cSmrg#define ResetWrap(screen) \ 31403367019cSmrg (screen)->do_wrap = False 31413367019cSmrg#endif 31423367019cSmrg 3143d522f475Smrg/* meaning of bits in screen.select flag */ 3144d522f475Smrg#define INWINDOW 01 /* the mouse is in one of the windows */ 3145d522f475Smrg#define FOCUS 02 /* one of the windows is the focus window */ 3146d522f475Smrg 3147d522f475Smrg#define MULTICLICKTIME 250 /* milliseconds */ 3148d522f475Smrg 3149c219fbebSmrgtypedef struct { 3150c219fbebSmrg const char *name; 3151c219fbebSmrg int code; 3152c219fbebSmrg} FlagList; 3153c219fbebSmrg 3154d522f475Smrgtypedef enum { 3155d522f475Smrg keyboardIsLegacy, /* bogus vt220 codes for F1-F4, etc. */ 3156d522f475Smrg keyboardIsDefault, 3157d522f475Smrg keyboardIsHP, 3158d522f475Smrg keyboardIsSCO, 3159d522f475Smrg keyboardIsSun, 3160d522f475Smrg keyboardIsTermcap, 3161d522f475Smrg keyboardIsVT220 3162d522f475Smrg} xtermKeyboardType; 3163d522f475Smrg 3164d522f475Smrgtypedef enum { /* legal values for screen.pointer_mode */ 31653367019cSmrg pNever = 0 31663367019cSmrg , pNoMouse = 1 31673367019cSmrg , pAlways = 2 31683367019cSmrg , pFocused = 3 3169d522f475Smrg} pointerModeTypes; 3170d522f475Smrg 3171d522f475Smrgtypedef enum { /* legal values for screen.utf8_mode */ 3172712a7ff4Smrg uFalse = 0 3173712a7ff4Smrg , uTrue = 1 3174712a7ff4Smrg , uAlways = 2 3175712a7ff4Smrg , uDefault = 3 3176712a7ff4Smrg , uLast 3177d522f475Smrg} utf8ModeTypes; 3178d522f475Smrg 31793367019cSmrgtypedef enum { /* legal values for screen.eight_bit_meta */ 31803367019cSmrg ebFalse = 0 31813367019cSmrg , ebTrue = 1 31823367019cSmrg , ebNever = 2 31833367019cSmrg , ebLocale = 3 31843367019cSmrg , ebLast 31853367019cSmrg} ebMetaModeTypes; 31863367019cSmrg 3187c48a5815Smrgtypedef enum { /* legal values for misc.cdXtraScroll */ 3188c48a5815Smrg edFalse = 0 3189c48a5815Smrg , edTrue = 1 3190c48a5815Smrg , edTrim = 2 3191c48a5815Smrg , edLast 3192c48a5815Smrg} edXtraScrollTypes; 3193c48a5815Smrg 3194037a25ddSmrg#define NAME_OLD_KT " legacy" 3195037a25ddSmrg 3196d522f475Smrg#if OPT_HP_FUNC_KEYS 3197d522f475Smrg#define NAME_HP_KT " hp" 3198d522f475Smrg#else 3199d522f475Smrg#define NAME_HP_KT /*nothing*/ 3200d522f475Smrg#endif 3201d522f475Smrg 3202d522f475Smrg#if OPT_SCO_FUNC_KEYS 3203d522f475Smrg#define NAME_SCO_KT " sco" 3204d522f475Smrg#else 3205d522f475Smrg#define NAME_SCO_KT /*nothing*/ 3206d522f475Smrg#endif 3207d522f475Smrg 3208d522f475Smrg#if OPT_SUN_FUNC_KEYS 3209d522f475Smrg#define NAME_SUN_KT " sun" 3210d522f475Smrg#else 3211d522f475Smrg#define NAME_SUN_KT /*nothing*/ 3212d522f475Smrg#endif 3213d522f475Smrg 3214d522f475Smrg#if OPT_SUNPC_KBD 3215d522f475Smrg#define NAME_VT220_KT " vt220" 3216d522f475Smrg#else 3217d522f475Smrg#define NAME_VT220_KT /*nothing*/ 3218d522f475Smrg#endif 3219d522f475Smrg 3220d522f475Smrg#if OPT_TCAP_FKEYS 3221d522f475Smrg#define NAME_TCAP_KT " tcap" 3222d522f475Smrg#else 3223d522f475Smrg#define NAME_TCAP_KT /*nothing*/ 3224d522f475Smrg#endif 3225d522f475Smrg 3226d522f475Smrg#define KEYBOARD_TYPES NAME_TCAP_KT NAME_HP_KT NAME_SCO_KT NAME_SUN_KT NAME_VT220_KT 3227d522f475Smrg 3228cd3331d0Smrg#if OPT_TRACE 3229cd3331d0Smrg#define TRACE_RC(code,func) code = func 3230cd3331d0Smrg#else 3231cd3331d0Smrg#define TRACE_RC(code,func) func 3232cd3331d0Smrg#endif 3233cd3331d0Smrg 3234d522f475Smrgextern const char * visibleKeyboardType(xtermKeyboardType); 3235d522f475Smrg 3236d522f475Smrgtypedef struct 3237d522f475Smrg{ 32383367019cSmrg int allow_keys; /* how to handle legacy/vt220 keyboard */ 3239d522f475Smrg int cursor_keys; /* how to handle cursor-key modifiers */ 3240d522f475Smrg int function_keys; /* how to handle function-key modifiers */ 3241d522f475Smrg int keypad_keys; /* how to handle keypad key-modifiers */ 3242d522f475Smrg int other_keys; /* how to handle other key-modifiers */ 3243d522f475Smrg int string_keys; /* how to handle string() modifiers */ 3244d522f475Smrg} TModify; 3245d522f475Smrg 3246d522f475Smrgtypedef struct 3247d522f475Smrg{ 3248d522f475Smrg xtermKeyboardType type; 32499a64e1c5Smrg IFlags flags; 3250d4fba8b9Smrg char *shell_translations; /* shell's translations, for input check */ 3251d4fba8b9Smrg char *xterm_translations; /* xterm's translations, for input check */ 3252d522f475Smrg char *extra_translations; 3253d4fba8b9Smrg char *print_translations; /* printable translations for buttons */ 3254d4fba8b9Smrg unsigned shift_buttons; /* special shift-modifier for mouse-buttons */ 3255d4fba8b9Smrg int shift_escape; /* working value of shiftEscape */ 3256d4fba8b9Smrg char * shift_escape_s; /* resource for shiftEscape */ 3257d522f475Smrg#if OPT_INITIAL_ERASE 3258d522f475Smrg int reset_DECBKM; /* reset should set DECBKM */ 3259d522f475Smrg#endif 3260d522f475Smrg#if OPT_MOD_FKEYS 3261d522f475Smrg TModify modify_now; /* current modifier value */ 3262d522f475Smrg TModify modify_1st; /* original modifier value, for resets */ 3263d522f475Smrg int format_keys; /* format of modifyOtherKeys */ 3264d522f475Smrg#endif 3265d522f475Smrg} TKeyboard; 3266d522f475Smrg 3267b7c89284Ssnj#define GravityIsNorthWest(w) ((w)->misc.resizeGravity == NorthWestGravity) 3268b7c89284Ssnj#define GravityIsSouthWest(w) ((w)->misc.resizeGravity == SouthWestGravity) 3269b7c89284Ssnj 3270d522f475Smrgtypedef struct _Misc { 3271d522f475Smrg VTFontNames default_font; 3272d522f475Smrg char *geo_metry; 3273d522f475Smrg char *T_geometry; 3274d522f475Smrg#if OPT_WIDE_CHARS 3275d522f475Smrg Boolean cjk_width; /* true for built-in CJK wcwidth() */ 3276d522f475Smrg Boolean mk_width; /* true for simpler built-in wcwidth() */ 3277d522f475Smrg int mk_samplesize; 3278d522f475Smrg int mk_samplepass; 3279d522f475Smrg#endif 3280d522f475Smrg#if OPT_LUIT_PROG 3281d522f475Smrg Boolean callfilter; /* true to invoke luit */ 3282d522f475Smrg Boolean use_encoding; /* true to use -encoding option for luit */ 3283d522f475Smrg char *locale_str; /* "locale" resource */ 3284d522f475Smrg char *localefilter; /* path for luit */ 3285d522f475Smrg#endif 3286b7c89284Ssnj fontWarningTypes fontWarnings; 3287d522f475Smrg int limit_resize; 3288d522f475Smrg#ifdef ALLOWLOGGING 3289d522f475Smrg Boolean log_on; 3290d522f475Smrg#endif 3291d4fba8b9Smrg Boolean color_inner_border; 3292d522f475Smrg Boolean login_shell; 3293d522f475Smrg Boolean re_verse; 3294d522f475Smrg Boolean re_verse0; /* initial value of "-rv" */ 32958f44fb3bSmrg Boolean resizeByPixel; 3296d522f475Smrg XtGravity resizeGravity; 3297d522f475Smrg Boolean reverseWrap; 3298d522f475Smrg Boolean autoWrap; 3299d522f475Smrg Boolean logInhibit; 3300d522f475Smrg Boolean signalInhibit; 3301d522f475Smrg#if OPT_TEK4014 3302d522f475Smrg Boolean tekInhibit; 3303d522f475Smrg Boolean tekSmall; /* start tek window in small size */ 3304d522f475Smrg Boolean TekEmu; /* true if Tektronix emulation */ 3305d522f475Smrg Boolean Tshow; /* Tek window showing */ 3306d522f475Smrg#endif 3307d522f475Smrg Boolean scrollbar; 3308d522f475Smrg#ifdef SCROLLBAR_RIGHT 3309d522f475Smrg Boolean useRight; 3310d522f475Smrg#endif 3311d522f475Smrg Boolean titeInhibit; 3312d522f475Smrg Boolean appcursorDefault; 3313d522f475Smrg Boolean appkeypadDefault; 3314c48a5815Smrg int cdXtraScroll; /* scroll on cd (clear-display) */ 3315c48a5815Smrg char *cdXtraScroll_s; 3316c48a5815Smrg int tiXtraScroll; /* scroll on ti/te (init/end-cup) */ 3317c48a5815Smrg char *tiXtraScroll_s; 3318d522f475Smrg#if OPT_INPUT_METHOD 3319b7c89284Ssnj char* f_x; /* font for XIM */ 3320d522f475Smrg char* input_method; 3321d522f475Smrg char* preedit_type; 3322b7c89284Ssnj Boolean open_im; /* true if input-method is opened */ 3323b7c89284Ssnj int retry_im; 3324d522f475Smrg#endif 3325d522f475Smrg Boolean dynamicColors; 3326d522f475Smrg#ifndef NO_ACTIVE_ICON 33273367019cSmrg char *active_icon_s; /* use application icon window */ 3328d522f475Smrg unsigned icon_border_width; 3329d522f475Smrg Pixel icon_border_pixel; 3330d522f475Smrg#endif /* NO_ACTIVE_ICON */ 3331d522f475Smrg#if OPT_DEC_SOFTFONT 3332d522f475Smrg Boolean font_loadable; 3333d522f475Smrg#endif 3334d522f475Smrg#if OPT_SHIFT_FONTS 3335d522f475Smrg Boolean shift_fonts; /* true if we interpret fontsize-shifting */ 3336d522f475Smrg#endif 3337d522f475Smrg#if OPT_SUNPC_KBD 3338d522f475Smrg int ctrl_fkeys; /* amount to add to XK_F1 for ctrl modifier */ 3339d522f475Smrg#endif 3340d522f475Smrg#if OPT_NUM_LOCK 3341d522f475Smrg Boolean real_NumLock; /* true if we treat NumLock key specially */ 3342d522f475Smrg Boolean alwaysUseMods; /* true if we always want f-key modifiers */ 3343d522f475Smrg#endif 3344d522f475Smrg#if OPT_RENDERFONT 3345dfb07bc7Smrg VTFontNames default_xft; 3346d522f475Smrg float face_size[NMENUFONTS]; 3347cd3331d0Smrg char *render_font_s; 3348d4fba8b9Smrg int limit_fontsets; 3349d1603babSmrg int limit_fontheight; 3350d1603babSmrg int limit_fontwidth; 3351d522f475Smrg#endif 3352d522f475Smrg} Misc; 3353d522f475Smrg 33543367019cSmrgtypedef struct _Work { 33553367019cSmrg int dummy; 33569a64e1c5Smrg#ifdef SunXK_F36 33579a64e1c5Smrg#define MAX_UDK 37 33589a64e1c5Smrg#else 33599a64e1c5Smrg#define MAX_UDK 35 33609a64e1c5Smrg#endif 33619a64e1c5Smrg struct { 33629a64e1c5Smrg char *str; 33639a64e1c5Smrg int len; 33649a64e1c5Smrg } user_keys[MAX_UDK]; 33658f44fb3bSmrg#define MAX_POINTER (XC_num_glyphs/2) 33668f44fb3bSmrg Cursor pointer_cursors[MAX_POINTER]; /* saved cursors */ 33673367019cSmrg#ifndef NO_ACTIVE_ICON 33683367019cSmrg int active_icon; /* use application icon window */ 3369d4fba8b9Smrg char *wm_name; 33703367019cSmrg#endif /* NO_ACTIVE_ICON */ 3371dfb07bc7Smrg#if OPT_INPUT_METHOD 3372dfb07bc7Smrg Boolean cannot_im; /* true if we cannot use input-method */ 3373dfb07bc7Smrg XFontSet xim_fs; /* fontset for XIM preedit */ 3374dfb07bc7Smrg int xim_fs_ascent; /* ascent of fs */ 3375dfb07bc7Smrg TInput inputs[NINPUTWIDGETS]; 3376dfb07bc7Smrg#endif 3377d4fba8b9Smrg Boolean doing_resize; /* currently in RequestResize */ 33783367019cSmrg#if OPT_MAXIMIZE 33793367019cSmrg#define MAX_EWMH_MODE 3 33803367019cSmrg#define MAX_EWMH_DATA (1 + OPT_TEK4014) 33813367019cSmrg struct { 33823367019cSmrg int mode; /* fullscreen, etc. */ 3383d4fba8b9Smrg Boolean checked[MAX_EWMH_MODE + 1]; 3384d4fba8b9Smrg Boolean allowed[MAX_EWMH_MODE + 1]; 33853367019cSmrg } ewmh[MAX_EWMH_DATA]; 33863367019cSmrg#endif 33873367019cSmrg#if OPT_NUM_LOCK 33883367019cSmrg unsigned num_lock; /* modifier for Num_Lock */ 33893367019cSmrg unsigned alt_mods; /* modifier for Alt_L or Alt_R */ 33903367019cSmrg unsigned meta_mods; /* modifier for Meta_L or Meta_R */ 33913367019cSmrg#endif 3392dfb07bc7Smrg XtermFontNames fonts; 3393c48a5815Smrg Boolean force_wideFont; /* true to single-step wideFont */ 33943367019cSmrg#if OPT_RENDERFONT 33953367019cSmrg Boolean render_font; 3396d1603babSmrg FcPattern *xft_defaults; 3397d4fba8b9Smrg unsigned max_fontsets; 33983367019cSmrg#endif 33999a64e1c5Smrg#if OPT_DABBREV 34009a64e1c5Smrg#define MAX_DABBREV 1024 /* maximum word length as in tcsh */ 34019a64e1c5Smrg char dabbrev_data[MAX_DABBREV]; 34029a64e1c5Smrg#endif 34039a64e1c5Smrg ScrnColors *oldColors; 3404dfb07bc7Smrg Boolean palette_changed; 3405d4fba8b9Smrg Boolean broken_box_chars; 3406980988aeSmrg /* data write dotext/WriteText */ 3407980988aeSmrg IChar *write_text; /* points to print_area */ 3408980988aeSmrg#if OPT_DEC_RECTOPS 3409980988aeSmrg Char *write_sums; /* if non-null, points to buffer_sums */ 3410980988aeSmrg Char *buffer_sums; /* data for ->charSeen[] */ 3411980988aeSmrg Char *buffer_sets; /* data for ->charSets[] */ 3412980988aeSmrg size_t sizeof_sums; /* allocated size of buffer_sums */ 3413980988aeSmrg#endif 34143367019cSmrg} Work; 34153367019cSmrg 3416d522f475Smrgtypedef struct {int foo;} XtermClassPart, TekClassPart; 3417d522f475Smrg 3418d522f475Smrgtypedef struct _XtermClassRec { 3419d522f475Smrg CoreClassPart core_class; 3420d522f475Smrg XtermClassPart xterm_class; 3421d522f475Smrg} XtermClassRec; 3422d522f475Smrg 3423d522f475Smrgextern WidgetClass xtermWidgetClass; 3424d522f475Smrg 3425d522f475Smrg#define IsXtermWidget(w) (XtClass(w) == xtermWidgetClass) 3426d522f475Smrg 3427d522f475Smrg#if OPT_TEK4014 3428d522f475Smrgtypedef struct _TekClassRec { 3429d522f475Smrg CoreClassPart core_class; 3430d522f475Smrg TekClassPart tek_class; 3431d522f475Smrg} TekClassRec; 3432d522f475Smrg 3433d522f475Smrgextern WidgetClass tekWidgetClass; 3434d522f475Smrg 3435d522f475Smrg#define IsTekWidget(w) (XtClass(w) == tekWidgetClass) 3436d522f475Smrg 3437d522f475Smrg#endif 3438d522f475Smrg 3439d522f475Smrg/* define masks for keyboard.flags */ 3440fa3f02f3Smrg#define MODE_KAM xBIT(0) /* mode 2: keyboard action mode */ 3441d522f475Smrg#define MODE_DECKPAM xBIT(1) /* keypad application mode */ 3442fa3f02f3Smrg#define MODE_DECCKM xBIT(2) /* private mode 1: cursor keys */ 3443fa3f02f3Smrg#define MODE_SRM xBIT(3) /* mode 12: send-receive mode */ 3444fa3f02f3Smrg#define MODE_DECBKM xBIT(4) /* private mode 67: backarrow */ 3445d1603babSmrg#define MODE_DECSDM xBIT(5) /* private mode 80: sixel DISPLAY mode -- note, when SDM is off, the terminal is in sixel SCROLLING mode */ 3446d522f475Smrg 3447d522f475Smrg#define N_MARGINBELL 10 3448d522f475Smrg 3449d522f475Smrg#define TAB_BITS_SHIFT 5 /* FIXME: 2**5 == 32 (should derive) */ 3450d522f475Smrg#define TAB_BITS_WIDTH (1 << TAB_BITS_SHIFT) 3451d522f475Smrg#define TAB_ARRAY_SIZE (1024 / TAB_BITS_WIDTH) 3452d522f475Smrg#define MAX_TABS (TAB_BITS_WIDTH * TAB_ARRAY_SIZE) 3453d522f475Smrg 3454980988aeSmrg#define OkTAB(c) ((c) > 0 && (c) < MAX_TABS) 3455d4fba8b9Smrg 3456d522f475Smrgtypedef unsigned Tabs [TAB_ARRAY_SIZE]; 3457d522f475Smrg 3458d4fba8b9Smrg#if OPT_XTERM_SGR 3459d4fba8b9Smrg#define MAX_SAVED_SGR 10 3460d4fba8b9Smrgtypedef struct { 3461d4fba8b9Smrg int used; 3462d4fba8b9Smrg struct { 3463d4fba8b9Smrg IFlags mask; 3464d4fba8b9Smrg IFlags flags; 3465d4fba8b9Smrg#if OPT_ISO_COLORS 3466d4fba8b9Smrg int sgr_foreground; 3467d4fba8b9Smrg int sgr_background; 3468d4fba8b9Smrg Boolean sgr_38_xcolors; 3469d4fba8b9Smrg#endif 3470d4fba8b9Smrg } stack[MAX_SAVED_SGR]; 3471d4fba8b9Smrg} SavedSGR; 3472d4fba8b9Smrg 3473d4fba8b9Smrgtypedef struct { 3474d4fba8b9Smrg ScrnColors base; 3475d4fba8b9Smrg ColorRes ansi[1]; 3476d4fba8b9Smrg} ColorSlot; 3477d4fba8b9Smrg 3478d4fba8b9Smrgtypedef struct { 3479d4fba8b9Smrg int used; /* currently saved or restored */ 3480d4fba8b9Smrg int last; /* maximum number of saved palettes */ 3481d4fba8b9Smrg ColorSlot *palettes[MAX_SAVED_SGR]; 3482d4fba8b9Smrg} SavedColors; 3483d4fba8b9Smrg#endif /* OPT_XTERM_SGR */ 3484d4fba8b9Smrg 3485d522f475Smrgtypedef struct _XtermWidgetRec { 3486d522f475Smrg CorePart core; 3487d522f475Smrg XSizeHints hints; 3488fa3f02f3Smrg XVisualInfo *visInfo; 3489fa3f02f3Smrg int numVisuals; 3490d4fba8b9Smrg unsigned rgb_shifts[3]; 3491d4fba8b9Smrg unsigned rgb_widths[3]; 3492d4fba8b9Smrg Bool has_rgb; 3493d522f475Smrg Bool init_menu; 3494d522f475Smrg TKeyboard keyboard; /* terminal keyboard */ 3495d522f475Smrg TScreen screen; /* terminal screen */ 34969a64e1c5Smrg IFlags flags; /* mode flags */ 3497d522f475Smrg int cur_foreground; /* current foreground color */ 3498d522f475Smrg int cur_background; /* current background color */ 3499d522f475Smrg Pixel dft_foreground; /* default foreground color */ 3500d522f475Smrg Pixel dft_background; /* default background color */ 3501712a7ff4Smrg Pixel old_foreground; /* original foreground color */ 3502712a7ff4Smrg Pixel old_background; /* original background color */ 3503d522f475Smrg#if OPT_ISO_COLORS 3504d522f475Smrg int sgr_foreground; /* current SGR foreground color */ 3505d522f475Smrg int sgr_background; /* current SGR background color */ 3506d4fba8b9Smrg Boolean sgr_38_xcolors; /* true if ISO 8613 extension */ 3507d522f475Smrg#endif 35089a64e1c5Smrg IFlags initflags; /* initial mode flags */ 3509d522f475Smrg Tabs tabs; /* tabstops of the terminal */ 3510d522f475Smrg Misc misc; /* miscellaneous parameters */ 35113367019cSmrg Work work; /* workspace (no resources) */ 3512d4fba8b9Smrg#if OPT_XTERM_SGR 3513d4fba8b9Smrg SavedSGR saved_sgr; 3514d4fba8b9Smrg SavedColors saved_colors; 3515d4fba8b9Smrg#endif 3516d522f475Smrg} XtermWidgetRec, *XtermWidget; 3517d522f475Smrg 3518d522f475Smrg#if OPT_TEK4014 3519d522f475Smrgtypedef struct _TekWidgetRec { 3520d522f475Smrg CorePart core; 3521dfb07bc7Smrg XtermWidget vt; /* main widget has border, etc. */ 3522d522f475Smrg TekPart tek; /* contains resources */ 3523d522f475Smrg TekScreen screen; /* contains working data (no resources) */ 3524d522f475Smrg Bool init_menu; 3525d522f475Smrg XSizeHints hints; 3526d522f475Smrg} TekWidgetRec, *TekWidget; 3527d522f475Smrg#endif /* OPT_TEK4014 */ 3528d522f475Smrg 3529d522f475Smrg/* 3530d522f475Smrg * terminal flags 353150027b5bSmrg * There are actually two namespaces mixed together here: 353250027b5bSmrg * a) One is the set of flags that can go in screen->visbuf attributes and 353350027b5bSmrg * which must fit in an IAttr (either a char or short, depending on whether 353450027b5bSmrg * wide-attributes are used). 353550027b5bSmrg * b) The other is the global setting stored in term->flags and 353650027b5bSmrg * screen->save_modes, which fits in an unsigned (IFlags). 3537d522f475Smrg */ 3538d522f475Smrg 3539d522f475Smrg#define AttrBIT(n) xBIT(n) /* text-attributes */ 3540d522f475Smrg#define MiscBIT(n) xBIT(n + 16) /* miscellaneous state flags */ 3541d522f475Smrg 3542d522f475Smrg/* global flags and character flags (visible character attributes) */ 3543d522f475Smrg#define INVERSE AttrBIT(0) /* invert the characters to be output */ 3544d522f475Smrg#define UNDERLINE AttrBIT(1) /* true if underlining */ 3545d522f475Smrg#define BOLD AttrBIT(2) 3546d522f475Smrg#define BLINK AttrBIT(3) 3547d522f475Smrg/* global flags (also character attributes) */ 3548d522f475Smrg#define BG_COLOR AttrBIT(4) /* true if background set */ 3549d522f475Smrg#define FG_COLOR AttrBIT(5) /* true if foreground set */ 3550d522f475Smrg 3551d522f475Smrg/* character flags (internal attributes) */ 3552d522f475Smrg#define PROTECTED AttrBIT(6) /* a character that cannot be erased */ 3553d522f475Smrg#define CHARDRAWN AttrBIT(7) /* a character has been drawn here on 3554d522f475Smrg the screen. Used to distinguish 3555d522f475Smrg blanks from empty parts of the 3556d522f475Smrg screen when selecting */ 3557980988aeSmrg/* 3558980988aeSmrg * This does not fit in a byte with the other (more important) attributes, but 3559980988aeSmrg * if wide-attributes are configured, it is possible to maintain it there. 3560980988aeSmrg */ 3561980988aeSmrg#define INVISIBLE AttrBIT(8) /* true if writing invisible text */ 3562d522f475Smrg 35639a64e1c5Smrg#if OPT_WIDE_ATTRS 3564980988aeSmrg#define ATR_FAINT AttrBIT(9) 3565980988aeSmrg#define ATR_ITALIC AttrBIT(10) 3566980988aeSmrg#define ATR_STRIKEOUT AttrBIT(11) 3567980988aeSmrg#define ATR_DBL_UNDER AttrBIT(12) 3568980988aeSmrg#define ATR_DIRECT_FG AttrBIT(13) 3569980988aeSmrg#define ATR_DIRECT_BG AttrBIT(14) 3570d4fba8b9Smrg#define SGR_MASK2 (ATR_FAINT | ATR_ITALIC | ATR_STRIKEOUT | ATR_DBL_UNDER | ATR_DIRECT_FG | ATR_DIRECT_BG) 3571980988aeSmrg#define AttrEND 15 35729a64e1c5Smrg#else 35739a64e1c5Smrg#define SGR_MASK2 0 3574980988aeSmrg#define AttrEND 9 35759a64e1c5Smrg#endif 3576d522f475Smrg 3577d522f475Smrg/* 3578d522f475Smrg * Other flags 3579d522f475Smrg */ 3580980988aeSmrg#define REVERSE_VIDEO MiscBIT(0) /* true if screen white on black */ 3581980988aeSmrg#define WRAPAROUND MiscBIT(1) /* true if auto wraparound mode */ 3582980988aeSmrg#define REVERSEWRAP MiscBIT(2) /* true if reverse wraparound mode */ 3583980988aeSmrg#define REVERSEWRAP2 MiscBIT(3) /* true if extended reverse wraparound */ 3584980988aeSmrg#define LINEFEED MiscBIT(4) /* true if in auto linefeed mode */ 3585980988aeSmrg#define ORIGIN MiscBIT(5) /* true if in origin mode */ 3586980988aeSmrg#define INSERT MiscBIT(6) /* true if in insert mode */ 3587980988aeSmrg#define SMOOTHSCROLL MiscBIT(7) /* true if in smooth scroll mode */ 3588980988aeSmrg#define IN132COLUMNS MiscBIT(8) /* true if in 132 column mode */ 3589d522f475Smrg#define NATIONAL MiscBIT(9) /* true if writing national charset */ 35903367019cSmrg#define LEFT_RIGHT MiscBIT(10) /* true if left/right margin mode */ 35913367019cSmrg#define NOCLEAR_COLM MiscBIT(11) /* true if no clear on DECCOLM change */ 3592d522f475Smrg 3593980988aeSmrg/* 3594980988aeSmrg * Drawing-bits start after the video/color attributes, and are independent 3595980988aeSmrg * of the miscellaneous flags. 3596980988aeSmrg */ 3597980988aeSmrg#define DrawBIT(n) xBIT(n + AttrEND) /* XTermDraw.draw_flags */ 35989a64e1c5Smrg/* The following attributes are used in the argument of drawXtermText() */ 35999a64e1c5Smrg#define NOBACKGROUND DrawBIT(0) /* Used for overstrike */ 36009a64e1c5Smrg#define NOTRANSLATION DrawBIT(1) /* No scan for chars missing in font */ 36019a64e1c5Smrg#define DOUBLEWFONT DrawBIT(2) /* The actual X-font is double-width */ 36029a64e1c5Smrg#define DOUBLEHFONT DrawBIT(3) /* The actual X-font is double-height */ 3603d1603babSmrg#define DOUBLEFIRST DrawBIT(4) /* Draw chars one-by-one */ 3604d1603babSmrg#define CHARBYCHAR DrawBIT(5) /* Draw chars one-by-one */ 36059a64e1c5Smrg 36069a64e1c5Smrg/* The following attribute is used in the argument of xtermSpecialFont etc */ 3607d1603babSmrg#define NORESOLUTION DrawBIT(6) /* find the font without resolution */ 36089a64e1c5Smrg 3609d522f475Smrg/* 3610d522f475Smrg * Groups of attributes 3611d522f475Smrg */ 3612d522f475Smrg /* mask for video-attributes only */ 3613d522f475Smrg#define SGR_MASK (BOLD | BLINK | UNDERLINE | INVERSE) 3614d522f475Smrg 3615d522f475Smrg /* mask: user-visible attributes */ 36169a64e1c5Smrg#define ATTRIBUTES (SGR_MASK | SGR_MASK2 | BG_COLOR | FG_COLOR | INVISIBLE | PROTECTED) 3617d522f475Smrg 3618d522f475Smrg/* The toplevel-call to drawXtermText() should have text-attributes guarded: */ 3619d522f475Smrg#define DRAWX_MASK (ATTRIBUTES | CHARDRAWN) 3620d522f475Smrg 3621712a7ff4Smrg/* 3622712a7ff4Smrg * BOLDATTR is not only nonzero when we will use bold font, but uses the bits 3623712a7ff4Smrg * for BOLD/BLINK to match against the video attributes which were originally 3624712a7ff4Smrg * requested. 3625712a7ff4Smrg */ 3626712a7ff4Smrg#define USE_BOLD(screen) ((screen)->allowBoldFonts) 3627712a7ff4Smrg 3628d522f475Smrg#if OPT_BLINK_TEXT 3629712a7ff4Smrg#define BOLDATTR(screen) (unsigned) (USE_BOLD(screen) ? (BOLD | ((screen)->blink_as_bold ? BLINK : 0)) : 0) 3630d522f475Smrg#else 3631712a7ff4Smrg#define BOLDATTR(screen) (unsigned) (USE_BOLD(screen) ? (BOLD | BLINK) : 0) 3632d522f475Smrg#endif 3633d522f475Smrg 3634c48a5815Smrg/* 3635d1603babSmrg * Sixel scrolling is on when Sixel Display Mode is off, and vice versa. 3636d1603babSmrg * (Note: DEC erroneously conflates the two in the VT330/340 manual). 3637c48a5815Smrg */ 3638c48a5815Smrg#define SixelScrolling(xw) (!((xw)->keyboard.flags & MODE_DECSDM)) 3639c48a5815Smrg 3640d522f475Smrg/* 3641d522f475Smrg * Per-line flags 3642d522f475Smrg */ 3643b7c89284Ssnj#define LINEWRAPPED AttrBIT(0) 3644b7c89284Ssnj/* used once per line to indicate that it wraps onto the next line so we can 3645b7c89284Ssnj * tell the difference between lines that have wrapped around and lines that 3646b7c89284Ssnj * have ended naturally with a CR at column max_col. 3647b7c89284Ssnj */ 3648b7c89284Ssnj#define LINEBLINKED AttrBIT(1) 3649b7c89284Ssnj/* set when the line contains blinking text. 3650b7c89284Ssnj */ 3651d522f475Smrg 3652d4fba8b9Smrg#if OPT_ZICONBEEP || OPT_TOOLBAR || (USE_DOUBLE_BUFFER && OPT_RENDERFONT) 3653d522f475Smrg#define HANDLE_STRUCT_NOTIFY 1 3654d522f475Smrg#else 3655d522f475Smrg#define HANDLE_STRUCT_NOTIFY 0 3656d522f475Smrg#endif 3657d522f475Smrg 3658d522f475Smrg/* 3659d522f475Smrg * If we've set protected attributes with the DEC-style DECSCA, then we'll have 3660d522f475Smrg * to use DECSED or DECSEL to erase preserving protected text. (The normal ED, 3661d522f475Smrg * EL won't preserve protected-text). If we've used SPA, then normal ED and EL 3662d522f475Smrg * will preserve protected-text. To keep things simple, just remember the last 3663d522f475Smrg * control that was used to begin protected-text, and use that to determine how 3664d522f475Smrg * erases are performed (otherwise we'd need 2 bits per protected character). 3665d522f475Smrg */ 3666d522f475Smrg#define OFF_PROTECT 0 3667d522f475Smrg#define DEC_PROTECT 1 3668d522f475Smrg#define ISO_PROTECT 2 3669d522f475Smrg 3670d4fba8b9Smrg/***====================================================================***/ 3671d4fba8b9Smrg 3672d4fba8b9Smrg/* 3673d4fba8b9Smrg * Reduce parameter-count of drawXtermText by putting less-modified data here. 3674d4fba8b9Smrg */ 3675d4fba8b9Smrgtypedef struct { 3676d4fba8b9Smrg XtermWidget xw; 3677d4fba8b9Smrg unsigned attr_flags; 3678d4fba8b9Smrg unsigned draw_flags; 3679d4fba8b9Smrg unsigned this_chrset; 3680d4fba8b9Smrg unsigned real_chrset; 3681d4fba8b9Smrg int on_wide; 3682d4fba8b9Smrg} XTermDraw; 3683d4fba8b9Smrg 3684d4fba8b9Smrg/***====================================================================***/ 3685d4fba8b9Smrg 3686d522f475Smrg#define TScreenOf(xw) (&(xw)->screen) 3687d522f475Smrg#define TekScreenOf(tw) (&(tw)->screen) 3688d522f475Smrg 3689712a7ff4Smrg#define PrinterOf(screen) (screen)->printer_state 3690712a7ff4Smrg 3691d522f475Smrg#ifdef SCROLLBAR_RIGHT 3692d522f475Smrg#define OriginX(screen) (((term->misc.useRight)?0:ScrollbarWidth(screen)) + screen->border) 3693d522f475Smrg#else 3694d522f475Smrg#define OriginX(screen) (ScrollbarWidth(screen) + screen->border) 3695d522f475Smrg#endif 3696d522f475Smrg 3697d522f475Smrg#define OriginY(screen) (screen->border) 3698d522f475Smrg 3699d522f475Smrg#define CursorMoved(screen) \ 3700d522f475Smrg ((screen)->cursor_moved || \ 3701d522f475Smrg ((screen)->cursorp.col != (screen)->cur_col || \ 3702d522f475Smrg (screen)->cursorp.row != (screen)->cur_row)) 3703d522f475Smrg 37043367019cSmrg#define CursorX2(screen,col,fw) ((col) * (int)(fw) + OriginX(screen)) 37053367019cSmrg#define CursorX(screen,col) CursorX2(screen, col, FontWidth(screen)) 37063367019cSmrg#define CursorY2(screen,row) (((row) * FontHeight(screen)) + screen->border) 37073367019cSmrg#define CursorY(screen,row) CursorY2(screen, INX2ROW(screen, row)) 3708d522f475Smrg 3709d522f475Smrg/* 3710d522f475Smrg * These definitions depend on whether xterm supports active-icon. 3711d522f475Smrg */ 3712d522f475Smrg#ifndef NO_ACTIVE_ICON 3713d522f475Smrg#define IsIconWin(screen,win) ((win) == &(screen)->iconVwin) 3714d522f475Smrg#define IsIcon(screen) (WhichVWin(screen) == &(screen)->iconVwin) 3715d522f475Smrg#define WhichVWin(screen) ((screen)->whichVwin) 3716d522f475Smrg#define WhichTWin(screen) ((screen)->whichTwin) 3717d522f475Smrg 3718dfb07bc7Smrg#define WhichVFont(screen,name) (IsIcon(screen) ? getIconicFont(screen) \ 3719d4fba8b9Smrg : getNormalFont(screen, (int)(name)))->fs 3720dfb07bc7Smrg#define FontAscent(screen) (IsIcon(screen) ? getIconicFont(screen)->fs->ascent \ 3721d522f475Smrg : WhichVWin(screen)->f_ascent) 3722dfb07bc7Smrg#define FontDescent(screen) (IsIcon(screen) ? getIconicFont(screen)->fs->descent \ 3723d522f475Smrg : WhichVWin(screen)->f_descent) 3724d522f475Smrg#else /* NO_ACTIVE_ICON */ 3725d522f475Smrg 3726d522f475Smrg#define IsIconWin(screen,win) (False) 3727d522f475Smrg#define IsIcon(screen) (False) 3728d522f475Smrg#define WhichVWin(screen) (&((screen)->fullVwin)) 3729d522f475Smrg#define WhichTWin(screen) (&((screen)->fullTwin)) 3730d522f475Smrg 3731d4fba8b9Smrg#define WhichVFont(screen,name) getNormalFont(screen, (int)(name))->fs 3732d522f475Smrg#define FontAscent(screen) WhichVWin(screen)->f_ascent 3733d522f475Smrg#define FontDescent(screen) WhichVWin(screen)->f_descent 3734d522f475Smrg 3735d522f475Smrg#endif /* NO_ACTIVE_ICON */ 3736d522f475Smrg 3737190d7dceSmrg#define okFont(font) ((font) != NULL && (font)->fid != 0) 3738d522f475Smrg 3739d522f475Smrg/* 3740d522f475Smrg * Macro to check if we are iconified; do not use render for that case. 3741d522f475Smrg */ 37423367019cSmrg#define UsingRenderFont(xw) (((xw)->work.render_font == True) && !IsIcon(TScreenOf(xw))) 3743d522f475Smrg 3744d522f475Smrg/* 3745d522f475Smrg * These definitions do not depend on whether xterm supports active-icon. 3746d522f475Smrg */ 3747d522f475Smrg#define VWindow(screen) WhichVWin(screen)->window 3748c219fbebSmrg#define VShellWindow(xw) XtWindow(SHELL_OF(xw)) 3749d522f475Smrg#define TWindow(screen) WhichTWin(screen)->window 3750d522f475Smrg#define TShellWindow XtWindow(SHELL_OF(tekWidget)) 3751d522f475Smrg 3752d4fba8b9Smrg#if USE_DOUBLE_BUFFER 3753d4fba8b9Smrgextern Window VDrawable(TScreen * /* screen */); 37543367019cSmrg#else 37553367019cSmrg#define VDrawable(screen) VWindow(screen) 37563367019cSmrg#endif 37573367019cSmrg 3758d522f475Smrg#define Width(screen) WhichVWin(screen)->width 3759d522f475Smrg#define Height(screen) WhichVWin(screen)->height 3760d522f475Smrg#define FullWidth(screen) WhichVWin(screen)->fullwidth 3761d522f475Smrg#define FullHeight(screen) WhichVWin(screen)->fullheight 3762d522f475Smrg#define FontWidth(screen) WhichVWin(screen)->f_width 3763d522f475Smrg#define FontHeight(screen) WhichVWin(screen)->f_height 3764d522f475Smrg 3765dfb07bc7Smrg#define NormalFont(screen) WhichVFont(screen, fNorm) 3766dfb07bc7Smrg#define BoldFont(screen) WhichVFont(screen, fBold) 3767d522f475Smrg 3768d522f475Smrg#if OPT_WIDE_CHARS 3769dfb07bc7Smrg#define NormalWFont(screen) WhichVFont(screen, fWide) 3770dfb07bc7Smrg#define BoldWFont(screen) WhichVFont(screen, fWBold) 3771d522f475Smrg#endif 3772d522f475Smrg 3773d522f475Smrg#define ScrollbarWidth(screen) WhichVWin(screen)->sb_info.width 3774d522f475Smrg 3775d4fba8b9Smrg/* y -> y_shift, to center text versus the cursor */ 3776d4fba8b9Smrg#define ScaleShift(screen) \ 3777d4fba8b9Smrg (int) ((IsIcon(screen) || (screen->scale_height <= 1.0f)) \ 3778d4fba8b9Smrg ? 0.0f \ 3779d4fba8b9Smrg : ((float) WhichVWin(screen)->f_height \ 3780d4fba8b9Smrg * ((float) screen->scale_height - 1.0f) / 2.0f)) 3781d4fba8b9Smrg 3782d4fba8b9Smrg#define BorderGC(w,sp) WhichVWin(sp)->border_gc 3783d4fba8b9Smrg#define FillerGC(w,sp) WhichVWin(sp)->filler_gc 3784d522f475Smrg#define NormalGC(w,sp) getCgsGC(w, WhichVWin(sp), gcNorm) 3785d522f475Smrg#define ReverseGC(w,sp) getCgsGC(w, WhichVWin(sp), gcNormReverse) 3786d522f475Smrg#define NormalBoldGC(w,sp) getCgsGC(w, WhichVWin(sp), gcBold) 3787d522f475Smrg#define ReverseBoldGC(w,sp) getCgsGC(w, WhichVWin(sp), gcBoldReverse) 3788d522f475Smrg 3789d522f475Smrg#define TWidth(screen) WhichTWin(screen)->width 3790d522f475Smrg#define THeight(screen) WhichTWin(screen)->height 3791d522f475Smrg#define TFullWidth(screen) WhichTWin(screen)->fullwidth 3792d522f475Smrg#define TFullHeight(screen) WhichTWin(screen)->fullheight 3793d522f475Smrg#define TekScale(screen) WhichTWin(screen)->tekscale 3794d522f475Smrg 3795dfb07bc7Smrg/* use these before tek4014 is realized, good enough for default "9x15" font */ 3796dfb07bc7Smrg#define TDefaultRows 37 3797dfb07bc7Smrg#define TDefaultCols 75 3798dfb07bc7Smrg 3799d522f475Smrg#define BorderWidth(w) ((w)->core.border_width) 3800d522f475Smrg#define BorderPixel(w) ((w)->core.border_pixel) 3801d522f475Smrg 3802cd3331d0Smrg#define AllowXtermOps(w,name) (TScreenOf(w)->name && !TScreenOf(w)->allowSendEvents) 3803cd3331d0Smrg 3804cd3331d0Smrg#define AllowColorOps(w,name) (AllowXtermOps(w, allowColorOps) || \ 3805cd3331d0Smrg !TScreenOf(w)->disallow_color_ops[name]) 3806cd3331d0Smrg 3807cd3331d0Smrg#define AllowFontOps(w,name) (AllowXtermOps(w, allowFontOps) || \ 3808cd3331d0Smrg !TScreenOf(w)->disallow_font_ops[name]) 3809cd3331d0Smrg 3810dfb07bc7Smrg#define AllowMouseOps(w,name) (AllowXtermOps(w, allowMouseOps) || \ 3811dfb07bc7Smrg !TScreenOf(w)->disallow_mouse_ops[name]) 3812dfb07bc7Smrg 3813cd3331d0Smrg#define AllowTcapOps(w,name) (AllowXtermOps(w, allowTcapOps) || \ 3814cd3331d0Smrg !TScreenOf(w)->disallow_tcap_ops[name]) 3815cd3331d0Smrg 3816b7c89284Ssnj#define AllowTitleOps(w) AllowXtermOps(w, allowTitleOps) 3817cd3331d0Smrg 3818d4fba8b9Smrg#define AllowXResOps(w) True 3819d4fba8b9Smrg 38203367019cSmrg#define SpecialWindowOps(w,name) (!TScreenOf(w)->disallow_win_ops[name]) 3821cd3331d0Smrg#define AllowWindowOps(w,name) (AllowXtermOps(w, allowWindowOps) || \ 38223367019cSmrg SpecialWindowOps(w,name)) 3823b7c89284Ssnj 3824d522f475Smrg#if OPT_TOOLBAR 3825d522f475Smrg#define ToolbarHeight(w) ((resource.toolBar) \ 3826c219fbebSmrg ? ((w)->VT100_TB_INFO(menu_height) \ 3827c219fbebSmrg + (w)->VT100_TB_INFO(menu_border) * 2) \ 3828d522f475Smrg : 0) 3829d522f475Smrg#else 3830d522f475Smrg#define ToolbarHeight(w) 0 3831d522f475Smrg#endif 3832d522f475Smrg 3833d522f475Smrg#if OPT_TEK4014 3834d522f475Smrg#define TEK_LINK_BLOCK_SIZE 1024 3835d522f475Smrg 3836d522f475Smrgtypedef struct Tek_Link 3837d522f475Smrg{ 3838d522f475Smrg struct Tek_Link *next; /* pointer to next TekLink in list 3839d522f475Smrg NULL <=> this is last TekLink */ 3840d522f475Smrg unsigned short fontsize;/* character size, 0-3 */ 3841d522f475Smrg unsigned short count; /* number of chars in data */ 3842d522f475Smrg char *ptr; /* current pointer into data */ 3843d522f475Smrg char data [TEK_LINK_BLOCK_SIZE]; 3844d522f475Smrg} TekLink; 3845d522f475Smrg#endif /* OPT_TEK4014 */ 3846d522f475Smrg 3847d522f475Smrg/* flags for cursors */ 3848d522f475Smrg#define OFF 0 3849d522f475Smrg#define ON 1 3850d522f475Smrg#define BLINKED_OFF 2 3851d522f475Smrg#define CLEAR 0 3852d522f475Smrg#define TOGGLE 1 3853d522f475Smrg 3854d522f475Smrg/* flags for inhibit */ 3855d522f475Smrg#ifdef ALLOWLOGGING 3856d522f475Smrg#define I_LOG 0x01 3857d522f475Smrg#endif 3858d522f475Smrg#define I_SIGNAL 0x02 3859d522f475Smrg#define I_TEK 0x04 3860d522f475Smrg 3861c219fbebSmrg/* *INDENT-ON* */ 3862c219fbebSmrg 3863d522f475Smrg#endif /* included_ptyx_h */ 3864