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