ptyx.h revision 636d5e9f
1636d5e9fSmrg/* $XTermId: ptyx.h,v 1.1032 2021/06/07 19:29:11 tom Exp $ */
2d522f475Smrg
3d522f475Smrg/*
48f44fb3bSmrg * Copyright 1999-2020,2021 by Thomas E. Dickey
5d522f475Smrg *
6d522f475Smrg *                         All Rights Reserved
7d522f475Smrg *
8d522f475Smrg * Permission is hereby granted, free of charge, to any person obtaining a
9d522f475Smrg * copy of this software and associated documentation files (the
10d522f475Smrg * "Software"), to deal in the Software without restriction, including
11d522f475Smrg * without limitation the rights to use, copy, modify, merge, publish,
12d522f475Smrg * distribute, sublicense, and/or sell copies of the Software, and to
13d522f475Smrg * permit persons to whom the Software is furnished to do so, subject to
14d522f475Smrg * the following conditions:
15d522f475Smrg *
16d522f475Smrg * The above copyright notice and this permission notice shall be included
17d522f475Smrg * in all copies or substantial portions of the Software.
18d522f475Smrg *
19d522f475Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20d522f475Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21d522f475Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22d522f475Smrg * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
23d522f475Smrg * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24d522f475Smrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25d522f475Smrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26d522f475Smrg *
27d522f475Smrg * Except as contained in this notice, the name(s) of the above copyright
28d522f475Smrg * holders shall not be used in advertising or otherwise to promote the
29d522f475Smrg * sale, use or other dealings in this Software without prior written
30d522f475Smrg * authorization.
31d522f475Smrg *
32d522f475Smrg *
33d522f475Smrg * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
34d522f475Smrg *
35d522f475Smrg *                         All Rights Reserved
36d522f475Smrg *
37d522f475Smrg * Permission to use, copy, modify, and distribute this software and its
38d522f475Smrg * documentation for any purpose and without fee is hereby granted,
39d522f475Smrg * provided that the above copyright notice appear in all copies and that
40d522f475Smrg * both that copyright notice and this permission notice appear in
41d522f475Smrg * supporting documentation, and that the name of Digital Equipment
42d522f475Smrg * Corporation not be used in advertising or publicity pertaining to
43d522f475Smrg * distribution of the software without specific, written prior permission.
44d522f475Smrg *
45d522f475Smrg *
46d522f475Smrg * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
47d522f475Smrg * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
48d522f475Smrg * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
49d522f475Smrg * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
50d522f475Smrg * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
51d522f475Smrg * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
52d522f475Smrg * SOFTWARE.
53d522f475Smrg */
54d522f475Smrg
55d522f475Smrg#ifndef included_ptyx_h
56d522f475Smrg#define included_ptyx_h 1
57d522f475Smrg
58d522f475Smrg#ifdef HAVE_CONFIG_H
59d522f475Smrg#include <xtermcfg.h>
60d522f475Smrg#endif
61d522f475Smrg
62d522f475Smrg/* ptyx.h */
63c219fbebSmrg/* *INDENT-OFF* */
64d522f475Smrg/* @(#)ptyx.h	X10/6.6	11/10/86 */
65d522f475Smrg
66d522f475Smrg#include <X11/IntrinsicP.h>
67d522f475Smrg#include <X11/Shell.h>		/* for XtNdieCallback, etc. */
68d522f475Smrg#include <X11/StringDefs.h>	/* for standard resource names */
69d522f475Smrg#include <X11/Xmu/Misc.h>	/* For Max() and Min(). */
708f44fb3bSmrg#include <X11/cursorfont.h>
718f44fb3bSmrg
723367019cSmrg
733367019cSmrg#undef bcopy
743367019cSmrg#undef bzero
75d522f475Smrg#include <X11/Xfuncs.h>
763367019cSmrg
77d522f475Smrg#include <X11/Xosdefs.h>
78d522f475Smrg#include <X11/Xmu/Converters.h>
79d522f475Smrg#ifdef XRENDERFONT
80d522f475Smrg#include <X11/Xft/Xft.h>
81d522f475Smrg#endif
82d522f475Smrg
83712a7ff4Smrg#include <stdio.h>
84712a7ff4Smrg
85d4fba8b9Smrg#if defined(HAVE_STDINT_H) || !defined(HAVE_CONFIG_H)
86fa3f02f3Smrg#include <stdint.h>
87fa3f02f3Smrg#define DECONST(type,s) ((type *)(intptr_t)(const type *)(s))
88fa3f02f3Smrg#else
89fa3f02f3Smrg#define DECONST(type,s) ((type *)(s))
90fa3f02f3Smrg#endif
91fa3f02f3Smrg
92d522f475Smrg/* adapted from IntrinsicI.h */
93d522f475Smrg#define MyStackAlloc(size, stack_cache_array)     \
94d522f475Smrg    ((size) <= sizeof(stack_cache_array)	  \
95d522f475Smrg    ?  (XtPointer)(stack_cache_array)		  \
96cd3331d0Smrg    :  (XtPointer)malloc((size_t)(size)))
97d522f475Smrg
98d522f475Smrg#define MyStackFree(pointer, stack_cache_array) \
99d522f475Smrg    if ((pointer) != ((char *)(stack_cache_array))) free(pointer)
100d522f475Smrg
101d522f475Smrg/* adapted from vile (vi-like-emacs) */
102cd3331d0Smrg#define TypeCallocN(type,n)	(type *)calloc((size_t) (n), sizeof(type))
103cd3331d0Smrg#define TypeCalloc(type)	TypeCallocN(type, 1)
104d522f475Smrg
105cd3331d0Smrg#define TypeMallocN(type,n)	(type *)malloc(sizeof(type) * (size_t) (n))
106cd3331d0Smrg#define TypeMalloc(type)	TypeMallocN(type, 1)
107d522f475Smrg
108d522f475Smrg#define TypeRealloc(type,n,p)	(type *)realloc(p, (n) * sizeof(type))
109d522f475Smrg
110c219fbebSmrg#define TypeXtReallocN(t,p,n)	(t *)(void *)XtRealloc((char *)(p), (Cardinal)(sizeof(t) * (size_t) (n)))
111c219fbebSmrg
112c219fbebSmrg#define TypeXtMallocX(type,n)	(type *)(void *)XtMalloc((Cardinal)(sizeof(type) + (size_t) (n)))
113c219fbebSmrg#define TypeXtMallocN(type,n)	(type *)(void *)XtMalloc((Cardinal)(sizeof(type) * (size_t) (n)))
114c219fbebSmrg#define TypeXtMalloc(type)	TypeXtMallocN(type, 1)
115c219fbebSmrg
116dfb07bc7Smrg#define CastMalloc(type)	(type *)malloc(sizeof(type))
117d522f475Smrg
118b7c89284Ssnj#define BumpBuffer(type, buffer, size, want) \
119b7c89284Ssnj	if (want >= size) { \
120b7c89284Ssnj	    size = 1 + (want * 2); \
121b7c89284Ssnj	    buffer = TypeRealloc(type, size, buffer); \
122b7c89284Ssnj	}
123b7c89284Ssnj
124b7c89284Ssnj#define BfBuf(type) screen->bf_buf_##type
125b7c89284Ssnj#define BfLen(type) screen->bf_len_##type
126b7c89284Ssnj
127b7c89284Ssnj#define TypedBuffer(type) \
128b7c89284Ssnj	type		*bf_buf_##type; \
129b7c89284Ssnj	Cardinal	bf_len_##type
130b7c89284Ssnj
131b7c89284Ssnj#define BumpTypedBuffer(type, want) \
132b7c89284Ssnj	BumpBuffer(type, BfBuf(type), BfLen(type), want)
133b7c89284Ssnj
134b7c89284Ssnj#define FreeTypedBuffer(type) \
135d4fba8b9Smrg	do { \
136d4fba8b9Smrg	    FreeAndNull(BfBuf(type)); \
137d4fba8b9Smrg	    BfLen(type) = 0; \
138d4fba8b9Smrg	} while (0)
139d4fba8b9Smrg
140d4fba8b9Smrg#define FreeAndNull(value) \
141d4fba8b9Smrg	do { \
142d4fba8b9Smrg	    free((void *)(value)); \
143d4fba8b9Smrg	    value = NULL; \
144d4fba8b9Smrg	} while (0)
145b7c89284Ssnj
146d522f475Smrg/*
147d522f475Smrg** System V definitions
148d522f475Smrg*/
149d522f475Smrg
150d522f475Smrg#ifdef att
151d522f475Smrg#define ATT
152d522f475Smrg#endif
153d522f475Smrg
154d522f475Smrg#ifdef SVR4
155d522f475Smrg#undef  SYSV			/* predefined on Solaris 2.4 */
156d522f475Smrg#define SYSV			/* SVR4 is (approx) superset of SVR3 */
157d522f475Smrg#define ATT
158d522f475Smrg#endif
159d522f475Smrg
160d522f475Smrg#ifdef SYSV
161d522f475Smrg#ifdef X_NOT_POSIX
162d522f475Smrg#if !defined(CRAY) && !defined(SVR4)
163d522f475Smrg#define	dup2(fd1,fd2)	((fd1 == fd2) ? fd1 : \
164d522f475Smrg				(close(fd2), fcntl(fd1, F_DUPFD, fd2)))
165d522f475Smrg#endif
166d522f475Smrg#endif
167d522f475Smrg#endif /* SYSV */
168d522f475Smrg
169d522f475Smrg/*
170d522f475Smrg * Newer versions of <X11/Xft/Xft.h> have a version number.  We use certain
171d522f475Smrg * features from that.
172d522f475Smrg */
173d522f475Smrg#if defined(XRENDERFONT) && defined(XFT_VERSION) && XFT_VERSION >= 20100
174d522f475Smrg#define HAVE_TYPE_FCCHAR32	1	/* compatible: XftChar16 */
175d522f475Smrg#define HAVE_TYPE_XFTCHARSPEC	1	/* new type XftCharSpec */
176d522f475Smrg#endif
177d522f475Smrg
178d522f475Smrg/*
179d522f475Smrg** Definitions to simplify ifdef's for pty's.
180d522f475Smrg*/
181d522f475Smrg#define USE_PTY_DEVICE 1
182d522f475Smrg#define USE_PTY_SEARCH 1
183d522f475Smrg
184b7c89284Ssnj#if defined(__osf__) || (defined(linux) && defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
185d522f475Smrg#undef USE_PTY_DEVICE
186d522f475Smrg#undef USE_PTY_SEARCH
187d522f475Smrg#define USE_PTS_DEVICE 1
188d522f475Smrg#elif defined(VMS)
189d522f475Smrg#undef USE_PTY_DEVICE
190d522f475Smrg#undef USE_PTY_SEARCH
191d522f475Smrg#elif defined(PUCC_PTYD)
192d522f475Smrg#undef USE_PTY_SEARCH
193d522f475Smrg#elif (defined(sun) && defined(SVR4)) || defined(_ALL_SOURCE) || defined(__CYGWIN__)
194d522f475Smrg#undef USE_PTY_SEARCH
1953367019cSmrg#elif defined(__OpenBSD__)
1963367019cSmrg#undef USE_PTY_SEARCH
1973367019cSmrg#undef USE_PTY_DEVICE
198d522f475Smrg#endif
199d522f475Smrg
2003367019cSmrg#if (defined (__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1)))
2013367019cSmrg#define USE_HANDSHAKE 0	/* "recent" Linux systems do not require handshaking */
202d522f475Smrg#endif
203d522f475Smrg
204d522f475Smrg#if (defined (__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1)))
205d522f475Smrg#define USE_USG_PTYS
206d522f475Smrg#elif (defined(ATT) && !defined(__sgi)) || defined(__MVS__) || (defined(SYSV) && defined(i386))
207d522f475Smrg#define USE_USG_PTYS
208d522f475Smrg#endif
209d522f475Smrg
210d522f475Smrg/*
211d522f475Smrg * More systems than not require pty-handshaking.
212d522f475Smrg */
213d522f475Smrg#ifndef USE_HANDSHAKE
214d522f475Smrg#define USE_HANDSHAKE 1
215d522f475Smrg#endif
216d522f475Smrg
217d522f475Smrg/*
218d522f475Smrg** allow for mobility of the pty master/slave directories
219d522f475Smrg*/
220d522f475Smrg#ifndef PTYDEV
221d522f475Smrg#if defined(__hpux)
222d522f475Smrg#define	PTYDEV		"/dev/ptym/ptyxx"
223d522f475Smrg#elif defined(__MVS__)
224d522f475Smrg#define	PTYDEV		"/dev/ptypxxxx"
225d522f475Smrg#else
226d522f475Smrg#define	PTYDEV		"/dev/ptyxx"
227d522f475Smrg#endif
228d522f475Smrg#endif	/* !PTYDEV */
229d522f475Smrg
230d522f475Smrg#ifndef TTYDEV
231d522f475Smrg#if defined(__hpux)
232d522f475Smrg#define TTYDEV		"/dev/pty/ttyxx"
233d522f475Smrg#elif defined(__MVS__)
234d522f475Smrg#define TTYDEV		"/dev/ptypxxxx"
235d522f475Smrg#elif defined(USE_PTS_DEVICE)
236d522f475Smrg#define TTYDEV		"/dev/pts/0"
237d522f475Smrg#else
238d522f475Smrg#define	TTYDEV		"/dev/ttyxx"
239d522f475Smrg#endif
240d522f475Smrg#endif	/* !TTYDEV */
241d522f475Smrg
242d522f475Smrg#ifndef PTYCHAR1
243d522f475Smrg#ifdef __hpux
244d522f475Smrg#define PTYCHAR1	"zyxwvutsrqp"
245d522f475Smrg#else	/* !__hpux */
246d522f475Smrg#define	PTYCHAR1	"pqrstuvwxyzPQRSTUVWXYZ"
247d522f475Smrg#endif	/* !__hpux */
248d522f475Smrg#endif	/* !PTYCHAR1 */
249d522f475Smrg
250d522f475Smrg#ifndef PTYCHAR2
251d522f475Smrg#ifdef __hpux
252d522f475Smrg#define	PTYCHAR2	"fedcba9876543210"
253d522f475Smrg#else	/* !__hpux */
254d522f475Smrg#if defined(__DragonFly__) || defined(__FreeBSD__)
255d522f475Smrg#define	PTYCHAR2	"0123456789abcdefghijklmnopqrstuv"
256d522f475Smrg#else /* !__FreeBSD__ */
257d522f475Smrg#define	PTYCHAR2	"0123456789abcdef"
258d522f475Smrg#endif /* !__FreeBSD__ */
259d522f475Smrg#endif	/* !__hpux */
260d522f475Smrg#endif	/* !PTYCHAR2 */
261d522f475Smrg
262d522f475Smrg#ifndef TTYFORMAT
263d522f475Smrg#if defined(CRAY)
264d522f475Smrg#define TTYFORMAT "/dev/ttyp%03d"
265d522f475Smrg#elif defined(__MVS__)
266d522f475Smrg#define TTYFORMAT "/dev/ttyp%04d"
267d522f475Smrg#else
268d522f475Smrg#define TTYFORMAT "/dev/ttyp%d"
269d522f475Smrg#endif
270d522f475Smrg#endif /* TTYFORMAT */
271d522f475Smrg
272d522f475Smrg#ifndef PTYFORMAT
273d522f475Smrg#ifdef CRAY
274d522f475Smrg#define PTYFORMAT "/dev/pty/%03d"
275d522f475Smrg#elif defined(__MVS__)
276d522f475Smrg#define PTYFORMAT "/dev/ptyp%04d"
277d522f475Smrg#else
278d522f475Smrg#define PTYFORMAT "/dev/ptyp%d"
279d522f475Smrg#endif
280d522f475Smrg#endif /* PTYFORMAT */
281d522f475Smrg
282d522f475Smrg#ifndef PTYCHARLEN
283d522f475Smrg#ifdef CRAY
284d522f475Smrg#define PTYCHARLEN 3
285d522f475Smrg#elif defined(__MVS__)
286d522f475Smrg#define PTYCHARLEN 8     /* OS/390 stores, e.g. ut_id="ttyp1234"  */
287d522f475Smrg#else
288d522f475Smrg#define PTYCHARLEN 2
289d522f475Smrg#endif
290d522f475Smrg#endif
291d522f475Smrg
292d522f475Smrg#ifndef MAXPTTYS
293d522f475Smrg#ifdef CRAY
294d522f475Smrg#define MAXPTTYS 256
295d522f475Smrg#else
296d522f475Smrg#define MAXPTTYS 2048
297d522f475Smrg#endif
298d522f475Smrg#endif
299d522f475Smrg
300d522f475Smrg/* Until the translation manager comes along, I have to do my own translation of
301d522f475Smrg * mouse events into the proper routines. */
302d522f475Smrg
303d522f475Smrgtypedef enum {
304d522f475Smrg    NORMAL = 0
305d522f475Smrg    , LEFTEXTENSION
306d522f475Smrg    , RIGHTEXTENSION
307d522f475Smrg} EventMode;
308d522f475Smrg
309d522f475Smrg/*
310d522f475Smrg * The origin of a screen is 0, 0.  Therefore, the number of rows
311d522f475Smrg * on a screen is screen->max_row + 1, and similarly for columns.
312d522f475Smrg */
313d522f475Smrg#define MaxCols(screen)		((screen)->max_col + 1)
314d522f475Smrg#define MaxRows(screen)		((screen)->max_row + 1)
315d522f475Smrg
316d522f475Smrgtypedef unsigned char Char;		/* to support 8 bit chars */
317d522f475Smrgtypedef Char *ScrnPtr;
318d522f475Smrgtypedef ScrnPtr *ScrnBuf;
319d522f475Smrg
320cd3331d0Smrg/*
321cd3331d0Smrg * Declare an X String, but for unsigned chars.
322cd3331d0Smrg */
323cd3331d0Smrg#ifdef _CONST_X_STRING
324cd3331d0Smrgtypedef const Char *UString;
325cd3331d0Smrg#else
326cd3331d0Smrgtypedef Char *UString;
327cd3331d0Smrg#endif
328cd3331d0Smrg
329cd3331d0Smrg#define IsEmpty(s) ((s) == 0 || *(s) == '\0')
3309a64e1c5Smrg#define IsSpace(c) ((c) == ' ' || (c) == '\t' || (c) == '\r' || (c) == '\n')
331cd3331d0Smrg
332037a25ddSmrg/*
333037a25ddSmrg * Check strtol result, using "FullS2L" when no more data is expected, and
334037a25ddSmrg * "PartS2L" when more data may follow in the string.
335037a25ddSmrg */
336037a25ddSmrg#define FullS2L(s,d) (PartS2L(s,d) && (*(d) == '\0'))
337037a25ddSmrg#define PartS2L(s,d) (isdigit(CharOf(*(s))) && (d) != (s) && (d) != 0)
338037a25ddSmrg
339037a25ddSmrg#define CASETYPE(name) case name: result = #name; break
340037a25ddSmrg
341fa3f02f3Smrg#define CharOf(n) ((Char)(n))
342d522f475Smrg
343d522f475Smrgtypedef struct {
344d522f475Smrg    int row;
345d522f475Smrg    int col;
346d522f475Smrg} CELL;
347d522f475Smrg
348d4fba8b9Smrgtypedef struct {
349d4fba8b9Smrg    Char  *data_buffer;			/* the current selection */
350d4fba8b9Smrg    size_t data_limit;			/* size of allocated buffer */
351d4fba8b9Smrg    size_t data_length;			/* number of significant bytes */
352d4fba8b9Smrg} SelectedCells;
353d4fba8b9Smrg
354d522f475Smrg#define isSameRow(a,b)		((a)->row == (b)->row)
355d522f475Smrg#define isSameCol(a,b)		((a)->col == (b)->col)
356d522f475Smrg#define isSameCELL(a,b)		(isSameRow(a,b) && isSameCol(a,b))
357d522f475Smrg
358d522f475Smrg#define xBIT(n)         (1 << (n))
359d522f475Smrg
360d522f475Smrg/*
361d522f475Smrg * ANSI emulation, special character codes
362d522f475Smrg */
363cd3331d0Smrg#define ANSI_EOT	0x04
364d522f475Smrg#define ANSI_BEL	0x07
365cd3331d0Smrg#define ANSI_BS		0x08
366cd3331d0Smrg#define ANSI_HT		0x09
367cd3331d0Smrg#define ANSI_LF		0x0A
368cd3331d0Smrg#define ANSI_VT		0x0B
369d522f475Smrg#define	ANSI_FF		0x0C		/* C0, C1 control names		*/
370cd3331d0Smrg#define ANSI_CR		0x0D
371cd3331d0Smrg#define ANSI_SO		0x0E
372cd3331d0Smrg#define ANSI_SI		0x0F
373cd3331d0Smrg#define	ANSI_XON	0x11		/* DC1 */
374cd3331d0Smrg#define	ANSI_XOFF	0x13		/* DC3 */
375d522f475Smrg#define	ANSI_NAK	0x15
376d522f475Smrg#define	ANSI_CAN	0x18
377d522f475Smrg#define	ANSI_ESC	0x1B
378d522f475Smrg#define	ANSI_SPA	0x20
379d522f475Smrg#define XTERM_POUND	0x1E		/* internal mapping for '#'	*/
380d522f475Smrg#define	ANSI_DEL	0x7F
381d522f475Smrg#define	ANSI_SS2	0x8E
382d522f475Smrg#define	ANSI_SS3	0x8F
383d522f475Smrg#define	ANSI_DCS	0x90
384d522f475Smrg#define	ANSI_SOS	0x98
385d522f475Smrg#define	ANSI_CSI	0x9B
386d522f475Smrg#define	ANSI_ST		0x9C
387d522f475Smrg#define	ANSI_OSC	0x9D
388d522f475Smrg#define	ANSI_PM		0x9E
389d522f475Smrg#define	ANSI_APC	0x9F
390d522f475Smrg
391d4fba8b9Smrg#define BAD_ASCII	'?'
392d4fba8b9Smrg#define NonLatin1(c)	(((c) != ANSI_LF) && \
393d4fba8b9Smrg			 ((c) != ANSI_HT) && \
394d4fba8b9Smrg			 (((c) < ANSI_SPA) || \
395d4fba8b9Smrg			  ((c) >= ANSI_DEL && (c) <= ANSI_APC)))
396d4fba8b9Smrg#define OnlyLatin1(c)	(NonLatin1(c) ? BAD_ASCII : (c))
397d4fba8b9Smrg
39894644356Smrg#define L_CURL		'{'
39994644356Smrg#define R_CURL		'}'
40094644356Smrg
401d522f475Smrg#define MIN_DECID  52			/* can emulate VT52 */
4023367019cSmrg#define MAX_DECID 525			/* ...through VT525 */
403d522f475Smrg
404d522f475Smrg#ifndef DFT_DECID
405d4fba8b9Smrg#define DFT_DECID "420"			/* default VT420 */
406d522f475Smrg#endif
407d522f475Smrg
408d522f475Smrg#ifndef DFT_KBD_DIALECT
409d522f475Smrg#define DFT_KBD_DIALECT "B"		/* default USASCII */
410d522f475Smrg#endif
411d522f475Smrg
4128f44fb3bSmrg#define MAX_I_PARAM	65535		/* parameters */
4138f44fb3bSmrg#define MAX_I_DELAY	32767		/* time-delay in ReGIS */
4148f44fb3bSmrg#define MAX_U_COLOR	65535u		/* colors */
4158f44fb3bSmrg#define MAX_U_COORD	32767u		/* coordinates */
4168f44fb3bSmrg#define MAX_U_STRING	65535u		/* string-length */
4178f44fb3bSmrg
418d522f475Smrg/* constants used for utf8 mode */
419d522f475Smrg#define UCS_REPL	0xfffd
420d522f475Smrg#define UCS_LIMIT	0x80000000U	/* both limit and flag for non-UCS */
421d522f475Smrg
422d522f475Smrg#define TERMCAP_SIZE 1500		/* 1023 is standard; 'screen' exceeds */
423d522f475Smrg
424dfb07bc7Smrg#define MAX_XLFD_FONTS	1
425dfb07bc7Smrg#define MAX_XFT_FONTS	1
426d4fba8b9Smrg#define NMENUFONTS	10		/* font entries in fontMenu */
427d522f475Smrg
428d522f475Smrg#define	NBOX	5			/* Number of Points in box	*/
429d522f475Smrg#define	NPARAM	30			/* Max. parameters		*/
430d522f475Smrg
431d522f475Smrgtypedef struct {
432cd3331d0Smrg	String opt;
433cd3331d0Smrg	String desc;
434d522f475Smrg} OptionHelp;
435d522f475Smrg
4363367019cSmrgtypedef	struct {
4373367019cSmrg	int	count;			/* number of values in params[]	*/
4383367019cSmrg	int	has_subparams;		/* true if there are any sub's	*/
4393367019cSmrg	int	is_sub[NPARAM];		/* true for subparam		*/
4403367019cSmrg	int	params[NPARAM];		/* parameter value		*/
4413367019cSmrg} PARAMS;
4423367019cSmrg
4430d92cbfdSchristostypedef short ParmType;
444d4fba8b9Smrgtypedef unsigned short UParm;		/* unparseputn passes ParmType	*/
4450d92cbfdSchristos
446d522f475Smrgtypedef struct {
4470d92cbfdSchristos	Char		a_type;		/* CSI, etc., see unparseq()	*/
4480d92cbfdSchristos	Char		a_pintro;	/* private-mode char, if any	*/
4493367019cSmrg	const char *	a_delim;	/* between parameters (;)	*/
4500d92cbfdSchristos	Char		a_inters;	/* special (before final-char)	*/
4510d92cbfdSchristos	Char		a_final;	/* final-char			*/
4520d92cbfdSchristos	ParmType	a_nparam;	/* # of parameters		*/
4530d92cbfdSchristos	ParmType	a_param[NPARAM]; /* Parameters			*/
4543367019cSmrg	Char		a_radix[NPARAM]; /* Parameters			*/
455d522f475Smrg} ANSI;
456d522f475Smrg
457d522f475Smrg#define TEK_FONT_LARGE 0
458d522f475Smrg#define TEK_FONT_2 1
459d522f475Smrg#define TEK_FONT_3 2
460d522f475Smrg#define TEK_FONT_SMALL 3
461d522f475Smrg#define	TEKNUMFONTS 4
462d522f475Smrg
463d522f475Smrg/* Actually there are 5 types of lines, but four are non-solid lines */
464d522f475Smrg#define	TEKNUMLINES	4
465d522f475Smrg
466d522f475Smrgtypedef struct {
467d522f475Smrg	int	x;
468d522f475Smrg	int	y;
469d522f475Smrg	int	fontsize;
470d522f475Smrg	unsigned linetype;
471d522f475Smrg} Tmodes;
472d522f475Smrg
473d522f475Smrgtypedef struct {
474d522f475Smrg	int Twidth;
475d522f475Smrg	int Theight;
476d522f475Smrg} T_fontsize;
477d522f475Smrg
478d522f475Smrgtypedef struct {
479d522f475Smrg	short *bits;
480d522f475Smrg	int x;
481d522f475Smrg	int y;
482d522f475Smrg	int width;
483d522f475Smrg	int height;
484d522f475Smrg} BitmapBits;
485d522f475Smrg
486d4fba8b9Smrg/* bit-assignments for extensions to DECRQCRA */
487d4fba8b9Smrgtypedef enum {
488d4fba8b9Smrg    csDEC = 0
489d4fba8b9Smrg    ,csPOSITIVE = xBIT(0)
490d4fba8b9Smrg    ,csATTRIBS = xBIT(1)
491d4fba8b9Smrg    ,csNOTRIM = xBIT(2)
492d4fba8b9Smrg    ,csDRAWN = xBIT(3)
493d4fba8b9Smrg    ,csBYTE = xBIT(4)
494d4fba8b9Smrg    ,cs8TH = xBIT(5)
495d4fba8b9Smrg} CSBITS;
496d522f475Smrg
497d522f475Smrg#define EXCHANGE(a,b,tmp) tmp = a; a = b; b = tmp
498d522f475Smrg
499d522f475Smrg/***====================================================================***/
500d522f475Smrg
501d522f475Smrg#if (XtSpecificationRelease < 6)
502d522f475Smrg#ifndef NO_ACTIVE_ICON
503d522f475Smrg#define NO_ACTIVE_ICON 1 /* Note: code relies on an X11R6 function */
504d522f475Smrg#endif
505d522f475Smrg#endif
506d522f475Smrg
507d522f475Smrg#ifndef OPT_AIX_COLORS
508d522f475Smrg#define OPT_AIX_COLORS  1 /* true if xterm is configured with AIX (16) colors */
509d522f475Smrg#endif
510d522f475Smrg
511b7c89284Ssnj#ifndef OPT_ALLOW_XXX_OPS
512b7c89284Ssnj#define OPT_ALLOW_XXX_OPS 1 /* true if xterm adds "Allow XXX Ops" submenu */
513b7c89284Ssnj#endif
514b7c89284Ssnj
515d522f475Smrg#ifndef OPT_BLINK_CURS
516d522f475Smrg#define OPT_BLINK_CURS  1 /* true if xterm has blinking cursor capability */
517d522f475Smrg#endif
518d522f475Smrg
519d522f475Smrg#ifndef OPT_BLINK_TEXT
520d522f475Smrg#define OPT_BLINK_TEXT  OPT_BLINK_CURS /* true if xterm has blinking text capability */
521d522f475Smrg#endif
522d522f475Smrg
523d522f475Smrg#ifndef OPT_BOX_CHARS
524d522f475Smrg#define OPT_BOX_CHARS	1 /* true if xterm can simulate box-characters */
525d522f475Smrg#endif
526d522f475Smrg
5273367019cSmrg#ifndef OPT_BUILTIN_XPMS
5283367019cSmrg#define OPT_BUILTIN_XPMS 0 /* true if all xpm data is compiled-in */
5293367019cSmrg#endif
5303367019cSmrg
531d522f475Smrg#ifndef OPT_BROKEN_OSC
532d522f475Smrg#ifdef linux
533d522f475Smrg#define OPT_BROKEN_OSC	1 /* man console_codes, 1st paragraph - cf: ECMA-48 */
534d522f475Smrg#else
535d522f475Smrg#define OPT_BROKEN_OSC	0 /* true if xterm allows Linux's broken OSC parsing */
536d522f475Smrg#endif
537d522f475Smrg#endif
538d522f475Smrg
539d522f475Smrg#ifndef OPT_BROKEN_ST
540d522f475Smrg#define OPT_BROKEN_ST	1 /* true if xterm allows old/broken OSC parsing */
541d522f475Smrg#endif
542d522f475Smrg
543d522f475Smrg#ifndef OPT_C1_PRINT
544d522f475Smrg#define OPT_C1_PRINT	1 /* true if xterm allows C1 controls to be printable */
545d522f475Smrg#endif
546d522f475Smrg
547d522f475Smrg#ifndef OPT_CLIP_BOLD
548d522f475Smrg#define OPT_CLIP_BOLD	1 /* true if xterm uses clipping to avoid bold-trash */
549d522f475Smrg#endif
550d522f475Smrg
551d522f475Smrg#ifndef OPT_COLOR_CLASS
552d522f475Smrg#define OPT_COLOR_CLASS 1 /* true if xterm uses separate color-resource classes */
553d522f475Smrg#endif
554d522f475Smrg
555d522f475Smrg#ifndef OPT_COLOR_RES
556d522f475Smrg#define OPT_COLOR_RES   1 /* true if xterm delays color-resource evaluation */
557d522f475Smrg#endif
558d522f475Smrg
559d522f475Smrg#ifndef OPT_DABBREV
560d522f475Smrg#define OPT_DABBREV 0	/* dynamic abbreviations */
561d522f475Smrg#endif
562d522f475Smrg
563d522f475Smrg#ifndef OPT_DEC_CHRSET
564d522f475Smrg#define OPT_DEC_CHRSET  1 /* true if xterm is configured for DEC charset */
565d522f475Smrg#endif
566d522f475Smrg
567d522f475Smrg#ifndef OPT_DEC_LOCATOR
568d522f475Smrg#define	OPT_DEC_LOCATOR 0 /* true if xterm supports VT220-style mouse events */
569d522f475Smrg#endif
570d522f475Smrg
571d522f475Smrg#ifndef OPT_DEC_RECTOPS
572d4fba8b9Smrg#define OPT_DEC_RECTOPS 1 /* true if xterm is configured for VT420 rectangles */
573d522f475Smrg#endif
574d522f475Smrg
575fa3f02f3Smrg#ifndef OPT_SIXEL_GRAPHICS
5769a64e1c5Smrg#define OPT_SIXEL_GRAPHICS 0 /* true if xterm supports VT240-style sixel graphics */
5779a64e1c5Smrg#endif
5789a64e1c5Smrg
579d4fba8b9Smrg#ifndef OPT_PRINT_GRAPHICS
580d4fba8b9Smrg#define OPT_PRINT_GRAPHICS 0 /* true if xterm supports screen dumps as sixel graphics */
581d4fba8b9Smrg#endif
582d4fba8b9Smrg
583037a25ddSmrg#ifndef OPT_SCREEN_DUMPS
584d4fba8b9Smrg#define OPT_SCREEN_DUMPS 1 /* true if xterm supports screen dumps */
585037a25ddSmrg#endif
586037a25ddSmrg
5879a64e1c5Smrg#ifndef OPT_REGIS_GRAPHICS
5889a64e1c5Smrg#define OPT_REGIS_GRAPHICS 0 /* true if xterm supports VT125/VT240/VT330 ReGIS graphics */
5899a64e1c5Smrg#endif
5909a64e1c5Smrg
5919a64e1c5Smrg#ifndef OPT_GRAPHICS
5929a64e1c5Smrg#define OPT_GRAPHICS 0 /* true if xterm is configured for any type of graphics */
593fa3f02f3Smrg#endif
594fa3f02f3Smrg
595d522f475Smrg#ifndef OPT_DEC_SOFTFONT
596d522f475Smrg#define OPT_DEC_SOFTFONT 0 /* true if xterm is configured for VT220 softfonts */
597d522f475Smrg#endif
598d522f475Smrg
5993367019cSmrg#ifndef OPT_DOUBLE_BUFFER
6003367019cSmrg#define OPT_DOUBLE_BUFFER 0 /* true if using double-buffering */
6013367019cSmrg#endif
6023367019cSmrg
603d522f475Smrg#ifndef OPT_EBCDIC
604d522f475Smrg#ifdef __MVS__
605d522f475Smrg#define OPT_EBCDIC 1
606d522f475Smrg#else
607d522f475Smrg#define OPT_EBCDIC 0
608d522f475Smrg#endif
609d522f475Smrg#endif
610d522f475Smrg
611d522f475Smrg#ifndef OPT_EXEC_XTERM
612d522f475Smrg#define OPT_EXEC_XTERM 0 /* true if xterm can fork/exec copies of itself */
613d522f475Smrg#endif
614d522f475Smrg
615d522f475Smrg#ifndef OPT_EXTRA_PASTE
616d522f475Smrg#define OPT_EXTRA_PASTE 1
617d522f475Smrg#endif
618d522f475Smrg
619b7c89284Ssnj#ifndef OPT_FIFO_LINES
620d4fba8b9Smrg#define OPT_FIFO_LINES 1 /* optimize save-lines feature using FIFO */
621b7c89284Ssnj#endif
622b7c89284Ssnj
623d522f475Smrg#ifndef OPT_FOCUS_EVENT
624d522f475Smrg#define OPT_FOCUS_EVENT	1 /* focus in/out events */
625d522f475Smrg#endif
626d522f475Smrg
627d522f475Smrg#ifndef OPT_HP_FUNC_KEYS
628d522f475Smrg#define OPT_HP_FUNC_KEYS 0 /* true if xterm supports HP-style function keys */
629d522f475Smrg#endif
630d522f475Smrg
631d522f475Smrg#ifndef OPT_I18N_SUPPORT
632d522f475Smrg#if (XtSpecificationRelease >= 5)
633d522f475Smrg#define OPT_I18N_SUPPORT 1 /* true if xterm uses internationalization support */
634d522f475Smrg#else
635d522f475Smrg#define OPT_I18N_SUPPORT 0
636d522f475Smrg#endif
637d522f475Smrg#endif
638d522f475Smrg
639d522f475Smrg#ifndef OPT_INITIAL_ERASE
640d522f475Smrg#define OPT_INITIAL_ERASE 1 /* use pty's erase character if it's not 128 */
641d522f475Smrg#endif
642d522f475Smrg
643d522f475Smrg#ifndef OPT_INPUT_METHOD
644d522f475Smrg#if (XtSpecificationRelease >= 6)
645d4fba8b9Smrg#define OPT_INPUT_METHOD OPT_I18N_SUPPORT /* true if xterm uses input-method support */
646d522f475Smrg#else
647d522f475Smrg#define OPT_INPUT_METHOD 0
648d522f475Smrg#endif
649d522f475Smrg#endif
650d522f475Smrg
651d522f475Smrg#ifndef OPT_ISO_COLORS
652d522f475Smrg#define OPT_ISO_COLORS  1 /* true if xterm is configured with ISO colors */
653d522f475Smrg#endif
654d522f475Smrg
655d4fba8b9Smrg#ifndef OPT_DIRECT_COLOR
656d4fba8b9Smrg#define OPT_DIRECT_COLOR  OPT_ISO_COLORS /* true if xterm is configured with direct-colors */
657d4fba8b9Smrg#endif
658d4fba8b9Smrg
659d522f475Smrg#ifndef OPT_256_COLORS
660d4fba8b9Smrg#define OPT_256_COLORS  1 /* true if xterm is configured with 256 colors */
661d522f475Smrg#endif
662d522f475Smrg
663d522f475Smrg#ifndef OPT_88_COLORS
664d4fba8b9Smrg#define OPT_88_COLORS	1 /* true if xterm is configured with 88 colors */
665d522f475Smrg#endif
666d522f475Smrg
667d522f475Smrg#ifndef OPT_HIGHLIGHT_COLOR
668d522f475Smrg#define OPT_HIGHLIGHT_COLOR 1 /* true if xterm supports color highlighting */
669d522f475Smrg#endif
670d522f475Smrg
671d522f475Smrg#ifndef OPT_LOAD_VTFONTS
672d522f475Smrg#define OPT_LOAD_VTFONTS 0 /* true if xterm has load-vt-fonts() action */
673d522f475Smrg#endif
674d522f475Smrg
675d522f475Smrg#ifndef OPT_LUIT_PROG
676d4fba8b9Smrg#define OPT_LUIT_PROG   1 /* true if xterm supports luit */
677d522f475Smrg#endif
678d522f475Smrg
679d522f475Smrg#ifndef OPT_MAXIMIZE
680d522f475Smrg#define OPT_MAXIMIZE	1 /* add actions for iconify ... maximize */
681d522f475Smrg#endif
682d522f475Smrg
683d522f475Smrg#ifndef OPT_MINI_LUIT
684d522f475Smrg#define OPT_MINI_LUIT   0 /* true if xterm supports built-in mini-luit */
685d522f475Smrg#endif
686d522f475Smrg
687d522f475Smrg#ifndef OPT_MOD_FKEYS
688d522f475Smrg#define OPT_MOD_FKEYS	1 /* modify cursor- and function-keys in normal mode */
689d522f475Smrg#endif
690d522f475Smrg
691d522f475Smrg#ifndef OPT_NUM_LOCK
692d522f475Smrg#define OPT_NUM_LOCK	1 /* use NumLock key only for numeric-keypad */
693d522f475Smrg#endif
694d522f475Smrg
695d522f475Smrg#ifndef OPT_PASTE64
696d4fba8b9Smrg#define OPT_PASTE64	1 /* program control of select/paste via base64 */
697d522f475Smrg#endif
698d522f475Smrg
699d522f475Smrg#ifndef OPT_PC_COLORS
700d522f475Smrg#define OPT_PC_COLORS   1 /* true if xterm supports PC-style (bold) colors */
701d522f475Smrg#endif
702d522f475Smrg
703712a7ff4Smrg#ifndef OPT_PRINT_ON_EXIT
704712a7ff4Smrg#define OPT_PRINT_ON_EXIT 1 /* true allows xterm to dump screen on X error */
705712a7ff4Smrg#endif
706712a7ff4Smrg
707d522f475Smrg#ifndef OPT_PTY_HANDSHAKE
708d522f475Smrg#define OPT_PTY_HANDSHAKE USE_HANDSHAKE	/* avoid pty races on older systems */
709d522f475Smrg#endif
710d522f475Smrg
711d522f475Smrg#ifndef OPT_PRINT_COLORS
712d522f475Smrg#define OPT_PRINT_COLORS 1 /* true if we print color information */
713d522f475Smrg#endif
714d522f475Smrg
715d522f475Smrg#ifndef OPT_READLINE
716d522f475Smrg#define OPT_READLINE	0 /* mouse-click/paste support for readline */
717d522f475Smrg#endif
718d522f475Smrg
719d522f475Smrg#ifndef OPT_RENDERFONT
720d522f475Smrg#ifdef XRENDERFONT
721d522f475Smrg#define OPT_RENDERFONT 1
722d522f475Smrg#else
723d522f475Smrg#define OPT_RENDERFONT 0
724d522f475Smrg#endif
725d522f475Smrg#endif
726d522f475Smrg
727d522f475Smrg#ifndef OPT_RENDERWIDE
728d522f475Smrg#if OPT_RENDERFONT && OPT_WIDE_CHARS && defined(HAVE_TYPE_XFTCHARSPEC)
729d522f475Smrg#define OPT_RENDERWIDE 1
730d522f475Smrg#else
731d522f475Smrg#define OPT_RENDERWIDE 0
732d522f475Smrg#endif
733d522f475Smrg#endif
734d522f475Smrg
735dfb07bc7Smrg#ifndef OPT_REPORT_CCLASS
736dfb07bc7Smrg#define OPT_REPORT_CCLASS  1 /* provide "-report-charclass" option */
737dfb07bc7Smrg#endif
738dfb07bc7Smrg
739fa3f02f3Smrg#ifndef OPT_REPORT_COLORS
740fa3f02f3Smrg#define OPT_REPORT_COLORS  1 /* provide "-report-colors" option */
741fa3f02f3Smrg#endif
742fa3f02f3Smrg
743fa3f02f3Smrg#ifndef OPT_REPORT_FONTS
744fa3f02f3Smrg#define OPT_REPORT_FONTS   1 /* provide "-report-fonts" option */
745fa3f02f3Smrg#endif
746fa3f02f3Smrg
747d4fba8b9Smrg#ifndef OPT_REPORT_ICONS
748d4fba8b9Smrg#define OPT_REPORT_ICONS   1 /* provide "-report-icons" option */
749d4fba8b9Smrg#endif
750d4fba8b9Smrg
751d522f475Smrg#ifndef OPT_SAME_NAME
752d522f475Smrg#define OPT_SAME_NAME   1 /* suppress redundant updates of title, icon, etc. */
753d522f475Smrg#endif
754d522f475Smrg
755b7c89284Ssnj#ifndef OPT_SAVE_LINES
756b7c89284Ssnj#define OPT_SAVE_LINES OPT_FIFO_LINES /* optimize save-lines feature */
757b7c89284Ssnj#endif
758b7c89284Ssnj
759d522f475Smrg#ifndef OPT_SCO_FUNC_KEYS
760d522f475Smrg#define OPT_SCO_FUNC_KEYS 0 /* true if xterm supports SCO-style function keys */
761d522f475Smrg#endif
762d522f475Smrg
763d522f475Smrg#ifndef OPT_SUN_FUNC_KEYS
764d522f475Smrg#define OPT_SUN_FUNC_KEYS 1 /* true if xterm supports Sun-style function keys */
765d522f475Smrg#endif
766d522f475Smrg
767cd3331d0Smrg#ifndef OPT_SCROLL_LOCK
768cd3331d0Smrg#define OPT_SCROLL_LOCK 1 /* true if xterm interprets fontsize-shifting */
769cd3331d0Smrg#endif
770cd3331d0Smrg
771d522f475Smrg#ifndef OPT_SELECT_REGEX
772d4fba8b9Smrg#define OPT_SELECT_REGEX 1 /* true if xterm supports regular-expression selects */
773d522f475Smrg#endif
774d522f475Smrg
7753367019cSmrg#ifndef OPT_SELECTION_OPS
7763367019cSmrg#define OPT_SELECTION_OPS 1 /* true if xterm supports operations on selection */
7773367019cSmrg#endif
7783367019cSmrg
779d522f475Smrg#ifndef OPT_SESSION_MGT
780d522f475Smrg#if defined(XtNdieCallback) && defined(XtNsaveCallback)
781d522f475Smrg#define OPT_SESSION_MGT 1
782d522f475Smrg#else
783d522f475Smrg#define OPT_SESSION_MGT 0
784d522f475Smrg#endif
785d522f475Smrg#endif
786d522f475Smrg
787d522f475Smrg#ifndef OPT_SHIFT_FONTS
788781b53c7Schristos#define OPT_SHIFT_FONTS 0 /* true if xterm interprets fontsize-shifting */
789d522f475Smrg#endif
790d522f475Smrg
791d522f475Smrg#ifndef OPT_SUNPC_KBD
792d522f475Smrg#define OPT_SUNPC_KBD	1 /* true if xterm supports Sun/PC keyboard map */
793d522f475Smrg#endif
794d522f475Smrg
795d522f475Smrg#ifndef OPT_TCAP_FKEYS
796d4fba8b9Smrg#define OPT_TCAP_FKEYS	1 /* true for termcap function-keys */
797d522f475Smrg#endif
798d522f475Smrg
799d522f475Smrg#ifndef OPT_TCAP_QUERY
800d4fba8b9Smrg#define OPT_TCAP_QUERY	1 /* true for termcap query */
801d522f475Smrg#endif
802d522f475Smrg
803d522f475Smrg#ifndef OPT_TEK4014
804d522f475Smrg#define OPT_TEK4014     1 /* true if we're using tek4014 emulation */
805d522f475Smrg#endif
806d522f475Smrg
807d522f475Smrg#ifndef OPT_TOOLBAR
808d522f475Smrg#define OPT_TOOLBAR	0 /* true if xterm supports toolbar menus */
809d522f475Smrg#endif
810d522f475Smrg
811d522f475Smrg#ifndef OPT_TRACE
812d522f475Smrg#define OPT_TRACE       0 /* true if we're using debugging traces */
813d522f475Smrg#endif
814d522f475Smrg
815d522f475Smrg#ifndef OPT_TRACE_FLAGS
816d522f475Smrg#define OPT_TRACE_FLAGS 0 /* additional tracing used for SCRN_BUF_FLAGS */
817d522f475Smrg#endif
818d522f475Smrg
819d4fba8b9Smrg#ifndef OPT_TRACE_UNIQUE
820d4fba8b9Smrg#define OPT_TRACE_UNIQUE 0 /* true if we're using multiple trace files */
821d4fba8b9Smrg#endif
822d4fba8b9Smrg
823d522f475Smrg#ifndef OPT_VT52_MODE
824d522f475Smrg#define OPT_VT52_MODE   1 /* true if xterm supports VT52 emulation */
825d522f475Smrg#endif
826d522f475Smrg
8279a64e1c5Smrg#ifndef OPT_WIDE_ATTRS
8289a64e1c5Smrg#define OPT_WIDE_ATTRS  1 /* true if xterm supports 16-bit attributes */
8299a64e1c5Smrg#endif
8309a64e1c5Smrg
831d522f475Smrg#ifndef OPT_WIDE_CHARS
832d4fba8b9Smrg#define OPT_WIDE_CHARS  1 /* true if xterm supports 16-bit characters */
833d522f475Smrg#endif
834d522f475Smrg
835b7c89284Ssnj#ifndef OPT_WIDER_ICHAR
836b7c89284Ssnj#define OPT_WIDER_ICHAR 1 /* true if xterm uses 32-bits for wide-chars */
837b7c89284Ssnj#endif
838b7c89284Ssnj
839d522f475Smrg#ifndef OPT_XMC_GLITCH
840d522f475Smrg#define OPT_XMC_GLITCH	0 /* true if xterm supports xmc (magic cookie glitch) */
841d522f475Smrg#endif
842d522f475Smrg
843d4fba8b9Smrg#ifndef OPT_XRES_QUERY
844d4fba8b9Smrg#define OPT_XRES_QUERY	1 /* true for resource query */
845d4fba8b9Smrg#endif
846d4fba8b9Smrg
847d4fba8b9Smrg#ifndef OPT_XTERM_SGR
848d4fba8b9Smrg#define OPT_XTERM_SGR   1 /* true if xterm supports private SGR controls */
849d4fba8b9Smrg#endif
850d4fba8b9Smrg
851d522f475Smrg#ifndef OPT_ZICONBEEP
852d522f475Smrg#define OPT_ZICONBEEP   1 /* true if xterm supports "-ziconbeep" option */
853d522f475Smrg#endif
854d522f475Smrg
855d522f475Smrg/***====================================================================***/
856d522f475Smrg
857d522f475Smrg#if OPT_AIX_COLORS && !OPT_ISO_COLORS
858d522f475Smrg/* You must have ANSI/ISO colors to support AIX colors */
859d522f475Smrg#undef  OPT_AIX_COLORS
860d522f475Smrg#define OPT_AIX_COLORS 0
861d522f475Smrg#endif
862d522f475Smrg
863d522f475Smrg#if OPT_COLOR_RES && !OPT_ISO_COLORS
864d522f475Smrg/* You must have ANSI/ISO colors to support ColorRes logic */
865d522f475Smrg#undef  OPT_COLOR_RES
866d522f475Smrg#define OPT_COLOR_RES 0
867d522f475Smrg#endif
868d522f475Smrg
869cd3331d0Smrg#if OPT_256_COLORS && (OPT_WIDE_CHARS || OPT_RENDERFONT || OPT_XMC_GLITCH)
870cd3331d0Smrg/* It's actually more complicated than that - but by trimming options you can
871cd3331d0Smrg * have 256 color resources though.
872cd3331d0Smrg */
873cd3331d0Smrg#define OPT_COLOR_RES2 1
874cd3331d0Smrg#else
875d522f475Smrg#define OPT_COLOR_RES2 0
876d522f475Smrg#endif
877d522f475Smrg
878d522f475Smrg#if OPT_PC_COLORS && !OPT_ISO_COLORS
879d522f475Smrg/* You must have ANSI/ISO colors to support PC colors */
880d522f475Smrg#undef  OPT_PC_COLORS
881d522f475Smrg#define OPT_PC_COLORS 0
882d522f475Smrg#endif
883d522f475Smrg
884d522f475Smrg#if OPT_PRINT_COLORS && !OPT_ISO_COLORS
885d522f475Smrg/* You must have ANSI/ISO colors to be able to print them */
886d522f475Smrg#undef  OPT_PRINT_COLORS
887d522f475Smrg#define OPT_PRINT_COLORS 0
888d522f475Smrg#endif
889d522f475Smrg
890d522f475Smrg#if OPT_256_COLORS && !OPT_ISO_COLORS
891d522f475Smrg/* You must have ANSI/ISO colors to support 256 colors */
892d522f475Smrg#undef  OPT_256_COLORS
893d522f475Smrg#define OPT_256_COLORS 0
894d522f475Smrg#endif
895d522f475Smrg
896d522f475Smrg#if OPT_88_COLORS && !OPT_ISO_COLORS
897d522f475Smrg/* You must have ANSI/ISO colors to support 88 colors */
898d522f475Smrg#undef  OPT_88_COLORS
899d522f475Smrg#define OPT_88_COLORS 0
900d522f475Smrg#endif
901d522f475Smrg
902d522f475Smrg#if OPT_88_COLORS && OPT_256_COLORS
903d522f475Smrg/* 256 colors supersedes 88 colors */
904d522f475Smrg#undef  OPT_88_COLORS
905d522f475Smrg#define OPT_88_COLORS 0
906d522f475Smrg#endif
907d522f475Smrg
908d522f475Smrg/***====================================================================***/
909d522f475Smrg
910d522f475Smrg/*
911d522f475Smrg * Indices for menu_font_names[][]
912d522f475Smrg */
913d522f475Smrgtypedef enum {
914d522f475Smrg    fNorm = 0			/* normal font */
915d522f475Smrg    , fBold			/* bold font */
916dfb07bc7Smrg#if OPT_WIDE_ATTRS || OPT_RENDERWIDE
917dfb07bc7Smrg    , fItal			/* italic font */
918d4fba8b9Smrg    , fBtal			/* bold-italic font */
919dfb07bc7Smrg#endif
920d522f475Smrg#if OPT_WIDE_CHARS
921d522f475Smrg    , fWide			/* double-width font */
922d522f475Smrg    , fWBold			/* double-width bold font */
923dfb07bc7Smrg    , fWItal			/* double-width italic font */
924d4fba8b9Smrg    , fWBtal			/* double-width bold-italic font */
925d522f475Smrg#endif
926d522f475Smrg    , fMAX
927d522f475Smrg} VTFontEnum;
928d522f475Smrg
929d522f475Smrg/*
930d522f475Smrg * Indices for cachedGCs.c (unrelated to VTFontEnum).
931d522f475Smrg */
932d522f475Smrgtypedef enum {
933d522f475Smrg    gcNorm = 0
934d522f475Smrg    , gcBold
935d522f475Smrg    , gcNormReverse
936d522f475Smrg    , gcBoldReverse
937d4fba8b9Smrg    , gcFiller
938d4fba8b9Smrg    , gcBorder
939d522f475Smrg#if OPT_BOX_CHARS
940d522f475Smrg    , gcLine
941d522f475Smrg    , gcDots
942d522f475Smrg#endif
943d522f475Smrg#if OPT_DEC_CHRSET
944d522f475Smrg    , gcCNorm
945d522f475Smrg    , gcCBold
946d522f475Smrg#endif
947d522f475Smrg#if OPT_WIDE_CHARS
948d522f475Smrg    , gcWide
949d522f475Smrg    , gcWBold
950d522f475Smrg    , gcWideReverse
951d522f475Smrg    , gcWBoldReverse
952d522f475Smrg#endif
953d522f475Smrg    , gcVTcursNormal
954d522f475Smrg    , gcVTcursFilled
955d522f475Smrg    , gcVTcursReverse
956d522f475Smrg    , gcVTcursOutline
957d522f475Smrg#if OPT_TEK4014
958d522f475Smrg    , gcTKcurs
959d522f475Smrg#endif
960d522f475Smrg    , gcMAX
961d522f475Smrg} CgsEnum;
962d522f475Smrg
963d522f475Smrg#define for_each_text_gc(n) for (n = gcNorm; n < gcVTcursNormal; ++n)
964d522f475Smrg#define for_each_curs_gc(n) for (n = gcVTcursNormal; n <= gcVTcursOutline; ++n)
965d522f475Smrg#define for_each_gc(n)      for (n = gcNorm; n < gcMAX; ++n)
966d522f475Smrg
967cd3331d0Smrg/*
968cd3331d0Smrg * Indices for the normal terminal colors in screen.Tcolors[].
969cd3331d0Smrg * See also OscTextColors, which has corresponding values.
970cd3331d0Smrg */
971d522f475Smrgtypedef enum {
972d522f475Smrg    TEXT_FG = 0			/* text foreground */
973d522f475Smrg    , TEXT_BG			/* text background */
974d522f475Smrg    , TEXT_CURSOR		/* text cursor */
975d522f475Smrg    , MOUSE_FG			/* mouse foreground */
976d522f475Smrg    , MOUSE_BG			/* mouse background */
977d522f475Smrg#if OPT_TEK4014
9783367019cSmrg    , TEK_FG = 5		/* tektronix foreground */
979d522f475Smrg    , TEK_BG			/* tektronix background */
980d522f475Smrg#endif
981d522f475Smrg#if OPT_HIGHLIGHT_COLOR
9823367019cSmrg    , HIGHLIGHT_BG = 7		/* highlight background */
9833367019cSmrg#endif
9843367019cSmrg#if OPT_TEK4014
9853367019cSmrg    , TEK_CURSOR = 8		/* tektronix cursor */
9863367019cSmrg#endif
9873367019cSmrg#if OPT_HIGHLIGHT_COLOR
9883367019cSmrg    , HIGHLIGHT_FG = 9		/* highlight foreground */
989d522f475Smrg#endif
990d522f475Smrg    , NCOLORS			/* total number of colors */
991d522f475Smrg} TermColors;
992d522f475Smrg
99394644356Smrg/*
99494644356Smrg * Definitions for exec-formatted and insert-formatted actions.
99594644356Smrg */
99694644356Smrgtypedef void (*FormatSelect) (Widget, char *, char *, CELL *, CELL *);
99794644356Smrg
99894644356Smrgtypedef struct {
999d4fba8b9Smrg    Boolean done;
100094644356Smrg    char *format;
100194644356Smrg    char *buffer;
100294644356Smrg    FormatSelect format_select;
100394644356Smrg#if OPT_PASTE64
100494644356Smrg    Cardinal base64_paste;
100594644356Smrg#endif
1006d4fba8b9Smrg#if OPT_PASTE64 || OPT_READLINE
100794644356Smrg    unsigned paste_brackets;
100894644356Smrg#endif
100994644356Smrg} InternalSelect;
101094644356Smrg
1011cd3331d0Smrg/*
1012cd3331d0Smrg * Constants for titleModes resource
1013cd3331d0Smrg */
1014cd3331d0Smrgtypedef enum {
1015cd3331d0Smrg    tmSetBase16 = 1		/* set title using hex-string */
1016cd3331d0Smrg    , tmGetBase16 = 2		/* get title using hex-string */
1017cd3331d0Smrg#if OPT_WIDE_CHARS
1018cd3331d0Smrg    , tmSetUtf8 = 4		/* like utf8Title, but controllable */
1019cd3331d0Smrg    , tmGetUtf8 = 8		/* retrieve title encoded as UTF-8 */
1020cd3331d0Smrg#endif
1021cd3331d0Smrg} TitleModes;
1022cd3331d0Smrg
1023cd3331d0Smrg#define IsTitleMode(xw,mode) (((xw)->screen.title_modes & mode) != 0)
1024cd3331d0Smrg
1025fa3f02f3Smrg#include <xcharmouse.h>
1026fa3f02f3Smrg
1027fa3f02f3Smrg/*
1028fa3f02f3Smrg * For readability...
1029fa3f02f3Smrg */
1030fa3f02f3Smrg#define nrc_percent   100
1031fa3f02f3Smrg#define nrc_dquote    200
1032fa3f02f3Smrg#define nrc_ampersand 300
1033fa3f02f3Smrgtypedef enum {
1034fa3f02f3Smrg    nrc_ASCII = 0
1035fa3f02f3Smrg    ,nrc_British		/* vt100 */
1036fa3f02f3Smrg    ,nrc_British_Latin_1	/* vt3xx */
1037d4fba8b9Smrg    ,nrc_DEC_Cyrillic		/* vt5xx */
1038fa3f02f3Smrg    ,nrc_DEC_Spec_Graphic	/* vt100 */
1039fa3f02f3Smrg    ,nrc_DEC_Alt_Chars		/* vt100 */
1040fa3f02f3Smrg    ,nrc_DEC_Alt_Graphics	/* vt100 */
1041fa3f02f3Smrg    ,nrc_DEC_Supp		/* vt2xx */
1042fa3f02f3Smrg    ,nrc_DEC_Supp_Graphic	/* vt3xx */
1043fa3f02f3Smrg    ,nrc_DEC_Technical		/* vt3xx */
1044fa3f02f3Smrg    ,nrc_Dutch			/* vt2xx */
1045fa3f02f3Smrg    ,nrc_Finnish		/* vt2xx */
1046fa3f02f3Smrg    ,nrc_Finnish2		/* vt2xx */
1047fa3f02f3Smrg    ,nrc_French			/* vt2xx */
1048fa3f02f3Smrg    ,nrc_French2		/* vt2xx */
1049fa3f02f3Smrg    ,nrc_French_Canadian	/* vt2xx */
1050fa3f02f3Smrg    ,nrc_French_Canadian2	/* vt3xx */
1051fa3f02f3Smrg    ,nrc_German			/* vt2xx */
1052fa3f02f3Smrg    ,nrc_Greek			/* vt5xx */
1053d4fba8b9Smrg    ,nrc_DEC_Greek_Supp		/* vt5xx */
1054d4fba8b9Smrg    ,nrc_ISO_Greek_Supp		/* vt5xx */
1055d4fba8b9Smrg    ,nrc_DEC_Hebrew_Supp	/* vt5xx */
1056fa3f02f3Smrg    ,nrc_Hebrew			/* vt5xx */
1057d4fba8b9Smrg    ,nrc_ISO_Hebrew_Supp	/* vt5xx */
1058fa3f02f3Smrg    ,nrc_Italian		/* vt2xx */
1059d4fba8b9Smrg    ,nrc_ISO_Latin_1_Supp	/* vt5xx */
1060d4fba8b9Smrg    ,nrc_ISO_Latin_2_Supp	/* vt5xx */
1061d4fba8b9Smrg    ,nrc_ISO_Latin_5_Supp	/* vt5xx */
1062d4fba8b9Smrg    ,nrc_ISO_Latin_Cyrillic	/* vt5xx */
1063fa3f02f3Smrg    ,nrc_Norwegian_Danish	/* vt3xx */
1064fa3f02f3Smrg    ,nrc_Norwegian_Danish2	/* vt2xx */
1065fa3f02f3Smrg    ,nrc_Norwegian_Danish3	/* vt2xx */
1066fa3f02f3Smrg    ,nrc_Portugese		/* vt3xx */
1067fa3f02f3Smrg    ,nrc_Russian		/* vt5xx */
1068fa3f02f3Smrg    ,nrc_SCS_NRCS		/* vt5xx - probably Serbo/Croatian */
1069fa3f02f3Smrg    ,nrc_Spanish		/* vt2xx */
1070fa3f02f3Smrg    ,nrc_Swedish		/* vt2xx */
1071fa3f02f3Smrg    ,nrc_Swedish2		/* vt2xx */
1072fa3f02f3Smrg    ,nrc_Swiss			/* vt2xx */
1073d4fba8b9Smrg    ,nrc_DEC_Turkish_Supp	/* vt5xx */
1074fa3f02f3Smrg    ,nrc_Turkish		/* vt5xx */
1075fa3f02f3Smrg    ,nrc_Unknown
1076fa3f02f3Smrg} DECNRCM_codes;
1077fa3f02f3Smrg
1078fa3f02f3Smrg/*
1079fa3f02f3Smrg * Use this enumerated type to check consistency among dpmodes(), savemodes()
1080d4fba8b9Smrg * restoremodes() and do_dec_rqm().
1081fa3f02f3Smrg */
1082fa3f02f3Smrgtypedef enum {
1083fa3f02f3Smrg    srm_DECCKM = 1
1084fa3f02f3Smrg    ,srm_DECANM = 2
1085fa3f02f3Smrg    ,srm_DECCOLM = 3
1086fa3f02f3Smrg    ,srm_DECSCLM = 4
1087fa3f02f3Smrg    ,srm_DECSCNM = 5
1088fa3f02f3Smrg    ,srm_DECOM = 6
1089fa3f02f3Smrg    ,srm_DECAWM = 7
1090fa3f02f3Smrg    ,srm_DECARM = 8
1091fa3f02f3Smrg    ,srm_X10_MOUSE = SET_X10_MOUSE
1092fa3f02f3Smrg#if OPT_TOOLBAR
1093fa3f02f3Smrg    ,srm_RXVT_TOOLBAR = 10
1094fa3f02f3Smrg#endif
1095fa3f02f3Smrg#if OPT_BLINK_CURS
1096fa3f02f3Smrg    ,srm_ATT610_BLINK = 12
1097d4fba8b9Smrg    ,srm_CURSOR_BLINK_OPS = 13
1098d4fba8b9Smrg    ,srm_XOR_CURSOR_BLINKS = 14
1099fa3f02f3Smrg#endif
1100fa3f02f3Smrg    ,srm_DECPFF = 18
1101fa3f02f3Smrg    ,srm_DECPEX = 19
1102fa3f02f3Smrg    ,srm_DECTCEM = 25
1103fa3f02f3Smrg    ,srm_RXVT_SCROLLBAR = 30
1104fa3f02f3Smrg#if OPT_SHIFT_FONTS
1105fa3f02f3Smrg    ,srm_RXVT_FONTSIZE = 35
1106fa3f02f3Smrg#endif
1107fa3f02f3Smrg#if OPT_TEK4014
1108fa3f02f3Smrg    ,srm_DECTEK = 38
1109fa3f02f3Smrg#endif
1110fa3f02f3Smrg    ,srm_132COLS = 40
1111fa3f02f3Smrg    ,srm_CURSES_HACK = 41
1112fa3f02f3Smrg    ,srm_DECNRCM = 42
1113d4fba8b9Smrg#if OPT_PRINT_GRAPHICS
1114d4fba8b9Smrg    ,srm_DECGEPM = 43		/* Graphics Expanded Print Mode */
1115d4fba8b9Smrg#endif
1116d4fba8b9Smrg    ,srm_MARGIN_BELL = 44	/* also DECGPCM (Graphics Print Color Mode) */
1117d4fba8b9Smrg    ,srm_REVERSEWRAP = 45	/* also DECGPCS (Graphics Print Color Syntax) */
1118fa3f02f3Smrg#ifdef ALLOWLOGGING
1119d4fba8b9Smrg    ,srm_ALLOWLOGGING = 46	/* also DECGPBM (Graphics Print Background Mode) */
1120d4fba8b9Smrg#elif OPT_PRINT_GRAPHICS
1121d4fba8b9Smrg    ,srm_DECGPBM = 46		/* Graphics Print Background Mode */
1122fa3f02f3Smrg#endif
1123d4fba8b9Smrg    ,srm_ALTBUF = 47		/* also DECGRPM (Graphics Rotated Print Mode) */
1124fa3f02f3Smrg    ,srm_DECNKM = 66
1125fa3f02f3Smrg    ,srm_DECBKM = 67
1126fa3f02f3Smrg    ,srm_DECLRMM = 69
1127fa3f02f3Smrg#if OPT_SIXEL_GRAPHICS
1128fa3f02f3Smrg    ,srm_DECSDM = 80		/* Sixel Display Mode */
1129fa3f02f3Smrg#endif
1130fa3f02f3Smrg    ,srm_DECNCSM = 95
1131fa3f02f3Smrg    ,srm_VT200_MOUSE = SET_VT200_MOUSE
1132fa3f02f3Smrg    ,srm_VT200_HIGHLIGHT_MOUSE = SET_VT200_HIGHLIGHT_MOUSE
1133fa3f02f3Smrg    ,srm_BTN_EVENT_MOUSE = SET_BTN_EVENT_MOUSE
1134fa3f02f3Smrg    ,srm_ANY_EVENT_MOUSE = SET_ANY_EVENT_MOUSE
1135fa3f02f3Smrg#if OPT_FOCUS_EVENT
1136fa3f02f3Smrg    ,srm_FOCUS_EVENT_MOUSE = SET_FOCUS_EVENT_MOUSE
1137fa3f02f3Smrg#endif
1138fa3f02f3Smrg    ,srm_EXT_MODE_MOUSE = SET_EXT_MODE_MOUSE
1139fa3f02f3Smrg    ,srm_SGR_EXT_MODE_MOUSE = SET_SGR_EXT_MODE_MOUSE
1140fa3f02f3Smrg    ,srm_URXVT_EXT_MODE_MOUSE = SET_URXVT_EXT_MODE_MOUSE
1141d4fba8b9Smrg    ,srm_PIXEL_POSITION_MOUSE = SET_PIXEL_POSITION_MOUSE
1142fa3f02f3Smrg    ,srm_ALTERNATE_SCROLL = SET_ALTERNATE_SCROLL
1143fa3f02f3Smrg    ,srm_RXVT_SCROLL_TTY_OUTPUT = 1010
1144fa3f02f3Smrg    ,srm_RXVT_SCROLL_TTY_KEYPRESS = 1011
1145fa3f02f3Smrg    ,srm_EIGHT_BIT_META = 1034
1146fa3f02f3Smrg#if OPT_NUM_LOCK
1147fa3f02f3Smrg    ,srm_REAL_NUMLOCK = 1035
1148fa3f02f3Smrg    ,srm_META_SENDS_ESC = 1036
1149fa3f02f3Smrg#endif
1150fa3f02f3Smrg    ,srm_DELETE_IS_DEL = 1037
1151fa3f02f3Smrg#if OPT_NUM_LOCK
1152fa3f02f3Smrg    ,srm_ALT_SENDS_ESC = 1039
1153fa3f02f3Smrg#endif
1154fa3f02f3Smrg    ,srm_KEEP_SELECTION = 1040
1155fa3f02f3Smrg    ,srm_SELECT_TO_CLIPBOARD = 1041
1156fa3f02f3Smrg    ,srm_BELL_IS_URGENT = 1042
1157fa3f02f3Smrg    ,srm_POP_ON_BELL = 1043
1158037a25ddSmrg    ,srm_KEEP_CLIPBOARD = 1044
1159d4fba8b9Smrg    ,srm_ALLOW_ALTBUF = 1046
1160d4fba8b9Smrg    ,srm_OPT_ALTBUF = 1047
1161d4fba8b9Smrg    ,srm_SAVE_CURSOR = 1048
1162d4fba8b9Smrg    ,srm_OPT_ALTBUF_CURSOR = 1049
1163fa3f02f3Smrg#if OPT_TCAP_FKEYS
1164fa3f02f3Smrg    ,srm_TCAP_FKEYS = 1050
1165fa3f02f3Smrg#endif
1166fa3f02f3Smrg#if OPT_SUN_FUNC_KEYS
1167fa3f02f3Smrg    ,srm_SUN_FKEYS = 1051
1168fa3f02f3Smrg#endif
1169fa3f02f3Smrg#if OPT_HP_FUNC_KEYS
1170fa3f02f3Smrg    ,srm_HP_FKEYS = 1052
1171fa3f02f3Smrg#endif
1172fa3f02f3Smrg#if OPT_SCO_FUNC_KEYS
1173fa3f02f3Smrg    ,srm_SCO_FKEYS = 1053
1174fa3f02f3Smrg#endif
1175fa3f02f3Smrg    ,srm_LEGACY_FKEYS = 1060
1176fa3f02f3Smrg#if OPT_SUNPC_KBD
1177fa3f02f3Smrg    ,srm_VT220_FKEYS = 1061
1178fa3f02f3Smrg#endif
11799a64e1c5Smrg#if OPT_GRAPHICS
1180fa3f02f3Smrg    ,srm_PRIVATE_COLOR_REGISTERS = 1070
1181fa3f02f3Smrg#endif
1182d4fba8b9Smrg#if OPT_PASTE64 || OPT_READLINE
1183d4fba8b9Smrg    ,srm_PASTE_IN_BRACKET = SET_PASTE_IN_BRACKET
1184d4fba8b9Smrg#endif
1185fa3f02f3Smrg#if OPT_READLINE
1186fa3f02f3Smrg    ,srm_BUTTON1_MOVE_POINT = SET_BUTTON1_MOVE_POINT
1187fa3f02f3Smrg    ,srm_BUTTON2_MOVE_POINT = SET_BUTTON2_MOVE_POINT
1188fa3f02f3Smrg    ,srm_DBUTTON3_DELETE = SET_DBUTTON3_DELETE
1189fa3f02f3Smrg    ,srm_PASTE_QUOTE = SET_PASTE_QUOTE
1190fa3f02f3Smrg    ,srm_PASTE_LITERAL_NL = SET_PASTE_LITERAL_NL
1191fa3f02f3Smrg#endif				/* OPT_READLINE */
11929a64e1c5Smrg#if OPT_SIXEL_GRAPHICS
11939a64e1c5Smrg    ,srm_SIXEL_SCROLLS_RIGHT = 8452
11949a64e1c5Smrg#endif
1195fa3f02f3Smrg} DECSET_codes;
1196fa3f02f3Smrg
1197d4fba8b9Smrg/* internal codes for selection atoms */
1198d4fba8b9Smrgtypedef enum {
1199d4fba8b9Smrg    PRIMARY_CODE = 0
1200d4fba8b9Smrg    ,CLIPBOARD_CODE
1201d4fba8b9Smrg    ,SECONDARY_CODE
1202d4fba8b9Smrg    ,MAX_SELECTION_CODES
1203d4fba8b9Smrg} SelectionCodes;
1204d4fba8b9Smrg
1205d522f475Smrg/* indices for mapping multiple clicks to selection types */
1206d522f475Smrgtypedef enum {
1207d522f475Smrg    Select_CHAR=0
1208d522f475Smrg    ,Select_WORD
1209d522f475Smrg    ,Select_LINE
1210d522f475Smrg    ,Select_GROUP
1211d522f475Smrg    ,Select_PAGE
1212d522f475Smrg    ,Select_ALL
1213d522f475Smrg#if OPT_SELECT_REGEX
1214d522f475Smrg    ,Select_REGEX
1215d522f475Smrg#endif
1216d522f475Smrg    ,NSELECTUNITS
1217d522f475Smrg} SelectUnit;
1218d522f475Smrg
1219d4fba8b9Smrg#if OPT_BLINK_CURS
1220d4fba8b9Smrgtypedef enum {
1221d4fba8b9Smrg    cbFalse = 0
1222d4fba8b9Smrg    , cbTrue
1223d4fba8b9Smrg    , cbAlways
1224d4fba8b9Smrg    , cbNever
1225d4fba8b9Smrg    , cbLAST
1226d4fba8b9Smrg} BlinkOps;
1227d4fba8b9Smrg#endif
1228d4fba8b9Smrg
1229cd3331d0Smrgtypedef enum {
1230cd3331d0Smrg    ecSetColor = 1
1231cd3331d0Smrg    , ecGetColor
1232cd3331d0Smrg    , ecGetAnsiColor
1233cd3331d0Smrg    , ecLAST
1234cd3331d0Smrg} ColorOps;
1235cd3331d0Smrg
1236cd3331d0Smrgtypedef enum {
1237cd3331d0Smrg    efSetFont = 1
1238cd3331d0Smrg    , efGetFont
1239cd3331d0Smrg    , efLAST
1240cd3331d0Smrg} FontOps;
1241cd3331d0Smrg
1242c219fbebSmrgtypedef enum {
1243c219fbebSmrg    esFalse = 0
1244c219fbebSmrg    , esTrue
1245c219fbebSmrg    , esAlways
1246c219fbebSmrg    , esNever
1247d4fba8b9Smrg    , esLAST
1248c219fbebSmrg} FullscreenOps;
1249c219fbebSmrg
12503367019cSmrg#ifndef NO_ACTIVE_ICON
12513367019cSmrgtypedef enum {
12523367019cSmrg    eiFalse = 0
12533367019cSmrg    , eiTrue
12543367019cSmrg    , eiDefault
12553367019cSmrg    , eiLAST
12563367019cSmrg} AIconOps;
12573367019cSmrg#endif
12583367019cSmrg
1259dfb07bc7Smrgtypedef enum {
1260dfb07bc7Smrg    emX10 = 1
1261dfb07bc7Smrg    , emLocator
1262dfb07bc7Smrg    , emVT200Click
1263dfb07bc7Smrg    , emVT200Hilite
1264dfb07bc7Smrg    , emAnyButton
1265dfb07bc7Smrg    , emAnyEvent
1266dfb07bc7Smrg    , emFocusEvent
1267dfb07bc7Smrg    , emExtended
1268dfb07bc7Smrg    , emSGR
1269dfb07bc7Smrg    , emURXVT
1270dfb07bc7Smrg    , emAlternateScroll
1271dfb07bc7Smrg    , emLAST
1272dfb07bc7Smrg} MouseOps;
1273dfb07bc7Smrg
1274d4fba8b9Smrgtypedef enum {
1275d4fba8b9Smrg#define DATA(name) ep##name
1276d4fba8b9Smrg    DATA(NUL) = 0
1277d4fba8b9Smrg    , DATA(SOH) =  1
1278d4fba8b9Smrg    , DATA(STX) =  2
1279d4fba8b9Smrg    , DATA(ETX) =  3
1280d4fba8b9Smrg    , DATA(EOT) =  4
1281d4fba8b9Smrg    , DATA(ENQ) =  5
1282d4fba8b9Smrg    , DATA(ACK) =  6
1283d4fba8b9Smrg    , DATA(BEL) =  7
1284d4fba8b9Smrg    , DATA(BS)  =  8
1285d4fba8b9Smrg    , DATA(HT)  =  9
1286d4fba8b9Smrg    , DATA(LF)  = 10
1287d4fba8b9Smrg    , DATA(VT)  = 11
1288d4fba8b9Smrg    , DATA(FF)  = 12
1289d4fba8b9Smrg    , DATA(CR)  = 13
1290d4fba8b9Smrg    , DATA(SO)  = 14
1291d4fba8b9Smrg    , DATA(SI)  = 15
1292d4fba8b9Smrg    , DATA(DLE) = 16
1293d4fba8b9Smrg    , DATA(DC1) = 17
1294d4fba8b9Smrg    , DATA(DC2) = 18
1295d4fba8b9Smrg    , DATA(DC3) = 19
1296d4fba8b9Smrg    , DATA(DC4) = 20
1297d4fba8b9Smrg    , DATA(NAK) = 21
1298d4fba8b9Smrg    , DATA(SYN) = 22
1299d4fba8b9Smrg    , DATA(ETB) = 23
1300d4fba8b9Smrg    , DATA(CAN) = 24
1301d4fba8b9Smrg    , DATA(EM)  = 25
1302d4fba8b9Smrg    , DATA(SUB) = 26
1303d4fba8b9Smrg    , DATA(ESC) = 27
1304d4fba8b9Smrg    , DATA(FS)  = 28
1305d4fba8b9Smrg    , DATA(GS)  = 29
1306d4fba8b9Smrg    , DATA(RS)  = 30
1307d4fba8b9Smrg    , DATA(US)  = 31
1308d4fba8b9Smrg    /* aliases */
1309d4fba8b9Smrg    , DATA(C0)
1310d4fba8b9Smrg    , DATA(DEL)
1311d4fba8b9Smrg#undef DATA
1312d4fba8b9Smrg    , epLAST
1313d4fba8b9Smrg} PasteControls;
1314d4fba8b9Smrg
1315d4fba8b9Smrgtypedef enum {			/* legal values for keyboard.shift_escape */
1316d4fba8b9Smrg    ssFalse = 0
1317d4fba8b9Smrg    , ssTrue = 1
1318d4fba8b9Smrg    , ssAlways = 2
1319d4fba8b9Smrg    , ssNever = 3
1320d4fba8b9Smrg    , ssLAST
1321d4fba8b9Smrg} ShiftEscapeOps;
1322d4fba8b9Smrg
1323d4fba8b9Smrg/*
1324d4fba8b9Smrg * xterm uses these codes for the its push-SGR feature.  They match where
1325d4fba8b9Smrg * possible the corresponding SGR coding.  The foreground and background colors
1326d4fba8b9Smrg * do not fit into that scheme (because they are a set of ranges), so those are
1327d4fba8b9Smrg * chosen arbitrarily -TD
1328d4fba8b9Smrg */
1329d4fba8b9Smrgtypedef enum {
1330d4fba8b9Smrg    psBOLD = 1
1331d4fba8b9Smrg#if OPT_WIDE_ATTRS
1332d4fba8b9Smrg    , psATR_FAINT = 2
1333d4fba8b9Smrg    , psATR_ITALIC = 3
1334d4fba8b9Smrg#endif
1335d4fba8b9Smrg    , psUNDERLINE = 4
1336d4fba8b9Smrg    , psBLINK = 5
1337d4fba8b9Smrg    , psINVERSE = 7
1338d4fba8b9Smrg    , psINVISIBLE = 8
1339d4fba8b9Smrg#if OPT_WIDE_ATTRS
1340d4fba8b9Smrg    , psATR_STRIKEOUT = 9
1341d4fba8b9Smrg#endif
1342d4fba8b9Smrg    /* SGR 10-19 correspond to primary/alternate fonts, currently unused */
1343d4fba8b9Smrg#if OPT_ISO_COLORS
1344d4fba8b9Smrg    , psFG_COLOR_obs = 10
1345d4fba8b9Smrg    , psBG_COLOR_obs = 11
1346d4fba8b9Smrg#endif
1347d4fba8b9Smrg#if OPT_WIDE_ATTRS
1348d4fba8b9Smrg    , psATR_DBL_UNDER = 21
1349d4fba8b9Smrg#endif
1350d4fba8b9Smrg    /* SGR 22-29 mostly are used to reset SGR 1-9 */
1351d4fba8b9Smrg#if OPT_ISO_COLORS
1352d4fba8b9Smrg    , psFG_COLOR = 30	/* stack maps many colors to one state */
1353d4fba8b9Smrg    , psBG_COLOR = 31
1354d4fba8b9Smrg#endif
1355d4fba8b9Smrg    , MAX_PUSH_SGR
1356d4fba8b9Smrg} PushSGR;
1357d4fba8b9Smrg
1358cd3331d0Smrgtypedef enum {
1359cd3331d0Smrg    etSetTcap = 1
1360cd3331d0Smrg    , etGetTcap
1361cd3331d0Smrg    , etLAST
1362cd3331d0Smrg} TcapOps;
1363cd3331d0Smrg
1364cd3331d0Smrgtypedef enum {
13653367019cSmrg    /* 1-23 are chosen to be the same as the control-sequence coding */
1366cd3331d0Smrg    ewRestoreWin = 1
1367cd3331d0Smrg    , ewMinimizeWin = 2
1368cd3331d0Smrg    , ewSetWinPosition = 3
1369cd3331d0Smrg    , ewSetWinSizePixels = 4
1370cd3331d0Smrg    , ewRaiseWin = 5
1371cd3331d0Smrg    , ewLowerWin = 6
1372cd3331d0Smrg    , ewRefreshWin = 7
1373cd3331d0Smrg    , ewSetWinSizeChars = 8
1374cd3331d0Smrg#if OPT_MAXIMIZE
1375cd3331d0Smrg    , ewMaximizeWin = 9
1376c219fbebSmrg    , ewFullscreenWin = 10
1377cd3331d0Smrg#endif
1378cd3331d0Smrg    , ewGetWinState = 11
1379cd3331d0Smrg    , ewGetWinPosition = 13
1380cd3331d0Smrg    , ewGetWinSizePixels = 14
1381d4fba8b9Smrg#if OPT_MAXIMIZE
1382d4fba8b9Smrg    , ewGetScreenSizePixels = 15
1383d4fba8b9Smrg    , ewGetCharSizePixels = 16
1384d4fba8b9Smrg#endif
1385cd3331d0Smrg    , ewGetWinSizeChars = 18
1386cd3331d0Smrg#if OPT_MAXIMIZE
1387cd3331d0Smrg    , ewGetScreenSizeChars = 19
1388cd3331d0Smrg#endif
1389cd3331d0Smrg    , ewGetIconTitle = 20
1390cd3331d0Smrg    , ewGetWinTitle = 21
1391cd3331d0Smrg    , ewPushTitle = 22
1392cd3331d0Smrg    , ewPopTitle = 23
1393cd3331d0Smrg    /* these do not fit into that scheme, which is why we use an array */
1394cd3331d0Smrg    , ewSetWinLines
1395cd3331d0Smrg    , ewSetXprop
1396cd3331d0Smrg    , ewGetSelection
1397cd3331d0Smrg    , ewSetSelection
1398d4fba8b9Smrg    , ewGetChecksum
1399d4fba8b9Smrg    , ewSetChecksum
1400cd3331d0Smrg    /* get the size of the array... */
1401cd3331d0Smrg    , ewLAST
1402cd3331d0Smrg} WindowOps;
1403cd3331d0Smrg
1404d4fba8b9Smrg/***====================================================================***/
1405d4fba8b9Smrg
1406cd3331d0Smrg#define	COLOR_DEFINED(s,w)	((s)->which & (unsigned) (1<<(w)))
1407d522f475Smrg#define	COLOR_VALUE(s,w)	((s)->colors[w])
1408cd3331d0Smrg#define	SET_COLOR_VALUE(s,w,v)	(((s)->colors[w] = (v)), UIntSet((s)->which, (1<<(w))))
1409d522f475Smrg
1410d522f475Smrg#define	COLOR_NAME(s,w)		((s)->names[w])
1411cd3331d0Smrg#define	SET_COLOR_NAME(s,w,v)	(((s)->names[w] = (v)), ((s)->which |= (unsigned) (1<<(w))))
1412d522f475Smrg
1413d522f475Smrg#define	UNDEFINE_COLOR(s,w)	((s)->which &= (~((w)<<1)))
1414d522f475Smrg
1415d522f475Smrg/***====================================================================***/
1416d522f475Smrg
1417d522f475Smrg#if OPT_ISO_COLORS
1418d4fba8b9Smrg#if OPT_WIDE_ATTRS
1419d4fba8b9Smrg#define COLOR_FLAGS		(FG_COLOR | BG_COLOR | ATR_DIRECT_FG | ATR_DIRECT_BG)
1420d4fba8b9Smrg#else
1421d4fba8b9Smrg#define COLOR_FLAGS		(FG_COLOR | BG_COLOR)
1422d4fba8b9Smrg#endif
1423d4fba8b9Smrg#define TERM_COLOR_FLAGS(xw)	((xw)->flags & COLOR_FLAGS)
1424d522f475Smrg#define COLOR_0		0
1425d522f475Smrg#define COLOR_1		1
1426d522f475Smrg#define COLOR_2		2
1427d522f475Smrg#define COLOR_3		3
1428d522f475Smrg#define COLOR_4		4
1429d522f475Smrg#define COLOR_5		5
1430d522f475Smrg#define COLOR_6		6
1431d522f475Smrg#define COLOR_7		7
1432d522f475Smrg#define COLOR_8		8
1433d522f475Smrg#define COLOR_9		9
1434d522f475Smrg#define COLOR_10	10
1435d522f475Smrg#define COLOR_11	11
1436d522f475Smrg#define COLOR_12	12
1437d522f475Smrg#define COLOR_13	13
1438d522f475Smrg#define COLOR_14	14
1439d522f475Smrg#define COLOR_15	15
1440d522f475Smrg#define MIN_ANSI_COLORS 16
1441d522f475Smrg
1442d522f475Smrg#if OPT_256_COLORS
1443d522f475Smrg# define NUM_ANSI_COLORS 256
1444d522f475Smrg#elif OPT_88_COLORS
1445d522f475Smrg# define NUM_ANSI_COLORS 88
1446d522f475Smrg#else
1447d522f475Smrg# define NUM_ANSI_COLORS MIN_ANSI_COLORS
1448d522f475Smrg#endif
1449d522f475Smrg
1450d4fba8b9Smrg#define okIndexedColor(n) ((n) >= 0 && (n) < NUM_ANSI_COLORS)
1451d4fba8b9Smrg
1452d522f475Smrg#if NUM_ANSI_COLORS > MIN_ANSI_COLORS
1453d522f475Smrg# define OPT_EXT_COLORS  1
1454d522f475Smrg#else
1455d522f475Smrg# define OPT_EXT_COLORS  0
1456d522f475Smrg#endif
1457d522f475Smrg
1458d522f475Smrg#define COLOR_BD	(NUM_ANSI_COLORS)	/* BOLD */
1459d522f475Smrg#define COLOR_UL	(NUM_ANSI_COLORS+1)	/* UNDERLINE */
1460d522f475Smrg#define COLOR_BL	(NUM_ANSI_COLORS+2)	/* BLINK */
1461d522f475Smrg#define COLOR_RV	(NUM_ANSI_COLORS+3)	/* REVERSE */
146294644356Smrg
146394644356Smrg#if OPT_WIDE_ATTRS
146494644356Smrg#define COLOR_IT	(NUM_ANSI_COLORS+4)	/* ITALIC */
146594644356Smrg#define MAXCOLORS	(NUM_ANSI_COLORS+5)
146694644356Smrg#else
1467d522f475Smrg#define MAXCOLORS	(NUM_ANSI_COLORS+4)
146894644356Smrg#endif
146994644356Smrg
1470d522f475Smrg#ifndef DFT_COLORMODE
1471d522f475Smrg#define DFT_COLORMODE True	/* default colorMode resource */
1472d522f475Smrg#endif
1473d522f475Smrg
147494644356Smrg#define UseItalicFont(screen) (!(screen)->colorITMode)
147594644356Smrg
1476d522f475Smrg#define ReverseOrHilite(screen,flags,hilite) \
1477d522f475Smrg		(( screen->colorRVMode && hilite ) || \
1478d522f475Smrg		    ( !screen->colorRVMode && \
1479d522f475Smrg		      (( (flags & INVERSE) && !hilite) || \
1480d522f475Smrg		       (!(flags & INVERSE) &&  hilite)) ))
1481d522f475Smrg
1482d522f475Smrg#else	/* !OPT_ISO_COLORS */
1483d522f475Smrg
1484d522f475Smrg#define TERM_COLOR_FLAGS(xw) 0
1485d522f475Smrg
148694644356Smrg#define UseItalicFont(screen) True
1487d522f475Smrg#define ReverseOrHilite(screen,flags,hilite) \
1488d522f475Smrg		      (( (flags & INVERSE) && !hilite) || \
1489d522f475Smrg		       (!(flags & INVERSE) &&  hilite))
1490d522f475Smrg
1491d522f475Smrg#endif	/* OPT_ISO_COLORS */
1492d522f475Smrg
1493d4fba8b9Smrgtypedef enum {
1494d4fba8b9Smrg	XK_TCAPNAME = 3
1495d4fba8b9Smrg	/* Define fake XK codes, we need those for the fake color response in
1496d4fba8b9Smrg	 * xtermcapKeycode().
1497d4fba8b9Smrg	 */
1498d4fba8b9Smrg#if OPT_ISO_COLORS
1499d4fba8b9Smrg	, XK_COLORS
1500d4fba8b9Smrg	, XK_RGB
1501d4fba8b9Smrg#endif
1502d4fba8b9Smrg} TcapQuery;
1503cd3331d0Smrg
1504d522f475Smrg#if OPT_AIX_COLORS
1505d522f475Smrg#define if_OPT_AIX_COLORS(screen, code) if(screen->colorMode) code
1506d522f475Smrg#else
1507d522f475Smrg#define if_OPT_AIX_COLORS(screen, code) /* nothing */
1508d522f475Smrg#endif
1509d522f475Smrg
1510b7c89284Ssnj#if OPT_256_COLORS || OPT_88_COLORS || OPT_ISO_COLORS
1511b7c89284Ssnj# define if_OPT_ISO_COLORS(screen, code) if (screen->colorMode) code
1512d522f475Smrg#else
1513b7c89284Ssnj# define if_OPT_ISO_COLORS(screen, code) /* nothing */
1514d522f475Smrg#endif
1515d522f475Smrg
1516d4fba8b9Smrg#if OPT_DIRECT_COLOR
1517d4fba8b9Smrg# define if_OPT_DIRECT_COLOR(screen, code) if (screen->direct_color) code
1518d4fba8b9Smrg# define if_OPT_DIRECT_COLOR2(screen, test, code) if (screen->direct_color && (test)) code
1519d4fba8b9Smrg#else
1520d4fba8b9Smrg# define if_OPT_DIRECT_COLOR(screen, code) /* nothing */
1521d4fba8b9Smrg# define if_OPT_DIRECT_COLOR2(screen, test, code) /* nothing */
1522d4fba8b9Smrg#endif
1523d4fba8b9Smrg
1524d4fba8b9Smrg#define if_OPT_DIRECT_COLOR2_else(cond, test, stmt) \
1525d4fba8b9Smrg	if_OPT_DIRECT_COLOR2(cond, test, stmt else)
1526d4fba8b9Smrg
1527d522f475Smrg#define COLOR_RES_NAME(root) "color" root
1528d522f475Smrg
1529d522f475Smrg#if OPT_COLOR_CLASS
1530d522f475Smrg#define COLOR_RES_CLASS(root) "Color" root
1531d522f475Smrg#else
1532d522f475Smrg#define COLOR_RES_CLASS(root) XtCForeground
1533d522f475Smrg#endif
1534d522f475Smrg
1535d522f475Smrg#if OPT_COLOR_RES
1536d522f475Smrg#define COLOR_RES(root,offset,value) Sres(COLOR_RES_NAME(root), COLOR_RES_CLASS(root), offset.resource, value)
1537d522f475Smrg#define COLOR_RES2(name,class,offset,value) Sres(name, class, offset.resource, value)
1538d522f475Smrg#else
1539d522f475Smrg#define COLOR_RES(root,offset,value) Cres(COLOR_RES_NAME(root), COLOR_RES_CLASS(root), offset, value)
1540d522f475Smrg#define COLOR_RES2(name,class,offset,value) Cres(name, class, offset, value)
1541d522f475Smrg#endif
1542d522f475Smrg
1543d522f475Smrg#define CLICK_RES_NAME(count)  "on" count "Clicks"
1544d522f475Smrg#define CLICK_RES_CLASS(count) "On" count "Clicks"
1545d522f475Smrg#define CLICK_RES(count,offset,value) Sres(CLICK_RES_NAME(count), CLICK_RES_CLASS(count), offset, value)
1546d522f475Smrg
1547d522f475Smrg/***====================================================================***/
1548d522f475Smrg
1549d522f475Smrg#if OPT_DEC_CHRSET
1550d522f475Smrg#define if_OPT_DEC_CHRSET(code) code
1551d522f475Smrg	/* Use 2 bits for encoding the double high/wide sense of characters */
1552d522f475Smrg#define CSET_SWL        0
1553d522f475Smrg#define CSET_DHL_TOP    1
1554d522f475Smrg#define CSET_DHL_BOT    2
1555d522f475Smrg#define CSET_DWL        3
1556d522f475Smrg#define NUM_CHRSET      8	/* normal/bold and 4 CSET_xxx values */
1557b7c89284Ssnj
1558d522f475Smrg	/* Use remaining bits for encoding the other character-sets */
1559d522f475Smrg#define CSET_NORMAL(code)  ((code) == CSET_SWL)
1560d522f475Smrg#define CSET_DOUBLE(code)  (!CSET_NORMAL(code) && !CSET_EXTEND(code))
1561cd3331d0Smrg#define CSET_EXTEND(code)  ((int)(code) > CSET_DWL)
1562b7c89284Ssnj
1563b7c89284Ssnj#define DBLCS_BITS            4
1564b7c89284Ssnj#define DBLCS_MASK            BITS2MASK(DBLCS_BITS)
1565b7c89284Ssnj
1566b7c89284Ssnj#define GetLineDblCS(ld)      (((ld)->bufHead >> LINEFLAG_BITS) & DBLCS_MASK)
1567b7c89284Ssnj#define SetLineDblCS(ld,cs)   (ld)->bufHead = (RowData) ((ld->bufHead & LINEFLAG_MASK) | (cs << LINEFLAG_BITS))
1568b7c89284Ssnj
1569b7c89284Ssnj#define LineCharSet(screen, ld) \
1570d4fba8b9Smrg	(unsigned) ((CSET_DOUBLE(GetLineDblCS(ld))) \
1571d4fba8b9Smrg		    ? GetLineDblCS(ld) \
1572d4fba8b9Smrg		    : (screen)->cur_chrset)
1573b7c89284Ssnj#define LineMaxCol(screen, ld) \
1574b7c89284Ssnj	(CSET_DOUBLE(GetLineDblCS(ld)) \
1575b7c89284Ssnj	 ? (screen->max_col / 2) \
1576b7c89284Ssnj	 : (screen->max_col))
1577b7c89284Ssnj#define LineCursorX(screen, ld, col) \
1578b7c89284Ssnj	(CSET_DOUBLE(GetLineDblCS(ld)) \
1579b7c89284Ssnj	 ? CursorX(screen, 2*(col)) \
1580b7c89284Ssnj	 : CursorX(screen, (col)))
1581b7c89284Ssnj#define LineFontWidth(screen, ld) \
1582b7c89284Ssnj	(CSET_DOUBLE(GetLineDblCS(ld)) \
1583b7c89284Ssnj	 ? 2*FontWidth(screen) \
1584b7c89284Ssnj	 : FontWidth(screen))
1585d522f475Smrg#else
1586b7c89284Ssnj
1587d522f475Smrg#define if_OPT_DEC_CHRSET(code) /*nothing*/
1588d4fba8b9Smrg#define CSET_SWL                        0
1589d4fba8b9Smrg#define GetLineDblCS(ld)                0U
1590d4fba8b9Smrg#define LineCharSet(screen, ld)         0U
1591b7c89284Ssnj#define LineMaxCol(screen, ld)          screen->max_col
1592b7c89284Ssnj#define LineCursorX(screen, ld, col)    CursorX(screen, col)
1593b7c89284Ssnj#define LineFontWidth(screen, ld)       FontWidth(screen)
1594b7c89284Ssnj
1595d522f475Smrg#endif
1596d522f475Smrg
1597d522f475Smrg#if OPT_LUIT_PROG && !OPT_WIDE_CHARS
1598d4fba8b9Smrg/* Luit requires the wide-chars configuration */
1599d4fba8b9Smrg#undef OPT_LUIT_PROG
1600d4fba8b9Smrg#define OPT_LUIT_PROG 0
1601d522f475Smrg#endif
1602d522f475Smrg
1603d522f475Smrg/***====================================================================***/
1604d522f475Smrg
1605d522f475Smrg#if OPT_EBCDIC
1606d522f475Smrgextern int E2A(int);
1607d522f475Smrgextern int A2E(int);
1608d522f475Smrg#else
1609d522f475Smrg#define E2A(a) (a)
1610d522f475Smrg#define A2E(a) (a)
1611d522f475Smrg#endif
1612d522f475Smrg
1613d522f475Smrg#define CONTROL(a) (A2E(E2A(a)&037))
1614d522f475Smrg
1615d522f475Smrg/***====================================================================***/
1616d522f475Smrg
1617d522f475Smrg#if OPT_TEK4014
1618d522f475Smrg#define TEK4014_ACTIVE(xw)      ((xw)->misc.TekEmu)
1619d522f475Smrg#define TEK4014_SHOWN(xw)       ((xw)->misc.Tshow)
1620d522f475Smrg#define CURRENT_EMU_VAL(tek,vt) (TEK4014_ACTIVE(term) ? tek : vt)
1621d522f475Smrg#define CURRENT_EMU()           CURRENT_EMU_VAL((Widget)tekWidget, (Widget)term)
1622d522f475Smrg#else
1623d522f475Smrg#define TEK4014_ACTIVE(screen)  0
1624d522f475Smrg#define TEK4014_SHOWN(xw)       0
1625d522f475Smrg#define CURRENT_EMU_VAL(tek,vt) (vt)
1626d522f475Smrg#define CURRENT_EMU()           ((Widget)term)
1627d522f475Smrg#endif
1628d522f475Smrg
1629d522f475Smrg/***====================================================================***/
1630d522f475Smrg
1631d522f475Smrg#if OPT_TOOLBAR
1632d522f475Smrg#define SHELL_OF(widget) XtParent(XtParent(widget))
1633d522f475Smrg#else
1634d522f475Smrg#define SHELL_OF(widget) XtParent(widget)
1635d522f475Smrg#endif
1636d522f475Smrg
1637d522f475Smrg/***====================================================================***/
1638d522f475Smrg
1639d522f475Smrg#if OPT_VT52_MODE
1640d522f475Smrg#define if_OPT_VT52_MODE(screen, code) if(screen->vtXX_level == 0) code
1641d522f475Smrg#else
1642d522f475Smrg#define if_OPT_VT52_MODE(screen, code) /* nothing */
1643d522f475Smrg#endif
1644d522f475Smrg
1645d522f475Smrg/***====================================================================***/
1646d522f475Smrg
1647d522f475Smrg#if OPT_XMC_GLITCH
1648d522f475Smrg#define if_OPT_XMC_GLITCH(screen, code) if(screen->xmc_glitch) code
1649d522f475Smrg#define XMC_GLITCH 1	/* the character we'll show */
1650d522f475Smrg#define XMC_FLAGS (INVERSE|UNDERLINE|BOLD|BLINK)
1651d522f475Smrg#else
1652d522f475Smrg#define if_OPT_XMC_GLITCH(screen, code) /* nothing */
1653d522f475Smrg#endif
1654d522f475Smrg
1655d522f475Smrg/***====================================================================***/
1656d522f475Smrg
16579a64e1c5Smrgtypedef unsigned IFlags;	/* at least 32 bits */
16589a64e1c5Smrg
16599a64e1c5Smrg#if OPT_WIDE_ATTRS
16609a64e1c5Smrgtypedef unsigned short IAttr;	/* at least 16 bits */
16619a64e1c5Smrg#else
16629a64e1c5Smrgtypedef unsigned char IAttr;	/* at least 8 bits */
16639a64e1c5Smrg#endif
16649a64e1c5Smrg
16659a64e1c5Smrg/***====================================================================***/
16669a64e1c5Smrg
16670d92cbfdSchristos#define LO_BYTE(ch) CharOf((ch) & 0xff)
16680d92cbfdSchristos#define HI_BYTE(ch) CharOf((ch) >> 8)
16690d92cbfdSchristos
1670d522f475Smrg#if OPT_WIDE_CHARS
1671d522f475Smrg#define if_OPT_WIDE_CHARS(screen, code) if(screen->wide_chars) code
1672d522f475Smrg#define if_WIDE_OR_NARROW(screen, wide, narrow) if(screen->wide_chars) wide else narrow
1673d4fba8b9Smrg#define NARROW_ICHAR	0xffff
1674b7c89284Ssnj#if OPT_WIDER_ICHAR
1675d4fba8b9Smrg#define WIDEST_ICHAR	0x1fffff
1676b7c89284Ssnjtypedef unsigned IChar;		/* for 8-21 bit characters */
1677b7c89284Ssnj#else
1678d4fba8b9Smrg#define WIDEST_ICHAR	NARROW_ICHAR
1679b7c89284Ssnjtypedef unsigned short IChar;	/* for 8-16 bit characters */
1680b7c89284Ssnj#endif
1681d522f475Smrg#else
1682d522f475Smrg#define if_OPT_WIDE_CHARS(screen, code) /* nothing */
1683d522f475Smrg#define if_WIDE_OR_NARROW(screen, wide, narrow) narrow
1684d522f475Smrgtypedef unsigned char IChar;	/* for 8-bit characters */
1685d522f475Smrg#endif
1686d522f475Smrg
1687d522f475Smrg/***====================================================================***/
1688d522f475Smrg
1689d522f475Smrg#ifndef RES_OFFSET
1690d522f475Smrg#define RES_OFFSET(offset) XtOffsetOf(XtermWidgetRec, offset)
1691d522f475Smrg#endif
1692d522f475Smrg
1693d522f475Smrg#define RES_NAME(name) name
1694d522f475Smrg#define RES_CLASS(name) name
1695d522f475Smrg
1696d522f475Smrg#define Bres(name, class, offset, dftvalue) \
1697d522f475Smrg	{RES_NAME(name), RES_CLASS(class), XtRBoolean, sizeof(Boolean), \
1698d522f475Smrg	 RES_OFFSET(offset), XtRImmediate, (XtPointer) dftvalue}
1699d522f475Smrg
1700d522f475Smrg#define Cres(name, class, offset, dftvalue) \
1701d522f475Smrg	{RES_NAME(name), RES_CLASS(class), XtRPixel, sizeof(Pixel), \
1702fa3f02f3Smrg	 RES_OFFSET(offset), XtRString, DECONST(char,dftvalue)}
1703d522f475Smrg
1704d522f475Smrg#define Tres(name, class, offset, dftvalue) \
1705d522f475Smrg	COLOR_RES2(name, class, screen.Tcolors[offset], dftvalue) \
1706d522f475Smrg
1707d522f475Smrg#define Fres(name, class, offset, dftvalue) \
1708d522f475Smrg	{RES_NAME(name), RES_CLASS(class), XtRFontStruct, sizeof(XFontStruct *), \
1709fa3f02f3Smrg	 RES_OFFSET(offset), XtRString, DECONST(char,dftvalue)}
1710d522f475Smrg
1711d522f475Smrg#define Ires(name, class, offset, dftvalue) \
1712d522f475Smrg	{RES_NAME(name), RES_CLASS(class), XtRInt, sizeof(int), \
1713d522f475Smrg	 RES_OFFSET(offset), XtRImmediate, (XtPointer) dftvalue}
1714d522f475Smrg
1715d522f475Smrg#define Dres(name, class, offset, dftvalue) \
1716d522f475Smrg	{RES_NAME(name), RES_CLASS(class), XtRFloat, sizeof(float), \
1717fa3f02f3Smrg	 RES_OFFSET(offset), XtRString, DECONST(char,dftvalue)}
1718d522f475Smrg
1719d522f475Smrg#define Sres(name, class, offset, dftvalue) \
1720d522f475Smrg	{RES_NAME(name), RES_CLASS(class), XtRString, sizeof(char *), \
1721fa3f02f3Smrg	 RES_OFFSET(offset), XtRString, DECONST(char,dftvalue)}
1722d522f475Smrg
1723d522f475Smrg#define Wres(name, class, offset, dftvalue) \
1724d522f475Smrg	{RES_NAME(name), RES_CLASS(class), XtRWidget, sizeof(Widget), \
1725d522f475Smrg	 RES_OFFSET(offset), XtRWidget, (XtPointer) dftvalue}
1726d522f475Smrg
1727d522f475Smrg/***====================================================================***/
1728d522f475Smrg
1729d522f475Smrg#define FRG_SIZE resource.minBufSize
1730d522f475Smrg#define BUF_SIZE resource.maxBufSize
1731d522f475Smrg
1732d522f475Smrgtypedef struct {
173394644356Smrg	Char    *next;
173494644356Smrg	Char    *last;
173594644356Smrg	int      update;	/* HandleInterpret */
1736d522f475Smrg#if OPT_WIDE_CHARS
173794644356Smrg	IChar    utf_data;	/* resulting character */
173894644356Smrg	int      utf_size;	/* ...number of bytes decoded */
173994644356Smrg	Char    *write_buf;
1740d522f475Smrg	unsigned write_len;
1741d522f475Smrg#endif
174294644356Smrg	Char     buffer[1];
1743d522f475Smrg} PtyData;
1744d522f475Smrg
1745d522f475Smrg/***====================================================================***/
1746d522f475Smrg
1747d4fba8b9Smrg/*
1748d4fba8b9Smrg * Pixel (and its components) are declared as unsigned long, but even for RGB
1749d4fba8b9Smrg * we need no more than 32-bits.
1750d4fba8b9Smrg */
1751d4fba8b9Smrgtypedef uint32_t MyPixel;
1752d4fba8b9Smrgtypedef int32_t MyColor;
1753d4fba8b9Smrg
1754d522f475Smrg#if OPT_ISO_COLORS
1755d4fba8b9Smrg#if OPT_DIRECT_COLOR
1756d4fba8b9Smrgtypedef struct {
1757d4fba8b9Smrg    MyColor fg;
1758d4fba8b9Smrg    MyColor bg;
1759d4fba8b9Smrg} CellColor;
1760d4fba8b9Smrg
1761d4fba8b9Smrg#define isSameCColor(p,q) (!memcmp(&(p), &(q), sizeof(CellColor)))
1762d4fba8b9Smrg
1763d4fba8b9Smrg#elif OPT_256_COLORS || OPT_88_COLORS
1764d4fba8b9Smrg
1765b7c89284Ssnj#define COLOR_BITS 8
1766b7c89284Ssnjtypedef unsigned short CellColor;
1767d4fba8b9Smrg
1768d522f475Smrg#else
1769d4fba8b9Smrg
1770b7c89284Ssnj#define COLOR_BITS 4
1771b7c89284Ssnjtypedef Char CellColor;
1772d4fba8b9Smrg
1773d522f475Smrg#endif
1774b7c89284Ssnj#else
17759a64e1c5Smrgtypedef unsigned CellColor;
1776d522f475Smrg#endif
1777b7c89284Ssnj
1778d4fba8b9Smrg#define NO_COLOR		((unsigned)-1)
1779d4fba8b9Smrg
1780d4fba8b9Smrg#ifndef isSameCColor
1781d4fba8b9Smrg#define isSameCColor(p,q)	((p) == (q))
1782d4fba8b9Smrg#endif
1783d4fba8b9Smrg
1784d4fba8b9Smrg#define BITS2MASK(b)		((1 << b) - 1)
1785b7c89284Ssnj
1786d4fba8b9Smrg#define COLOR_MASK		BITS2MASK(COLOR_BITS)
1787b7c89284Ssnj
1788d4fba8b9Smrg#if OPT_DIRECT_COLOR
1789d4fba8b9Smrg#define clrDirectFG(flags)	UIntClr(flags, ATR_DIRECT_FG)
1790d4fba8b9Smrg#define clrDirectBG(flags)	UIntClr(flags, ATR_DIRECT_BG)
1791d4fba8b9Smrg#define GetCellColorFG(data)	((data).fg)
1792d4fba8b9Smrg#define GetCellColorBG(data)	((data).bg)
1793d4fba8b9Smrg#define hasDirectFG(flags)	((flags) & ATR_DIRECT_FG)
1794d4fba8b9Smrg#define hasDirectBG(flags)	((flags) & ATR_DIRECT_BG)
1795d4fba8b9Smrg#define setDirectFG(flags,test)	if (test) UIntSet(flags, ATR_DIRECT_FG); else UIntClr(flags, ATR_DIRECT_FG)
1796d4fba8b9Smrg#define setDirectBG(flags,test)	if (test) UIntSet(flags, ATR_DIRECT_BG); else UIntClr(flags, ATR_DIRECT_BG)
1797d4fba8b9Smrg#elif OPT_ISO_COLORS
1798d4fba8b9Smrg#define clrDirectFG(flags)	/* nothing */
1799d4fba8b9Smrg#define clrDirectBG(flags)	/* nothing */
1800d4fba8b9Smrg#define GetCellColorFG(data)	((data) & COLOR_MASK)
1801d4fba8b9Smrg#define GetCellColorBG(data)	(((data) >> COLOR_BITS) & COLOR_MASK)
1802d4fba8b9Smrg#define hasDirectFG(flags)	0
1803d4fba8b9Smrg#define hasDirectBG(flags)	0
1804d4fba8b9Smrg#define setDirectFG(flags,test)	(void)(test)
1805d4fba8b9Smrg#define setDirectBG(flags,test)	(void)(test)
1806d4fba8b9Smrg#else
1807d4fba8b9Smrg#define GetCellColorFG(data)	7
1808d4fba8b9Smrg#define GetCellColorBG(data)	0
1809d4fba8b9Smrg#endif
1810d4fba8b9Smrgextern CellColor blank_cell_color;
1811b7c89284Ssnj
1812b7c89284Ssnjtypedef Char RowData;		/* wrap/blink, and DEC single-double chars */
1813b7c89284Ssnj
1814d4fba8b9Smrg#define LINEFLAG_BITS		4
1815d4fba8b9Smrg#define LINEFLAG_MASK		BITS2MASK(LINEFLAG_BITS)
1816b7c89284Ssnj
1817d4fba8b9Smrg#define GetLineFlags(ld)	((ld)->bufHead & LINEFLAG_MASK)
1818b7c89284Ssnj
1819d522f475Smrg#if OPT_DEC_CHRSET
1820d4fba8b9Smrg#define SetLineFlags(ld,xx)	(ld)->bufHead = (RowData) ((ld->bufHead & (DBLCS_MASK << LINEFLAG_BITS)) | (xx & LINEFLAG_MASK))
1821b7c89284Ssnj#else
1822d4fba8b9Smrg#define SetLineFlags(ld,xx)	(ld)->bufHead = (RowData) (xx & LINEFLAG_MASK)
1823d522f475Smrg#endif
1824b7c89284Ssnj
1825b7c89284Ssnjtypedef IChar CharData;
1826b7c89284Ssnj
1827b7c89284Ssnj/*
1828b7c89284Ssnj * This is the xterm line-data/scrollback structure.
1829b7c89284Ssnj */
1830b7c89284Ssnjtypedef struct {
1831b7c89284Ssnj	Dimension lineSize;	/* number of columns in this row */
1832b7c89284Ssnj	RowData bufHead;	/* flag for wrapped lines */
1833d522f475Smrg#if OPT_WIDE_CHARS
1834b7c89284Ssnj	Char combSize;		/* number of items in combData[] */
1835b7c89284Ssnj#endif
18369a64e1c5Smrg	IAttr *attribs;		/* video attributes */
1837b7c89284Ssnj#if OPT_ISO_COLORS
1838b7c89284Ssnj	CellColor *color;	/* foreground+background color numbers */
1839b7c89284Ssnj#endif
1840b7c89284Ssnj	CharData *charData;	/* cell's base character */
1841b7c89284Ssnj	CharData *combData[1];	/* first enum past fixed-offsets */
1842b7c89284Ssnj} LineData;
1843b7c89284Ssnj
184494644356Smrgtypedef const LineData CLineData;
184594644356Smrg
1846b7c89284Ssnj/*
1847b7c89284Ssnj * We use CellData in a few places, when copying a cell's data to a temporary
1848b7c89284Ssnj * variable.
1849b7c89284Ssnj */
1850b7c89284Ssnjtypedef struct {
18519a64e1c5Smrg	IAttr attribs;
1852b7c89284Ssnj#if OPT_WIDE_CHARS
1853b7c89284Ssnj	Char combSize;		/* number of items in combData[] */
1854b7c89284Ssnj#endif
1855b7c89284Ssnj#if OPT_ISO_COLORS
1856b7c89284Ssnj	CellColor color;	/* color-array */
1857d522f475Smrg#endif
1858b7c89284Ssnj	CharData charData;	/* cell's base character */
1859b7c89284Ssnj	CharData combData[1];	/* array of combining chars */
1860b7c89284Ssnj} CellData;
1861b7c89284Ssnj
1862b7c89284Ssnj#define for_each_combData(off, ld) for (off = 0; off < ld->combSize; ++off)
1863b7c89284Ssnj
1864d4fba8b9Smrg#define Clear1Cell(ld, x) \
1865d4fba8b9Smrg	do { \
1866d4fba8b9Smrg	    ld->charData[x] = ' '; \
1867d4fba8b9Smrg	    do { \
1868d4fba8b9Smrg	    if_OPT_WIDE_CHARS(screen, { \
1869d4fba8b9Smrg		size_t z; \
1870d4fba8b9Smrg		for_each_combData(z, ld) { \
1871d4fba8b9Smrg		    ld->combData[z][x] = '\0'; \
1872d4fba8b9Smrg		} \
1873d4fba8b9Smrg	    }) } while (0); \
1874d4fba8b9Smrg	} while (0)
1875d4fba8b9Smrg
1876d4fba8b9Smrg#define Clear2Cell(dst, src, x) \
1877d4fba8b9Smrg	do { \
1878d4fba8b9Smrg	    dst->charData[x] = ' '; \
1879d4fba8b9Smrg	    dst->attribs[x] = src->attribs[x]; \
1880d4fba8b9Smrg	    do { \
1881d4fba8b9Smrg	    if_OPT_ISO_COLORS(screen, { \
1882d4fba8b9Smrg		dst->color[x] = src->color[x]; \
1883d4fba8b9Smrg	    }) } while (0); \
1884d4fba8b9Smrg	    do { \
1885d4fba8b9Smrg	    if_OPT_WIDE_CHARS(screen, { \
1886d4fba8b9Smrg		size_t z; \
1887d4fba8b9Smrg		for_each_combData(z, dst) { \
1888d4fba8b9Smrg		    dst->combData[z][x] = '\0'; \
1889d4fba8b9Smrg		} \
1890d4fba8b9Smrg	    }) } while (0); \
1891d4fba8b9Smrg	} while (0)
1892d4fba8b9Smrg
1893b7c89284Ssnj/*
1894b7c89284Ssnj * Accommodate older compilers by not using variable-length arrays.
1895b7c89284Ssnj */
1896b7c89284Ssnj#define SizeOfLineData  offsetof(LineData, combData)
1897b7c89284Ssnj#define SizeOfCellData  offsetof(CellData, combData)
1898d522f475Smrg
1899d522f475Smrg	/*
1900d522f475Smrg	 * A "row" is the index within the visible part of the screen, and an
1901d522f475Smrg	 * "inx" is the index within the whole set of scrollable lines.
1902d522f475Smrg	 */
1903d522f475Smrg#define ROW2INX(screen, row)	((row) + (screen)->topline)
1904d522f475Smrg#define INX2ROW(screen, inx)	((inx) - (screen)->topline)
1905d522f475Smrg
190694644356Smrg/* these are unused but could be useful for debugging */
190794644356Smrg#if 0
1908d522f475Smrg#define ROW2ABS(screen, row)	((row) + (screen)->savedlines)
1909d522f475Smrg#define INX2ABS(screen, inx)	ROW2ABS(screen, INX2ROW(screen, inx))
191094644356Smrg#endif
1911d522f475Smrg
1912d522f475Smrg#define okScrnRow(screen, row) \
1913b7c89284Ssnj	((row) <= ((screen)->max_row - (screen)->topline) \
1914d522f475Smrg      && (row) >= -((screen)->savedlines))
1915d522f475Smrg
1916b7c89284Ssnj	/*
1917b7c89284Ssnj	 * Cache data for "proportional" and other fonts containing a mixture
1918b7c89284Ssnj	 * of widths.
1919b7c89284Ssnj	 */
1920b7c89284Ssnjtypedef struct {
19213367019cSmrg	Bool		mixed;
1922b7c89284Ssnj	Dimension	min_width;	/* nominal cell width for 0..255 */
1923b7c89284Ssnj	Dimension	max_width;	/* maximum cell width */
1924b7c89284Ssnj} FontMap;
1925d522f475Smrg
1926fa3f02f3Smrg#define KNOWN_MISSING	256
1927fa3f02f3Smrg
1928dfb07bc7Smrgtypedef enum {
1929dfb07bc7Smrg	fwNever = 0,
1930dfb07bc7Smrg	fwResource,
1931dfb07bc7Smrg	fwAlways
1932dfb07bc7Smrg} fontWarningTypes;
1933dfb07bc7Smrg
1934d522f475Smrgtypedef struct {
1935d522f475Smrg	unsigned	chrset;
1936d522f475Smrg	unsigned	flags;
1937dfb07bc7Smrg	fontWarningTypes warn;
1938d522f475Smrg	XFontStruct *	fs;
1939d522f475Smrg	char *		fn;
1940b7c89284Ssnj	FontMap		map;
1941fa3f02f3Smrg	Char		known_missing[KNOWN_MISSING];
1942d522f475Smrg} XTermFonts;
1943d522f475Smrg
1944b7c89284Ssnj#if OPT_RENDERFONT
1945cd3331d0Smrgtypedef enum {
1946cd3331d0Smrg	erFalse = 0
1947cd3331d0Smrg	, erTrue
1948cd3331d0Smrg	, erDefault
1949636d5e9fSmrg	, erDefaultOff
1950cd3331d0Smrg	, erLast
1951cd3331d0Smrg} RenderFont;
1952cd3331d0Smrg
1953cd3331d0Smrg#define DefaultRenderFont(xw) \
19543367019cSmrg	if ((xw)->work.render_font == erDefault) \
19553367019cSmrg	    (xw)->work.render_font = erFalse
1956cd3331d0Smrg
1957d4fba8b9Smrgtypedef enum {
1958d4fba8b9Smrg    	xcEmpty = 0			/* slot is unused */
1959d4fba8b9Smrg	, xcBogus			/* ignore this pattern */
1960d4fba8b9Smrg	, xcOpened			/* slot has open font descriptor */
1961d4fba8b9Smrg	, xcUnused			/* opened, but unused so far */
1962d4fba8b9Smrg} XftCache;
1963d4fba8b9Smrg
1964b7c89284Ssnjtypedef struct {
1965b7c89284Ssnj	XftFont *	font;
1966d4fba8b9Smrg	XftCache	usage;
1967d4fba8b9Smrg} XTermXftCache;
1968d4fba8b9Smrg
1969d4fba8b9Smrgtypedef struct {
1970d4fba8b9Smrg	XftFont *	font;		/* main font */
1971d4fba8b9Smrg	XftPattern *	pattern;	/* pattern for main font */
1972d4fba8b9Smrg	XftFontSet *	fontset;	/* ordered list of fallback patterns */
1973d4fba8b9Smrg	XTermXftCache * cache;
1974d4fba8b9Smrg	unsigned	limit;		/* allocated size of cache[] */
1975d4fba8b9Smrg	unsigned	opened;		/* number of slots with xcOpened */
1976b7c89284Ssnj	FontMap		map;
1977b7c89284Ssnj} XTermXftFonts;
1978d4fba8b9Smrg
1979d4fba8b9Smrgtypedef	struct _ListXftFonts {
1980d4fba8b9Smrg	struct _ListXftFonts *next;
1981d4fba8b9Smrg	XftFont *	font;
1982d4fba8b9Smrg} ListXftFonts;
1983b7c89284Ssnj#endif
1984b7c89284Ssnj
1985d522f475Smrgtypedef struct {
1986d522f475Smrg	int		top;
1987d522f475Smrg	int		left;
1988d522f475Smrg	int		bottom;
1989d522f475Smrg	int		right;
1990d522f475Smrg} XTermRect;
1991d522f475Smrg
1992d4fba8b9Smrg/***====================================================================***/
1993d4fba8b9Smrg
1994d522f475Smrg	/* indices into save_modes[] */
1995d522f475Smrgtypedef enum {
1996d4fba8b9Smrg	DP_ALLOW_ALTBUF,
19973367019cSmrg	DP_ALTERNATE_SCROLL,
19983367019cSmrg	DP_ALT_SENDS_ESC,
19993367019cSmrg	DP_BELL_IS_URGENT,
2000d522f475Smrg	DP_CRS_VISIBLE,
2001d522f475Smrg	DP_DECANM,
2002d522f475Smrg	DP_DECARM,
2003d522f475Smrg	DP_DECAWM,
2004d522f475Smrg	DP_DECBKM,
2005d522f475Smrg	DP_DECCKM,
2006d522f475Smrg	DP_DECCOLM,	/* IN132COLUMNS */
20073367019cSmrg	DP_DECKPAM,
20083367019cSmrg	DP_DECNRCM,
2009d522f475Smrg	DP_DECOM,
2010d522f475Smrg	DP_DECPEX,
2011d522f475Smrg	DP_DECPFF,
2012d522f475Smrg	DP_DECSCLM,
2013d522f475Smrg	DP_DECSCNM,
2014d522f475Smrg	DP_DECTCEM,
20153367019cSmrg	DP_DELETE_IS_DEL,
20163367019cSmrg	DP_EIGHT_BIT_META,
2017037a25ddSmrg	DP_KEEP_CLIPBOARD,
20183367019cSmrg	DP_KEEP_SELECTION,
20193367019cSmrg	DP_KEYBOARD_TYPE,
20203367019cSmrg	DP_POP_ON_BELL,
2021d522f475Smrg	DP_PRN_EXTENT,
2022d522f475Smrg	DP_PRN_FORMFEED,
20233367019cSmrg	DP_RXVT_SCROLLBAR,
20243367019cSmrg	DP_RXVT_SCROLL_TTY_KEYPRESS,
20253367019cSmrg	DP_RXVT_SCROLL_TTY_OUTPUT,
20263367019cSmrg	DP_SELECT_TO_CLIPBOARD,
2027d4fba8b9Smrg	DP_X_ALTBUF,
2028d522f475Smrg	DP_X_DECCOLM,
20293367019cSmrg	DP_X_EXT_MOUSE,
2030d522f475Smrg	DP_X_LOGGING,
20313367019cSmrg	DP_X_LRMM,
2032d522f475Smrg	DP_X_MARGIN,
2033d522f475Smrg	DP_X_MORE,
2034d522f475Smrg	DP_X_MOUSE,
20353367019cSmrg	DP_X_NCSM,
2036d522f475Smrg	DP_X_REVWRAP,
2037d522f475Smrg	DP_X_X10MSE,
2038d522f475Smrg#if OPT_BLINK_CURS
2039d522f475Smrg	DP_CRS_BLINK,
2040d522f475Smrg#endif
2041d522f475Smrg#if OPT_FOCUS_EVENT
2042d522f475Smrg	DP_X_FOCUS,
2043d522f475Smrg#endif
20443367019cSmrg#if OPT_NUM_LOCK
20453367019cSmrg	DP_REAL_NUMLOCK,
20463367019cSmrg	DP_META_SENDS_ESC,
20473367019cSmrg#endif
20483367019cSmrg#if OPT_SHIFT_FONTS
20493367019cSmrg	DP_RXVT_FONTSIZE,
20503367019cSmrg#endif
2051fa3f02f3Smrg#if OPT_SIXEL_GRAPHICS
2052fa3f02f3Smrg	DP_DECSDM,
2053fa3f02f3Smrg#endif
20543367019cSmrg#if OPT_TEK4014
20553367019cSmrg	DP_DECTEK,
20563367019cSmrg#endif
2057d522f475Smrg#if OPT_TOOLBAR
2058d522f475Smrg	DP_TOOLBAR,
2059d522f475Smrg#endif
2060d4fba8b9Smrg#if OPT_GRAPHICS
2061fa3f02f3Smrg	DP_X_PRIVATE_COLOR_REGISTERS,
2062d4fba8b9Smrg#endif
20639a64e1c5Smrg#if OPT_SIXEL_GRAPHICS
20649a64e1c5Smrg	DP_SIXEL_SCROLLS_RIGHT,
2065d4fba8b9Smrg#endif
2066d4fba8b9Smrg#if OPT_PRINT_GRAPHICS
2067d4fba8b9Smrg	DP_DECGEPM,  /* Graphics Expanded Print Mode */
2068d4fba8b9Smrg	DP_DECGPCM,  /* Graphics Print Color Mode */
2069d4fba8b9Smrg	DP_DECGPCS,  /* Graphics Print Color Syntax */
2070d4fba8b9Smrg	DP_DECGPBM,  /* Graphics Print Background Mode */
2071d4fba8b9Smrg	DP_DECGRPM,  /* Graphics Rotated Print Mode */
20729a64e1c5Smrg#endif
2073d522f475Smrg	DP_LAST
2074d522f475Smrg} SaveModes;
2075d522f475Smrg
20760d92cbfdSchristos#define DoSM(code,value)  screen->save_modes[code] = (unsigned) (value)
20770d92cbfdSchristos#define DoRM(code,value)  value = (Boolean) screen->save_modes[code]
20780d92cbfdSchristos#define DoRM0(code,value) value = screen->save_modes[code]
2079d522f475Smrg
2080d522f475Smrg	/* index into vt_shell[] or tek_shell[] */
2081d522f475Smrgtypedef enum {
2082dfb07bc7Smrg	noMenu = -1
2083dfb07bc7Smrg	,mainMenu
2084dfb07bc7Smrg	,vtMenu
2085dfb07bc7Smrg	,fontMenu
2086b7c89284Ssnj#if OPT_TEK4014
2087dfb07bc7Smrg	,tekMenu
2088b7c89284Ssnj#endif
2089d522f475Smrg} MenuIndex;
2090d522f475Smrg
2091cd3331d0Smrgtypedef enum {
2092cd3331d0Smrg	bvOff = -1,
2093cd3331d0Smrg	bvLow = 0,
2094cd3331d0Smrg	bvHigh
2095cd3331d0Smrg} BellVolume;
2096cd3331d0Smrg
2097d522f475Smrg#define NUM_POPUP_MENUS 4
2098d522f475Smrg
2099d522f475Smrg#if OPT_COLOR_RES
2100d522f475Smrgtypedef struct {
2101d522f475Smrg	String		resource;
2102d522f475Smrg	Pixel		value;
21033367019cSmrg	unsigned short red, green, blue;
2104cd3331d0Smrg	int		mode;		/* -1=invalid, 0=unset, 1=set   */
2105d522f475Smrg} ColorRes;
2106d522f475Smrg#else
2107d522f475Smrg#define ColorRes Pixel
2108d522f475Smrg#endif
2109d522f475Smrg
2110cd3331d0Smrg/* these are set in getPrinterFlags */
2111cd3331d0Smrgtypedef struct {
2112cd3331d0Smrg	int	printer_extent;		/* print complete page		*/
2113cd3331d0Smrg	int	printer_formfeed;	/* print formfeed per function	*/
2114cd3331d0Smrg	int	printer_newline;	/* print newline per function	*/
2115cd3331d0Smrg	int	print_attributes;	/* 0=off, 1=normal, 2=color	*/
2116712a7ff4Smrg	int	print_everything;	/* 0=all, 1=dft, 2=alt, 3=saved */
2117cd3331d0Smrg} PrinterFlags;
2118cd3331d0Smrg
2119712a7ff4Smrgtypedef struct {
2120712a7ff4Smrg	FILE *	fp;			/* output file/pipe used	*/
2121712a7ff4Smrg	Boolean isOpen;			/* output was opened/tried	*/
2122712a7ff4Smrg	Boolean toFile;			/* true when directly to file	*/
21233367019cSmrg	Boolean printer_checked;	/* printer_command is checked	*/
2124712a7ff4Smrg	String	printer_command;	/* pipe/shell command string	*/
2125712a7ff4Smrg	Boolean printer_autoclose;	/* close printer when offline	*/
2126712a7ff4Smrg	Boolean printer_extent;		/* print complete page		*/
2127712a7ff4Smrg	Boolean printer_formfeed;	/* print formfeed per function	*/
2128712a7ff4Smrg	Boolean printer_newline;	/* print newline per function	*/
2129712a7ff4Smrg	int	printer_controlmode;	/* 0=off, 1=auto, 2=controller	*/
2130712a7ff4Smrg	int	print_attributes;	/* 0=off, 1=normal, 2=color	*/
2131712a7ff4Smrg	int	print_everything;	/* 0=all, 1=dft, 2=alt, 3=saved */
2132712a7ff4Smrg} PrinterState;
2133712a7ff4Smrg
2134d522f475Smrgtypedef struct {
2135d522f475Smrg	unsigned	which;		/* must have NCOLORS bits */
2136d522f475Smrg	Pixel		colors[NCOLORS];
2137d522f475Smrg	char		*names[NCOLORS];
2138d522f475Smrg} ScrnColors;
2139d522f475Smrg
2140d4fba8b9Smrg#define NUM_GSETS 4
2141d4fba8b9Smrg
2142d522f475Smrgtypedef struct {
2143d522f475Smrg	Boolean		saved;
2144d522f475Smrg	int		row;
2145d522f475Smrg	int		col;
21469a64e1c5Smrg	IFlags		flags;		/* VTxxx saves graphics rendition */
21470d92cbfdSchristos	Char		curgl;
21480d92cbfdSchristos	Char		curgr;
2149d4fba8b9Smrg	DECNRCM_codes	gsets[NUM_GSETS];
2150dfb07bc7Smrg	Boolean		wrap_flag;
2151d522f475Smrg#if OPT_ISO_COLORS
2152d4fba8b9Smrg	int		cur_foreground;  /* current foreground color	*/
2153d4fba8b9Smrg	int		cur_background;  /* current background color	*/
2154d4fba8b9Smrg	int		sgr_foreground;  /* current SGR foreground color */
2155d4fba8b9Smrg	int		sgr_background;  /* current SGR background color */
2156d4fba8b9Smrg	Boolean		sgr_38_xcolors;  /* true if ISO 8613 extension	*/
2157d522f475Smrg#endif
2158d522f475Smrg} SavedCursor;
2159d522f475Smrg
2160cd3331d0Smrgtypedef struct _SaveTitle {
21613367019cSmrg	struct _SaveTitle *next;
2162cd3331d0Smrg	char		*iconName;
2163cd3331d0Smrg	char		*windowName;
2164cd3331d0Smrg} SaveTitle;
2165cd3331d0Smrg
2166d522f475Smrg#define SAVED_CURSORS 2
2167d522f475Smrg
2168d522f475Smrgtypedef struct {
2169d522f475Smrg	int		width;		/* if > 0, width of scrollbar,	*/
2170d522f475Smrg					/* and scrollbar is showing	*/
2171d522f475Smrg	Boolean		rv_cached;	/* see ScrollBarReverseVideo	*/
2172d522f475Smrg	int		rv_active;	/* ...current reverse-video	*/
2173d522f475Smrg	Pixel		bg;		/* ...cached background color	*/
2174d522f475Smrg	Pixel		fg;		/* ...cached foreground color	*/
2175d522f475Smrg	Pixel		bdr;		/* ...cached border color	*/
2176d522f475Smrg	Pixmap		bdpix;		/* ...cached border pixmap	*/
2177d522f475Smrg} SbInfo;
2178d522f475Smrg
2179d522f475Smrg#if OPT_TOOLBAR
2180d522f475Smrgtypedef struct {
2181d522f475Smrg	Widget		menu_bar;	/* toolbar, if initialized	*/
2182d522f475Smrg	Dimension	menu_height;	/* ...and its height		*/
2183d522f475Smrg	Dimension	menu_border;	/* ...and its border		*/
2184d522f475Smrg} TbInfo;
2185d522f475Smrg#define VT100_TB_INFO(name) screen.fullVwin.tb_info.name
2186d522f475Smrg#endif
2187d522f475Smrg
2188d522f475Smrgtypedef struct {
2189d522f475Smrg	Window		window;		/* X window id			*/
2190d4fba8b9Smrg	int		width;		/* width of columns in pixels	*/
2191d4fba8b9Smrg	int		height;		/* height of rows in pixels	*/
2192d522f475Smrg	Dimension	fullwidth;	/* full width of window		*/
2193d522f475Smrg	Dimension	fullheight;	/* full height of window	*/
2194d522f475Smrg	int		f_width;	/* width of fonts in pixels	*/
2195d522f475Smrg	int		f_height;	/* height of fonts in pixels	*/
2196d522f475Smrg	int		f_ascent;	/* ascent of font in pixels	*/
2197d522f475Smrg	int		f_descent;	/* descent of font in pixels	*/
2198d522f475Smrg	SbInfo		sb_info;
2199d4fba8b9Smrg	GC		filler_gc;	/* filler's fg/bg		*/
2200d4fba8b9Smrg	GC		border_gc;	/* inner border's fg/bg		*/
2201d4fba8b9Smrg	GC		marker_gc[2];	/* wrap-marks			*/
2202d4fba8b9Smrg#if USE_DOUBLE_BUFFER
22033367019cSmrg	Drawable	drawable;	/* X drawable id                */
22043367019cSmrg#endif
2205d522f475Smrg#if OPT_TOOLBAR
2206d522f475Smrg	Boolean		active;		/* true if toolbars are used	*/
2207d522f475Smrg	TbInfo		tb_info;	/* toolbar information		*/
2208d522f475Smrg#endif
2209d522f475Smrg} VTwin;
2210d522f475Smrg
2211d522f475Smrgtypedef struct {
2212d522f475Smrg	Window		window;		/* X window id			*/
2213d522f475Smrg	int		width;		/* width of columns		*/
2214d522f475Smrg	int		height;		/* height of rows		*/
2215d522f475Smrg	Dimension	fullwidth;	/* full width of window		*/
2216d522f475Smrg	Dimension	fullheight;	/* full height of window	*/
2217d522f475Smrg	double		tekscale;	/* scale factor Tek -> vs100	*/
2218d522f475Smrg} TKwin;
2219d522f475Smrg
2220712a7ff4Smrgtypedef struct {
2221dfb07bc7Smrg    char *f_n;			/* the normal font */
2222dfb07bc7Smrg    char *f_b;			/* the bold font */
2223712a7ff4Smrg#if OPT_WIDE_CHARS
2224dfb07bc7Smrg    char *f_w;			/* the normal wide font */
2225dfb07bc7Smrg    char *f_wb;			/* the bold wide font */
2226712a7ff4Smrg#endif
2227712a7ff4Smrg} VTFontNames;
2228712a7ff4Smrg
2229dfb07bc7Smrgtypedef struct {
2230dfb07bc7Smrg    char **list_n;		/* the normal font */
2231dfb07bc7Smrg    char **list_b;		/* the bold font */
2232dfb07bc7Smrg#if OPT_WIDE_ATTRS || OPT_RENDERWIDE
2233dfb07bc7Smrg    char **list_i;		/* italic font (Xft only) */
2234d4fba8b9Smrg    char **list_bi;		/* bold-italic font (Xft only) */
2235dfb07bc7Smrg#endif
2236dfb07bc7Smrg#if OPT_WIDE_CHARS
2237dfb07bc7Smrg    char **list_w;		/* the normal wide font */
2238dfb07bc7Smrg    char **list_wb;		/* the bold wide font */
2239dfb07bc7Smrg    char **list_wi;		/* wide italic font (Xft only) */
2240d4fba8b9Smrg    char **list_wbi;		/* wide bold-italic font (Xft only) */
2241dfb07bc7Smrg#endif
2242dfb07bc7Smrg} VTFontList;
2243dfb07bc7Smrg
2244dfb07bc7Smrgtypedef struct {
2245dfb07bc7Smrg    VTFontList x11;
2246dfb07bc7Smrg#if OPT_RENDERFONT
2247dfb07bc7Smrg    VTFontList xft;
2248dfb07bc7Smrg#endif
2249dfb07bc7Smrg} XtermFontNames;
2250dfb07bc7Smrg
2251712a7ff4Smrgtypedef struct {
2252712a7ff4Smrg    VTFontNames default_font;
2253712a7ff4Smrg    String menu_font_names[NMENUFONTS][fMAX];
2254dfb07bc7Smrg    XtermFontNames fonts;
2255712a7ff4Smrg} SubResourceRec;
2256712a7ff4Smrg
22573367019cSmrg#if OPT_INPUT_METHOD
22583367019cSmrg#define NINPUTWIDGETS	3
22593367019cSmrgtypedef struct {
22603367019cSmrg	Widget		w;
22613367019cSmrg	XIM		xim;		/* input method attached to 'w' */
22623367019cSmrg	XIC		xic;		/* input context attached to 'xim' */
22633367019cSmrg} TInput;
22643367019cSmrg#endif
22653367019cSmrg
22663367019cSmrgtypedef enum {
22673367019cSmrg	CURSOR_BLOCK = 2
22683367019cSmrg	, CURSOR_UNDERLINE = 4
22693367019cSmrg	, CURSOR_BAR = 6
22703367019cSmrg} XtCursorShape;
22713367019cSmrg
22723367019cSmrg#define isCursorBlock(s)	((s)->cursor_shape == CURSOR_BLOCK)
22733367019cSmrg#define isCursorUnderline(s)	((s)->cursor_shape == CURSOR_UNDERLINE)
22743367019cSmrg#define isCursorBar(s)		((s)->cursor_shape == CURSOR_BAR)
22753367019cSmrg
22763367019cSmrgtypedef enum {
22773367019cSmrg	DEFAULT_STYLE = 0
22783367019cSmrg	, BLINK_BLOCK
22793367019cSmrg	, STEADY_BLOCK
22803367019cSmrg	, BLINK_UNDERLINE
22813367019cSmrg	, STEADY_UNDERLINE
22823367019cSmrg	, BLINK_BAR
22833367019cSmrg	, STEADY_BAR
22843367019cSmrg} XtCursorStyle;
22853367019cSmrg
2286d4fba8b9Smrg#if OPT_GRAPHICS
2287d4fba8b9Smrg#define GraphicsTermId(screen) (\
2288d4fba8b9Smrg	(screen)->graphics_termid \
2289d4fba8b9Smrg	 ? (screen)->graphics_termid \
2290d4fba8b9Smrg	 : (screen)->terminal_id)
2291d4fba8b9Smrg#else
2292d4fba8b9Smrg#define GraphicsTermId(screen) (screen)->terminal_id
2293d4fba8b9Smrg#endif
2294d4fba8b9Smrg
2295d4fba8b9Smrg#if OPT_REGIS_GRAPHICS
2296d4fba8b9Smrg#define optRegisGraphics(screen) \
2297d4fba8b9Smrg	(GraphicsTermId(screen) == 125 || \
2298d4fba8b9Smrg	 GraphicsTermId(screen) == 240 || \
2299d4fba8b9Smrg	 GraphicsTermId(screen) == 241 || \
2300d4fba8b9Smrg	 GraphicsTermId(screen) == 330 || \
2301d4fba8b9Smrg	 GraphicsTermId(screen) == 340)
2302d4fba8b9Smrg#else
2303d4fba8b9Smrg#define optRegisGraphics(screen) False
2304d4fba8b9Smrg#endif
2305d4fba8b9Smrg
2306d4fba8b9Smrg#if OPT_SIXEL_GRAPHICS
2307d4fba8b9Smrg#define optSixelGraphics(screen) \
2308d4fba8b9Smrg	(GraphicsTermId(screen) == 240 || \
2309d4fba8b9Smrg	 GraphicsTermId(screen) == 241 || \
2310d4fba8b9Smrg	 GraphicsTermId(screen) == 330 || \
2311d4fba8b9Smrg	 GraphicsTermId(screen) == 340 || \
2312d4fba8b9Smrg	 GraphicsTermId(screen) == 382)
2313d4fba8b9Smrg#else
2314d4fba8b9Smrg#define optSixelGraphics(screen) False
2315d4fba8b9Smrg#endif
2316d4fba8b9Smrg
2317d4fba8b9Smrg#if OPT_PRINT_GRAPHICS
2318d4fba8b9Smrg#define if_PRINT_GRAPHICS2(statement) if (optRegisGraphics(screen)) { statement; } else
2319d4fba8b9Smrg#else
2320d4fba8b9Smrg#define if_PRINT_GRAPHICS2(statement) /* nothing */
2321d4fba8b9Smrg#endif
2322d4fba8b9Smrg
2323d522f475Smrgtypedef struct {
2324d522f475Smrg/* These parameters apply to both windows */
2325d522f475Smrg	Display		*display;	/* X display for screen		*/
2326d522f475Smrg	int		respond;	/* socket for responses
2327d522f475Smrg					   (position report, etc.)	*/
2328d4fba8b9Smrg	int		nextEventDelay;	/* msecs to delay for x-events  */
2329d522f475Smrg/* These parameters apply to VT100 window */
2330d4fba8b9Smrg	IChar		*unparse_bfr;
2331d522f475Smrg	unsigned	unparse_len;
2332d4fba8b9Smrg	unsigned	unparse_max;	/* limitResponse resource	*/
2333d522f475Smrg
2334d522f475Smrg#if OPT_TCAP_QUERY
2335d522f475Smrg	int		tc_query_code;
2336d522f475Smrg	Bool		tc_query_fkey;
2337d522f475Smrg#endif
2338d522f475Smrg	pid_t		pid;		/* pid of process on far side   */
2339d522f475Smrg	uid_t		uid;		/* user id of actual person	*/
2340d522f475Smrg	gid_t		gid;		/* group id of actual person	*/
2341d522f475Smrg	ColorRes	Tcolors[NCOLORS]; /* terminal colors		*/
2342d522f475Smrg#if OPT_HIGHLIGHT_COLOR
2343d522f475Smrg	Boolean		hilite_color;	/* hilite colors override	*/
2344d522f475Smrg	Boolean		hilite_reverse;	/* hilite overrides reverse	*/
2345d522f475Smrg#endif
2346d522f475Smrg#if OPT_ISO_COLORS
23473367019cSmrg	XColor *	cmap_data;	/* color table			*/
23483367019cSmrg	unsigned	cmap_size;
2349d522f475Smrg	ColorRes	Acolors[MAXCOLORS]; /* ANSI color emulation	*/
2350d522f475Smrg	int		veryBoldColors;	/* modifier for boldColors	*/
2351d522f475Smrg	Boolean		boldColors;	/* can we make bold colors?	*/
2352d522f475Smrg	Boolean		colorMode;	/* are we using color mode?	*/
2353d522f475Smrg	Boolean		colorULMode;	/* use color for underline?	*/
2354d522f475Smrg	Boolean		italicULMode;	/* italic font for underline?	*/
2355d522f475Smrg	Boolean		colorBDMode;	/* use color for bold?		*/
2356d522f475Smrg	Boolean		colorBLMode;	/* use color for blink?		*/
2357d522f475Smrg	Boolean		colorRVMode;	/* use color for reverse?	*/
2358d522f475Smrg	Boolean		colorAttrMode;	/* prefer colorUL/BD to SGR	*/
235994644356Smrg#if OPT_WIDE_ATTRS
236094644356Smrg	Boolean		colorITMode;	/* use color for italics?	*/
236194644356Smrg#endif
2362d4fba8b9Smrg#if OPT_DIRECT_COLOR
2363d4fba8b9Smrg	Boolean		direct_color;	/* direct-color enabled?	*/
2364d522f475Smrg#endif
2365d4fba8b9Smrg#endif /* OPT_ISO_COLORS */
2366d522f475Smrg#if OPT_DEC_CHRSET
2367d522f475Smrg	Boolean		font_doublesize;/* enable font-scaling		*/
2368d522f475Smrg	int		cache_doublesize;/* limit of our cache		*/
2369d522f475Smrg	Char		cur_chrset;	/* character-set index & code	*/
2370d522f475Smrg	int		fonts_used;	/* count items in double_fonts	*/
2371d522f475Smrg	XTermFonts	double_fonts[NUM_CHRSET];
2372d4fba8b9Smrg#if OPT_RENDERFONT
2373d4fba8b9Smrg	XftFont *	double_xft_fonts[NUM_CHRSET];
2374d522f475Smrg#endif
2375d4fba8b9Smrg#endif /* OPT_DEC_CHRSET */
2376d522f475Smrg#if OPT_DEC_RECTOPS
2377d522f475Smrg	int		cur_decsace;	/* parameter for DECSACE	*/
2378d4fba8b9Smrg	int		checksum_ext;	/* extensions for DECRQCRA	*/
2379d4fba8b9Smrg	int		checksum_ext0;	/* initial checksumExtension	*/
2380d522f475Smrg#endif
2381d522f475Smrg#if OPT_WIDE_CHARS
2382d522f475Smrg	Boolean		wide_chars;	/* true when 16-bit chars	*/
2383d522f475Smrg	Boolean		vt100_graphics;	/* true to allow vt100-graphics	*/
2384d522f475Smrg	Boolean		utf8_inparse;	/* true to enable UTF-8 parser	*/
23853367019cSmrg	Boolean		normalized_c;	/* true to precompose to Form C */
2386712a7ff4Smrg	char *		utf8_mode_s;	/* use UTF-8 decode/encode	*/
2387712a7ff4Smrg	char *		utf8_fonts_s;	/* use UTF-8 decode/encode	*/
2388d4fba8b9Smrg	char *		utf8_title_s;	/* use UTF-8 titles		*/
2389fa3f02f3Smrg	int		utf8_nrc_mode;	/* saved UTF-8 mode for DECNRCM */
2390fa3f02f3Smrg	Boolean		utf8_always;	/* special case for wideChars	*/
2391d522f475Smrg	int		utf8_mode;	/* use UTF-8 decode/encode: 0-2	*/
2392d4fba8b9Smrg	int		utf8_fonts;	/* use UTF-8 fonts: 0-2		*/
2393d4fba8b9Smrg	int		utf8_title;	/* use UTF-8 EWHM props: 0-2	*/
2394d522f475Smrg	int		max_combining;	/* maximum # of combining chars	*/
2395d522f475Smrg	Boolean		utf8_latin1;	/* use UTF-8 with Latin-1 bias	*/
2396d4fba8b9Smrg	Boolean		utf8_weblike;	/* use UTF-8 with browser bias	*/
2397d522f475Smrg	int		latin9_mode;	/* poor man's luit, latin9	*/
2398d522f475Smrg	int		unicode_font;	/* font uses unicode encoding	*/
2399d522f475Smrg	int		utf_count;	/* state of utf_char		*/
2400d522f475Smrg	IChar		utf_char;	/* in-progress character	*/
24013367019cSmrg	Boolean		char_was_written;
2402d522f475Smrg	int		last_written_col;
2403d522f475Smrg	int		last_written_row;
2404b7c89284Ssnj	TypedBuffer(XChar2b);
2405b7c89284Ssnj	TypedBuffer(char);
2406d522f475Smrg#endif
2407d522f475Smrg#if OPT_BROKEN_OSC
2408d522f475Smrg	Boolean		brokenLinuxOSC; /* true to ignore Linux palette ctls */
2409d522f475Smrg#endif
2410d522f475Smrg#if OPT_BROKEN_ST
2411d522f475Smrg	Boolean		brokenStringTerm; /* true to match old OSC parse */
2412d522f475Smrg#endif
2413d522f475Smrg#if OPT_C1_PRINT || OPT_WIDE_CHARS
2414d522f475Smrg	Boolean		c1_printable;	/* true if we treat C1 as print	*/
2415d522f475Smrg#endif
2416d522f475Smrg	int		border;		/* inner border			*/
2417d522f475Smrg	int		scrollBarBorder; /* scrollBar border		*/
24180d92cbfdSchristos	long		event_mask;
24190d92cbfdSchristos	unsigned	send_mouse_pos;	/* user wants mouse transition  */
2420d522f475Smrg					/* and position information	*/
24213367019cSmrg	int		extend_coords;	/* support large terminals	*/
2422dfb07bc7Smrg#if OPT_FOCUS_EVENT
2423d522f475Smrg	Boolean		send_focus_pos; /* user wants focus in/out info */
2424dfb07bc7Smrg#endif
2425d522f475Smrg	Boolean		quiet_grab;	/* true if no cursor change on focus */
2426d522f475Smrg#if OPT_PASTE64
2427b7c89284Ssnj	Cardinal	base64_paste;	/* set to send paste in base64	*/
2428d522f475Smrg	int		base64_final;	/* string-terminator for paste	*/
2429d522f475Smrg	/* _qWriteSelectionData expects these to be initialized to zero.
2430d522f475Smrg	 * base64_flush() is the last step of the conversion, it clears these
2431d522f475Smrg	 * variables.
2432d522f475Smrg	 */
24330d92cbfdSchristos	unsigned	base64_accu;
24340d92cbfdSchristos	unsigned	base64_count;
24350d92cbfdSchristos	unsigned	base64_pad;
2436d522f475Smrg#endif
2437d4fba8b9Smrg#if OPT_PASTE64 || OPT_READLINE
2438d4fba8b9Smrg	unsigned	paste_brackets;
2439d4fba8b9Smrg	/* not part of bracketed-paste, these are here to simplify ifdefs */
2440d4fba8b9Smrg	unsigned	dclick3_deletes;
2441d4fba8b9Smrg	unsigned	paste_literal_nl;
2442d4fba8b9Smrg#endif
2443d522f475Smrg#if OPT_READLINE
2444d522f475Smrg	unsigned	click1_moves;
2445d522f475Smrg	unsigned	paste_moves;
2446d522f475Smrg	unsigned	paste_quotes;
2447d522f475Smrg#endif	/* OPT_READLINE */
2448d522f475Smrg#if OPT_DEC_LOCATOR
2449d522f475Smrg	Boolean		locator_reset;	/* turn mouse off after 1 report? */
2450d522f475Smrg	Boolean		locator_pixels;	/* report in pixels?		*/
2451d522f475Smrg					/* if false, report in cells	*/
24520d92cbfdSchristos	unsigned	locator_events;	/* what events to report	*/
2453d522f475Smrg	Boolean		loc_filter;	/* is filter rectangle active?	*/
2454d522f475Smrg	int		loc_filter_top;	/* filter rectangle for DEC Locator */
2455d522f475Smrg	int		loc_filter_left;
2456d522f475Smrg	int		loc_filter_bottom;
2457d522f475Smrg	int		loc_filter_right;
2458d522f475Smrg#endif	/* OPT_DEC_LOCATOR */
2459d522f475Smrg	int		mouse_button;	/* current button pressed	*/
2460d522f475Smrg	int		mouse_row;	/* ...and its row		*/
2461d522f475Smrg	int		mouse_col;	/* ...and its column		*/
2462d522f475Smrg	int		select;		/* xterm selected		*/
2463d522f475Smrg	Boolean		bellOnReset;	/* bellOnReset			*/
2464d522f475Smrg	Boolean		visualbell;	/* visual bell mode		*/
2465d522f475Smrg	Boolean		poponbell;	/* pop on bell mode		*/
24660d92cbfdSchristos
2467dfb07bc7Smrg	Boolean		eraseSavedLines; /* eraseSavedLines option	*/
2468dfb07bc7Smrg	Boolean		eraseSavedLines0; /* initial eraseSavedLines	*/
2469dfb07bc7Smrg	Boolean		tabCancelsWrap; /* tabCancelsWrap option	*/
2470dfb07bc7Smrg
24713367019cSmrg	Boolean		allowPasteControls; /* PasteControls mode	*/
2472cd3331d0Smrg	Boolean		allowColorOps;	/* ColorOps mode		*/
24730d92cbfdSchristos	Boolean		allowFontOps;	/* FontOps mode			*/
2474dfb07bc7Smrg	Boolean		allowMouseOps;	/* MouseOps mode		*/
2475d522f475Smrg	Boolean		allowSendEvents;/* SendEvent mode		*/
24760d92cbfdSchristos	Boolean		allowTcapOps;	/* TcapOps mode			*/
2477d522f475Smrg	Boolean		allowTitleOps;	/* TitleOps mode		*/
2478d522f475Smrg	Boolean		allowWindowOps;	/* WindowOps mode		*/
24790d92cbfdSchristos
248094644356Smrg	Boolean		allowPasteControl0; /* PasteControls mode	*/
2481cd3331d0Smrg	Boolean		allowColorOp0;	/* initial ColorOps mode	*/
24820d92cbfdSchristos	Boolean		allowFontOp0;	/* initial FontOps mode		*/
2483dfb07bc7Smrg	Boolean		allowMouseOp0;	/* initial MouseOps mode	*/
2484d522f475Smrg	Boolean		allowSendEvent0;/* initial SendEvent mode	*/
24850d92cbfdSchristos	Boolean		allowTcapOp0;	/* initial TcapOps mode		*/
2486d522f475Smrg	Boolean		allowTitleOp0;	/* initial TitleOps mode	*/
2487d522f475Smrg	Boolean		allowWindowOp0;	/* initial WindowOps mode	*/
24880d92cbfdSchristos
2489cd3331d0Smrg	String		disallowedColorOps;
2490cd3331d0Smrg	char		disallow_color_ops[ecLAST];
2491cd3331d0Smrg
2492cd3331d0Smrg	String		disallowedFontOps;
2493cd3331d0Smrg	char		disallow_font_ops[efLAST];
2494cd3331d0Smrg
2495dfb07bc7Smrg	String		disallowedMouseOps;
2496dfb07bc7Smrg	char		disallow_mouse_ops[emLAST];
2497dfb07bc7Smrg
2498d4fba8b9Smrg	String		disallowedPasteControls;
2499d4fba8b9Smrg	char		disallow_paste_controls[epLAST];
2500d4fba8b9Smrg
2501cd3331d0Smrg	String		disallowedTcapOps;
2502cd3331d0Smrg	char		disallow_tcap_ops[etLAST];
2503cd3331d0Smrg
2504cd3331d0Smrg	String		disallowedWinOps;
2505cd3331d0Smrg	char		disallow_win_ops[ewLAST];
2506cd3331d0Smrg
2507d522f475Smrg	Boolean		awaitInput;	/* select-timeout mode		*/
2508d522f475Smrg	Boolean		grabbedKbd;	/* keyboard is grabbed		*/
2509d522f475Smrg#ifdef ALLOWLOGGING
2510d522f475Smrg	int		logging;	/* logging mode			*/
2511d522f475Smrg	int		logfd;		/* file descriptor of log	*/
2512d522f475Smrg	char		*logfile;	/* log file name		*/
2513d522f475Smrg	Char		*logstart;	/* current start of log buffer	*/
2514d522f475Smrg#endif
2515d522f475Smrg	int		inhibit;	/* flags for inhibiting changes	*/
2516d522f475Smrg
2517d522f475Smrg/* VT window parameters */
2518d522f475Smrg	Boolean		Vshow;		/* VT window showing		*/
2519d522f475Smrg	VTwin		fullVwin;
25203367019cSmrg	int		needSwap;
2521d522f475Smrg#ifndef NO_ACTIVE_ICON
2522d522f475Smrg	VTwin		iconVwin;
2523d522f475Smrg	VTwin		*whichVwin;
2524d522f475Smrg#endif /* NO_ACTIVE_ICON */
2525d522f475Smrg
2526d522f475Smrg	int		pointer_mode;	/* when to use hidden_cursor	*/
25279a64e1c5Smrg	int		pointer_mode0;	/* ...initial value             */
2528d522f475Smrg	Boolean 	hide_pointer;	/* true to use "hidden_cursor"  */
2529d4fba8b9Smrg	String		pointer_shape;	/* name of shape in cursor font */
25308f44fb3bSmrg	Cursor		pointer_cursor;	/* current pointer cursor	*/
2531d522f475Smrg	Cursor		hidden_cursor;	/* hidden cursor in window	*/
2532d522f475Smrg
2533d522f475Smrg	String	answer_back;		/* response to ENQ		*/
2534d522f475Smrg
2535712a7ff4Smrg	PrinterState	printer_state;	/* actual printer state		*/
2536cd3331d0Smrg	PrinterFlags	printer_flags;	/* working copy of printer flags */
2537712a7ff4Smrg#if OPT_PRINT_ON_EXIT
2538712a7ff4Smrg	Boolean		write_error;
2539712a7ff4Smrg#endif
2540cd3331d0Smrg
2541d522f475Smrg	Boolean		fnt_prop;	/* true if proportional fonts	*/
2542d4fba8b9Smrg	unsigned	fnt_boxes;	/* 0=no boxes, 1=old, 2=unicode */
2543cd3331d0Smrg	Boolean		force_packed;	/* true to override proportional */
2544d522f475Smrg#if OPT_BOX_CHARS
25453367019cSmrg	Boolean		force_box_chars;/* true if we assume no boxchars */
2546d4fba8b9Smrg	Boolean		broken_box_chars;/* true if broken boxchars	*/
2547cd3331d0Smrg	Boolean		force_all_chars;/* true to outline missing chars */
2548fa3f02f3Smrg	Boolean		assume_all_chars;/* true to allow missing chars */
2549cd3331d0Smrg	Boolean		allow_packing;	/* true to allow packed-fonts	*/
2550d522f475Smrg#endif
2551d522f475Smrg	Dimension	fnt_wide;
2552d522f475Smrg	Dimension	fnt_high;
25533367019cSmrg	float		scale_height;	/* scaling for font-height	*/
2554d522f475Smrg	XTermFonts	fnts[fMAX];	/* normal/bold/etc for terminal	*/
2555d522f475Smrg	Boolean		free_bold_box;	/* same_font_size's austerity	*/
2556712a7ff4Smrg	Boolean		allowBoldFonts;	/* do we use bold fonts at all? */
25579a64e1c5Smrg#if OPT_WIDE_ATTRS
25589a64e1c5Smrg	XTermFonts	ifnts[fMAX];	/* normal/bold/etc italic fonts */
25599a64e1c5Smrg	Boolean		ifnts_ok;	/* true if ifnts[] is cached	*/
25609a64e1c5Smrg#endif
2561d522f475Smrg#ifndef NO_ACTIVE_ICON
2562cb4a1343Smrg	XTermFonts	fnt_icon;	/* icon font			*/
2563cb4a1343Smrg	String		icon_fontname;	/* name of icon font		*/
2564cb4a1343Smrg	int		icon_fontnum;	/* number to use for icon font	*/
2565d522f475Smrg#endif /* NO_ACTIVE_ICON */
2566d522f475Smrg	int		enbolden;	/* overstrike for bold font	*/
2567d522f475Smrg	XPoint		*box;		/* draw unselected cursor	*/
2568d522f475Smrg
2569d522f475Smrg	int		cursor_state;	/* ON, OFF, or BLINKED_OFF	*/
2570d522f475Smrg	int		cursor_busy;	/* do not redraw...		*/
25710d92cbfdSchristos	Boolean		cursor_underline; /* true if cursor is in underline mode */
25723367019cSmrg	XtCursorShape	cursor_shape;
2573d522f475Smrg#if OPT_BLINK_CURS
2574d4fba8b9Smrg	BlinkOps	cursor_blink;	/* cursor blink enable		*/
2575d4fba8b9Smrg	BlinkOps	cursor_blink_i;	/* save cursor blink enable	*/
2576d4fba8b9Smrg	char *		cursor_blink_s;	/* ...resource cursorBlink	*/
2577d4fba8b9Smrg	int		cursor_blink_esc; /* cursor blink escape-state	*/
2578d4fba8b9Smrg	Boolean		cursor_blink_xor; /* how to merge menu/escapes	*/
2579d522f475Smrg#endif
2580d522f475Smrg#if OPT_BLINK_TEXT
2581d522f475Smrg	Boolean		blink_as_bold;	/* text blink disable		*/
2582d522f475Smrg#endif
2583d522f475Smrg#if OPT_BLINK_CURS || OPT_BLINK_TEXT
2584d522f475Smrg	int		blink_state;	/* ON, OFF, or BLINKED_OFF	*/
2585d522f475Smrg	int		blink_on;	/* cursor on time (msecs)	*/
2586d522f475Smrg	int		blink_off;	/* cursor off time (msecs)	*/
2587d522f475Smrg	XtIntervalId	blink_timer;	/* timer-id for cursor-proc	*/
2588d522f475Smrg#endif
2589d522f475Smrg#if OPT_ZICONBEEP
2590d522f475Smrg	Boolean		zIconBeep_flagged; /* True if icon name was changed */
2591d522f475Smrg#endif /* OPT_ZICONBEEP */
2592d522f475Smrg	int		cursor_GC;	/* see ShowCursor()		*/
2593d522f475Smrg	int		cursor_set;	/* requested state		*/
2594d522f475Smrg	CELL		cursorp;	/* previous cursor row/column	*/
2595d522f475Smrg	int		cur_col;	/* current cursor column	*/
2596d522f475Smrg	int		cur_row;	/* current cursor row		*/
2597d522f475Smrg	int		max_col;	/* rightmost column		*/
2598d522f475Smrg	int		max_row;	/* bottom row			*/
2599d522f475Smrg	int		top_marg;	/* top line of scrolling region */
2600d522f475Smrg	int		bot_marg;	/* bottom line of  "	    "	*/
26013367019cSmrg	int		lft_marg;	/* left column of "	    "	*/
26023367019cSmrg	int		rgt_marg;	/* right column of "	    "	*/
2603d522f475Smrg	Widget		scrollWidget;	/* pointer to scrollbar struct	*/
2604d4fba8b9Smrg#if USE_DOUBLE_BUFFER
2605d4fba8b9Smrg	int		buffered_sb;	/* nonzero when pending update	*/
2606d4fba8b9Smrg	struct timeval	buffered_at;	/* reference time, for FPS	*/
2607d4fba8b9Smrg#define DbeMsecs(xw)	(1000L / (long) resource.buffered_fps)
2608d4fba8b9Smrg#endif
2609d522f475Smrg	/*
2610d522f475Smrg	 * Indices used to keep track of the top of the vt100 window and
2611d522f475Smrg	 * the saved lines, taking scrolling into account.
2612d522f475Smrg	 */
2613d522f475Smrg	int		topline;	/* line number of top, <= 0	*/
261494644356Smrg	long		saved_fifo;     /* number of lines that've ever been saved */
2615d522f475Smrg	int		savedlines;     /* number of lines that've been saved */
2616d522f475Smrg	int		savelines;	/* number of lines off top to save */
2617d522f475Smrg	int		scroll_amt;	/* amount to scroll		*/
2618d522f475Smrg	int		refresh_amt;	/* amount to refresh		*/
2619d522f475Smrg	/*
2620b7c89284Ssnj	 * Working variables for getLineData().
2621b7c89284Ssnj	 */
2622b7c89284Ssnj	size_t		lineExtra;	/* extra space for combining chars */
2623d4fba8b9Smrg	size_t		cellExtra;	/* extra space for combining chars */
2624b7c89284Ssnj	/*
2625b7c89284Ssnj	 * Pointer to the current visible buffer.
2626d522f475Smrg	 */
2627d522f475Smrg	ScrnBuf		visbuf;		/* ptr to visible screen buf (main) */
2628d522f475Smrg	/*
2629d522f475Smrg	 * Data for the normal buffer, which may have saved lines to which
2630d522f475Smrg	 * the user can scroll.
2631d522f475Smrg	 */
2632b7c89284Ssnj	ScrnBuf		saveBuf_index;
2633b7c89284Ssnj	Char		*saveBuf_data;
2634d522f475Smrg	/*
2635b7c89284Ssnj	 * Data for visible and alternate buffer.
2636d522f475Smrg	 */
2637b7c89284Ssnj	ScrnBuf		editBuf_index[2];
2638b7c89284Ssnj	Char		*editBuf_data[2];
2639b7c89284Ssnj	int		whichBuf;	/* 0/1 for normal/alternate buf */
2640b7c89284Ssnj	Boolean		is_running;	/* true when buffers are legal	*/
2641d522f475Smrg	/*
2642d522f475Smrg	 * Workspace used for screen operations.
2643d522f475Smrg	 */
2644d522f475Smrg	Char		**save_ptr;	/* workspace for save-pointers  */
2645d522f475Smrg	size_t		save_len;	/* ...and its length		*/
2646d522f475Smrg
2647d522f475Smrg	int		scrolllines;	/* number of lines to button scroll */
26483367019cSmrg	Boolean		alternateScroll; /* scroll-actions become keys */
2649d522f475Smrg	Boolean		scrollttyoutput; /* scroll to bottom on tty output */
2650d522f475Smrg	Boolean		scrollkey;	/* scroll to bottom on key	*/
2651d522f475Smrg	Boolean		cursor_moved;	/* scrolling makes cursor move	*/
2652d522f475Smrg
26530d92cbfdSchristos	Boolean		do_wrap;	/* true if cursor in last column
2654d522f475Smrg					    and character just output    */
2655d522f475Smrg
2656d522f475Smrg	int		incopy;		/* 0 idle; 1 XCopyArea issued;
2657d522f475Smrg					    -1 first GraphicsExpose seen,
2658d522f475Smrg					    but last not seen		*/
2659d522f475Smrg	int		copy_src_x;	/* params from last XCopyArea ... */
2660d522f475Smrg	int		copy_src_y;
2661d522f475Smrg	unsigned int	copy_width;
2662d522f475Smrg	unsigned int	copy_height;
2663d522f475Smrg	int		copy_dest_x;
2664d522f475Smrg	int		copy_dest_y;
2665d522f475Smrg
26663367019cSmrg	Dimension	embed_wide;
26673367019cSmrg	Dimension	embed_high;
26683367019cSmrg
2669d522f475Smrg	Boolean		c132;		/* allow change to 132 columns	*/
2670d522f475Smrg	Boolean		curses;		/* kludge line wrap for more	*/
2671d522f475Smrg	Boolean		hp_ll_bc;	/* kludge HP-style ll for xdb	*/
2672d522f475Smrg	Boolean		marginbell;	/* true if margin bell on	*/
2673d522f475Smrg	int		nmarginbell;	/* columns from right margin	*/
2674cd3331d0Smrg	int		bellArmed;	/* cursor below bell margin	*/
2675cd3331d0Smrg	BellVolume	marginVolume;	/* margin-bell volume           */
2676cd3331d0Smrg	BellVolume	warningVolume;	/* warning-bell volume          */
2677d522f475Smrg	Boolean		multiscroll;	/* true if multi-scroll		*/
2678d522f475Smrg	int		scrolls;	/* outstanding scroll count,
2679d522f475Smrg					    used only with multiscroll	*/
2680d522f475Smrg	SavedCursor	sc[SAVED_CURSORS]; /* data for restore cursor	*/
26819a64e1c5Smrg	IFlags		save_modes[DP_LAST]; /* save dec/xterm private modes */
2682d522f475Smrg
2683cd3331d0Smrg	int		title_modes;	/* control set/get of titles	*/
26849a64e1c5Smrg	int		title_modes0;	/* ...initial value         	*/
2685cd3331d0Smrg	SaveTitle	*save_title;
2686cd3331d0Smrg
2687d522f475Smrg	/* Improved VT100 emulation stuff.				*/
2688d522f475Smrg	String		keyboard_dialect; /* default keyboard dialect	*/
2689d4fba8b9Smrg	DECNRCM_codes	gsets[NUM_GSETS]; /* G0 through G3.		*/
2690d522f475Smrg	Char		curgl;		/* Current GL setting.		*/
2691d522f475Smrg	Char		curgr;		/* Current GR setting.		*/
2692d522f475Smrg	Char		curss;		/* Current single shift.	*/
2693d522f475Smrg	String		term_id;	/* resource for terminal_id	*/
2694d522f475Smrg	int		terminal_id;	/* 100=vt100, 220=vt220, etc.	*/
2695d522f475Smrg	int		vtXX_level;	/* 0=vt52, 1,2,3 = vt100 ... vt320 */
26963367019cSmrg	int		ansi_level;	/* dpANSI levels 1,2,3		*/
2697d522f475Smrg	int		protected_mode;	/* 0=off, 1=DEC, 2=ISO		*/
2698d522f475Smrg	Boolean		always_bold_mode; /* compare normal/bold font	*/
2699d522f475Smrg	Boolean		always_highlight; /* whether to highlight cursor */
2700d522f475Smrg	Boolean		bold_mode;	/* use bold font or overstrike	*/
2701d522f475Smrg	Boolean		delete_is_del;	/* true for compatible Delete key */
2702d522f475Smrg	Boolean		jumpscroll;	/* whether we should jumpscroll */
2703b7c89284Ssnj	Boolean		fastscroll;	/* whether we should fastscroll */
2704d522f475Smrg	Boolean		old_fkeys;	/* true for compatible fkeys	*/
27059a64e1c5Smrg	Boolean		old_fkeys0;	/* ...initial value         	*/
2706d522f475Smrg	Boolean		underline;	/* whether to underline text	*/
2707d522f475Smrg
2708d522f475Smrg#if OPT_MAXIMIZE
2709d522f475Smrg	Boolean		restore_data;
2710d522f475Smrg	int		restore_x;
2711d522f475Smrg	int		restore_y;
2712d522f475Smrg	unsigned	restore_width;
2713d522f475Smrg	unsigned	restore_height;
2714d522f475Smrg#endif
2715d522f475Smrg
271694644356Smrg#if OPT_REGIS_GRAPHICS
271794644356Smrg	String		graphics_regis_default_font; /* font for "builtin" */
271894644356Smrg
271994644356Smrg	String		graphics_regis_screensize; /* given a size in pixels */
272094644356Smrg	Dimension	graphics_regis_def_wide; /* ...corresponding width   */
272194644356Smrg	Dimension	graphics_regis_def_high; /* ...and height            */
272294644356Smrg#endif
272394644356Smrg
272494644356Smrg#if OPT_GRAPHICS
2725d4fba8b9Smrg	String		graph_termid;		/* resource for graphics_termid */
2726d4fba8b9Smrg	int		graphics_termid;	/* based on terminal_id   */
272794644356Smrg	String		graphics_max_size;	/* given a size in pixels */
272894644356Smrg	Dimension	graphics_max_wide;	/* ...corresponding width */
272994644356Smrg	Dimension	graphics_max_high;	/* ...and height          */
273094644356Smrg#endif
273194644356Smrg
2732cd3331d0Smrg#if OPT_SCROLL_LOCK
2733cd3331d0Smrg	Boolean		allowScrollLock;/* ScrollLock mode		*/
2734cd3331d0Smrg	Boolean		allowScrollLock0;/* initial ScrollLock mode	*/
2735636d5e9fSmrg	Boolean		autoScrollLock; /* Auto ScrollLock mode		*/
2736cd3331d0Smrg	Boolean		scroll_lock;	/* true to keep buffer in view	*/
2737cd3331d0Smrg	Boolean		scroll_dirty;	/* scrolling makes screen dirty	*/
2738cd3331d0Smrg#endif
2739cd3331d0Smrg
2740fa3f02f3Smrg#if OPT_SIXEL_GRAPHICS
2741fa3f02f3Smrg	Boolean		sixel_scrolling; /* sixel scrolling             */
27429a64e1c5Smrg	Boolean		sixel_scrolls_right; /* sixel scrolling moves cursor to right */
27439a64e1c5Smrg#endif
27449a64e1c5Smrg
27459a64e1c5Smrg#if OPT_GRAPHICS
27469a64e1c5Smrg	int		numcolorregisters; /* number of supported color registers */
2747fa3f02f3Smrg	Boolean		privatecolorregisters; /* private color registers for each graphic */
2748fa3f02f3Smrg#endif
2749fa3f02f3Smrg
2750d4fba8b9Smrg	/* Graphics Printing */
2751d4fba8b9Smrg#if OPT_PRINT_GRAPHICS
2752d4fba8b9Smrg	Boolean		graphics_print_to_host;
2753d4fba8b9Smrg	Boolean		graphics_expanded_print_mode;
2754d4fba8b9Smrg	Boolean		graphics_print_color_mode;
2755d4fba8b9Smrg	Boolean		graphics_print_color_syntax;
2756d4fba8b9Smrg	Boolean		graphics_print_background_mode;
2757d4fba8b9Smrg	Boolean		graphics_rotated_print_mode;
2758d4fba8b9Smrg#endif
2759d4fba8b9Smrg
2760d522f475Smrg#if OPT_VT52_MODE
2761d4fba8b9Smrg	IFlags		vt52_save_flags;
27620d92cbfdSchristos	Char		vt52_save_curgl;
27630d92cbfdSchristos	Char		vt52_save_curgr;
27640d92cbfdSchristos	Char		vt52_save_curss;
2765d4fba8b9Smrg	DECNRCM_codes	vt52_save_gsets[NUM_GSETS];
2766d522f475Smrg#endif
2767d522f475Smrg	/* Testing */
2768d522f475Smrg#if OPT_XMC_GLITCH
2769d522f475Smrg	unsigned	xmc_glitch;	/* # of spaces to pad on SGR's	*/
27709a64e1c5Smrg	IAttr		xmc_attributes;	/* attrs that make a glitch	*/
2771d522f475Smrg	Boolean		xmc_inline;	/* SGR's propagate only to eol	*/
2772d522f475Smrg	Boolean		move_sgr_ok;	/* SGR is reset on move		*/
2773d522f475Smrg#endif
2774d522f475Smrg
2775d522f475Smrg	/*
2776d522f475Smrg	 * Bell
2777d522f475Smrg	 */
2778d522f475Smrg	int		visualBellDelay; /* msecs to delay for visibleBell */
2779d522f475Smrg	int		bellSuppressTime; /* msecs after Bell before another allowed */
2780d522f475Smrg	Boolean		bellInProgress; /* still ringing/flashing prev bell? */
2781d522f475Smrg	Boolean		bellIsUrgent;	/* set XUrgency WM hint on bell */
27823367019cSmrg	Boolean		flash_line;	/* show visualBell as current line */
2783d522f475Smrg	/*
2784d522f475Smrg	 * Select/paste state.
2785d522f475Smrg	 */
2786d522f475Smrg	Boolean		selectToClipboard; /* primary vs clipboard */
2787d522f475Smrg	String		*mappedSelect;	/* mapping for "SELECT" to "PRIMARY" */
2788d522f475Smrg
2789d522f475Smrg	Boolean		waitingForTrackInfo;
2790d522f475Smrg	int		numberOfClicks;
2791d522f475Smrg	int		maxClicks;
2792d522f475Smrg	int		multiClickTime;	/* time between multiclick selects */
2793d522f475Smrg	SelectUnit	selectUnit;
2794d522f475Smrg	SelectUnit	selectMap[NSELECTUNITS];
2795d522f475Smrg	String		onClick[NSELECTUNITS + 1];
2796d522f475Smrg
2797d522f475Smrg	char		*charClass;	/* for overriding word selection */
2798d522f475Smrg	Boolean		cutNewline;	/* whether or not line cut has \n */
2799d522f475Smrg	Boolean		cutToBeginningOfLine;  /* line cuts to BOL? */
2800d522f475Smrg	Boolean		highlight_selection; /* controls appearance of selection */
2801cb4a1343Smrg	Boolean		show_wrap_marks; /* show lines which are wrapped */
2802d522f475Smrg	Boolean		trim_selection; /* controls trimming of selection */
2803d522f475Smrg	Boolean		i18nSelections;
2804d522f475Smrg	Boolean		brokenSelections;
2805037a25ddSmrg	Boolean		keepClipboard;	/* retain data sent to clipboard */
2806d522f475Smrg	Boolean		keepSelection;	/* do not lose selection on output */
2807d522f475Smrg	Boolean		replyToEmacs;	/* Send emacs escape code when done selecting or extending? */
2808d4fba8b9Smrg
2809d4fba8b9Smrg	SelectedCells	clipboard_data;	/* what we sent to the clipboard */
2810d4fba8b9Smrg
2811d522f475Smrg	EventMode	eventMode;
2812d522f475Smrg	Time		selection_time;	/* latest event timestamp */
2813d522f475Smrg	Time		lastButtonUpTime;
2814d522f475Smrg	unsigned	lastButton;
2815d522f475Smrg
2816d4fba8b9Smrg#define MAX_CUT_BUFFER  8		/* CUT_BUFFER0 to CUT_BUFFER7 */
2817d4fba8b9Smrg#define MAX_SELECTIONS	(MAX_SELECTION_CODES + MAX_CUT_BUFFER)
2818d4fba8b9Smrg	SelectedCells	selected_cells[MAX_SELECTIONS];
2819d4fba8b9Smrg
2820d522f475Smrg	CELL		rawPos;		/* raw position for selection start */
2821d522f475Smrg	CELL		startRaw;	/* area before selectUnit processing */
2822d522f475Smrg	CELL		endRaw;		/* " " */
2823d522f475Smrg	CELL		startSel;	/* area after selectUnit processing */
2824d522f475Smrg	CELL		endSel;		/* " " */
2825d522f475Smrg	CELL		startH;		/* start highlighted text */
2826d522f475Smrg	CELL		endH;		/* end highlighted text */
2827d522f475Smrg	CELL		saveStartW;	/* saved WORD state, for LINE */
2828d522f475Smrg	CELL		startExt;	/* Start, end of extension */
2829d522f475Smrg	CELL		endExt;		/* " " */
2830d522f475Smrg	CELL		saveStartR;	/* Saved values of raw selection for extend to restore to */
2831d522f475Smrg	CELL		saveEndR;	/* " " */
2832d522f475Smrg	int		startHCoord, endHCoord;
2833d522f475Smrg	int		firstValidRow;	/* Valid rows for selection clipping */
2834d522f475Smrg	int		lastValidRow;	/* " " */
2835d522f475Smrg
28363367019cSmrg	Boolean		selectToBuffer;	/* copy selection to buffer	*/
283794644356Smrg	InternalSelect	internal_select;
28383367019cSmrg
2839b7c89284Ssnj	String		default_string;
2840b7c89284Ssnj	String		eightbit_select_types;
2841b7c89284Ssnj	Atom*		selection_targets_8bit;
2842b7c89284Ssnj#if OPT_WIDE_CHARS
2843b7c89284Ssnj	String		utf8_select_types;
2844b7c89284Ssnj	Atom*		selection_targets_utf8;
2845b7c89284Ssnj#endif
2846d522f475Smrg	Atom*		selection_atoms; /* which selections we own */
28473367019cSmrg	Cardinal	sel_atoms_size;	 /* how many atoms allocated */
2848d522f475Smrg	Cardinal	selection_count; /* how many atoms in use */
2849d522f475Smrg#if OPT_SELECT_REGEX
2850d522f475Smrg	char *		selectExpr[NSELECTUNITS];
2851d522f475Smrg#endif
2852d522f475Smrg	/*
2853d522f475Smrg	 * Input/output state.
2854d522f475Smrg	 */
28553367019cSmrg	Boolean		input_eight_bits;	/* do not send ESC when meta pressed */
28563367019cSmrg	int		eight_bit_meta;		/* use 8th bit when meta pressed */
28573367019cSmrg	char *		eight_bit_meta_s;	/* ...resource eightBitMeta */
28583367019cSmrg	Boolean		output_eight_bits;	/* honor all bits or strip */
28593367019cSmrg	Boolean		control_eight_bits;	/* send CSI as 8-bits */
2860d522f475Smrg	Boolean		backarrow_key;		/* backspace/delete */
2861d522f475Smrg	Boolean		alt_is_not_meta;	/* use both Alt- and Meta-key */
2862d522f475Smrg	Boolean		alt_sends_esc;		/* Alt-key sends ESC prefix */
2863d522f475Smrg	Boolean		meta_sends_esc;		/* Meta-key sends ESC prefix */
2864d522f475Smrg	/*
2865d522f475Smrg	 * Fonts
2866d522f475Smrg	 */
2867d522f475Smrg	Pixmap		menu_item_bitmap;	/* mask for checking items */
2868d522f475Smrg	String		initial_font;
2869dfb07bc7Smrg	char *		menu_font_names[NMENUFONTS][fMAX];
2870d522f475Smrg#define MenuFontName(n) menu_font_names[n][fNorm]
287194644356Smrg#define EscapeFontName() MenuFontName(fontMenu_fontescape)
287294644356Smrg#define SelectFontName() MenuFontName(fontMenu_fontsel)
2873d522f475Smrg	long		menu_font_sizes[NMENUFONTS];
2874d522f475Smrg	int		menu_font_number;
28753367019cSmrg#if OPT_LOAD_VTFONTS || OPT_WIDE_CHARS
2876712a7ff4Smrg	Boolean		savedVTFonts;
2877712a7ff4Smrg	Boolean		mergedVTFonts;
2878712a7ff4Smrg	SubResourceRec	cacheVTFonts;
2879712a7ff4Smrg#endif
2880d522f475Smrg#if OPT_CLIP_BOLD
2881d4fba8b9Smrg	Boolean		use_border_clipping;
2882d522f475Smrg	Boolean		use_clipping;
2883d522f475Smrg#endif
2884d522f475Smrg	void *		main_cgs_cache;
2885d522f475Smrg#ifndef NO_ACTIVE_ICON
2886d522f475Smrg	void *		icon_cgs_cache;
2887d522f475Smrg#endif
2888d522f475Smrg#if OPT_RENDERFONT
2889d4fba8b9Smrg	Boolean		force_xft_height;
2890d4fba8b9Smrg	ListXftFonts	*list_xft_fonts;
2891b7c89284Ssnj	XTermXftFonts	renderFontNorm[NMENUFONTS];
2892b7c89284Ssnj	XTermXftFonts	renderFontBold[NMENUFONTS];
2893b7c89284Ssnj	XTermXftFonts	renderFontItal[NMENUFONTS];
2894d4fba8b9Smrg	XTermXftFonts	renderFontBtal[NMENUFONTS];
2895b7c89284Ssnj#if OPT_RENDERWIDE
2896b7c89284Ssnj	XTermXftFonts	renderWideNorm[NMENUFONTS];
2897b7c89284Ssnj	XTermXftFonts	renderWideBold[NMENUFONTS];
2898b7c89284Ssnj	XTermXftFonts	renderWideItal[NMENUFONTS];
2899d4fba8b9Smrg	XTermXftFonts	renderWideBtal[NMENUFONTS];
2900b7c89284Ssnj	TypedBuffer(XftCharSpec);
2901b7c89284Ssnj#else
2902b7c89284Ssnj	TypedBuffer(XftChar8);
2903b7c89284Ssnj#endif
2904d522f475Smrg	XftDraw *	renderDraw;
2905d522f475Smrg#endif
2906d522f475Smrg#if OPT_DABBREV
2907b7c89284Ssnj	Boolean		dabbrev_working;	/* nonzero during dabbrev process */
2908d522f475Smrg	unsigned char	dabbrev_erase_char;	/* used for deleting inserted completion */
2909d522f475Smrg#endif
2910d522f475Smrg	char		tcapbuf[TERMCAP_SIZE];
2911712a7ff4Smrg	char		tcap_area[TERMCAP_SIZE];
2912d522f475Smrg#if OPT_TCAP_FKEYS
2913d522f475Smrg	char **		tcap_fkeys;
2914d522f475Smrg#endif
2915d4fba8b9Smrg	String		cursor_font_name;	/* alternate cursor font */
2916d522f475Smrg} TScreen;
2917d522f475Smrg
2918d4fba8b9Smrgtypedef XTermFonts *(*MyGetFont) (TScreen *, int);
2919d4fba8b9Smrg
2920d522f475Smrgtypedef struct _TekPart {
2921d522f475Smrg	XFontStruct *	Tfont[TEKNUMFONTS];
2922d522f475Smrg	int		tobaseline[TEKNUMFONTS]; /* top-baseline, each font */
2923d522f475Smrg	char *		initial_font;		/* large, 2, 3, small */
2924d522f475Smrg	char *		gin_terminator_str;	/* ginTerminator resource */
2925d522f475Smrg#if OPT_TOOLBAR
2926d522f475Smrg	TbInfo		tb_info;	/* toolbar information		*/
2927d522f475Smrg#endif
2928d522f475Smrg} TekPart;
2929d522f475Smrg
2930d522f475Smrg/* Tektronix window parameters */
2931d522f475Smrgtypedef struct _TekScreen {
2932d522f475Smrg	GC		TnormalGC;	/* normal painting		*/
2933d522f475Smrg	GC		TcursorGC;	/* normal cursor painting	*/
2934d522f475Smrg
2935d522f475Smrg	Boolean		waitrefresh;	/* postpone refresh		*/
2936d522f475Smrg	TKwin		fullTwin;
2937d522f475Smrg#ifndef NO_ACTIVE_ICON
2938d522f475Smrg	TKwin		iconTwin;
2939d522f475Smrg	TKwin		*whichTwin;
2940d522f475Smrg#endif /* NO_ACTIVE_ICON */
2941d522f475Smrg
2942d522f475Smrg	Cursor		arrow;		/* arrow cursor			*/
2943d522f475Smrg	GC		linepat[TEKNUMLINES]; /* line patterns		*/
2944d522f475Smrg	int		cur_X;		/* current x			*/
2945d522f475Smrg	int		cur_Y;		/* current y			*/
2946d522f475Smrg	Tmodes		cur;		/* current tek modes		*/
2947d522f475Smrg	Tmodes		page;		/* starting tek modes on page	*/
2948d522f475Smrg	int		margin;		/* 0 -> margin 1, 1 -> margin 2	*/
2949d522f475Smrg	int		pen;		/* current Tektronix pen 0=up, 1=dn */
2950d522f475Smrg	char		*TekGIN;	/* nonzero if Tektronix GIN mode*/
2951d522f475Smrg	int		gin_terminator; /* Tek strap option */
2952d522f475Smrg	char		tcapbuf[TERMCAP_SIZE];
2953d522f475Smrg} TekScreen;
2954d522f475Smrg
2955d4fba8b9Smrg#if OPT_PASTE64 || OPT_READLINE
2956d522f475Smrg#define SCREEN_FLAG(screenp,f)		(1&(screenp)->f)
2957d522f475Smrg#define SCREEN_FLAG_set(screenp,f)	((screenp)->f |= 1)
2958cd3331d0Smrg#define SCREEN_FLAG_unset(screenp,f)	((screenp)->f &= (unsigned) ~1L)
2959d522f475Smrg#define SCREEN_FLAG_save(screenp,f)	\
2960d522f475Smrg	((screenp)->f = (((screenp)->f)<<1) | SCREEN_FLAG(screenp,f))
2961d522f475Smrg#define SCREEN_FLAG_restore(screenp,f)	((screenp)->f = (((screenp)->f)>>1))
2962d522f475Smrg#else
2963d522f475Smrg#define SCREEN_FLAG(screenp,f)		(0)
2964d522f475Smrg#endif
2965d522f475Smrg
29663367019cSmrg/*
29673367019cSmrg * After screen-updates, reset the flag that tells us we should do wrapping.
29683367019cSmrg * Likewise, reset (in wide-character mode) the flag that tells us where the
29693367019cSmrg * "previous" character was written.
29703367019cSmrg */
29713367019cSmrg#if OPT_WIDE_CHARS
29723367019cSmrg#define ResetWrap(screen) \
29733367019cSmrg    (screen)->do_wrap = \
29743367019cSmrg    (screen)->char_was_written = False
29753367019cSmrg#else
29763367019cSmrg#define ResetWrap(screen) \
29773367019cSmrg    (screen)->do_wrap = False
29783367019cSmrg#endif
29793367019cSmrg
2980d522f475Smrg/* meaning of bits in screen.select flag */
2981d522f475Smrg#define	INWINDOW	01	/* the mouse is in one of the windows */
2982d522f475Smrg#define	FOCUS		02	/* one of the windows is the focus window */
2983d522f475Smrg
2984d522f475Smrg#define MULTICLICKTIME 250	/* milliseconds */
2985d522f475Smrg
2986c219fbebSmrgtypedef struct {
2987c219fbebSmrg    const char *name;
2988c219fbebSmrg    int code;
2989c219fbebSmrg} FlagList;
2990c219fbebSmrg
2991d522f475Smrgtypedef enum {
2992d522f475Smrg    keyboardIsLegacy,		/* bogus vt220 codes for F1-F4, etc. */
2993d522f475Smrg    keyboardIsDefault,
2994d522f475Smrg    keyboardIsHP,
2995d522f475Smrg    keyboardIsSCO,
2996d522f475Smrg    keyboardIsSun,
2997d522f475Smrg    keyboardIsTermcap,
2998d522f475Smrg    keyboardIsVT220
2999d522f475Smrg} xtermKeyboardType;
3000d522f475Smrg
3001d522f475Smrgtypedef enum {			/* legal values for screen.pointer_mode */
30023367019cSmrg    pNever = 0
30033367019cSmrg    , pNoMouse = 1
30043367019cSmrg    , pAlways = 2
30053367019cSmrg    , pFocused = 3
3006d522f475Smrg} pointerModeTypes;
3007d522f475Smrg
3008d522f475Smrgtypedef enum {			/* legal values for screen.utf8_mode */
3009712a7ff4Smrg    uFalse = 0
3010712a7ff4Smrg    , uTrue = 1
3011712a7ff4Smrg    , uAlways = 2
3012712a7ff4Smrg    , uDefault = 3
3013712a7ff4Smrg    , uLast
3014d522f475Smrg} utf8ModeTypes;
3015d522f475Smrg
30163367019cSmrgtypedef enum {			/* legal values for screen.eight_bit_meta */
30173367019cSmrg    ebFalse = 0
30183367019cSmrg    , ebTrue = 1
30193367019cSmrg    , ebNever = 2
30203367019cSmrg    , ebLocale = 3
30213367019cSmrg    , ebLast
30223367019cSmrg} ebMetaModeTypes;
30233367019cSmrg
3024037a25ddSmrg#define NAME_OLD_KT " legacy"
3025037a25ddSmrg
3026d522f475Smrg#if OPT_HP_FUNC_KEYS
3027d522f475Smrg#define NAME_HP_KT " hp"
3028d522f475Smrg#else
3029d522f475Smrg#define NAME_HP_KT /*nothing*/
3030d522f475Smrg#endif
3031d522f475Smrg
3032d522f475Smrg#if OPT_SCO_FUNC_KEYS
3033d522f475Smrg#define NAME_SCO_KT " sco"
3034d522f475Smrg#else
3035d522f475Smrg#define NAME_SCO_KT /*nothing*/
3036d522f475Smrg#endif
3037d522f475Smrg
3038d522f475Smrg#if OPT_SUN_FUNC_KEYS
3039d522f475Smrg#define NAME_SUN_KT " sun"
3040d522f475Smrg#else
3041d522f475Smrg#define NAME_SUN_KT /*nothing*/
3042d522f475Smrg#endif
3043d522f475Smrg
3044d522f475Smrg#if OPT_SUNPC_KBD
3045d522f475Smrg#define NAME_VT220_KT " vt220"
3046d522f475Smrg#else
3047d522f475Smrg#define NAME_VT220_KT /*nothing*/
3048d522f475Smrg#endif
3049d522f475Smrg
3050d522f475Smrg#if OPT_TCAP_FKEYS
3051d522f475Smrg#define NAME_TCAP_KT " tcap"
3052d522f475Smrg#else
3053d522f475Smrg#define NAME_TCAP_KT /*nothing*/
3054d522f475Smrg#endif
3055d522f475Smrg
3056d522f475Smrg#define KEYBOARD_TYPES NAME_TCAP_KT NAME_HP_KT NAME_SCO_KT NAME_SUN_KT NAME_VT220_KT
3057d522f475Smrg
3058cd3331d0Smrg#if OPT_TRACE
3059cd3331d0Smrg#define TRACE_RC(code,func) code = func
3060cd3331d0Smrg#else
3061cd3331d0Smrg#define TRACE_RC(code,func) func
3062cd3331d0Smrg#endif
3063cd3331d0Smrg
3064d522f475Smrgextern	const char * visibleKeyboardType(xtermKeyboardType);
3065d522f475Smrg
3066d522f475Smrgtypedef struct
3067d522f475Smrg{
30683367019cSmrg    int allow_keys;		/* how to handle legacy/vt220 keyboard */
3069d522f475Smrg    int cursor_keys;		/* how to handle cursor-key modifiers */
3070d522f475Smrg    int function_keys;		/* how to handle function-key modifiers */
3071d522f475Smrg    int keypad_keys;		/* how to handle keypad key-modifiers */
3072d522f475Smrg    int other_keys;		/* how to handle other key-modifiers */
3073d522f475Smrg    int string_keys;		/* how to handle string() modifiers */
3074d522f475Smrg} TModify;
3075d522f475Smrg
3076d522f475Smrgtypedef struct
3077d522f475Smrg{
3078d522f475Smrg    xtermKeyboardType type;
30799a64e1c5Smrg    IFlags flags;
3080d4fba8b9Smrg    char *shell_translations;	/* shell's translations, for input check */
3081d4fba8b9Smrg    char *xterm_translations;	/* xterm's translations, for input check */
3082d522f475Smrg    char *extra_translations;
3083d4fba8b9Smrg    char *print_translations;	/* printable translations for buttons */
3084d4fba8b9Smrg    unsigned shift_buttons;	/* special shift-modifier for mouse-buttons */
3085d4fba8b9Smrg    int shift_escape;		/* working value of shiftEscape */
3086d4fba8b9Smrg    char * shift_escape_s;	/* resource for shiftEscape */
3087d522f475Smrg#if OPT_INITIAL_ERASE
3088d522f475Smrg    int	reset_DECBKM;		/* reset should set DECBKM */
3089d522f475Smrg#endif
3090d522f475Smrg#if OPT_MOD_FKEYS
3091d522f475Smrg    TModify modify_now;		/* current modifier value */
3092d522f475Smrg    TModify modify_1st;		/* original modifier value, for resets */
3093d522f475Smrg    int format_keys;		/* format of modifyOtherKeys */
3094d522f475Smrg#endif
3095d522f475Smrg} TKeyboard;
3096d522f475Smrg
3097b7c89284Ssnj#define GravityIsNorthWest(w) ((w)->misc.resizeGravity == NorthWestGravity)
3098b7c89284Ssnj#define GravityIsSouthWest(w) ((w)->misc.resizeGravity == SouthWestGravity)
3099b7c89284Ssnj
3100d522f475Smrgtypedef struct _Misc {
3101d522f475Smrg    VTFontNames default_font;
3102d522f475Smrg    char *geo_metry;
3103d522f475Smrg    char *T_geometry;
3104d522f475Smrg#if OPT_WIDE_CHARS
3105d522f475Smrg    Boolean cjk_width;		/* true for built-in CJK wcwidth() */
3106d522f475Smrg    Boolean mk_width;		/* true for simpler built-in wcwidth() */
3107d522f475Smrg    int mk_samplesize;
3108d522f475Smrg    int mk_samplepass;
3109d522f475Smrg#endif
3110d522f475Smrg#if OPT_LUIT_PROG
3111d522f475Smrg    Boolean callfilter;		/* true to invoke luit */
3112d522f475Smrg    Boolean use_encoding;	/* true to use -encoding option for luit */
3113d522f475Smrg    char *locale_str;		/* "locale" resource */
3114d522f475Smrg    char *localefilter;		/* path for luit */
3115d522f475Smrg#endif
3116b7c89284Ssnj    fontWarningTypes fontWarnings;
3117d522f475Smrg    int limit_resize;
3118d522f475Smrg#ifdef ALLOWLOGGING
3119d522f475Smrg    Boolean log_on;
3120d522f475Smrg#endif
3121d4fba8b9Smrg    Boolean color_inner_border;
3122d522f475Smrg    Boolean login_shell;
3123d522f475Smrg    Boolean re_verse;
3124d522f475Smrg    Boolean re_verse0;		/* initial value of "-rv" */
31258f44fb3bSmrg    Boolean resizeByPixel;
3126d522f475Smrg    XtGravity resizeGravity;
3127d522f475Smrg    Boolean reverseWrap;
3128d522f475Smrg    Boolean autoWrap;
3129d522f475Smrg    Boolean logInhibit;
3130d522f475Smrg    Boolean signalInhibit;
3131d522f475Smrg#if OPT_TEK4014
3132d522f475Smrg    Boolean tekInhibit;
3133d522f475Smrg    Boolean tekSmall;		/* start tek window in small size */
3134d522f475Smrg    Boolean TekEmu;		/* true if Tektronix emulation	*/
3135d522f475Smrg    Boolean Tshow;		/* Tek window showing		*/
3136d522f475Smrg#endif
3137d522f475Smrg    Boolean scrollbar;
3138d522f475Smrg#ifdef SCROLLBAR_RIGHT
3139d522f475Smrg    Boolean useRight;
3140d522f475Smrg#endif
3141d522f475Smrg    Boolean titeInhibit;
31423367019cSmrg    Boolean tiXtraScroll;	/* scroll on ti/te */
31433367019cSmrg    Boolean cdXtraScroll;	/* scroll on cd (clear-display) */
3144d522f475Smrg    Boolean appcursorDefault;
3145d522f475Smrg    Boolean appkeypadDefault;
3146d522f475Smrg#if OPT_INPUT_METHOD
3147b7c89284Ssnj    char* f_x;			/* font for XIM */
3148d522f475Smrg    char* input_method;
3149d522f475Smrg    char* preedit_type;
3150b7c89284Ssnj    Boolean open_im;		/* true if input-method is opened */
3151b7c89284Ssnj    int retry_im;
3152d522f475Smrg#endif
3153d522f475Smrg    Boolean dynamicColors;
3154d522f475Smrg#ifndef NO_ACTIVE_ICON
31553367019cSmrg    char *active_icon_s;	/* use application icon window  */
3156d522f475Smrg    unsigned icon_border_width;
3157d522f475Smrg    Pixel icon_border_pixel;
3158d522f475Smrg#endif /* NO_ACTIVE_ICON */
3159d522f475Smrg#if OPT_DEC_SOFTFONT
3160d522f475Smrg    Boolean font_loadable;
3161d522f475Smrg#endif
3162d522f475Smrg#if OPT_SHIFT_FONTS
3163d522f475Smrg    Boolean shift_fonts;	/* true if we interpret fontsize-shifting */
3164d522f475Smrg#endif
3165d522f475Smrg#if OPT_SUNPC_KBD
3166d522f475Smrg    int ctrl_fkeys;		/* amount to add to XK_F1 for ctrl modifier */
3167d522f475Smrg#endif
3168d522f475Smrg#if OPT_NUM_LOCK
3169d522f475Smrg    Boolean real_NumLock;	/* true if we treat NumLock key specially */
3170d522f475Smrg    Boolean alwaysUseMods;	/* true if we always want f-key modifiers */
3171d522f475Smrg#endif
3172d522f475Smrg#if OPT_RENDERFONT
3173dfb07bc7Smrg    VTFontNames default_xft;
3174d522f475Smrg    float face_size[NMENUFONTS];
3175cd3331d0Smrg    char *render_font_s;
3176d4fba8b9Smrg    int limit_fontsets;
3177d522f475Smrg#endif
3178d522f475Smrg} Misc;
3179d522f475Smrg
31803367019cSmrgtypedef struct _Work {
31813367019cSmrg    int dummy;
31829a64e1c5Smrg#ifdef SunXK_F36
31839a64e1c5Smrg#define MAX_UDK 37
31849a64e1c5Smrg#else
31859a64e1c5Smrg#define MAX_UDK 35
31869a64e1c5Smrg#endif
31879a64e1c5Smrg    struct {
31889a64e1c5Smrg	char *str;
31899a64e1c5Smrg	int len;
31909a64e1c5Smrg    } user_keys[MAX_UDK];
31918f44fb3bSmrg#define MAX_POINTER (XC_num_glyphs/2)
31928f44fb3bSmrg    Cursor pointer_cursors[MAX_POINTER]; /* saved cursors	*/
31933367019cSmrg#ifndef NO_ACTIVE_ICON
31943367019cSmrg    int active_icon;		/* use application icon window  */
3195d4fba8b9Smrg    char *wm_name;
31963367019cSmrg#endif /* NO_ACTIVE_ICON */
3197dfb07bc7Smrg#if OPT_INPUT_METHOD
3198dfb07bc7Smrg    Boolean cannot_im;		/* true if we cannot use input-method */
3199dfb07bc7Smrg    XFontSet xim_fs;		/* fontset for XIM preedit */
3200dfb07bc7Smrg    int xim_fs_ascent;		/* ascent of fs */
3201dfb07bc7Smrg    TInput inputs[NINPUTWIDGETS];
3202dfb07bc7Smrg#endif
3203d4fba8b9Smrg    Boolean doing_resize;	/* currently in RequestResize */
32043367019cSmrg#if OPT_MAXIMIZE
32053367019cSmrg#define MAX_EWMH_MODE 3
32063367019cSmrg#define MAX_EWMH_DATA (1 + OPT_TEK4014)
32073367019cSmrg    struct {
32083367019cSmrg	int mode;		/* fullscreen, etc.		*/
3209d4fba8b9Smrg	Boolean checked[MAX_EWMH_MODE + 1];
3210d4fba8b9Smrg	Boolean allowed[MAX_EWMH_MODE + 1];
32113367019cSmrg    } ewmh[MAX_EWMH_DATA];
32123367019cSmrg#endif
32133367019cSmrg#if OPT_NUM_LOCK
32143367019cSmrg    unsigned num_lock;		/* modifier for Num_Lock */
32153367019cSmrg    unsigned alt_mods;		/* modifier for Alt_L or Alt_R */
32163367019cSmrg    unsigned meta_mods;		/* modifier for Meta_L or Meta_R */
32173367019cSmrg#endif
3218dfb07bc7Smrg    XtermFontNames fonts;
32193367019cSmrg#if OPT_RENDERFONT
32203367019cSmrg    Boolean render_font;
3221d4fba8b9Smrg    unsigned max_fontsets;
32223367019cSmrg#endif
32239a64e1c5Smrg#if OPT_DABBREV
32249a64e1c5Smrg#define MAX_DABBREV	1024	/* maximum word length as in tcsh */
32259a64e1c5Smrg    char dabbrev_data[MAX_DABBREV];
32269a64e1c5Smrg#endif
32279a64e1c5Smrg    ScrnColors *oldColors;
3228dfb07bc7Smrg    Boolean palette_changed;
3229d4fba8b9Smrg    Boolean broken_box_chars;
32303367019cSmrg} Work;
32313367019cSmrg
3232d522f475Smrgtypedef struct {int foo;} XtermClassPart, TekClassPart;
3233d522f475Smrg
3234d522f475Smrgtypedef struct _XtermClassRec {
3235d522f475Smrg    CoreClassPart  core_class;
3236d522f475Smrg    XtermClassPart xterm_class;
3237d522f475Smrg} XtermClassRec;
3238d522f475Smrg
3239d522f475Smrgextern WidgetClass xtermWidgetClass;
3240d522f475Smrg
3241d522f475Smrg#define IsXtermWidget(w) (XtClass(w) == xtermWidgetClass)
3242d522f475Smrg
3243d522f475Smrg#if OPT_TEK4014
3244d522f475Smrgtypedef struct _TekClassRec {
3245d522f475Smrg    CoreClassPart core_class;
3246d522f475Smrg    TekClassPart tek_class;
3247d522f475Smrg} TekClassRec;
3248d522f475Smrg
3249d522f475Smrgextern WidgetClass tekWidgetClass;
3250d522f475Smrg
3251d522f475Smrg#define IsTekWidget(w) (XtClass(w) == tekWidgetClass)
3252d522f475Smrg
3253d522f475Smrg#endif
3254d522f475Smrg
3255d522f475Smrg/* define masks for keyboard.flags */
3256fa3f02f3Smrg#define MODE_KAM	xBIT(0)	/* mode 2: keyboard action mode */
3257d522f475Smrg#define MODE_DECKPAM	xBIT(1)	/* keypad application mode */
3258fa3f02f3Smrg#define MODE_DECCKM	xBIT(2)	/* private mode 1: cursor keys */
3259fa3f02f3Smrg#define MODE_SRM	xBIT(3)	/* mode 12: send-receive mode */
3260fa3f02f3Smrg#define MODE_DECBKM	xBIT(4)	/* private mode 67: backarrow */
3261fa3f02f3Smrg#define MODE_DECSDM	xBIT(5)	/* private mode 80: sixel scrolling mode */
3262d522f475Smrg
3263d522f475Smrg#define N_MARGINBELL	10
3264d522f475Smrg
3265d522f475Smrg#define TAB_BITS_SHIFT	5	/* FIXME: 2**5 == 32 (should derive) */
3266d522f475Smrg#define TAB_BITS_WIDTH	(1 << TAB_BITS_SHIFT)
3267d522f475Smrg#define TAB_ARRAY_SIZE	(1024 / TAB_BITS_WIDTH)
3268d522f475Smrg#define MAX_TABS	(TAB_BITS_WIDTH * TAB_ARRAY_SIZE)
3269d522f475Smrg
3270d4fba8b9Smrg#define OkTAB(c)	((c) >= 0 && (c) < MAX_TABS)
3271d4fba8b9Smrg
3272d522f475Smrgtypedef unsigned Tabs [TAB_ARRAY_SIZE];
3273d522f475Smrg
3274d4fba8b9Smrg#if OPT_XTERM_SGR
3275d4fba8b9Smrg#define MAX_SAVED_SGR	10
3276d4fba8b9Smrgtypedef	struct {
3277d4fba8b9Smrg    int		used;
3278d4fba8b9Smrg    struct	{
3279d4fba8b9Smrg	IFlags	mask;
3280d4fba8b9Smrg	IFlags	flags;
3281d4fba8b9Smrg#if OPT_ISO_COLORS
3282d4fba8b9Smrg	int	sgr_foreground;
3283d4fba8b9Smrg	int	sgr_background;
3284d4fba8b9Smrg	Boolean	sgr_38_xcolors;
3285d4fba8b9Smrg#endif
3286d4fba8b9Smrg    } stack[MAX_SAVED_SGR];
3287d4fba8b9Smrg} SavedSGR;
3288d4fba8b9Smrg
3289d4fba8b9Smrgtypedef struct {
3290d4fba8b9Smrg    ScrnColors base;
3291d4fba8b9Smrg    ColorRes ansi[1];
3292d4fba8b9Smrg} ColorSlot;
3293d4fba8b9Smrg
3294d4fba8b9Smrgtypedef struct {
3295d4fba8b9Smrg    int		used;		/* currently saved or restored	*/
3296d4fba8b9Smrg    int		last;		/* maximum number of saved palettes */
3297d4fba8b9Smrg    ColorSlot	*palettes[MAX_SAVED_SGR];
3298d4fba8b9Smrg} SavedColors;
3299d4fba8b9Smrg#endif /* OPT_XTERM_SGR */
3300d4fba8b9Smrg
3301d522f475Smrgtypedef struct _XtermWidgetRec {
3302d522f475Smrg    CorePart	core;
3303d522f475Smrg    XSizeHints	hints;
3304fa3f02f3Smrg    XVisualInfo *visInfo;
3305fa3f02f3Smrg    int		numVisuals;
3306d4fba8b9Smrg    unsigned	rgb_shifts[3];
3307d4fba8b9Smrg    unsigned	rgb_widths[3];
3308d4fba8b9Smrg    Bool	has_rgb;
3309d522f475Smrg    Bool	init_menu;
3310d522f475Smrg    TKeyboard	keyboard;	/* terminal keyboard		*/
3311d522f475Smrg    TScreen	screen;		/* terminal screen		*/
33129a64e1c5Smrg    IFlags	flags;		/* mode flags			*/
3313d522f475Smrg    int		cur_foreground; /* current foreground color	*/
3314d522f475Smrg    int		cur_background; /* current background color	*/
3315d522f475Smrg    Pixel	dft_foreground; /* default foreground color	*/
3316d522f475Smrg    Pixel	dft_background; /* default background color	*/
3317712a7ff4Smrg    Pixel	old_foreground; /* original foreground color	*/
3318712a7ff4Smrg    Pixel	old_background; /* original background color	*/
3319d522f475Smrg#if OPT_ISO_COLORS
3320d522f475Smrg    int		sgr_foreground; /* current SGR foreground color */
3321d522f475Smrg    int		sgr_background; /* current SGR background color */
3322d4fba8b9Smrg    Boolean	sgr_38_xcolors;	/* true if ISO 8613 extension	*/
3323d522f475Smrg#endif
33249a64e1c5Smrg    IFlags	initflags;	/* initial mode flags		*/
3325d522f475Smrg    Tabs	tabs;		/* tabstops of the terminal	*/
3326d522f475Smrg    Misc	misc;		/* miscellaneous parameters	*/
33273367019cSmrg    Work	work;		/* workspace (no resources)	*/
3328d4fba8b9Smrg#if OPT_XTERM_SGR
3329d4fba8b9Smrg    SavedSGR	saved_sgr;
3330d4fba8b9Smrg    SavedColors	saved_colors;
3331d4fba8b9Smrg#endif
3332d522f475Smrg} XtermWidgetRec, *XtermWidget;
3333d522f475Smrg
3334d522f475Smrg#if OPT_TEK4014
3335d522f475Smrgtypedef struct _TekWidgetRec {
3336d522f475Smrg    CorePart	core;
3337dfb07bc7Smrg    XtermWidget vt;		/* main widget has border, etc. */
3338d522f475Smrg    TekPart	tek;		/* contains resources */
3339d522f475Smrg    TekScreen	screen;		/* contains working data (no resources) */
3340d522f475Smrg    Bool	init_menu;
3341d522f475Smrg    XSizeHints	hints;
3342d522f475Smrg} TekWidgetRec, *TekWidget;
3343d522f475Smrg#endif /* OPT_TEK4014 */
3344d522f475Smrg
3345d522f475Smrg/*
3346d522f475Smrg * terminal flags
3347d522f475Smrg * There are actually two namespaces mixed together here.
3348d522f475Smrg * One is the set of flags that can go in screen->visbuf attributes
3349d522f475Smrg * and which must fit in a char (see OFF_ATTRS).
3350d522f475Smrg * The other is the global setting stored in
3351d522f475Smrg * term->flags and screen->save_modes.  This need only fit in an unsigned.
3352d522f475Smrg */
3353d522f475Smrg
3354d522f475Smrg#define AttrBIT(n)	xBIT(n)		/* text-attributes */
3355d522f475Smrg#define MiscBIT(n)	xBIT(n + 16)	/* miscellaneous state flags */
3356d522f475Smrg
3357d522f475Smrg/* global flags and character flags (visible character attributes) */
3358d522f475Smrg#define INVERSE		AttrBIT(0)	/* invert the characters to be output */
3359d522f475Smrg#define UNDERLINE	AttrBIT(1)	/* true if underlining */
3360d522f475Smrg#define BOLD		AttrBIT(2)
3361d522f475Smrg#define BLINK		AttrBIT(3)
3362d522f475Smrg/* global flags (also character attributes) */
3363d522f475Smrg#define BG_COLOR	AttrBIT(4)	/* true if background set */
3364d522f475Smrg#define FG_COLOR	AttrBIT(5)	/* true if foreground set */
3365d522f475Smrg
3366d522f475Smrg/* character flags (internal attributes) */
3367d522f475Smrg#define PROTECTED	AttrBIT(6)	/* a character that cannot be erased */
3368d522f475Smrg#define CHARDRAWN	AttrBIT(7)	/* a character has been drawn here on
3369d522f475Smrg					   the screen.  Used to distinguish
3370d522f475Smrg					   blanks from empty parts of the
3371d522f475Smrg					   screen when selecting */
3372d522f475Smrg
33739a64e1c5Smrg#if OPT_WIDE_ATTRS
33749a64e1c5Smrg#define ATR_FAINT	AttrBIT(8)
33759a64e1c5Smrg#define ATR_ITALIC	AttrBIT(9)
33769a64e1c5Smrg#define ATR_STRIKEOUT	AttrBIT(10)
33779a64e1c5Smrg#define ATR_DBL_UNDER	AttrBIT(11)
3378d4fba8b9Smrg#define ATR_DIRECT_FG	AttrBIT(12)
3379d4fba8b9Smrg#define ATR_DIRECT_BG	AttrBIT(13)
3380d4fba8b9Smrg#define SGR_MASK2       (ATR_FAINT | ATR_ITALIC | ATR_STRIKEOUT | ATR_DBL_UNDER | ATR_DIRECT_FG | ATR_DIRECT_BG)
33819a64e1c5Smrg#else
33829a64e1c5Smrg#define SGR_MASK2       0
33839a64e1c5Smrg#endif
3384d522f475Smrg
3385d522f475Smrg/*
3386d522f475Smrg * Other flags
3387d522f475Smrg */
3388d522f475Smrg#define WRAPAROUND	MiscBIT(0)	/* true if auto wraparound mode */
3389d522f475Smrg#define	REVERSEWRAP	MiscBIT(1)	/* true if reverse wraparound mode */
3390d522f475Smrg#define REVERSE_VIDEO	MiscBIT(2)	/* true if screen white on black */
3391d522f475Smrg#define LINEFEED	MiscBIT(3)	/* true if in auto linefeed mode */
3392d522f475Smrg#define ORIGIN		MiscBIT(4)	/* true if in origin mode */
3393d522f475Smrg#define INSERT		MiscBIT(5)	/* true if in insert mode */
3394d522f475Smrg#define SMOOTHSCROLL	MiscBIT(6)	/* true if in smooth scroll mode */
3395d522f475Smrg#define IN132COLUMNS	MiscBIT(7)	/* true if in 132 column mode */
3396d522f475Smrg#define INVISIBLE	MiscBIT(8)	/* true if writing invisible text */
3397d522f475Smrg#define NATIONAL        MiscBIT(9)	/* true if writing national charset */
33983367019cSmrg#define LEFT_RIGHT      MiscBIT(10)	/* true if left/right margin mode */
33993367019cSmrg#define NOCLEAR_COLM    MiscBIT(11)	/* true if no clear on DECCOLM change */
3400d522f475Smrg
3401d4fba8b9Smrg#define DrawBIT(n)	xBIT(n + 8)	/* XTermDraw.draw_flags */
34029a64e1c5Smrg/* The following attributes are used in the argument of drawXtermText()  */
34039a64e1c5Smrg#define NOBACKGROUND	DrawBIT(0)	/* Used for overstrike */
34049a64e1c5Smrg#define NOTRANSLATION	DrawBIT(1)	/* No scan for chars missing in font */
34059a64e1c5Smrg#define DOUBLEWFONT	DrawBIT(2)	/* The actual X-font is double-width */
34069a64e1c5Smrg#define DOUBLEHFONT	DrawBIT(3)	/* The actual X-font is double-height */
34079a64e1c5Smrg#define CHARBYCHAR	DrawBIT(4)	/* Draw chars one-by-one */
34089a64e1c5Smrg
34099a64e1c5Smrg/* The following attribute is used in the argument of xtermSpecialFont etc */
34109a64e1c5Smrg#define NORESOLUTION	DrawBIT(5)	/* find the font without resolution */
34119a64e1c5Smrg
34129a64e1c5Smrg
3413d522f475Smrg/*
3414d522f475Smrg * Groups of attributes
3415d522f475Smrg */
3416d522f475Smrg			/* mask for video-attributes only */
3417d522f475Smrg#define SGR_MASK	(BOLD | BLINK | UNDERLINE | INVERSE)
3418d522f475Smrg
3419d522f475Smrg			/* mask: user-visible attributes */
34209a64e1c5Smrg#define	ATTRIBUTES	(SGR_MASK | SGR_MASK2 | BG_COLOR | FG_COLOR | INVISIBLE | PROTECTED)
3421d522f475Smrg
3422d522f475Smrg/* The toplevel-call to drawXtermText() should have text-attributes guarded: */
3423d522f475Smrg#define DRAWX_MASK	(ATTRIBUTES | CHARDRAWN)
3424d522f475Smrg
3425712a7ff4Smrg/*
3426712a7ff4Smrg * BOLDATTR is not only nonzero when we will use bold font, but uses the bits
3427712a7ff4Smrg * for BOLD/BLINK to match against the video attributes which were originally
3428712a7ff4Smrg * requested.
3429712a7ff4Smrg */
3430712a7ff4Smrg#define USE_BOLD(screen) ((screen)->allowBoldFonts)
3431712a7ff4Smrg
3432d522f475Smrg#if OPT_BLINK_TEXT
3433712a7ff4Smrg#define BOLDATTR(screen) (unsigned) (USE_BOLD(screen) ? (BOLD | ((screen)->blink_as_bold ? BLINK : 0)) : 0)
3434d522f475Smrg#else
3435712a7ff4Smrg#define BOLDATTR(screen) (unsigned) (USE_BOLD(screen) ? (BOLD | BLINK) : 0)
3436d522f475Smrg#endif
3437d522f475Smrg
3438d522f475Smrg/*
3439d522f475Smrg * Per-line flags
3440d522f475Smrg */
3441b7c89284Ssnj#define LINEWRAPPED	AttrBIT(0)
3442b7c89284Ssnj/* used once per line to indicate that it wraps onto the next line so we can
3443b7c89284Ssnj * tell the difference between lines that have wrapped around and lines that
3444b7c89284Ssnj * have ended naturally with a CR at column max_col.
3445b7c89284Ssnj */
3446b7c89284Ssnj#define LINEBLINKED	AttrBIT(1)
3447b7c89284Ssnj/* set when the line contains blinking text.
3448b7c89284Ssnj */
3449d522f475Smrg
3450d4fba8b9Smrg#if OPT_ZICONBEEP || OPT_TOOLBAR || (USE_DOUBLE_BUFFER && OPT_RENDERFONT)
3451d522f475Smrg#define HANDLE_STRUCT_NOTIFY 1
3452d522f475Smrg#else
3453d522f475Smrg#define HANDLE_STRUCT_NOTIFY 0
3454d522f475Smrg#endif
3455d522f475Smrg
3456d522f475Smrg/*
3457d522f475Smrg * If we've set protected attributes with the DEC-style DECSCA, then we'll have
3458d522f475Smrg * to use DECSED or DECSEL to erase preserving protected text.  (The normal ED,
3459d522f475Smrg * EL won't preserve protected-text).  If we've used SPA, then normal ED and EL
3460d522f475Smrg * will preserve protected-text.  To keep things simple, just remember the last
3461d522f475Smrg * control that was used to begin protected-text, and use that to determine how
3462d522f475Smrg * erases are performed (otherwise we'd need 2 bits per protected character).
3463d522f475Smrg */
3464d522f475Smrg#define OFF_PROTECT 0
3465d522f475Smrg#define DEC_PROTECT 1
3466d522f475Smrg#define ISO_PROTECT 2
3467d522f475Smrg
3468d4fba8b9Smrg/***====================================================================***/
3469d4fba8b9Smrg
3470d4fba8b9Smrg/*
3471d4fba8b9Smrg * Reduce parameter-count of drawXtermText by putting less-modified data here.
3472d4fba8b9Smrg */
3473d4fba8b9Smrgtypedef struct {
3474d4fba8b9Smrg	XtermWidget	xw;
3475d4fba8b9Smrg	unsigned	attr_flags;
3476d4fba8b9Smrg	unsigned	draw_flags;
3477d4fba8b9Smrg	unsigned	this_chrset;
3478d4fba8b9Smrg	unsigned	real_chrset;
3479d4fba8b9Smrg	int		on_wide;
3480d4fba8b9Smrg} XTermDraw;
3481d4fba8b9Smrg
3482d4fba8b9Smrg/***====================================================================***/
3483d4fba8b9Smrg
3484d522f475Smrg#define TScreenOf(xw)	(&(xw)->screen)
3485d522f475Smrg#define TekScreenOf(tw) (&(tw)->screen)
3486d522f475Smrg
3487712a7ff4Smrg#define PrinterOf(screen) (screen)->printer_state
3488712a7ff4Smrg
3489d522f475Smrg#ifdef SCROLLBAR_RIGHT
3490d522f475Smrg#define OriginX(screen) (((term->misc.useRight)?0:ScrollbarWidth(screen)) + screen->border)
3491d522f475Smrg#else
3492d522f475Smrg#define OriginX(screen) (ScrollbarWidth(screen) + screen->border)
3493d522f475Smrg#endif
3494d522f475Smrg
3495d522f475Smrg#define OriginY(screen) (screen->border)
3496d522f475Smrg
3497d522f475Smrg#define CursorMoved(screen) \
3498d522f475Smrg		((screen)->cursor_moved || \
3499d522f475Smrg		    ((screen)->cursorp.col != (screen)->cur_col || \
3500d522f475Smrg		     (screen)->cursorp.row != (screen)->cur_row))
3501d522f475Smrg
35023367019cSmrg#define CursorX2(screen,col,fw) ((col) * (int)(fw) + OriginX(screen))
35033367019cSmrg#define CursorX(screen,col)     CursorX2(screen, col, FontWidth(screen))
35043367019cSmrg#define CursorY2(screen,row)    (((row) * FontHeight(screen)) + screen->border)
35053367019cSmrg#define CursorY(screen,row)     CursorY2(screen, INX2ROW(screen, row))
3506d522f475Smrg
3507d522f475Smrg/*
3508d522f475Smrg * These definitions depend on whether xterm supports active-icon.
3509d522f475Smrg */
3510d522f475Smrg#ifndef NO_ACTIVE_ICON
3511d522f475Smrg#define IsIconWin(screen,win)	((win) == &(screen)->iconVwin)
3512d522f475Smrg#define IsIcon(screen)		(WhichVWin(screen) == &(screen)->iconVwin)
3513d522f475Smrg#define WhichVWin(screen)	((screen)->whichVwin)
3514d522f475Smrg#define WhichTWin(screen)	((screen)->whichTwin)
3515d522f475Smrg
3516dfb07bc7Smrg#define WhichVFont(screen,name)	(IsIcon(screen) ? getIconicFont(screen) \
3517d4fba8b9Smrg						: getNormalFont(screen, (int)(name)))->fs
3518dfb07bc7Smrg#define FontAscent(screen)	(IsIcon(screen) ? getIconicFont(screen)->fs->ascent \
3519d522f475Smrg						: WhichVWin(screen)->f_ascent)
3520dfb07bc7Smrg#define FontDescent(screen)	(IsIcon(screen) ? getIconicFont(screen)->fs->descent \
3521d522f475Smrg						: WhichVWin(screen)->f_descent)
3522d522f475Smrg#else /* NO_ACTIVE_ICON */
3523d522f475Smrg
3524d522f475Smrg#define IsIconWin(screen,win)	(False)
3525d522f475Smrg#define IsIcon(screen)		(False)
3526d522f475Smrg#define WhichVWin(screen)	(&((screen)->fullVwin))
3527d522f475Smrg#define WhichTWin(screen)	(&((screen)->fullTwin))
3528d522f475Smrg
3529d4fba8b9Smrg#define WhichVFont(screen,name)	getNormalFont(screen, (int)(name))->fs
3530d522f475Smrg#define FontAscent(screen)	WhichVWin(screen)->f_ascent
3531d522f475Smrg#define FontDescent(screen)	WhichVWin(screen)->f_descent
3532d522f475Smrg
3533d522f475Smrg#endif /* NO_ACTIVE_ICON */
3534d522f475Smrg
3535d522f475Smrg#define okFont(font) ((font) != 0 && (font)->fid != 0)
3536d522f475Smrg
3537d522f475Smrg/*
3538d522f475Smrg * Macro to check if we are iconified; do not use render for that case.
3539d522f475Smrg */
35403367019cSmrg#define UsingRenderFont(xw)	(((xw)->work.render_font == True) && !IsIcon(TScreenOf(xw)))
3541d522f475Smrg
3542d522f475Smrg/*
3543d522f475Smrg * These definitions do not depend on whether xterm supports active-icon.
3544d522f475Smrg */
3545d522f475Smrg#define VWindow(screen)		WhichVWin(screen)->window
3546c219fbebSmrg#define VShellWindow(xw)	XtWindow(SHELL_OF(xw))
3547d522f475Smrg#define TWindow(screen)		WhichTWin(screen)->window
3548d522f475Smrg#define TShellWindow		XtWindow(SHELL_OF(tekWidget))
3549d522f475Smrg
3550d4fba8b9Smrg#if USE_DOUBLE_BUFFER
3551d4fba8b9Smrgextern Window VDrawable(TScreen * /* screen */);
35523367019cSmrg#else
35533367019cSmrg#define VDrawable(screen)	VWindow(screen)
35543367019cSmrg#endif
35553367019cSmrg
3556d522f475Smrg#define Width(screen)		WhichVWin(screen)->width
3557d522f475Smrg#define Height(screen)		WhichVWin(screen)->height
3558d522f475Smrg#define FullWidth(screen)	WhichVWin(screen)->fullwidth
3559d522f475Smrg#define FullHeight(screen)	WhichVWin(screen)->fullheight
3560d522f475Smrg#define FontWidth(screen)	WhichVWin(screen)->f_width
3561d522f475Smrg#define FontHeight(screen)	WhichVWin(screen)->f_height
3562d522f475Smrg
3563dfb07bc7Smrg#define NormalFont(screen)	WhichVFont(screen, fNorm)
3564dfb07bc7Smrg#define BoldFont(screen)	WhichVFont(screen, fBold)
3565d522f475Smrg
3566d522f475Smrg#if OPT_WIDE_CHARS
3567dfb07bc7Smrg#define NormalWFont(screen)	WhichVFont(screen, fWide)
3568dfb07bc7Smrg#define BoldWFont(screen)	WhichVFont(screen, fWBold)
3569d522f475Smrg#endif
3570d522f475Smrg
3571d522f475Smrg#define ScrollbarWidth(screen)	WhichVWin(screen)->sb_info.width
3572d522f475Smrg
3573d4fba8b9Smrg/* y -> y_shift, to center text versus the cursor */
3574d4fba8b9Smrg#define ScaleShift(screen) \
3575d4fba8b9Smrg	    (int) ((IsIcon(screen) || (screen->scale_height <= 1.0f)) \
3576d4fba8b9Smrg	           ? 0.0f \
3577d4fba8b9Smrg	           : ((float) WhichVWin(screen)->f_height \
3578d4fba8b9Smrg		      * ((float) screen->scale_height - 1.0f) / 2.0f))
3579d4fba8b9Smrg
3580d4fba8b9Smrg#define BorderGC(w,sp)		WhichVWin(sp)->border_gc
3581d4fba8b9Smrg#define FillerGC(w,sp)		WhichVWin(sp)->filler_gc
3582d522f475Smrg#define NormalGC(w,sp)		getCgsGC(w, WhichVWin(sp), gcNorm)
3583d522f475Smrg#define ReverseGC(w,sp)		getCgsGC(w, WhichVWin(sp), gcNormReverse)
3584d522f475Smrg#define NormalBoldGC(w,sp)	getCgsGC(w, WhichVWin(sp), gcBold)
3585d522f475Smrg#define ReverseBoldGC(w,sp)	getCgsGC(w, WhichVWin(sp), gcBoldReverse)
3586d522f475Smrg
3587d522f475Smrg#define TWidth(screen)		WhichTWin(screen)->width
3588d522f475Smrg#define THeight(screen)		WhichTWin(screen)->height
3589d522f475Smrg#define TFullWidth(screen)	WhichTWin(screen)->fullwidth
3590d522f475Smrg#define TFullHeight(screen)	WhichTWin(screen)->fullheight
3591d522f475Smrg#define TekScale(screen)	WhichTWin(screen)->tekscale
3592d522f475Smrg
3593dfb07bc7Smrg/* use these before tek4014 is realized, good enough for default "9x15" font */
3594dfb07bc7Smrg#define TDefaultRows		37
3595dfb07bc7Smrg#define TDefaultCols		75
3596dfb07bc7Smrg
3597d522f475Smrg#define BorderWidth(w)		((w)->core.border_width)
3598d522f475Smrg#define BorderPixel(w)		((w)->core.border_pixel)
3599d522f475Smrg
3600cd3331d0Smrg#define AllowXtermOps(w,name)	(TScreenOf(w)->name && !TScreenOf(w)->allowSendEvents)
3601cd3331d0Smrg
3602cd3331d0Smrg#define AllowColorOps(w,name)	(AllowXtermOps(w, allowColorOps) || \
3603cd3331d0Smrg				 !TScreenOf(w)->disallow_color_ops[name])
3604cd3331d0Smrg
3605cd3331d0Smrg#define AllowFontOps(w,name)	(AllowXtermOps(w, allowFontOps) || \
3606cd3331d0Smrg				 !TScreenOf(w)->disallow_font_ops[name])
3607cd3331d0Smrg
3608dfb07bc7Smrg#define AllowMouseOps(w,name)	(AllowXtermOps(w, allowMouseOps) || \
3609dfb07bc7Smrg				 !TScreenOf(w)->disallow_mouse_ops[name])
3610dfb07bc7Smrg
3611cd3331d0Smrg#define AllowTcapOps(w,name)	(AllowXtermOps(w, allowTcapOps) || \
3612cd3331d0Smrg				 !TScreenOf(w)->disallow_tcap_ops[name])
3613cd3331d0Smrg
3614b7c89284Ssnj#define AllowTitleOps(w)	AllowXtermOps(w, allowTitleOps)
3615cd3331d0Smrg
3616d4fba8b9Smrg#define AllowXResOps(w)		True
3617d4fba8b9Smrg
36183367019cSmrg#define SpecialWindowOps(w,name) (!TScreenOf(w)->disallow_win_ops[name])
3619cd3331d0Smrg#define AllowWindowOps(w,name)	(AllowXtermOps(w, allowWindowOps) || \
36203367019cSmrg				 SpecialWindowOps(w,name))
3621b7c89284Ssnj
3622d522f475Smrg#if OPT_TOOLBAR
3623d522f475Smrg#define ToolbarHeight(w)	((resource.toolBar) \
3624c219fbebSmrg				 ? ((w)->VT100_TB_INFO(menu_height) \
3625c219fbebSmrg				  + (w)->VT100_TB_INFO(menu_border) * 2) \
3626d522f475Smrg				 : 0)
3627d522f475Smrg#else
3628d522f475Smrg#define ToolbarHeight(w) 0
3629d522f475Smrg#endif
3630d522f475Smrg
3631d522f475Smrg#if OPT_TEK4014
3632d522f475Smrg#define TEK_LINK_BLOCK_SIZE 1024
3633d522f475Smrg
3634d522f475Smrgtypedef struct Tek_Link
3635d522f475Smrg{
3636d522f475Smrg	struct Tek_Link	*next;	/* pointer to next TekLink in list
3637d522f475Smrg				   NULL <=> this is last TekLink */
3638d522f475Smrg	unsigned short fontsize;/* character size, 0-3 */
3639d522f475Smrg	unsigned short count;	/* number of chars in data */
3640d522f475Smrg	char *ptr;		/* current pointer into data */
3641d522f475Smrg	char data [TEK_LINK_BLOCK_SIZE];
3642d522f475Smrg} TekLink;
3643d522f475Smrg#endif /* OPT_TEK4014 */
3644d522f475Smrg
3645d522f475Smrg/* flags for cursors */
3646d522f475Smrg#define	OFF		0
3647d522f475Smrg#define	ON		1
3648d522f475Smrg#define	BLINKED_OFF	2
3649d522f475Smrg#define	CLEAR		0
3650d522f475Smrg#define	TOGGLE		1
3651d522f475Smrg
3652d522f475Smrg/* flags for inhibit */
3653d522f475Smrg#ifdef ALLOWLOGGING
3654d522f475Smrg#define	I_LOG		0x01
3655d522f475Smrg#endif
3656d522f475Smrg#define	I_SIGNAL	0x02
3657d522f475Smrg#define	I_TEK		0x04
3658d522f475Smrg
3659c219fbebSmrg/* *INDENT-ON* */
3660c219fbebSmrg
3661d522f475Smrg#endif /* included_ptyx_h */
3662