-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathterm.c
6055 lines (5662 loc) · 156 KB
/
term.c
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
/* vi:set ts=8 sts=4 sw=4:
*
* VIM - Vi IMproved by Bram Moolenaar
*
* Do ":help uganda" in Vim to read copying and usage conditions.
* Do ":help credits" in Vim to see a list of people who contributed.
* See README.txt for an overview of the Vim source code.
*/
/*
*
* term.c: functions for controlling the terminal
*
* primitive termcap support for Amiga, MSDOS, and Win32 included
*
* NOTE: padding and variable substitution is not performed,
* when compiling without HAVE_TGETENT, we use tputs() and tgoto() dummies.
*/
/*
* Some systems have a prototype for tgetstr() with (char *) instead of
* (char **). This define removes that prototype. We include our own prototype
* below.
*/
#define tgetstr tgetstr_defined_wrong
#include "vim.h"
#ifdef HAVE_TGETENT
# ifdef HAVE_TERMIOS_H
# include <termios.h> /* seems to be required for some Linux */
# endif
# ifdef HAVE_TERMCAP_H
# include <termcap.h>
# endif
/*
* A few linux systems define outfuntype in termcap.h to be used as the third
* argument for tputs().
*/
# ifdef VMS
# define TPUTSFUNCAST
# else
# ifdef HAVE_OUTFUNTYPE
# define TPUTSFUNCAST (outfuntype)
# else
# define TPUTSFUNCAST (int (*)())
# endif
# endif
#endif
#undef tgetstr
/*
* Here are the builtin termcap entries. They are not stored as complete
* structures with all entries, as such a structure is too big.
*
* The entries are compact, therefore they normally are included even when
* HAVE_TGETENT is defined. When HAVE_TGETENT is defined, the builtin entries
* can be accessed with "builtin_amiga", "builtin_ansi", "builtin_debug", etc.
*
* Each termcap is a list of builtin_term structures. It always starts with
* KS_NAME, which separates the entries. See parse_builtin_tcap() for all
* details.
* bt_entry is either a KS_xxx code (>= 0), or a K_xxx code.
*
* Entries marked with "guessed" may be wrong.
*/
struct builtin_term
{
int bt_entry;
char *bt_string;
};
/* start of keys that are not directly used by Vim but can be mapped */
#define BT_EXTRA_KEYS 0x101
static struct builtin_term *find_builtin_term __ARGS((char_u *name));
static void parse_builtin_tcap __ARGS((char_u *s));
static void term_color __ARGS((char_u *s, int n));
static void gather_termleader __ARGS((void));
#ifdef FEAT_TERMRESPONSE
static void req_codes_from_term __ARGS((void));
static void req_more_codes_from_term __ARGS((void));
static void got_code_from_term __ARGS((char_u *code, int len));
static void check_for_codes_from_term __ARGS((void));
#endif
#if defined(FEAT_GUI) \
|| (defined(FEAT_MOUSE) && (!defined(UNIX) || defined(FEAT_MOUSE_XTERM) \
|| defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE)))
static int get_bytes_from_buf __ARGS((char_u *, char_u *, int));
#endif
static void del_termcode_idx __ARGS((int idx));
static int term_is_builtin __ARGS((char_u *name));
static int term_7to8bit __ARGS((char_u *p));
#ifdef FEAT_TERMRESPONSE
static void switch_to_8bit __ARGS((void));
#endif
#ifdef HAVE_TGETENT
static char_u *tgetent_error __ARGS((char_u *, char_u *));
/*
* Here is our own prototype for tgetstr(), any prototypes from the include
* files have been disabled by the define at the start of this file.
*/
char *tgetstr __ARGS((char *, char **));
# ifdef FEAT_TERMRESPONSE
/* Change this to "if 1" to debug what happens with termresponse. */
# if 0
# define DEBUG_TERMRESPONSE
static void log_tr(char *msg);
# define LOG_TR(msg) log_tr(msg)
# else
# define LOG_TR(msg)
# endif
/* Request Terminal Version status: */
# define CRV_GET 1 /* send T_CRV when switched to RAW mode */
# define CRV_SENT 2 /* did send T_CRV, waiting for answer */
# define CRV_GOT 3 /* received T_CRV response */
static int crv_status = CRV_GET;
/* Request Cursor position report: */
# define U7_GET 1 /* send T_U7 when switched to RAW mode */
# define U7_SENT 2 /* did send T_U7, waiting for answer */
# define U7_GOT 3 /* received T_U7 response */
static int u7_status = U7_GET;
# endif
/*
* Don't declare these variables if termcap.h contains them.
* Autoconf checks if these variables should be declared extern (not all
* systems have them).
* Some versions define ospeed to be speed_t, but that is incompatible with
* BSD, where ospeed is short and speed_t is long.
*/
# ifndef HAVE_OSPEED
# ifdef OSPEED_EXTERN
extern short ospeed;
# else
short ospeed;
# endif
# endif
# ifndef HAVE_UP_BC_PC
# ifdef UP_BC_PC_EXTERN
extern char *UP, *BC, PC;
# else
char *UP, *BC, PC;
# endif
# endif
# define TGETSTR(s, p) vim_tgetstr((s), (p))
# define TGETENT(b, t) tgetent((char *)(b), (char *)(t))
static char_u *vim_tgetstr __ARGS((char *s, char_u **pp));
#endif /* HAVE_TGETENT */
static int detected_8bit = FALSE; /* detected 8-bit terminal */
static struct builtin_term builtin_termcaps[] =
{
#if defined(FEAT_GUI)
/*
* GUI pseudo term-cap.
*/
{(int)KS_NAME, "gui"},
{(int)KS_CE, IF_EB("\033|$", ESC_STR "|$")},
{(int)KS_AL, IF_EB("\033|i", ESC_STR "|i")},
# ifdef TERMINFO
{(int)KS_CAL, IF_EB("\033|%p1%dI", ESC_STR "|%p1%dI")},
# else
{(int)KS_CAL, IF_EB("\033|%dI", ESC_STR "|%dI")},
# endif
{(int)KS_DL, IF_EB("\033|d", ESC_STR "|d")},
# ifdef TERMINFO
{(int)KS_CDL, IF_EB("\033|%p1%dD", ESC_STR "|%p1%dD")},
{(int)KS_CS, IF_EB("\033|%p1%d;%p2%dR", ESC_STR "|%p1%d;%p2%dR")},
# ifdef FEAT_VERTSPLIT
{(int)KS_CSV, IF_EB("\033|%p1%d;%p2%dV", ESC_STR "|%p1%d;%p2%dV")},
# endif
# else
{(int)KS_CDL, IF_EB("\033|%dD", ESC_STR "|%dD")},
{(int)KS_CS, IF_EB("\033|%d;%dR", ESC_STR "|%d;%dR")},
# ifdef FEAT_VERTSPLIT
{(int)KS_CSV, IF_EB("\033|%d;%dV", ESC_STR "|%d;%dV")},
# endif
# endif
{(int)KS_CL, IF_EB("\033|C", ESC_STR "|C")},
/* attributes switched on with 'h', off with * 'H' */
{(int)KS_ME, IF_EB("\033|31H", ESC_STR "|31H")}, /* HL_ALL */
{(int)KS_MR, IF_EB("\033|1h", ESC_STR "|1h")}, /* HL_INVERSE */
{(int)KS_MD, IF_EB("\033|2h", ESC_STR "|2h")}, /* HL_BOLD */
{(int)KS_SE, IF_EB("\033|16H", ESC_STR "|16H")}, /* HL_STANDOUT */
{(int)KS_SO, IF_EB("\033|16h", ESC_STR "|16h")}, /* HL_STANDOUT */
{(int)KS_UE, IF_EB("\033|8H", ESC_STR "|8H")}, /* HL_UNDERLINE */
{(int)KS_US, IF_EB("\033|8h", ESC_STR "|8h")}, /* HL_UNDERLINE */
{(int)KS_UCE, IF_EB("\033|8C", ESC_STR "|8C")}, /* HL_UNDERCURL */
{(int)KS_UCS, IF_EB("\033|8c", ESC_STR "|8c")}, /* HL_UNDERCURL */
{(int)KS_CZR, IF_EB("\033|4H", ESC_STR "|4H")}, /* HL_ITALIC */
{(int)KS_CZH, IF_EB("\033|4h", ESC_STR "|4h")}, /* HL_ITALIC */
{(int)KS_VB, IF_EB("\033|f", ESC_STR "|f")},
{(int)KS_MS, "y"},
{(int)KS_UT, "y"},
{(int)KS_XN, "y"},
{(int)KS_LE, "\b"}, /* cursor-left = BS */
{(int)KS_ND, "\014"}, /* cursor-right = CTRL-L */
# ifdef TERMINFO
{(int)KS_CM, IF_EB("\033|%p1%d;%p2%dM", ESC_STR "|%p1%d;%p2%dM")},
# else
{(int)KS_CM, IF_EB("\033|%d;%dM", ESC_STR "|%d;%dM")},
# endif
/* there are no key sequences here, the GUI sequences are recognized
* in check_termcode() */
#endif
#ifndef NO_BUILTIN_TCAPS
# if defined(AMIGA) || defined(ALL_BUILTIN_TCAPS)
/*
* Amiga console window, default for Amiga
*/
{(int)KS_NAME, "amiga"},
{(int)KS_CE, "\033[K"},
{(int)KS_CD, "\033[J"},
{(int)KS_AL, "\033[L"},
# ifdef TERMINFO
{(int)KS_CAL, "\033[%p1%dL"},
# else
{(int)KS_CAL, "\033[%dL"},
# endif
{(int)KS_DL, "\033[M"},
# ifdef TERMINFO
{(int)KS_CDL, "\033[%p1%dM"},
# else
{(int)KS_CDL, "\033[%dM"},
# endif
{(int)KS_CL, "\014"},
{(int)KS_VI, "\033[0 p"},
{(int)KS_VE, "\033[1 p"},
{(int)KS_ME, "\033[0m"},
{(int)KS_MR, "\033[7m"},
{(int)KS_MD, "\033[1m"},
{(int)KS_SE, "\033[0m"},
{(int)KS_SO, "\033[33m"},
{(int)KS_US, "\033[4m"},
{(int)KS_UE, "\033[0m"},
{(int)KS_CZH, "\033[3m"},
{(int)KS_CZR, "\033[0m"},
#if defined(__MORPHOS__) || defined(__AROS__)
{(int)KS_CCO, "8"}, /* allow 8 colors */
# ifdef TERMINFO
{(int)KS_CAB, "\033[4%p1%dm"},/* set background color */
{(int)KS_CAF, "\033[3%p1%dm"},/* set foreground color */
# else
{(int)KS_CAB, "\033[4%dm"}, /* set background color */
{(int)KS_CAF, "\033[3%dm"}, /* set foreground color */
# endif
{(int)KS_OP, "\033[m"}, /* reset colors */
#endif
{(int)KS_MS, "y"},
{(int)KS_UT, "y"}, /* guessed */
{(int)KS_LE, "\b"},
# ifdef TERMINFO
{(int)KS_CM, "\033[%i%p1%d;%p2%dH"},
# else
{(int)KS_CM, "\033[%i%d;%dH"},
# endif
#if defined(__MORPHOS__)
{(int)KS_SR, "\033M"},
#endif
# ifdef TERMINFO
{(int)KS_CRI, "\033[%p1%dC"},
# else
{(int)KS_CRI, "\033[%dC"},
# endif
{K_UP, "\233A"},
{K_DOWN, "\233B"},
{K_LEFT, "\233D"},
{K_RIGHT, "\233C"},
{K_S_UP, "\233T"},
{K_S_DOWN, "\233S"},
{K_S_LEFT, "\233 A"},
{K_S_RIGHT, "\233 @"},
{K_S_TAB, "\233Z"},
{K_F1, "\233\060~"},/* some compilers don't dig "\2330" */
{K_F2, "\233\061~"},
{K_F3, "\233\062~"},
{K_F4, "\233\063~"},
{K_F5, "\233\064~"},
{K_F6, "\233\065~"},
{K_F7, "\233\066~"},
{K_F8, "\233\067~"},
{K_F9, "\233\070~"},
{K_F10, "\233\071~"},
{K_S_F1, "\233\061\060~"},
{K_S_F2, "\233\061\061~"},
{K_S_F3, "\233\061\062~"},
{K_S_F4, "\233\061\063~"},
{K_S_F5, "\233\061\064~"},
{K_S_F6, "\233\061\065~"},
{K_S_F7, "\233\061\066~"},
{K_S_F8, "\233\061\067~"},
{K_S_F9, "\233\061\070~"},
{K_S_F10, "\233\061\071~"},
{K_HELP, "\233?~"},
{K_INS, "\233\064\060~"}, /* 101 key keyboard */
{K_PAGEUP, "\233\064\061~"}, /* 101 key keyboard */
{K_PAGEDOWN, "\233\064\062~"}, /* 101 key keyboard */
{K_HOME, "\233\064\064~"}, /* 101 key keyboard */
{K_END, "\233\064\065~"}, /* 101 key keyboard */
{BT_EXTRA_KEYS, ""},
{TERMCAP2KEY('#', '2'), "\233\065\064~"}, /* shifted home key */
{TERMCAP2KEY('#', '3'), "\233\065\060~"}, /* shifted insert key */
{TERMCAP2KEY('*', '7'), "\233\065\065~"}, /* shifted end key */
# endif
# if defined(__BEOS__) || defined(ALL_BUILTIN_TCAPS)
/*
* almost standard ANSI terminal, default for bebox
*/
{(int)KS_NAME, "beos-ansi"},
{(int)KS_CE, "\033[K"},
{(int)KS_CD, "\033[J"},
{(int)KS_AL, "\033[L"},
# ifdef TERMINFO
{(int)KS_CAL, "\033[%p1%dL"},
# else
{(int)KS_CAL, "\033[%dL"},
# endif
{(int)KS_DL, "\033[M"},
# ifdef TERMINFO
{(int)KS_CDL, "\033[%p1%dM"},
# else
{(int)KS_CDL, "\033[%dM"},
# endif
#ifdef BEOS_PR_OR_BETTER
# ifdef TERMINFO
{(int)KS_CS, "\033[%i%p1%d;%p2%dr"},
# else
{(int)KS_CS, "\033[%i%d;%dr"}, /* scroll region */
# endif
#endif
{(int)KS_CL, "\033[H\033[2J"},
#ifdef notyet
{(int)KS_VI, "[VI]"}, /* cursor invisible, VT320: CSI ? 25 l */
{(int)KS_VE, "[VE]"}, /* cursor visible, VT320: CSI ? 25 h */
#endif
{(int)KS_ME, "\033[m"}, /* normal mode */
{(int)KS_MR, "\033[7m"}, /* reverse */
{(int)KS_MD, "\033[1m"}, /* bold */
{(int)KS_SO, "\033[31m"}, /* standout mode: red */
{(int)KS_SE, "\033[m"}, /* standout end */
{(int)KS_CZH, "\033[35m"}, /* italic: purple */
{(int)KS_CZR, "\033[m"}, /* italic end */
{(int)KS_US, "\033[4m"}, /* underscore mode */
{(int)KS_UE, "\033[m"}, /* underscore end */
{(int)KS_CCO, "8"}, /* allow 8 colors */
# ifdef TERMINFO
{(int)KS_CAB, "\033[4%p1%dm"},/* set background color */
{(int)KS_CAF, "\033[3%p1%dm"},/* set foreground color */
# else
{(int)KS_CAB, "\033[4%dm"}, /* set background color */
{(int)KS_CAF, "\033[3%dm"}, /* set foreground color */
# endif
{(int)KS_OP, "\033[m"}, /* reset colors */
{(int)KS_MS, "y"}, /* safe to move cur in reverse mode */
{(int)KS_UT, "y"}, /* guessed */
{(int)KS_LE, "\b"},
# ifdef TERMINFO
{(int)KS_CM, "\033[%i%p1%d;%p2%dH"},
# else
{(int)KS_CM, "\033[%i%d;%dH"},
# endif
{(int)KS_SR, "\033M"},
# ifdef TERMINFO
{(int)KS_CRI, "\033[%p1%dC"},
# else
{(int)KS_CRI, "\033[%dC"},
# endif
#if defined(BEOS_DR8)
{(int)KS_DB, ""}, /* hack! see screen.c */
#endif
{K_UP, "\033[A"},
{K_DOWN, "\033[B"},
{K_LEFT, "\033[D"},
{K_RIGHT, "\033[C"},
# endif
# if defined(UNIX) || defined(ALL_BUILTIN_TCAPS) || defined(SOME_BUILTIN_TCAPS) || defined(__EMX__)
/*
* standard ANSI terminal, default for unix
*/
{(int)KS_NAME, "ansi"},
{(int)KS_CE, IF_EB("\033[K", ESC_STR "[K")},
{(int)KS_AL, IF_EB("\033[L", ESC_STR "[L")},
# ifdef TERMINFO
{(int)KS_CAL, IF_EB("\033[%p1%dL", ESC_STR "[%p1%dL")},
# else
{(int)KS_CAL, IF_EB("\033[%dL", ESC_STR "[%dL")},
# endif
{(int)KS_DL, IF_EB("\033[M", ESC_STR "[M")},
# ifdef TERMINFO
{(int)KS_CDL, IF_EB("\033[%p1%dM", ESC_STR "[%p1%dM")},
# else
{(int)KS_CDL, IF_EB("\033[%dM", ESC_STR "[%dM")},
# endif
{(int)KS_CL, IF_EB("\033[H\033[2J", ESC_STR "[H" ESC_STR_nc "[2J")},
{(int)KS_ME, IF_EB("\033[0m", ESC_STR "[0m")},
{(int)KS_MR, IF_EB("\033[7m", ESC_STR "[7m")},
{(int)KS_MS, "y"},
{(int)KS_UT, "y"}, /* guessed */
{(int)KS_LE, "\b"},
# ifdef TERMINFO
{(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", ESC_STR "[%i%p1%d;%p2%dH")},
# else
{(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")},
# endif
# ifdef TERMINFO
{(int)KS_CRI, IF_EB("\033[%p1%dC", ESC_STR "[%p1%dC")},
# else
{(int)KS_CRI, IF_EB("\033[%dC", ESC_STR "[%dC")},
# endif
# endif
# if defined(MSDOS) || defined(ALL_BUILTIN_TCAPS) || defined(__EMX__)
/*
* These codes are valid when nansi.sys or equivalent has been installed.
* Function keys on a PC are preceded with a NUL. These are converted into
* K_NUL '\316' in mch_inchar(), because we cannot handle NULs in key codes.
* CTRL-arrow is used instead of SHIFT-arrow.
*/
#ifdef __EMX__
{(int)KS_NAME, "os2ansi"},
#else
{(int)KS_NAME, "pcansi"},
{(int)KS_DL, "\033[M"},
{(int)KS_AL, "\033[L"},
#endif
{(int)KS_CE, "\033[K"},
{(int)KS_CL, "\033[2J"},
{(int)KS_ME, "\033[0m"},
{(int)KS_MR, "\033[5m"}, /* reverse: black on lightgrey */
{(int)KS_MD, "\033[1m"}, /* bold: white text */
{(int)KS_SE, "\033[0m"}, /* standout end */
{(int)KS_SO, "\033[31m"}, /* standout: white on blue */
{(int)KS_CZH, "\033[34;43m"}, /* italic mode: blue text on yellow */
{(int)KS_CZR, "\033[0m"}, /* italic mode end */
{(int)KS_US, "\033[36;41m"}, /* underscore mode: cyan text on red */
{(int)KS_UE, "\033[0m"}, /* underscore mode end */
{(int)KS_CCO, "8"}, /* allow 8 colors */
# ifdef TERMINFO
{(int)KS_CAB, "\033[4%p1%dm"},/* set background color */
{(int)KS_CAF, "\033[3%p1%dm"},/* set foreground color */
# else
{(int)KS_CAB, "\033[4%dm"}, /* set background color */
{(int)KS_CAF, "\033[3%dm"}, /* set foreground color */
# endif
{(int)KS_OP, "\033[0m"}, /* reset colors */
{(int)KS_MS, "y"},
{(int)KS_UT, "y"}, /* guessed */
{(int)KS_LE, "\b"},
# ifdef TERMINFO
{(int)KS_CM, "\033[%i%p1%d;%p2%dH"},
# else
{(int)KS_CM, "\033[%i%d;%dH"},
# endif
# ifdef TERMINFO
{(int)KS_CRI, "\033[%p1%dC"},
# else
{(int)KS_CRI, "\033[%dC"},
# endif
{K_UP, "\316H"},
{K_DOWN, "\316P"},
{K_LEFT, "\316K"},
{K_RIGHT, "\316M"},
{K_S_LEFT, "\316s"},
{K_S_RIGHT, "\316t"},
{K_F1, "\316;"},
{K_F2, "\316<"},
{K_F3, "\316="},
{K_F4, "\316>"},
{K_F5, "\316?"},
{K_F6, "\316@"},
{K_F7, "\316A"},
{K_F8, "\316B"},
{K_F9, "\316C"},
{K_F10, "\316D"},
{K_F11, "\316\205"}, /* guessed */
{K_F12, "\316\206"}, /* guessed */
{K_S_F1, "\316T"},
{K_S_F2, "\316U"},
{K_S_F3, "\316V"},
{K_S_F4, "\316W"},
{K_S_F5, "\316X"},
{K_S_F6, "\316Y"},
{K_S_F7, "\316Z"},
{K_S_F8, "\316["},
{K_S_F9, "\316\\"},
{K_S_F10, "\316]"},
{K_S_F11, "\316\207"}, /* guessed */
{K_S_F12, "\316\210"}, /* guessed */
{K_INS, "\316R"},
{K_DEL, "\316S"},
{K_HOME, "\316G"},
{K_END, "\316O"},
{K_PAGEDOWN, "\316Q"},
{K_PAGEUP, "\316I"},
# endif
# if defined(MSDOS)
/*
* These codes are valid for the pc video. The entries that start with ESC |
* are translated into conio calls in os_msdos.c. Default for MSDOS.
*/
{(int)KS_NAME, "pcterm"},
{(int)KS_CE, "\033|K"},
{(int)KS_AL, "\033|L"},
{(int)KS_DL, "\033|M"},
# ifdef TERMINFO
{(int)KS_CS, "\033|%i%p1%d;%p2%dr"},
# ifdef FEAT_VERTSPLIT
{(int)KS_CSV, "\033|%i%p1%d;%p2%dV"},
# endif
# else
{(int)KS_CS, "\033|%i%d;%dr"},
# ifdef FEAT_VERTSPLIT
{(int)KS_CSV, "\033|%i%d;%dV"},
# endif
# endif
{(int)KS_CL, "\033|J"},
{(int)KS_ME, "\033|0m"}, /* normal */
{(int)KS_MR, "\033|112m"}, /* reverse: black on lightgrey */
{(int)KS_MD, "\033|15m"}, /* bold: white text */
{(int)KS_SE, "\033|0m"}, /* standout end */
{(int)KS_SO, "\033|31m"}, /* standout: white on blue */
{(int)KS_CZH, "\033|225m"}, /* italic mode: blue text on yellow */
{(int)KS_CZR, "\033|0m"}, /* italic mode end */
{(int)KS_US, "\033|67m"}, /* underscore mode: cyan text on red */
{(int)KS_UE, "\033|0m"}, /* underscore mode end */
{(int)KS_CCO, "16"}, /* allow 16 colors */
# ifdef TERMINFO
{(int)KS_CAB, "\033|%p1%db"}, /* set background color */
{(int)KS_CAF, "\033|%p1%df"}, /* set foreground color */
# else
{(int)KS_CAB, "\033|%db"}, /* set background color */
{(int)KS_CAF, "\033|%df"}, /* set foreground color */
# endif
{(int)KS_MS, "y"},
{(int)KS_UT, "y"},
{(int)KS_LE, "\b"},
# ifdef TERMINFO
{(int)KS_CM, "\033|%i%p1%d;%p2%dH"},
# else
{(int)KS_CM, "\033|%i%d;%dH"},
# endif
#ifdef DJGPP
{(int)KS_VB, "\033|B"}, /* visual bell */
#endif
{K_UP, "\316H"},
{K_DOWN, "\316P"},
{K_LEFT, "\316K"},
{K_RIGHT, "\316M"},
{K_S_LEFT, "\316s"},
{K_S_RIGHT, "\316t"},
{K_S_TAB, "\316\017"},
{K_F1, "\316;"},
{K_F2, "\316<"},
{K_F3, "\316="},
{K_F4, "\316>"},
{K_F5, "\316?"},
{K_F6, "\316@"},
{K_F7, "\316A"},
{K_F8, "\316B"},
{K_F9, "\316C"},
{K_F10, "\316D"},
{K_F11, "\316\205"},
{K_F12, "\316\206"},
{K_S_F1, "\316T"},
{K_S_F2, "\316U"},
{K_S_F3, "\316V"},
{K_S_F4, "\316W"},
{K_S_F5, "\316X"},
{K_S_F6, "\316Y"},
{K_S_F7, "\316Z"},
{K_S_F8, "\316["},
{K_S_F9, "\316\\"},
{K_S_F10, "\316]"},
{K_S_F11, "\316\207"},
{K_S_F12, "\316\210"},
{K_INS, "\316R"},
{K_DEL, "\316S"},
{K_HOME, "\316G"},
{K_END, "\316O"},
{K_PAGEDOWN, "\316Q"},
{K_PAGEUP, "\316I"},
{K_KPLUS, "\316N"},
{K_KMINUS, "\316J"},
{K_KMULTIPLY, "\3167"},
{K_K0, "\316\332"},
{K_K1, "\316\336"},
{K_K2, "\316\342"},
{K_K3, "\316\346"},
{K_K4, "\316\352"},
{K_K5, "\316\356"},
{K_K6, "\316\362"},
{K_K7, "\316\366"},
{K_K8, "\316\372"},
{K_K9, "\316\376"},
# endif
# if defined(WIN3264) || defined(ALL_BUILTIN_TCAPS) || defined(__EMX__)
/*
* These codes are valid for the Win32 Console . The entries that start with
* ESC | are translated into console calls in os_win32.c. The function keys
* are also translated in os_win32.c.
*/
{(int)KS_NAME, "win32"},
{(int)KS_CE, "\033|K"}, /* clear to end of line */
{(int)KS_AL, "\033|L"}, /* add new blank line */
# ifdef TERMINFO
{(int)KS_CAL, "\033|%p1%dL"}, /* add number of new blank lines */
# else
{(int)KS_CAL, "\033|%dL"}, /* add number of new blank lines */
# endif
{(int)KS_DL, "\033|M"}, /* delete line */
# ifdef TERMINFO
{(int)KS_CDL, "\033|%p1%dM"}, /* delete number of lines */
# else
{(int)KS_CDL, "\033|%dM"}, /* delete number of lines */
# endif
{(int)KS_CL, "\033|J"}, /* clear screen */
{(int)KS_CD, "\033|j"}, /* clear to end of display */
{(int)KS_VI, "\033|v"}, /* cursor invisible */
{(int)KS_VE, "\033|V"}, /* cursor visible */
{(int)KS_ME, "\033|0m"}, /* normal */
{(int)KS_MR, "\033|112m"}, /* reverse: black on lightgray */
{(int)KS_MD, "\033|15m"}, /* bold: white on black */
#if 1
{(int)KS_SO, "\033|31m"}, /* standout: white on blue */
{(int)KS_SE, "\033|0m"}, /* standout end */
#else
{(int)KS_SO, "\033|F"}, /* standout: high intensity */
{(int)KS_SE, "\033|f"}, /* standout end */
#endif
{(int)KS_CZH, "\033|225m"}, /* italic: blue text on yellow */
{(int)KS_CZR, "\033|0m"}, /* italic end */
{(int)KS_US, "\033|67m"}, /* underscore: cyan text on red */
{(int)KS_UE, "\033|0m"}, /* underscore end */
{(int)KS_CCO, "16"}, /* allow 16 colors */
# ifdef TERMINFO
{(int)KS_CAB, "\033|%p1%db"}, /* set background color */
{(int)KS_CAF, "\033|%p1%df"}, /* set foreground color */
# else
{(int)KS_CAB, "\033|%db"}, /* set background color */
{(int)KS_CAF, "\033|%df"}, /* set foreground color */
# endif
{(int)KS_MS, "y"}, /* save to move cur in reverse mode */
{(int)KS_UT, "y"},
{(int)KS_XN, "y"},
{(int)KS_LE, "\b"},
# ifdef TERMINFO
{(int)KS_CM, "\033|%i%p1%d;%p2%dH"},/* cursor motion */
# else
{(int)KS_CM, "\033|%i%d;%dH"},/* cursor motion */
# endif
{(int)KS_VB, "\033|B"}, /* visual bell */
{(int)KS_TI, "\033|S"}, /* put terminal in termcap mode */
{(int)KS_TE, "\033|E"}, /* out of termcap mode */
# ifdef TERMINFO
{(int)KS_CS, "\033|%i%p1%d;%p2%dr"},/* scroll region */
# else
{(int)KS_CS, "\033|%i%d;%dr"},/* scroll region */
# endif
{K_UP, "\316H"},
{K_DOWN, "\316P"},
{K_LEFT, "\316K"},
{K_RIGHT, "\316M"},
{K_S_UP, "\316\304"},
{K_S_DOWN, "\316\317"},
{K_S_LEFT, "\316\311"},
{K_C_LEFT, "\316s"},
{K_S_RIGHT, "\316\313"},
{K_C_RIGHT, "\316t"},
{K_S_TAB, "\316\017"},
{K_F1, "\316;"},
{K_F2, "\316<"},
{K_F3, "\316="},
{K_F4, "\316>"},
{K_F5, "\316?"},
{K_F6, "\316@"},
{K_F7, "\316A"},
{K_F8, "\316B"},
{K_F9, "\316C"},
{K_F10, "\316D"},
{K_F11, "\316\205"},
{K_F12, "\316\206"},
{K_S_F1, "\316T"},
{K_S_F2, "\316U"},
{K_S_F3, "\316V"},
{K_S_F4, "\316W"},
{K_S_F5, "\316X"},
{K_S_F6, "\316Y"},
{K_S_F7, "\316Z"},
{K_S_F8, "\316["},
{K_S_F9, "\316\\"},
{K_S_F10, "\316]"},
{K_S_F11, "\316\207"},
{K_S_F12, "\316\210"},
{K_INS, "\316R"},
{K_DEL, "\316S"},
{K_HOME, "\316G"},
{K_S_HOME, "\316\302"},
{K_C_HOME, "\316w"},
{K_END, "\316O"},
{K_S_END, "\316\315"},
{K_C_END, "\316u"},
{K_PAGEDOWN, "\316Q"},
{K_PAGEUP, "\316I"},
{K_KPLUS, "\316N"},
{K_KMINUS, "\316J"},
{K_KMULTIPLY, "\316\067"},
{K_K0, "\316\332"},
{K_K1, "\316\336"},
{K_K2, "\316\342"},
{K_K3, "\316\346"},
{K_K4, "\316\352"},
{K_K5, "\316\356"},
{K_K6, "\316\362"},
{K_K7, "\316\366"},
{K_K8, "\316\372"},
{K_K9, "\316\376"},
# endif
# if defined(VMS) || defined(ALL_BUILTIN_TCAPS)
/*
* VT320 is working as an ANSI terminal compatible DEC terminal.
* (it covers VT1x0, VT2x0 and VT3x0 up to VT320 on VMS as well)
* Note: K_F1...K_F5 are for internal use, should not be defined.
* TODO:- rewrite ESC[ codes to CSI
* - keyboard languages (CSI ? 26 n)
*/
{(int)KS_NAME, "vt320"},
{(int)KS_CE, IF_EB("\033[K", ESC_STR "[K")},
{(int)KS_AL, IF_EB("\033[L", ESC_STR "[L")},
# ifdef TERMINFO
{(int)KS_CAL, IF_EB("\033[%p1%dL", ESC_STR "[%p1%dL")},
# else
{(int)KS_CAL, IF_EB("\033[%dL", ESC_STR "[%dL")},
# endif
{(int)KS_DL, IF_EB("\033[M", ESC_STR "[M")},
# ifdef TERMINFO
{(int)KS_CDL, IF_EB("\033[%p1%dM", ESC_STR "[%p1%dM")},
# else
{(int)KS_CDL, IF_EB("\033[%dM", ESC_STR "[%dM")},
# endif
{(int)KS_CL, IF_EB("\033[H\033[2J", ESC_STR "[H" ESC_STR_nc "[2J")},
{(int)KS_CD, IF_EB("\033[J", ESC_STR "[J")},
{(int)KS_CCO, "8"}, /* allow 8 colors */
{(int)KS_ME, IF_EB("\033[0m", ESC_STR "[0m")},
{(int)KS_MR, IF_EB("\033[7m", ESC_STR "[7m")},
{(int)KS_MD, IF_EB("\033[1m", ESC_STR "[1m")}, /* bold mode */
{(int)KS_SE, IF_EB("\033[22m", ESC_STR "[22m")},/* normal mode */
{(int)KS_UE, IF_EB("\033[24m", ESC_STR "[24m")},/* exit underscore mode */
{(int)KS_US, IF_EB("\033[4m", ESC_STR "[4m")}, /* underscore mode */
{(int)KS_CZH, IF_EB("\033[34;43m", ESC_STR "[34;43m")}, /* italic mode: blue text on yellow */
{(int)KS_CZR, IF_EB("\033[0m", ESC_STR "[0m")}, /* italic mode end */
{(int)KS_CAB, IF_EB("\033[4%dm", ESC_STR "[4%dm")}, /* set background color (ANSI) */
{(int)KS_CAF, IF_EB("\033[3%dm", ESC_STR "[3%dm")}, /* set foreground color (ANSI) */
{(int)KS_CSB, IF_EB("\033[102;%dm", ESC_STR "[102;%dm")}, /* set screen background color */
{(int)KS_CSF, IF_EB("\033[101;%dm", ESC_STR "[101;%dm")}, /* set screen foreground color */
{(int)KS_MS, "y"},
{(int)KS_UT, "y"},
{(int)KS_XN, "y"},
{(int)KS_LE, "\b"},
# ifdef TERMINFO
{(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH",
ESC_STR "[%i%p1%d;%p2%dH")},
# else
{(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")},
# endif
# ifdef TERMINFO
{(int)KS_CRI, IF_EB("\033[%p1%dC", ESC_STR "[%p1%dC")},
# else
{(int)KS_CRI, IF_EB("\033[%dC", ESC_STR "[%dC")},
# endif
{K_UP, IF_EB("\033[A", ESC_STR "[A")},
{K_DOWN, IF_EB("\033[B", ESC_STR "[B")},
{K_RIGHT, IF_EB("\033[C", ESC_STR "[C")},
{K_LEFT, IF_EB("\033[D", ESC_STR "[D")},
{K_F1, IF_EB("\033[11~", ESC_STR "[11~")},
{K_F2, IF_EB("\033[12~", ESC_STR "[12~")},
{K_F3, IF_EB("\033[13~", ESC_STR "[13~")},
{K_F4, IF_EB("\033[14~", ESC_STR "[14~")},
{K_F5, IF_EB("\033[15~", ESC_STR "[15~")},
{K_F6, IF_EB("\033[17~", ESC_STR "[17~")},
{K_F7, IF_EB("\033[18~", ESC_STR "[18~")},
{K_F8, IF_EB("\033[19~", ESC_STR "[19~")},
{K_F9, IF_EB("\033[20~", ESC_STR "[20~")},
{K_F10, IF_EB("\033[21~", ESC_STR "[21~")},
{K_F11, IF_EB("\033[23~", ESC_STR "[23~")},
{K_F12, IF_EB("\033[24~", ESC_STR "[24~")},
{K_F13, IF_EB("\033[25~", ESC_STR "[25~")},
{K_F14, IF_EB("\033[26~", ESC_STR "[26~")},
{K_F15, IF_EB("\033[28~", ESC_STR "[28~")}, /* Help */
{K_F16, IF_EB("\033[29~", ESC_STR "[29~")}, /* Select */
{K_F17, IF_EB("\033[31~", ESC_STR "[31~")},
{K_F18, IF_EB("\033[32~", ESC_STR "[32~")},
{K_F19, IF_EB("\033[33~", ESC_STR "[33~")},
{K_F20, IF_EB("\033[34~", ESC_STR "[34~")},
{K_INS, IF_EB("\033[2~", ESC_STR "[2~")},
{K_DEL, IF_EB("\033[3~", ESC_STR "[3~")},
{K_HOME, IF_EB("\033[1~", ESC_STR "[1~")},
{K_END, IF_EB("\033[4~", ESC_STR "[4~")},
{K_PAGEUP, IF_EB("\033[5~", ESC_STR "[5~")},
{K_PAGEDOWN, IF_EB("\033[6~", ESC_STR "[6~")},
{K_KPLUS, IF_EB("\033Ok", ESC_STR "Ok")}, /* keypad plus */
{K_KMINUS, IF_EB("\033Om", ESC_STR "Om")}, /* keypad minus */
{K_KDIVIDE, IF_EB("\033Oo", ESC_STR "Oo")}, /* keypad / */
{K_KMULTIPLY, IF_EB("\033Oj", ESC_STR "Oj")}, /* keypad * */
{K_KENTER, IF_EB("\033OM", ESC_STR "OM")}, /* keypad Enter */
{K_BS, "\x7f"}, /* for some reason 0177 doesn't work */
# endif
# if defined(ALL_BUILTIN_TCAPS) || defined(__MINT__)
/*
* Ordinary vt52
*/
{(int)KS_NAME, "vt52"},
{(int)KS_CE, IF_EB("\033K", ESC_STR "K")},
{(int)KS_CD, IF_EB("\033J", ESC_STR "J")},
{(int)KS_CM, IF_EB("\033Y%+ %+ ", ESC_STR "Y%+ %+ ")},
{(int)KS_LE, "\b"},
# ifdef __MINT__
{(int)KS_AL, IF_EB("\033L", ESC_STR "L")},
{(int)KS_DL, IF_EB("\033M", ESC_STR "M")},
{(int)KS_CL, IF_EB("\033E", ESC_STR "E")},
{(int)KS_SR, IF_EB("\033I", ESC_STR "I")},
{(int)KS_VE, IF_EB("\033e", ESC_STR "e")},
{(int)KS_VI, IF_EB("\033f", ESC_STR "f")},
{(int)KS_SO, IF_EB("\033p", ESC_STR "p")},
{(int)KS_SE, IF_EB("\033q", ESC_STR "q")},
{K_UP, IF_EB("\033A", ESC_STR "A")},
{K_DOWN, IF_EB("\033B", ESC_STR "B")},
{K_LEFT, IF_EB("\033D", ESC_STR "D")},
{K_RIGHT, IF_EB("\033C", ESC_STR "C")},
{K_S_UP, IF_EB("\033a", ESC_STR "a")},
{K_S_DOWN, IF_EB("\033b", ESC_STR "b")},
{K_S_LEFT, IF_EB("\033d", ESC_STR "d")},
{K_S_RIGHT, IF_EB("\033c", ESC_STR "c")},
{K_F1, IF_EB("\033P", ESC_STR "P")},
{K_F2, IF_EB("\033Q", ESC_STR "Q")},
{K_F3, IF_EB("\033R", ESC_STR "R")},
{K_F4, IF_EB("\033S", ESC_STR "S")},
{K_F5, IF_EB("\033T", ESC_STR "T")},
{K_F6, IF_EB("\033U", ESC_STR "U")},
{K_F7, IF_EB("\033V", ESC_STR "V")},
{K_F8, IF_EB("\033W", ESC_STR "W")},
{K_F9, IF_EB("\033X", ESC_STR "X")},
{K_F10, IF_EB("\033Y", ESC_STR "Y")},
{K_S_F1, IF_EB("\033p", ESC_STR "p")},
{K_S_F2, IF_EB("\033q", ESC_STR "q")},
{K_S_F3, IF_EB("\033r", ESC_STR "r")},
{K_S_F4, IF_EB("\033s", ESC_STR "s")},
{K_S_F5, IF_EB("\033t", ESC_STR "t")},
{K_S_F6, IF_EB("\033u", ESC_STR "u")},
{K_S_F7, IF_EB("\033v", ESC_STR "v")},
{K_S_F8, IF_EB("\033w", ESC_STR "w")},
{K_S_F9, IF_EB("\033x", ESC_STR "x")},
{K_S_F10, IF_EB("\033y", ESC_STR "y")},
{K_INS, IF_EB("\033I", ESC_STR "I")},
{K_HOME, IF_EB("\033E", ESC_STR "E")},
{K_PAGEDOWN, IF_EB("\033b", ESC_STR "b")},
{K_PAGEUP, IF_EB("\033a", ESC_STR "a")},
# else
{(int)KS_AL, IF_EB("\033T", ESC_STR "T")},
{(int)KS_DL, IF_EB("\033U", ESC_STR "U")},
{(int)KS_CL, IF_EB("\033H\033J", ESC_STR "H" ESC_STR_nc "J")},
{(int)KS_ME, IF_EB("\033SO", ESC_STR "SO")},
{(int)KS_MR, IF_EB("\033S2", ESC_STR "S2")},
{(int)KS_MS, "y"},
# endif
# endif
# if defined(UNIX) || defined(ALL_BUILTIN_TCAPS) || defined(SOME_BUILTIN_TCAPS) || defined(__EMX__)
{(int)KS_NAME, "xterm"},
{(int)KS_CE, IF_EB("\033[K", ESC_STR "[K")},
{(int)KS_AL, IF_EB("\033[L", ESC_STR "[L")},
# ifdef TERMINFO
{(int)KS_CAL, IF_EB("\033[%p1%dL", ESC_STR "[%p1%dL")},
# else
{(int)KS_CAL, IF_EB("\033[%dL", ESC_STR "[%dL")},
# endif
{(int)KS_DL, IF_EB("\033[M", ESC_STR "[M")},
# ifdef TERMINFO
{(int)KS_CDL, IF_EB("\033[%p1%dM", ESC_STR "[%p1%dM")},
# else
{(int)KS_CDL, IF_EB("\033[%dM", ESC_STR "[%dM")},
# endif
# ifdef TERMINFO
{(int)KS_CS, IF_EB("\033[%i%p1%d;%p2%dr",
ESC_STR "[%i%p1%d;%p2%dr")},
# else
{(int)KS_CS, IF_EB("\033[%i%d;%dr", ESC_STR "[%i%d;%dr")},
# endif
{(int)KS_CL, IF_EB("\033[H\033[2J", ESC_STR "[H" ESC_STR_nc "[2J")},
{(int)KS_CD, IF_EB("\033[J", ESC_STR "[J")},
{(int)KS_ME, IF_EB("\033[m", ESC_STR "[m")},
{(int)KS_MR, IF_EB("\033[7m", ESC_STR "[7m")},
{(int)KS_MD, IF_EB("\033[1m", ESC_STR "[1m")},
{(int)KS_UE, IF_EB("\033[m", ESC_STR "[m")},
{(int)KS_US, IF_EB("\033[4m", ESC_STR "[4m")},
{(int)KS_MS, "y"},
{(int)KS_UT, "y"},
{(int)KS_LE, "\b"},
# ifdef TERMINFO
{(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH",
ESC_STR "[%i%p1%d;%p2%dH")},
# else
{(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")},
# endif
{(int)KS_SR, IF_EB("\033M", ESC_STR "M")},
# ifdef TERMINFO
{(int)KS_CRI, IF_EB("\033[%p1%dC", ESC_STR "[%p1%dC")},
# else
{(int)KS_CRI, IF_EB("\033[%dC", ESC_STR "[%dC")},
# endif
{(int)KS_KS, IF_EB("\033[?1h\033=", ESC_STR "[?1h" ESC_STR_nc "=")},
{(int)KS_KE, IF_EB("\033[?1l\033>", ESC_STR "[?1l" ESC_STR_nc ">")},
# ifdef FEAT_XTERM_SAVE
{(int)KS_TI, IF_EB("\0337\033[?47h", ESC_STR "7" ESC_STR_nc "[?47h")},
{(int)KS_TE, IF_EB("\033[2J\033[?47l\0338",
ESC_STR "[2J" ESC_STR_nc "[?47l" ESC_STR_nc "8")},
# endif
{(int)KS_CIS, IF_EB("\033]1;", ESC_STR "]1;")},
{(int)KS_CIE, "\007"},
{(int)KS_TS, IF_EB("\033]2;", ESC_STR "]2;")},
{(int)KS_FS, "\007"},
# ifdef TERMINFO
{(int)KS_CWS, IF_EB("\033[8;%p1%d;%p2%dt",
ESC_STR "[8;%p1%d;%p2%dt")},
{(int)KS_CWP, IF_EB("\033[3;%p1%d;%p2%dt",
ESC_STR "[3;%p1%d;%p2%dt")},
# else
{(int)KS_CWS, IF_EB("\033[8;%d;%dt", ESC_STR "[8;%d;%dt")},
{(int)KS_CWP, IF_EB("\033[3;%d;%dt", ESC_STR "[3;%d;%dt")},
# endif
{(int)KS_CRV, IF_EB("\033[>c", ESC_STR "[>c")},
{(int)KS_U7, IF_EB("\033[6n", ESC_STR "[6n")},
{K_UP, IF_EB("\033O*A", ESC_STR "O*A")},
{K_DOWN, IF_EB("\033O*B", ESC_STR "O*B")},
{K_RIGHT, IF_EB("\033O*C", ESC_STR "O*C")},
{K_LEFT, IF_EB("\033O*D", ESC_STR "O*D")},
/* An extra set of cursor keys for vt100 mode */
{K_XUP, IF_EB("\033[1;*A", ESC_STR "[1;*A")},
{K_XDOWN, IF_EB("\033[1;*B", ESC_STR "[1;*B")},
{K_XRIGHT, IF_EB("\033[1;*C", ESC_STR "[1;*C")},
{K_XLEFT, IF_EB("\033[1;*D", ESC_STR "[1;*D")},
/* An extra set of function keys for vt100 mode */
{K_XF1, IF_EB("\033O*P", ESC_STR "O*P")},
{K_XF2, IF_EB("\033O*Q", ESC_STR "O*Q")},
{K_XF3, IF_EB("\033O*R", ESC_STR "O*R")},
{K_XF4, IF_EB("\033O*S", ESC_STR "O*S")},
{K_F1, IF_EB("\033[11;*~", ESC_STR "[11;*~")},
{K_F2, IF_EB("\033[12;*~", ESC_STR "[12;*~")},
{K_F3, IF_EB("\033[13;*~", ESC_STR "[13;*~")},
{K_F4, IF_EB("\033[14;*~", ESC_STR "[14;*~")},
{K_F5, IF_EB("\033[15;*~", ESC_STR "[15;*~")},
{K_F6, IF_EB("\033[17;*~", ESC_STR "[17;*~")},
{K_F7, IF_EB("\033[18;*~", ESC_STR "[18;*~")},
{K_F8, IF_EB("\033[19;*~", ESC_STR "[19;*~")},
{K_F9, IF_EB("\033[20;*~", ESC_STR "[20;*~")},
{K_F10, IF_EB("\033[21;*~", ESC_STR "[21;*~")},
{K_F11, IF_EB("\033[23;*~", ESC_STR "[23;*~")},
{K_F12, IF_EB("\033[24;*~", ESC_STR "[24;*~")},
{K_S_TAB, IF_EB("\033[Z", ESC_STR "[Z")},
{K_HELP, IF_EB("\033[28;*~", ESC_STR "[28;*~")},
{K_UNDO, IF_EB("\033[26;*~", ESC_STR "[26;*~")},
{K_INS, IF_EB("\033[2;*~", ESC_STR "[2;*~")},
{K_HOME, IF_EB("\033[1;*H", ESC_STR "[1;*H")},
/* {K_S_HOME, IF_EB("\033O2H", ESC_STR "O2H")}, */
/* {K_C_HOME, IF_EB("\033O5H", ESC_STR "O5H")}, */
{K_KHOME, IF_EB("\033[1;*~", ESC_STR "[1;*~")},
{K_XHOME, IF_EB("\033O*H", ESC_STR "O*H")}, /* other Home */
{K_ZHOME, IF_EB("\033[7;*~", ESC_STR "[7;*~")}, /* other Home */
{K_END, IF_EB("\033[1;*F", ESC_STR "[1;*F")},
/* {K_S_END, IF_EB("\033O2F", ESC_STR "O2F")}, */
/* {K_C_END, IF_EB("\033O5F", ESC_STR "O5F")}, */
{K_KEND, IF_EB("\033[4;*~", ESC_STR "[4;*~")},
{K_XEND, IF_EB("\033O*F", ESC_STR "O*F")}, /* other End */
{K_ZEND, IF_EB("\033[8;*~", ESC_STR "[8;*~")},
{K_PAGEUP, IF_EB("\033[5;*~", ESC_STR "[5;*~")},
{K_PAGEDOWN, IF_EB("\033[6;*~", ESC_STR "[6;*~")},
{K_KPLUS, IF_EB("\033O*k", ESC_STR "O*k")}, /* keypad plus */
{K_KMINUS, IF_EB("\033O*m", ESC_STR "O*m")}, /* keypad minus */
{K_KDIVIDE, IF_EB("\033O*o", ESC_STR "O*o")}, /* keypad / */