This repository has been archived by the owner on Jul 26, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
ptyx.h
2836 lines (2432 loc) · 79.8 KB
/
ptyx.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* $XTermId: ptyx.h,v 1.762 2013/02/13 00:42:21 tom Exp $ */
/*
* Copyright 1999-2012,2013 by Thomas E. Dickey
*
* All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name(s) of the above copyright
* holders shall not be used in advertising or otherwise to promote the
* sale, use or other dealings in this Software without prior written
* authorization.
*
*
* Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
*
* All Rights Reserved
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted,
* provided that the above copyright notice appear in all copies and that
* both that copyright notice and this permission notice appear in
* supporting documentation, and that the name of Digital Equipment
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software without specific, written prior permission.
*
*
* DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
* DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#ifndef included_ptyx_h
#define included_ptyx_h 1
#ifdef HAVE_CONFIG_H
#include <xtermcfg.h>
#endif
/* ptyx.h */
/* *INDENT-OFF* */
/* @(#)ptyx.h X10/6.6 11/10/86 */
#include <X11/IntrinsicP.h>
#include <X11/Shell.h> /* for XtNdieCallback, etc. */
#include <X11/StringDefs.h> /* for standard resource names */
#include <X11/Xmu/Misc.h> /* For Max() and Min(). */
#undef bcopy
#undef bzero
#include <X11/Xfuncs.h>
#include <X11/Xosdefs.h>
#include <X11/Xmu/Converters.h>
#ifdef XRENDERFONT
#include <X11/Xft/Xft.h>
#endif
#include <stdio.h>
/* adapted from IntrinsicI.h */
#define MyStackAlloc(size, stack_cache_array) \
((size) <= sizeof(stack_cache_array) \
? (XtPointer)(stack_cache_array) \
: (XtPointer)malloc((size_t)(size)))
#define MyStackFree(pointer, stack_cache_array) \
if ((pointer) != ((char *)(stack_cache_array))) free(pointer)
/* adapted from vile (vi-like-emacs) */
#define TypeCallocN(type,n) (type *)calloc((size_t) (n), sizeof(type))
#define TypeCalloc(type) TypeCallocN(type, 1)
#define TypeMallocN(type,n) (type *)malloc(sizeof(type) * (size_t) (n))
#define TypeMalloc(type) TypeMallocN(type, 1)
#define TypeRealloc(type,n,p) (type *)realloc(p, (n) * sizeof(type))
#define TypeXtReallocN(t,p,n) (t *)(void *)XtRealloc((char *)(p), (Cardinal)(sizeof(t) * (size_t) (n)))
#define TypeXtMallocX(type,n) (type *)(void *)XtMalloc((Cardinal)(sizeof(type) + (size_t) (n)))
#define TypeXtMallocN(type,n) (type *)(void *)XtMalloc((Cardinal)(sizeof(type) * (size_t) (n)))
#define TypeXtMalloc(type) TypeXtMallocN(type, 1)
/* use these to allocate partly-structured data */
#define CastMallocN(type,n) (type *)malloc(sizeof(type) + (size_t) (n))
#define CastMalloc(type) CastMallocN(type,0)
#define BumpBuffer(type, buffer, size, want) \
if (want >= size) { \
size = 1 + (want * 2); \
buffer = TypeRealloc(type, size, buffer); \
}
#define BfBuf(type) screen->bf_buf_##type
#define BfLen(type) screen->bf_len_##type
#define TypedBuffer(type) \
type *bf_buf_##type; \
Cardinal bf_len_##type
#define BumpTypedBuffer(type, want) \
BumpBuffer(type, BfBuf(type), BfLen(type), want)
#define FreeTypedBuffer(type) \
if (BfBuf(type) != 0) { \
free(BfBuf(type)); \
BfBuf(type) = 0; \
} \
BfLen(type) = 0
/*
** System V definitions
*/
#ifdef att
#define ATT
#endif
#ifdef SVR4
#undef SYSV /* predefined on Solaris 2.4 */
#define SYSV /* SVR4 is (approx) superset of SVR3 */
#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 /* SYSV */
/*
* Newer versions of <X11/Xft/Xft.h> have a version number. We use certain
* features from that.
*/
#if defined(XRENDERFONT) && defined(XFT_VERSION) && XFT_VERSION >= 20100
#define HAVE_TYPE_FCCHAR32 1 /* compatible: XftChar16 */
#define HAVE_TYPE_XFTCHARSPEC 1 /* new type XftCharSpec */
#endif
/*
** Definitions to simplify ifdef's for pty's.
*/
#define USE_PTY_DEVICE 1
#define USE_PTY_SEARCH 1
#if defined(__osf__) || (defined(linux) && defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)) || defined(__DragonFly__) || 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
#elif defined(__OpenBSD__)
#undef USE_PTY_SEARCH
#undef USE_PTY_DEVICE
#endif
#if (defined (__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1)))
#define USE_HANDSHAKE 0 /* "recent" Linux systems do not require handshaking */
#endif
#if (defined (__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1)))
#define USE_USG_PTYS
#elif (defined(ATT) && !defined(__sgi)) || defined(__MVS__) || (defined(SYSV) && defined(i386))
#define USE_USG_PTYS
#endif
/*
* More systems than not require pty-handshaking.
*/
#ifndef USE_HANDSHAKE
#define USE_HANDSHAKE 1
#endif
/*
** allow for mobility of the pty master/slave directories
*/
#ifndef PTYDEV
#if defined(__hpux)
#define PTYDEV "/dev/ptym/ptyxx"
#elif defined(__MVS__)
#define PTYDEV "/dev/ptypxxxx"
#else
#define PTYDEV "/dev/ptyxx"
#endif
#endif /* !PTYDEV */
#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 /* !TTYDEV */
#ifndef PTYCHAR1
#ifdef __hpux
#define PTYCHAR1 "zyxwvutsrqp"
#else /* !__hpux */
#define PTYCHAR1 "pqrstuvwxyzPQRSTUVWXYZ"
#endif /* !__hpux */
#endif /* !PTYCHAR1 */
#ifndef PTYCHAR2
#ifdef __hpux
#define PTYCHAR2 "fedcba9876543210"
#else /* !__hpux */
#if defined(__DragonFly__) || defined(__FreeBSD__)
#define PTYCHAR2 "0123456789abcdefghijklmnopqrstuv"
#else /* !__FreeBSD__ */
#define PTYCHAR2 "0123456789abcdef"
#endif /* !__FreeBSD__ */
#endif /* !__hpux */
#endif /* !PTYCHAR2 */
#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 /* TTYFORMAT */
#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 /* PTYFORMAT */
#ifndef PTYCHARLEN
#ifdef CRAY
#define PTYCHARLEN 3
#elif defined(__MVS__)
#define PTYCHARLEN 8 /* OS/390 stores, e.g. ut_id="ttyp1234" */
#else
#define PTYCHARLEN 2
#endif
#endif
#ifndef MAXPTTYS
#ifdef CRAY
#define MAXPTTYS 256
#else
#define MAXPTTYS 2048
#endif
#endif
/* Until the translation manager comes along, I have to do my own translation of
* mouse events into the proper routines. */
typedef enum {
NORMAL = 0
, LEFTEXTENSION
, RIGHTEXTENSION
} EventMode;
/*
* The origin of a screen is 0, 0. Therefore, the number of rows
* on a screen is screen->max_row + 1, and similarly for columns.
*/
#define MaxCols(screen) ((screen)->max_col + 1)
#define MaxRows(screen) ((screen)->max_row + 1)
typedef unsigned char Char; /* to support 8 bit chars */
typedef Char *ScrnPtr;
typedef ScrnPtr *ScrnBuf;
/*
* Declare an X String, but for unsigned chars.
*/
#ifdef _CONST_X_STRING
typedef const Char *UString;
#else
typedef Char *UString;
#endif
#define IsEmpty(s) ((s) == 0 || *(s) == '\0')
#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))
/*
* ANSI emulation, special character codes
*/
#define ANSI_EOT 0x04
#define ANSI_BEL 0x07
#define ANSI_BS 0x08
#define ANSI_HT 0x09
#define ANSI_LF 0x0A
#define ANSI_VT 0x0B
#define ANSI_FF 0x0C /* C0, C1 control names */
#define ANSI_CR 0x0D
#define ANSI_SO 0x0E
#define ANSI_SI 0x0F
#define ANSI_XON 0x11 /* DC1 */
#define ANSI_XOFF 0x13 /* DC3 */
#define ANSI_NAK 0x15
#define ANSI_CAN 0x18
#define ANSI_ESC 0x1B
#define ANSI_SPA 0x20
#define XTERM_POUND 0x1E /* internal mapping for '#' */
#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 /* can emulate VT52 */
#define MAX_DECID 525 /* ...through VT525 */
#ifndef DFT_DECID
#define DFT_DECID "vt420" /* default VT420 */
#endif
#ifndef DFT_KBD_DIALECT
#define DFT_KBD_DIALECT "B" /* default USASCII */
#endif
/* constants used for utf8 mode */
#define UCS_REPL 0xfffd
#define UCS_LIMIT 0x80000000U /* both limit and flag for non-UCS */
#define TERMCAP_SIZE 1500 /* 1023 is standard; 'screen' exceeds */
#define NMENUFONTS 9 /* font entries in fontMenu */
#define NBOX 5 /* Number of Points in box */
#define NPARAM 30 /* Max. parameters */
typedef struct {
String opt;
String desc;
} OptionHelp;
typedef struct {
int count; /* number of values in params[] */
int has_subparams; /* true if there are any sub's */
int is_sub[NPARAM]; /* true for subparam */
int params[NPARAM]; /* parameter value */
} PARAMS;
typedef short ParmType;
typedef struct {
Char a_type; /* CSI, etc., see unparseq() */
Char a_pintro; /* private-mode char, if any */
const char * a_delim; /* between parameters (;) */
Char a_inters; /* special (before final-char) */
Char a_final; /* final-char */
ParmType a_nparam; /* # of parameters */
ParmType a_param[NPARAM]; /* Parameters */
Char a_radix[NPARAM]; /* Parameters */
} ANSI;
#define TEK_FONT_LARGE 0
#define TEK_FONT_2 1
#define TEK_FONT_3 2
#define TEK_FONT_SMALL 3
#define TEKNUMFONTS 4
/* Actually there are 5 types of lines, but four are non-solid lines */
#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 /* default # lines to save */
#define SCROLLLINES 1 /* default # lines to scroll */
#define EXCHANGE(a,b,tmp) tmp = a; a = b; b = tmp
/***====================================================================***/
#if (XtSpecificationRelease < 6)
#ifndef NO_ACTIVE_ICON
#define NO_ACTIVE_ICON 1 /* Note: code relies on an X11R6 function */
#endif
#endif
#ifndef OPT_AIX_COLORS
#define OPT_AIX_COLORS 1 /* true if xterm is configured with AIX (16) colors */
#endif
#ifndef OPT_ALLOW_XXX_OPS
#define OPT_ALLOW_XXX_OPS 1 /* true if xterm adds "Allow XXX Ops" submenu */
#endif
#ifndef OPT_BLINK_CURS
#define OPT_BLINK_CURS 1 /* true if xterm has blinking cursor capability */
#endif
#ifndef OPT_BLINK_TEXT
#define OPT_BLINK_TEXT OPT_BLINK_CURS /* true if xterm has blinking text capability */
#endif
#ifndef OPT_BOX_CHARS
#define OPT_BOX_CHARS 1 /* true if xterm can simulate box-characters */
#endif
#ifndef OPT_BUILTIN_XPMS
#define OPT_BUILTIN_XPMS 0 /* true if all xpm data is compiled-in */
#endif
#ifndef OPT_BROKEN_OSC
#ifdef linux
#define OPT_BROKEN_OSC 1 /* man console_codes, 1st paragraph - cf: ECMA-48 */
#else
#define OPT_BROKEN_OSC 0 /* true if xterm allows Linux's broken OSC parsing */
#endif
#endif
#ifndef OPT_BROKEN_ST
#define OPT_BROKEN_ST 1 /* true if xterm allows old/broken OSC parsing */
#endif
#ifndef OPT_C1_PRINT
#define OPT_C1_PRINT 1 /* true if xterm allows C1 controls to be printable */
#endif
#ifndef OPT_CLIP_BOLD
#define OPT_CLIP_BOLD 1 /* true if xterm uses clipping to avoid bold-trash */
#endif
#ifndef OPT_COLOR_CLASS
#define OPT_COLOR_CLASS 1 /* true if xterm uses separate color-resource classes */
#endif
#ifndef OPT_COLOR_RES
#define OPT_COLOR_RES 1 /* true if xterm delays color-resource evaluation */
#endif
#ifndef OPT_DABBREV
#define OPT_DABBREV 0 /* dynamic abbreviations */
#endif
#ifndef OPT_DEC_CHRSET
#define OPT_DEC_CHRSET 1 /* true if xterm is configured for DEC charset */
#endif
#ifndef OPT_DEC_LOCATOR
#define OPT_DEC_LOCATOR 0 /* true if xterm supports VT220-style mouse events */
#endif
#ifndef OPT_DEC_RECTOPS
#define OPT_DEC_RECTOPS 0 /* true if xterm is configured for VT420 rectangles */
#endif
#ifndef OPT_DEC_SOFTFONT
#define OPT_DEC_SOFTFONT 0 /* true if xterm is configured for VT220 softfonts */
#endif
#ifndef OPT_DOUBLE_BUFFER
#define OPT_DOUBLE_BUFFER 0 /* true if using double-buffering */
#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 /* true if xterm can fork/exec copies of itself */
#endif
#ifndef OPT_EXTRA_PASTE
#define OPT_EXTRA_PASTE 1
#endif
#ifndef OPT_FIFO_LINES
#define OPT_FIFO_LINES 0 /* optimize save-lines feature using FIFO */
#endif
#ifndef OPT_FOCUS_EVENT
#define OPT_FOCUS_EVENT 1 /* focus in/out events */
#endif
#ifndef OPT_HP_FUNC_KEYS
#define OPT_HP_FUNC_KEYS 0 /* true if xterm supports HP-style function keys */
#endif
#ifndef OPT_I18N_SUPPORT
#if (XtSpecificationRelease >= 5)
#define OPT_I18N_SUPPORT 1 /* true if xterm uses internationalization support */
#else
#define OPT_I18N_SUPPORT 0
#endif
#endif
#ifndef OPT_INITIAL_ERASE
#define OPT_INITIAL_ERASE 1 /* use pty's erase character if it's not 128 */
#endif
#ifndef OPT_INPUT_METHOD
#if (XtSpecificationRelease >= 6)
#define OPT_INPUT_METHOD 1 /* true if xterm uses input-method support */
#else
#define OPT_INPUT_METHOD 0
#endif
#endif
#ifndef OPT_ISO_COLORS
#define OPT_ISO_COLORS 1 /* true if xterm is configured with ISO colors */
#endif
#ifndef OPT_256_COLORS
#define OPT_256_COLORS 0 /* true if xterm is configured with 256 colors */
#endif
#ifndef OPT_88_COLORS
#define OPT_88_COLORS 0 /* true if xterm is configured with 88 colors */
#endif
#ifndef OPT_HIGHLIGHT_COLOR
#define OPT_HIGHLIGHT_COLOR 1 /* true if xterm supports color highlighting */
#endif
#ifndef OPT_LOAD_VTFONTS
#define OPT_LOAD_VTFONTS 0 /* true if xterm has load-vt-fonts() action */
#endif
#ifndef OPT_LUIT_PROG
#define OPT_LUIT_PROG 0 /* true if xterm supports luit */
#endif
#ifndef OPT_MAXIMIZE
#define OPT_MAXIMIZE 1 /* add actions for iconify ... maximize */
#endif
#ifndef OPT_MINI_LUIT
#define OPT_MINI_LUIT 0 /* true if xterm supports built-in mini-luit */
#endif
#ifndef OPT_MOD_FKEYS
#define OPT_MOD_FKEYS 1 /* modify cursor- and function-keys in normal mode */
#endif
#ifndef OPT_NUM_LOCK
#define OPT_NUM_LOCK 1 /* use NumLock key only for numeric-keypad */
#endif
#ifndef OPT_PASTE64
#define OPT_PASTE64 0 /* program control of select/paste via base64 */
#endif
#ifndef OPT_PC_COLORS
#define OPT_PC_COLORS 1 /* true if xterm supports PC-style (bold) colors */
#endif
#ifndef OPT_PRINT_ON_EXIT
#define OPT_PRINT_ON_EXIT 1 /* true allows xterm to dump screen on X error */
#endif
#ifndef OPT_PTY_HANDSHAKE
#define OPT_PTY_HANDSHAKE USE_HANDSHAKE /* avoid pty races on older systems */
#endif
#ifndef OPT_PRINT_COLORS
#define OPT_PRINT_COLORS 1 /* true if we print color information */
#endif
#ifndef OPT_READLINE
#define OPT_READLINE 0 /* mouse-click/paste support for readline */
#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 /* suppress redundant updates of title, icon, etc. */
#endif
#ifndef OPT_SAVE_LINES
#define OPT_SAVE_LINES OPT_FIFO_LINES /* optimize save-lines feature */
#endif
#ifndef OPT_SCO_FUNC_KEYS
#define OPT_SCO_FUNC_KEYS 0 /* true if xterm supports SCO-style function keys */
#endif
#ifndef OPT_SUN_FUNC_KEYS
#define OPT_SUN_FUNC_KEYS 1 /* true if xterm supports Sun-style function keys */
#endif
#ifndef OPT_SCROLL_LOCK
#define OPT_SCROLL_LOCK 1 /* true if xterm interprets fontsize-shifting */
#endif
#ifndef OPT_SELECT_REGEX
#define OPT_SELECT_REGEX 0 /* true if xterm supports regular-expression selects */
#endif
#ifndef OPT_SELECTION_OPS
#define OPT_SELECTION_OPS 1 /* true if xterm supports operations on selection */
#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 /* true if xterm interprets fontsize-shifting */
#endif
#ifndef OPT_SUNPC_KBD
#define OPT_SUNPC_KBD 1 /* true if xterm supports Sun/PC keyboard map */
#endif
#ifndef OPT_TCAP_FKEYS
#define OPT_TCAP_FKEYS 0 /* true for experimental termcap function-keys */
#endif
#ifndef OPT_TCAP_QUERY
#define OPT_TCAP_QUERY 0 /* true for experimental termcap query */
#endif
#ifndef OPT_TEK4014
#define OPT_TEK4014 1 /* true if we're using tek4014 emulation */
#endif
#ifndef OPT_TOOLBAR
#define OPT_TOOLBAR 0 /* true if xterm supports toolbar menus */
#endif
#ifndef OPT_TRACE
#define OPT_TRACE 0 /* true if we're using debugging traces */
#endif
#ifndef OPT_TRACE_FLAGS
#define OPT_TRACE_FLAGS 0 /* additional tracing used for SCRN_BUF_FLAGS */
#endif
#ifndef OPT_VT52_MODE
#define OPT_VT52_MODE 1 /* true if xterm supports VT52 emulation */
#endif
#ifndef OPT_WIDE_CHARS
#define OPT_WIDE_CHARS 0 /* true if xterm supports 16-bit characters */
#endif
#ifndef OPT_WIDER_ICHAR
#define OPT_WIDER_ICHAR 1 /* true if xterm uses 32-bits for wide-chars */
#endif
#ifndef OPT_XMC_GLITCH
#define OPT_XMC_GLITCH 0 /* true if xterm supports xmc (magic cookie glitch) */
#endif
#ifndef OPT_ZICONBEEP
#define OPT_ZICONBEEP 1 /* true if xterm supports "-ziconbeep" option */
#endif
/***====================================================================***/
#if OPT_AIX_COLORS && !OPT_ISO_COLORS
/* You must have ANSI/ISO colors to support AIX colors */
#undef OPT_AIX_COLORS
#define OPT_AIX_COLORS 0
#endif
#if OPT_COLOR_RES && !OPT_ISO_COLORS
/* You must have ANSI/ISO colors to support ColorRes logic */
#undef OPT_COLOR_RES
#define OPT_COLOR_RES 0
#endif
#if OPT_256_COLORS && (OPT_WIDE_CHARS || OPT_RENDERFONT || OPT_XMC_GLITCH)
/* It's actually more complicated than that - but by trimming options you can
* have 256 color resources though.
*/
#define OPT_COLOR_RES2 1
#else
#define OPT_COLOR_RES2 0
#endif
#if OPT_PASTE64 && !OPT_READLINE
/* OPT_PASTE64 uses logic from OPT_READLINE */
#undef OPT_READLINE
#define OPT_READLINE 1
#endif
#if OPT_PC_COLORS && !OPT_ISO_COLORS
/* You must have ANSI/ISO colors to support PC colors */
#undef OPT_PC_COLORS
#define OPT_PC_COLORS 0
#endif
#if OPT_PRINT_COLORS && !OPT_ISO_COLORS
/* You must have ANSI/ISO colors to be able to print them */
#undef OPT_PRINT_COLORS
#define OPT_PRINT_COLORS 0
#endif
#if OPT_256_COLORS && !OPT_ISO_COLORS
/* You must have ANSI/ISO colors to support 256 colors */
#undef OPT_256_COLORS
#define OPT_256_COLORS 0
#endif
#if OPT_88_COLORS && !OPT_ISO_COLORS
/* You must have ANSI/ISO colors to support 88 colors */
#undef OPT_88_COLORS
#define OPT_88_COLORS 0
#endif
#if OPT_88_COLORS && OPT_256_COLORS
/* 256 colors supersedes 88 colors */
#undef OPT_88_COLORS
#define OPT_88_COLORS 0
#endif
/***====================================================================***/
/*
* Indices for menu_font_names[][]
*/
typedef enum {
fNorm = 0 /* normal font */
, fBold /* bold font */
#if OPT_WIDE_CHARS
, fWide /* double-width font */
, fWBold /* double-width bold font */
#endif
, fMAX
} VTFontEnum;
/*
* Indices for cachedGCs.c (unrelated to 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)
/*
* Indices for the normal terminal colors in screen.Tcolors[].
* See also OscTextColors, which has corresponding values.
*/
typedef enum {
TEXT_FG = 0 /* text foreground */
, TEXT_BG /* text background */
, TEXT_CURSOR /* text cursor */
, MOUSE_FG /* mouse foreground */
, MOUSE_BG /* mouse background */
#if OPT_TEK4014
, TEK_FG = 5 /* tektronix foreground */
, TEK_BG /* tektronix background */
#endif
#if OPT_HIGHLIGHT_COLOR
, HIGHLIGHT_BG = 7 /* highlight background */
#endif
#if OPT_TEK4014
, TEK_CURSOR = 8 /* tektronix cursor */
#endif
#if OPT_HIGHLIGHT_COLOR
, HIGHLIGHT_FG = 9 /* highlight foreground */
#endif
, NCOLORS /* total number of colors */
} TermColors;
/*
* Constants for titleModes resource
*/
typedef enum {
tmSetBase16 = 1 /* set title using hex-string */
, tmGetBase16 = 2 /* get title using hex-string */
#if OPT_WIDE_CHARS
, tmSetUtf8 = 4 /* like utf8Title, but controllable */
, tmGetUtf8 = 8 /* retrieve title encoded as UTF-8 */
#endif
} TitleModes;
#define IsTitleMode(xw,mode) (((xw)->screen.title_modes & mode) != 0)
/* indices for mapping multiple clicks to selection types */
typedef enum {
Select_CHAR=0
,Select_WORD
,Select_LINE
,Select_GROUP
,Select_PAGE
,Select_ALL
#if OPT_SELECT_REGEX
,Select_REGEX
#endif
,NSELECTUNITS
} SelectUnit;
typedef enum {
ecSetColor = 1
, ecGetColor
, ecGetAnsiColor
, ecLAST
} ColorOps;
typedef enum {
efSetFont = 1
, efGetFont
, efLAST
} FontOps;
typedef enum {
esFalse = 0
, esTrue
, esAlways
, esNever
} FullscreenOps;
#ifndef NO_ACTIVE_ICON
typedef enum {
eiFalse = 0
, eiTrue
, eiDefault
, eiLAST
} AIconOps;
#endif
typedef enum {
etSetTcap = 1
, etGetTcap
, etLAST
} TcapOps;
typedef enum {
/* 1-23 are chosen to be the same as the control-sequence coding */
ewRestoreWin = 1
, ewMinimizeWin = 2
, ewSetWinPosition = 3
, ewSetWinSizePixels = 4
, ewRaiseWin = 5
, ewLowerWin = 6
, ewRefreshWin = 7
, ewSetWinSizeChars = 8
#if OPT_MAXIMIZE
, ewMaximizeWin = 9
, ewFullscreenWin = 10
#endif
, ewGetWinState = 11
, ewGetWinPosition = 13
, ewGetWinSizePixels = 14
, ewGetWinSizeChars = 18
#if OPT_MAXIMIZE
, ewGetScreenSizeChars = 19
#endif
, ewGetIconTitle = 20
, ewGetWinTitle = 21
, ewPushTitle = 22
, ewPopTitle = 23
/* these do not fit into that scheme, which is why we use an array */
, ewSetWinLines
, ewSetXprop
, ewGetSelection
, ewSetSelection
/* get the size of the array... */
, ewLAST
} WindowOps;
#define COLOR_DEFINED(s,w) ((s)->which & (unsigned) (1<<(w)))
#define COLOR_VALUE(s,w) ((s)->colors[w])
#define SET_COLOR_VALUE(s,w,v) (((s)->colors[w] = (v)), UIntSet((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 |= (unsigned) (1<<(w))))
#define UNDEFINE_COLOR(s,w) ((s)->which &= (~((w)<<1)))
/***====================================================================***/
#if OPT_ISO_COLORS
#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