#ifndef included_ptyx_h
#define included_ptyx_h 1
#ifdef HAVE_CONFIG_H
#include <xtermcfg.h>
#endif
#include <X11/IntrinsicP.h>
#include <X11/Shell.h>
#include <X11/StringDefs.h>
#include <X11/Xmu/Misc.h>
#include <X11/Xfuncs.h>
#include <X11/Xosdefs.h>
#include <X11/Xmu/Converters.h>
#ifdef XRENDERFONT
#include <X11/Xft/Xft.h>
#endif
#define MyStackAlloc(size, stack_cache_array) \
((size) <= sizeof(stack_cache_array) \
? (XtPointer)(stack_cache_array) \
: (XtPointer)malloc((unsigned)(size)))
#define MyStackFree(pointer, stack_cache_array) \
if ((pointer) != ((char *)(stack_cache_array))) free(pointer)
#define TypeCallocN(type,n) (type *)calloc((n), sizeof(type))
#define TypeCalloc(type) TypeCalloc(type,1)
#define TypeMallocN(type,n) (type *)malloc(sizeof(type) * (n))
#define TypeMalloc(type) TypeMallocN(type,1)
#define TypeRealloc(type,n,p) (type *)realloc(p, (n) * sizeof(type))
#define CastMallocN(type,n) (type *)malloc(sizeof(type) + (n))
#define CastMalloc(type) CastMallocN(type,0)
#ifdef att
#define ATT
#endif
#ifdef SVR4
#undef SYSV
#define SYSV
#define ATT
#endif
#ifdef SYSV
#ifdef X_NOT_POSIX
#if !defined(CRAY) && !defined(SVR4)
#define dup2(fd1,fd2) ((fd1 == fd2) ? fd1 : \
(close(fd2), fcntl(fd1, F_DUPFD, fd2)))
#endif
#endif
#endif
#if defined(XRENDERFONT) && defined(XFT_VERSION) && XFT_VERSION >= 20100
#define HAVE_TYPE_FCCHAR32 1
#define HAVE_TYPE_XFTCHARSPEC 1
#endif
#define USE_PTY_DEVICE 1
#define USE_PTY_SEARCH 1
#if defined(__osf__) || (defined(linux) && defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
#undef USE_PTY_DEVICE
#undef USE_PTY_SEARCH
#define USE_PTS_DEVICE 1
#elif defined(VMS)
#undef USE_PTY_DEVICE
#undef USE_PTY_SEARCH
#elif defined(PUCC_PTYD)
#undef USE_PTY_SEARCH
#elif (defined(sun) && defined(SVR4)) || defined(_ALL_SOURCE) || defined(__CYGWIN__)
#undef USE_PTY_SEARCH
#endif
#if defined(SYSV) && defined(i386) && !defined(SVR4)
#define ATT
#define USE_HANDSHAKE 1
#define USE_ISPTS_FLAG 1
#endif
#if (defined (__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1)))
#define USE_USG_PTYS
#define USE_HANDSHAKE 0
#elif (defined(ATT) && !defined(__sgi)) || defined(__MVS__) || (defined(SYSV) && defined(i386))
#define USE_USG_PTYS
#else
#define USE_HANDSHAKE 1
#endif
#ifndef USE_HANDSHAKE
#define USE_HANDSHAKE 1
#endif
#ifndef PTYDEV
#if defined(__hpux)
#define PTYDEV "/dev/ptym/ptyxx"
#elif defined(__MVS__)
#define PTYDEV "/dev/ptypxxxx"
#else
#define PTYDEV "/dev/ptyxx"
#endif
#endif
#ifndef TTYDEV
#if defined(__hpux)
#define TTYDEV "/dev/pty/ttyxx"
#elif defined(__MVS__)
#define TTYDEV "/dev/ptypxxxx"
#elif defined(USE_PTS_DEVICE)
#define TTYDEV "/dev/pts/0"
#else
#define TTYDEV "/dev/ttyxx"
#endif
#endif
#ifndef PTYCHAR1
#ifdef __hpux
#define PTYCHAR1 "zyxwvutsrqp"
#else
#ifdef __UNIXOS2__
#define PTYCHAR1 "pq"
#else
#define PTYCHAR1 "pqrstuvwxyzPQRSTUVWXYZ"
#endif
#endif
#endif
#ifndef PTYCHAR2
#ifdef __hpux
#define PTYCHAR2 "fedcba9876543210"
#else
#if defined(__DragonFly__) || defined(__FreeBSD__)
#define PTYCHAR2 "0123456789abcdefghijklmnopqrstuv"
#else
#define PTYCHAR2 "0123456789abcdef"
#endif
#endif
#endif
#ifndef TTYFORMAT
#if defined(CRAY)
#define TTYFORMAT "/dev/ttyp%03d"
#elif defined(__MVS__)
#define TTYFORMAT "/dev/ttyp%04d"
#else
#define TTYFORMAT "/dev/ttyp%d"
#endif
#endif
#ifndef PTYFORMAT
#ifdef CRAY
#define PTYFORMAT "/dev/pty/%03d"
#elif defined(__MVS__)
#define PTYFORMAT "/dev/ptyp%04d"
#else
#define PTYFORMAT "/dev/ptyp%d"
#endif
#endif
#ifndef PTYCHARLEN
#ifdef CRAY
#define PTYCHARLEN 3
#elif defined(__MVS__)
#define PTYCHARLEN 8
#else
#define PTYCHARLEN 2
#endif
#endif
#ifndef MAXPTTYS
#ifdef CRAY
#define MAXPTTYS 256
#else
#define MAXPTTYS 2048
#endif
#endif
typedef enum {
NORMAL = 0
, LEFTEXTENSION
, RIGHTEXTENSION
} EventMode;
#define MaxCols(screen) ((screen)->max_col + 1)
#define MaxRows(screen) ((screen)->max_row + 1)
typedef unsigned char Char;
typedef Char *ScrnPtr;
typedef ScrnPtr *ScrnBuf;
#define CharOf(n) ((unsigned char)(n))
typedef struct {
int row;
int col;
} CELL;
#define isSameRow(a,b) ((a)->row == (b)->row)
#define isSameCol(a,b) ((a)->col == (b)->col)
#define isSameCELL(a,b) (isSameRow(a,b) && isSameCol(a,b))
#define xBIT(n) (1 << (n))
#define ANSI_BEL 0x07
#define ANSI_FF 0x0C
#define ANSI_NAK 0x15
#define ANSI_CAN 0x18
#define ANSI_ESC 0x1B
#define ANSI_SPA 0x20
#define XTERM_POUND 0x1E
#define ANSI_DEL 0x7F
#define ANSI_SS2 0x8E
#define ANSI_SS3 0x8F
#define ANSI_DCS 0x90
#define ANSI_SOS 0x98
#define ANSI_CSI 0x9B
#define ANSI_ST 0x9C
#define ANSI_OSC 0x9D
#define ANSI_PM 0x9E
#define ANSI_APC 0x9F
#define MIN_DECID 52
#define MAX_DECID 420
#ifndef DFT_DECID
#define DFT_DECID "vt100"
#endif
#ifndef DFT_KBD_DIALECT
#define DFT_KBD_DIALECT "B"
#endif
#define UCS_REPL 0xfffd
#define UCS_LIMIT 0x80000000U
#define TERMCAP_SIZE 1500
#define NMENUFONTS 9
#define NBOX 5
#define NPARAM 30
typedef struct {
char *opt;
char *desc;
} OptionHelp;
typedef short ParmType;
typedef struct {
Char a_type;
Char a_pintro;
Char a_inters;
Char a_final;
ParmType a_nparam;
ParmType a_param[NPARAM];
} ANSI;
#define TEK_FONT_LARGE 0
#define TEK_FONT_2 1
#define TEK_FONT_3 2
#define TEK_FONT_SMALL 3
#define TEKNUMFONTS 4
#define TEKNUMLINES 4
typedef struct {
int x;
int y;
int fontsize;
unsigned linetype;
} Tmodes;
typedef struct {
int Twidth;
int Theight;
} T_fontsize;
typedef struct {
short *bits;
int x;
int y;
int width;
int height;
} BitmapBits;
#define SAVELINES 64
#define SCROLLLINES 1
#define EXCHANGE(a,b,tmp) tmp = a; a = b; b = tmp
#if (XtSpecificationRelease < 6)
#ifndef NO_ACTIVE_ICON
#define NO_ACTIVE_ICON 1
#endif
#endif
#ifndef OPT_AIX_COLORS
#define OPT_AIX_COLORS 1
#endif
#ifndef OPT_BLINK_CURS
#define OPT_BLINK_CURS 1
#endif
#ifndef OPT_BLINK_TEXT
#define OPT_BLINK_TEXT OPT_BLINK_CURS
#endif
#ifndef OPT_BOX_CHARS
#define OPT_BOX_CHARS 1
#endif
#ifndef OPT_BROKEN_OSC
#ifdef linux
#define OPT_BROKEN_OSC 1
#else
#define OPT_BROKEN_OSC 0
#endif
#endif
#ifndef OPT_BROKEN_ST
#define OPT_BROKEN_ST 1
#endif
#ifndef OPT_C1_PRINT
#define OPT_C1_PRINT 1
#endif
#ifndef OPT_CLIP_BOLD
#define OPT_CLIP_BOLD 1
#endif
#ifndef OPT_COLOR_CLASS
#define OPT_COLOR_CLASS 1
#endif
#ifndef OPT_COLOR_RES
#define OPT_COLOR_RES 1
#undef OPT_COLOR_RES2
#endif
#ifndef OPT_COLOR_RES2
#define OPT_COLOR_RES2 OPT_COLOR_RES
#endif
#ifndef OPT_DABBREV
#define OPT_DABBREV 0
#endif
#ifndef OPT_DEC_CHRSET
#define OPT_DEC_CHRSET 1
#endif
#ifndef OPT_DEC_LOCATOR
#define OPT_DEC_LOCATOR 0
#endif
#ifndef OPT_DEC_RECTOPS
#define OPT_DEC_RECTOPS 0
#endif
#ifndef OPT_DEC_SOFTFONT
#define OPT_DEC_SOFTFONT 0
#endif
#ifndef OPT_EBCDIC
#ifdef __MVS__
#define OPT_EBCDIC 1
#else
#define OPT_EBCDIC 0
#endif
#endif
#ifndef OPT_EXEC_XTERM
#define OPT_EXEC_XTERM 0
#endif
#ifndef OPT_EXTRA_PASTE
#define OPT_EXTRA_PASTE 1
#endif
#ifndef OPT_FOCUS_EVENT
#define OPT_FOCUS_EVENT 1
#endif
#ifndef OPT_HP_FUNC_KEYS
#define OPT_HP_FUNC_KEYS 0
#endif
#ifndef OPT_I18N_SUPPORT
#if (XtSpecificationRelease >= 5)
#define OPT_I18N_SUPPORT 1
#else
#define OPT_I18N_SUPPORT 0
#endif
#endif
#ifndef OPT_INITIAL_ERASE
#define OPT_INITIAL_ERASE 1
#endif
#ifndef OPT_INPUT_METHOD
#if (XtSpecificationRelease >= 6)
#define OPT_INPUT_METHOD 1
#else
#define OPT_INPUT_METHOD 0
#endif
#endif
#ifndef OPT_ISO_COLORS
#define OPT_ISO_COLORS 1
#endif
#ifndef OPT_256_COLORS
#define OPT_256_COLORS 0
#endif
#ifndef OPT_88_COLORS
#define OPT_88_COLORS 0
#endif
#ifndef OPT_HIGHLIGHT_COLOR
#define OPT_HIGHLIGHT_COLOR 1
#endif
#ifndef OPT_LOAD_VTFONTS
#define OPT_LOAD_VTFONTS 0
#endif
#ifndef OPT_LUIT_PROG
#define OPT_LUIT_PROG 0
#endif
#ifndef OPT_MAXIMIZE
#define OPT_MAXIMIZE 1
#endif
#ifndef OPT_MINI_LUIT
#define OPT_MINI_LUIT 0
#endif
#ifndef OPT_MOD_FKEYS
#define OPT_MOD_FKEYS 1
#endif
#ifndef OPT_NUM_LOCK
#define OPT_NUM_LOCK 1
#endif
#ifndef OPT_PASTE64
#define OPT_PASTE64 0
#endif
#ifndef OPT_PC_COLORS
#define OPT_PC_COLORS 1
#endif
#ifndef OPT_PTY_HANDSHAKE
#define OPT_PTY_HANDSHAKE USE_HANDSHAKE
#endif
#ifndef OPT_PRINT_COLORS
#define OPT_PRINT_COLORS 1
#endif
#ifndef OPT_READLINE
#define OPT_READLINE 0
#endif
#ifndef OPT_RENDERFONT
#ifdef XRENDERFONT
#define OPT_RENDERFONT 1
#else
#define OPT_RENDERFONT 0
#endif
#endif
#ifndef OPT_RENDERWIDE
#if OPT_RENDERFONT && OPT_WIDE_CHARS && defined(HAVE_TYPE_XFTCHARSPEC)
#define OPT_RENDERWIDE 1
#else
#define OPT_RENDERWIDE 0
#endif
#endif
#ifndef OPT_SAME_NAME
#define OPT_SAME_NAME 1
#endif
#ifndef OPT_SCO_FUNC_KEYS
#define OPT_SCO_FUNC_KEYS 0
#endif
#ifndef OPT_SUN_FUNC_KEYS
#define OPT_SUN_FUNC_KEYS 1
#endif
#ifndef OPT_SELECT_REGEX
#define OPT_SELECT_REGEX 0
#endif
#ifndef OPT_SESSION_MGT
#if defined(XtNdieCallback) && defined(XtNsaveCallback)
#define OPT_SESSION_MGT 1
#else
#define OPT_SESSION_MGT 0
#endif
#endif
#ifndef OPT_SHIFT_FONTS
#define OPT_SHIFT_FONTS 1
#endif
#ifndef OPT_SUNPC_KBD
#define OPT_SUNPC_KBD 1
#endif
#ifndef OPT_TCAP_FKEYS
#define OPT_TCAP_FKEYS 0
#endif
#ifndef OPT_TCAP_QUERY
#define OPT_TCAP_QUERY 0
#endif
#ifndef OPT_TEK4014
#define OPT_TEK4014 1
#endif
#ifndef OPT_TOOLBAR
#define OPT_TOOLBAR 0
#endif
#ifndef OPT_TRACE
#define OPT_TRACE 0
#endif
#ifndef OPT_TRACE_FLAGS
#define OPT_TRACE_FLAGS 0
#endif
#ifndef OPT_VT52_MODE
#define OPT_VT52_MODE 1
#endif
#ifndef OPT_WIDE_CHARS
#define OPT_WIDE_CHARS 0
#endif
#ifndef OPT_XMC_GLITCH
#define OPT_XMC_GLITCH 0
#endif
#ifndef OPT_ZICONBEEP
#define OPT_ZICONBEEP 1
#endif
#if OPT_AIX_COLORS && !OPT_ISO_COLORS
#undef OPT_AIX_COLORS
#define OPT_AIX_COLORS 0
#endif
#if OPT_COLOR_RES && !OPT_ISO_COLORS
#undef OPT_COLOR_RES
#define OPT_COLOR_RES 0
#endif
#if OPT_COLOR_RES2 && !(OPT_256_COLORS || OPT_88_COLORS)
#undef OPT_COLOR_RES2
#define OPT_COLOR_RES2 0
#endif
#if OPT_PASTE64 && !OPT_READLINE
#undef OPT_READLINE
#define OPT_READLINE 1
#endif
#if OPT_PC_COLORS && !OPT_ISO_COLORS
#undef OPT_PC_COLORS
#define OPT_PC_COLORS 0
#endif
#if OPT_PRINT_COLORS && !OPT_ISO_COLORS
#undef OPT_PRINT_COLORS
#define OPT_PRINT_COLORS 0
#endif
#if OPT_256_COLORS && !OPT_ISO_COLORS
#undef OPT_256_COLORS
#define OPT_256_COLORS 0
#endif
#if OPT_88_COLORS && !OPT_ISO_COLORS
#undef OPT_88_COLORS
#define OPT_88_COLORS 0
#endif
#if OPT_88_COLORS && OPT_256_COLORS
#undef OPT_88_COLORS
#define OPT_88_COLORS 0
#endif
typedef enum {
fNorm = 0
, fBold
#if OPT_WIDE_CHARS
, fWide
, fWBold
#endif
, fMAX
} VTFontEnum;
typedef enum {
gcNorm = 0
, gcBold
, gcNormReverse
, gcBoldReverse
#if OPT_BOX_CHARS
, gcLine
, gcDots
#endif
#if OPT_DEC_CHRSET
, gcCNorm
, gcCBold
#endif
#if OPT_WIDE_CHARS
, gcWide
, gcWBold
, gcWideReverse
, gcWBoldReverse
#endif
, gcVTcursNormal
, gcVTcursFilled
, gcVTcursReverse
, gcVTcursOutline
#if OPT_TEK4014
, gcTKcurs
#endif
, gcMAX
} CgsEnum;
#define for_each_text_gc(n) for (n = gcNorm; n < gcVTcursNormal; ++n)
#define for_each_curs_gc(n) for (n = gcVTcursNormal; n <= gcVTcursOutline; ++n)
#define for_each_gc(n) for (n = gcNorm; n < gcMAX; ++n)
typedef enum {
TEXT_FG = 0
, TEXT_BG
, TEXT_CURSOR
, MOUSE_FG
, MOUSE_BG
#if OPT_TEK4014
, TEK_FG
, TEK_BG
, TEK_CURSOR
#endif
#if OPT_HIGHLIGHT_COLOR
, HIGHLIGHT_BG
, HIGHLIGHT_FG
#endif
, NCOLORS
} TermColors;
typedef enum {
Select_CHAR=0
,Select_WORD
,Select_LINE
,Select_GROUP
,Select_PAGE
,Select_ALL
#if OPT_SELECT_REGEX
,Select_REGEX
#endif
,NSELECTUNITS
} SelectUnit;
#define COLOR_DEFINED(s,w) ((s)->which & (1<<(w)))
#define COLOR_VALUE(s,w) ((s)->colors[w])
#define SET_COLOR_VALUE(s,w,v) (((s)->colors[w] = (v)), ((s)->which |= (1<<(w))))
#define COLOR_NAME(s,w) ((s)->names[w])
#define SET_COLOR_NAME(s,w,v) (((s)->names[w] = (v)), ((s)->which |= (1<<(w))))
#define UNDEFINE_COLOR(s,w) ((s)->which &= (~((w)<<1)))
#if OPT_ISO_COLORS
#define if_OPT_ISO_COLORS(screen, code) if(screen->colorMode) code
#define TERM_COLOR_FLAGS(xw) ((xw)->flags & (FG_COLOR|BG_COLOR))
#define COLOR_0 0
#define COLOR_1 1
#define COLOR_2 2
#define COLOR_3 3
#define COLOR_4 4
#define COLOR_5 5
#define COLOR_6 6
#define COLOR_7 7
#define COLOR_8 8
#define COLOR_9 9
#define COLOR_10 10
#define COLOR_11 11
#define COLOR_12 12
#define COLOR_13 13
#define COLOR_14 14
#define COLOR_15 15
#define MIN_ANSI_COLORS 16
#if OPT_256_COLORS
# define NUM_ANSI_COLORS 256
#elif OPT_88_COLORS
# define NUM_ANSI_COLORS 88
#else
# define NUM_ANSI_COLORS MIN_ANSI_COLORS
#endif
#if NUM_ANSI_COLORS > MIN_ANSI_COLORS
# define OPT_EXT_COLORS 1
#else
# define OPT_EXT_COLORS 0
#endif
#define COLOR_BD (NUM_ANSI_COLORS)
#define COLOR_UL (NUM_ANSI_COLORS+1)
#define COLOR_BL (NUM_ANSI_COLORS+2)
#define COLOR_RV (NUM_ANSI_COLORS+3)
#define MAXCOLORS (NUM_ANSI_COLORS+4)
#ifndef DFT_COLORMODE
#define DFT_COLORMODE True
#endif
#define ReverseOrHilite(screen,flags,hilite) \
(( screen->colorRVMode && hilite ) || \
( !screen->colorRVMode && \
(( (flags & INVERSE) && !hilite) || \
(!(flags & INVERSE) && hilite)) ))
#if OPT_TCAP_QUERY && OPT_ISO_COLORS
# define XK_COLORS 0x0003
#endif
#else
#define if_OPT_ISO_COLORS(screen, code)
#define TERM_COLOR_FLAGS(xw) 0
#define ReverseOrHilite(screen,flags,hilite) \
(( (flags & INVERSE) && !hilite) || \
(!(flags & INVERSE) && hilite))
#endif
#if OPT_AIX_COLORS
#define if_OPT_AIX_COLORS(screen, code) if(screen->colorMode) code
#else
#define if_OPT_AIX_COLORS(screen, code)
#endif
#if OPT_256_COLORS || OPT_88_COLORS
# define if_OPT_EXT_COLORS(screen, code) if(screen->colorMode) code
# define if_OPT_ISO_TRADITIONAL_COLORS(screen, code)
#elif OPT_ISO_COLORS
# define if_OPT_EXT_COLORS(screen, code)
# define if_OPT_ISO_TRADITIONAL_COLORS(screen, code) if(screen->colorMode) code
#else
# define if_OPT_EXT_COLORS(screen, code)
# define if_OPT_ISO_TRADITIONAL_COLORS(screen, code)
#endif
#define COLOR_RES_NAME(root) "color" root
#if OPT_COLOR_CLASS
#define COLOR_RES_CLASS(root) "Color" root
#else
#define COLOR_RES_CLASS(root) XtCForeground
#endif
#if OPT_COLOR_RES
#define COLOR_RES(root,offset,value) Sres(COLOR_RES_NAME(root), COLOR_RES_CLASS(root), offset.resource, value)
#define COLOR_RES2(name,class,offset,value) Sres(name, class, offset.resource, value)
#else
#define COLOR_RES(root,offset,value) Cres(COLOR_RES_NAME(root), COLOR_RES_CLASS(root), offset, value)
#define COLOR_RES2(name,class,offset,value) Cres(name, class, offset, value)
#endif
#define CLICK_RES_NAME(count) "on" count "Clicks"
#define CLICK_RES_CLASS(count) "On" count "Clicks"
#define CLICK_RES(count,offset,value) Sres(CLICK_RES_NAME(count), CLICK_RES_CLASS(count), offset, value)
#if OPT_DEC_CHRSET
#define if_OPT_DEC_CHRSET(code) code
#define CSET_SWL 0
#define CSET_DHL_TOP 1
#define CSET_DHL_BOT 2
#define CSET_DWL 3
#define NUM_CHRSET 8
#define CSET_NORMAL(code) ((code) == CSET_SWL)
#define CSET_DOUBLE(code) (!CSET_NORMAL(code) && !CSET_EXTEND(code))
#define CSET_EXTEND(code) ((code) > CSET_DWL)
#define SCRN_ROW_CSET(screen,row) (SCRN_BUF_CSETS((screen), row)[0])
#define CurMaxCol(screen, row) \
(CSET_DOUBLE(SCRN_ROW_CSET(screen, row)) \
? (screen->max_col / 2) \
: (screen->max_col))
#define CurCursorX(screen, row, col) \
(CSET_DOUBLE(SCRN_ROW_CSET(screen, row)) \
? CursorX(screen, 2*(col)) \
: CursorX(screen, (col)))
#define CurFontWidth(screen, row) \
(CSET_DOUBLE(SCRN_ROW_CSET(screen, row)) \
? 2*FontWidth(screen) \
: FontWidth(screen))
#else
#define if_OPT_DEC_CHRSET(code)
#define CurMaxCol(screen, row) screen->max_col
#define CurCursorX(screen, row, col) CursorX(screen, col)
#define CurFontWidth(screen, row) FontWidth(screen)
#endif
#if OPT_LUIT_PROG && !OPT_WIDE_CHARS
#error Luit requires the wide-chars configuration
#endif
#if OPT_WIDE_CHARS
#define MAX_PTRS term->num_ptrs
#else
#define MAX_PTRS (OFF_FINAL)
#endif
#define BUF_HEAD 1
#define BUF_PTRS (MAX_PTRS - BUF_HEAD)
#if OPT_EBCDIC
extern int E2A(int);
extern int A2E(int);
#else
#define E2A(a) (a)
#define A2E(a) (a)
#endif
#define CONTROL(a) (A2E(E2A(a)&037))
#if OPT_TEK4014
#define TEK4014_ACTIVE(xw) ((xw)->misc.TekEmu)
#define TEK4014_SHOWN(xw) ((xw)->misc.Tshow)
#define CURRENT_EMU_VAL(tek,vt) (TEK4014_ACTIVE(term) ? tek : vt)
#define CURRENT_EMU() CURRENT_EMU_VAL((Widget)tekWidget, (Widget)term)
#else
#define TEK4014_ACTIVE(screen) 0
#define TEK4014_SHOWN(xw) 0
#define CURRENT_EMU_VAL(tek,vt) (vt)
#define CURRENT_EMU() ((Widget)term)
#endif
#if OPT_TOOLBAR
#define SHELL_OF(widget) XtParent(XtParent(widget))
#else
#define SHELL_OF(widget) XtParent(widget)
#endif
#if OPT_VT52_MODE
#define if_OPT_VT52_MODE(screen, code) if(screen->vtXX_level == 0) code
#else
#define if_OPT_VT52_MODE(screen, code)
#endif
#if OPT_XMC_GLITCH
#define if_OPT_XMC_GLITCH(screen, code) if(screen->xmc_glitch) code
#define XMC_GLITCH 1
#define XMC_FLAGS (INVERSE|UNDERLINE|BOLD|BLINK)
#else
#define if_OPT_XMC_GLITCH(screen, code)
#endif
#define LO_BYTE(ch) CharOf((ch) & 0xff)
#define HI_BYTE(ch) CharOf((ch) >> 8)
#define PACK_FGBG(screen, row, col) \
(unsigned) ((SCRN_BUF_FGRND(screen, row)[col] << 8) \
| (SCRN_BUF_BGRND(screen, row)[col]))
#if OPT_WIDE_CHARS
#define if_OPT_WIDE_CHARS(screen, code) if(screen->wide_chars) code
#define if_WIDE_OR_NARROW(screen, wide, narrow) if(screen->wide_chars) wide else narrow
#define PAIRED_CHARS(lo,hi) lo,hi
#define PACK_PAIR(lo,hi,n) (lo[n] | (hi ? (hi[n] << 8) : 0))
typedef unsigned IChar;
#else
#define if_OPT_WIDE_CHARS(screen, code)
#define if_WIDE_OR_NARROW(screen, wide, narrow) narrow
#define PAIRED_CHARS(lo,hi) lo
#define PACK_PAIR(lo,hi,n) lo[n]
typedef unsigned char IChar;
#endif
#ifndef RES_OFFSET
#define RES_OFFSET(offset) XtOffsetOf(XtermWidgetRec, offset)
#endif
#define RES_NAME(name) name
#define RES_CLASS(name) name
#define Bres(name, class, offset, dftvalue) \
{RES_NAME(name), RES_CLASS(class), XtRBoolean, sizeof(Boolean), \
RES_OFFSET(offset), XtRImmediate, (XtPointer) dftvalue}
#define Cres(name, class, offset, dftvalue) \
{RES_NAME(name), RES_CLASS(class), XtRPixel, sizeof(Pixel), \
RES_OFFSET(offset), XtRString, (XtPointer) dftvalue}
#define Tres(name, class, offset, dftvalue) \
COLOR_RES2(name, class, screen.Tcolors[offset], dftvalue) \
#define Fres(name, class, offset, dftvalue) \
{RES_NAME(name), RES_CLASS(class), XtRFontStruct, sizeof(XFontStruct *), \
RES_OFFSET(offset), XtRString, (XtPointer) dftvalue}
#define Ires(name, class, offset, dftvalue) \
{RES_NAME(name), RES_CLASS(class), XtRInt, sizeof(int), \
RES_OFFSET(offset), XtRImmediate, (XtPointer) dftvalue}
#define Dres(name, class, offset, dftvalue) \
{RES_NAME(name), RES_CLASS(class), XtRFloat, sizeof(float), \
RES_OFFSET(offset), XtRString, (XtPointer) dftvalue}
#define Sres(name, class, offset, dftvalue) \
{RES_NAME(name), RES_CLASS(class), XtRString, sizeof(char *), \
RES_OFFSET(offset), XtRString, (XtPointer) dftvalue}
#define Wres(name, class, offset, dftvalue) \
{RES_NAME(name), RES_CLASS(class), XtRWidget, sizeof(Widget), \
RES_OFFSET(offset), XtRWidget, (XtPointer) dftvalue}
#define FRG_SIZE resource.minBufSize
#define BUF_SIZE resource.maxBufSize
typedef struct {
Char * next;
Char * last;
int update;
#if OPT_WIDE_CHARS
IChar utf_data;
int utf_size;
Char *write_buf;
unsigned write_len;
#endif
Char buffer[1];
} PtyData;
typedef enum {
OFF_FLAGS = 0
, OFF_ATTRS
#if OPT_ISO_COLORS
#if OPT_256_COLORS || OPT_88_COLORS
, OFF_FGRND
, OFF_BGRND
#else
, OFF_COLOR
#endif
#endif
#if OPT_DEC_CHRSET
, OFF_CSETS
#endif
, OFF_CHARS
#if OPT_WIDE_CHARS
, OFF_WIDEC
#endif
, OFF_FINAL
} BufOffsets;
#define ROW2INX(screen, row) ((row) + (screen)->topline)
#define INX2ROW(screen, inx) ((inx) - (screen)->topline)
#define ROW2ABS(screen, row) ((row) + (screen)->savedlines)
#define INX2ABS(screen, inx) ROW2ABS(screen, INX2ROW(screen, inx))
#define okScrnRow(screen, row) \
((row) <= (screen)->max_row \
&& (row) >= -((screen)->savedlines))
#define BUFFER_PTR(buf, row, off) (buf[MAX_PTRS * (row) + off])
#define BUF_FLAGS(buf, row) BUFFER_PTR(buf, row, OFF_FLAGS)
#define BUF_CHARS(buf, row) BUFFER_PTR(buf, row, OFF_CHARS)
#define BUF_ATTRS(buf, row) BUFFER_PTR(buf, row, OFF_ATTRS)
#define BUF_COLOR(buf, row) BUFFER_PTR(buf, row, OFF_COLOR)
#define BUF_FGRND(buf, row) BUFFER_PTR(buf, row, OFF_FGRND)
#define BUF_BGRND(buf, row) BUFFER_PTR(buf, row, OFF_BGRND)
#define BUF_CSETS(buf, row) BUFFER_PTR(buf, row, OFF_CSETS)
#define BUF_WIDEC(buf, row) BUFFER_PTR(buf, row, OFF_WIDEC)
#define SCREEN_PTR(screen, row, off) BUFFER_PTR(screen->visbuf, row, off)
#define SCRN_BUF_FLAGS(screen, row) SCREEN_PTR(screen, row, OFF_FLAGS)
#define SCRN_BUF_CHARS(screen, row) SCREEN_PTR(screen, row, OFF_CHARS)
#define SCRN_BUF_ATTRS(screen, row) SCREEN_PTR(screen, row, OFF_ATTRS)
#define SCRN_BUF_COLOR(screen, row) SCREEN_PTR(screen, row, OFF_COLOR)
#define SCRN_BUF_FGRND(screen, row) SCREEN_PTR(screen, row, OFF_FGRND)
#define SCRN_BUF_BGRND(screen, row) SCREEN_PTR(screen, row, OFF_BGRND)
#define SCRN_BUF_CSETS(screen, row) SCREEN_PTR(screen, row, OFF_CSETS)
#define SCRN_BUF_WIDEC(screen, row) SCREEN_PTR(screen, row, OFF_WIDEC)
typedef struct {
unsigned chrset;
unsigned flags;
XFontStruct * fs;
char * fn;
} XTermFonts;
typedef struct {
int top;
int left;
int bottom;
int right;
} XTermRect;
typedef enum {
DP_CRS_VISIBLE,
DP_DECANM,
DP_DECARM,
DP_DECAWM,
DP_DECBKM,
DP_DECCKM,
DP_DECCOLM,
DP_DECOM,
DP_DECPEX,
DP_DECPFF,
DP_DECSCLM,
DP_DECSCNM,
DP_DECTCEM,
DP_DECTEK,
DP_PRN_EXTENT,
DP_PRN_FORMFEED,
DP_X_ALTSCRN,
DP_X_DECCOLM,
DP_X_LOGGING,
DP_X_MARGIN,
DP_X_MORE,
DP_X_MOUSE,
DP_X_REVWRAP,
DP_X_X10MSE,
#if OPT_BLINK_CURS
DP_CRS_BLINK,
#endif
#if OPT_FOCUS_EVENT
DP_X_FOCUS,
#endif
#if OPT_TOOLBAR
DP_TOOLBAR,
#endif
DP_LAST
} SaveModes;
#define DoSM(code,value) screen->save_modes[code] = (unsigned) (value)
#define DoRM(code,value) value = (Boolean) screen->save_modes[code]
#define DoRM0(code,value) value = screen->save_modes[code]
typedef enum {
noMenu = -1,
mainMenu,
vtMenu,
fontMenu,
tekMenu
} MenuIndex;
#define NUM_POPUP_MENUS 4
#if OPT_COLOR_RES
typedef struct {
String resource;
Pixel value;
int mode;
} ColorRes;
#else
#define ColorRes Pixel
#endif
typedef struct {
unsigned which;
Pixel colors[NCOLORS];
char *names[NCOLORS];
} ScrnColors;
typedef struct {
Boolean saved;
int row;
int col;
unsigned flags;
Char curgl;
Char curgr;
Char gsets[4];
#if OPT_ISO_COLORS
int cur_foreground;
int cur_background;
int sgr_foreground;
int sgr_background;
Boolean sgr_extended;
#endif
} SavedCursor;
#define SAVED_CURSORS 2
typedef struct {
int width;
Boolean rv_cached;
int rv_active;
Pixel bg;
Pixel fg;
Pixel bdr;
Pixmap bdpix;
} SbInfo;
#if OPT_TOOLBAR
typedef struct {
Widget menu_bar;
Dimension menu_height;
Dimension menu_border;
} TbInfo;
#define VT100_TB_INFO(name) screen.fullVwin.tb_info.name
#endif
typedef struct {
Window window;
int width;
int height;
Dimension fullwidth;
Dimension fullheight;
int f_width;
int f_height;
int f_ascent;
int f_descent;
SbInfo sb_info;
#if OPT_TOOLBAR
Boolean active;
TbInfo tb_info;
#endif
} VTwin;
typedef struct {
Window window;
int width;
int height;
Dimension fullwidth;
Dimension fullheight;
double tekscale;
} TKwin;
typedef struct {
Display *display;
int respond;
IChar unparse_bfr[256];
unsigned unparse_len;
#if OPT_TCAP_QUERY
int tc_query_code;
Bool tc_query_fkey;
#endif
pid_t pid;
uid_t uid;
gid_t gid;
ColorRes Tcolors[NCOLORS];
#if OPT_HIGHLIGHT_COLOR
Boolean hilite_color;
Boolean hilite_reverse;
#endif
#if OPT_ISO_COLORS
ColorRes Acolors[MAXCOLORS];
int veryBoldColors;
Boolean boldColors;
Boolean colorMode;
Boolean colorULMode;
Boolean italicULMode;
Boolean colorBDMode;
Boolean colorBLMode;
Boolean colorRVMode;
Boolean colorAttrMode;
#endif
#if OPT_DEC_CHRSET
Boolean font_doublesize;
int cache_doublesize;
Char cur_chrset;
int fonts_used;
XTermFonts double_fonts[NUM_CHRSET];
#endif
#if OPT_DEC_RECTOPS
int cur_decsace;
#endif
#if OPT_WIDE_CHARS
Boolean wide_chars;
Boolean vt100_graphics;
Boolean utf8_inparse;
int utf8_mode;
int max_combining;
Boolean utf8_latin1;
Boolean utf8_title;
int latin9_mode;
int unicode_font;
int utf_count;
IChar utf_char;
int last_written_col;
int last_written_row;
XChar2b *draw_buf;
Cardinal draw_len;
#endif
#if OPT_BROKEN_OSC
Boolean brokenLinuxOSC;
#endif
#if OPT_BROKEN_ST
Boolean brokenStringTerm;
#endif
#if OPT_C1_PRINT || OPT_WIDE_CHARS
Boolean c1_printable;
#endif
int border;
int scrollBarBorder;
long event_mask;
unsigned send_mouse_pos;
Boolean send_focus_pos;
Boolean quiet_grab;
#if OPT_PASTE64
int base64_paste;
int base64_final;
unsigned base64_accu;
unsigned base64_count;
unsigned base64_pad;
#endif
#if OPT_READLINE
unsigned click1_moves;
unsigned paste_moves;
unsigned dclick3_deletes;
unsigned paste_brackets;
unsigned paste_quotes;
unsigned paste_literal_nl;
#endif
#if OPT_DEC_LOCATOR
Boolean locator_reset;
Boolean locator_pixels;
unsigned locator_events;
Boolean loc_filter;
int loc_filter_top;
int loc_filter_left;
int loc_filter_bottom;
int loc_filter_right;
#endif
int mouse_button;
int mouse_row;
int mouse_col;
int select;
Boolean bellOnReset;
Boolean visualbell;
Boolean poponbell;
Boolean allowFontOps;
Boolean allowSendEvents;
Boolean allowTcapOps;
Boolean allowTitleOps;
Boolean allowWindowOps;
Boolean allowFontOp0;
Boolean allowSendEvent0;
Boolean allowTcapOp0;
Boolean allowTitleOp0;
Boolean allowWindowOp0;
Boolean awaitInput;
Boolean grabbedKbd;
#ifdef ALLOWLOGGING
int logging;
int logfd;
char *logfile;
Char *logstart;
#endif
int inhibit;
Boolean Vshow;
VTwin fullVwin;
#ifndef NO_ACTIVE_ICON
VTwin iconVwin;
VTwin *whichVwin;
#endif
int pointer_mode;
Boolean hide_pointer;
Cursor pointer_cursor;
Cursor hidden_cursor;
String answer_back;
String printer_command;
Boolean printer_autoclose;
Boolean printer_extent;
Boolean printer_formfeed;
int printer_controlmode;
int print_attributes;
Boolean fnt_prop;
Boolean fnt_boxes;
#if OPT_BOX_CHARS
Boolean force_box_chars;
Boolean force_all_chars;
#endif
Dimension fnt_wide;
Dimension fnt_high;
XTermFonts fnts[fMAX];
Boolean free_bold_box;
#ifndef NO_ACTIVE_ICON
XTermFonts fnt_icon;
#endif
int enbolden;
XPoint *box;
int cursor_state;
int cursor_busy;
Boolean cursor_underline;
#if OPT_BLINK_CURS
Boolean cursor_blink;
Boolean cursor_blink_res;
Boolean cursor_blink_esc;
#endif
#if OPT_BLINK_TEXT
Boolean blink_as_bold;
#endif
#if OPT_BLINK_CURS || OPT_BLINK_TEXT
int blink_state;
int blink_on;
int blink_off;
XtIntervalId blink_timer;
#endif
#if OPT_ZICONBEEP
Boolean zIconBeep_flagged;
#endif
int cursor_GC;
int cursor_set;
CELL cursorp;
int cur_col;
int cur_row;
int max_col;
int max_row;
int top_marg;
int bot_marg;
Widget scrollWidget;
int topline;
int savedlines;
int savelines;
int scroll_amt;
int refresh_amt;
ScrnBuf visbuf;
ScrnBuf allbuf;
Char *sbuf_address;
Boolean is_running;
ScrnBuf altbuf;
Char *abuf_address;
Boolean alternate;
Char **save_ptr;
size_t save_len;
int scrolllines;
Boolean scrollttyoutput;
Boolean scrollkey;
Boolean cursor_moved;
Boolean do_wrap;
int incopy;
int copy_src_x;
int copy_src_y;
unsigned int copy_width;
unsigned int copy_height;
int copy_dest_x;
int copy_dest_y;
Boolean c132;
Boolean curses;
Boolean hp_ll_bc;
Boolean marginbell;
int nmarginbell;
int bellarmed;
Boolean multiscroll;
int scrolls;
SavedCursor sc[SAVED_CURSORS];
unsigned save_modes[DP_LAST];
String keyboard_dialect;
Char gsets[4];
Char curgl;
Char curgr;
Char curss;
String term_id;
int terminal_id;
int vtXX_level;
int ansi_level;
int protected_mode;
Boolean always_bold_mode;
Boolean always_highlight;
Boolean bold_mode;
Boolean delete_is_del;
Boolean jumpscroll;
Boolean old_fkeys;
Boolean underline;
#if OPT_MAXIMIZE
Boolean restore_data;
int restore_x;
int restore_y;
unsigned restore_width;
unsigned restore_height;
#endif
#if OPT_VT52_MODE
int vt52_save_level;
Char vt52_save_curgl;
Char vt52_save_curgr;
Char vt52_save_curss;
Char vt52_save_gsets[4];
#endif
#if OPT_XMC_GLITCH
unsigned xmc_glitch;
int xmc_attributes;
Boolean xmc_inline;
Boolean move_sgr_ok;
#endif
int visualBellDelay;
int bellSuppressTime;
Boolean bellInProgress;
Boolean bellIsUrgent;
Boolean selectToClipboard;
String *mappedSelect;
Boolean waitingForTrackInfo;
int numberOfClicks;
int maxClicks;
int multiClickTime;
SelectUnit selectUnit;
SelectUnit selectMap[NSELECTUNITS];
String onClick[NSELECTUNITS + 1];
char *charClass;
Boolean cutNewline;
Boolean cutToBeginningOfLine;
Boolean highlight_selection;
Boolean trim_selection;
Boolean i18nSelections;
Boolean brokenSelections;
Boolean keepSelection;
Boolean replyToEmacs;
Char *selection_data;
int selection_size;
unsigned long selection_length;
EventMode eventMode;
Time selection_time;
Time lastButtonUpTime;
unsigned lastButton;
CELL rawPos;
CELL startRaw;
CELL endRaw;
CELL startSel;
CELL endSel;
CELL startH;
CELL endH;
CELL saveStartW;
CELL startExt;
CELL endExt;
CELL saveStartR;
CELL saveEndR;
int startHCoord, endHCoord;
int firstValidRow;
int lastValidRow;
Atom* selection_atoms;
Cardinal sel_atoms_size;
Cardinal selection_count;
#if OPT_SELECT_REGEX
char * selectExpr[NSELECTUNITS];
#endif
Boolean input_eight_bits;
Boolean output_eight_bits;
Boolean control_eight_bits;
Boolean backarrow_key;
Boolean alt_is_not_meta;
Boolean alt_sends_esc;
Boolean meta_sends_esc;
Pixmap menu_item_bitmap;
String initial_font;
String menu_font_names[NMENUFONTS][fMAX];
#define MenuFontName(n) menu_font_names[n][fNorm]
long menu_font_sizes[NMENUFONTS];
int menu_font_number;
#if OPT_CLIP_BOLD
Boolean use_clipping;
#endif
void * main_cgs_cache;
#ifndef NO_ACTIVE_ICON
void * icon_cgs_cache;
#endif
#if OPT_RENDERFONT
XftFont * renderFontNorm[NMENUFONTS];
XftFont * renderFontBold[NMENUFONTS];
XftFont * renderFontItal[NMENUFONTS];
XftFont * renderWideNorm[NMENUFONTS];
XftFont * renderWideBold[NMENUFONTS];
XftFont * renderWideItal[NMENUFONTS];
XftDraw * renderDraw;
#endif
#if OPT_INPUT_METHOD
XIM xim;
XFontSet fs;
int fs_ascent;
#endif
XIC xic;
#if OPT_DABBREV
int dabbrev_working;
unsigned char dabbrev_erase_char;
#endif
char tcapbuf[TERMCAP_SIZE];
#if OPT_TCAP_FKEYS
char ** tcap_fkeys;
char tcap_area[TERMCAP_SIZE];
#endif
} TScreen;
typedef struct _TekPart {
XFontStruct * Tfont[TEKNUMFONTS];
int tobaseline[TEKNUMFONTS];
char * initial_font;
char * gin_terminator_str;
#if OPT_TOOLBAR
TbInfo tb_info;
#endif
} TekPart;
typedef struct _TekScreen {
GC TnormalGC;
GC TcursorGC;
Boolean waitrefresh;
TKwin fullTwin;
#ifndef NO_ACTIVE_ICON
TKwin iconTwin;
TKwin *whichTwin;
#endif
Cursor arrow;
GC linepat[TEKNUMLINES];
int cur_X;
int cur_Y;
Tmodes cur;
Tmodes page;
int margin;
int pen;
char *TekGIN;
int gin_terminator;
char tcapbuf[TERMCAP_SIZE];
} TekScreen;
#if OPT_READLINE
#define SCREEN_FLAG(screenp,f) (1&(screenp)->f)
#define SCREEN_FLAG_set(screenp,f) ((screenp)->f |= 1)
#define SCREEN_FLAG_unset(screenp,f) ((screenp)->f &= ~1L)
#define SCREEN_FLAG_save(screenp,f) \
((screenp)->f = (((screenp)->f)<<1) | SCREEN_FLAG(screenp,f))
#define SCREEN_FLAG_restore(screenp,f) ((screenp)->f = (((screenp)->f)>>1))
#else
#define SCREEN_FLAG(screenp,f) (0)
#endif
#define INWINDOW 01
#define FOCUS 02
#define MULTICLICKTIME 250
typedef enum {
keyboardIsLegacy,
keyboardIsDefault,
keyboardIsHP,
keyboardIsSCO,
keyboardIsSun,
keyboardIsTermcap,
keyboardIsVT220
} xtermKeyboardType;
typedef enum {
pNever = 0,
pNoMouse = 1,
pAlways = 2
} pointerModeTypes;
typedef enum {
uFalse = 0,
uTrue = 1,
uAlways = 2,
uDefault = 3
} utf8ModeTypes;
#if OPT_HP_FUNC_KEYS
#define NAME_HP_KT " hp"
#else
#define NAME_HP_KT
#endif
#if OPT_SCO_FUNC_KEYS
#define NAME_SCO_KT " sco"
#else
#define NAME_SCO_KT
#endif
#if OPT_SUN_FUNC_KEYS
#define NAME_SUN_KT " sun"
#else
#define NAME_SUN_KT
#endif
#if OPT_SUNPC_KBD
#define NAME_VT220_KT " vt220"
#else
#define NAME_VT220_KT
#endif
#if OPT_TCAP_FKEYS
#define NAME_TCAP_KT " tcap"
#else
#define NAME_TCAP_KT
#endif
#define KEYBOARD_TYPES NAME_TCAP_KT NAME_HP_KT NAME_SCO_KT NAME_SUN_KT NAME_VT220_KT
#if OPT_TRACE
extern const char * visibleKeyboardType(xtermKeyboardType);
#endif
typedef struct
{
int cursor_keys;
int function_keys;
int keypad_keys;
int other_keys;
int string_keys;
} TModify;
typedef struct
{
xtermKeyboardType type;
unsigned flags;
char *shell_translations;
char *xterm_translations;
char *extra_translations;
#if OPT_INITIAL_ERASE
int reset_DECBKM;
#endif
#if OPT_MOD_FKEYS
TModify modify_now;
TModify modify_1st;
int format_keys;
#endif
} TKeyboard;
typedef struct {
char *f_n;
char *f_b;
#if OPT_WIDE_CHARS
char *f_w;
char *f_wb;
#endif
} VTFontNames;
typedef struct _Misc {
VTFontNames default_font;
char *geo_metry;
char *T_geometry;
#if OPT_WIDE_CHARS
Boolean cjk_width;
Boolean mk_width;
int mk_samplesize;
int mk_samplepass;
#endif
#if OPT_LUIT_PROG
Boolean callfilter;
Boolean use_encoding;
char *locale_str;
char *localefilter;
#endif
#if OPT_INPUT_METHOD
char *f_x;
#endif
int limit_resize;
#ifdef ALLOWLOGGING
Boolean log_on;
#endif
Boolean login_shell;
Boolean re_verse;
Boolean re_verse0;
XtGravity resizeGravity;
Boolean reverseWrap;
Boolean autoWrap;
Boolean logInhibit;
Boolean signalInhibit;
#if OPT_TEK4014
Boolean tekInhibit;
Boolean tekSmall;
Boolean TekEmu;
Boolean Tshow;
#endif
Boolean scrollbar;
#ifdef SCROLLBAR_RIGHT
Boolean useRight;
#endif
Boolean titeInhibit;
Boolean tiXtraScroll;
Boolean appcursorDefault;
Boolean appkeypadDefault;
#if OPT_INPUT_METHOD
char* input_method;
char* preedit_type;
Boolean open_im;
Boolean cannot_im;
#endif
Boolean dynamicColors;
Boolean shared_ic;
#ifndef NO_ACTIVE_ICON
Boolean active_icon;
unsigned icon_border_width;
Pixel icon_border_pixel;
#endif
#if OPT_DEC_SOFTFONT
Boolean font_loadable;
#endif
#if OPT_SHIFT_FONTS
Boolean shift_fonts;
#endif
#if OPT_SUNPC_KBD
int ctrl_fkeys;
#endif
#if OPT_NUM_LOCK
Boolean real_NumLock;
Boolean alwaysUseMods;
unsigned long num_lock;
unsigned long alt_mods;
unsigned long meta_mods;
unsigned long other_mods;
#endif
#if OPT_RENDERFONT
char *face_name;
char *face_wide_name;
float face_size[NMENUFONTS];
Boolean render_font;
#endif
} Misc;
typedef struct {int foo;} XtermClassPart, TekClassPart;
typedef struct _XtermClassRec {
CoreClassPart core_class;
XtermClassPart xterm_class;
} XtermClassRec;
extern WidgetClass xtermWidgetClass;
#define IsXtermWidget(w) (XtClass(w) == xtermWidgetClass)
#if OPT_TEK4014
typedef struct _TekClassRec {
CoreClassPart core_class;
TekClassPart tek_class;
} TekClassRec;
extern WidgetClass tekWidgetClass;
#define IsTekWidget(w) (XtClass(w) == tekWidgetClass)
#endif
#define MODE_KAM xBIT(0)
#define MODE_DECKPAM xBIT(1)
#define MODE_DECCKM xBIT(2)
#define MODE_SRM xBIT(3)
#define MODE_DECBKM xBIT(4)
#define N_MARGINBELL 10
#define TAB_BITS_SHIFT 5
#define TAB_BITS_WIDTH (1 << TAB_BITS_SHIFT)
#define TAB_ARRAY_SIZE (1024 / TAB_BITS_WIDTH)
#define MAX_TABS (TAB_BITS_WIDTH * TAB_ARRAY_SIZE)
typedef unsigned Tabs [TAB_ARRAY_SIZE];
typedef struct _XtermWidgetRec {
CorePart core;
XSizeHints hints;
Bool init_menu;
TKeyboard keyboard;
TScreen screen;
unsigned flags;
int cur_foreground;
int cur_background;
Pixel dft_foreground;
Pixel dft_background;
#if OPT_ISO_COLORS
int sgr_foreground;
int sgr_background;
Boolean sgr_extended;
#endif
#if OPT_ISO_COLORS || OPT_DEC_CHRSET || OPT_WIDE_CHARS
int num_ptrs;
#endif
unsigned initflags;
Tabs tabs;
Misc misc;
} XtermWidgetRec, *XtermWidget;
#if OPT_TEK4014
typedef struct _TekWidgetRec {
CorePart core;
TekPart tek;
TekScreen screen;
Bool init_menu;
XSizeHints hints;
} TekWidgetRec, *TekWidget;
#endif
#define AttrBIT(n) xBIT(n)
#define DrawBIT(n) xBIT(n + 8)
#define MiscBIT(n) xBIT(n + 16)
#define INVERSE AttrBIT(0)
#define UNDERLINE AttrBIT(1)
#define BOLD AttrBIT(2)
#define BLINK AttrBIT(3)
#define BG_COLOR AttrBIT(4)
#define FG_COLOR AttrBIT(5)
#define PROTECTED AttrBIT(6)
#define CHARDRAWN AttrBIT(7)
#define NOBACKGROUND DrawBIT(0)
#define NOTRANSLATION DrawBIT(1)
#define DOUBLEWFONT DrawBIT(2)
#define DOUBLEHFONT DrawBIT(3)
#define CHARBYCHAR DrawBIT(4)
#define NORESOLUTION DrawBIT(5)
#define WRAPAROUND MiscBIT(0)
#define REVERSEWRAP MiscBIT(1)
#define REVERSE_VIDEO MiscBIT(2)
#define LINEFEED MiscBIT(3)
#define ORIGIN MiscBIT(4)
#define INSERT MiscBIT(5)
#define SMOOTHSCROLL MiscBIT(6)
#define IN132COLUMNS MiscBIT(7)
#define INVISIBLE MiscBIT(8)
#define NATIONAL MiscBIT(9)
#define SGR_MASK (BOLD | BLINK | UNDERLINE | INVERSE)
#define ATTRIBUTES (SGR_MASK | BG_COLOR | FG_COLOR | INVISIBLE | PROTECTED)
#define DRAWX_MASK (ATTRIBUTES | CHARDRAWN)
#if OPT_BLINK_TEXT
#define BOLDATTR(screen) (BOLD | ((screen)->blink_as_bold ? BLINK : 0))
#else
#define BOLDATTR(screen) (BOLD | BLINK)
#endif
#define LINEWRAPPED 0x01
#if OPT_ZICONBEEP || OPT_TOOLBAR
#define HANDLE_STRUCT_NOTIFY 1
#else
#define HANDLE_STRUCT_NOTIFY 0
#endif
#define OFF_PROTECT 0
#define DEC_PROTECT 1
#define ISO_PROTECT 2
#define TScreenOf(xw) (&(xw)->screen)
#define TekScreenOf(tw) (&(tw)->screen)
#ifdef SCROLLBAR_RIGHT
#define OriginX(screen) (((term->misc.useRight)?0:ScrollbarWidth(screen)) + screen->border)
#else
#define OriginX(screen) (ScrollbarWidth(screen) + screen->border)
#endif
#define OriginY(screen) (screen->border)
#define CursorMoved(screen) \
((screen)->cursor_moved || \
((screen)->cursorp.col != (screen)->cur_col || \
(screen)->cursorp.row != (screen)->cur_row))
#define CursorX(screen,col) ((col) * FontWidth(screen) + OriginX(screen))
#define CursorY(screen,row) ((INX2ROW(screen, row) * FontHeight(screen)) \
+ screen->border)
#ifndef NO_ACTIVE_ICON
#define IsIconWin(screen,win) ((win) == &(screen)->iconVwin)
#define IsIcon(screen) (WhichVWin(screen) == &(screen)->iconVwin)
#define WhichVWin(screen) ((screen)->whichVwin)
#define WhichTWin(screen) ((screen)->whichTwin)
#define WhichVFont(screen,name) (IsIcon(screen) ? (screen)->fnt_icon.fs \
: (screen)->name)
#define FontAscent(screen) (IsIcon(screen) ? (screen)->fnt_icon.fs->ascent \
: WhichVWin(screen)->f_ascent)
#define FontDescent(screen) (IsIcon(screen) ? (screen)->fnt_icon.fs->descent \
: WhichVWin(screen)->f_descent)
#else
#define IsIconWin(screen,win) (False)
#define IsIcon(screen) (False)
#define WhichVWin(screen) (&((screen)->fullVwin))
#define WhichTWin(screen) (&((screen)->fullTwin))
#define WhichVFont(screen,name) ((screen)->name)
#define FontAscent(screen) WhichVWin(screen)->f_ascent
#define FontDescent(screen) WhichVWin(screen)->f_descent
#endif
#define okFont(font) ((font) != 0 && (font)->fid != 0)
#define UsingRenderFont(xw) ((xw)->misc.render_font && !IsIcon(&((xw)->screen)))
#define VWindow(screen) WhichVWin(screen)->window
#define VShellWindow XtWindow(SHELL_OF(term))
#define TWindow(screen) WhichTWin(screen)->window
#define TShellWindow XtWindow(SHELL_OF(tekWidget))
#define Width(screen) WhichVWin(screen)->width
#define Height(screen) WhichVWin(screen)->height
#define FullWidth(screen) WhichVWin(screen)->fullwidth
#define FullHeight(screen) WhichVWin(screen)->fullheight
#define FontWidth(screen) WhichVWin(screen)->f_width
#define FontHeight(screen) WhichVWin(screen)->f_height
#define NormalFont(screen) WhichVFont(screen, fnts[fNorm].fs)
#define BoldFont(screen) WhichVFont(screen, fnts[fBold].fs)
#if OPT_WIDE_CHARS
#define NormalWFont(screen) WhichVFont(screen, fnts[fWide].fs)
#define BoldWFont(screen) WhichVFont(screen, fnts[fWBold].fs)
#endif
#define ScrollbarWidth(screen) WhichVWin(screen)->sb_info.width
#define NormalGC(w,sp) getCgsGC(w, WhichVWin(sp), gcNorm)
#define ReverseGC(w,sp) getCgsGC(w, WhichVWin(sp), gcNormReverse)
#define NormalBoldGC(w,sp) getCgsGC(w, WhichVWin(sp), gcBold)
#define ReverseBoldGC(w,sp) getCgsGC(w, WhichVWin(sp), gcBoldReverse)
#define TWidth(screen) WhichTWin(screen)->width
#define THeight(screen) WhichTWin(screen)->height
#define TFullWidth(screen) WhichTWin(screen)->fullwidth
#define TFullHeight(screen) WhichTWin(screen)->fullheight
#define TekScale(screen) WhichTWin(screen)->tekscale
#define BorderWidth(w) ((w)->core.border_width)
#define BorderPixel(w) ((w)->core.border_pixel)
#if OPT_TOOLBAR
#define ToolbarHeight(w) ((resource.toolBar) \
? (term->VT100_TB_INFO(menu_height) \
+ term->VT100_TB_INFO(menu_border) * 2) \
: 0)
#else
#define ToolbarHeight(w) 0
#endif
#if OPT_TEK4014
#define TEK_LINK_BLOCK_SIZE 1024
typedef struct Tek_Link
{
struct Tek_Link *next;
unsigned short fontsize;
unsigned short count;
char *ptr;
char data [TEK_LINK_BLOCK_SIZE];
} TekLink;
#endif
#define OFF 0
#define ON 1
#define BLINKED_OFF 2
#define CLEAR 0
#define TOGGLE 1
#ifdef ALLOWLOGGING
#define I_LOG 0x01
#endif
#define I_SIGNAL 0x02
#define I_TEK 0x04
#if OPT_TRACE
#undef NDEBUG
#else
#ifndef NDEBUG
#define NDEBUG
#endif
#endif
#include <trace.h>
#ifndef TRACE
#define TRACE(p)
#endif
#ifndef TRACE_ARGV
#define TRACE_ARGV(tag,argv)
#endif
#ifndef TRACE_CHILD
#define TRACE_CHILD
#endif
#ifndef TRACE_HINTS
#define TRACE_HINTS(hints)
#endif
#ifndef TRACE_IDS
#define TRACE_IDS
#endif
#ifndef TRACE_OPTS
#define TRACE_OPTS(opts,ress,lens)
#endif
#ifndef TRACE_TRANS
#define TRACE_TRANS(name,w)
#endif
#ifndef TRACE_WM_HINTS
#define TRACE_WM_HINTS(w)
#endif
#ifndef TRACE_XRES
#define TRACE_XRES()
#endif
#ifndef TRACE2
#define TRACE2(p)
#endif
#endif