PageRenderTime 38ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 1ms

/nx-3.5.0/nx-X11/programs/xterm/ptyx.h

#
C Header | 2016 lines | 1550 code | 272 blank | 194 comment | 72 complexity | 609703184c8aef73549346fe1cee6ecb MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-2.0, LGPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. /* $XTermId: ptyx.h,v 1.390 2005/11/03 13:17:28 tom Exp $ */
  2. /*
  3. * $Xorg: ptyx.h,v 1.3 2000/08/17 19:55:09 cpqbld Exp $
  4. */
  5. /* $XFree86: xc/programs/xterm/ptyx.h,v 3.127 2005/11/03 13:17:28 dickey Exp $ */
  6. /*
  7. * Copyright 1999-2004,2005 by Thomas E. Dickey
  8. *
  9. * All Rights Reserved
  10. *
  11. * Permission is hereby granted, free of charge, to any person obtaining a
  12. * copy of this software and associated documentation files (the
  13. * "Software"), to deal in the Software without restriction, including
  14. * without limitation the rights to use, copy, modify, merge, publish,
  15. * distribute, sublicense, and/or sell copies of the Software, and to
  16. * permit persons to whom the Software is furnished to do so, subject to
  17. * the following conditions:
  18. *
  19. * The above copyright notice and this permission notice shall be included
  20. * in all copies or substantial portions of the Software.
  21. *
  22. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  23. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  24. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  25. * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
  26. * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  27. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  28. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29. *
  30. * Except as contained in this notice, the name(s) of the above copyright
  31. * holders shall not be used in advertising or otherwise to promote the
  32. * sale, use or other dealings in this Software without prior written
  33. * authorization.
  34. *
  35. *
  36. * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
  37. *
  38. * All Rights Reserved
  39. *
  40. * Permission to use, copy, modify, and distribute this software and its
  41. * documentation for any purpose and without fee is hereby granted,
  42. * provided that the above copyright notice appear in all copies and that
  43. * both that copyright notice and this permission notice appear in
  44. * supporting documentation, and that the name of Digital Equipment
  45. * Corporation not be used in advertising or publicity pertaining to
  46. * distribution of the software without specific, written prior permission.
  47. *
  48. *
  49. * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  50. * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  51. * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  52. * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  53. * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  54. * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  55. * SOFTWARE.
  56. */
  57. #ifndef included_ptyx_h
  58. #define included_ptyx_h 1
  59. #ifdef HAVE_CONFIG_H
  60. #include <xtermcfg.h>
  61. #endif
  62. /* ptyx.h */
  63. /* @(#)ptyx.h X10/6.6 11/10/86 */
  64. #include <X11/IntrinsicP.h>
  65. #include <X11/Shell.h> /* for XtNdieCallback, etc. */
  66. #include <X11/StringDefs.h> /* for standard resource names */
  67. #include <X11/Xmu/Misc.h> /* For Max() and Min(). */
  68. #include <X11/Xfuncs.h>
  69. #include <X11/Xosdefs.h>
  70. #include <X11/Xmu/Converters.h>
  71. #ifdef XRENDERFONT
  72. #include <X11/Xft/Xft.h>
  73. #endif
  74. /* adapted from IntrinsicI.h */
  75. #define MyStackAlloc(size, stack_cache_array) \
  76. ((size) <= sizeof(stack_cache_array) \
  77. ? (XtPointer)(stack_cache_array) \
  78. : (XtPointer)malloc((unsigned)(size)))
  79. #define MyStackFree(pointer, stack_cache_array) \
  80. if ((pointer) != ((char *)(stack_cache_array))) free(pointer)
  81. /* adapted from vile (vi-like-emacs) */
  82. #define TypeCallocN(type,n) (type *)calloc((n), sizeof(type))
  83. #define TypeCalloc(type) TypeCalloc(type,1)
  84. #define TypeMallocN(type,n) (type *)malloc(sizeof(type) * (n))
  85. #define TypeMalloc(type) TypeMallocN(type,0)
  86. #define TypeRealloc(type,n,p) (type *)realloc(p, (n) * sizeof(type))
  87. /* use these to allocate partly-structured data */
  88. #define CastMallocN(type,n) (type *)malloc(sizeof(type) + (n))
  89. #define CastMalloc(type) CastMallocN(type,0)
  90. /*
  91. ** System V definitions
  92. */
  93. #ifdef att
  94. #define ATT
  95. #endif
  96. #ifdef SVR4
  97. #undef SYSV /* predefined on Solaris 2.4 */
  98. #define SYSV /* SVR4 is (approx) superset of SVR3 */
  99. #define ATT
  100. #endif
  101. #ifdef SYSV
  102. #ifdef X_NOT_POSIX
  103. #if !defined(CRAY) && !defined(SVR4)
  104. #define dup2(fd1,fd2) ((fd1 == fd2) ? fd1 : \
  105. (close(fd2), fcntl(fd1, F_DUPFD, fd2)))
  106. #endif
  107. #endif
  108. #endif /* SYSV */
  109. /*
  110. * Newer versions of <X11/Xft/Xft.h> have a version number. We use certain
  111. * features from that.
  112. */
  113. #if defined(XRENDERFONT) && defined(XFT_VERSION) && XFT_VERSION >= 20100
  114. #define HAVE_TYPE_FCCHAR32 1 /* compatible: XftChar16 */
  115. #define HAVE_TYPE_XFTCHARSPEC 1 /* new type XftCharSpec */
  116. #endif
  117. /*
  118. ** Definitions to simplify ifdef's for pty's.
  119. */
  120. #define USE_PTY_DEVICE 1
  121. #define USE_PTY_SEARCH 1
  122. #if defined(__osf__) || (defined(linux) && defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
  123. #undef USE_PTY_DEVICE
  124. #undef USE_PTY_SEARCH
  125. #define USE_PTS_DEVICE 1
  126. #elif defined(VMS)
  127. #undef USE_PTY_DEVICE
  128. #undef USE_PTY_SEARCH
  129. #elif defined(PUCC_PTYD)
  130. #undef USE_PTY_SEARCH
  131. #endif
  132. #if defined(SYSV) && defined(i386) && !defined(SVR4)
  133. #define ATT
  134. #define USE_HANDSHAKE 1
  135. #define USE_ISPTS_FLAG 1
  136. #endif
  137. #if (defined (__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1)))
  138. #define USE_USG_PTYS
  139. #define USE_HANDSHAKE 0 /* "recent" Linux systems do not require handshaking */
  140. #elif (defined(ATT) && !defined(__sgi)) || defined(__MVS__) || (defined(SYSV) && defined(i386))
  141. #define USE_USG_PTYS
  142. #else
  143. #define USE_HANDSHAKE 1
  144. #endif
  145. /*
  146. * More systems than not require pty-handshaking.
  147. */
  148. #ifndef USE_HANDSHAKE
  149. #define USE_HANDSHAKE 1
  150. #endif
  151. /*
  152. ** allow for mobility of the pty master/slave directories
  153. */
  154. #ifndef PTYDEV
  155. #if defined(__hpux)
  156. #define PTYDEV "/dev/ptym/ptyxx"
  157. #elif defined(__MVS__)
  158. #define PTYDEV "/dev/ptypxxxx"
  159. #else
  160. #define PTYDEV "/dev/ptyxx"
  161. #endif
  162. #endif /* !PTYDEV */
  163. #ifndef TTYDEV
  164. #if defined(__hpux)
  165. #define TTYDEV "/dev/pty/ttyxx"
  166. #elif defined(__MVS__)
  167. #define TTYDEV "/dev/ptypxxxx"
  168. #elif defined(USE_PTS_DEVICE)
  169. #define TTYDEV "/dev/pts/0"
  170. #else
  171. #define TTYDEV "/dev/ttyxx"
  172. #endif
  173. #endif /* !TTYDEV */
  174. #ifndef PTYCHAR1
  175. #ifdef __hpux
  176. #define PTYCHAR1 "zyxwvutsrqp"
  177. #else /* !__hpux */
  178. #ifdef __UNIXOS2__
  179. #define PTYCHAR1 "pq"
  180. #else
  181. #define PTYCHAR1 "pqrstuvwxyzPQRSTUVWXYZ"
  182. #endif /* !__UNIXOS2__ */
  183. #endif /* !__hpux */
  184. #endif /* !PTYCHAR1 */
  185. #ifndef PTYCHAR2
  186. #ifdef __hpux
  187. #define PTYCHAR2 "fedcba9876543210"
  188. #else /* !__hpux */
  189. #if defined(__DragonFly__) || defined(__FreeBSD__)
  190. #define PTYCHAR2 "0123456789abcdefghijklmnopqrstuv"
  191. #else /* !__FreeBSD__ */
  192. #define PTYCHAR2 "0123456789abcdef"
  193. #endif /* !__FreeBSD__ */
  194. #endif /* !__hpux */
  195. #endif /* !PTYCHAR2 */
  196. #ifndef TTYFORMAT
  197. #if defined(CRAY)
  198. #define TTYFORMAT "/dev/ttyp%03d"
  199. #elif defined(__MVS__)
  200. #define TTYFORMAT "/dev/ttyp%04d"
  201. #else
  202. #define TTYFORMAT "/dev/ttyp%d"
  203. #endif
  204. #endif /* TTYFORMAT */
  205. #ifndef PTYFORMAT
  206. #ifdef CRAY
  207. #define PTYFORMAT "/dev/pty/%03d"
  208. #elif defined(__MVS__)
  209. #define PTYFORMAT "/dev/ptyp%04d"
  210. #else
  211. #define PTYFORMAT "/dev/ptyp%d"
  212. #endif
  213. #endif /* PTYFORMAT */
  214. #ifndef PTYCHARLEN
  215. #ifdef CRAY
  216. #define PTYCHARLEN 3
  217. #elif defined(__MVS__)
  218. #define PTYCHARLEN 8 /* OS/390 stores, e.g. ut_id="ttyp1234" */
  219. #else
  220. #define PTYCHARLEN 2
  221. #endif
  222. #endif
  223. #ifndef MAXPTTYS
  224. #ifdef CRAY
  225. #define MAXPTTYS 256
  226. #else
  227. #define MAXPTTYS 2048
  228. #endif
  229. #endif
  230. /* Until the translation manager comes along, I have to do my own translation of
  231. * mouse events into the proper routines. */
  232. typedef enum {NORMAL, LEFTEXTENSION, RIGHTEXTENSION} EventMode;
  233. /*
  234. * The origin of a screen is 0, 0. Therefore, the number of rows
  235. * on a screen is screen->max_row + 1, and similarly for columns.
  236. */
  237. #define MaxCols(screen) ((screen)->max_col + 1)
  238. #define MaxRows(screen) ((screen)->max_row + 1)
  239. typedef unsigned char Char; /* to support 8 bit chars */
  240. typedef Char *ScrnPtr;
  241. typedef ScrnPtr *ScrnBuf;
  242. #define CharOf(n) ((unsigned char)(n))
  243. /*
  244. * ANSI emulation, special character codes
  245. */
  246. #define INQ 0x05
  247. #define BEL 0x07
  248. #define FF 0x0C /* C0, C1 control names */
  249. #define LS1 0x0E
  250. #define LS0 0x0F
  251. #define NAK 0x15
  252. #define CAN 0x18
  253. #define SUB 0x1A
  254. #define ESC 0x1B
  255. #define XPOUND 0x1E /* internal mapping for '#' */
  256. #define US 0x1F
  257. #define DEL 0x7F
  258. #define RI 0x8D
  259. #define SS2 0x8E
  260. #define SS3 0x8F
  261. #define DCS 0x90
  262. #define SPA 0x96
  263. #define EPA 0x97
  264. #define SOS 0x98
  265. #define OLDID 0x9A /* ESC Z */
  266. #define CSI 0x9B
  267. #define ST 0x9C
  268. #define OSC 0x9D
  269. #define PM 0x9E
  270. #define APC 0x9F
  271. #define RDEL 0xFF
  272. #define MIN_DECID 52 /* can emulate VT52 */
  273. #define MAX_DECID 420 /* ...through VT420 */
  274. #ifndef DFT_DECID
  275. #define DFT_DECID "vt100" /* default VT100 */
  276. #endif
  277. #ifndef DFT_KBD_DIALECT
  278. #define DFT_KBD_DIALECT "B" /* default USASCII */
  279. #endif
  280. /* constants used for utf8 mode */
  281. #define UCS_REPL 0xfffd
  282. #define UCS_LIMIT 0x80000000U /* both limit and flag for non-UCS */
  283. #define TERMCAP_SIZE 1500 /* 1023 is standard; 'screen' exceeds */
  284. #define NMENUFONTS 9 /* font entries in fontMenu */
  285. #define NBOX 5 /* Number of Points in box */
  286. #define NPARAM 30 /* Max. parameters */
  287. typedef struct {
  288. char *opt;
  289. char *desc;
  290. } OptionHelp;
  291. typedef struct {
  292. unsigned char a_type; /* CSI, etc., see unparseq() */
  293. unsigned char a_pintro; /* private-mode char, if any */
  294. unsigned char a_inters; /* special (before final-char) */
  295. unsigned char a_final; /* final-char */
  296. short a_nparam; /* # of parameters */
  297. short a_param[NPARAM]; /* Parameters */
  298. } ANSI;
  299. #define TEK_FONT_LARGE 0
  300. #define TEK_FONT_2 1
  301. #define TEK_FONT_3 2
  302. #define TEK_FONT_SMALL 3
  303. #define TEKNUMFONTS 4
  304. /* Actually there are 5 types of lines, but four are non-solid lines */
  305. #define TEKNUMLINES 4
  306. typedef struct {
  307. int x;
  308. int y;
  309. int fontsize;
  310. unsigned linetype;
  311. } Tmodes;
  312. typedef struct {
  313. int Twidth;
  314. int Theight;
  315. } T_fontsize;
  316. typedef struct {
  317. short *bits;
  318. int x;
  319. int y;
  320. int width;
  321. int height;
  322. } BitmapBits;
  323. #define SAVELINES 64 /* default # lines to save */
  324. #define SCROLLLINES 1 /* default # lines to scroll */
  325. #define EXCHANGE(a,b,tmp) tmp = a; a = b; b = tmp
  326. /***====================================================================***/
  327. #if (XtSpecificationRelease < 6)
  328. #ifndef NO_ACTIVE_ICON
  329. #define NO_ACTIVE_ICON 1 /* Note: code relies on an X11R6 function */
  330. #endif
  331. #endif
  332. #ifndef OPT_AIX_COLORS
  333. #define OPT_AIX_COLORS 1 /* true if xterm is configured with AIX (16) colors */
  334. #endif
  335. #ifndef OPT_BLINK_CURS
  336. #define OPT_BLINK_CURS 1 /* true if xterm has blinking cursor capability */
  337. #endif
  338. #ifndef OPT_BLINK_TEXT
  339. #define OPT_BLINK_TEXT OPT_BLINK_CURS /* true if xterm has blinking text capability */
  340. #endif
  341. #ifndef OPT_BOX_CHARS
  342. #define OPT_BOX_CHARS 1 /* true if xterm can simulate box-characters */
  343. #endif
  344. #ifndef OPT_BROKEN_OSC
  345. #ifdef linux
  346. #define OPT_BROKEN_OSC 1 /* man console_codes, 1st paragraph - cf: ECMA-48 */
  347. #else
  348. #define OPT_BROKEN_OSC 0 /* true if xterm allows Linux's broken OSC parsing */
  349. #endif
  350. #endif
  351. #ifndef OPT_BROKEN_ST
  352. #define OPT_BROKEN_ST 1 /* true if xterm allows old/broken OSC parsing */
  353. #endif
  354. #ifndef OPT_C1_PRINT
  355. #define OPT_C1_PRINT 1 /* true if xterm allows C1 controls to be printable */
  356. #endif
  357. #ifndef OPT_CLIP_BOLD
  358. #define OPT_CLIP_BOLD 1 /* true if xterm uses clipping to avoid bold-trash */
  359. #endif
  360. #ifndef OPT_COLOR_CLASS
  361. #define OPT_COLOR_CLASS 1 /* true if xterm uses separate color-resource classes */
  362. #endif
  363. #ifndef OPT_COLOR_RES
  364. #define OPT_COLOR_RES 1 /* true if xterm delays color-resource evaluation */
  365. #undef OPT_COLOR_RES2
  366. #endif
  367. #ifndef OPT_COLOR_RES2
  368. #define OPT_COLOR_RES2 OPT_COLOR_RES /* true to avoid using extra resources */
  369. #endif
  370. #ifndef OPT_DABBREV
  371. #define OPT_DABBREV 0 /* dynamic abbreviations */
  372. #endif
  373. #ifndef OPT_DEC_CHRSET
  374. #define OPT_DEC_CHRSET 1 /* true if xterm is configured for DEC charset */
  375. #endif
  376. #ifndef OPT_DEC_LOCATOR
  377. #define OPT_DEC_LOCATOR 0 /* true if xterm supports VT220-style mouse events */
  378. #endif
  379. #ifndef OPT_DEC_RECTOPS
  380. #define OPT_DEC_RECTOPS 0 /* true if xterm is configured for VT420 rectangles */
  381. #endif
  382. #ifndef OPT_DEC_SOFTFONT
  383. #define OPT_DEC_SOFTFONT 0 /* true if xterm is configured for VT220 softfonts */
  384. #endif
  385. #ifndef OPT_EBCDIC
  386. #ifdef __MVS__
  387. #define OPT_EBCDIC 1
  388. #else
  389. #define OPT_EBCDIC 0
  390. #endif
  391. #endif
  392. #ifndef OPT_HP_FUNC_KEYS
  393. #define OPT_HP_FUNC_KEYS 0 /* true if xterm supports HP-style function keys */
  394. #endif
  395. #ifndef OPT_I18N_SUPPORT
  396. #if (XtSpecificationRelease >= 5)
  397. #define OPT_I18N_SUPPORT 1 /* true if xterm uses internationalization support */
  398. #else
  399. #define OPT_I18N_SUPPORT 0
  400. #endif
  401. #endif
  402. #ifndef OPT_INITIAL_ERASE
  403. #define OPT_INITIAL_ERASE 1 /* use pty's erase character if it's not 128 */
  404. #endif
  405. #ifndef OPT_INPUT_METHOD
  406. #if (XtSpecificationRelease >= 6)
  407. #define OPT_INPUT_METHOD 1 /* true if xterm uses input-method support */
  408. #else
  409. #define OPT_INPUT_METHOD 0
  410. #endif
  411. #endif
  412. #ifndef OPT_ISO_COLORS
  413. #define OPT_ISO_COLORS 1 /* true if xterm is configured with ISO colors */
  414. #endif
  415. #ifndef OPT_256_COLORS
  416. #define OPT_256_COLORS 0 /* true if xterm is configured with 256 colors */
  417. #endif
  418. #ifndef OPT_88_COLORS
  419. #define OPT_88_COLORS 0 /* true if xterm is configured with 88 colors */
  420. #endif
  421. #ifndef OPT_HIGHLIGHT_COLOR
  422. #define OPT_HIGHLIGHT_COLOR 1 /* true if xterm supports color highlighting */
  423. #endif
  424. #ifndef OPT_LOAD_VTFONTS
  425. #define OPT_LOAD_VTFONTS 0 /* true if xterm has load-vt-fonts() action */
  426. #endif
  427. #ifndef OPT_LUIT_PROG
  428. #define OPT_LUIT_PROG 0 /* true if xterm supports luit */
  429. #endif
  430. #ifndef OPT_MAXIMIZE
  431. #define OPT_MAXIMIZE 1 /* add actions for iconify ... maximize */
  432. #endif
  433. #ifndef OPT_MINI_LUIT
  434. #define OPT_MINI_LUIT 0 /* true if xterm supports built-in mini-luit */
  435. #endif
  436. #ifndef OPT_MOD_FKEYS
  437. #define OPT_MOD_FKEYS 1 /* modify cursor- and function-keys in normal mode */
  438. #endif
  439. #ifndef OPT_NUM_LOCK
  440. #define OPT_NUM_LOCK 1 /* use NumLock key only for numeric-keypad */
  441. #endif
  442. #ifndef OPT_PASTE64
  443. #define OPT_PASTE64 0 /* program control of select/paste via base64 */
  444. #endif
  445. #ifndef OPT_PC_COLORS
  446. #define OPT_PC_COLORS 1 /* true if xterm supports PC-style (bold) colors */
  447. #endif
  448. #ifndef OPT_PTY_HANDSHAKE
  449. #define OPT_PTY_HANDSHAKE USE_HANDSHAKE /* avoid pty races on older systems */
  450. #endif
  451. #ifndef OPT_PRINT_COLORS
  452. #define OPT_PRINT_COLORS 1 /* true if we print color information */
  453. #endif
  454. #ifndef OPT_READLINE
  455. #define OPT_READLINE 0 /* mouse-click/paste support for readline */
  456. #endif
  457. #ifndef OPT_RENDERFONT
  458. #ifdef XRENDERFONT
  459. #define OPT_RENDERFONT 1
  460. #else
  461. #define OPT_RENDERFONT 0
  462. #endif
  463. #endif
  464. #ifndef OPT_RENDERWIDE
  465. #if OPT_RENDERFONT && OPT_WIDE_CHARS && defined(HAVE_TYPE_XFTCHARSPEC)
  466. #define OPT_RENDERWIDE 1
  467. #else
  468. #define OPT_RENDERWIDE 0
  469. #endif
  470. #endif
  471. #ifndef OPT_SAME_NAME
  472. #define OPT_SAME_NAME 1 /* suppress redundant updates of title, icon, etc. */
  473. #endif
  474. #ifndef OPT_SCO_FUNC_KEYS
  475. #define OPT_SCO_FUNC_KEYS 0 /* true if xterm supports SCO-style function keys */
  476. #endif
  477. #ifndef OPT_SESSION_MGT
  478. #if defined(XtNdieCallback) && defined(XtNsaveCallback)
  479. #define OPT_SESSION_MGT 1
  480. #else
  481. #define OPT_SESSION_MGT 0
  482. #endif
  483. #endif
  484. #ifndef OPT_SHIFT_FONTS
  485. #define OPT_SHIFT_FONTS 1 /* true if xterm interprets fontsize-shifting */
  486. #endif
  487. #ifndef OPT_SUNPC_KBD
  488. #define OPT_SUNPC_KBD 1 /* true if xterm supports Sun/PC keyboard map */
  489. #endif
  490. #ifndef OPT_TCAP_QUERY
  491. #define OPT_TCAP_QUERY 0 /* true for experimental termcap query */
  492. #endif
  493. #ifndef OPT_TEK4014
  494. #define OPT_TEK4014 1 /* true if we're using tek4014 emulation */
  495. #endif
  496. #ifndef OPT_TOOLBAR
  497. #define OPT_TOOLBAR 0 /* true if xterm supports toolbar menus */
  498. #endif
  499. #ifndef OPT_TRACE
  500. #define OPT_TRACE 0 /* true if we're using debugging traces */
  501. #endif
  502. #ifndef OPT_VT52_MODE
  503. #define OPT_VT52_MODE 1 /* true if xterm supports VT52 emulation */
  504. #endif
  505. #ifndef OPT_WIDE_CHARS
  506. #define OPT_WIDE_CHARS 0 /* true if xterm supports 16-bit characters */
  507. #endif
  508. #ifndef OPT_XMC_GLITCH
  509. #define OPT_XMC_GLITCH 0 /* true if xterm supports xmc (magic cookie glitch) */
  510. #endif
  511. #ifndef OPT_ZICONBEEP
  512. #define OPT_ZICONBEEP 1 /* true if xterm supports "-ziconbeep" option */
  513. #endif
  514. /***====================================================================***/
  515. #if OPT_AIX_COLORS && !OPT_ISO_COLORS
  516. /* You must have ANSI/ISO colors to support AIX colors */
  517. #undef OPT_AIX_COLORS
  518. #define OPT_AIX_COLORS 0
  519. #endif
  520. #if OPT_COLOR_RES && !OPT_ISO_COLORS
  521. /* You must have ANSI/ISO colors to support ColorRes logic */
  522. #undef OPT_COLOR_RES
  523. #define OPT_COLOR_RES 0
  524. #endif
  525. #if OPT_COLOR_RES2 && !(OPT_256_COLORS || OPT_88_COLORS)
  526. /* You must have 88/256 colors to need fake-resource logic */
  527. #undef OPT_COLOR_RES2
  528. #define OPT_COLOR_RES2 0
  529. #endif
  530. #if OPT_PASTE64 && !OPT_READLINE
  531. /* OPT_PASTE64 uses logic from OPT_READLINE */
  532. #undef OPT_READLINE
  533. #define OPT_READLINE 1
  534. #endif
  535. #if OPT_PC_COLORS && !OPT_ISO_COLORS
  536. /* You must have ANSI/ISO colors to support PC colors */
  537. #undef OPT_PC_COLORS
  538. #define OPT_PC_COLORS 0
  539. #endif
  540. #if OPT_PRINT_COLORS && !OPT_ISO_COLORS
  541. /* You must have ANSI/ISO colors to be able to print them */
  542. #undef OPT_PRINT_COLORS
  543. #define OPT_PRINT_COLORS 0
  544. #endif
  545. #if OPT_256_COLORS && !OPT_ISO_COLORS
  546. /* You must have ANSI/ISO colors to support 256 colors */
  547. #undef OPT_256_COLORS
  548. #define OPT_256_COLORS 0
  549. #endif
  550. #if OPT_88_COLORS && !OPT_ISO_COLORS
  551. /* You must have ANSI/ISO colors to support 88 colors */
  552. #undef OPT_88_COLORS
  553. #define OPT_88_COLORS 0
  554. #endif
  555. #if OPT_88_COLORS && OPT_256_COLORS
  556. /* 256 colors supersedes 88 colors */
  557. #undef OPT_88_COLORS
  558. #define OPT_88_COLORS 0
  559. #endif
  560. /***====================================================================***/
  561. /*
  562. * Indices for menu_font_names[][]
  563. */
  564. typedef enum {
  565. fNorm = 0
  566. , fBold
  567. #if OPT_WIDE_CHARS
  568. , fWide
  569. , fWBold
  570. #endif
  571. , fMAX
  572. } VTFontEnum;
  573. /* indices for the normal terminal colors in screen.Tcolors[] */
  574. typedef enum {
  575. TEXT_FG = 0 /* text foreground */
  576. , TEXT_BG = 1 /* text background */
  577. , TEXT_CURSOR = 2 /* text cursor */
  578. , MOUSE_FG = 3 /* mouse foreground */
  579. , MOUSE_BG = 4 /* mouse background */
  580. #if OPT_TEK4014
  581. , TEK_FG = 5 /* tektronix foreground */
  582. , TEK_BG = 6 /* tektronix background */
  583. #endif
  584. #if OPT_HIGHLIGHT_COLOR
  585. , HIGHLIGHT_BG = 7 /* highlight background */
  586. #endif
  587. #if OPT_TEK4014
  588. , TEK_CURSOR = 8 /* tektronix cursor */
  589. #endif
  590. , NCOLORS /* total number of colors */
  591. } TermColors;
  592. #define COLOR_DEFINED(s,w) ((s)->which & (1<<(w)))
  593. #define COLOR_VALUE(s,w) ((s)->colors[w])
  594. #define SET_COLOR_VALUE(s,w,v) (((s)->colors[w] = (v)), ((s)->which |= (1<<(w))))
  595. #define COLOR_NAME(s,w) ((s)->names[w])
  596. #define SET_COLOR_NAME(s,w,v) (((s)->names[w] = (v)), ((s)->which |= (1<<(w))))
  597. #define UNDEFINE_COLOR(s,w) ((s)->which &= (~((w)<<1)))
  598. /***====================================================================***/
  599. #if OPT_ISO_COLORS
  600. #define if_OPT_ISO_COLORS(screen, code) if(screen->colorMode) code
  601. #define TERM_COLOR_FLAGS(xw) ((xw)->flags & (FG_COLOR|BG_COLOR))
  602. #define COLOR_0 0
  603. #define COLOR_1 1
  604. #define COLOR_2 2
  605. #define COLOR_3 3
  606. #define COLOR_4 4
  607. #define COLOR_5 5
  608. #define COLOR_6 6
  609. #define COLOR_7 7
  610. #define COLOR_8 8
  611. #define COLOR_9 9
  612. #define COLOR_10 10
  613. #define COLOR_11 11
  614. #define COLOR_12 12
  615. #define COLOR_13 13
  616. #define COLOR_14 14
  617. #define COLOR_15 15
  618. #define MIN_ANSI_COLORS 16
  619. #if OPT_256_COLORS
  620. # define NUM_ANSI_COLORS 256
  621. #elif OPT_88_COLORS
  622. # define NUM_ANSI_COLORS 88
  623. #else
  624. # define NUM_ANSI_COLORS MIN_ANSI_COLORS
  625. #endif
  626. #if NUM_ANSI_COLORS > MIN_ANSI_COLORS
  627. # define OPT_EXT_COLORS 1
  628. #else
  629. # define OPT_EXT_COLORS 0
  630. #endif
  631. #define COLOR_BD (NUM_ANSI_COLORS) /* BOLD */
  632. #define COLOR_UL (NUM_ANSI_COLORS+1) /* UNDERLINE */
  633. #define COLOR_BL (NUM_ANSI_COLORS+2) /* BLINK */
  634. #define COLOR_RV (NUM_ANSI_COLORS+3) /* REVERSE */
  635. #define MAXCOLORS (NUM_ANSI_COLORS+4)
  636. #ifndef DFT_COLORMODE
  637. #define DFT_COLORMODE TRUE /* default colorMode resource */
  638. #endif
  639. #define ReverseOrHilite(screen,flags,hilite) \
  640. (( screen->colorRVMode && hilite ) || \
  641. ( !screen->colorRVMode && \
  642. (( (flags & INVERSE) && !hilite) || \
  643. (!(flags & INVERSE) && hilite)) ))
  644. /* Define a fake XK code, we need it for the fake color response in
  645. * xtermcapKeycode(). */
  646. #if OPT_TCAP_QUERY
  647. # define XK_COLORS 0x0003
  648. #endif
  649. #else /* !OPT_ISO_COLORS */
  650. #define if_OPT_ISO_COLORS(screen, code) /* nothing */
  651. #define TERM_COLOR_FLAGS(xw) 0
  652. #define ReverseOrHilite(screen,flags,hilite) \
  653. (( (flags & INVERSE) && !hilite) || \
  654. (!(flags & INVERSE) && hilite))
  655. #endif /* OPT_ISO_COLORS */
  656. #if OPT_AIX_COLORS
  657. #define if_OPT_AIX_COLORS(screen, code) if(screen->colorMode) code
  658. #else
  659. #define if_OPT_AIX_COLORS(screen, code) /* nothing */
  660. #endif
  661. #if OPT_256_COLORS || OPT_88_COLORS
  662. # define if_OPT_EXT_COLORS(screen, code) if(screen->colorMode) code
  663. # define if_OPT_ISO_TRADITIONAL_COLORS(screen, code) /* nothing */
  664. #elif OPT_ISO_COLORS
  665. # define if_OPT_EXT_COLORS(screen, code) /* nothing */
  666. # define if_OPT_ISO_TRADITIONAL_COLORS(screen, code) if(screen->colorMode) code
  667. #else
  668. # define if_OPT_EXT_COLORS(screen, code) /* nothing */
  669. # define if_OPT_ISO_TRADITIONAL_COLORS(screen, code) /*nothing*/
  670. #endif
  671. #define COLOR_RES_NAME(root) "color" root
  672. #if OPT_COLOR_CLASS
  673. #define COLOR_RES_CLASS(root) "Color" root
  674. #else
  675. #define COLOR_RES_CLASS(root) XtCForeground
  676. #endif
  677. #if OPT_COLOR_RES
  678. #define COLOR_RES(root,offset,value) Sres(COLOR_RES_NAME(root), COLOR_RES_CLASS(root), offset.resource, value)
  679. #define COLOR_RES2(name,class,offset,value) Sres(name, class, offset.resource, value)
  680. #else
  681. #define COLOR_RES(root,offset,value) Cres(COLOR_RES_NAME(root), COLOR_RES_CLASS(root), offset, value)
  682. #define COLOR_RES2(name,class,offset,value) Cres(name, class, offset, value)
  683. #endif
  684. /***====================================================================***/
  685. #if OPT_DEC_CHRSET
  686. #define if_OPT_DEC_CHRSET(code) code
  687. /* Use 2 bits for encoding the double high/wide sense of characters */
  688. #define CSET_SWL 0
  689. #define CSET_DHL_TOP 1
  690. #define CSET_DHL_BOT 2
  691. #define CSET_DWL 3
  692. #define NUM_CHRSET 8 /* normal/bold and 4 CSET_xxx values */
  693. /* Use remaining bits for encoding the other character-sets */
  694. #define CSET_NORMAL(code) ((code) == CSET_SWL)
  695. #define CSET_DOUBLE(code) (!CSET_NORMAL(code) && !CSET_EXTEND(code))
  696. #define CSET_EXTEND(code) ((code) > CSET_DWL)
  697. /* for doublesize characters, the first cell in a row holds the info */
  698. #define SCRN_ROW_CSET(screen,row) (SCRN_BUF_CSETS((screen), row)[0])
  699. #define CurMaxCol(screen, row) \
  700. (CSET_DOUBLE(SCRN_ROW_CSET(screen, row)) \
  701. ? (screen->max_col / 2) \
  702. : (screen->max_col))
  703. #define CurCursorX(screen, row, col) \
  704. (CSET_DOUBLE(SCRN_ROW_CSET(screen, row)) \
  705. ? CursorX(screen, 2*(col)) \
  706. : CursorX(screen, (col)))
  707. #define CurFontWidth(screen, row) \
  708. (CSET_DOUBLE(SCRN_ROW_CSET(screen, row)) \
  709. ? 2*FontWidth(screen) \
  710. : FontWidth(screen))
  711. #else
  712. #define if_OPT_DEC_CHRSET(code) /*nothing*/
  713. #define CurMaxCol(screen, row) screen->max_col
  714. #define CurCursorX(screen, row, col) CursorX(screen, col)
  715. #define CurFontWidth(screen, row) FontWidth(screen)
  716. #endif
  717. #if OPT_LUIT_PROG && !OPT_WIDE_CHARS
  718. #error Luit requires the wide-chars configuration
  719. #endif
  720. /* the number of pointers per row in 'ScrnBuf' */
  721. #if OPT_ISO_COLORS || OPT_DEC_CHRSET || OPT_WIDE_CHARS
  722. #define MAX_PTRS term->num_ptrs
  723. #else
  724. #define MAX_PTRS (OFF_ATTRS+1)
  725. #endif
  726. #define BUF_HEAD 1
  727. /* the number that point to Char data */
  728. #define BUF_PTRS (MAX_PTRS - BUF_HEAD)
  729. /***====================================================================***/
  730. #if OPT_EBCDIC
  731. extern int E2A(int);
  732. extern int A2E(int);
  733. #else
  734. #define E2A(a) (a)
  735. #define A2E(a) (a)
  736. #endif
  737. #define CONTROL(a) (A2E(E2A(a)&037))
  738. /***====================================================================***/
  739. #if OPT_TEK4014
  740. #define TEK4014_ACTIVE(screen) ((screen)->TekEmu)
  741. #define CURRENT_EMU_VAL(screen,tek,vt) (TEK4014_ACTIVE(screen) ? tek : vt)
  742. #define CURRENT_EMU(screen) CURRENT_EMU_VAL(screen, (Widget)tekWidget, (Widget)term)
  743. #else
  744. #define TEK4014_ACTIVE(screen) 0
  745. #define CURRENT_EMU_VAL(screen,tek,vt) (vt)
  746. #define CURRENT_EMU(screen) ((Widget)term)
  747. #endif
  748. /***====================================================================***/
  749. #if OPT_TOOLBAR
  750. #define SHELL_OF(widget) XtParent(XtParent(widget))
  751. #else
  752. #define SHELL_OF(widget) XtParent(widget)
  753. #endif
  754. /***====================================================================***/
  755. #if OPT_VT52_MODE
  756. #define if_OPT_VT52_MODE(screen, code) if(screen->vtXX_level == 0) code
  757. #else
  758. #define if_OPT_VT52_MODE(screen, code) /* nothing */
  759. #endif
  760. /***====================================================================***/
  761. #if OPT_XMC_GLITCH
  762. #define if_OPT_XMC_GLITCH(screen, code) if(screen->xmc_glitch) code
  763. #define XMC_GLITCH 1 /* the character we'll show */
  764. #define XMC_FLAGS (INVERSE|UNDERLINE|BOLD)
  765. #else
  766. #define if_OPT_XMC_GLITCH(screen, code) /* nothing */
  767. #endif
  768. /***====================================================================***/
  769. #if OPT_WIDE_CHARS
  770. #define if_OPT_WIDE_CHARS(screen, code) if(screen->wide_chars) code
  771. #define PAIRED_CHARS(a,b) a,b
  772. typedef unsigned IChar; /* for 8 or 16-bit characters, plus flag */
  773. #else
  774. #define if_OPT_WIDE_CHARS(screen, code) /* nothing */
  775. #define PAIRED_CHARS(a,b) a
  776. typedef unsigned char IChar; /* for 8-bit characters */
  777. #endif
  778. /***====================================================================***/
  779. #ifndef RES_OFFSET
  780. #define RES_OFFSET(offset) XtOffsetOf(XtermWidgetRec, offset)
  781. #endif
  782. #define RES_NAME(name) name
  783. #define RES_CLASS(name) name
  784. #define Bres(name, class, offset, dftvalue) \
  785. {RES_NAME(name), RES_CLASS(class), XtRBoolean, sizeof(Boolean), \
  786. RES_OFFSET(offset), XtRImmediate, (XtPointer) dftvalue}
  787. #define Cres(name, class, offset, dftvalue) \
  788. {RES_NAME(name), RES_CLASS(class), XtRPixel, sizeof(Pixel), \
  789. RES_OFFSET(offset), XtRString, (XtPointer) dftvalue}
  790. #define Tres(name, class, offset, dftvalue) \
  791. COLOR_RES2(name, class, screen.Tcolors[offset], dftvalue) \
  792. #define Fres(name, class, offset, dftvalue) \
  793. {RES_NAME(name), RES_CLASS(class), XtRFontStruct, sizeof(XFontStruct *), \
  794. RES_OFFSET(offset), XtRString, (XtPointer) dftvalue}
  795. #define Ires(name, class, offset, dftvalue) \
  796. {RES_NAME(name), RES_CLASS(class), XtRInt, sizeof(int), \
  797. RES_OFFSET(offset), XtRImmediate, (XtPointer) dftvalue}
  798. #define Dres(name, class, offset, dftvalue) \
  799. {RES_NAME(name), RES_CLASS(class), XtRFloat, sizeof(float), \
  800. RES_OFFSET(offset), XtRString, (XtPointer) dftvalue}
  801. #define Sres(name, class, offset, dftvalue) \
  802. {RES_NAME(name), RES_CLASS(class), XtRString, sizeof(char *), \
  803. RES_OFFSET(offset), XtRString, (XtPointer) dftvalue}
  804. #define Wres(name, class, offset, dftvalue) \
  805. {RES_NAME(name), RES_CLASS(class), XtRWidget, sizeof(Widget), \
  806. RES_OFFSET(offset), XtRWidget, (XtPointer) dftvalue}
  807. /***====================================================================***/
  808. #define FRG_SIZE resource.minBufSize
  809. #define BUF_SIZE resource.maxBufSize
  810. typedef struct {
  811. Char * next;
  812. Char * last;
  813. int update; /* HandleInterpret */
  814. #if OPT_WIDE_CHARS
  815. IChar utf_data; /* resulting character */
  816. int utf_size; /* ...number of bytes decoded */
  817. #endif
  818. Char buffer[1];
  819. } PtyData;
  820. /***====================================================================***/
  821. /* The order of ifdef's matches the logic for num_ptrs in VTInitialize */
  822. typedef enum {
  823. OFF_FLAGS = 0 /* BUF_HEAD */
  824. , OFF_CHARS = 1 /* first (or only) byte of cell's character */
  825. , OFF_ATTRS = 2 /* video attributes */
  826. #if OPT_ISO_COLORS
  827. #if OPT_256_COLORS || OPT_88_COLORS
  828. , OFF_FGRND /* foreground color number */
  829. , OFF_BGRND /* background color number */
  830. #else
  831. , OFF_COLOR /* foreground+background color numbers */
  832. #endif
  833. #endif
  834. #if OPT_DEC_CHRSET
  835. , OFF_CSETS /* DEC character-set */
  836. #endif
  837. #if OPT_WIDE_CHARS
  838. , OFF_WIDEC /* second byte of first wide-character */
  839. , OFF_COM1L /* first combining character */
  840. , OFF_COM1H
  841. , OFF_COM2L /* second combining character */
  842. , OFF_COM2H
  843. #endif
  844. } BufOffsets;
  845. /* ScrnBuf-level macros */
  846. #define BUF_FLAGS(buf, row) (buf[MAX_PTRS * (row) + OFF_FLAGS])
  847. #define BUF_CHARS(buf, row) (buf[MAX_PTRS * (row) + OFF_CHARS])
  848. #define BUF_ATTRS(buf, row) (buf[MAX_PTRS * (row) + OFF_ATTRS])
  849. #define BUF_COLOR(buf, row) (buf[MAX_PTRS * (row) + OFF_COLOR])
  850. #define BUF_FGRND(buf, row) (buf[MAX_PTRS * (row) + OFF_FGRND])
  851. #define BUF_BGRND(buf, row) (buf[MAX_PTRS * (row) + OFF_BGRND])
  852. #define BUF_CSETS(buf, row) (buf[MAX_PTRS * (row) + OFF_CSETS])
  853. #define BUF_WIDEC(buf, row) (buf[MAX_PTRS * (row) + OFF_WIDEC])
  854. #define BUF_COM1L(buf, row) (buf[MAX_PTRS * (row) + OFF_COM1L])
  855. #define BUF_COM1H(buf, row) (buf[MAX_PTRS * (row) + OFF_COM1H])
  856. #define BUF_COM2L(buf, row) (buf[MAX_PTRS * (row) + OFF_COM2L])
  857. #define BUF_COM2H(buf, row) (buf[MAX_PTRS * (row) + OFF_COM2H])
  858. /* TScreen-level macros */
  859. #define SCRN_BUF_FLAGS(screen, row) BUF_FLAGS(screen->visbuf, row)
  860. #define SCRN_BUF_CHARS(screen, row) BUF_CHARS(screen->visbuf, row)
  861. #define SCRN_BUF_ATTRS(screen, row) BUF_ATTRS(screen->visbuf, row)
  862. #define SCRN_BUF_COLOR(screen, row) BUF_COLOR(screen->visbuf, row)
  863. #define SCRN_BUF_FGRND(screen, row) BUF_FGRND(screen->visbuf, row)
  864. #define SCRN_BUF_BGRND(screen, row) BUF_BGRND(screen->visbuf, row)
  865. #define SCRN_BUF_CSETS(screen, row) BUF_CSETS(screen->visbuf, row)
  866. #define SCRN_BUF_WIDEC(screen, row) BUF_WIDEC(screen->visbuf, row)
  867. #define SCRN_BUF_COM1L(screen, row) BUF_COM1L(screen->visbuf, row)
  868. #define SCRN_BUF_COM2L(screen, row) BUF_COM2L(screen->visbuf, row)
  869. #define SCRN_BUF_COM1H(screen, row) BUF_COM1H(screen->visbuf, row)
  870. #define SCRN_BUF_COM2H(screen, row) BUF_COM2H(screen->visbuf, row)
  871. typedef struct {
  872. unsigned chrset;
  873. unsigned flags;
  874. XFontStruct * fs;
  875. GC gc;
  876. char * fn;
  877. } XTermFonts;
  878. typedef struct {
  879. int top;
  880. int left;
  881. int bottom;
  882. int right;
  883. } XTermRect;
  884. /* indices into save_modes[] */
  885. typedef enum {
  886. DP_CRS_VISIBLE,
  887. DP_DECANM,
  888. DP_DECARM,
  889. DP_DECAWM,
  890. DP_DECBKM,
  891. DP_DECCKM,
  892. DP_DECCOLM, /* IN132COLUMNS */
  893. DP_DECOM,
  894. DP_DECPEX,
  895. DP_DECPFF,
  896. DP_DECSCLM,
  897. DP_DECSCNM,
  898. DP_DECTCEM,
  899. DP_DECTEK,
  900. DP_PRN_EXTENT,
  901. DP_PRN_FORMFEED,
  902. DP_X_ALTSCRN,
  903. DP_X_DECCOLM,
  904. DP_X_LOGGING,
  905. DP_X_MARGIN,
  906. DP_X_MORE,
  907. DP_X_MOUSE,
  908. DP_X_REVWRAP,
  909. DP_X_X10MSE,
  910. #if OPT_BLINK_CURS
  911. DP_CRS_BLINK,
  912. #endif
  913. #if OPT_TOOLBAR
  914. DP_TOOLBAR,
  915. #endif
  916. DP_LAST
  917. } SaveModes;
  918. #define DoSM(code,value) screen->save_modes[code] = value
  919. #define DoRM(code,value) value = screen->save_modes[code]
  920. /* index into vt_shell[] or tek_shell[] */
  921. typedef enum {
  922. noMenu = -1,
  923. mainMenu,
  924. vtMenu,
  925. fontMenu,
  926. tekMenu
  927. } MenuIndex;
  928. #define NUM_POPUP_MENUS 4
  929. #if OPT_COLOR_RES
  930. typedef struct {
  931. String resource;
  932. Pixel value;
  933. int mode;
  934. } ColorRes;
  935. #else
  936. #define ColorRes Pixel
  937. #endif
  938. typedef struct {
  939. unsigned which; /* must have NCOLORS bits */
  940. Pixel colors[NCOLORS];
  941. char *names[NCOLORS];
  942. } ScrnColors;
  943. typedef struct {
  944. Boolean saved;
  945. int row;
  946. int col;
  947. unsigned flags; /* VTxxx saves graphics rendition */
  948. char curgl;
  949. char curgr;
  950. char gsets[4];
  951. #if OPT_ISO_COLORS
  952. int cur_foreground; /* current foreground color */
  953. int cur_background; /* current background color */
  954. int sgr_foreground; /* current SGR foreground color */
  955. int sgr_background; /* current SGR background color */
  956. Boolean sgr_extended; /* SGR set with extended codes? */
  957. #endif
  958. } SavedCursor;
  959. typedef struct {
  960. int width; /* if > 0, width of scrollbar, */
  961. /* and scrollbar is showing */
  962. Boolean rv_cached; /* see ScrollBarReverseVideo */
  963. int rv_active; /* ...current reverse-video */
  964. Pixel bg; /* ...cached background color */
  965. Pixel fg; /* ...cached foreground color */
  966. Pixel bdr; /* ...cached border color */
  967. Pixmap bdpix; /* ...cached border pixmap */
  968. } SbInfo;
  969. #if OPT_TOOLBAR
  970. typedef struct {
  971. Widget menu_bar; /* toolbar, if initialized */
  972. Dimension menu_height; /* ...and its height */
  973. Dimension menu_border; /* ...and its border */
  974. } TbInfo;
  975. #define VT100_TB_INFO(name) screen.fullVwin.tb_info.name
  976. #endif
  977. struct _vtwin {
  978. Window window; /* X window id */
  979. int width; /* width of columns */
  980. int height; /* height of rows */
  981. Dimension fullwidth; /* full width of window */
  982. Dimension fullheight; /* full height of window */
  983. int f_width; /* width of fonts in pixels */
  984. int f_height; /* height of fonts in pixels */
  985. int f_ascent; /* ascent of font in pixels */
  986. int f_descent; /* descent of font in pixels */
  987. SbInfo sb_info;
  988. GC normalGC; /* normal painting */
  989. GC reverseGC; /* reverse painting */
  990. GC normalboldGC; /* normal painting, bold font */
  991. GC reverseboldGC; /* reverse painting, bold font */
  992. #if OPT_TOOLBAR
  993. Boolean active; /* true if toolbars are used */
  994. TbInfo tb_info; /* toolbar information */
  995. #endif
  996. };
  997. struct _tekwin {
  998. Window window; /* X window id */
  999. int width; /* width of columns */
  1000. int height; /* height of rows */
  1001. Dimension fullwidth; /* full width of window */
  1002. Dimension fullheight; /* full height of window */
  1003. double tekscale; /* scale factor Tek -> vs100 */
  1004. };
  1005. typedef struct {
  1006. /* These parameters apply to both windows */
  1007. Display *display; /* X display for screen */
  1008. int respond; /* socket for responses
  1009. (position report, etc.) */
  1010. #if OPT_TCAP_QUERY
  1011. int tc_query;
  1012. #endif
  1013. pid_t pid; /* pid of process on far side */
  1014. uid_t uid; /* user id of actual person */
  1015. gid_t gid; /* group id of actual person */
  1016. GC cursorGC; /* normal cursor painting */
  1017. GC fillCursorGC; /* special cursor painting */
  1018. GC reversecursorGC;/* reverse cursor painting */
  1019. GC cursoroutlineGC;/* for painting lines around */
  1020. ColorRes Tcolors[NCOLORS]; /* terminal colors */
  1021. #if OPT_ISO_COLORS
  1022. ColorRes Acolors[MAXCOLORS]; /* ANSI color emulation */
  1023. int veryBoldColors; /* modifier for boldColors */
  1024. Boolean boldColors; /* can we make bold colors? */
  1025. Boolean colorMode; /* are we using color mode? */
  1026. Boolean colorULMode; /* use color for underline? */
  1027. Boolean italicULMode; /* italic font for underline? */
  1028. Boolean colorBDMode; /* use color for bold? */
  1029. Boolean colorBLMode; /* use color for blink? */
  1030. Boolean colorRVMode; /* use color for reverse? */
  1031. Boolean colorAttrMode; /* prefer colorUL/BD to SGR */
  1032. #endif
  1033. #if OPT_DEC_CHRSET
  1034. Boolean font_doublesize;/* enable font-scaling */
  1035. int cache_doublesize;/* limit of our cache */
  1036. Char cur_chrset; /* character-set index & code */
  1037. int fonts_used; /* count items in double_fonts */
  1038. XTermFonts double_fonts[NUM_CHRSET];
  1039. #endif
  1040. #if OPT_DEC_RECTOPS
  1041. int cur_decsace; /* parameter for DECSACE */
  1042. #endif
  1043. #if OPT_WIDE_CHARS
  1044. Boolean wide_chars; /* true when 16-bit chars */
  1045. Boolean vt100_graphics; /* true to allow vt100-graphics */
  1046. Boolean utf8_inparse; /* true to enable UTF-8 parser */
  1047. int utf8_mode; /* use UTF-8 decode/encode: 0-2 */
  1048. int latin9_mode; /* poor man's luit, latin9 */
  1049. int unicode_font; /* font uses unicode encoding */
  1050. int utf_count; /* state of utf_char */
  1051. IChar utf_char; /* in-progress character */
  1052. int last_written_col;
  1053. int last_written_row;
  1054. #endif
  1055. #if OPT_BROKEN_OSC
  1056. Boolean brokenLinuxOSC; /* true to ignore Linux palette ctls */
  1057. #endif
  1058. #if OPT_BROKEN_ST
  1059. Boolean brokenStringTerm; /* true to match old OSC parse */
  1060. #endif
  1061. #if OPT_C1_PRINT
  1062. Boolean c1_printable; /* true if we treat C1 as print */
  1063. #endif
  1064. int border; /* inner border */
  1065. int scrollBarBorder; /* scrollBar border */
  1066. Cursor arrow; /* arrow cursor */
  1067. unsigned long event_mask;
  1068. unsigned short send_mouse_pos; /* user wants mouse transition */
  1069. /* and position information */
  1070. #if OPT_PASTE64
  1071. int base64_paste; /* set to send paste in base64 */
  1072. /* _qWriteSelectionData expects these to be initialized to zero.
  1073. * base64_flush() is the last step of the conversion, it clears these
  1074. * variables.
  1075. */
  1076. int base64_accu;
  1077. int base64_count;
  1078. int base64_pad;
  1079. #endif
  1080. #if OPT_READLINE
  1081. unsigned click1_moves;
  1082. unsigned paste_moves;
  1083. unsigned dclick3_deletes;
  1084. unsigned paste_brackets;
  1085. unsigned paste_quotes;
  1086. unsigned paste_literal_nl;
  1087. #endif /* OPT_READLINE */
  1088. #if OPT_DEC_LOCATOR
  1089. Boolean locator_reset; /* turn mouse off after 1 report? */
  1090. Boolean locator_pixels; /* report in pixels? */
  1091. /* if false, report in cells */
  1092. unsigned short locator_events; /* what events to report */
  1093. Boolean loc_filter; /* is filter rectangle active? */
  1094. int loc_filter_top; /* filter rectangle for DEC Locator */
  1095. int loc_filter_left;
  1096. int loc_filter_bottom;
  1097. int loc_filter_right;
  1098. #endif /* OPT_DEC_LOCATOR */
  1099. int mouse_button; /* current button pressed */
  1100. int mouse_row; /* ...and its row */
  1101. int mouse_col; /* ...and its column */
  1102. int select; /* xterm selected */
  1103. Boolean bellOnReset; /* bellOnReset */
  1104. Boolean visualbell; /* visual bell mode */
  1105. Boolean poponbell; /* pop on bell mode */
  1106. Boolean allowSendEvents;/* SendEvent mode */
  1107. Boolean allowWindowOps; /* WindowOps mode */
  1108. Boolean allowSendEvent0;/* initial SendEvent mode */
  1109. Boolean allowWindowOp0; /* initial WindowOps mode */
  1110. Boolean awaitInput; /* select-timeout mode */
  1111. Boolean grabbedKbd; /* keyboard is grabbed */
  1112. #ifdef ALLOWLOGGING
  1113. int logging; /* logging mode */
  1114. int logfd; /* file descriptor of log */
  1115. char *logfile; /* log file name */
  1116. Char *logstart; /* current start of log buffer */
  1117. #endif
  1118. int inhibit; /* flags for inhibiting changes */
  1119. /* VT window parameters */
  1120. Boolean Vshow; /* VT window showing */
  1121. struct _vtwin fullVwin;
  1122. #ifndef NO_ACTIVE_ICON
  1123. struct _vtwin iconVwin;
  1124. struct _vtwin * whichVwin;
  1125. #endif /* NO_ACTIVE_ICON */
  1126. Cursor pointer_cursor; /* pointer cursor in window */
  1127. String answer_back; /* response to ENQ */
  1128. String printer_command; /* pipe/shell command string */
  1129. Boolean printer_autoclose; /* close printer when offline */
  1130. Boolean printer_extent; /* print complete page */
  1131. Boolean printer_formfeed; /* print formfeed per function */
  1132. int printer_controlmode; /* 0=off, 1=auto, 2=controller */
  1133. int print_attributes; /* 0=off, 1=normal, 2=color */
  1134. Boolean fnt_prop; /* true if proportional fonts */
  1135. Boolean fnt_boxes; /* true if font has box-chars */
  1136. #if OPT_BOX_CHARS
  1137. Boolean force_box_chars;/* true if we assume that */
  1138. Boolean force_all_chars;/* true to outline missing chars*/
  1139. #endif
  1140. Dimension fnt_wide;
  1141. Dimension fnt_high;
  1142. XFontStruct *fnt_norm; /* normal font of terminal */
  1143. XFontStruct *fnt_bold; /* bold font of terminal */
  1144. Boolean free_bold_box; /* same_font_size's austerity */
  1145. #if OPT_WIDE_CHARS
  1146. XFontStruct *fnt_dwd; /* wide font of terminal */
  1147. XFontStruct *fnt_dwdb; /* wide bold font of terminal */
  1148. #endif
  1149. #ifndef NO_ACTIVE_ICON
  1150. XFontStruct *fnt_icon; /* icon font */
  1151. #endif /* NO_ACTIVE_ICON */
  1152. int enbolden; /* overstrike for bold font */
  1153. XPoint *box; /* draw unselected cursor */
  1154. int cursor_state; /* ON, OFF, or BLINKED_OFF */
  1155. int cursor_busy; /* do not redraw... */
  1156. #if OPT_BLINK_CURS
  1157. Boolean cursor_blink; /* cursor blink enable */
  1158. Boolean cursor_blink_res; /* initial cursor blink value */
  1159. Boolean cursor_blink_esc; /* cursor blink escape-state */
  1160. #endif
  1161. #if OPT_BLINK_TEXT
  1162. Boolean blink_as_bold; /* text blink disable */
  1163. #endif
  1164. #if OPT_BLINK_CURS || OPT_BLINK_TEXT
  1165. int blink_state; /* ON, OFF, or BLINKED_OFF */
  1166. int blink_on; /* cursor on time (msecs) */
  1167. int blink_off; /* cursor off time (msecs) */
  1168. XtIntervalId blink_timer; /* timer-id for cursor-proc */
  1169. #endif
  1170. int cursor_GC; /* see ShowCursor() */
  1171. int cursor_set; /* requested state */
  1172. int cursor_col; /* previous cursor column */
  1173. int cursor_row; /* previous cursor row */
  1174. Boolean cursor_moved; /* scrolling makes cursor move */
  1175. int cur_col; /* current cursor column */
  1176. int cur_row; /* current cursor row */
  1177. int max_col; /* rightmost column */
  1178. int max_row; /* bottom row */
  1179. int top_marg; /* top line of scrolling region */
  1180. int bot_marg; /* bottom line of " " */
  1181. Widget scrollWidget; /* pointer to scrollbar struct */
  1182. int topline; /* line number of top, <= 0 */
  1183. int savedlines; /* number of lines that've been saved */
  1184. int savelines; /* number of lines off top to save */
  1185. int scrolllines; /* number of lines to button scroll */
  1186. Boolean scrollttyoutput; /* scroll to bottom on tty output */
  1187. Boolean scrollkey; /* scroll to bottom on key */
  1188. ScrnBuf visbuf; /* ptr to visible screen buf (main) */
  1189. ScrnBuf allbuf; /* screen buffer (may include
  1190. lines scrolled off top) */
  1191. Char *sbuf_address; /* main screen memory address */
  1192. ScrnBuf altbuf; /* alternate screen buffer */
  1193. Char *abuf_address; /* alternate screen memory address */
  1194. Char **save_ptr; /* workspace for save-pointers */
  1195. size_t save_len; /* ...and its length */
  1196. Boolean alternate; /* true if using alternate buf */
  1197. unsigned short do_wrap; /* true if cursor in last column
  1198. and character just output */
  1199. int incopy; /* 0 idle; 1 XCopyArea issued;
  1200. -1 first GraphicsExpose seen,
  1201. but last not seen */
  1202. int copy_src_x; /* params from last XCopyArea ... */
  1203. int copy_src_y;
  1204. unsigned int copy_width;
  1205. unsigned int copy_height;
  1206. int copy_dest_x;
  1207. int copy_dest_y;
  1208. Boolean c132; /* allow change to 132 columns */
  1209. Boolean curses; /* kludge line wrap for more */
  1210. Boolean hp_ll_bc; /* kludge HP-style ll for xdb */
  1211. Boolean marginbell; /* true if margin bell on */
  1212. int nmarginbell; /* columns from right margin */
  1213. int bellarmed; /* cursor below bell margin */
  1214. Boolean multiscroll; /* true if multi-scroll */
  1215. int scrolls; /* outstanding scroll count,
  1216. used only with multiscroll */
  1217. SavedCursor sc[2]; /* data for restore cursor */
  1218. unsigned char save_modes[DP_LAST]; /* save dec/xterm private modes */
  1219. /* Improved VT100 emulation stuff. */
  1220. String keyboard_dialect; /* default keyboard dialect */
  1221. char gsets[4]; /* G0 through G3. */
  1222. Char curgl; /* Current GL setting. */
  1223. Char curgr; /* Current GR setting. */
  1224. Char curss; /* Current single shift. */
  1225. String term_id; /* resource for terminal_id */
  1226. int terminal_id; /* 100=vt100, 220=vt220, etc. */
  1227. int vtXX_level; /* 0=vt52, 1,2,3 = vt100 ... vt320 */
  1228. int ansi_level; /* levels 1,2,3 */
  1229. int scroll_amt; /* amount to scroll */
  1230. int refresh_amt; /* amount to refresh */
  1231. int protected_mode; /* 0=off, 1=DEC, 2=ISO */
  1232. Boolean old_fkeys; /* true for compatible fkeys */
  1233. Boolean delete_is_del; /* true for compatible Delete key */
  1234. Boolean jumpscroll; /* whether we should jumpscroll */
  1235. Boolean always_highlight; /* whether to highlight cursor */
  1236. Boolean underline; /* whether to underline text */
  1237. Boolean bold_mode; /* whether to use bold font */
  1238. #if OPT_MAXIMIZE
  1239. Boolean restore_data;
  1240. int restore_x;
  1241. int restore_y;
  1242. unsigned restore_width;
  1243. unsigned restore_height;
  1244. #endif
  1245. #if OPT_VT52_MODE
  1246. int vt52_save_level; /* save-area for DECANM */
  1247. char vt52_save_curgl;
  1248. char vt52_save_curgr;
  1249. char vt52_save_curss;
  1250. char vt52_save_gsets[4];
  1251. #endif
  1252. /* Testing */
  1253. #if OPT_XMC_GLITCH
  1254. unsigned xmc_glitch; /* # of spaces to pad on SGR's */
  1255. int xmc_attributes; /* attrs that make a glitch */
  1256. Boolean xmc_inline; /* SGR's propagate only to eol */
  1257. Boolean move_sgr_ok; /* SGR is reset on move */
  1258. #endif
  1259. #if OPT_TEK4014
  1260. /* Tektronix window parameters */
  1261. GC TnormalGC; /* normal painting */
  1262. GC TcursorGC; /* normal cursor painting */
  1263. Boolean Tshow; /* Tek window showing */
  1264. Boolean waitrefresh; /* postpone refresh */
  1265. struct _tekwin fullTwin;
  1266. #ifndef NO_ACTIVE_ICON
  1267. struct _tekwin iconTwin;
  1268. struct _tekwin *whichTwin;
  1269. #endif /* NO_ACTIVE_ICON */
  1270. GC linepat[TEKNUMLINES]; /* line patterns */
  1271. Boolean TekEmu; /* true if Tektronix emulation */
  1272. int cur_X; /* current x */
  1273. int cur_Y; /* current y */
  1274. Tmodes cur; /* current tek modes */
  1275. Tmodes page; /* starting tek modes on page */
  1276. int margin; /* 0 -> margin 1, 1 -> margin 2 */
  1277. int pen; /* current Tektronix pen 0=up, 1=dn */
  1278. char *TekGIN; /* nonzero if Tektronix GIN mode*/
  1279. int gin_terminator; /* Tek strap option */
  1280. #endif /* OPT_TEK4014 */
  1281. int multiClickTime; /* time between multiclick selects */
  1282. int visualBellDelay; /* msecs to delay for visibleBell */
  1283. int bellSuppressTime; /* msecs after Bell before another allowed */
  1284. Boolean bellInProgress; /* still ringing/flashing prev bell? */
  1285. char *charClass; /* for overriding word selection */
  1286. Boolean cutNewline; /* whether or not line cut has \n */
  1287. Boolean cutToBeginningOfLine; /* line cuts to BOL? */
  1288. Boolean highlight_selection; /* controls appearance of selection */
  1289. Boolean trim_selection; /* controls trimming of selection */
  1290. Boolean i18nSelections;
  1291. Boolean brokenSelections;
  1292. Char *selection_data; /* the current selection */
  1293. int selection_size; /* size of allocated buffer */
  1294. int selection_length; /* number of significant bytes */
  1295. Time selection_time; /* latest event timestamp */
  1296. int startHRow, startHCol, /* highlighted text */
  1297. endHRow, endHCol,
  1298. startHCoord, endHCoord;
  1299. Atom* selection_atoms; /* which selections we own */
  1300. Cardinal sel_atoms_size; /* how many atoms allocated */
  1301. Cardinal selection_count; /* how many atoms in use */
  1302. Boolean input_eight_bits;/* use 8th bit instead of ESC prefix */
  1303. Boolean output_eight_bits; /* honor all bits or strip */
  1304. Boolean control_eight_bits; /* send CSI as 8-bits */
  1305. Boolean backarrow_key; /* backspace/delete */
  1306. Boolean meta_sends_esc; /* Meta-key sends ESC prefix */
  1307. Pixmap menu_item_bitmap; /* mask for checking items */
  1308. String menu_font_names[NMENUFONTS][fMAX];
  1309. #define MenuFontName(n) menu_font_names[n][fNorm]
  1310. long menu_font_sizes[NMENUFONTS];
  1311. int menu_font_number;
  1312. #if OPT_RENDERFONT
  1313. XftFont * renderFontNorm[NMENUFONTS];
  1314. XftFont * renderFontBold[NMENUFONTS];
  1315. XftFont * renderFontItal[NMENUFONTS];
  1316. XftFont * renderWideNorm[NMENUFONTS];
  1317. XftFont * renderWideBold[NMENUFONTS];
  1318. XftFont * renderWideItal[NMENUFONTS];
  1319. XftDraw * renderDraw;
  1320. #endif
  1321. #if OPT_INPUT_METHOD
  1322. XIM xim;
  1323. XFontSet fs; /* fontset for XIM preedit */
  1324. int fs_ascent; /* ascent of fs */
  1325. #endif
  1326. XIC xic; /* this is used even without XIM */
  1327. #if OPT_DABBREV
  1328. int dabbrev_working; /* nonzero during dabbrev process */
  1329. unsigned char dabbrev_erase_char; /* used for deleting inserted completion */
  1330. #endif
  1331. } TScreen;
  1332. typedef struct _TekPart {
  1333. XFontStruct * Tfont[TEKNUMFONTS];
  1334. int tobaseline[TEKNUMFONTS]; /* top-baseline, each font */
  1335. char * initial_font; /* large, 2, 3, small */
  1336. char * gin_terminator_str; /* ginTerminator resource */
  1337. #if OPT_TOOLBAR
  1338. TbInfo tb_info; /* toolbar information */
  1339. #endif
  1340. } TekPart;
  1341. #if OPT_READLINE
  1342. #define SCREEN_FLAG(screenp,f) (1&(screenp)->f)
  1343. #define SCREEN_FLAG_set(screenp,f) ((screenp)->f |= 1)
  1344. #define SCREEN_FLAG_unset(screenp,f) ((screenp)->f &= ~1L)
  1345. #define SCREEN_FLAG_save(screenp,f) \
  1346. ((screenp)->f = (((screenp)->f)<<1) | SCREEN_FLAG(screenp,f))
  1347. #define SCREEN_FLAG_restore(screenp,f) ((screenp)->f = (((screenp)->f)>>1))
  1348. #else
  1349. #define SCREEN_FLAG(screenp,f) (0)
  1350. #endif
  1351. /* meaning of bits in screen.select flag */
  1352. #define INWINDOW 01 /* the mouse is in one of the windows */
  1353. #define FOCUS 02 /* one of the windows is the focus window */
  1354. #define MULTICLICKTIME 250 /* milliseconds */
  1355. typedef enum {
  1356. keyboardIsLegacy, /* bogus vt220 codes for F1-F4, etc. */
  1357. keyboardIsDefault,
  1358. keyboardIsHP,
  1359. keyboardIsSCO,
  1360. keyboardIsSun,
  1361. keyboardIsVT220
  1362. } xtermKeyboardType;
  1363. typedef enum { /* legal values for screen.utf8_mode */
  1364. uFalse = 0,
  1365. uTrue = 1,
  1366. uAlways = 2,
  1367. uDefault = 3
  1368. } utf8ModeTypes;
  1369. #if OPT_HP_FUNC_KEYS
  1370. #define NAME_HP_KT " hp"
  1371. #else
  1372. #define NAME_HP_KT /*nothing*/
  1373. #endif
  1374. #if OPT_SCO_FUNC_KEYS
  1375. #define NAME_SCO_KT " sco"
  1376. #else
  1377. #define NAME_SCO_KT /*nothing*/
  1378. #endif
  1379. #define NAME_SUN_KT " sun"
  1380. #if OPT_SUNPC_KBD
  1381. #define NAME_VT220_KT " vt220"
  1382. #else
  1383. #define NAME_VT220_KT /*nothing*/
  1384. #endif
  1385. #define KEYBOARD_TYPES NAME_HP_KT NAME_SCO_KT NAME_SUN_KT NAME_VT220_KT
  1386. #if OPT_TRACE
  1387. extern const char * visibleKeyboardType(xtermKeyboardType);
  1388. #endif
  1389. typedef struct
  1390. {
  1391. xtermKeyboardType type;
  1392. unsigned flags;
  1393. #if OPT_INITIAL_ERASE
  1394. int reset_DECBKM; /* reset should set DECBKM */
  1395. #endif
  1396. int modify_cursor_keys; /* how to handle modifiers */
  1397. } TKeyboard;
  1398. typedef struct {
  1399. char *f_n; /* the normal font */
  1400. char *f_b; /* the bold font */
  1401. #if OPT_WIDE_CHARS
  1402. char *f_w; /* the normal wide font */
  1403. char *f_wb; /* the bold wide font */
  1404. #endif
  1405. } VTFontNames;
  1406. typedef struct _Misc {
  1407. VTFontNames default_font;
  1408. char *geo_metry;
  1409. char *T_geometry;
  1410. #if OPT_WIDE_CHARS
  1411. Boolean cjk_width; /* true for built-in CJK wcwidth() */
  1412. Boolean mk_width; /* true for simpler built-in wcwidth() */
  1413. #endif
  1414. #if OPT_LUIT_PROG
  1415. Boolean callfilter; /* true to invoke luit */
  1416. Boolean use_encoding; /* true to use -encoding option for luit */
  1417. char *locale_str; /* "locale" resource */
  1418. char *localefilter; /* path for luit */
  1419. #endif
  1420. #if OPT_INPUT_METHOD
  1421. char *f_x; /* font for XIM */
  1422. #endif
  1423. int limit_resize;
  1424. #ifdef ALLOWLOGGING
  1425. Boolean log_on;
  1426. #endif
  1427. Boolean login_shell;
  1428. Boolean re_verse;
  1429. Boolean re_verse0; /* initial value of "-rv" */
  1430. XtGravity resizeGravity;
  1431. Boolean reverseWrap;
  1432. Boolean autoWrap;
  1433. Boolean logInhibit;
  1434. Boolean signalInhibit;
  1435. #if OPT_TEK4014
  1436. Boolean tekInhibit;
  1437. Boolean tekSmall; /* start tek window in small size */
  1438. #endif
  1439. Boolean scrollbar;
  1440. #ifdef SCROLLBAR_RIGHT
  1441. Boolean useRight;
  1442. #endif
  1443. Boolean titeInhibit;
  1444. Boolean tiXtraScroll;
  1445. Boolean appcursorDefault;
  1446. Boolean appkeypadDefault;
  1447. #if OPT_INPUT_METHOD
  1448. char* input_method;
  1449. char* preedit_type;
  1450. Boolean open_im;
  1451. Boolean cannot_im; /* true if we cannot use input-method */
  1452. #endif
  1453. Boolean dynamicColors;
  1454. Boolean shared_ic;
  1455. #ifndef NO_ACTIVE_ICON
  1456. Boolean active_icon; /* use application icon window */
  1457. unsigned icon_border_width;
  1458. Pixel icon_border_pixel;
  1459. #endif /* NO_ACTIVE_ICON */
  1460. #if OPT_DEC_SOFTFONT

Large files files are truncated, but you can click here to view the full file