Mercurial > vim
annotate src/term.c @ 28533:b2f93ab72fdc
Added tag v8.2.4790 for changeset 11387538e7c481cb723d74feb6898dcb48bed0d0
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 19 Apr 2022 16:45:03 +0200 |
parents | 8751e815864e |
children | a54564337e89 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9939
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 /* | |
10 * | |
11 * term.c: functions for controlling the terminal | |
12 * | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
13 * primitive termcap support for Amiga and Win32 included |
7 | 14 * |
15 * NOTE: padding and variable substitution is not performed, | |
16 * when compiling without HAVE_TGETENT, we use tputs() and tgoto() dummies. | |
17 */ | |
18 | |
19 /* | |
20 * Some systems have a prototype for tgetstr() with (char *) instead of | |
21 * (char **). This define removes that prototype. We include our own prototype | |
22 * below. | |
23 */ | |
24 #define tgetstr tgetstr_defined_wrong | |
16378
3d6b282e2d6e
patch 8.1.1194: typos and small problems in source files
Bram Moolenaar <Bram@vim.org>
parents:
16245
diff
changeset
|
25 |
7 | 26 #include "vim.h" |
27 | |
28 #ifdef HAVE_TGETENT | |
29 # ifdef HAVE_TERMIOS_H | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
30 # include <termios.h> // seems to be required for some Linux |
7 | 31 # endif |
32 # ifdef HAVE_TERMCAP_H | |
33 # include <termcap.h> | |
34 # endif | |
35 | |
36 /* | |
37 * A few linux systems define outfuntype in termcap.h to be used as the third | |
38 * argument for tputs(). | |
39 */ | |
27684
1761cc771623
patch 8.2.4368: Amiga: a few compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
40 # if defined(VMS) || defined(AMIGA) |
23408
bdda90ed5f6c
patch 8.2.2247: VMS: various smaller problems
Bram Moolenaar <Bram@vim.org>
parents:
23406
diff
changeset
|
41 # define TPUTSFUNCAST (void (*)(unsigned int)) |
7 | 42 # else |
43 # ifdef HAVE_OUTFUNTYPE | |
44 # define TPUTSFUNCAST (outfuntype) | |
45 # else | |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
46 # define TPUTSFUNCAST (int (*)(int)) |
7 | 47 # endif |
48 # endif | |
49 #endif | |
50 | |
51 #undef tgetstr | |
52 | |
53 /* | |
54 * Here are the builtin termcap entries. They are not stored as complete | |
2823 | 55 * structures with all entries, as such a structure is too big. |
7 | 56 * |
57 * The entries are compact, therefore they normally are included even when | |
58 * HAVE_TGETENT is defined. When HAVE_TGETENT is defined, the builtin entries | |
59 * can be accessed with "builtin_amiga", "builtin_ansi", "builtin_debug", etc. | |
60 * | |
61 * Each termcap is a list of builtin_term structures. It always starts with | |
62 * KS_NAME, which separates the entries. See parse_builtin_tcap() for all | |
63 * details. | |
64 * bt_entry is either a KS_xxx code (>= 0), or a K_xxx code. | |
65 * | |
66 * Entries marked with "guessed" may be wrong. | |
67 */ | |
68 struct builtin_term | |
69 { | |
70 int bt_entry; | |
71 char *bt_string; | |
72 }; | |
73 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
74 // start of keys that are not directly used by Vim but can be mapped |
7 | 75 #define BT_EXTRA_KEYS 0x101 |
76 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
77 static void parse_builtin_tcap(char_u *s); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
78 static void gather_termleader(void); |
7 | 79 #ifdef FEAT_TERMRESPONSE |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
80 static void req_codes_from_term(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
81 static void req_more_codes_from_term(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
82 static void got_code_from_term(char_u *code, int len); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
83 static void check_for_codes_from_term(void); |
7 | 84 #endif |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
85 static void del_termcode_idx(int idx); |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
86 static int find_term_bykeys(char_u *src); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
87 static int term_is_builtin(char_u *name); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
88 static int term_7to8bit(char_u *p); |
7 | 89 |
90 #ifdef HAVE_TGETENT | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
91 static char *tgetent_error(char_u *, char_u *); |
7 | 92 |
93 /* | |
94 * Here is our own prototype for tgetstr(), any prototypes from the include | |
95 * files have been disabled by the define at the start of this file. | |
96 */ | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
97 char *tgetstr(char *, char **); |
7 | 98 |
99 # ifdef FEAT_TERMRESPONSE | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
100 // Change this to "if 1" to debug what happens with termresponse. |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
101 # if 0 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
102 # define DEBUG_TERMRESPONSE |
25475
038eb6d9003a
patch 8.2.3274: macro for printf format check can be simplified
Bram Moolenaar <Bram@vim.org>
parents:
25429
diff
changeset
|
103 static void log_tr(const char *fmt, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2); |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
104 # define LOG_TR(msg) log_tr msg |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
105 # else |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
106 # define LOG_TR(msg) do { /**/ } while (0) |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
107 # endif |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
108 |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
109 typedef enum { |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
110 STATUS_GET, // send request when switching to RAW mode |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
111 STATUS_SENT, // did send request, checking for response |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
112 STATUS_GOT, // received response |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
113 STATUS_FAIL // timed out |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
114 } request_progress_T; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
115 |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
116 typedef struct { |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
117 request_progress_T tr_progress; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
118 time_t tr_start; // when request was sent, -1 for never |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
119 } termrequest_T; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
120 |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
121 # define TERMREQUEST_INIT {STATUS_GET, -1} |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
122 |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
123 // Request Terminal Version status: |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
124 static termrequest_T crv_status = TERMREQUEST_INIT; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
125 |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
126 // Request Cursor position report: |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
127 static termrequest_T u7_status = TERMREQUEST_INIT; |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
128 |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
129 // Request xterm compatibility check: |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
130 static termrequest_T xcc_status = TERMREQUEST_INIT; |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
131 |
12634
94566ecb55f0
patch 8.0.1195: can't build on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12632
diff
changeset
|
132 # ifdef FEAT_TERMINAL |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
133 // Request foreground color report: |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
134 static termrequest_T rfg_status = TERMREQUEST_INIT; |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
135 static int fg_r = 0; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
136 static int fg_g = 0; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
137 static int fg_b = 0; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
138 static int bg_r = 255; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
139 static int bg_g = 255; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
140 static int bg_b = 255; |
12634
94566ecb55f0
patch 8.0.1195: can't build on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12632
diff
changeset
|
141 # endif |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
142 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
143 // Request background color report: |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
144 static termrequest_T rbg_status = TERMREQUEST_INIT; |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
145 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
146 // Request cursor blinking mode report: |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
147 static termrequest_T rbm_status = TERMREQUEST_INIT; |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
148 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
149 // Request cursor style report: |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
150 static termrequest_T rcs_status = TERMREQUEST_INIT; |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
151 |
19195
2ef19eed524a
patch 8.2.0156: various typos in source files and tests
Bram Moolenaar <Bram@vim.org>
parents:
19178
diff
changeset
|
152 // Request window's position report: |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
153 static termrequest_T winpos_status = TERMREQUEST_INIT; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
154 |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
155 static termrequest_T *all_termrequests[] = { |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
156 &crv_status, |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
157 &u7_status, |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
158 &xcc_status, |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
159 # ifdef FEAT_TERMINAL |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
160 &rfg_status, |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
161 # endif |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
162 &rbg_status, |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
163 &rbm_status, |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
164 &rcs_status, |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
165 &winpos_status, |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
166 NULL |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
167 }; |
28505
8751e815864e
patch 8.2.4777: screendump tests fail because of a redraw
Bram Moolenaar <Bram@vim.org>
parents:
28501
diff
changeset
|
168 |
8751e815864e
patch 8.2.4777: screendump tests fail because of a redraw
Bram Moolenaar <Bram@vim.org>
parents:
28501
diff
changeset
|
169 // The t_8u code may default to a value but get reset when the term response is |
8751e815864e
patch 8.2.4777: screendump tests fail because of a redraw
Bram Moolenaar <Bram@vim.org>
parents:
28501
diff
changeset
|
170 // received. To avoid redrawing too often, only redraw when t_8u is not reset |
8751e815864e
patch 8.2.4777: screendump tests fail because of a redraw
Bram Moolenaar <Bram@vim.org>
parents:
28501
diff
changeset
|
171 // and it was supposed to be written. |
8751e815864e
patch 8.2.4777: screendump tests fail because of a redraw
Bram Moolenaar <Bram@vim.org>
parents:
28501
diff
changeset
|
172 // FALSE -> don't output t_8u yet |
8751e815864e
patch 8.2.4777: screendump tests fail because of a redraw
Bram Moolenaar <Bram@vim.org>
parents:
28501
diff
changeset
|
173 // MAYBE -> tried outputing t_8u while FALSE |
8751e815864e
patch 8.2.4777: screendump tests fail because of a redraw
Bram Moolenaar <Bram@vim.org>
parents:
28501
diff
changeset
|
174 // OK -> can write t_8u |
8751e815864e
patch 8.2.4777: screendump tests fail because of a redraw
Bram Moolenaar <Bram@vim.org>
parents:
28501
diff
changeset
|
175 int write_t_8u_state = FALSE; |
7 | 176 # endif |
177 | |
178 /* | |
179 * Don't declare these variables if termcap.h contains them. | |
180 * Autoconf checks if these variables should be declared extern (not all | |
181 * systems have them). | |
182 * Some versions define ospeed to be speed_t, but that is incompatible with | |
183 * BSD, where ospeed is short and speed_t is long. | |
184 */ | |
185 # ifndef HAVE_OSPEED | |
186 # ifdef OSPEED_EXTERN | |
187 extern short ospeed; | |
188 # else | |
189 short ospeed; | |
190 # endif | |
191 # endif | |
192 # ifndef HAVE_UP_BC_PC | |
193 # ifdef UP_BC_PC_EXTERN | |
194 extern char *UP, *BC, PC; | |
195 # else | |
196 char *UP, *BC, PC; | |
197 # endif | |
198 # endif | |
199 | |
200 # define TGETSTR(s, p) vim_tgetstr((s), (p)) | |
201 # define TGETENT(b, t) tgetent((char *)(b), (char *)(t)) | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
202 static char_u *vim_tgetstr(char *s, char_u **pp); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
203 #endif // HAVE_TGETENT |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
204 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
205 static int detected_8bit = FALSE; // detected 8-bit terminal |
7 | 206 |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
207 #if (defined(UNIX) || defined(VMS)) |
27930
1a702abffaf3
patch 8.2.4490: terminal focus reporting only works for xterm-like terminals
Bram Moolenaar <Bram@vim.org>
parents:
27684
diff
changeset
|
208 static int focus_state = MAYBE; // TRUE if the Vim window has focus |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
209 #endif |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
210 |
12184
76fbd85c3cea
patch 8.0.0972: compiler warnings for unused variables
Christian Brabandt <cb@256bit.org>
parents:
12174
diff
changeset
|
211 #ifdef FEAT_TERMRESPONSE |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
212 // When the cursor shape was detected these values are used: |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
213 // 1: block, 2: underline, 3: vertical bar |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
214 static int initial_cursor_shape = 0; |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
215 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
216 // The blink flag from the style response may be inverted from the actual |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
217 // blinking state, xterm XORs the flags. |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
218 static int initial_cursor_shape_blink = FALSE; |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
219 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
220 // The blink flag from the blinking-cursor mode response |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
221 static int initial_cursor_blink = FALSE; |
12184
76fbd85c3cea
patch 8.0.0972: compiler warnings for unused variables
Christian Brabandt <cb@256bit.org>
parents:
12174
diff
changeset
|
222 #endif |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
223 |
298 | 224 static struct builtin_term builtin_termcaps[] = |
7 | 225 { |
226 | |
227 #if defined(FEAT_GUI) | |
228 /* | |
229 * GUI pseudo term-cap. | |
230 */ | |
231 {(int)KS_NAME, "gui"}, | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
232 {(int)KS_CE, "\033|$"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
233 {(int)KS_AL, "\033|i"}, |
7 | 234 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
235 {(int)KS_CAL, "\033|%p1%dI"}, |
7 | 236 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
237 {(int)KS_CAL, "\033|%dI"}, |
7 | 238 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
239 {(int)KS_DL, "\033|d"}, |
7 | 240 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
241 {(int)KS_CDL, "\033|%p1%dD"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
242 {(int)KS_CS, "\033|%p1%d;%p2%dR"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
243 {(int)KS_CSV, "\033|%p1%d;%p2%dV"}, |
7 | 244 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
245 {(int)KS_CDL, "\033|%dD"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
246 {(int)KS_CS, "\033|%d;%dR"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
247 {(int)KS_CSV, "\033|%d;%dV"}, |
7 | 248 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
249 {(int)KS_CL, "\033|C"}, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
250 // attributes switched on with 'h', off with * 'H' |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
251 {(int)KS_ME, "\033|31H"}, // HL_ALL |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
252 {(int)KS_MR, "\033|1h"}, // HL_INVERSE |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
253 {(int)KS_MD, "\033|2h"}, // HL_BOLD |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
254 {(int)KS_SE, "\033|16H"}, // HL_STANDOUT |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
255 {(int)KS_SO, "\033|16h"}, // HL_STANDOUT |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
256 {(int)KS_UE, "\033|8H"}, // HL_UNDERLINE |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
257 {(int)KS_US, "\033|8h"}, // HL_UNDERLINE |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
258 {(int)KS_UCE, "\033|8C"}, // HL_UNDERCURL |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
259 {(int)KS_UCS, "\033|8c"}, // HL_UNDERCURL |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
260 {(int)KS_STE, "\033|4C"}, // HL_STRIKETHROUGH |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
261 {(int)KS_STS, "\033|4c"}, // HL_STRIKETHROUGH |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
262 {(int)KS_CZR, "\033|4H"}, // HL_ITALIC |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
263 {(int)KS_CZH, "\033|4h"}, // HL_ITALIC |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
264 {(int)KS_VB, "\033|f"}, |
7 | 265 {(int)KS_MS, "y"}, |
266 {(int)KS_UT, "y"}, | |
6602 | 267 {(int)KS_XN, "y"}, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
268 {(int)KS_LE, "\b"}, // cursor-left = BS |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
269 {(int)KS_ND, "\014"}, // cursor-right = CTRL-L |
7 | 270 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
271 {(int)KS_CM, "\033|%p1%d;%p2%dM"}, |
7 | 272 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
273 {(int)KS_CM, "\033|%d;%dM"}, |
7 | 274 # endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
275 // there are no key sequences here, the GUI sequences are recognized |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
276 // in check_termcode() |
7 | 277 #endif |
278 | |
279 #ifndef NO_BUILTIN_TCAPS | |
280 | |
281 # if defined(AMIGA) || defined(ALL_BUILTIN_TCAPS) | |
282 /* | |
283 * Amiga console window, default for Amiga | |
284 */ | |
285 {(int)KS_NAME, "amiga"}, | |
286 {(int)KS_CE, "\033[K"}, | |
287 {(int)KS_CD, "\033[J"}, | |
288 {(int)KS_AL, "\033[L"}, | |
289 # ifdef TERMINFO | |
290 {(int)KS_CAL, "\033[%p1%dL"}, | |
291 # else | |
292 {(int)KS_CAL, "\033[%dL"}, | |
293 # endif | |
294 {(int)KS_DL, "\033[M"}, | |
295 # ifdef TERMINFO | |
296 {(int)KS_CDL, "\033[%p1%dM"}, | |
297 # else | |
298 {(int)KS_CDL, "\033[%dM"}, | |
299 # endif | |
300 {(int)KS_CL, "\014"}, | |
301 {(int)KS_VI, "\033[0 p"}, | |
302 {(int)KS_VE, "\033[1 p"}, | |
303 {(int)KS_ME, "\033[0m"}, | |
304 {(int)KS_MR, "\033[7m"}, | |
305 {(int)KS_MD, "\033[1m"}, | |
306 {(int)KS_SE, "\033[0m"}, | |
307 {(int)KS_SO, "\033[33m"}, | |
308 {(int)KS_US, "\033[4m"}, | |
309 {(int)KS_UE, "\033[0m"}, | |
310 {(int)KS_CZH, "\033[3m"}, | |
311 {(int)KS_CZR, "\033[0m"}, | |
22956
9c8af140b2da
patch 8.2.2025: Amiga: Not all colors are used on OS4
Bram Moolenaar <Bram@vim.org>
parents:
22764
diff
changeset
|
312 #if defined(__amigaos4__) || defined(__MORPHOS__) || defined(__AROS__) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
313 {(int)KS_CCO, "8"}, // allow 8 colors |
7 | 314 # ifdef TERMINFO |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
315 {(int)KS_CAB, "\033[4%p1%dm"},// set background color |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
316 {(int)KS_CAF, "\033[3%p1%dm"},// set foreground color |
7 | 317 # else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
318 {(int)KS_CAB, "\033[4%dm"}, // set background color |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
319 {(int)KS_CAF, "\033[3%dm"}, // set foreground color |
7 | 320 # endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
321 {(int)KS_OP, "\033[m"}, // reset colors |
7 | 322 #endif |
323 {(int)KS_MS, "y"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
324 {(int)KS_UT, "y"}, // guessed |
7 | 325 {(int)KS_LE, "\b"}, |
326 # ifdef TERMINFO | |
327 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
328 # else | |
329 {(int)KS_CM, "\033[%i%d;%dH"}, | |
330 # endif | |
331 #if defined(__MORPHOS__) | |
332 {(int)KS_SR, "\033M"}, | |
333 #endif | |
334 # ifdef TERMINFO | |
335 {(int)KS_CRI, "\033[%p1%dC"}, | |
336 # else | |
337 {(int)KS_CRI, "\033[%dC"}, | |
338 # endif | |
339 {K_UP, "\233A"}, | |
340 {K_DOWN, "\233B"}, | |
341 {K_LEFT, "\233D"}, | |
342 {K_RIGHT, "\233C"}, | |
343 {K_S_UP, "\233T"}, | |
344 {K_S_DOWN, "\233S"}, | |
345 {K_S_LEFT, "\233 A"}, | |
346 {K_S_RIGHT, "\233 @"}, | |
347 {K_S_TAB, "\233Z"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
348 {K_F1, "\233\060~"},// some compilers don't dig "\2330" |
7 | 349 {K_F2, "\233\061~"}, |
350 {K_F3, "\233\062~"}, | |
351 {K_F4, "\233\063~"}, | |
352 {K_F5, "\233\064~"}, | |
353 {K_F6, "\233\065~"}, | |
354 {K_F7, "\233\066~"}, | |
355 {K_F8, "\233\067~"}, | |
356 {K_F9, "\233\070~"}, | |
357 {K_F10, "\233\071~"}, | |
358 {K_S_F1, "\233\061\060~"}, | |
359 {K_S_F2, "\233\061\061~"}, | |
360 {K_S_F3, "\233\061\062~"}, | |
361 {K_S_F4, "\233\061\063~"}, | |
362 {K_S_F5, "\233\061\064~"}, | |
363 {K_S_F6, "\233\061\065~"}, | |
364 {K_S_F7, "\233\061\066~"}, | |
365 {K_S_F8, "\233\061\067~"}, | |
366 {K_S_F9, "\233\061\070~"}, | |
367 {K_S_F10, "\233\061\071~"}, | |
368 {K_HELP, "\233?~"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
369 {K_INS, "\233\064\060~"}, // 101 key keyboard |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
370 {K_PAGEUP, "\233\064\061~"}, // 101 key keyboard |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
371 {K_PAGEDOWN, "\233\064\062~"}, // 101 key keyboard |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
372 {K_HOME, "\233\064\064~"}, // 101 key keyboard |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
373 {K_END, "\233\064\065~"}, // 101 key keyboard |
7 | 374 |
375 {BT_EXTRA_KEYS, ""}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
376 {TERMCAP2KEY('#', '2'), "\233\065\064~"}, // shifted home key |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
377 {TERMCAP2KEY('#', '3'), "\233\065\060~"}, // shifted insert key |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
378 {TERMCAP2KEY('*', '7'), "\233\065\065~"}, // shifted end key |
7 | 379 # endif |
380 | |
20591
4411c2b96af9
patch 8.2.0849: BeOS code is not maintained and probably unused
Bram Moolenaar <Bram@vim.org>
parents:
20589
diff
changeset
|
381 # ifdef ALL_BUILTIN_TCAPS |
7 | 382 /* |
20591
4411c2b96af9
patch 8.2.0849: BeOS code is not maintained and probably unused
Bram Moolenaar <Bram@vim.org>
parents:
20589
diff
changeset
|
383 * almost standard ANSI terminal |
7 | 384 */ |
385 {(int)KS_CE, "\033[K"}, | |
386 {(int)KS_CD, "\033[J"}, | |
387 {(int)KS_AL, "\033[L"}, | |
388 # ifdef TERMINFO | |
389 {(int)KS_CAL, "\033[%p1%dL"}, | |
390 # else | |
391 {(int)KS_CAL, "\033[%dL"}, | |
392 # endif | |
393 {(int)KS_DL, "\033[M"}, | |
394 # ifdef TERMINFO | |
395 {(int)KS_CDL, "\033[%p1%dM"}, | |
396 # else | |
397 {(int)KS_CDL, "\033[%dM"}, | |
398 # endif | |
399 {(int)KS_CL, "\033[H\033[2J"}, | |
400 #ifdef notyet | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
401 {(int)KS_VI, "[VI]"}, // cursor invisible, VT320: CSI ? 25 l |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
402 {(int)KS_VE, "[VE]"}, // cursor visible, VT320: CSI ? 25 h |
7 | 403 #endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
404 {(int)KS_ME, "\033[m"}, // normal mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
405 {(int)KS_MR, "\033[7m"}, // reverse |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
406 {(int)KS_MD, "\033[1m"}, // bold |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
407 {(int)KS_SO, "\033[31m"}, // standout mode: red |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
408 {(int)KS_SE, "\033[m"}, // standout end |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
409 {(int)KS_CZH, "\033[35m"}, // italic: purple |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
410 {(int)KS_CZR, "\033[m"}, // italic end |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
411 {(int)KS_US, "\033[4m"}, // underscore mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
412 {(int)KS_UE, "\033[m"}, // underscore end |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
413 {(int)KS_CCO, "8"}, // allow 8 colors |
7 | 414 # ifdef TERMINFO |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
415 {(int)KS_CAB, "\033[4%p1%dm"},// set background color |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
416 {(int)KS_CAF, "\033[3%p1%dm"},// set foreground color |
7 | 417 # else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
418 {(int)KS_CAB, "\033[4%dm"}, // set background color |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
419 {(int)KS_CAF, "\033[3%dm"}, // set foreground color |
7 | 420 # endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
421 {(int)KS_OP, "\033[m"}, // reset colors |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
422 {(int)KS_MS, "y"}, // safe to move cur in reverse mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
423 {(int)KS_UT, "y"}, // guessed |
7 | 424 {(int)KS_LE, "\b"}, |
425 # ifdef TERMINFO | |
426 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
427 # else | |
428 {(int)KS_CM, "\033[%i%d;%dH"}, | |
429 # endif | |
430 {(int)KS_SR, "\033M"}, | |
431 # ifdef TERMINFO | |
432 {(int)KS_CRI, "\033[%p1%dC"}, | |
433 # else | |
434 {(int)KS_CRI, "\033[%dC"}, | |
435 # endif | |
436 | |
437 {K_UP, "\033[A"}, | |
438 {K_DOWN, "\033[B"}, | |
439 {K_LEFT, "\033[D"}, | |
440 {K_RIGHT, "\033[C"}, | |
441 # endif | |
442 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
443 # if defined(UNIX) || defined(ALL_BUILTIN_TCAPS) || defined(SOME_BUILTIN_TCAPS) |
7 | 444 /* |
445 * standard ANSI terminal, default for unix | |
446 */ | |
447 {(int)KS_NAME, "ansi"}, | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
448 {(int)KS_CE, "\033[K"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
449 {(int)KS_AL, "\033[L"}, |
7 | 450 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
451 {(int)KS_CAL, "\033[%p1%dL"}, |
7 | 452 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
453 {(int)KS_CAL, "\033[%dL"}, |
7 | 454 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
455 {(int)KS_DL, "\033[M"}, |
7 | 456 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
457 {(int)KS_CDL, "\033[%p1%dM"}, |
7 | 458 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
459 {(int)KS_CDL, "\033[%dM"}, |
7 | 460 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
461 {(int)KS_CL, "\033[H\033[2J"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
462 {(int)KS_ME, "\033[0m"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
463 {(int)KS_MR, "\033[7m"}, |
7 | 464 {(int)KS_MS, "y"}, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
465 {(int)KS_UT, "y"}, // guessed |
7 | 466 {(int)KS_LE, "\b"}, |
467 # ifdef TERMINFO | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
468 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, |
7 | 469 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
470 {(int)KS_CM, "\033[%i%d;%dH"}, |
7 | 471 # endif |
472 # ifdef TERMINFO | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
473 {(int)KS_CRI, "\033[%p1%dC"}, |
7 | 474 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
475 {(int)KS_CRI, "\033[%dC"}, |
7 | 476 # endif |
477 # endif | |
478 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
479 # if defined(ALL_BUILTIN_TCAPS) |
7 | 480 /* |
481 * These codes are valid when nansi.sys or equivalent has been installed. | |
482 * Function keys on a PC are preceded with a NUL. These are converted into | |
483 * K_NUL '\316' in mch_inchar(), because we cannot handle NULs in key codes. | |
484 * CTRL-arrow is used instead of SHIFT-arrow. | |
485 */ | |
486 {(int)KS_NAME, "pcansi"}, | |
487 {(int)KS_DL, "\033[M"}, | |
488 {(int)KS_AL, "\033[L"}, | |
489 {(int)KS_CE, "\033[K"}, | |
490 {(int)KS_CL, "\033[2J"}, | |
491 {(int)KS_ME, "\033[0m"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
492 {(int)KS_MR, "\033[5m"}, // reverse: black on lightgrey |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
493 {(int)KS_MD, "\033[1m"}, // bold: white text |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
494 {(int)KS_SE, "\033[0m"}, // standout end |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
495 {(int)KS_SO, "\033[31m"}, // standout: white on blue |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
496 {(int)KS_CZH, "\033[34;43m"}, // italic mode: blue text on yellow |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
497 {(int)KS_CZR, "\033[0m"}, // italic mode end |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
498 {(int)KS_US, "\033[36;41m"}, // underscore mode: cyan text on red |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
499 {(int)KS_UE, "\033[0m"}, // underscore mode end |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
500 {(int)KS_CCO, "8"}, // allow 8 colors |
7 | 501 # ifdef TERMINFO |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
502 {(int)KS_CAB, "\033[4%p1%dm"},// set background color |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
503 {(int)KS_CAF, "\033[3%p1%dm"},// set foreground color |
7 | 504 # else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
505 {(int)KS_CAB, "\033[4%dm"}, // set background color |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
506 {(int)KS_CAF, "\033[3%dm"}, // set foreground color |
7 | 507 # endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
508 {(int)KS_OP, "\033[0m"}, // reset colors |
7 | 509 {(int)KS_MS, "y"}, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
510 {(int)KS_UT, "y"}, // guessed |
7 | 511 {(int)KS_LE, "\b"}, |
512 # ifdef TERMINFO | |
513 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
514 # else | |
515 {(int)KS_CM, "\033[%i%d;%dH"}, | |
516 # endif | |
517 # ifdef TERMINFO | |
518 {(int)KS_CRI, "\033[%p1%dC"}, | |
519 # else | |
520 {(int)KS_CRI, "\033[%dC"}, | |
521 # endif | |
522 {K_UP, "\316H"}, | |
523 {K_DOWN, "\316P"}, | |
524 {K_LEFT, "\316K"}, | |
525 {K_RIGHT, "\316M"}, | |
526 {K_S_LEFT, "\316s"}, | |
527 {K_S_RIGHT, "\316t"}, | |
528 {K_F1, "\316;"}, | |
529 {K_F2, "\316<"}, | |
530 {K_F3, "\316="}, | |
531 {K_F4, "\316>"}, | |
532 {K_F5, "\316?"}, | |
533 {K_F6, "\316@"}, | |
534 {K_F7, "\316A"}, | |
535 {K_F8, "\316B"}, | |
536 {K_F9, "\316C"}, | |
537 {K_F10, "\316D"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
538 {K_F11, "\316\205"}, // guessed |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
539 {K_F12, "\316\206"}, // guessed |
7 | 540 {K_S_F1, "\316T"}, |
541 {K_S_F2, "\316U"}, | |
542 {K_S_F3, "\316V"}, | |
543 {K_S_F4, "\316W"}, | |
544 {K_S_F5, "\316X"}, | |
545 {K_S_F6, "\316Y"}, | |
546 {K_S_F7, "\316Z"}, | |
547 {K_S_F8, "\316["}, | |
548 {K_S_F9, "\316\\"}, | |
549 {K_S_F10, "\316]"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
550 {K_S_F11, "\316\207"}, // guessed |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
551 {K_S_F12, "\316\210"}, // guessed |
7 | 552 {K_INS, "\316R"}, |
553 {K_DEL, "\316S"}, | |
554 {K_HOME, "\316G"}, | |
555 {K_END, "\316O"}, | |
556 {K_PAGEDOWN, "\316Q"}, | |
557 {K_PAGEUP, "\316I"}, | |
558 # endif | |
559 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15852
diff
changeset
|
560 # if defined(MSWIN) || defined(ALL_BUILTIN_TCAPS) |
7 | 561 /* |
562 * These codes are valid for the Win32 Console . The entries that start with | |
563 * ESC | are translated into console calls in os_win32.c. The function keys | |
564 * are also translated in os_win32.c. | |
565 */ | |
566 {(int)KS_NAME, "win32"}, | |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
567 {(int)KS_CE, "\033|K"}, // clear to end of line |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
568 {(int)KS_AL, "\033|L"}, // add new blank line |
7 | 569 # ifdef TERMINFO |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
570 {(int)KS_CAL, "\033|%p1%dL"}, // add number of new blank lines |
7 | 571 # else |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
572 {(int)KS_CAL, "\033|%dL"}, // add number of new blank lines |
7 | 573 # endif |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
574 {(int)KS_DL, "\033|M"}, // delete line |
7 | 575 # ifdef TERMINFO |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
576 {(int)KS_CDL, "\033|%p1%dM"}, // delete number of lines |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
577 {(int)KS_CSV, "\033|%p1%d;%p2%dV"}, |
7 | 578 # else |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
579 {(int)KS_CDL, "\033|%dM"}, // delete number of lines |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
580 {(int)KS_CSV, "\033|%d;%dV"}, |
7 | 581 # endif |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
582 {(int)KS_CL, "\033|J"}, // clear screen |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
583 {(int)KS_CD, "\033|j"}, // clear to end of display |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
584 {(int)KS_VI, "\033|v"}, // cursor invisible |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
585 {(int)KS_VE, "\033|V"}, // cursor visible |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
586 |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
587 {(int)KS_ME, "\033|0m"}, // normal |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
588 {(int)KS_MR, "\033|112m"}, // reverse: black on lightgray |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
589 {(int)KS_MD, "\033|15m"}, // bold: white on black |
7 | 590 #if 1 |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
591 {(int)KS_SO, "\033|31m"}, // standout: white on blue |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
592 {(int)KS_SE, "\033|0m"}, // standout end |
7 | 593 #else |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
594 {(int)KS_SO, "\033|F"}, // standout: high intensity |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
595 {(int)KS_SE, "\033|f"}, // standout end |
7 | 596 #endif |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
597 {(int)KS_CZH, "\033|225m"}, // italic: blue text on yellow |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
598 {(int)KS_CZR, "\033|0m"}, // italic end |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
599 {(int)KS_US, "\033|67m"}, // underscore: cyan text on red |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
600 {(int)KS_UE, "\033|0m"}, // underscore end |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
601 {(int)KS_CCO, "16"}, // allow 16 colors |
7 | 602 # ifdef TERMINFO |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
603 {(int)KS_CAB, "\033|%p1%db"}, // set background color |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
604 {(int)KS_CAF, "\033|%p1%df"}, // set foreground color |
7 | 605 # else |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
606 {(int)KS_CAB, "\033|%db"}, // set background color |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
607 {(int)KS_CAF, "\033|%df"}, // set foreground color |
7 | 608 # endif |
609 | |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
610 {(int)KS_MS, "y"}, // save to move cur in reverse mode |
7 | 611 {(int)KS_UT, "y"}, |
6602 | 612 {(int)KS_XN, "y"}, |
7 | 613 {(int)KS_LE, "\b"}, |
614 # ifdef TERMINFO | |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
615 {(int)KS_CM, "\033|%i%p1%d;%p2%dH"}, // cursor motion |
7 | 616 # else |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
617 {(int)KS_CM, "\033|%i%d;%dH"}, // cursor motion |
7 | 618 # endif |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
619 {(int)KS_VB, "\033|B"}, // visual bell |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
620 {(int)KS_TI, "\033|S"}, // put terminal in termcap mode |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
621 {(int)KS_TE, "\033|E"}, // out of termcap mode |
7 | 622 # ifdef TERMINFO |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
623 {(int)KS_CS, "\033|%i%p1%d;%p2%dr"}, // scroll region |
7 | 624 # else |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
625 {(int)KS_CS, "\033|%i%d;%dr"}, // scroll region |
7 | 626 # endif |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
627 # ifdef FEAT_TERMGUICOLORS |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
628 {(int)KS_8F, "\033|38;2;%lu;%lu;%lum"}, |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
629 {(int)KS_8B, "\033|48;2;%lu;%lu;%lum"}, |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
630 # endif |
7 | 631 |
632 {K_UP, "\316H"}, | |
633 {K_DOWN, "\316P"}, | |
634 {K_LEFT, "\316K"}, | |
635 {K_RIGHT, "\316M"}, | |
636 {K_S_UP, "\316\304"}, | |
637 {K_S_DOWN, "\316\317"}, | |
638 {K_S_LEFT, "\316\311"}, | |
639 {K_C_LEFT, "\316s"}, | |
640 {K_S_RIGHT, "\316\313"}, | |
641 {K_C_RIGHT, "\316t"}, | |
642 {K_S_TAB, "\316\017"}, | |
643 {K_F1, "\316;"}, | |
644 {K_F2, "\316<"}, | |
645 {K_F3, "\316="}, | |
646 {K_F4, "\316>"}, | |
647 {K_F5, "\316?"}, | |
648 {K_F6, "\316@"}, | |
649 {K_F7, "\316A"}, | |
650 {K_F8, "\316B"}, | |
651 {K_F9, "\316C"}, | |
652 {K_F10, "\316D"}, | |
653 {K_F11, "\316\205"}, | |
654 {K_F12, "\316\206"}, | |
655 {K_S_F1, "\316T"}, | |
656 {K_S_F2, "\316U"}, | |
657 {K_S_F3, "\316V"}, | |
658 {K_S_F4, "\316W"}, | |
659 {K_S_F5, "\316X"}, | |
660 {K_S_F6, "\316Y"}, | |
661 {K_S_F7, "\316Z"}, | |
662 {K_S_F8, "\316["}, | |
663 {K_S_F9, "\316\\"}, | |
664 {K_S_F10, "\316]"}, | |
665 {K_S_F11, "\316\207"}, | |
666 {K_S_F12, "\316\210"}, | |
667 {K_INS, "\316R"}, | |
668 {K_DEL, "\316S"}, | |
669 {K_HOME, "\316G"}, | |
670 {K_S_HOME, "\316\302"}, | |
671 {K_C_HOME, "\316w"}, | |
672 {K_END, "\316O"}, | |
673 {K_S_END, "\316\315"}, | |
674 {K_C_END, "\316u"}, | |
675 {K_PAGEDOWN, "\316Q"}, | |
676 {K_PAGEUP, "\316I"}, | |
677 {K_KPLUS, "\316N"}, | |
678 {K_KMINUS, "\316J"}, | |
679 {K_KMULTIPLY, "\316\067"}, | |
680 {K_K0, "\316\332"}, | |
681 {K_K1, "\316\336"}, | |
682 {K_K2, "\316\342"}, | |
683 {K_K3, "\316\346"}, | |
684 {K_K4, "\316\352"}, | |
685 {K_K5, "\316\356"}, | |
686 {K_K6, "\316\362"}, | |
687 {K_K7, "\316\366"}, | |
688 {K_K8, "\316\372"}, | |
689 {K_K9, "\316\376"}, | |
16182
bed0d7200635
patch 8.1.1096: MS-Windows: cannot distinguish BS and CTRL-H
Bram Moolenaar <Bram@vim.org>
parents:
16058
diff
changeset
|
690 {K_BS, "\316x"}, |
7 | 691 # endif |
692 | |
693 # if defined(VMS) || defined(ALL_BUILTIN_TCAPS) | |
694 /* | |
695 * VT320 is working as an ANSI terminal compatible DEC terminal. | |
696 * (it covers VT1x0, VT2x0 and VT3x0 up to VT320 on VMS as well) | |
697 * TODO:- rewrite ESC[ codes to CSI | |
698 * - keyboard languages (CSI ? 26 n) | |
699 */ | |
700 {(int)KS_NAME, "vt320"}, | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
701 {(int)KS_CE, "\033[K"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
702 {(int)KS_AL, "\033[L"}, |
7 | 703 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
704 {(int)KS_CAL, "\033[%p1%dL"}, |
7 | 705 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
706 {(int)KS_CAL, "\033[%dL"}, |
7 | 707 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
708 {(int)KS_DL, "\033[M"}, |
7 | 709 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
710 {(int)KS_CDL, "\033[%p1%dM"}, |
7 | 711 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
712 {(int)KS_CDL, "\033[%dM"}, |
7 | 713 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
714 {(int)KS_CL, "\033[H\033[2J"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
715 {(int)KS_CD, "\033[J"}, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
716 {(int)KS_CCO, "8"}, // allow 8 colors |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
717 {(int)KS_ME, "\033[0m"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
718 {(int)KS_MR, "\033[7m"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
719 {(int)KS_MD, "\033[1m"}, // bold mode |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
720 {(int)KS_SE, "\033[22m"},// normal mode |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
721 {(int)KS_UE, "\033[24m"},// exit underscore mode |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
722 {(int)KS_US, "\033[4m"}, // underscore mode |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
723 {(int)KS_CZH, "\033[34;43m"}, // italic mode: blue text on yellow |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
724 {(int)KS_CZR, "\033[0m"}, // italic mode end |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
725 {(int)KS_CAB, "\033[4%dm"}, // set background color (ANSI) |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
726 {(int)KS_CAF, "\033[3%dm"}, // set foreground color (ANSI) |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
727 {(int)KS_CSB, "\033[102;%dm"}, // set screen background color |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
728 {(int)KS_CSF, "\033[101;%dm"}, // set screen foreground color |
7 | 729 {(int)KS_MS, "y"}, |
730 {(int)KS_UT, "y"}, | |
6602 | 731 {(int)KS_XN, "y"}, |
7 | 732 {(int)KS_LE, "\b"}, |
733 # ifdef TERMINFO | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
734 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, |
7 | 735 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
736 {(int)KS_CM, "\033[%i%d;%dH"}, |
7 | 737 # endif |
738 # ifdef TERMINFO | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
739 {(int)KS_CRI, "\033[%p1%dC"}, |
7 | 740 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
741 {(int)KS_CRI, "\033[%dC"}, |
7 | 742 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
743 {K_UP, "\033[A"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
744 {K_DOWN, "\033[B"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
745 {K_RIGHT, "\033[C"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
746 {K_LEFT, "\033[D"}, |
14252
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
747 // Note: cursor key sequences for application cursor mode are omitted, |
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
748 // because they interfere with typed commands: <Esc>OA. |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
749 {K_F1, "\033[11~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
750 {K_F2, "\033[12~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
751 {K_F3, "\033[13~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
752 {K_F4, "\033[14~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
753 {K_F5, "\033[15~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
754 {K_F6, "\033[17~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
755 {K_F7, "\033[18~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
756 {K_F8, "\033[19~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
757 {K_F9, "\033[20~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
758 {K_F10, "\033[21~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
759 {K_F11, "\033[23~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
760 {K_F12, "\033[24~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
761 {K_F13, "\033[25~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
762 {K_F14, "\033[26~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
763 {K_F15, "\033[28~"}, // Help |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
764 {K_F16, "\033[29~"}, // Select |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
765 {K_F17, "\033[31~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
766 {K_F18, "\033[32~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
767 {K_F19, "\033[33~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
768 {K_F20, "\033[34~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
769 {K_INS, "\033[2~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
770 {K_DEL, "\033[3~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
771 {K_HOME, "\033[1~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
772 {K_END, "\033[4~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
773 {K_PAGEUP, "\033[5~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
774 {K_PAGEDOWN, "\033[6~"}, |
14252
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
775 // These sequences starting with <Esc> O may interfere with what the user |
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
776 // is typing. Remove these if that bothers you. |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
777 {K_KPLUS, "\033Ok"}, // keypad plus |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
778 {K_KMINUS, "\033Om"}, // keypad minus |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
779 {K_KDIVIDE, "\033Oo"}, // keypad / |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
780 {K_KMULTIPLY, "\033Oj"}, // keypad * |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
781 {K_KENTER, "\033OM"}, // keypad Enter |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
782 {K_K0, "\033Op"}, // keypad 0 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
783 {K_K1, "\033Oq"}, // keypad 1 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
784 {K_K2, "\033Or"}, // keypad 2 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
785 {K_K3, "\033Os"}, // keypad 3 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
786 {K_K4, "\033Ot"}, // keypad 4 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
787 {K_K5, "\033Ou"}, // keypad 5 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
788 {K_K6, "\033Ov"}, // keypad 6 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
789 {K_K7, "\033Ow"}, // keypad 7 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
790 {K_K8, "\033Ox"}, // keypad 8 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
791 {K_K9, "\033Oy"}, // keypad 9 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
792 {K_BS, "\x7f"}, // for some reason 0177 doesn't work |
7 | 793 # endif |
794 | |
21329
bb3f60b0aca0
patch 8.2.1215: Atari MiNT support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
21226
diff
changeset
|
795 # if defined(ALL_BUILTIN_TCAPS) |
7 | 796 /* |
797 * Ordinary vt52 | |
798 */ | |
799 {(int)KS_NAME, "vt52"}, | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
800 {(int)KS_CE, "\033K"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
801 {(int)KS_CD, "\033J"}, |
7264
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
802 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
803 {(int)KS_CM, "\033Y%p1%' '%+%c%p2%' '%+%c"}, |
7264
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
804 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
805 {(int)KS_CM, "\033Y%+ %+ "}, |
7264
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
806 # endif |
7 | 807 {(int)KS_LE, "\b"}, |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
808 {(int)KS_SR, "\033I"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
809 {(int)KS_AL, "\033L"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
810 {(int)KS_DL, "\033M"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
811 {K_UP, "\033A"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
812 {K_DOWN, "\033B"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
813 {K_LEFT, "\033D"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
814 {K_RIGHT, "\033C"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
815 {K_F1, "\033P"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
816 {K_F2, "\033Q"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
817 {K_F3, "\033R"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
818 {(int)KS_CL, "\033H\033J"}, |
7 | 819 {(int)KS_MS, "y"}, |
820 # endif | |
821 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
822 # if defined(UNIX) || defined(ALL_BUILTIN_TCAPS) || defined(SOME_BUILTIN_TCAPS) |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
823 {(int)KS_NAME, "xterm"}, |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
824 {(int)KS_CE, "\033[K"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
825 {(int)KS_AL, "\033[L"}, |
7 | 826 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
827 {(int)KS_CAL, "\033[%p1%dL"}, |
7 | 828 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
829 {(int)KS_CAL, "\033[%dL"}, |
7 | 830 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
831 {(int)KS_DL, "\033[M"}, |
7 | 832 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
833 {(int)KS_CDL, "\033[%p1%dM"}, |
7 | 834 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
835 {(int)KS_CDL, "\033[%dM"}, |
7 | 836 # endif |
837 # ifdef TERMINFO | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
838 {(int)KS_CS, "\033[%i%p1%d;%p2%dr"}, |
7 | 839 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
840 {(int)KS_CS, "\033[%i%d;%dr"}, |
7 | 841 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
842 {(int)KS_CL, "\033[H\033[2J"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
843 {(int)KS_CD, "\033[J"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
844 {(int)KS_ME, "\033[m"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
845 {(int)KS_MR, "\033[7m"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
846 {(int)KS_MD, "\033[1m"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
847 {(int)KS_UE, "\033[m"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
848 {(int)KS_US, "\033[4m"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
849 {(int)KS_STE, "\033[29m"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
850 {(int)KS_STS, "\033[9m"}, |
7 | 851 {(int)KS_MS, "y"}, |
852 {(int)KS_UT, "y"}, | |
853 {(int)KS_LE, "\b"}, | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
854 {(int)KS_VI, "\033[?25l"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
855 {(int)KS_VE, "\033[?25h"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
856 {(int)KS_VS, "\033[?12h"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
857 {(int)KS_CVS, "\033[?12l"}, |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
858 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
859 {(int)KS_CSH, "\033[%p1%d q"}, |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
860 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
861 {(int)KS_CSH, "\033[%d q"}, |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
862 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
863 {(int)KS_CRC, "\033[?12$p"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
864 {(int)KS_CRS, "\033P$q q\033\\"}, |
7 | 865 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
866 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, |
7 | 867 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
868 {(int)KS_CM, "\033[%i%d;%dH"}, |
7 | 869 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
870 {(int)KS_SR, "\033M"}, |
7 | 871 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
872 {(int)KS_CRI, "\033[%p1%dC"}, |
7 | 873 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
874 {(int)KS_CRI, "\033[%dC"}, |
7 | 875 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
876 {(int)KS_KS, "\033[?1h\033="}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
877 {(int)KS_KE, "\033[?1l\033>"}, |
7 | 878 # ifdef FEAT_XTERM_SAVE |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
879 {(int)KS_TI, "\0337\033[?47h"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
880 {(int)KS_TE, "\033[?47l\0338"}, |
7 | 881 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
882 {(int)KS_CTI, "\033[>4;2m"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
883 {(int)KS_CTE, "\033[>4;m"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
884 {(int)KS_CIS, "\033]1;"}, |
7 | 885 {(int)KS_CIE, "\007"}, |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
886 {(int)KS_TS, "\033]2;"}, |
7 | 887 {(int)KS_FS, "\007"}, |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
888 {(int)KS_CSC, "\033]12;"}, |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
889 {(int)KS_CEC, "\007"}, |
7 | 890 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
891 {(int)KS_CWS, "\033[8;%p1%d;%p2%dt"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
892 {(int)KS_CWP, "\033[3;%p1%d;%p2%dt"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
893 {(int)KS_CGP, "\033[13t"}, |
7 | 894 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
895 {(int)KS_CWS, "\033[8;%d;%dt"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
896 {(int)KS_CWP, "\033[3;%d;%dt"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
897 {(int)KS_CGP, "\033[13t"}, |
7 | 898 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
899 {(int)KS_CRV, "\033[>c"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
900 {(int)KS_RFG, "\033]10;?\007"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
901 {(int)KS_RBG, "\033]11;?\007"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
902 {(int)KS_U7, "\033[6n"}, |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
903 # ifdef FEAT_TERMGUICOLORS |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
904 // These are printf strings, not terminal codes. |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
905 {(int)KS_8F, "\033[38;2;%lu;%lu;%lum"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
906 {(int)KS_8B, "\033[48;2;%lu;%lu;%lum"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
907 {(int)KS_8U, "\033[58;2;%lu;%lu;%lum"}, |
8985
42eb58c9da92
commit https://github.com/vim/vim/commit/b2fa54a84078e2b8dc3c7c7bfbccf6b75c0788d0
Christian Brabandt <cb@256bit.org>
parents:
8981
diff
changeset
|
908 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
909 {(int)KS_CAU, "\033[58;5;%dm"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
910 {(int)KS_CBE, "\033[?2004h"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
911 {(int)KS_CBD, "\033[?2004l"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
912 {(int)KS_CST, "\033[22;2t"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
913 {(int)KS_CRT, "\033[23;2t"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
914 {(int)KS_SSI, "\033[22;1t"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
915 {(int)KS_SRI, "\033[23;1t"}, |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
916 # if (defined(UNIX) || defined(VMS)) |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
917 {(int)KS_FD, "\033[?1004l"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
918 {(int)KS_FE, "\033[?1004h"}, |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
919 # endif |
180 | 920 |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
921 {K_UP, "\033O*A"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
922 {K_DOWN, "\033O*B"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
923 {K_RIGHT, "\033O*C"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
924 {K_LEFT, "\033O*D"}, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
925 // An extra set of cursor keys for vt100 mode |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
926 {K_XUP, "\033[@;*A"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
927 {K_XDOWN, "\033[@;*B"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
928 {K_XRIGHT, "\033[@;*C"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
929 {K_XLEFT, "\033[@;*D"}, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
930 // An extra set of function keys for vt100 mode |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
931 {K_XF1, "\033O*P"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
932 {K_XF2, "\033O*Q"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
933 {K_XF3, "\033O*R"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
934 {K_XF4, "\033O*S"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
935 {K_F1, "\033[11;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
936 {K_F2, "\033[12;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
937 {K_F3, "\033[13;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
938 {K_F4, "\033[14;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
939 {K_F5, "\033[15;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
940 {K_F6, "\033[17;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
941 {K_F7, "\033[18;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
942 {K_F8, "\033[19;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
943 {K_F9, "\033[20;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
944 {K_F10, "\033[21;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
945 {K_F11, "\033[23;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
946 {K_F12, "\033[24;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
947 {K_S_TAB, "\033[Z"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
948 {K_HELP, "\033[28;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
949 {K_UNDO, "\033[26;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
950 {K_INS, "\033[2;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
951 {K_HOME, "\033[1;*H"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
952 // {K_S_HOME, "\033O2H"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
953 // {K_C_HOME, "\033O5H"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
954 {K_KHOME, "\033[1;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
955 {K_XHOME, "\033O*H"}, // other Home |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
956 {K_ZHOME, "\033[7;*~"}, // other Home |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
957 {K_END, "\033[1;*F"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
958 // {K_S_END, "\033O2F"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
959 // {K_C_END, "\033O5F"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
960 {K_KEND, "\033[4;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
961 {K_XEND, "\033O*F"}, // other End |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
962 {K_ZEND, "\033[8;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
963 {K_PAGEUP, "\033[5;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
964 {K_PAGEDOWN, "\033[6;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
965 {K_KPLUS, "\033O*k"}, // keypad plus |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
966 {K_KMINUS, "\033O*m"}, // keypad minus |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
967 {K_KDIVIDE, "\033O*o"}, // keypad / |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
968 {K_KMULTIPLY, "\033O*j"}, // keypad * |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
969 {K_KENTER, "\033O*M"}, // keypad Enter |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
970 {K_KPOINT, "\033O*n"}, // keypad . |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
971 {K_K0, "\033O*p"}, // keypad 0 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
972 {K_K1, "\033O*q"}, // keypad 1 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
973 {K_K2, "\033O*r"}, // keypad 2 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
974 {K_K3, "\033O*s"}, // keypad 3 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
975 {K_K4, "\033O*t"}, // keypad 4 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
976 {K_K5, "\033O*u"}, // keypad 5 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
977 {K_K6, "\033O*v"}, // keypad 6 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
978 {K_K7, "\033O*w"}, // keypad 7 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
979 {K_K8, "\033O*x"}, // keypad 8 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
980 {K_K9, "\033O*y"}, // keypad 9 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
981 {K_KDEL, "\033[3;*~"}, // keypad Del |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
982 {K_PS, "\033[200~"}, // paste start |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
983 {K_PE, "\033[201~"}, // paste end |
7 | 984 |
985 {BT_EXTRA_KEYS, ""}, | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
986 {TERMCAP2KEY('k', '0'), "\033[10;*~"}, // F0 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
987 {TERMCAP2KEY('F', '3'), "\033[25;*~"}, // F13 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
988 // F14 and F15 are missing, because they send the same codes as the undo |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
989 // and help key, although they don't work on all keyboards. |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
990 {TERMCAP2KEY('F', '6'), "\033[29;*~"}, // F16 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
991 {TERMCAP2KEY('F', '7'), "\033[31;*~"}, // F17 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
992 {TERMCAP2KEY('F', '8'), "\033[32;*~"}, // F18 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
993 {TERMCAP2KEY('F', '9'), "\033[33;*~"}, // F19 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
994 {TERMCAP2KEY('F', 'A'), "\033[34;*~"}, // F20 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
995 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
996 {TERMCAP2KEY('F', 'B'), "\033[42;*~"}, // F21 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
997 {TERMCAP2KEY('F', 'C'), "\033[43;*~"}, // F22 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
998 {TERMCAP2KEY('F', 'D'), "\033[44;*~"}, // F23 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
999 {TERMCAP2KEY('F', 'E'), "\033[45;*~"}, // F24 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
1000 {TERMCAP2KEY('F', 'F'), "\033[46;*~"}, // F25 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
1001 {TERMCAP2KEY('F', 'G'), "\033[47;*~"}, // F26 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
1002 {TERMCAP2KEY('F', 'H'), "\033[48;*~"}, // F27 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
1003 {TERMCAP2KEY('F', 'I'), "\033[49;*~"}, // F28 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
1004 {TERMCAP2KEY('F', 'J'), "\033[50;*~"}, // F29 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
1005 {TERMCAP2KEY('F', 'K'), "\033[51;*~"}, // F30 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
1006 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
1007 {TERMCAP2KEY('F', 'L'), "\033[52;*~"}, // F31 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
1008 {TERMCAP2KEY('F', 'M'), "\033[53;*~"}, // F32 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
1009 {TERMCAP2KEY('F', 'N'), "\033[54;*~"}, // F33 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
1010 {TERMCAP2KEY('F', 'O'), "\033[55;*~"}, // F34 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
1011 {TERMCAP2KEY('F', 'P'), "\033[56;*~"}, // F35 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
1012 {TERMCAP2KEY('F', 'Q'), "\033[57;*~"}, // F36 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
1013 {TERMCAP2KEY('F', 'R'), "\033[58;*~"}, // F37 |
7 | 1014 # endif |
1015 | |
1016 # if defined(UNIX) || defined(ALL_BUILTIN_TCAPS) | |
1017 /* | |
1018 * iris-ansi for Silicon Graphics machines. | |
1019 */ | |
1020 {(int)KS_NAME, "iris-ansi"}, | |
1021 {(int)KS_CE, "\033[K"}, | |
1022 {(int)KS_CD, "\033[J"}, | |
1023 {(int)KS_AL, "\033[L"}, | |
1024 # ifdef TERMINFO | |
1025 {(int)KS_CAL, "\033[%p1%dL"}, | |
1026 # else | |
1027 {(int)KS_CAL, "\033[%dL"}, | |
1028 # endif | |
1029 {(int)KS_DL, "\033[M"}, | |
1030 # ifdef TERMINFO | |
1031 {(int)KS_CDL, "\033[%p1%dM"}, | |
1032 # else | |
1033 {(int)KS_CDL, "\033[%dM"}, | |
1034 # endif | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1035 #if 0 // The scroll region is not working as Vim expects. |
7 | 1036 # ifdef TERMINFO |
1037 {(int)KS_CS, "\033[%i%p1%d;%p2%dr"}, | |
1038 # else | |
1039 {(int)KS_CS, "\033[%i%d;%dr"}, | |
1040 # endif | |
1041 #endif | |
1042 {(int)KS_CL, "\033[H\033[2J"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1043 {(int)KS_VE, "\033[9/y\033[12/y"}, // These aren't documented |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1044 {(int)KS_VS, "\033[10/y\033[=1h\033[=2l"}, // These aren't documented |
7 | 1045 {(int)KS_TI, "\033[=6h"}, |
1046 {(int)KS_TE, "\033[=6l"}, | |
1047 {(int)KS_SE, "\033[21;27m"}, | |
1048 {(int)KS_SO, "\033[1;7m"}, | |
1049 {(int)KS_ME, "\033[m"}, | |
1050 {(int)KS_MR, "\033[7m"}, | |
1051 {(int)KS_MD, "\033[1m"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1052 {(int)KS_CCO, "8"}, // allow 8 colors |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1053 {(int)KS_CZH, "\033[3m"}, // italic mode on |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1054 {(int)KS_CZR, "\033[23m"}, // italic mode off |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1055 {(int)KS_US, "\033[4m"}, // underline on |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1056 {(int)KS_UE, "\033[24m"}, // underline off |
7 | 1057 # ifdef TERMINFO |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1058 {(int)KS_CAB, "\033[4%p1%dm"}, // set background color (ANSI) |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1059 {(int)KS_CAF, "\033[3%p1%dm"}, // set foreground color (ANSI) |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1060 {(int)KS_CSB, "\033[102;%p1%dm"}, // set screen background color |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1061 {(int)KS_CSF, "\033[101;%p1%dm"}, // set screen foreground color |
7 | 1062 # else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1063 {(int)KS_CAB, "\033[4%dm"}, // set background color (ANSI) |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1064 {(int)KS_CAF, "\033[3%dm"}, // set foreground color (ANSI) |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1065 {(int)KS_CSB, "\033[102;%dm"}, // set screen background color |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1066 {(int)KS_CSF, "\033[101;%dm"}, // set screen foreground color |
7 | 1067 # endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1068 {(int)KS_MS, "y"}, // guessed |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1069 {(int)KS_UT, "y"}, // guessed |
7 | 1070 {(int)KS_LE, "\b"}, |
1071 # ifdef TERMINFO | |
1072 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
1073 # else | |
1074 {(int)KS_CM, "\033[%i%d;%dH"}, | |
1075 # endif | |
1076 {(int)KS_SR, "\033M"}, | |
1077 # ifdef TERMINFO | |
1078 {(int)KS_CRI, "\033[%p1%dC"}, | |
1079 # else | |
1080 {(int)KS_CRI, "\033[%dC"}, | |
1081 # endif | |
1082 {(int)KS_CIS, "\033P3.y"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1083 {(int)KS_CIE, "\234"}, // ST "String Terminator" |
7 | 1084 {(int)KS_TS, "\033P1.y"}, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1085 {(int)KS_FS, "\234"}, // ST "String Terminator" |
7 | 1086 # ifdef TERMINFO |
1087 {(int)KS_CWS, "\033[203;%p1%d;%p2%d/y"}, | |
1088 {(int)KS_CWP, "\033[205;%p1%d;%p2%d/y"}, | |
1089 # else | |
1090 {(int)KS_CWS, "\033[203;%d;%d/y"}, | |
1091 {(int)KS_CWP, "\033[205;%d;%d/y"}, | |
1092 # endif | |
1093 {K_UP, "\033[A"}, | |
1094 {K_DOWN, "\033[B"}, | |
1095 {K_LEFT, "\033[D"}, | |
1096 {K_RIGHT, "\033[C"}, | |
1097 {K_S_UP, "\033[161q"}, | |
1098 {K_S_DOWN, "\033[164q"}, | |
1099 {K_S_LEFT, "\033[158q"}, | |
1100 {K_S_RIGHT, "\033[167q"}, | |
1101 {K_F1, "\033[001q"}, | |
1102 {K_F2, "\033[002q"}, | |
1103 {K_F3, "\033[003q"}, | |
1104 {K_F4, "\033[004q"}, | |
1105 {K_F5, "\033[005q"}, | |
1106 {K_F6, "\033[006q"}, | |
1107 {K_F7, "\033[007q"}, | |
1108 {K_F8, "\033[008q"}, | |
1109 {K_F9, "\033[009q"}, | |
1110 {K_F10, "\033[010q"}, | |
1111 {K_F11, "\033[011q"}, | |
1112 {K_F12, "\033[012q"}, | |
1113 {K_S_F1, "\033[013q"}, | |
1114 {K_S_F2, "\033[014q"}, | |
1115 {K_S_F3, "\033[015q"}, | |
1116 {K_S_F4, "\033[016q"}, | |
1117 {K_S_F5, "\033[017q"}, | |
1118 {K_S_F6, "\033[018q"}, | |
1119 {K_S_F7, "\033[019q"}, | |
1120 {K_S_F8, "\033[020q"}, | |
1121 {K_S_F9, "\033[021q"}, | |
1122 {K_S_F10, "\033[022q"}, | |
1123 {K_S_F11, "\033[023q"}, | |
1124 {K_S_F12, "\033[024q"}, | |
1125 {K_INS, "\033[139q"}, | |
1126 {K_HOME, "\033[H"}, | |
1127 {K_END, "\033[146q"}, | |
1128 {K_PAGEUP, "\033[150q"}, | |
1129 {K_PAGEDOWN, "\033[154q"}, | |
1130 # endif | |
1131 | |
1132 # if defined(DEBUG) || defined(ALL_BUILTIN_TCAPS) | |
1133 /* | |
1134 * for debugging | |
1135 */ | |
1136 {(int)KS_NAME, "debug"}, | |
1137 {(int)KS_CE, "[CE]"}, | |
1138 {(int)KS_CD, "[CD]"}, | |
1139 {(int)KS_AL, "[AL]"}, | |
1140 # ifdef TERMINFO | |
1141 {(int)KS_CAL, "[CAL%p1%d]"}, | |
1142 # else | |
1143 {(int)KS_CAL, "[CAL%d]"}, | |
1144 # endif | |
1145 {(int)KS_DL, "[DL]"}, | |
1146 # ifdef TERMINFO | |
1147 {(int)KS_CDL, "[CDL%p1%d]"}, | |
1148 # else | |
1149 {(int)KS_CDL, "[CDL%d]"}, | |
1150 # endif | |
1151 # ifdef TERMINFO | |
1152 {(int)KS_CS, "[%p1%dCS%p2%d]"}, | |
1153 # else | |
1154 {(int)KS_CS, "[%dCS%d]"}, | |
1155 # endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12429
diff
changeset
|
1156 # ifdef TERMINFO |
7 | 1157 {(int)KS_CSV, "[%p1%dCSV%p2%d]"}, |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12429
diff
changeset
|
1158 # else |
7 | 1159 {(int)KS_CSV, "[%dCSV%d]"}, |
1160 # endif | |
1161 # ifdef TERMINFO | |
1162 {(int)KS_CAB, "[CAB%p1%d]"}, | |
1163 {(int)KS_CAF, "[CAF%p1%d]"}, | |
1164 {(int)KS_CSB, "[CSB%p1%d]"}, | |
1165 {(int)KS_CSF, "[CSF%p1%d]"}, | |
1166 # else | |
1167 {(int)KS_CAB, "[CAB%d]"}, | |
1168 {(int)KS_CAF, "[CAF%d]"}, | |
1169 {(int)KS_CSB, "[CSB%d]"}, | |
1170 {(int)KS_CSF, "[CSF%d]"}, | |
1171 # endif | |
20619
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
1172 {(int)KS_CAU, "[CAU%d]"}, |
7 | 1173 {(int)KS_OP, "[OP]"}, |
1174 {(int)KS_LE, "[LE]"}, | |
1175 {(int)KS_CL, "[CL]"}, | |
1176 {(int)KS_VI, "[VI]"}, | |
1177 {(int)KS_VE, "[VE]"}, | |
1178 {(int)KS_VS, "[VS]"}, | |
1179 {(int)KS_ME, "[ME]"}, | |
1180 {(int)KS_MR, "[MR]"}, | |
1181 {(int)KS_MB, "[MB]"}, | |
1182 {(int)KS_MD, "[MD]"}, | |
1183 {(int)KS_SE, "[SE]"}, | |
1184 {(int)KS_SO, "[SO]"}, | |
1185 {(int)KS_UE, "[UE]"}, | |
1186 {(int)KS_US, "[US]"}, | |
205 | 1187 {(int)KS_UCE, "[UCE]"}, |
1188 {(int)KS_UCS, "[UCS]"}, | |
12317
2a8890b80923
patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents:
12307
diff
changeset
|
1189 {(int)KS_STE, "[STE]"}, |
2a8890b80923
patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents:
12307
diff
changeset
|
1190 {(int)KS_STS, "[STS]"}, |
7 | 1191 {(int)KS_MS, "[MS]"}, |
1192 {(int)KS_UT, "[UT]"}, | |
6602 | 1193 {(int)KS_XN, "[XN]"}, |
7 | 1194 # ifdef TERMINFO |
1195 {(int)KS_CM, "[%p1%dCM%p2%d]"}, | |
1196 # else | |
1197 {(int)KS_CM, "[%dCM%d]"}, | |
1198 # endif | |
1199 {(int)KS_SR, "[SR]"}, | |
1200 # ifdef TERMINFO | |
1201 {(int)KS_CRI, "[CRI%p1%d]"}, | |
1202 # else | |
1203 {(int)KS_CRI, "[CRI%d]"}, | |
1204 # endif | |
1205 {(int)KS_VB, "[VB]"}, | |
1206 {(int)KS_KS, "[KS]"}, | |
1207 {(int)KS_KE, "[KE]"}, | |
1208 {(int)KS_TI, "[TI]"}, | |
1209 {(int)KS_TE, "[TE]"}, | |
1210 {(int)KS_CIS, "[CIS]"}, | |
1211 {(int)KS_CIE, "[CIE]"}, | |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
1212 {(int)KS_CSC, "[CSC]"}, |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
1213 {(int)KS_CEC, "[CEC]"}, |
7 | 1214 {(int)KS_TS, "[TS]"}, |
1215 {(int)KS_FS, "[FS]"}, | |
1216 # ifdef TERMINFO | |
1217 {(int)KS_CWS, "[%p1%dCWS%p2%d]"}, | |
1218 {(int)KS_CWP, "[%p1%dCWP%p2%d]"}, | |
1219 # else | |
1220 {(int)KS_CWS, "[%dCWS%d]"}, | |
1221 {(int)KS_CWP, "[%dCWP%d]"}, | |
1222 # endif | |
1223 {(int)KS_CRV, "[CRV]"}, | |
4215 | 1224 {(int)KS_U7, "[U7]"}, |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
1225 {(int)KS_RFG, "[RFG]"}, |
6874 | 1226 {(int)KS_RBG, "[RBG]"}, |
7 | 1227 {K_UP, "[KU]"}, |
1228 {K_DOWN, "[KD]"}, | |
1229 {K_LEFT, "[KL]"}, | |
1230 {K_RIGHT, "[KR]"}, | |
180 | 1231 {K_XUP, "[xKU]"}, |
1232 {K_XDOWN, "[xKD]"}, | |
1233 {K_XLEFT, "[xKL]"}, | |
1234 {K_XRIGHT, "[xKR]"}, | |
7 | 1235 {K_S_UP, "[S-KU]"}, |
1236 {K_S_DOWN, "[S-KD]"}, | |
1237 {K_S_LEFT, "[S-KL]"}, | |
1238 {K_C_LEFT, "[C-KL]"}, | |
1239 {K_S_RIGHT, "[S-KR]"}, | |
1240 {K_C_RIGHT, "[C-KR]"}, | |
1241 {K_F1, "[F1]"}, | |
1242 {K_XF1, "[xF1]"}, | |
1243 {K_F2, "[F2]"}, | |
1244 {K_XF2, "[xF2]"}, | |
1245 {K_F3, "[F3]"}, | |
1246 {K_XF3, "[xF3]"}, | |
1247 {K_F4, "[F4]"}, | |
1248 {K_XF4, "[xF4]"}, | |
1249 {K_F5, "[F5]"}, | |
1250 {K_F6, "[F6]"}, | |
1251 {K_F7, "[F7]"}, | |
1252 {K_F8, "[F8]"}, | |
1253 {K_F9, "[F9]"}, | |
1254 {K_F10, "[F10]"}, | |
1255 {K_F11, "[F11]"}, | |
1256 {K_F12, "[F12]"}, | |
1257 {K_S_F1, "[S-F1]"}, | |
1258 {K_S_XF1, "[S-xF1]"}, | |
1259 {K_S_F2, "[S-F2]"}, | |
1260 {K_S_XF2, "[S-xF2]"}, | |
1261 {K_S_F3, "[S-F3]"}, | |
1262 {K_S_XF3, "[S-xF3]"}, | |
1263 {K_S_F4, "[S-F4]"}, | |
1264 {K_S_XF4, "[S-xF4]"}, | |
1265 {K_S_F5, "[S-F5]"}, | |
1266 {K_S_F6, "[S-F6]"}, | |
1267 {K_S_F7, "[S-F7]"}, | |
1268 {K_S_F8, "[S-F8]"}, | |
1269 {K_S_F9, "[S-F9]"}, | |
1270 {K_S_F10, "[S-F10]"}, | |
1271 {K_S_F11, "[S-F11]"}, | |
1272 {K_S_F12, "[S-F12]"}, | |
1273 {K_HELP, "[HELP]"}, | |
1274 {K_UNDO, "[UNDO]"}, | |
1275 {K_BS, "[BS]"}, | |
1276 {K_INS, "[INS]"}, | |
1277 {K_KINS, "[KINS]"}, | |
1278 {K_DEL, "[DEL]"}, | |
1279 {K_KDEL, "[KDEL]"}, | |
1280 {K_HOME, "[HOME]"}, | |
1281 {K_S_HOME, "[C-HOME]"}, | |
1282 {K_C_HOME, "[C-HOME]"}, | |
1283 {K_KHOME, "[KHOME]"}, | |
1284 {K_XHOME, "[XHOME]"}, | |
230 | 1285 {K_ZHOME, "[ZHOME]"}, |
7 | 1286 {K_END, "[END]"}, |
1287 {K_S_END, "[C-END]"}, | |
1288 {K_C_END, "[C-END]"}, | |
1289 {K_KEND, "[KEND]"}, | |
1290 {K_XEND, "[XEND]"}, | |
230 | 1291 {K_ZEND, "[ZEND]"}, |
7 | 1292 {K_PAGEUP, "[PAGEUP]"}, |
1293 {K_PAGEDOWN, "[PAGEDOWN]"}, | |
1294 {K_KPAGEUP, "[KPAGEUP]"}, | |
1295 {K_KPAGEDOWN, "[KPAGEDOWN]"}, | |
1296 {K_MOUSE, "[MOUSE]"}, | |
1297 {K_KPLUS, "[KPLUS]"}, | |
1298 {K_KMINUS, "[KMINUS]"}, | |
1299 {K_KDIVIDE, "[KDIVIDE]"}, | |
1300 {K_KMULTIPLY, "[KMULTIPLY]"}, | |
1301 {K_KENTER, "[KENTER]"}, | |
1302 {K_KPOINT, "[KPOINT]"}, | |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
1303 {K_PS, "[PASTE-START]"}, |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
1304 {K_PE, "[PASTE-END]"}, |
7 | 1305 {K_K0, "[K0]"}, |
1306 {K_K1, "[K1]"}, | |
1307 {K_K2, "[K2]"}, | |
1308 {K_K3, "[K3]"}, | |
1309 {K_K4, "[K4]"}, | |
1310 {K_K5, "[K5]"}, | |
1311 {K_K6, "[K6]"}, | |
1312 {K_K7, "[K7]"}, | |
1313 {K_K8, "[K8]"}, | |
1314 {K_K9, "[K9]"}, | |
1315 # endif | |
1316 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1317 #endif // NO_BUILTIN_TCAPS |
7 | 1318 |
1319 /* | |
1320 * The most minimal terminal: only clear screen and cursor positioning | |
1321 * Always included. | |
1322 */ | |
1323 {(int)KS_NAME, "dumb"}, | |
1324 {(int)KS_CL, "\014"}, | |
1325 #ifdef TERMINFO | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
1326 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, |
7 | 1327 #else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
1328 {(int)KS_CM, "\033[%i%d;%dH"}, |
7 | 1329 #endif |
1330 | |
1331 /* | |
1332 * end marker | |
1333 */ | |
1334 {(int)KS_NAME, NULL} | |
1335 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1336 }; // end of builtin_termcaps |
7 | 1337 |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1338 #if defined(FEAT_TERMGUICOLORS) || defined(PROTO) |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
1339 static guicolor_T |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1340 termgui_mch_get_color(char_u *name) |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1341 { |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
1342 return gui_get_color_cmn(name); |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1343 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1344 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1345 guicolor_T |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1346 termgui_get_color(char_u *name) |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1347 { |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1348 guicolor_T t; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1349 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1350 if (*name == NUL) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1351 return INVALCOLOR; |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1352 t = termgui_mch_get_color(name); |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1353 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1354 if (t == INVALCOLOR) |
26057
92c424550367
patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
1355 semsg(_(e_cannot_allocate_color_str), name); |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1356 return t; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1357 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1358 |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
1359 guicolor_T |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1360 termgui_mch_get_rgb(guicolor_T color) |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1361 { |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
1362 return color; |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1363 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1364 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1365 |
7 | 1366 /* |
1367 * DEFAULT_TERM is used, when no terminal is specified with -T option or $TERM. | |
1368 */ | |
1369 #ifdef AMIGA | |
1370 # define DEFAULT_TERM (char_u *)"amiga" | |
1371 #endif | |
1372 | |
1373 #ifdef MSWIN | |
1374 # define DEFAULT_TERM (char_u *)"win32" | |
1375 #endif | |
1376 | |
21329
bb3f60b0aca0
patch 8.2.1215: Atari MiNT support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
21226
diff
changeset
|
1377 #if defined(UNIX) |
7 | 1378 # define DEFAULT_TERM (char_u *)"ansi" |
1379 #endif | |
1380 | |
1381 #ifdef VMS | |
1382 # define DEFAULT_TERM (char_u *)"vt320" | |
1383 #endif | |
1384 | |
19526
22f0dda71638
patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
19489
diff
changeset
|
1385 #ifdef __HAIKU__ |
22f0dda71638
patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
19489
diff
changeset
|
1386 # undef DEFAULT_TERM |
22f0dda71638
patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
19489
diff
changeset
|
1387 # define DEFAULT_TERM (char_u *)"xterm" |
22f0dda71638
patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
19489
diff
changeset
|
1388 #endif |
22f0dda71638
patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
19489
diff
changeset
|
1389 |
7 | 1390 #ifndef DEFAULT_TERM |
1391 # define DEFAULT_TERM (char_u *)"dumb" | |
1392 #endif | |
1393 | |
1394 /* | |
1395 * Term_strings contains currently used terminal output strings. | |
1396 * It is initialized with the default values by parse_builtin_tcap(). | |
1397 * The values can be changed by setting the option with the same name. | |
1398 */ | |
1399 char_u *(term_strings[(int)KS_LAST + 1]); | |
1400 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1401 static int need_gather = FALSE; // need to fill termleader[] |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1402 static char_u termleader[256 + 1]; // for check_termcode() |
7 | 1403 #ifdef FEAT_TERMRESPONSE |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1404 static int check_for_codes = FALSE; // check for key code response |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1405 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1406 /* |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1407 * Structure and table to store terminal features that can be detected by |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1408 * querying the terminal. Either by inspecting the termresponse or a more |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1409 * specific request. Besides this there are: |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1410 * t_colors - number of colors supported |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1411 */ |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1412 typedef struct { |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1413 char *tpr_name; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1414 int tpr_set_by_termresponse; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1415 int tpr_status; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1416 } termprop_T; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1417 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1418 // Values for tpr_status. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1419 #define TPR_UNKNOWN 'u' |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1420 #define TPR_YES 'y' |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1421 #define TPR_NO 'n' |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1422 #define TPR_MOUSE_XTERM 'x' // use "xterm" for 'ttymouse' |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1423 #define TPR_MOUSE_XTERM2 '2' // use "xterm2" for 'ttymouse' |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1424 #define TPR_MOUSE_SGR 's' // use "sgr" for 'ttymouse' |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1425 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1426 // can request the cursor style without messing up the display |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1427 #define TPR_CURSOR_STYLE 0 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1428 // can request the cursor blink mode without messing up the display |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1429 #define TPR_CURSOR_BLINK 1 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1430 // can set the underline color with t_8u without resetting other colors |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1431 #define TPR_UNDERLINE_RGB 2 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1432 // mouse support - TPR_MOUSE_XTERM, TPR_MOUSE_XTERM2 or TPR_MOUSE_SGR |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1433 #define TPR_MOUSE 3 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1434 // table size |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1435 #define TPR_COUNT 4 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1436 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1437 static termprop_T term_props[TPR_COUNT]; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1438 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1439 /* |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1440 * Initialize the term_props table. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1441 * When "all" is FALSE only set those that are detected from the version |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1442 * response. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1443 */ |
20836
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1444 void |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1445 init_term_props(int all) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1446 { |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1447 int i; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1448 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1449 term_props[TPR_CURSOR_STYLE].tpr_name = "cursor_style"; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1450 term_props[TPR_CURSOR_STYLE].tpr_set_by_termresponse = FALSE; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1451 term_props[TPR_CURSOR_BLINK].tpr_name = "cursor_blink_mode"; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1452 term_props[TPR_CURSOR_BLINK].tpr_set_by_termresponse = FALSE; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1453 term_props[TPR_UNDERLINE_RGB].tpr_name = "underline_rgb"; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1454 term_props[TPR_UNDERLINE_RGB].tpr_set_by_termresponse = TRUE; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1455 term_props[TPR_MOUSE].tpr_name = "mouse"; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1456 term_props[TPR_MOUSE].tpr_set_by_termresponse = TRUE; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1457 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1458 for (i = 0; i < TPR_COUNT; ++i) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1459 if (all || term_props[i].tpr_set_by_termresponse) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1460 term_props[i].tpr_status = TPR_UNKNOWN; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1461 } |
7 | 1462 #endif |
1463 | |
20836
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1464 #if defined(FEAT_EVAL) || defined(PROTO) |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1465 void |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1466 f_terminalprops(typval_T *argvars UNUSED, typval_T *rettv) |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1467 { |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1468 # ifdef FEAT_TERMRESPONSE |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1469 int i; |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1470 # endif |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1471 |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1472 if (rettv_dict_alloc(rettv) != OK) |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1473 return; |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1474 # ifdef FEAT_TERMRESPONSE |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1475 for (i = 0; i < TPR_COUNT; ++i) |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1476 { |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1477 char_u value[2]; |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1478 |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1479 value[0] = term_props[i].tpr_status; |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1480 value[1] = NUL; |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1481 dict_add_string(rettv->vval.v_dict, term_props[i].tpr_name, value); |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1482 } |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1483 # endif |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1484 } |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1485 #endif |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1486 |
7 | 1487 static struct builtin_term * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1488 find_builtin_term(char_u *term) |
7 | 1489 { |
1490 struct builtin_term *p; | |
1491 | |
1492 p = builtin_termcaps; | |
1493 while (p->bt_string != NULL) | |
1494 { | |
1495 if (p->bt_entry == (int)KS_NAME) | |
1496 { | |
1497 #ifdef UNIX | |
1498 if (STRCMP(p->bt_string, "iris-ansi") == 0 && vim_is_iris(term)) | |
1499 return p; | |
1500 else if (STRCMP(p->bt_string, "xterm") == 0 && vim_is_xterm(term)) | |
1501 return p; | |
1502 else | |
1503 #endif | |
1504 #ifdef VMS | |
1505 if (STRCMP(p->bt_string, "vt320") == 0 && vim_is_vt300(term)) | |
1506 return p; | |
1507 else | |
1508 #endif | |
1509 if (STRCMP(term, p->bt_string) == 0) | |
1510 return p; | |
1511 } | |
1512 ++p; | |
1513 } | |
1514 return p; | |
1515 } | |
1516 | |
1517 /* | |
1518 * Parsing of the builtin termcap entries. | |
1519 * Caller should check if 'name' is a valid builtin term. | |
1520 * The terminal's name is not set, as this is already done in termcapinit(). | |
1521 */ | |
1522 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1523 parse_builtin_tcap(char_u *term) |
7 | 1524 { |
1525 struct builtin_term *p; | |
1526 char_u name[2]; | |
1527 int term_8bit; | |
1528 | |
1529 p = find_builtin_term(term); | |
1530 term_8bit = term_is_8bit(term); | |
1531 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1532 // Do not parse if builtin term not found |
7 | 1533 if (p->bt_string == NULL) |
1534 return; | |
1535 | |
1536 for (++p; p->bt_entry != (int)KS_NAME && p->bt_entry != BT_EXTRA_KEYS; ++p) | |
1537 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1538 if ((int)p->bt_entry >= 0) // KS_xx entry |
7 | 1539 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1540 // Only set the value if it wasn't set yet. |
7 | 1541 if (term_strings[p->bt_entry] == NULL |
1542 || term_strings[p->bt_entry] == empty_option) | |
1543 { | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1544 #ifdef FEAT_EVAL |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1545 int opt_idx = -1; |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1546 #endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1547 // 8bit terminal: use CSI instead of <Esc>[ |
7 | 1548 if (term_8bit && term_7to8bit((char_u *)p->bt_string) != 0) |
1549 { | |
1550 char_u *s, *t; | |
1551 | |
1552 s = vim_strsave((char_u *)p->bt_string); | |
1553 if (s != NULL) | |
1554 { | |
1555 for (t = s; *t; ++t) | |
1556 if (term_7to8bit(t)) | |
1557 { | |
1558 *t = term_7to8bit(t); | |
14321
6bcac243b9de
patch 8.1.0176: overlapping string argument for strcpy()
Christian Brabandt <cb@256bit.org>
parents:
14282
diff
changeset
|
1559 STRMOVE(t + 1, t + 2); |
7 | 1560 } |
1561 term_strings[p->bt_entry] = s; | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1562 #ifdef FEAT_EVAL |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1563 opt_idx = |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1564 #endif |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1565 set_term_option_alloced( |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1566 &term_strings[p->bt_entry]); |
7 | 1567 } |
1568 } | |
1569 else | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1570 { |
7 | 1571 term_strings[p->bt_entry] = (char_u *)p->bt_string; |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1572 #ifdef FEAT_EVAL |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1573 opt_idx = get_term_opt_idx(&term_strings[p->bt_entry]); |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1574 #endif |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1575 } |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1576 #ifdef FEAT_EVAL |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1577 set_term_option_sctx_idx(NULL, opt_idx); |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1578 #endif |
7 | 1579 } |
1580 } | |
1581 else | |
1582 { | |
1583 name[0] = KEY2TERMCAP0((int)p->bt_entry); | |
1584 name[1] = KEY2TERMCAP1((int)p->bt_entry); | |
1585 if (find_termcode(name) == NULL) | |
1586 add_termcode(name, (char_u *)p->bt_string, term_8bit); | |
1587 } | |
1588 } | |
1589 } | |
11739
5c69c6d9e2eb
patch 8.0.0752: build fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11731
diff
changeset
|
1590 |
7 | 1591 /* |
1592 * Set number of colors. | |
1593 * Store it as a number in t_colors. | |
1594 * Store it as a string in T_CCO (using nr_colors[]). | |
1595 */ | |
19997
3d1de9093c01
patch 8.2.0554: the GUI doesn't set t_Co
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
1596 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1597 set_color_count(int nr) |
7 | 1598 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1599 char_u nr_colors[20]; // string for number of colors |
7 | 1600 |
1601 t_colors = nr; | |
1602 if (t_colors > 1) | |
1603 sprintf((char *)nr_colors, "%d", t_colors); | |
1604 else | |
1605 *nr_colors = NUL; | |
694 | 1606 set_string_option_direct((char_u *)"t_Co", -1, nr_colors, OPT_FREE, 0); |
7 | 1607 } |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1608 |
11739
5c69c6d9e2eb
patch 8.0.0752: build fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11731
diff
changeset
|
1609 #if defined(FEAT_TERMRESPONSE) |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1610 /* |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1611 * Set the color count to "val" and redraw if it changed. |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1612 */ |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1613 static void |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1614 may_adjust_color_count(int val) |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1615 { |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1616 if (val != t_colors) |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1617 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1618 // Nr of colors changed, initialize highlighting and |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1619 // redraw everything. This causes a redraw, which usually |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1620 // clears the message. Try keeping the message if it |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1621 // might work. |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1622 set_keep_msg_from_hist(); |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1623 set_color_count(val); |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1624 init_highlight(TRUE, FALSE); |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1625 # ifdef DEBUG_TERMRESPONSE |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1626 { |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
1627 int r = redraw_asap(CLEAR); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
1628 |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
1629 log_tr("Received t_Co, redraw_asap(): %d", r); |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1630 } |
20524
bed30e6b5a09
patch 8.2.0816: terminal test fails when compiled with Athena
Bram Moolenaar <Bram@vim.org>
parents:
20500
diff
changeset
|
1631 # else |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1632 redraw_asap(CLEAR); |
20524
bed30e6b5a09
patch 8.2.0816: terminal test fails when compiled with Athena
Bram Moolenaar <Bram@vim.org>
parents:
20500
diff
changeset
|
1633 # endif |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1634 } |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1635 } |
7 | 1636 #endif |
1637 | |
1638 #ifdef HAVE_TGETENT | |
1639 static char *(key_names[]) = | |
1640 { | |
20524
bed30e6b5a09
patch 8.2.0816: terminal test fails when compiled with Athena
Bram Moolenaar <Bram@vim.org>
parents:
20500
diff
changeset
|
1641 # ifdef FEAT_TERMRESPONSE |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1642 // Do this one first, it may cause a screen redraw. |
7 | 1643 "Co", |
20524
bed30e6b5a09
patch 8.2.0816: terminal test fails when compiled with Athena
Bram Moolenaar <Bram@vim.org>
parents:
20500
diff
changeset
|
1644 # endif |
7 | 1645 "ku", "kd", "kr", "kl", |
1646 "#2", "#4", "%i", "*7", | |
1647 "k1", "k2", "k3", "k4", "k5", "k6", | |
1648 "k7", "k8", "k9", "k;", "F1", "F2", | |
1649 "%1", "&8", "kb", "kI", "kD", "kh", | |
1650 "@7", "kP", "kN", "K1", "K3", "K4", "K5", "kB", | |
1651 NULL | |
1652 }; | |
1653 #endif | |
1654 | |
13874
fc2f175e8169
patch 8.0.1808: can't build without TGETENT
Christian Brabandt <cb@256bit.org>
parents:
13872
diff
changeset
|
1655 #ifdef HAVE_TGETENT |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1656 static void |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1657 get_term_entries(int *height, int *width) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1658 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1659 static struct { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1660 enum SpecialKey dest; // index in term_strings[] |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1661 char *name; // termcap name for string |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1662 } string_names[] = |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1663 { {KS_CE, "ce"}, {KS_AL, "al"}, {KS_CAL,"AL"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1664 {KS_DL, "dl"}, {KS_CDL,"DL"}, {KS_CS, "cs"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1665 {KS_CL, "cl"}, {KS_CD, "cd"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1666 {KS_VI, "vi"}, {KS_VE, "ve"}, {KS_MB, "mb"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1667 {KS_ME, "me"}, {KS_MR, "mr"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1668 {KS_MD, "md"}, {KS_SE, "se"}, {KS_SO, "so"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1669 {KS_CZH,"ZH"}, {KS_CZR,"ZR"}, {KS_UE, "ue"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1670 {KS_US, "us"}, {KS_UCE, "Ce"}, {KS_UCS, "Cs"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1671 {KS_STE,"Te"}, {KS_STS,"Ts"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1672 {KS_CM, "cm"}, {KS_SR, "sr"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1673 {KS_CRI,"RI"}, {KS_VB, "vb"}, {KS_KS, "ks"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1674 {KS_KE, "ke"}, {KS_TI, "ti"}, {KS_TE, "te"}, |
18299
a9cf41bcb5d6
patch 8.1.2144: side effects when using t_ti to enable modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18295
diff
changeset
|
1675 {KS_CTI, "TI"}, {KS_CTE, "TE"}, |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1676 {KS_BC, "bc"}, {KS_CSB,"Sb"}, {KS_CSF,"Sf"}, |
20619
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
1677 {KS_CAB,"AB"}, {KS_CAF,"AF"}, {KS_CAU,"AU"}, |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
1678 {KS_LE, "le"}, |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1679 {KS_ND, "nd"}, {KS_OP, "op"}, {KS_CRV, "RV"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1680 {KS_VS, "vs"}, {KS_CVS, "VS"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1681 {KS_CIS, "IS"}, {KS_CIE, "IE"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1682 {KS_CSC, "SC"}, {KS_CEC, "EC"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1683 {KS_TS, "ts"}, {KS_FS, "fs"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1684 {KS_CWP, "WP"}, {KS_CWS, "WS"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1685 {KS_CSI, "SI"}, {KS_CEI, "EI"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1686 {KS_U7, "u7"}, {KS_RFG, "RF"}, {KS_RBG, "RB"}, |
20619
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
1687 {KS_8F, "8f"}, {KS_8B, "8b"}, {KS_8U, "8u"}, |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1688 {KS_CBE, "BE"}, {KS_CBD, "BD"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1689 {KS_CPS, "PS"}, {KS_CPE, "PE"}, |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
1690 {KS_CST, "ST"}, {KS_CRT, "RT"}, |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
1691 {KS_SSI, "Si"}, {KS_SRI, "Ri"}, |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1692 {(enum SpecialKey)0, NULL} |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1693 }; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1694 int i; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1695 char_u *p; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1696 static char_u tstrbuf[TBUFSZ]; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1697 char_u *tp = tstrbuf; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1698 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1699 /* |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1700 * get output strings |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1701 */ |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1702 for (i = 0; string_names[i].name != NULL; ++i) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1703 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1704 if (TERM_STR(string_names[i].dest) == NULL |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1705 || TERM_STR(string_names[i].dest) == empty_option) |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1706 { |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1707 TERM_STR(string_names[i].dest) = TGETSTR(string_names[i].name, &tp); |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1708 #ifdef FEAT_EVAL |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1709 set_term_option_sctx_idx(string_names[i].name, -1); |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1710 #endif |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1711 } |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1712 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1713 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1714 // tgetflag() returns 1 if the flag is present, 0 if not and |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1715 // possibly -1 if the flag doesn't exist. |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1716 if ((T_MS == NULL || T_MS == empty_option) && tgetflag("ms") > 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1717 T_MS = (char_u *)"y"; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1718 if ((T_XS == NULL || T_XS == empty_option) && tgetflag("xs") > 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1719 T_XS = (char_u *)"y"; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1720 if ((T_XN == NULL || T_XN == empty_option) && tgetflag("xn") > 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1721 T_XN = (char_u *)"y"; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1722 if ((T_DB == NULL || T_DB == empty_option) && tgetflag("db") > 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1723 T_DB = (char_u *)"y"; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1724 if ((T_DA == NULL || T_DA == empty_option) && tgetflag("da") > 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1725 T_DA = (char_u *)"y"; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1726 if ((T_UT == NULL || T_UT == empty_option) && tgetflag("ut") > 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1727 T_UT = (char_u *)"y"; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1728 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1729 /* |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1730 * get key codes |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1731 */ |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1732 for (i = 0; key_names[i] != NULL; ++i) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1733 if (find_termcode((char_u *)key_names[i]) == NULL) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1734 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1735 p = TGETSTR(key_names[i], &tp); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1736 // if cursor-left == backspace, ignore it (televideo 925) |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1737 if (p != NULL |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1738 && (*p != Ctrl_H |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1739 || key_names[i][0] != 'k' |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1740 || key_names[i][1] != 'l')) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1741 add_termcode((char_u *)key_names[i], p, FALSE); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1742 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1743 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1744 if (*height == 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1745 *height = tgetnum("li"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1746 if (*width == 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1747 *width = tgetnum("co"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1748 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1749 /* |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1750 * Get number of colors (if not done already). |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1751 */ |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1752 if (TERM_STR(KS_CCO) == NULL || TERM_STR(KS_CCO) == empty_option) |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1753 { |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1754 set_color_count(tgetnum("Co")); |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1755 #ifdef FEAT_EVAL |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1756 set_term_option_sctx_idx("Co", -1); |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1757 #endif |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1758 } |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1759 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1760 # ifndef hpux |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1761 BC = (char *)TGETSTR("bc", &tp); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1762 UP = (char *)TGETSTR("up", &tp); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1763 p = TGETSTR("pc", &tp); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1764 if (p) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1765 PC = *p; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1766 # endif |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1767 } |
13874
fc2f175e8169
patch 8.0.1808: can't build without TGETENT
Christian Brabandt <cb@256bit.org>
parents:
13872
diff
changeset
|
1768 #endif |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1769 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1770 static void |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
1771 report_term_error(char *error_msg, char_u *term) |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1772 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1773 struct builtin_term *termp; |
21624
1d75baa22d9a
patch 8.2.1362: last entry of ":set term=xxx" overwritten by error message
Bram Moolenaar <Bram@vim.org>
parents:
21329
diff
changeset
|
1774 int i; |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1775 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1776 mch_errmsg("\r\n"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1777 if (error_msg != NULL) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1778 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
1779 mch_errmsg(error_msg); |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1780 mch_errmsg("\r\n"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1781 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1782 mch_errmsg("'"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1783 mch_errmsg((char *)term); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1784 mch_errmsg(_("' not known. Available builtin terminals are:")); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1785 mch_errmsg("\r\n"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1786 for (termp = &(builtin_termcaps[0]); termp->bt_string != NULL; ++termp) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1787 { |
25429
2aefea114696
patch 8.2.3251: listing builtin_gui as an available terminal is confusing
Bram Moolenaar <Bram@vim.org>
parents:
24850
diff
changeset
|
1788 if (termp->bt_entry == (int)KS_NAME |
2aefea114696
patch 8.2.3251: listing builtin_gui as an available terminal is confusing
Bram Moolenaar <Bram@vim.org>
parents:
24850
diff
changeset
|
1789 && STRCMP(termp->bt_string, "gui") != 0) |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1790 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1791 #ifdef HAVE_TGETENT |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1792 mch_errmsg(" builtin_"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1793 #else |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1794 mch_errmsg(" "); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1795 #endif |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1796 mch_errmsg(termp->bt_string); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1797 mch_errmsg("\r\n"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1798 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1799 } |
21624
1d75baa22d9a
patch 8.2.1362: last entry of ":set term=xxx" overwritten by error message
Bram Moolenaar <Bram@vim.org>
parents:
21329
diff
changeset
|
1800 // Output extra 'cmdheight' line breaks to avoid that the following error |
1d75baa22d9a
patch 8.2.1362: last entry of ":set term=xxx" overwritten by error message
Bram Moolenaar <Bram@vim.org>
parents:
21329
diff
changeset
|
1801 // message overwrites the last terminal name. |
1d75baa22d9a
patch 8.2.1362: last entry of ":set term=xxx" overwritten by error message
Bram Moolenaar <Bram@vim.org>
parents:
21329
diff
changeset
|
1802 for (i = 1; i < p_ch; ++i) |
1d75baa22d9a
patch 8.2.1362: last entry of ":set term=xxx" overwritten by error message
Bram Moolenaar <Bram@vim.org>
parents:
21329
diff
changeset
|
1803 mch_errmsg("\r\n"); |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1804 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1805 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1806 static void |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1807 report_default_term(char_u *term) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1808 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1809 mch_errmsg(_("defaulting to '")); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1810 mch_errmsg((char *)term); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1811 mch_errmsg("'\r\n"); |
22742
f7f2d73ff85e
patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Bram Moolenaar <Bram@vim.org>
parents:
22522
diff
changeset
|
1812 if (emsg_silent == 0 && !in_assert_fails) |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1813 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1814 screen_start(); // don't know where cursor is now |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1815 out_flush(); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1816 if (!is_not_a_term()) |
18642
bbea1f108187
patch 8.1.2313: debugging where a delay comes from is not easy
Bram Moolenaar <Bram@vim.org>
parents:
18430
diff
changeset
|
1817 ui_delay(2007L, TRUE); |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1818 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1819 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1820 |
7 | 1821 /* |
1822 * Set terminal options for terminal "term". | |
1823 * Return OK if terminal 'term' was found in a termcap, FAIL otherwise. | |
1824 * | |
1825 * While doing this, until ttest(), some options may be NULL, be careful. | |
1826 */ | |
1827 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1828 set_termname(char_u *term) |
7 | 1829 { |
1830 struct builtin_term *termp; | |
1831 #ifdef HAVE_TGETENT | |
1832 int builtin_first = p_tbi; | |
1833 int try; | |
1834 int termcap_cleared = FALSE; | |
1835 #endif | |
1836 int width = 0, height = 0; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
1837 char *error_msg = NULL; |
7 | 1838 char_u *bs_p, *del_p; |
1839 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1840 // In silect mode (ex -s) we don't use the 'term' option. |
168 | 1841 if (silent_mode) |
1842 return OK; | |
1843 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1844 detected_8bit = FALSE; // reset 8-bit detection |
7 | 1845 |
1846 if (term_is_builtin(term)) | |
1847 { | |
1848 term += 8; | |
1849 #ifdef HAVE_TGETENT | |
1850 builtin_first = 1; | |
1851 #endif | |
1852 } | |
1853 | |
1854 /* | |
1855 * If HAVE_TGETENT is not defined, only the builtin termcap is used, otherwise: | |
1856 * If builtin_first is TRUE: | |
1857 * 0. try builtin termcap | |
1858 * 1. try external termcap | |
1859 * 2. if both fail default to a builtin terminal | |
1860 * If builtin_first is FALSE: | |
1861 * 1. try external termcap | |
1862 * 2. try builtin termcap, if both fail default to a builtin terminal | |
1863 */ | |
1864 #ifdef HAVE_TGETENT | |
1865 for (try = builtin_first ? 0 : 1; try < 3; ++try) | |
1866 { | |
1867 /* | |
1868 * Use external termcap | |
1869 */ | |
1870 if (try == 1) | |
1871 { | |
1872 char_u tbuf[TBUFSZ]; | |
1873 | |
1874 /* | |
1875 * If the external termcap does not have a matching entry, try the | |
1876 * builtin ones. | |
1877 */ | |
1878 if ((error_msg = tgetent_error(tbuf, term)) == NULL) | |
1879 { | |
1880 if (!termcap_cleared) | |
1881 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1882 clear_termoptions(); // clear old options |
7 | 1883 termcap_cleared = TRUE; |
1884 } | |
1885 | |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1886 get_term_entries(&height, &width); |
7 | 1887 } |
1888 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1889 else // try == 0 || try == 2 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1890 #endif // HAVE_TGETENT |
7 | 1891 /* |
1892 * Use builtin termcap | |
1893 */ | |
1894 { | |
1895 #ifdef HAVE_TGETENT | |
1896 /* | |
1897 * If builtin termcap was already used, there is no need to search | |
1898 * for the builtin termcap again, quit now. | |
1899 */ | |
1900 if (try == 2 && builtin_first && termcap_cleared) | |
1901 break; | |
1902 #endif | |
1903 /* | |
1904 * search for 'term' in builtin_termcaps[] | |
1905 */ | |
1906 termp = find_builtin_term(term); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1907 if (termp->bt_string == NULL) // did not find it |
7 | 1908 { |
1909 #ifdef HAVE_TGETENT | |
1910 /* | |
1911 * If try == 0, first try the external termcap. If that is not | |
1912 * found we'll get back here with try == 2. | |
1913 * If termcap_cleared is set we used the external termcap, | |
1914 * don't complain about not finding the term in the builtin | |
1915 * termcap. | |
1916 */ | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1917 if (try == 0) // try external one |
7 | 1918 continue; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1919 if (termcap_cleared) // found in external termcap |
7 | 1920 break; |
1921 #endif | |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1922 report_term_error(error_msg, term); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1923 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1924 // when user typed :set term=xxx, quit here |
7 | 1925 if (starting != NO_SCREEN) |
1926 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1927 screen_start(); // don't know where cursor is now |
7 | 1928 wait_return(TRUE); |
1929 return FAIL; | |
1930 } | |
1931 term = DEFAULT_TERM; | |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1932 report_default_term(term); |
694 | 1933 set_string_option_direct((char_u *)"term", -1, term, |
1934 OPT_FREE, 0); | |
7 | 1935 display_errors(); |
1936 } | |
1937 out_flush(); | |
1938 #ifdef HAVE_TGETENT | |
1939 if (!termcap_cleared) | |
1940 { | |
1941 #endif | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1942 clear_termoptions(); // clear old options |
7 | 1943 #ifdef HAVE_TGETENT |
1944 termcap_cleared = TRUE; | |
1945 } | |
1946 #endif | |
1947 parse_builtin_tcap(term); | |
1948 #ifdef FEAT_GUI | |
1949 if (term_is_gui(term)) | |
1950 { | |
1951 out_flush(); | |
1952 gui_init(); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1953 // If starting the GUI failed, don't do any of the other |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1954 // things for this terminal |
7 | 1955 if (!gui.in_use) |
1956 return FAIL; | |
1957 #ifdef HAVE_TGETENT | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1958 break; // don't try using external termcap |
7 | 1959 #endif |
1960 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1961 #endif // FEAT_GUI |
7 | 1962 } |
1963 #ifdef HAVE_TGETENT | |
1964 } | |
1965 #endif | |
1966 | |
1967 /* | |
1968 * special: There is no info in the termcap about whether the cursor | |
1969 * positioning is relative to the start of the screen or to the start of the | |
1970 * scrolling region. We just guess here. Only msdos pcterm is known to do it | |
1971 * relative. | |
1972 */ | |
1973 if (STRCMP(term, "pcterm") == 0) | |
1974 T_CCS = (char_u *)"yes"; | |
1975 else | |
1976 T_CCS = empty_option; | |
1977 | |
1978 #ifdef UNIX | |
1979 /* | |
1980 * Any "stty" settings override the default for t_kb from the termcap. | |
1981 * This is in os_unix.c, because it depends a lot on the version of unix that | |
1982 * is being used. | |
1983 * Don't do this when the GUI is active, it uses "t_kb" and "t_kD" directly. | |
1984 */ | |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
1985 # ifdef FEAT_GUI |
7 | 1986 if (!gui.in_use) |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
1987 # endif |
7 | 1988 get_stty(); |
1989 #endif | |
1990 | |
1991 /* | |
1992 * If the termcap has no entry for 'bs' and/or 'del' and the ioctl() also | |
1993 * didn't work, use the default CTRL-H | |
1994 * The default for t_kD is DEL, unless t_kb is DEL. | |
1995 * The vim_strsave'd strings are probably lost forever, well it's only two | |
1996 * bytes. Don't do this when the GUI is active, it uses "t_kb" and "t_kD" | |
1997 * directly. | |
1998 */ | |
1999 #ifdef FEAT_GUI | |
2000 if (!gui.in_use) | |
2001 #endif | |
2002 { | |
2003 bs_p = find_termcode((char_u *)"kb"); | |
2004 del_p = find_termcode((char_u *)"kD"); | |
2005 if (bs_p == NULL || *bs_p == NUL) | |
2006 add_termcode((char_u *)"kb", (bs_p = (char_u *)CTRL_H_STR), FALSE); | |
2007 if ((del_p == NULL || *del_p == NUL) && | |
2008 (bs_p == NULL || *bs_p != DEL)) | |
2009 add_termcode((char_u *)"kD", (char_u *)DEL_STR, FALSE); | |
2010 } | |
2011 | |
2012 #if defined(UNIX) || defined(VMS) | |
2013 term_is_xterm = vim_is_xterm(term); | |
2014 #endif | |
18352
94e1a49b879e
patch 8.1.2170: cannot build without the +termresponse feature
Bram Moolenaar <Bram@vim.org>
parents:
18350
diff
changeset
|
2015 #ifdef FEAT_TERMRESPONSE |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
2016 // Reset terminal properties that are set based on the termresponse, which |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
2017 // will be sent out soon. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
2018 init_term_props(FALSE); |
18352
94e1a49b879e
patch 8.1.2170: cannot build without the +termresponse feature
Bram Moolenaar <Bram@vim.org>
parents:
18350
diff
changeset
|
2019 #endif |
7 | 2020 |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
2021 #if defined(UNIX) || defined(VMS) |
7 | 2022 /* |
2023 * For Unix, set the 'ttymouse' option to the type of mouse to be used. | |
2024 * The termcode for the mouse is added as a side effect in option.c. | |
2025 */ | |
2026 { | |
11563
2547bbe6716e
patch 8.0.0664: mouse does not work in tmux
Christian Brabandt <cb@256bit.org>
parents:
11557
diff
changeset
|
2027 char_u *p = (char_u *)""; |
2547bbe6716e
patch 8.0.0664: mouse does not work in tmux
Christian Brabandt <cb@256bit.org>
parents:
11557
diff
changeset
|
2028 |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
2029 # ifdef FEAT_MOUSE_XTERM |
1623 | 2030 if (use_xterm_like_mouse(term)) |
7 | 2031 { |
2032 if (use_xterm_mouse()) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2033 p = NULL; // keep existing value, might be "xterm2" |
7 | 2034 else |
2035 p = (char_u *)"xterm"; | |
2036 } | |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
2037 # endif |
7 | 2038 if (p != NULL) |
3980 | 2039 { |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28453
diff
changeset
|
2040 set_option_value_give_err((char_u *)"ttym", 0L, p, 0); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2041 // Reset the WAS_SET flag, 'ttymouse' can be set to "sgr" or |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2042 // "xterm2" in check_termcode(). |
3980 | 2043 reset_option_was_set((char_u *)"ttym"); |
2044 } | |
7 | 2045 if (p == NULL |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
2046 # ifdef FEAT_GUI |
7 | 2047 || gui.in_use |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
2048 # endif |
7 | 2049 ) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2050 check_mouse_termcode(); // set mouse termcode anyway |
7 | 2051 } |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
2052 #else |
7 | 2053 set_mouse_termcode(KS_MOUSE, (char_u *)"\233M"); |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
2054 #endif |
7 | 2055 |
23632
8da1d91d751c
patch 8.2.2358: wrong #ifdef for use_xterm_like_mouse()
Bram Moolenaar <Bram@vim.org>
parents:
23620
diff
changeset
|
2056 #ifdef FEAT_MOUSE_XTERM |
27930
1a702abffaf3
patch 8.2.4490: terminal focus reporting only works for xterm-like terminals
Bram Moolenaar <Bram@vim.org>
parents:
27684
diff
changeset
|
2057 // Focus reporting is supported by xterm compatible terminals and tmux. |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2058 if (use_xterm_like_mouse(term)) |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2059 { |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2060 char_u name[3]; |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2061 |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2062 // handle focus in event |
23632
8da1d91d751c
patch 8.2.2358: wrong #ifdef for use_xterm_like_mouse()
Bram Moolenaar <Bram@vim.org>
parents:
23620
diff
changeset
|
2063 name[0] = KS_EXTRA; |
8da1d91d751c
patch 8.2.2358: wrong #ifdef for use_xterm_like_mouse()
Bram Moolenaar <Bram@vim.org>
parents:
23620
diff
changeset
|
2064 name[1] = KE_FOCUSGAINED; |
8da1d91d751c
patch 8.2.2358: wrong #ifdef for use_xterm_like_mouse()
Bram Moolenaar <Bram@vim.org>
parents:
23620
diff
changeset
|
2065 name[2] = NUL; |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2066 add_termcode(name, (char_u *)"\033[I", FALSE); |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2067 |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2068 // handle focus out event |
23632
8da1d91d751c
patch 8.2.2358: wrong #ifdef for use_xterm_like_mouse()
Bram Moolenaar <Bram@vim.org>
parents:
23620
diff
changeset
|
2069 name[1] = KE_FOCUSLOST; |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2070 add_termcode(name, (char_u *)"\033[O", FALSE); |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2071 |
24045
1b56d4c75d19
patch 8.2.2564: focus events end Insert mode if 'esckeys' is not set
Bram Moolenaar <Bram@vim.org>
parents:
23774
diff
changeset
|
2072 need_gather = TRUE; |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2073 } |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2074 #endif |
27930
1a702abffaf3
patch 8.2.4490: terminal focus reporting only works for xterm-like terminals
Bram Moolenaar <Bram@vim.org>
parents:
27684
diff
changeset
|
2075 #if (defined(UNIX) || defined(VMS)) |
1a702abffaf3
patch 8.2.4490: terminal focus reporting only works for xterm-like terminals
Bram Moolenaar <Bram@vim.org>
parents:
27684
diff
changeset
|
2076 // First time after setting 'term' a focus event is always reported. |
1a702abffaf3
patch 8.2.4490: terminal focus reporting only works for xterm-like terminals
Bram Moolenaar <Bram@vim.org>
parents:
27684
diff
changeset
|
2077 focus_state = MAYBE; |
1a702abffaf3
patch 8.2.4490: terminal focus reporting only works for xterm-like terminals
Bram Moolenaar <Bram@vim.org>
parents:
27684
diff
changeset
|
2078 #endif |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2079 |
7 | 2080 #ifdef USE_TERM_CONSOLE |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2081 // DEFAULT_TERM indicates that it is the machine console. |
7 | 2082 if (STRCMP(term, DEFAULT_TERM) != 0) |
2083 term_console = FALSE; | |
2084 else | |
2085 { | |
2086 term_console = TRUE; | |
2087 # ifdef AMIGA | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2088 win_resize_on(); // enable window resizing reports |
7 | 2089 # endif |
2090 } | |
2091 #endif | |
2092 | |
2093 #if defined(UNIX) || defined(VMS) | |
2094 /* | |
2095 * 'ttyfast' is default on for xterm, iris-ansi and a few others. | |
2096 */ | |
2097 if (vim_is_fastterm(term)) | |
2098 p_tf = TRUE; | |
2099 #endif | |
2100 #ifdef USE_TERM_CONSOLE | |
2101 /* | |
2102 * 'ttyfast' is default on consoles | |
2103 */ | |
2104 if (term_console) | |
2105 p_tf = TRUE; | |
2106 #endif | |
2107 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2108 ttest(TRUE); // make sure we have a valid set of terminal codes |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2109 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2110 full_screen = TRUE; // we can use termcap codes from now on |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2111 set_term_defaults(); // use current values as defaults |
7 | 2112 #ifdef FEAT_TERMRESPONSE |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
2113 LOG_TR(("setting crv_status to STATUS_GET")); |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2114 crv_status.tr_progress = STATUS_GET; // Get terminal version later |
28505
8751e815864e
patch 8.2.4777: screendump tests fail because of a redraw
Bram Moolenaar <Bram@vim.org>
parents:
28501
diff
changeset
|
2115 write_t_8u_state = FALSE; |
7 | 2116 #endif |
2117 | |
2118 /* | |
2119 * Initialize the terminal with the appropriate termcap codes. | |
2120 * Set the mouse and window title if possible. | |
2121 * Don't do this when starting, need to parse the .vimrc first, because it | |
2122 * may redefine t_TI etc. | |
2123 */ | |
2124 if (starting != NO_SCREEN) | |
2125 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2126 starttermcap(); // may change terminal mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2127 setmouse(); // may start using the mouse |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2128 maketitle(); // may display window title |
7 | 2129 } |
2130 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2131 // display initial screen after ttest() checking. jw. |
7 | 2132 if (width <= 0 || height <= 0) |
2133 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2134 // termcap failed to report size |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2135 // set defaults, in case ui_get_shellsize() also fails |
7 | 2136 width = 80; |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15852
diff
changeset
|
2137 #if defined(MSWIN) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2138 height = 25; // console is often 25 lines |
7 | 2139 #else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2140 height = 24; // most terminals are 24 lines |
7 | 2141 #endif |
2142 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2143 set_shellsize(width, height, FALSE); // may change Rows |
7 | 2144 if (starting != NO_SCREEN) |
2145 { | |
2146 if (scroll_region) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2147 scroll_region_reset(); // In case Rows changed |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2148 check_map_keycodes(); // check mappings for terminal codes used |
7 | 2149 |
2150 { | |
19489
31ac050a29a7
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
2151 buf_T *buf; |
31ac050a29a7
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
2152 aco_save_T aco; |
7 | 2153 |
2154 /* | |
2155 * Execute the TermChanged autocommands for each buffer that is | |
2156 * loaded. | |
2157 */ | |
19489
31ac050a29a7
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
2158 FOR_ALL_BUFFERS(buf) |
7 | 2159 { |
2160 if (curbuf->b_ml.ml_mfp != NULL) | |
19489
31ac050a29a7
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
2161 { |
31ac050a29a7
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
2162 aucmd_prepbuf(&aco, buf); |
7 | 2163 apply_autocmds(EVENT_TERMCHANGED, NULL, NULL, FALSE, |
2164 curbuf); | |
19489
31ac050a29a7
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
2165 // restore curwin/curbuf and a few other things |
31ac050a29a7
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
2166 aucmd_restbuf(&aco); |
31ac050a29a7
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
2167 } |
7 | 2168 } |
2169 } | |
2170 } | |
2171 | |
2172 #ifdef FEAT_TERMRESPONSE | |
2173 may_req_termresponse(); | |
2174 #endif | |
2175 | |
2176 return OK; | |
2177 } | |
2178 | |
26177
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2179 #if defined(EXITFREE) || defined(PROTO) |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2180 |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2181 # ifdef HAVE_DEL_CURTERM |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2182 # undef TERMINAL // name clash in term.h |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2183 # include <term.h> // declares cur_term |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2184 # endif |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2185 |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2186 /* |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2187 * If supported, delete "cur_term", which caches terminal related entries. |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2188 * Avoids that valgrind reports possibly lost memory. |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2189 */ |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2190 void |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2191 free_cur_term() |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2192 { |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2193 # ifdef HAVE_DEL_CURTERM |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2194 if (cur_term) |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2195 del_curterm(cur_term); |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2196 # endif |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2197 } |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2198 |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2199 #endif |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2200 |
7 | 2201 #ifdef HAVE_TGETENT |
2202 /* | |
2203 * Call tgetent() | |
2204 * Return error message if it fails, NULL if it's OK. | |
2205 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
2206 static char * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2207 tgetent_error(char_u *tbuf, char_u *term) |
7 | 2208 { |
2209 int i; | |
2210 | |
18838
8dabdfc7c799
patch 8.1.2406: leaking memory in test_paste and test_registers
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
2211 // Note: Valgrind may report a leak here, because the library keeps one |
8dabdfc7c799
patch 8.1.2406: leaking memory in test_paste and test_registers
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
2212 // buffer around that we can't ever free. |
7 | 2213 i = TGETENT(tbuf, term); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2214 if (i < 0 // -1 is always an error |
7 | 2215 # ifdef TGETENT_ZERO_ERR |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2216 || i == 0 // sometimes zero is also an error |
7 | 2217 # endif |
2218 ) | |
2219 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2220 // On FreeBSD tputs() gets a SEGV after a tgetent() which fails. Call |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2221 // tgetent() with the always existing "dumb" entry to avoid a crash or |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2222 // hang. |
7 | 2223 (void)TGETENT(tbuf, "dumb"); |
2224 | |
2225 if (i < 0) | |
2226 # ifdef TGETENT_ZERO_ERR | |
26917
d91aea2a612c
patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
2227 return _(e_cannot_open_termcap_file); |
7 | 2228 if (i == 0) |
2229 # endif | |
2230 #ifdef TERMINFO | |
26917
d91aea2a612c
patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
2231 return _(e_terminal_entry_not_found_in_terminfo); |
7 | 2232 #else |
26917
d91aea2a612c
patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
2233 return _(e_terminal_entry_not_found_in_termcap); |
7 | 2234 #endif |
2235 } | |
2236 return NULL; | |
2237 } | |
2238 | |
2239 /* | |
2240 * Some versions of tgetstr() have been reported to return -1 instead of NULL. | |
2241 * Fix that here. | |
2242 */ | |
2243 static char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2244 vim_tgetstr(char *s, char_u **pp) |
7 | 2245 { |
2246 char *p; | |
2247 | |
2248 p = tgetstr(s, (char **)pp); | |
2249 if (p == (char *)-1) | |
2250 p = NULL; | |
2251 return (char_u *)p; | |
2252 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2253 #endif // HAVE_TGETENT |
7 | 2254 |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
2255 #if defined(HAVE_TGETENT) && (defined(UNIX) || defined(VMS) || defined(MACOS_X)) |
7 | 2256 /* |
2257 * Get Columns and Rows from the termcap. Used after a window signal if the | |
2258 * ioctl() fails. It doesn't make sense to call tgetent each time if the "co" | |
2259 * and "li" entries never change. But on some systems this works. | |
2260 * Errors while getting the entries are ignored. | |
2261 */ | |
2262 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2263 getlinecol( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2264 long *cp, // pointer to columns |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2265 long *rp) // pointer to rows |
7 | 2266 { |
2267 char_u tbuf[TBUFSZ]; | |
2268 | |
2269 if (T_NAME != NULL && *T_NAME != NUL && tgetent_error(tbuf, T_NAME) == NULL) | |
2270 { | |
2271 if (*cp == 0) | |
2272 *cp = tgetnum("co"); | |
2273 if (*rp == 0) | |
2274 *rp = tgetnum("li"); | |
2275 } | |
2276 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2277 #endif // defined(HAVE_TGETENT) && defined(UNIX) |
7 | 2278 |
2279 /* | |
2280 * Get a string entry from the termcap and add it to the list of termcodes. | |
2281 * Used for <t_xx> special keys. | |
2282 * Give an error message for failure when not sourcing. | |
2283 * If force given, replace an existing entry. | |
2284 * Return FAIL if the entry was not found, OK if the entry was added. | |
2285 */ | |
2286 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2287 add_termcap_entry(char_u *name, int force) |
7 | 2288 { |
2289 char_u *term; | |
2290 int key; | |
2291 struct builtin_term *termp; | |
2292 #ifdef HAVE_TGETENT | |
2293 char_u *string; | |
2294 int i; | |
2295 int builtin_first; | |
2296 char_u tbuf[TBUFSZ]; | |
2297 char_u tstrbuf[TBUFSZ]; | |
2298 char_u *tp = tstrbuf; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
2299 char *error_msg = NULL; |
7 | 2300 #endif |
2301 | |
2302 /* | |
2303 * If the GUI is running or will start in a moment, we only support the keys | |
2304 * that the GUI can produce. | |
2305 */ | |
2306 #ifdef FEAT_GUI | |
2307 if (gui.in_use || gui.starting) | |
2308 return gui_mch_haskey(name); | |
2309 #endif | |
2310 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2311 if (!force && find_termcode(name) != NULL) // it's already there |
7 | 2312 return OK; |
2313 | |
2314 term = T_NAME; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2315 if (term == NULL || *term == NUL) // 'term' not defined yet |
7 | 2316 return FAIL; |
2317 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2318 if (term_is_builtin(term)) // name starts with "builtin_" |
7 | 2319 { |
2320 term += 8; | |
2321 #ifdef HAVE_TGETENT | |
2322 builtin_first = TRUE; | |
2323 #endif | |
2324 } | |
2325 #ifdef HAVE_TGETENT | |
2326 else | |
2327 builtin_first = p_tbi; | |
2328 #endif | |
2329 | |
2330 #ifdef HAVE_TGETENT | |
2331 /* | |
2332 * We can get the entry from the builtin termcap and from the external one. | |
2333 * If 'ttybuiltin' is on or the terminal name starts with "builtin_", try | |
2334 * builtin termcap first. | |
2335 * If 'ttybuiltin' is off, try external termcap first. | |
2336 */ | |
2337 for (i = 0; i < 2; ++i) | |
2338 { | |
7210
08b50e436093
commit https://github.com/vim/vim/commit/98b30a473a58ae98c280e0383c8b1e08c0ebced5
Christian Brabandt <cb@256bit.org>
parents:
6901
diff
changeset
|
2339 if ((!builtin_first) == i) |
7 | 2340 #endif |
2341 /* | |
2342 * Search in builtin termcap | |
2343 */ | |
2344 { | |
2345 termp = find_builtin_term(term); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2346 if (termp->bt_string != NULL) // found it |
7 | 2347 { |
2348 key = TERMCAP2KEY(name[0], name[1]); | |
13406
4e30f3f4cb78
patch 8.0.1577: virtual replace test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13398
diff
changeset
|
2349 ++termp; |
7 | 2350 while (termp->bt_entry != (int)KS_NAME) |
2351 { | |
2352 if ((int)termp->bt_entry == key) | |
2353 { | |
2354 add_termcode(name, (char_u *)termp->bt_string, | |
2355 term_is_8bit(term)); | |
2356 return OK; | |
2357 } | |
2358 ++termp; | |
2359 } | |
2360 } | |
2361 } | |
2362 #ifdef HAVE_TGETENT | |
2363 else | |
2364 /* | |
2365 * Search in external termcap | |
2366 */ | |
2367 { | |
2368 error_msg = tgetent_error(tbuf, term); | |
2369 if (error_msg == NULL) | |
2370 { | |
2371 string = TGETSTR((char *)name, &tp); | |
2372 if (string != NULL && *string != NUL) | |
2373 { | |
2374 add_termcode(name, string, FALSE); | |
2375 return OK; | |
2376 } | |
2377 } | |
2378 } | |
2379 } | |
2380 #endif | |
2381 | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18838
diff
changeset
|
2382 if (SOURCING_NAME == NULL) |
7 | 2383 { |
2384 #ifdef HAVE_TGETENT | |
2385 if (error_msg != NULL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
2386 emsg(error_msg); |
7 | 2387 else |
2388 #endif | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
2389 semsg(_(e_no_str_entry_in_termcap), name); |
7 | 2390 } |
2391 return FAIL; | |
2392 } | |
2393 | |
2394 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2395 term_is_builtin(char_u *name) |
7 | 2396 { |
2397 return (STRNCMP(name, "builtin_", (size_t)8) == 0); | |
2398 } | |
2399 | |
2400 /* | |
2401 * Return TRUE if terminal "name" uses CSI instead of <Esc>[. | |
2402 * Assume that the terminal is using 8-bit controls when the name contains | |
2403 * "8bit", like in "xterm-8bit". | |
2404 */ | |
2405 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2406 term_is_8bit(char_u *name) |
7 | 2407 { |
2408 return (detected_8bit || strstr((char *)name, "8bit") != NULL); | |
2409 } | |
2410 | |
2411 /* | |
2412 * Translate terminal control chars from 7-bit to 8-bit: | |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
2413 * <Esc>[ -> CSI <M_C_[> |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
2414 * <Esc>] -> OSC <M-C-]> |
7 | 2415 * <Esc>O -> <M-C-O> |
2416 */ | |
2417 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2418 term_7to8bit(char_u *p) |
7 | 2419 { |
2420 if (*p == ESC) | |
2421 { | |
2422 if (p[1] == '[') | |
2423 return CSI; | |
2424 if (p[1] == ']') | |
6901 | 2425 return OSC; |
7 | 2426 if (p[1] == 'O') |
2427 return 0x8f; | |
2428 } | |
2429 return 0; | |
2430 } | |
2431 | |
13762
9de2b25932eb
patch 8.0.1753: various warnings from a static analyser
Christian Brabandt <cb@256bit.org>
parents:
13573
diff
changeset
|
2432 #if defined(FEAT_GUI) || defined(PROTO) |
7 | 2433 int |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2434 term_is_gui(char_u *name) |
7 | 2435 { |
2436 return (STRCMP(name, "builtin_gui") == 0 || STRCMP(name, "gui") == 0); | |
2437 } | |
2438 #endif | |
2439 | |
2440 #if !defined(HAVE_TGETENT) || defined(AMIGA) || defined(PROTO) | |
2441 | |
2442 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2443 tltoa(unsigned long i) |
7 | 2444 { |
2445 static char_u buf[16]; | |
2446 char_u *p; | |
2447 | |
2448 p = buf + 15; | |
2449 *p = '\0'; | |
2450 do | |
2451 { | |
2452 --p; | |
2453 *p = (char_u) (i % 10 + '0'); | |
2454 i /= 10; | |
2455 } | |
2456 while (i > 0 && p > buf); | |
2457 return p; | |
2458 } | |
2459 #endif | |
2460 | |
2461 #ifndef HAVE_TGETENT | |
2462 | |
2463 /* | |
2464 * minimal tgoto() implementation. | |
2465 * no padding and we only parse for %i %d and %+char | |
2466 */ | |
298 | 2467 static char * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2468 tgoto(char *cm, int x, int y) |
7 | 2469 { |
2470 static char buf[30]; | |
2471 char *p, *s, *e; | |
2472 | |
2473 if (!cm) | |
2474 return "OOPS"; | |
2475 e = buf + 29; | |
2476 for (s = buf; s < e && *cm; cm++) | |
2477 { | |
2478 if (*cm != '%') | |
2479 { | |
2480 *s++ = *cm; | |
2481 continue; | |
2482 } | |
2483 switch (*++cm) | |
2484 { | |
2485 case 'd': | |
2486 p = (char *)tltoa((unsigned long)y); | |
2487 y = x; | |
2488 while (*p) | |
2489 *s++ = *p++; | |
2490 break; | |
2491 case 'i': | |
2492 x++; | |
2493 y++; | |
2494 break; | |
2495 case '+': | |
2496 *s++ = (char)(*++cm + y); | |
2497 y = x; | |
2498 break; | |
2499 case '%': | |
2500 *s++ = *cm; | |
2501 break; | |
2502 default: | |
2503 return "OOPS"; | |
2504 } | |
2505 } | |
2506 *s = '\0'; | |
2507 return buf; | |
2508 } | |
2509 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2510 #endif // HAVE_TGETENT |
7 | 2511 |
2512 /* | |
2513 * Set the terminal name and initialize the terminal options. | |
2514 * If "name" is NULL or empty, get the terminal name from the environment. | |
2515 * If that fails, use the default terminal name. | |
2516 */ | |
2517 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2518 termcapinit(char_u *name) |
7 | 2519 { |
2520 char_u *term; | |
2521 | |
2522 if (name != NULL && *name == NUL) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2523 name = NULL; // empty name is equal to no name |
7 | 2524 term = name; |
2525 | |
2526 #ifndef MSWIN | |
2527 if (term == NULL) | |
2528 term = mch_getenv((char_u *)"TERM"); | |
2529 #endif | |
2530 if (term == NULL || *term == NUL) | |
2531 term = DEFAULT_TERM; | |
694 | 2532 set_string_option_direct((char_u *)"term", -1, term, OPT_FREE, 0); |
7 | 2533 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2534 // Set the default terminal name. |
7 | 2535 set_string_default("term", term); |
2536 set_string_default("ttytype", term); | |
2537 | |
2538 /* | |
2539 * Avoid using "term" here, because the next mch_getenv() may overwrite it. | |
2540 */ | |
2541 set_termname(T_NAME != NULL ? T_NAME : term); | |
2542 } | |
2543 | |
2544 /* | |
16200
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2545 * The number of calls to ui_write is reduced by using "out_buf". |
7 | 2546 */ |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
2547 #define OUT_SIZE 2047 |
16200
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2548 |
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2549 // add one to allow mch_write() in os_win32.c to append a NUL |
7 | 2550 static char_u out_buf[OUT_SIZE + 1]; |
16200
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2551 |
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2552 static int out_pos = 0; // number of chars in out_buf |
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2553 |
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2554 // Since the maximum number of SGR parameters shown as a normal value range is |
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2555 // 16, the escape sequence length can be 4 * 16 + lead + tail. |
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2556 #define MAX_ESC_SEQ_LEN 80 |
7 | 2557 |
2558 /* | |
2559 * out_flush(): flush the output buffer | |
2560 */ | |
2561 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2562 out_flush(void) |
7 | 2563 { |
2564 int len; | |
2565 | |
2566 if (out_pos != 0) | |
2567 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2568 // set out_pos to 0 before ui_write, to avoid recursiveness |
7 | 2569 len = out_pos; |
2570 out_pos = 0; | |
24194
9f64c420f280
patch 8.2.2638: cannot write a message to the terminal from the GUI
Bram Moolenaar <Bram@vim.org>
parents:
24045
diff
changeset
|
2571 ui_write(out_buf, len, FALSE); |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2572 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2573 if (ch_log_output) |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2574 { |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2575 out_buf[len] = NUL; |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2576 ch_log(NULL, "raw %s output: \"%s\"", |
23610
07f9e4a54178
patch 8.2.2347: build failure without GUI
Bram Moolenaar <Bram@vim.org>
parents:
23606
diff
changeset
|
2577 # ifdef FEAT_GUI |
07f9e4a54178
patch 8.2.2347: build failure without GUI
Bram Moolenaar <Bram@vim.org>
parents:
23606
diff
changeset
|
2578 (gui.in_use && !gui.dying && !gui.starting) ? "GUI" : |
07f9e4a54178
patch 8.2.2347: build failure without GUI
Bram Moolenaar <Bram@vim.org>
parents:
23606
diff
changeset
|
2579 # endif |
07f9e4a54178
patch 8.2.2347: build failure without GUI
Bram Moolenaar <Bram@vim.org>
parents:
23606
diff
changeset
|
2580 "terminal", |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2581 out_buf); |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2582 ch_log_output = FALSE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2583 } |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2584 #endif |
7 | 2585 } |
2586 } | |
2587 | |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2588 /* |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
2589 * out_flush_cursor(): flush the output buffer and redraw the cursor. |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
2590 * Does not flush recursively in the GUI to avoid slow drawing. |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2591 */ |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2592 void |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2593 out_flush_cursor( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2594 int force UNUSED, // when TRUE, update cursor even when not moved |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2595 int clear_selection UNUSED) // clear selection under cursor |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2596 { |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2597 mch_disable_flush(); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2598 out_flush(); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2599 mch_enable_flush(); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2600 #ifdef FEAT_GUI |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2601 if (gui.in_use) |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2602 { |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2603 gui_update_cursor(force, clear_selection); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2604 gui_may_flush(); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2605 } |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2606 #endif |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2607 } |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2608 |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2609 |
7 | 2610 /* |
2611 * Sometimes a byte out of a multi-byte character is written with out_char(). | |
2612 * To avoid flushing half of the character, call this function first. | |
2613 */ | |
2614 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2615 out_flush_check(void) |
7 | 2616 { |
2617 if (enc_dbcs != 0 && out_pos >= OUT_SIZE - MB_MAXBYTES) | |
2618 out_flush(); | |
2619 } | |
2620 | |
2621 #ifdef FEAT_GUI | |
2622 /* | |
2623 * out_trash(): Throw away the contents of the output buffer | |
2624 */ | |
2625 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2626 out_trash(void) |
7 | 2627 { |
2628 out_pos = 0; | |
2629 } | |
2630 #endif | |
2631 | |
2632 /* | |
2633 * out_char(c): put a byte into the output buffer. | |
2634 * Flush it if it becomes full. | |
2635 * This should not be used for outputting text on the screen (use functions | |
2636 * like msg_puts() and screen_putchar() for that). | |
2637 */ | |
2638 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2639 out_char(unsigned c) |
7 | 2640 { |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12640
diff
changeset
|
2641 #if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(MACOS_X) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2642 if (c == '\n') // turn LF into CR-LF (CRMOD doesn't seem to do this) |
7 | 2643 out_char('\r'); |
2644 #endif | |
2645 | |
2646 out_buf[out_pos++] = c; | |
2647 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2648 // For testing we flush each time. |
7 | 2649 if (out_pos >= OUT_SIZE || p_wd) |
2650 out_flush(); | |
2651 } | |
2652 | |
2653 /* | |
18430
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
2654 * Output "c" like out_char(), but don't flush when p_wd is set. |
7 | 2655 */ |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2656 static int |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2657 out_char_nf(int c) |
7 | 2658 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2659 out_buf[out_pos++] = (unsigned)c; |
7 | 2660 |
2661 if (out_pos >= OUT_SIZE) | |
2662 out_flush(); | |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2663 return (unsigned)c; |
7 | 2664 } |
2665 | |
2666 /* | |
18430
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
2667 * A never-padding out_str(). |
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
2668 * Use this whenever you don't want to run the string through tputs(). |
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
2669 * tputs() above is harmless, but tputs() from the termcap library |
7 | 2670 * is likely to strip off leading digits, that it mistakes for padding |
2671 * information, and "%i", "%d", etc. | |
2672 * This should only be used for writing terminal codes, not for outputting | |
2673 * normal text (use functions like msg_puts() and screen_putchar() for that). | |
2674 */ | |
2675 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2676 out_str_nf(char_u *s) |
7 | 2677 { |
16200
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2678 // avoid terminal strings being split up |
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2679 if (out_pos > OUT_SIZE - MAX_ESC_SEQ_LEN) |
7 | 2680 out_flush(); |
16200
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2681 |
7 | 2682 while (*s) |
2683 out_char_nf(*s++); | |
2684 | |
16200
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2685 // For testing we write one string at a time. |
7 | 2686 if (p_wd) |
2687 out_flush(); | |
2688 } | |
2689 | |
2690 /* | |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2691 * A conditional-flushing out_str, mainly for visualbell. |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2692 * Handles a delay internally, because termlib may not respect the delay or do |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2693 * it at the wrong time. |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2694 * Note: Only for terminal strings. |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2695 */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2696 void |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2697 out_str_cf(char_u *s) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2698 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2699 if (s != NULL && *s) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2700 { |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2701 #ifdef HAVE_TGETENT |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2702 char_u *p; |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2703 #endif |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2704 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2705 #ifdef FEAT_GUI |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2706 // Don't use tputs() when GUI is used, ncurses crashes. |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2707 if (gui.in_use) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2708 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2709 out_str_nf(s); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2710 return; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2711 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2712 #endif |
16200
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2713 if (out_pos > OUT_SIZE - MAX_ESC_SEQ_LEN) |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2714 out_flush(); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2715 #ifdef HAVE_TGETENT |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2716 for (p = s; *s; ++s) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2717 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2718 // flush just before delay command |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2719 if (*s == '$' && *(s + 1) == '<') |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2720 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2721 char_u save_c = *s; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2722 int duration = atoi((char *)s + 2); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2723 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2724 *s = NUL; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2725 tputs((char *)p, 1, TPUTSFUNCAST out_char_nf); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2726 *s = save_c; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2727 out_flush(); |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2728 # ifdef ELAPSED_FUNC |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2729 // Only sleep here if we can limit this happening in |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2730 // vim_beep(). |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2731 p = vim_strchr(s, '>'); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2732 if (p == NULL || duration <= 0) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2733 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2734 // can't parse the time, don't sleep here |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2735 p = s; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2736 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2737 else |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2738 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2739 ++p; |
23648
b7d3c79075c5
patch 8.2.2366: when using ":sleep" the cursor is always displayed
Bram Moolenaar <Bram@vim.org>
parents:
23632
diff
changeset
|
2740 do_sleep(duration, FALSE); |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2741 } |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2742 # else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2743 // Rely on the terminal library to sleep. |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2744 p = s; |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2745 # endif |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2746 break; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2747 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2748 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2749 tputs((char *)p, 1, TPUTSFUNCAST out_char_nf); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2750 #else |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2751 while (*s) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2752 out_char_nf(*s++); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2753 #endif |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2754 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2755 // For testing we write one string at a time. |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2756 if (p_wd) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2757 out_flush(); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2758 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2759 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2760 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2761 /* |
7 | 2762 * out_str(s): Put a character string a byte at a time into the output buffer. |
18430
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
2763 * If HAVE_TGETENT is defined use tputs(), the termcap parser. (jw) |
7 | 2764 * This should only be used for writing terminal codes, not for outputting |
2765 * normal text (use functions like msg_puts() and screen_putchar() for that). | |
2766 */ | |
2767 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2768 out_str(char_u *s) |
7 | 2769 { |
2770 if (s != NULL && *s) | |
2771 { | |
2772 #ifdef FEAT_GUI | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2773 // Don't use tputs() when GUI is used, ncurses crashes. |
7 | 2774 if (gui.in_use) |
2775 { | |
2776 out_str_nf(s); | |
2777 return; | |
2778 } | |
2779 #endif | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2780 // avoid terminal strings being split up |
16200
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2781 if (out_pos > OUT_SIZE - MAX_ESC_SEQ_LEN) |
7 | 2782 out_flush(); |
2783 #ifdef HAVE_TGETENT | |
2784 tputs((char *)s, 1, TPUTSFUNCAST out_char_nf); | |
2785 #else | |
2786 while (*s) | |
2787 out_char_nf(*s++); | |
2788 #endif | |
2789 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2790 // For testing we write one string at a time. |
7 | 2791 if (p_wd) |
2792 out_flush(); | |
2793 } | |
2794 } | |
2795 | |
2796 /* | |
2797 * cursor positioning using termcap parser. (jw) | |
2798 */ | |
2799 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2800 term_windgoto(int row, int col) |
7 | 2801 { |
2802 OUT_STR(tgoto((char *)T_CM, col, row)); | |
2803 } | |
2804 | |
2805 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2806 term_cursor_right(int i) |
7 | 2807 { |
2808 OUT_STR(tgoto((char *)T_CRI, 0, i)); | |
2809 } | |
2810 | |
2811 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2812 term_append_lines(int line_count) |
7 | 2813 { |
2814 OUT_STR(tgoto((char *)T_CAL, 0, line_count)); | |
2815 } | |
2816 | |
2817 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2818 term_delete_lines(int line_count) |
7 | 2819 { |
2820 OUT_STR(tgoto((char *)T_CDL, 0, line_count)); | |
2821 } | |
2822 | |
2823 #if defined(HAVE_TGETENT) || defined(PROTO) | |
2824 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2825 term_set_winpos(int x, int y) |
7 | 2826 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2827 // Can't handle a negative value here |
7 | 2828 if (x < 0) |
2829 x = 0; | |
2830 if (y < 0) | |
2831 y = 0; | |
2832 OUT_STR(tgoto((char *)T_CWP, y, x)); | |
2833 } | |
2834 | |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2835 # if defined(FEAT_TERMRESPONSE) || defined(PROTO) |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2836 /* |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2837 * Return TRUE if we can request the terminal for a response. |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2838 */ |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2839 static int |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2840 can_get_termresponse() |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2841 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2842 return cur_tmode == TMODE_RAW |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2843 && termcap_active |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2844 # ifdef UNIX |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2845 && (is_not_a_term() || (isatty(1) && isatty(read_cmd_fd))) |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2846 # endif |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2847 && p_ek; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2848 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2849 |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2850 /* |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2851 * Set "status" to STATUS_SENT. |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2852 */ |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2853 static void |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2854 termrequest_sent(termrequest_T *status) |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2855 { |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2856 status->tr_progress = STATUS_SENT; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2857 status->tr_start = time(NULL); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2858 } |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2859 |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2860 /* |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2861 * Return TRUE if any of the requests are in STATUS_SENT. |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2862 */ |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2863 static int |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2864 termrequest_any_pending() |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2865 { |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2866 int i; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2867 time_t now = time(NULL); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2868 |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2869 for (i = 0; all_termrequests[i] != NULL; ++i) |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2870 { |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2871 if (all_termrequests[i]->tr_progress == STATUS_SENT) |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2872 { |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2873 if (all_termrequests[i]->tr_start > 0 && now > 0 |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2874 && all_termrequests[i]->tr_start + 2 < now) |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2875 // Sent the request more than 2 seconds ago and didn't get a |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2876 // response, assume it failed. |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2877 all_termrequests[i]->tr_progress = STATUS_FAIL; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2878 else |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2879 return TRUE; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2880 } |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2881 } |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2882 return FALSE; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2883 } |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2884 |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2885 static int winpos_x = -1; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2886 static int winpos_y = -1; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2887 static int did_request_winpos = 0; |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2888 |
16245
e0a6298bd70f
patch 8.1.1127: getwinpos() doesn't work in terminal on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents:
16200
diff
changeset
|
2889 # if defined(FEAT_EVAL) || defined(FEAT_TERMINAL) || defined(PROTO) |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2890 /* |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2891 * Try getting the Vim window position from the terminal. |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2892 * Returns OK or FAIL. |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2893 */ |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2894 int |
13379
0f9dd1b43244
patch 8.0.1563: timeout of getwinposx() can be too short
Christian Brabandt <cb@256bit.org>
parents:
13365
diff
changeset
|
2895 term_get_winpos(int *x, int *y, varnumber_T timeout) |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2896 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2897 int count = 0; |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2898 int prev_winpos_x = winpos_x; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2899 int prev_winpos_y = winpos_y; |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2900 |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2901 if (*T_CGP == NUL || !can_get_termresponse()) |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2902 return FAIL; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2903 winpos_x = -1; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2904 winpos_y = -1; |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2905 ++did_request_winpos; |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2906 termrequest_sent(&winpos_status); |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2907 OUT_STR(T_CGP); |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2908 out_flush(); |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2909 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2910 // Try reading the result for "timeout" msec. |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2911 while (count++ <= timeout / 10 && !got_int) |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2912 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2913 (void)vpeekc_nomap(); |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2914 if (winpos_x >= 0 && winpos_y >= 0) |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2915 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2916 *x = winpos_x; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2917 *y = winpos_y; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2918 return OK; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2919 } |
18642
bbea1f108187
patch 8.1.2313: debugging where a delay comes from is not easy
Bram Moolenaar <Bram@vim.org>
parents:
18430
diff
changeset
|
2920 ui_delay(10L, FALSE); |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2921 } |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2922 // Do not reset "did_request_winpos", if we timed out the response might |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2923 // still come later and we must consume it. |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2924 |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2925 winpos_x = prev_winpos_x; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2926 winpos_y = prev_winpos_y; |
13762
9de2b25932eb
patch 8.0.1753: various warnings from a static analyser
Christian Brabandt <cb@256bit.org>
parents:
13573
diff
changeset
|
2927 if (timeout < 10 && prev_winpos_y >= 0 && prev_winpos_x >= 0) |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2928 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2929 // Polling: return previous values if we have them. |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2930 *x = winpos_x; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2931 *y = winpos_y; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2932 return OK; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2933 } |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2934 |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2935 return FALSE; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2936 } |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2937 # endif |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2938 # endif |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2939 |
7 | 2940 void |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
2941 term_set_winsize(int height, int width) |
7 | 2942 { |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
2943 OUT_STR(tgoto((char *)T_CWS, width, height)); |
7 | 2944 } |
2945 #endif | |
2946 | |
2947 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2948 term_color(char_u *s, int n) |
7 | 2949 { |
2950 char buf[20]; | |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2951 int i = *s == CSI ? 1 : 2; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2952 // index in s[] just after <Esc>[ or CSI |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2953 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2954 // Special handling of 16 colors, because termcap can't handle it |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2955 // Also accept "\e[3%dm" for TERMINFO, it is sometimes used |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2956 // Also accept CSI instead of <Esc>[ |
7 | 2957 if (n >= 8 && t_colors >= 16 |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
2958 && ((s[0] == ESC && s[1] == '[') |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
2959 #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
2960 || (s[0] == ESC && s[1] == '|') |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
2961 #endif |
20437
3bb4dea4a164
patch 8.2.0773: switching to raw mode every time ":" is used
Bram Moolenaar <Bram@vim.org>
parents:
20425
diff
changeset
|
2962 || (s[0] == CSI && (i = 1) == 1)) |
7 | 2963 && s[i] != NUL |
2964 && (STRCMP(s + i + 1, "%p1%dm") == 0 | |
2965 || STRCMP(s + i + 1, "%dm") == 0) | |
2966 && (s[i] == '3' || s[i] == '4')) | |
2967 { | |
2968 #ifdef TERMINFO | |
9068
0a3bc9fdea20
commit https://github.com/vim/vim/commit/827b165b2aebad2cfe98cc6d5804c6c0fe8afd89
Christian Brabandt <cb@256bit.org>
parents:
9027
diff
changeset
|
2969 char *format = "%s%s%%p1%%dm"; |
7 | 2970 #else |
9068
0a3bc9fdea20
commit https://github.com/vim/vim/commit/827b165b2aebad2cfe98cc6d5804c6c0fe8afd89
Christian Brabandt <cb@256bit.org>
parents:
9027
diff
changeset
|
2971 char *format = "%s%s%%dm"; |
7 | 2972 #endif |
14007
5d6e8dedfc73
patch 8.1.0021: clang warns for undefined behavior
Christian Brabandt <cb@256bit.org>
parents:
13874
diff
changeset
|
2973 char *lead = i == 2 ? ( |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
2974 #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS) |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
2975 s[1] == '|' ? "\033|" : |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
2976 #endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
2977 "\033[") : "\233"; |
14007
5d6e8dedfc73
patch 8.1.0021: clang warns for undefined behavior
Christian Brabandt <cb@256bit.org>
parents:
13874
diff
changeset
|
2978 char *tail = s[i] == '3' ? (n >= 16 ? "38;5;" : "9") |
5d6e8dedfc73
patch 8.1.0021: clang warns for undefined behavior
Christian Brabandt <cb@256bit.org>
parents:
13874
diff
changeset
|
2979 : (n >= 16 ? "48;5;" : "10"); |
5d6e8dedfc73
patch 8.1.0021: clang warns for undefined behavior
Christian Brabandt <cb@256bit.org>
parents:
13874
diff
changeset
|
2980 |
5d6e8dedfc73
patch 8.1.0021: clang warns for undefined behavior
Christian Brabandt <cb@256bit.org>
parents:
13874
diff
changeset
|
2981 sprintf(buf, format, lead, tail); |
7 | 2982 OUT_STR(tgoto(buf, 0, n >= 16 ? n : n - 8)); |
2983 } | |
2984 else | |
2985 OUT_STR(tgoto((char *)s, 0, n)); | |
2986 } | |
2987 | |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2988 void |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2989 term_fg_color(int n) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2990 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2991 // Use "AF" termcap entry if present, "Sf" entry otherwise |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2992 if (*T_CAF) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2993 term_color(T_CAF, n); |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2994 else if (*T_CSF) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2995 term_color(T_CSF, n); |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2996 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2997 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2998 void |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2999 term_bg_color(int n) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3000 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3001 // Use "AB" termcap entry if present, "Sb" entry otherwise |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3002 if (*T_CAB) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3003 term_color(T_CAB, n); |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3004 else if (*T_CSB) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3005 term_color(T_CSB, n); |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3006 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3007 |
20619
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3008 void |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3009 term_ul_color(int n) |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3010 { |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3011 if (*T_CAU) |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3012 term_color(T_CAU, n); |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3013 } |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3014 |
18679
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3015 /* |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3016 * Return "dark" or "light" depending on the kind of terminal. |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3017 * This is just guessing! Recognized are: |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3018 * "linux" Linux console |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3019 * "screen.linux" Linux console with screen |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3020 * "cygwin.*" Cygwin shell |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3021 * "putty.*" Putty program |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3022 * We also check the COLORFGBG environment variable, which is set by |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3023 * rxvt and derivatives. This variable contains either two or three |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3024 * values separated by semicolons; we want the last value in either |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3025 * case. If this value is 0-6 or 8, our background is dark. |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3026 */ |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3027 char_u * |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3028 term_bg_default(void) |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3029 { |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3030 #if defined(MSWIN) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3031 // DOS console is nearly always black |
18679
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3032 return (char_u *)"dark"; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3033 #else |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3034 char_u *p; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3035 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3036 if (STRCMP(T_NAME, "linux") == 0 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3037 || STRCMP(T_NAME, "screen.linux") == 0 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3038 || STRNCMP(T_NAME, "cygwin", 6) == 0 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3039 || STRNCMP(T_NAME, "putty", 5) == 0 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3040 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3041 && (p = vim_strrchr(p, ';')) != NULL |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3042 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8') |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3043 && p[2] == NUL)) |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3044 return (char_u *)"dark"; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3045 return (char_u *)"light"; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3046 #endif |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3047 } |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3048 |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
3049 #if defined(FEAT_TERMGUICOLORS) || defined(PROTO) |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3050 |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3051 #define RED(rgb) (((long_u)(rgb) >> 16) & 0xFF) |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3052 #define GREEN(rgb) (((long_u)(rgb) >> 8) & 0xFF) |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3053 #define BLUE(rgb) (((long_u)(rgb) ) & 0xFF) |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3054 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3055 static void |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3056 term_rgb_color(char_u *s, guicolor_T rgb) |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3057 { |
8975
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
3058 #define MAX_COLOR_STR_LEN 100 |
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
3059 char buf[MAX_COLOR_STR_LEN]; |
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
3060 |
28505
8751e815864e
patch 8.2.4777: screendump tests fail because of a redraw
Bram Moolenaar <Bram@vim.org>
parents:
28501
diff
changeset
|
3061 if (*s == NUL) |
8751e815864e
patch 8.2.4777: screendump tests fail because of a redraw
Bram Moolenaar <Bram@vim.org>
parents:
28501
diff
changeset
|
3062 return; |
8981
3b51b0aeb9a3
commit https://github.com/vim/vim/commit/a1c487eef71d1673e57511453009de9cb4c9af51
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
3063 vim_snprintf(buf, MAX_COLOR_STR_LEN, |
8975
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
3064 (char *)s, RED(rgb), GREEN(rgb), BLUE(rgb)); |
20589
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3065 #ifdef FEAT_VTP |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3066 if (use_wt()) |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3067 { |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3068 out_flush(); |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3069 buf[1] = '['; |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3070 vtp_printf(buf); |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3071 } |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3072 else |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3073 #endif |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3074 OUT_STR(buf); |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3075 } |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3076 |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3077 void |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3078 term_fg_rgb_color(guicolor_T rgb) |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3079 { |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3080 term_rgb_color(T_8F, rgb); |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3081 } |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3082 |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3083 void |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3084 term_bg_rgb_color(guicolor_T rgb) |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3085 { |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3086 term_rgb_color(T_8B, rgb); |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3087 } |
20619
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3088 |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3089 void |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3090 term_ul_rgb_color(guicolor_T rgb) |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3091 { |
28505
8751e815864e
patch 8.2.4777: screendump tests fail because of a redraw
Bram Moolenaar <Bram@vim.org>
parents:
28501
diff
changeset
|
3092 # ifdef FEAT_TERMRESPONSE |
8751e815864e
patch 8.2.4777: screendump tests fail because of a redraw
Bram Moolenaar <Bram@vim.org>
parents:
28501
diff
changeset
|
3093 if (write_t_8u_state != OK) |
8751e815864e
patch 8.2.4777: screendump tests fail because of a redraw
Bram Moolenaar <Bram@vim.org>
parents:
28501
diff
changeset
|
3094 write_t_8u_state = MAYBE; |
8751e815864e
patch 8.2.4777: screendump tests fail because of a redraw
Bram Moolenaar <Bram@vim.org>
parents:
28501
diff
changeset
|
3095 else |
8751e815864e
patch 8.2.4777: screendump tests fail because of a redraw
Bram Moolenaar <Bram@vim.org>
parents:
28501
diff
changeset
|
3096 # endif |
8751e815864e
patch 8.2.4777: screendump tests fail because of a redraw
Bram Moolenaar <Bram@vim.org>
parents:
28501
diff
changeset
|
3097 term_rgb_color(T_8U, rgb); |
20619
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3098 } |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3099 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3100 |
26336
a2e6da79274d
patch 8.2.3699: the +title feature adds a lot of #ifdef but little code
Bram Moolenaar <Bram@vim.org>
parents:
26177
diff
changeset
|
3101 #if (defined(UNIX) || defined(VMS) || defined(MACOS_X)) || defined(PROTO) |
7 | 3102 /* |
3103 * Generic function to set window title, using t_ts and t_fs. | |
3104 */ | |
3105 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3106 term_settitle(char_u *title) |
7 | 3107 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3108 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3109 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3110 #endif |
18430
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
3111 // t_ts takes one argument: column in status line |
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
3112 OUT_STR(tgoto((char *)T_TS, 0, 0)); // set title start |
7 | 3113 out_str_nf(title); |
18430
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
3114 out_str(T_FS); // set title end |
7 | 3115 out_flush(); |
3116 } | |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3117 |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3118 /* |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3119 * Tell the terminal to push (save) the title and/or icon, so that it can be |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3120 * popped (restored) later. |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3121 */ |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3122 void |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3123 term_push_title(int which) |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3124 { |
16586
5ebb2c87d1f5
patch 8.1.1296: crash when using invalid command line argument
Bram Moolenaar <Bram@vim.org>
parents:
16523
diff
changeset
|
3125 if ((which & SAVE_RESTORE_TITLE) && T_CST != NULL && *T_CST != NUL) |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3126 { |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3127 OUT_STR(T_CST); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3128 out_flush(); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3129 } |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3130 |
16586
5ebb2c87d1f5
patch 8.1.1296: crash when using invalid command line argument
Bram Moolenaar <Bram@vim.org>
parents:
16523
diff
changeset
|
3131 if ((which & SAVE_RESTORE_ICON) && T_SSI != NULL && *T_SSI != NUL) |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3132 { |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3133 OUT_STR(T_SSI); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3134 out_flush(); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3135 } |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3136 } |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3137 |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3138 /* |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3139 * Tell the terminal to pop the title and/or icon. |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3140 */ |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3141 void |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3142 term_pop_title(int which) |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3143 { |
16586
5ebb2c87d1f5
patch 8.1.1296: crash when using invalid command line argument
Bram Moolenaar <Bram@vim.org>
parents:
16523
diff
changeset
|
3144 if ((which & SAVE_RESTORE_TITLE) && T_CRT != NULL && *T_CRT != NUL) |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3145 { |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3146 OUT_STR(T_CRT); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3147 out_flush(); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3148 } |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3149 |
16586
5ebb2c87d1f5
patch 8.1.1296: crash when using invalid command line argument
Bram Moolenaar <Bram@vim.org>
parents:
16523
diff
changeset
|
3150 if ((which & SAVE_RESTORE_ICON) && T_SRI != NULL && *T_SRI != NUL) |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3151 { |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3152 OUT_STR(T_SRI); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3153 out_flush(); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3154 } |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3155 } |
7 | 3156 #endif |
3157 | |
3158 /* | |
3159 * Make sure we have a valid set or terminal options. | |
3160 * Replace all entries that are NULL by empty_option | |
3161 */ | |
3162 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3163 ttest(int pairs) |
7 | 3164 { |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
3165 char_u *env_colors; |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
3166 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3167 check_options(); // make sure no options are NULL |
7 | 3168 |
3169 /* | |
3170 * MUST have "cm": cursor motion. | |
3171 */ | |
3172 if (*T_CM == NUL) | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
3173 emsg(_(e_terminal_capability_cm_required)); |
7 | 3174 |
3175 /* | |
3176 * if "cs" defined, use a scroll region, it's faster. | |
3177 */ | |
3178 if (*T_CS != NUL) | |
3179 scroll_region = TRUE; | |
3180 else | |
3181 scroll_region = FALSE; | |
3182 | |
3183 if (pairs) | |
3184 { | |
3185 /* | |
3186 * optional pairs | |
3187 */ | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3188 // TP goes to normal mode for TI (invert) and TB (bold) |
7 | 3189 if (*T_ME == NUL) |
3190 T_ME = T_MR = T_MD = T_MB = empty_option; | |
3191 if (*T_SO == NUL || *T_SE == NUL) | |
3192 T_SO = T_SE = empty_option; | |
3193 if (*T_US == NUL || *T_UE == NUL) | |
3194 T_US = T_UE = empty_option; | |
3195 if (*T_CZH == NUL || *T_CZR == NUL) | |
3196 T_CZH = T_CZR = empty_option; | |
3197 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3198 // T_VE is needed even though T_VI is not defined |
7 | 3199 if (*T_VE == NUL) |
3200 T_VI = empty_option; | |
3201 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3202 // if 'mr' or 'me' is not defined use 'so' and 'se' |
7 | 3203 if (*T_ME == NUL) |
3204 { | |
3205 T_ME = T_SE; | |
3206 T_MR = T_SO; | |
3207 T_MD = T_SO; | |
3208 } | |
3209 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3210 // if 'so' or 'se' is not defined use 'mr' and 'me' |
7 | 3211 if (*T_SO == NUL) |
3212 { | |
3213 T_SE = T_ME; | |
3214 if (*T_MR == NUL) | |
3215 T_SO = T_MD; | |
3216 else | |
3217 T_SO = T_MR; | |
3218 } | |
3219 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3220 // if 'ZH' or 'ZR' is not defined use 'mr' and 'me' |
7 | 3221 if (*T_CZH == NUL) |
3222 { | |
3223 T_CZR = T_ME; | |
3224 if (*T_MR == NUL) | |
3225 T_CZH = T_MD; | |
3226 else | |
3227 T_CZH = T_MR; | |
3228 } | |
3229 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3230 // "Sb" and "Sf" come in pairs |
7 | 3231 if (*T_CSB == NUL || *T_CSF == NUL) |
3232 { | |
3233 T_CSB = empty_option; | |
3234 T_CSF = empty_option; | |
3235 } | |
3236 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3237 // "AB" and "AF" come in pairs |
7 | 3238 if (*T_CAB == NUL || *T_CAF == NUL) |
3239 { | |
3240 T_CAB = empty_option; | |
3241 T_CAF = empty_option; | |
3242 } | |
3243 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3244 // if 'Sb' and 'AB' are not defined, reset "Co" |
7 | 3245 if (*T_CSB == NUL && *T_CAB == NUL) |
1941 | 3246 free_one_termoption(T_CCO); |
7 | 3247 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3248 // Set 'weirdinvert' according to value of 't_xs' |
7 | 3249 p_wiv = (*T_XS != NUL); |
3250 } | |
3251 need_gather = TRUE; | |
3252 | |
20181
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3253 // Set t_colors to the value of $COLORS or t_Co. Ignore $COLORS in the |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3254 // GUI. |
7 | 3255 t_colors = atoi((char *)T_CCO); |
20181
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3256 #ifdef FEAT_GUI |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3257 if (!gui.in_use) |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3258 #endif |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
3259 { |
20181
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3260 env_colors = mch_getenv((char_u *)"COLORS"); |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3261 if (env_colors != NULL && isdigit(*env_colors)) |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3262 { |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3263 int colors = atoi((char *)env_colors); |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3264 |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3265 if (colors != t_colors) |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3266 set_color_count(colors); |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3267 } |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
3268 } |
7 | 3269 } |
3270 | |
3271 #if (defined(FEAT_GUI) && (defined(FEAT_MENU) || !defined(USE_ON_FLY_SCROLL))) \ | |
3272 || defined(PROTO) | |
3273 /* | |
3274 * Represent the given long_u as individual bytes, with the most significant | |
3275 * byte first, and store them in dst. | |
3276 */ | |
3277 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3278 add_long_to_buf(long_u val, char_u *dst) |
7 | 3279 { |
3280 int i; | |
3281 int shift; | |
3282 | |
1883 | 3283 for (i = 1; i <= (int)sizeof(long_u); i++) |
7 | 3284 { |
3285 shift = 8 * (sizeof(long_u) - i); | |
3286 dst[i - 1] = (char_u) ((val >> shift) & 0xff); | |
3287 } | |
3288 } | |
3289 | |
3290 /* | |
3291 * Interpret the next string of bytes in buf as a long integer, with the most | |
3292 * significant byte first. Note that it is assumed that buf has been through | |
3293 * inchar(), so that NUL and K_SPECIAL will be represented as three bytes each. | |
3294 * Puts result in val, and returns the number of bytes read from buf | |
3295 * (between sizeof(long_u) and 2 * sizeof(long_u)), or -1 if not enough bytes | |
3296 * were present. | |
3297 */ | |
3298 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3299 get_long_from_buf(char_u *buf, long_u *val) |
7 | 3300 { |
3301 int len; | |
3302 char_u bytes[sizeof(long_u)]; | |
3303 int i; | |
3304 int shift; | |
3305 | |
3306 *val = 0; | |
3307 len = get_bytes_from_buf(buf, bytes, (int)sizeof(long_u)); | |
3308 if (len != -1) | |
3309 { | |
1883 | 3310 for (i = 0; i < (int)sizeof(long_u); i++) |
7 | 3311 { |
3312 shift = 8 * (sizeof(long_u) - 1 - i); | |
3313 *val += (long_u)bytes[i] << shift; | |
3314 } | |
3315 } | |
3316 return len; | |
3317 } | |
3318 #endif | |
3319 | |
3320 /* | |
3321 * Read the next num_bytes bytes from buf, and store them in bytes. Assume | |
3322 * that buf has been through inchar(). Returns the actual number of bytes used | |
3323 * from buf (between num_bytes and num_bytes*2), or -1 if not enough bytes were | |
3324 * available. | |
3325 */ | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
3326 int |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3327 get_bytes_from_buf(char_u *buf, char_u *bytes, int num_bytes) |
7 | 3328 { |
3329 int len = 0; | |
3330 int i; | |
3331 char_u c; | |
3332 | |
3333 for (i = 0; i < num_bytes; i++) | |
3334 { | |
3335 if ((c = buf[len++]) == NUL) | |
3336 return -1; | |
3337 if (c == K_SPECIAL) | |
3338 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3339 if (buf[len] == NUL || buf[len + 1] == NUL) // cannot happen? |
7 | 3340 return -1; |
3341 if (buf[len++] == (int)KS_ZERO) | |
3342 c = NUL; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3343 // else it should be KS_SPECIAL; when followed by KE_FILLER c is |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3344 // K_SPECIAL, or followed by KE_CSI and c must be CSI. |
5076
19ed30f7cef7
updated for version 7.3.1281
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
3345 if (buf[len++] == (int)KE_CSI) |
19ed30f7cef7
updated for version 7.3.1281
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
3346 c = CSI; |
7 | 3347 } |
1160 | 3348 else if (c == CSI && buf[len] == KS_EXTRA |
3349 && buf[len + 1] == (int)KE_CSI) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3350 // CSI is stored as CSI KS_SPECIAL KE_CSI to avoid confusion with |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3351 // the start of a special key, see add_to_input_buf_csi(). |
667 | 3352 len += 2; |
7 | 3353 bytes[i] = c; |
3354 } | |
3355 return len; | |
3356 } | |
3357 | |
3358 /* | |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3359 * Check if the new shell size is valid, correct it if it's too small or way |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3360 * too big. |
7 | 3361 */ |
3362 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3363 check_shellsize(void) |
7 | 3364 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3365 if (Rows < min_rows()) // need room for one window and command line |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3366 Rows = min_rows(); |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3367 limit_screen_size(); |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3368 } |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3369 |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3370 /* |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3371 * Limit Rows and Columns to avoid an overflow in Rows * Columns. |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3372 */ |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3373 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3374 limit_screen_size(void) |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3375 { |
7 | 3376 if (Columns < MIN_COLUMNS) |
3377 Columns = MIN_COLUMNS; | |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3378 else if (Columns > 10000) |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3379 Columns = 10000; |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3380 if (Rows > 1000) |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3381 Rows = 1000; |
7 | 3382 } |
3383 | |
41 | 3384 /* |
3385 * Invoked just before the screen structures are going to be (re)allocated. | |
3386 */ | |
7 | 3387 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3388 win_new_shellsize(void) |
7 | 3389 { |
3390 static int old_Rows = 0; | |
3391 static int old_Columns = 0; | |
3392 | |
3393 if (old_Rows != Rows || old_Columns != Columns) | |
3394 ui_new_shellsize(); | |
3395 if (old_Rows != Rows) | |
3396 { | |
24228
1e85e76f9e76
patch 8.2.2655: The -w command line argument doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24194
diff
changeset
|
3397 // If 'window' uses the whole screen, keep it using that. |
1e85e76f9e76
patch 8.2.2655: The -w command line argument doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24194
diff
changeset
|
3398 // Don't change it when set with "-w size" on the command line. |
27996
3ae5bc51d39d
patch 8.2.4523: when gvim is started maximized the 'window' option isn't set
Bram Moolenaar <Bram@vim.org>
parents:
27930
diff
changeset
|
3399 if (p_window == old_Rows - 1 |
3ae5bc51d39d
patch 8.2.4523: when gvim is started maximized the 'window' option isn't set
Bram Moolenaar <Bram@vim.org>
parents:
27930
diff
changeset
|
3400 || (old_Rows == 0 && !option_was_set((char_u *)"window"))) |
164 | 3401 p_window = Rows - 1; |
7 | 3402 old_Rows = Rows; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3403 shell_new_rows(); // update window sizes |
7 | 3404 } |
3405 if (old_Columns != Columns) | |
3406 { | |
3407 old_Columns = Columns; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3408 shell_new_columns(); // update window sizes |
7 | 3409 } |
3410 } | |
3411 | |
3412 /* | |
3413 * Call this function when the Vim shell has been resized in any way. | |
3414 * Will obtain the current size and redraw (also when size didn't change). | |
3415 */ | |
3416 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3417 shell_resized(void) |
7 | 3418 { |
3419 set_shellsize(0, 0, FALSE); | |
3420 } | |
3421 | |
3422 /* | |
3423 * Check if the shell size changed. Handle a resize. | |
3424 * When the size didn't change, nothing happens. | |
3425 */ | |
3426 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3427 shell_resized_check(void) |
7 | 3428 { |
3429 int old_Rows = Rows; | |
3430 int old_Columns = Columns; | |
3431 | |
3770 | 3432 if (!exiting |
3433 #ifdef FEAT_GUI | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3434 // Do not get the size when executing a shell command during |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3435 // startup. |
3770 | 3436 && !gui.starting |
3437 #endif | |
3438 ) | |
2673 | 3439 { |
3440 (void)ui_get_shellsize(); | |
3441 check_shellsize(); | |
3442 if (old_Rows != Rows || old_Columns != Columns) | |
3443 shell_resized(); | |
3444 } | |
7 | 3445 } |
3446 | |
3447 /* | |
3448 * Set size of the Vim shell. | |
3449 * If 'mustset' is TRUE, we must set Rows and Columns, do not get the real | |
3450 * window size (this is used for the :win command). | |
3451 * If 'mustset' is FALSE, we may try to get the real window size and if | |
3452 * it fails use 'width' and 'height'. | |
3453 */ | |
3454 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3455 set_shellsize(int width, int height, int mustset) |
7 | 3456 { |
3457 static int busy = FALSE; | |
3458 | |
3459 /* | |
3460 * Avoid recursiveness, can happen when setting the window size causes | |
3461 * another window-changed signal. | |
3462 */ | |
3463 if (busy) | |
3464 return; | |
3465 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3466 if (width < 0 || height < 0) // just checking... |
7 | 3467 return; |
3468 | |
3068 | 3469 if (State == HITRETURN || State == SETWSIZE) |
7 | 3470 { |
17330
b2918bd457cb
patch 8.1.1664: GUI resize may cause changing Rows at a bad time
Bram Moolenaar <Bram@vim.org>
parents:
16961
diff
changeset
|
3471 // postpone the resizing |
7 | 3472 State = SETWSIZE; |
3473 return; | |
3474 } | |
3475 | |
17330
b2918bd457cb
patch 8.1.1664: GUI resize may cause changing Rows at a bad time
Bram Moolenaar <Bram@vim.org>
parents:
16961
diff
changeset
|
3476 if (updating_screen) |
b2918bd457cb
patch 8.1.1664: GUI resize may cause changing Rows at a bad time
Bram Moolenaar <Bram@vim.org>
parents:
16961
diff
changeset
|
3477 // resizing while in update_screen() may cause a crash |
b2918bd457cb
patch 8.1.1664: GUI resize may cause changing Rows at a bad time
Bram Moolenaar <Bram@vim.org>
parents:
16961
diff
changeset
|
3478 return; |
b2918bd457cb
patch 8.1.1664: GUI resize may cause changing Rows at a bad time
Bram Moolenaar <Bram@vim.org>
parents:
16961
diff
changeset
|
3479 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3480 // curwin->w_buffer can be NULL when we are closing a window and the |
23410
ae3421daa981
patch 8.2.2248: ASAN error on exit with GUI
Bram Moolenaar <Bram@vim.org>
parents:
23408
diff
changeset
|
3481 // buffer (or window) has already been closed and removing a scrollbar |
ae3421daa981
patch 8.2.2248: ASAN error on exit with GUI
Bram Moolenaar <Bram@vim.org>
parents:
23408
diff
changeset
|
3482 // causes a resize event. Don't resize then, it will happen after entering |
ae3421daa981
patch 8.2.2248: ASAN error on exit with GUI
Bram Moolenaar <Bram@vim.org>
parents:
23408
diff
changeset
|
3483 // another buffer. |
ae3421daa981
patch 8.2.2248: ASAN error on exit with GUI
Bram Moolenaar <Bram@vim.org>
parents:
23408
diff
changeset
|
3484 if (curwin->w_buffer == NULL || curwin->w_lines == NULL) |
3068 | 3485 return; |
3486 | |
7 | 3487 ++busy; |
3488 | |
3489 #ifdef AMIGA | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3490 out_flush(); // must do this before mch_get_shellsize() for |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3491 // some obscure reason |
7 | 3492 #endif |
3493 | |
3494 if (mustset || (ui_get_shellsize() == FAIL && height != 0)) | |
3495 { | |
3496 Rows = height; | |
3497 Columns = width; | |
3498 check_shellsize(); | |
3499 ui_set_shellsize(mustset); | |
3500 } | |
3501 else | |
3502 check_shellsize(); | |
3503 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3504 // The window layout used to be adjusted here, but it now happens in |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3505 // screenalloc() (also invoked from screenclear()). That is because the |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3506 // "busy" check above may skip this, but not screenalloc(). |
7 | 3507 |
3508 if (State != ASKMORE && State != EXTERNCMD && State != CONFIRM) | |
3509 screenclear(); | |
3510 else | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3511 screen_start(); // don't know where cursor is now |
7 | 3512 |
3513 if (starting != NO_SCREEN) | |
3514 { | |
3515 maketitle(); | |
26336
a2e6da79274d
patch 8.2.3699: the +title feature adds a lot of #ifdef but little code
Bram Moolenaar <Bram@vim.org>
parents:
26177
diff
changeset
|
3516 |
7 | 3517 changed_line_abv_curs(); |
3518 invalidate_botline(); | |
3519 | |
3520 /* | |
3521 * We only redraw when it's needed: | |
3522 * - While at the more prompt or executing an external command, don't | |
3523 * redraw, but position the cursor. | |
3524 * - While editing the command line, only redraw that. | |
3525 * - in Ex mode, don't redraw anything. | |
3526 * - Otherwise, redraw right now, and position the cursor. | |
3527 * Always need to call update_screen() or screenalloc(), to make | |
3528 * sure Rows/Columns and the size of ScreenLines[] is correct! | |
3529 */ | |
3530 if (State == ASKMORE || State == EXTERNCMD || State == CONFIRM | |
3531 || exmode_active) | |
3532 { | |
3533 screenalloc(FALSE); | |
3534 repeat_message(); | |
3535 } | |
3536 else | |
3537 { | |
1024 | 3538 if (curwin->w_p_scb) |
3539 do_check_scrollbind(TRUE); | |
3540 if (State & CMDLINE) | |
648 | 3541 { |
1024 | 3542 update_screen(NOT_VALID); |
3543 redrawcmdline(); | |
648 | 3544 } |
3545 else | |
1024 | 3546 { |
3547 update_topline(); | |
3548 if (pum_visible()) | |
3549 { | |
3550 redraw_later(NOT_VALID); | |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12513
diff
changeset
|
3551 ins_compl_show_pum(); |
1024 | 3552 } |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12513
diff
changeset
|
3553 update_screen(NOT_VALID); |
1024 | 3554 if (redrawing()) |
3555 setcursor(); | |
3556 } | |
7 | 3557 } |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3558 cursor_on(); // redrawing may have switched it off |
7 | 3559 } |
3560 out_flush(); | |
3561 --busy; | |
3562 } | |
3563 | |
3564 /* | |
3565 * Set the terminal to TMODE_RAW (for Normal mode) or TMODE_COOK (for external | |
3566 * commands and Ex mode). | |
3567 */ | |
3568 void | |
20450
d5d89c24eec7
patch 8.2.0779: tmode_T not used everywhere
Bram Moolenaar <Bram@vim.org>
parents:
20439
diff
changeset
|
3569 settmode(tmode_T tmode) |
7 | 3570 { |
3571 #ifdef FEAT_GUI | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3572 // don't set the term where gvim was started to any mode |
7 | 3573 if (gui.in_use) |
3574 return; | |
3575 #endif | |
3576 | |
3577 if (full_screen) | |
3578 { | |
3579 /* | |
20437
3bb4dea4a164
patch 8.2.0773: switching to raw mode every time ":" is used
Bram Moolenaar <Bram@vim.org>
parents:
20425
diff
changeset
|
3580 * When returning after calling a shell cur_tmode is TMODE_UNKNOWN, |
3bb4dea4a164
patch 8.2.0773: switching to raw mode every time ":" is used
Bram Moolenaar <Bram@vim.org>
parents:
20425
diff
changeset
|
3581 * set the terminal to raw mode, even though we think it already is, |
3bb4dea4a164
patch 8.2.0773: switching to raw mode every time ":" is used
Bram Moolenaar <Bram@vim.org>
parents:
20425
diff
changeset
|
3582 * because the shell program may have reset the terminal mode. |
7 | 3583 * When we think the terminal is normal, don't try to set it to |
3584 * normal again, because that causes problems (logout!) on some | |
3585 * machines. | |
3586 */ | |
20437
3bb4dea4a164
patch 8.2.0773: switching to raw mode every time ":" is used
Bram Moolenaar <Bram@vim.org>
parents:
20425
diff
changeset
|
3587 if (tmode != cur_tmode) |
7 | 3588 { |
3589 #ifdef FEAT_TERMRESPONSE | |
1691 | 3590 # ifdef FEAT_GUI |
3591 if (!gui.in_use && !gui.starting) | |
3592 # endif | |
3593 { | |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3594 // May need to check for T_CRV response and termcodes, it |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3595 // doesn't work in Cooked mode, an external program may get |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3596 // them. |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3597 if (tmode != TMODE_RAW && termrequest_any_pending()) |
1691 | 3598 (void)vpeekc_nomap(); |
3599 check_for_codes_from_term(); | |
3600 } | |
7 | 3601 #endif |
3602 if (tmode != TMODE_RAW) | |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3603 mch_setmouse(FALSE); // switch mouse off |
20439
d4b2a8675b78
patch 8.2.0774: t_TI and t_TE are output when using 'visualbell'
Bram Moolenaar <Bram@vim.org>
parents:
20437
diff
changeset
|
3604 |
d4b2a8675b78
patch 8.2.0774: t_TI and t_TE are output when using 'visualbell'
Bram Moolenaar <Bram@vim.org>
parents:
20437
diff
changeset
|
3605 // Disable bracketed paste and modifyOtherKeys in cooked mode. |
d4b2a8675b78
patch 8.2.0774: t_TI and t_TE are output when using 'visualbell'
Bram Moolenaar <Bram@vim.org>
parents:
20437
diff
changeset
|
3606 // Avoid doing this too often, on some terminals the codes are not |
d4b2a8675b78
patch 8.2.0774: t_TI and t_TE are output when using 'visualbell'
Bram Moolenaar <Bram@vim.org>
parents:
20437
diff
changeset
|
3607 // handled properly. |
d4b2a8675b78
patch 8.2.0774: t_TI and t_TE are output when using 'visualbell'
Bram Moolenaar <Bram@vim.org>
parents:
20437
diff
changeset
|
3608 if (termcap_active && tmode != TMODE_SLEEP |
d4b2a8675b78
patch 8.2.0774: t_TI and t_TE are output when using 'visualbell'
Bram Moolenaar <Bram@vim.org>
parents:
20437
diff
changeset
|
3609 && cur_tmode != TMODE_SLEEP) |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3610 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3611 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3612 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3613 #endif |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3614 if (tmode != TMODE_RAW) |
20425
426ef48be465
patch 8.2.0767: modifyOtherKeys active when using a shell command in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
20181
diff
changeset
|
3615 { |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3616 out_str(T_BD); // disable bracketed paste mode |
20425
426ef48be465
patch 8.2.0767: modifyOtherKeys active when using a shell command in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
20181
diff
changeset
|
3617 out_str(T_CTE); // possibly disables modifyOtherKeys |
426ef48be465
patch 8.2.0767: modifyOtherKeys active when using a shell command in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
20181
diff
changeset
|
3618 } |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3619 else |
20425
426ef48be465
patch 8.2.0767: modifyOtherKeys active when using a shell command in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
20181
diff
changeset
|
3620 { |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3621 out_str(T_BE); // enable bracketed paste mode (should |
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3622 // be before mch_settmode(). |
20425
426ef48be465
patch 8.2.0767: modifyOtherKeys active when using a shell command in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
20181
diff
changeset
|
3623 out_str(T_CTI); // possibly enables modifyOtherKeys |
426ef48be465
patch 8.2.0767: modifyOtherKeys active when using a shell command in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
20181
diff
changeset
|
3624 } |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3625 } |
7 | 3626 out_flush(); |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3627 mch_settmode(tmode); // machine specific function |
7 | 3628 cur_tmode = tmode; |
3629 if (tmode == TMODE_RAW) | |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3630 setmouse(); // may switch mouse on |
7 | 3631 out_flush(); |
3632 } | |
3633 #ifdef FEAT_TERMRESPONSE | |
3634 may_req_termresponse(); | |
3635 #endif | |
3636 } | |
3637 } | |
3638 | |
3639 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3640 starttermcap(void) |
7 | 3641 { |
3642 if (full_screen && !termcap_active) | |
3643 { | |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3644 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3645 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3646 #endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3647 out_str(T_TI); // start termcap mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3648 out_str(T_CTI); // start "raw" mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3649 out_str(T_KS); // start "keypad transmit" mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3650 out_str(T_BE); // enable bracketed paste mode |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3651 |
24045
1b56d4c75d19
patch 8.2.2564: focus events end Insert mode if 'esckeys' is not set
Bram Moolenaar <Bram@vim.org>
parents:
23774
diff
changeset
|
3652 #if defined(UNIX) || defined(VMS) |
1b56d4c75d19
patch 8.2.2564: focus events end Insert mode if 'esckeys' is not set
Bram Moolenaar <Bram@vim.org>
parents:
23774
diff
changeset
|
3653 // Enable xterm's focus reporting mode when 'esckeys' is set. |
27930
1a702abffaf3
patch 8.2.4490: terminal focus reporting only works for xterm-like terminals
Bram Moolenaar <Bram@vim.org>
parents:
27684
diff
changeset
|
3654 if (p_ek && *T_FE != NUL) |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3655 out_str(T_FE); |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3656 #endif |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3657 |
7 | 3658 out_flush(); |
3659 termcap_active = TRUE; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3660 screen_start(); // don't know where cursor is now |
7 | 3661 #ifdef FEAT_TERMRESPONSE |
1691 | 3662 # ifdef FEAT_GUI |
3663 if (!gui.in_use && !gui.starting) | |
3664 # endif | |
3665 { | |
3666 may_req_termresponse(); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3667 // Immediately check for a response. If t_Co changes, we don't |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3668 // want to redraw with wrong colors first. |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3669 if (crv_status.tr_progress == STATUS_SENT) |
1691 | 3670 check_for_codes_from_term(); |
3671 } | |
7 | 3672 #endif |
3673 } | |
3674 } | |
3675 | |
3676 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3677 stoptermcap(void) |
7 | 3678 { |
3679 screen_stop_highlight(); | |
3680 reset_cterm_colors(); | |
3681 if (termcap_active) | |
3682 { | |
3683 #ifdef FEAT_TERMRESPONSE | |
1691 | 3684 # ifdef FEAT_GUI |
3685 if (!gui.in_use && !gui.starting) | |
3686 # endif | |
3687 { | |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3688 // May need to discard T_CRV, T_U7 or T_RBG response. |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3689 if (termrequest_any_pending()) |
4391 | 3690 { |
3691 # ifdef UNIX | |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3692 // Give the terminal a chance to respond. |
21927
88070e222e82
patch 8.2.1513: cannot interrupt shell used for filename expansion
Bram Moolenaar <Bram@vim.org>
parents:
21624
diff
changeset
|
3693 mch_delay(100L, 0); |
4391 | 3694 # endif |
3695 # ifdef TCIFLUSH | |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3696 // Discard data received but not read. |
4391 | 3697 if (exiting) |
3698 tcflush(fileno(stdin), TCIFLUSH); | |
3699 # endif | |
3700 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3701 // Check for termcodes first, otherwise an external program may |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3702 // get them. |
1691 | 3703 check_for_codes_from_term(); |
3704 } | |
7 | 3705 #endif |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3706 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3707 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3708 #endif |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3709 |
24045
1b56d4c75d19
patch 8.2.2564: focus events end Insert mode if 'esckeys' is not set
Bram Moolenaar <Bram@vim.org>
parents:
23774
diff
changeset
|
3710 #if defined(UNIX) || defined(VMS) |
1b56d4c75d19
patch 8.2.2564: focus events end Insert mode if 'esckeys' is not set
Bram Moolenaar <Bram@vim.org>
parents:
23774
diff
changeset
|
3711 // Disable xterm's focus reporting mode if 'esckeys' is set. |
27930
1a702abffaf3
patch 8.2.4490: terminal focus reporting only works for xterm-like terminals
Bram Moolenaar <Bram@vim.org>
parents:
27684
diff
changeset
|
3712 if (p_ek && *T_FD != NUL) |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3713 out_str(T_FD); |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3714 #endif |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3715 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3716 out_str(T_BD); // disable bracketed paste mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3717 out_str(T_KE); // stop "keypad transmit" mode |
7 | 3718 out_flush(); |
3719 termcap_active = FALSE; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3720 cursor_on(); // just in case it is still off |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3721 out_str(T_CTE); // stop "raw" mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3722 out_str(T_TE); // stop termcap mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3723 screen_start(); // don't know where cursor is now |
7 | 3724 out_flush(); |
3725 } | |
3726 } | |
3727 | |
5932 | 3728 #if defined(FEAT_TERMRESPONSE) || defined(PROTO) |
7 | 3729 /* |
3730 * Request version string (for xterm) when needed. | |
3731 * Only do this after switching to raw mode, otherwise the result will be | |
3732 * echoed. | |
626 | 3733 * Only do this after startup has finished, to avoid that the response comes |
1221 | 3734 * while executing "-c !cmd" or even after "-c quit". |
7 | 3735 * Only do this after termcap mode has been started, otherwise the codes for |
3736 * the cursor keys may be wrong. | |
620 | 3737 * Only do this when 'esckeys' is on, otherwise the response causes trouble in |
3738 * Insert mode. | |
164 | 3739 * On Unix only do it when both output and input are a tty (avoid writing |
3740 * request to terminal while reading from a file). | |
7 | 3741 * The result is caught in check_termcode(). |
3742 */ | |
626 | 3743 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3744 may_req_termresponse(void) |
7 | 3745 { |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3746 if (crv_status.tr_progress == STATUS_GET |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
3747 && can_get_termresponse() |
626 | 3748 && starting == 0 |
7 | 3749 && *T_CRV != NUL) |
3750 { | |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3751 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3752 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3753 #endif |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3754 LOG_TR(("Sending CRV request")); |
7 | 3755 out_str(T_CRV); |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3756 termrequest_sent(&crv_status); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3757 // check for the characters now, otherwise they might be eaten by |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3758 // get_keystroke() |
7 | 3759 out_flush(); |
3760 (void)vpeekc_nomap(); | |
3761 } | |
3762 } | |
4215 | 3763 |
3764 /* | |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3765 * Send sequences to the terminal and check with t_u7 how the cursor moves, to |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3766 * find out properties of the terminal. |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
3767 * Note that this goes out before T_CRV, so that the result can be used when |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
3768 * the termresponse arrives. |
4215 | 3769 */ |
3770 void | |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3771 check_terminal_behavior(void) |
4215 | 3772 { |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3773 int did_send = FALSE; |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3774 |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3775 if (!can_get_termresponse() || starting != 0 || *T_U7 == NUL) |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3776 return; |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3777 |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3778 if (u7_status.tr_progress == STATUS_GET |
4215 | 3779 && !option_was_set((char_u *)"ambiwidth")) |
3780 { | |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3781 char_u buf[16]; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3782 |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3783 // Ambiguous width check. |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3784 // Check how the terminal treats ambiguous character width (UAX #11). |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3785 // First, we move the cursor to (1, 0) and print a test ambiguous |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3786 // character \u25bd (WHITE DOWN-POINTING TRIANGLE) and then query |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3787 // the current cursor position. If the terminal treats \u25bd as |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3788 // single width, the position is (1, 1), or if it is treated as double |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3789 // width, that will be (1, 2). This function has the side effect that |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3790 // changes cursor position, so it must be called immediately after |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3791 // entering termcap mode. |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3792 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3793 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3794 #endif |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3795 LOG_TR(("Sending request for ambiwidth check")); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3796 // Do this in the second row. In the first row the returned sequence |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3797 // may be CSI 1;2R, which is the same as <S-F3>. |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3798 term_windgoto(1, 0); |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3799 buf[mb_char2bytes(0x25bd, buf)] = NUL; |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3800 out_str(buf); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3801 out_str(T_U7); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3802 termrequest_sent(&u7_status); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3803 out_flush(); |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3804 did_send = TRUE; |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3805 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3806 // This overwrites a few characters on the screen, a redraw is needed |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3807 // after this. Clear them out for now. |
17482
6cf077f59152
patch 8.1.1739: deleted match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents:
17330
diff
changeset
|
3808 screen_stop_highlight(); |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3809 term_windgoto(1, 0); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3810 out_str((char_u *)" "); |
21226
421c4ed6b949
patch 8.2.1164: text cleared by checking terminal properties not redrawn
Bram Moolenaar <Bram@vim.org>
parents:
20935
diff
changeset
|
3811 line_was_clobbered(1); |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3812 } |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3813 |
27004
671664c5faa4
patch 8.2.4031: crash in xterm with only two lines
Bram Moolenaar <Bram@vim.org>
parents:
26917
diff
changeset
|
3814 if (xcc_status.tr_progress == STATUS_GET && Rows > 2) |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3815 { |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3816 // 2. Check compatibility with xterm. |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3817 // We move the cursor to (2, 0), print a test sequence and then query |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3818 // the current cursor position. If the terminal properly handles |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3819 // unknown DCS string and CSI sequence with intermediate byte, the test |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3820 // sequence is ignored and the cursor does not move. If the terminal |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3821 // handles test sequence incorrectly, a garbage string is displayed and |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3822 // the cursor does move. |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3823 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3824 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3825 #endif |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3826 LOG_TR(("Sending xterm compatibility test sequence.")); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3827 // Do this in the third row. Second row is used by ambiguous |
23229
b545334ae654
patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents:
22956
diff
changeset
|
3828 // character width check. |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3829 term_windgoto(2, 0); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3830 // send the test DCS string. |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3831 out_str((char_u *)"\033Pzz\033\\"); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3832 // send the test CSI sequence with intermediate byte. |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3833 out_str((char_u *)"\033[0%m"); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3834 out_str(T_U7); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3835 termrequest_sent(&xcc_status); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3836 out_flush(); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3837 did_send = TRUE; |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3838 |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3839 // If the terminal handles test sequence incorrectly, garbage text is |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3840 // displayed. Clear them out for now. |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3841 screen_stop_highlight(); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3842 term_windgoto(2, 0); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3843 out_str((char_u *)" "); |
21226
421c4ed6b949
patch 8.2.1164: text cleared by checking terminal properties not redrawn
Bram Moolenaar <Bram@vim.org>
parents:
20935
diff
changeset
|
3844 line_was_clobbered(2); |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3845 } |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3846 |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3847 if (did_send) |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3848 { |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3849 term_windgoto(0, 0); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3850 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3851 // Need to reset the known cursor position. |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3852 screen_start(); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3853 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3854 // check for the characters now, otherwise they might be eaten by |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3855 // get_keystroke() |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3856 out_flush(); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3857 (void)vpeekc_nomap(); |
4215 | 3858 } |
3859 } | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3860 |
6874 | 3861 /* |
6885 | 3862 * Similar to requesting the version string: Request the terminal background |
3863 * color when it is the right moment. | |
6874 | 3864 */ |
3865 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3866 may_req_bg_color(void) |
6874 | 3867 { |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3868 if (can_get_termresponse() && starting == 0) |
6874 | 3869 { |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3870 int didit = FALSE; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3871 |
12640
a715f0b44532
patch 8.0.1198: older compilers don't know uint8_t
Christian Brabandt <cb@256bit.org>
parents:
12634
diff
changeset
|
3872 # ifdef FEAT_TERMINAL |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3873 // Only request foreground if t_RF is set. |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3874 if (rfg_status.tr_progress == STATUS_GET && *T_RFG != NUL) |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3875 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3876 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3877 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3878 #endif |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3879 LOG_TR(("Sending FG request")); |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3880 out_str(T_RFG); |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3881 termrequest_sent(&rfg_status); |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3882 didit = TRUE; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3883 } |
12640
a715f0b44532
patch 8.0.1198: older compilers don't know uint8_t
Christian Brabandt <cb@256bit.org>
parents:
12634
diff
changeset
|
3884 # endif |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3885 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3886 // Only request background if t_RB is set. |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3887 if (rbg_status.tr_progress == STATUS_GET && *T_RBG != NUL) |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3888 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3889 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3890 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3891 #endif |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3892 LOG_TR(("Sending BG request")); |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3893 out_str(T_RBG); |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3894 termrequest_sent(&rbg_status); |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3895 didit = TRUE; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3896 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3897 |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3898 if (didit) |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3899 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3900 // check for the characters now, otherwise they might be eaten by |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3901 // get_keystroke() |
12232
1553d1a4bf7c
patch 8.0.0996: Mac: t_RS is echoed on the screne in Terminal.app
Christian Brabandt <cb@256bit.org>
parents:
12226
diff
changeset
|
3902 out_flush(); |
1553d1a4bf7c
patch 8.0.0996: Mac: t_RS is echoed on the screne in Terminal.app
Christian Brabandt <cb@256bit.org>
parents:
12226
diff
changeset
|
3903 (void)vpeekc_nomap(); |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3904 } |
6874 | 3905 } |
3906 } | |
3907 | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3908 # ifdef DEBUG_TERMRESPONSE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3909 static void |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3910 log_tr(const char *fmt, ...) |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3911 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3912 static FILE *fd_tr = NULL; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3913 static proftime_T start; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3914 proftime_T now; |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3915 va_list ap; |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3916 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3917 if (fd_tr == NULL) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3918 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3919 fd_tr = fopen("termresponse.log", "w"); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3920 profile_start(&start); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3921 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3922 now = start; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3923 profile_end(&now); |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3924 fprintf(fd_tr, "%s: %s ", profile_msg(&now), |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3925 must_redraw == NOT_VALID ? "NV" |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3926 : must_redraw == CLEAR ? "CL" : " "); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3927 va_start(ap, fmt); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3928 vfprintf(fd_tr, fmt, ap); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3929 va_end(ap); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3930 fputc('\n', fd_tr); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3931 fflush(fd_tr); |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3932 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3933 # endif |
7 | 3934 #endif |
3935 | |
3936 /* | |
3937 * Return TRUE when saving and restoring the screen. | |
3938 */ | |
3939 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3940 swapping_screen(void) |
7 | 3941 { |
3942 return (full_screen && *T_TI != NUL); | |
3943 } | |
3944 | |
3945 /* | |
3946 * By outputting the 'cursor very visible' termcap code, for some windowed | |
3947 * terminals this makes the screen scrolled to the correct position. | |
3948 * Used when starting Vim or returning from a shell. | |
3949 */ | |
3950 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3951 scroll_start(void) |
7 | 3952 { |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3953 if (*T_VS != NUL && *T_CVS != NUL) |
7 | 3954 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3955 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3956 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3957 #endif |
7 | 3958 out_str(T_VS); |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3959 out_str(T_CVS); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3960 screen_start(); // don't know where cursor is now |
7 | 3961 } |
3962 } | |
3963 | |
24428
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
3964 // True if cursor is not visible |
7 | 3965 static int cursor_is_off = FALSE; |
3966 | |
24428
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
3967 // True if cursor is not visible due to an ongoing cursor-less sleep |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
3968 static int cursor_is_asleep = FALSE; |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
3969 |
7 | 3970 /* |
14581
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3971 * Enable the cursor without checking if it's already enabled. |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3972 */ |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3973 void |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3974 cursor_on_force(void) |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3975 { |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3976 out_str(T_VE); |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3977 cursor_is_off = FALSE; |
24428
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
3978 cursor_is_asleep = FALSE; |
14581
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3979 } |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3980 |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3981 /* |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3982 * Enable the cursor if it's currently off. |
7 | 3983 */ |
3984 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3985 cursor_on(void) |
7 | 3986 { |
24428
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
3987 if (cursor_is_off && !cursor_is_asleep) |
14581
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3988 cursor_on_force(); |
7 | 3989 } |
3990 | |
3991 /* | |
3992 * Disable the cursor. | |
3993 */ | |
3994 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3995 cursor_off(void) |
7 | 3996 { |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3997 if (full_screen && !cursor_is_off) |
7 | 3998 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3999 out_str(T_VI); // disable cursor |
7 | 4000 cursor_is_off = TRUE; |
4001 } | |
4002 } | |
4003 | |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
27004
diff
changeset
|
4004 #ifdef FEAT_GUI |
24428
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4005 /* |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4006 * Check whether the cursor is invisible due to an ongoing cursor-less sleep |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4007 */ |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4008 int |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4009 cursor_is_sleeping(void) |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4010 { |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4011 return cursor_is_asleep; |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4012 } |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
27004
diff
changeset
|
4013 #endif |
24428
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4014 |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4015 /* |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4016 * Disable the cursor and mark it disabled by cursor-less sleep |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4017 */ |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4018 void |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4019 cursor_sleep(void) |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4020 { |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4021 cursor_is_asleep = TRUE; |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4022 cursor_off(); |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4023 } |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4024 |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4025 /* |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4026 * Enable the cursor and mark it not disabled by cursor-less sleep |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4027 */ |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4028 void |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4029 cursor_unsleep(void) |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4030 { |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4031 cursor_is_asleep = FALSE; |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4032 cursor_on(); |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4033 } |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4034 |
39 | 4035 #if defined(CURSOR_SHAPE) || defined(PROTO) |
7 | 4036 /* |
6727 | 4037 * Set cursor shape to match Insert or Replace mode. |
36 | 4038 */ |
4039 void | |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4040 term_cursor_mode(int forced) |
36 | 4041 { |
12078
d21b8f31b296
patch 8.0.0919: cursor color isn't set on startup
Christian Brabandt <cb@256bit.org>
parents:
12076
diff
changeset
|
4042 static int showing_mode = -1; |
6727 | 4043 char_u *p; |
4044 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4045 // Only do something when redrawing the screen and we can restore the |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4046 // mode. |
6727 | 4047 if (!full_screen || *T_CEI == NUL) |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4048 { |
12184
76fbd85c3cea
patch 8.0.0972: compiler warnings for unused variables
Christian Brabandt <cb@256bit.org>
parents:
12174
diff
changeset
|
4049 # ifdef FEAT_TERMRESPONSE |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4050 if (forced && initial_cursor_shape > 0) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4051 // Restore to initial values. |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4052 term_cursor_shape(initial_cursor_shape, initial_cursor_blink); |
12184
76fbd85c3cea
patch 8.0.0972: compiler warnings for unused variables
Christian Brabandt <cb@256bit.org>
parents:
12174
diff
changeset
|
4053 # endif |
36 | 4054 return; |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4055 } |
36 | 4056 |
6727 | 4057 if ((State & REPLACE) == REPLACE) |
36 | 4058 { |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4059 if (forced || showing_mode != REPLACE) |
6727 | 4060 { |
4061 if (*T_CSR != NUL) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4062 p = T_CSR; // Replace mode cursor |
6727 | 4063 else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4064 p = T_CSI; // fall back to Insert mode cursor |
6727 | 4065 if (*p != NUL) |
4066 { | |
4067 out_str(p); | |
4068 showing_mode = REPLACE; | |
4069 } | |
4070 } | |
36 | 4071 } |
6727 | 4072 else if (State & INSERT) |
36 | 4073 { |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4074 if ((forced || showing_mode != INSERT) && *T_CSI != NUL) |
6727 | 4075 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4076 out_str(T_CSI); // Insert mode cursor |
6727 | 4077 showing_mode = INSERT; |
4078 } | |
4079 } | |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4080 else if (forced || showing_mode != NORMAL) |
6727 | 4081 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4082 out_str(T_CEI); // non-Insert mode cursor |
6727 | 4083 showing_mode = NORMAL; |
36 | 4084 } |
4085 } | |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4086 |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4087 # if defined(FEAT_TERMINAL) || defined(PROTO) |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4088 void |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4089 term_cursor_color(char_u *color) |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4090 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4091 if (*T_CSC != NUL) |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4092 { |
18430
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
4093 out_str(T_CSC); // set cursor color start |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4094 out_str_nf(color); |
18430
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
4095 out_str(T_CEC); // set cursor color end |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4096 out_flush(); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4097 } |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4098 } |
12172
444793fce117
patch 8.0.0966: build failure without terminal feature
Christian Brabandt <cb@256bit.org>
parents:
12170
diff
changeset
|
4099 # endif |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4100 |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4101 int |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4102 blink_state_is_inverted() |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4103 { |
12261
875d7cc9b127
patch 8.0.1010: build failure without termresponse feature
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
4104 #ifdef FEAT_TERMRESPONSE |
16936
73e6ed2f69a2
patch 8.1.1469: no test for checking the cursor style response
Bram Moolenaar <Bram@vim.org>
parents:
16926
diff
changeset
|
4105 return rbm_status.tr_progress == STATUS_GOT |
73e6ed2f69a2
patch 8.1.1469: no test for checking the cursor style response
Bram Moolenaar <Bram@vim.org>
parents:
16926
diff
changeset
|
4106 && rcs_status.tr_progress == STATUS_GOT |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4107 && initial_cursor_blink != initial_cursor_shape_blink; |
12261
875d7cc9b127
patch 8.0.1010: build failure without termresponse feature
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
4108 #else |
875d7cc9b127
patch 8.0.1010: build failure without termresponse feature
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
4109 return FALSE; |
875d7cc9b127
patch 8.0.1010: build failure without termresponse feature
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
4110 #endif |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4111 } |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4112 |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4113 /* |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
4114 * "shape": 1 = block, 2 = underline, 3 = vertical bar |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4115 */ |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4116 void |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4117 term_cursor_shape(int shape, int blink) |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4118 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4119 if (*T_CSH != NUL) |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4120 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4121 OUT_STR(tgoto((char *)T_CSH, 0, shape * 2 - blink)); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4122 out_flush(); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4123 } |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4124 else |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
4125 { |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4126 int do_blink = blink; |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4127 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4128 // t_SH is empty: try setting just the blink state. |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4129 // The blink flags are XORed together, if the initial blinking from |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4130 // style and shape differs, we need to invert the flag here. |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4131 if (blink_state_is_inverted()) |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4132 do_blink = !blink; |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4133 |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4134 if (do_blink && *T_VS != NUL) |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4135 { |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4136 out_str(T_VS); |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4137 out_flush(); |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4138 } |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4139 else if (!do_blink && *T_CVS != NUL) |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4140 { |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4141 out_str(T_CVS); |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4142 out_flush(); |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4143 } |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
4144 } |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4145 } |
39 | 4146 #endif |
36 | 4147 |
4148 /* | |
7 | 4149 * Set scrolling region for window 'wp'. |
4150 * The region starts 'off' lines from the start of the window. | |
4151 * Also set the vertical scroll region for a vertically split window. Always | |
4152 * the full width of the window, excluding the vertical separator. | |
4153 */ | |
4154 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4155 scroll_region_set(win_T *wp, int off) |
7 | 4156 { |
4157 OUT_STR(tgoto((char *)T_CS, W_WINROW(wp) + wp->w_height - 1, | |
4158 W_WINROW(wp) + off)); | |
4159 if (*T_CSV != NUL && wp->w_width != Columns) | |
12513
3ca08bf99396
patch 8.0.1135: W_WINCOL() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12497
diff
changeset
|
4160 OUT_STR(tgoto((char *)T_CSV, wp->w_wincol + wp->w_width - 1, |
3ca08bf99396
patch 8.0.1135: W_WINCOL() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12497
diff
changeset
|
4161 wp->w_wincol)); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4162 screen_start(); // don't know where cursor is now |
7 | 4163 } |
4164 | |
4165 /* | |
4166 * Reset scrolling region to the whole screen. | |
4167 */ | |
4168 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4169 scroll_region_reset(void) |
7 | 4170 { |
4171 OUT_STR(tgoto((char *)T_CS, (int)Rows - 1, 0)); | |
4172 if (*T_CSV != NUL) | |
4173 OUT_STR(tgoto((char *)T_CSV, (int)Columns - 1, 0)); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4174 screen_start(); // don't know where cursor is now |
7 | 4175 } |
4176 | |
4177 | |
4178 /* | |
4179 * List of terminal codes that are currently recognized. | |
4180 */ | |
4181 | |
298 | 4182 static struct termcode |
7 | 4183 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4184 char_u name[2]; // termcap name of entry |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4185 char_u *code; // terminal code (in allocated memory) |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4186 int len; // STRLEN(code) |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4187 int modlen; // length of part before ";*~". |
7 | 4188 } *termcodes = NULL; |
4189 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4190 static int tc_max_len = 0; // number of entries that termcodes[] can hold |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4191 static int tc_len = 0; // current number of entries in termcodes[] |
7 | 4192 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
4193 static int termcode_star(char_u *code, int len); |
180 | 4194 |
7 | 4195 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4196 clear_termcodes(void) |
7 | 4197 { |
4198 while (tc_len > 0) | |
4199 vim_free(termcodes[--tc_len].code); | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
4200 VIM_CLEAR(termcodes); |
7 | 4201 tc_max_len = 0; |
4202 | |
4203 #ifdef HAVE_TGETENT | |
4204 BC = (char *)empty_option; | |
4205 UP = (char *)empty_option; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4206 PC = NUL; // set pad character to NUL |
7 | 4207 ospeed = 0; |
4208 #endif | |
4209 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4210 need_gather = TRUE; // need to fill termleader[] |
7 | 4211 } |
4212 | |
180 | 4213 #define ATC_FROM_TERM 55 |
4214 | |
7 | 4215 /* |
4216 * Add a new entry to the list of terminal codes. | |
4217 * The list is kept alphabetical for ":set termcap" | |
180 | 4218 * "flags" is TRUE when replacing 7-bit by 8-bit controls is desired. |
4219 * "flags" can also be ATC_FROM_TERM for got_code_from_term(). | |
7 | 4220 */ |
4221 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4222 add_termcode(char_u *name, char_u *string, int flags) |
7 | 4223 { |
4224 struct termcode *new_tc; | |
4225 int i, j; | |
4226 char_u *s; | |
179 | 4227 int len; |
7 | 4228 |
4229 if (string == NULL || *string == NUL) | |
4230 { | |
4231 del_termcode(name); | |
4232 return; | |
4233 } | |
4234 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15852
diff
changeset
|
4235 #if defined(MSWIN) && !defined(FEAT_GUI) |
20830
9064044fd4f6
patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents:
20778
diff
changeset
|
4236 s = vim_strnsave(string, STRLEN(string) + 1); |
6047 | 4237 #else |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4238 # ifdef VIMDLL |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4239 if (!gui.in_use) |
20830
9064044fd4f6
patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents:
20778
diff
changeset
|
4240 s = vim_strnsave(string, STRLEN(string) + 1); |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4241 else |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4242 # endif |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4243 s = vim_strsave(string); |
6047 | 4244 #endif |
7 | 4245 if (s == NULL) |
4246 return; | |
4247 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4248 // Change leading <Esc>[ to CSI, change <Esc>O to <M-O>. |
180 | 4249 if (flags != 0 && flags != ATC_FROM_TERM && term_7to8bit(string) != 0) |
7 | 4250 { |
1623 | 4251 STRMOVE(s, s + 1); |
7 | 4252 s[0] = term_7to8bit(string); |
4253 } | |
6047 | 4254 |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4255 #if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL)) |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4256 # ifdef VIMDLL |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4257 if (!gui.in_use) |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4258 # endif |
6047 | 4259 { |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4260 if (s[0] == K_NUL) |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4261 { |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4262 STRMOVE(s + 1, s); |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4263 s[1] = 3; |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4264 } |
6047 | 4265 } |
4266 #endif | |
4267 | |
179 | 4268 len = (int)STRLEN(s); |
7 | 4269 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4270 need_gather = TRUE; // need to fill termleader[] |
7 | 4271 |
4272 /* | |
4273 * need to make space for more entries | |
4274 */ | |
4275 if (tc_len == tc_max_len) | |
4276 { | |
4277 tc_max_len += 20; | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
4278 new_tc = ALLOC_MULT(struct termcode, tc_max_len); |
7 | 4279 if (new_tc == NULL) |
4280 { | |
4281 tc_max_len -= 20; | |
24737
e97a14604f65
patch 8.2.2907: memory leak when running out of memory
Bram Moolenaar <Bram@vim.org>
parents:
24428
diff
changeset
|
4282 vim_free(s); |
7 | 4283 return; |
4284 } | |
4285 for (i = 0; i < tc_len; ++i) | |
4286 new_tc[i] = termcodes[i]; | |
4287 vim_free(termcodes); | |
4288 termcodes = new_tc; | |
4289 } | |
4290 | |
4291 /* | |
4292 * Look for existing entry with the same name, it is replaced. | |
4293 * Look for an existing entry that is alphabetical higher, the new entry | |
4294 * is inserted in front of it. | |
4295 */ | |
4296 for (i = 0; i < tc_len; ++i) | |
4297 { | |
4298 if (termcodes[i].name[0] < name[0]) | |
4299 continue; | |
4300 if (termcodes[i].name[0] == name[0]) | |
4301 { | |
4302 if (termcodes[i].name[1] < name[1]) | |
4303 continue; | |
4304 /* | |
180 | 4305 * Exact match: May replace old code. |
7 | 4306 */ |
4307 if (termcodes[i].name[1] == name[1]) | |
4308 { | |
180 | 4309 if (flags == ATC_FROM_TERM && (j = termcode_star( |
4310 termcodes[i].code, termcodes[i].len)) > 0) | |
179 | 4311 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4312 // Don't replace ESC[123;*X or ESC O*X with another when |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4313 // invoked from got_code_from_term(). |
180 | 4314 if (len == termcodes[i].len - j |
179 | 4315 && STRNCMP(s, termcodes[i].code, len - 1) == 0 |
180 | 4316 && s[len - 1] |
4317 == termcodes[i].code[termcodes[i].len - 1]) | |
179 | 4318 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4319 // They are equal but for the ";*": don't add it. |
179 | 4320 vim_free(s); |
4321 return; | |
4322 } | |
4323 } | |
4324 else | |
4325 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4326 // Replace old code. |
179 | 4327 vim_free(termcodes[i].code); |
4328 --tc_len; | |
4329 break; | |
4330 } | |
7 | 4331 } |
4332 } | |
4333 /* | |
4334 * Found alphabetical larger entry, move rest to insert new entry | |
4335 */ | |
4336 for (j = tc_len; j > i; --j) | |
4337 termcodes[j] = termcodes[j - 1]; | |
4338 break; | |
4339 } | |
4340 | |
4341 termcodes[i].name[0] = name[0]; | |
4342 termcodes[i].name[1] = name[1]; | |
4343 termcodes[i].code = s; | |
179 | 4344 termcodes[i].len = len; |
180 | 4345 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4346 // For xterm we recognize special codes like "ESC[42;*X" and "ESC O*X" that |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4347 // accept modifiers. |
180 | 4348 termcodes[i].modlen = 0; |
4349 j = termcode_star(s, len); | |
4350 if (j > 0) | |
23406
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
4351 { |
180 | 4352 termcodes[i].modlen = len - 1 - j; |
23406
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
4353 // For "CSI[@;X" the "@" is not included in "modlen". |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
4354 if (termcodes[i].code[termcodes[i].modlen - 1] == '@') |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
4355 --termcodes[i].modlen; |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
4356 } |
7 | 4357 ++tc_len; |
4358 } | |
4359 | |
180 | 4360 /* |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
4361 * Check termcode "code[len]" for ending in ;*X or *X. |
180 | 4362 * The "X" can be any character. |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
4363 * Return 0 if not found, 2 for ;*X and 1 for *X. |
180 | 4364 */ |
4365 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4366 termcode_star(char_u *code, int len) |
180 | 4367 { |
23406
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
4368 // Shortest is <M-O>*X. With ; shortest is <CSI>@;*X |
180 | 4369 if (len >= 3 && code[len - 2] == '*') |
4370 { | |
4371 if (len >= 5 && code[len - 3] == ';') | |
4372 return 2; | |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
4373 else |
180 | 4374 return 1; |
4375 } | |
4376 return 0; | |
4377 } | |
4378 | |
7 | 4379 char_u * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4380 find_termcode(char_u *name) |
7 | 4381 { |
4382 int i; | |
4383 | |
4384 for (i = 0; i < tc_len; ++i) | |
4385 if (termcodes[i].name[0] == name[0] && termcodes[i].name[1] == name[1]) | |
4386 return termcodes[i].code; | |
4387 return NULL; | |
4388 } | |
4389 | |
4390 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4391 get_termcode(int i) |
7 | 4392 { |
4393 if (i >= tc_len) | |
4394 return NULL; | |
4395 return &termcodes[i].name[0]; | |
4396 } | |
4397 | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4398 /* |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4399 * Returns the length of the terminal code at index 'idx'. |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4400 */ |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4401 int |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4402 get_termcode_len(int idx) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4403 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4404 return termcodes[idx].len; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4405 } |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4406 |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4407 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4408 del_termcode(char_u *name) |
7 | 4409 { |
4410 int i; | |
4411 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4412 if (termcodes == NULL) // nothing there yet |
7 | 4413 return; |
4414 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4415 need_gather = TRUE; // need to fill termleader[] |
7 | 4416 |
4417 for (i = 0; i < tc_len; ++i) | |
4418 if (termcodes[i].name[0] == name[0] && termcodes[i].name[1] == name[1]) | |
4419 { | |
4420 del_termcode_idx(i); | |
4421 return; | |
4422 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4423 // not found. Give error message? |
7 | 4424 } |
4425 | |
4426 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4427 del_termcode_idx(int idx) |
7 | 4428 { |
4429 int i; | |
4430 | |
4431 vim_free(termcodes[idx].code); | |
4432 --tc_len; | |
4433 for (i = idx; i < tc_len; ++i) | |
4434 termcodes[i] = termcodes[i + 1]; | |
4435 } | |
4436 | |
4437 #ifdef FEAT_TERMRESPONSE | |
4438 /* | |
4439 * Called when detected that the terminal sends 8-bit codes. | |
4440 * Convert all 7-bit codes to their 8-bit equivalent. | |
4441 */ | |
4442 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4443 switch_to_8bit(void) |
7 | 4444 { |
4445 int i; | |
4446 int c; | |
4447 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4448 // Only need to do something when not already using 8-bit codes. |
7 | 4449 if (!term_is_8bit(T_NAME)) |
4450 { | |
4451 for (i = 0; i < tc_len; ++i) | |
4452 { | |
4453 c = term_7to8bit(termcodes[i].code); | |
4454 if (c != 0) | |
4455 { | |
1623 | 4456 STRMOVE(termcodes[i].code + 1, termcodes[i].code + 2); |
7 | 4457 termcodes[i].code[0] = c; |
4458 } | |
4459 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4460 need_gather = TRUE; // need to fill termleader[] |
7 | 4461 } |
4462 detected_8bit = TRUE; | |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
4463 LOG_TR(("Switching to 8 bit")); |
7 | 4464 } |
4465 #endif | |
4466 | |
4467 #ifdef CHECK_DOUBLE_CLICK | |
4468 static linenr_T orig_topline = 0; | |
4469 # ifdef FEAT_DIFF | |
4470 static int orig_topfill = 0; | |
4471 # endif | |
4472 #endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12429
diff
changeset
|
4473 #if defined(CHECK_DOUBLE_CLICK) || defined(PROTO) |
7 | 4474 /* |
26771
fc859aea8cec
patch 8.2.3914: various spelling mistakes in comments
Bram Moolenaar <Bram@vim.org>
parents:
26670
diff
changeset
|
4475 * Checking for double-clicks ourselves. |
7 | 4476 * "orig_topline" is used to avoid detecting a double-click when the window |
4477 * contents scrolled (e.g., when 'scrolloff' is non-zero). | |
4478 */ | |
4479 /* | |
4480 * Set orig_topline. Used when jumping to another window, so that a double | |
4481 * click still works. | |
4482 */ | |
4483 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4484 set_mouse_topline(win_T *wp) |
7 | 4485 { |
4486 orig_topline = wp->w_topline; | |
4487 # ifdef FEAT_DIFF | |
4488 orig_topfill = wp->w_topfill; | |
4489 # endif | |
4490 } | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4491 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4492 /* |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4493 * Returns TRUE if the top line and top fill of window 'wp' matches the saved |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4494 * topline and topfill. |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4495 */ |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4496 int |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4497 is_mouse_topline(win_T *wp) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4498 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4499 return orig_topline == wp->w_topline |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4500 #ifdef FEAT_DIFF |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4501 && orig_topfill == wp->w_topfill |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4502 #endif |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4503 ; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4504 } |
7 | 4505 #endif |
4506 | |
4507 /* | |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4508 * Put "string[new_slen]" in typebuf, or in "buf[bufsize]" if "buf" is not NULL. |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4509 * Remove "slen" bytes. |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4510 * Returns FAIL for error. |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4511 */ |
20727
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20705
diff
changeset
|
4512 int |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4513 put_string_in_typebuf( |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4514 int offset, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4515 int slen, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4516 char_u *string, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4517 int new_slen, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4518 char_u *buf, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4519 int bufsize, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4520 int *buflen) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4521 { |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4522 int extra = new_slen - slen; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4523 |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4524 string[new_slen] = NUL; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4525 if (buf == NULL) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4526 { |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4527 if (extra < 0) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4528 // remove matched chars, taking care of noremap |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4529 del_typebuf(-extra, offset); |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4530 else if (extra > 0) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4531 // insert the extra space we need |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4532 ins_typebuf(string + slen, REMAP_YES, offset, FALSE, FALSE); |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4533 |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4534 // Careful: del_typebuf() and ins_typebuf() may have reallocated |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4535 // typebuf.tb_buf[]! |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4536 mch_memmove(typebuf.tb_buf + typebuf.tb_off + offset, string, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4537 (size_t)new_slen); |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4538 } |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4539 else |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4540 { |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4541 if (extra < 0) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4542 // remove matched characters |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4543 mch_memmove(buf + offset, buf + offset - extra, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4544 (size_t)(*buflen + offset + extra)); |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4545 else if (extra > 0) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4546 { |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4547 // Insert the extra space we need. If there is insufficient |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4548 // space return -1. |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4549 if (*buflen + extra + new_slen >= bufsize) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4550 return FAIL; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4551 mch_memmove(buf + offset + extra, buf + offset, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4552 (size_t)(*buflen - offset)); |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4553 } |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4554 mch_memmove(buf + offset, string, (size_t)new_slen); |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4555 *buflen = *buflen + extra + new_slen; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4556 } |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4557 return OK; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4558 } |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4559 |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4560 /* |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4561 * Decode a modifier number as xterm provides it into MOD_MASK bits. |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4562 */ |
18717
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4563 int |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4564 decode_modifiers(int n) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4565 { |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4566 int code = n - 1; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4567 int modifiers = 0; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4568 |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4569 if (code & 1) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4570 modifiers |= MOD_MASK_SHIFT; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4571 if (code & 2) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4572 modifiers |= MOD_MASK_ALT; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4573 if (code & 4) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4574 modifiers |= MOD_MASK_CTRL; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4575 if (code & 8) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4576 modifiers |= MOD_MASK_META; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4577 return modifiers; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4578 } |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4579 |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4580 static int |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4581 modifiers2keycode(int modifiers, int *key, char_u *string) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4582 { |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4583 int new_slen = 0; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4584 |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4585 if (modifiers != 0) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4586 { |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4587 // Some keys have the modifier included. Need to handle that here to |
22764
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4588 // make mappings work. This may result in a special key, such as |
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4589 // K_S_TAB. |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4590 *key = simplify_key(*key, &modifiers); |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4591 if (modifiers != 0) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4592 { |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4593 string[new_slen++] = K_SPECIAL; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4594 string[new_slen++] = (int)KS_MODIFIER; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4595 string[new_slen++] = modifiers; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4596 } |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4597 } |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4598 return new_slen; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4599 } |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4600 |
20776
7728e309e013
patch 8.2.0940: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
20774
diff
changeset
|
4601 #ifdef FEAT_TERMRESPONSE |
7728e309e013
patch 8.2.0940: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
20774
diff
changeset
|
4602 /* |
7728e309e013
patch 8.2.0940: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
20774
diff
changeset
|
4603 * Handle a cursor position report. |
7728e309e013
patch 8.2.0940: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
20774
diff
changeset
|
4604 */ |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4605 static void |
20776
7728e309e013
patch 8.2.0940: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
20774
diff
changeset
|
4606 handle_u7_response(int *arg, char_u *tp UNUSED, int csi_len UNUSED) |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4607 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4608 if (arg[0] == 2 && arg[1] >= 2) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4609 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4610 char *aw = NULL; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4611 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4612 LOG_TR(("Received U7 status: %s", tp)); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4613 u7_status.tr_progress = STATUS_GOT; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4614 did_cursorhold = TRUE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4615 if (arg[1] == 2) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4616 aw = "single"; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4617 else if (arg[1] == 3) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4618 aw = "double"; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4619 if (aw != NULL && STRCMP(aw, p_ambw) != 0) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4620 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4621 // Setting the option causes a screen redraw. Do |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4622 // that right away if possible, keeping any |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4623 // messages. |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28453
diff
changeset
|
4624 set_option_value_give_err((char_u *)"ambw", 0L, (char_u *)aw, 0); |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4625 # ifdef DEBUG_TERMRESPONSE |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4626 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4627 int r = redraw_asap(CLEAR); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4628 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4629 log_tr("set 'ambiwidth', redraw_asap(): %d", r); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4630 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4631 # else |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4632 redraw_asap(CLEAR); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4633 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4634 # ifdef FEAT_EVAL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4635 set_vim_var_string(VV_TERMU7RESP, tp, csi_len); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4636 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4637 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4638 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4639 else if (arg[0] == 3) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4640 { |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4641 int value; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4642 |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4643 LOG_TR(("Received compatibility test result: %s", tp)); |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4644 xcc_status.tr_progress = STATUS_GOT; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4645 |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4646 // Third row: xterm compatibility test. |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4647 // If the cursor is on the first column then the terminal can handle |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4648 // the request for cursor style and blinking. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4649 value = arg[1] == 1 ? TPR_YES : TPR_NO; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4650 term_props[TPR_CURSOR_STYLE].tpr_status = value; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4651 term_props[TPR_CURSOR_BLINK].tpr_status = value; |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4652 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4653 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4654 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4655 /* |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4656 * Handle a response to T_CRV: {lead}{first}{x};{vers};{y}c |
23229
b545334ae654
patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents:
22956
diff
changeset
|
4657 * Xterm and alike use '>' for {first}. |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4658 * Rxvt sends "{lead}?1;2c". |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4659 */ |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4660 static void |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4661 handle_version_response(int first, int *arg, int argc, char_u *tp) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4662 { |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4663 // The xterm version. It is set to zero when it can't be an actual xterm |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4664 // version. |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4665 int version = arg[1]; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4666 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4667 LOG_TR(("Received CRV response: %s", tp)); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4668 crv_status.tr_progress = STATUS_GOT; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4669 did_cursorhold = TRUE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4670 |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4671 // Reset terminal properties that are set based on the termresponse. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4672 // Mainly useful for tests that send the termresponse multiple times. |
20836
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
4673 // For testing all props can be reset. |
20838
020aec2e8de9
patch 8.2.0971: build with tiny features fails
Bram Moolenaar <Bram@vim.org>
parents:
20836
diff
changeset
|
4674 init_term_props( |
020aec2e8de9
patch 8.2.0971: build with tiny features fails
Bram Moolenaar <Bram@vim.org>
parents:
20836
diff
changeset
|
4675 #ifdef FEAT_EVAL |
020aec2e8de9
patch 8.2.0971: build with tiny features fails
Bram Moolenaar <Bram@vim.org>
parents:
20836
diff
changeset
|
4676 reset_term_props_on_termresponse |
020aec2e8de9
patch 8.2.0971: build with tiny features fails
Bram Moolenaar <Bram@vim.org>
parents:
20836
diff
changeset
|
4677 #else |
020aec2e8de9
patch 8.2.0971: build with tiny features fails
Bram Moolenaar <Bram@vim.org>
parents:
20836
diff
changeset
|
4678 FALSE |
020aec2e8de9
patch 8.2.0971: build with tiny features fails
Bram Moolenaar <Bram@vim.org>
parents:
20836
diff
changeset
|
4679 #endif |
020aec2e8de9
patch 8.2.0971: build with tiny features fails
Bram Moolenaar <Bram@vim.org>
parents:
20836
diff
changeset
|
4680 ); |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4681 |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4682 // If this code starts with CSI, you can bet that the |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4683 // terminal uses 8-bit codes. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4684 if (tp[0] == CSI) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4685 switch_to_8bit(); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4686 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4687 // Screen sends 40500. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4688 // rxvt sends its version number: "20703" is 2.7.3. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4689 // Ignore it for when the user has set 'term' to xterm, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4690 // even though it's an rxvt. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4691 if (version > 20000) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4692 version = 0; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4693 |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4694 // Figure out more if the reeponse is CSI > 99 ; 99 ; 99 c |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4695 if (first == '>' && argc == 3) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4696 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4697 int need_flush = FALSE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4698 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4699 // mintty 2.9.5 sends 77;20905;0c. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4700 // (77 is ASCII 'M' for mintty.) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4701 if (arg[0] == 77) |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4702 { |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4703 // mintty can do SGR mouse reporting |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4704 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4705 } |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4706 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4707 // If xterm version >= 141 try to get termcap codes. For other |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4708 // terminals the request should be ignored. |
26670
a77b661439f9
patch 8.2.3864: cannot disable requesting key codes from xterm
Bram Moolenaar <Bram@vim.org>
parents:
26439
diff
changeset
|
4709 if (version >= 141 && p_xtermcodes) |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4710 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4711 LOG_TR(("Enable checking for XT codes")); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4712 check_for_codes = TRUE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4713 need_gather = TRUE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4714 req_codes_from_term(); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4715 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4716 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4717 // libvterm sends 0;100;0 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4718 if (version == 100 && arg[0] == 0 && arg[2] == 0) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4719 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4720 // If run from Vim $COLORS is set to the number of |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4721 // colors the terminal supports. Otherwise assume |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4722 // 256, libvterm supports even more. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4723 if (mch_getenv((char_u *)"COLORS") == NULL) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4724 may_adjust_color_count(256); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4725 // Libvterm can handle SGR mouse reporting. |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4726 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4727 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4728 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4729 if (version == 95) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4730 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4731 // Mac Terminal.app sends 1;95;0 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4732 if (arg[0] == 1 && arg[2] == 0) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4733 { |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4734 term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4735 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4736 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4737 // iTerm2 sends 0;95;0 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4738 else if (arg[0] == 0 && arg[2] == 0) |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4739 { |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4740 // iTerm2 can do SGR mouse reporting |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4741 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4742 } |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4743 // old iTerm2 sends 0;95; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4744 else if (arg[0] == 0 && arg[2] == -1) |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4745 term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES; |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4746 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4747 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4748 // screen sends 83;40500;0 83 is 'S' in ASCII. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4749 if (arg[0] == 83) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4750 { |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4751 // screen supports SGR mouse codes since 4.7.0 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4752 if (arg[1] >= 40700) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4753 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4754 else |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4755 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_XTERM; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4756 } |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4757 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4758 // If no recognized terminal has set mouse behavior, assume xterm. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4759 if (term_props[TPR_MOUSE].tpr_status == TPR_UNKNOWN) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4760 { |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4761 // Xterm version 277 supports SGR. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4762 // Xterm version >= 95 supports mouse dragging. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4763 if (version >= 277) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4764 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4765 else if (version >= 95) |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4766 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_XTERM2; |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4767 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4768 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4769 // Detect terminals that set $TERM to something like |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4770 // "xterm-256color" but are not fully xterm compatible. |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4771 // |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4772 // Gnome terminal sends 1;3801;0, 1;4402;0 or 1;2501;0. |
20850
bf7453768034
patch 8.2.0977: t_8u is made empty for the wrong terminals
Bram Moolenaar <Bram@vim.org>
parents:
20838
diff
changeset
|
4773 // Newer Gnome-terminal sends 65;6001;1. |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4774 // xfce4-terminal sends 1;2802;0. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4775 // screen sends 83;40500;0 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4776 // Assuming any version number over 2500 is not an |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4777 // xterm (without the limit for rxvt and screen). |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4778 if (arg[1] >= 2500) |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4779 term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4780 |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4781 else if (version == 136 && arg[2] == 0) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4782 { |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4783 term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4784 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4785 // PuTTY sends 0;136;0 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4786 if (arg[0] == 0) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4787 { |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4788 // supports sgr-like mouse reporting. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4789 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4790 } |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4791 // vandyke SecureCRT sends 1;136;0 |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4792 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4793 |
28501
e1c6e1f3c1bb
patch 8.2.4775: SpellBad highlighting does not work in Konsole
Bram Moolenaar <Bram@vim.org>
parents:
28497
diff
changeset
|
4794 // Konsole sends 0;115;0 - but t_u8 does not actually work, therefore |
e1c6e1f3c1bb
patch 8.2.4775: SpellBad highlighting does not work in Konsole
Bram Moolenaar <Bram@vim.org>
parents:
28497
diff
changeset
|
4795 // commented out. |
e1c6e1f3c1bb
patch 8.2.4775: SpellBad highlighting does not work in Konsole
Bram Moolenaar <Bram@vim.org>
parents:
28497
diff
changeset
|
4796 // else if (version == 115 && arg[0] == 0 && arg[2] == 0) |
e1c6e1f3c1bb
patch 8.2.4775: SpellBad highlighting does not work in Konsole
Bram Moolenaar <Bram@vim.org>
parents:
28497
diff
changeset
|
4797 // term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES; |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4798 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4799 // GNU screen sends 83;30600;0, 83;40500;0, etc. |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4800 // 30600/40500 is a version number of GNU screen. DA2 support is added |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4801 // on 3.6. DCS string has a special meaning to GNU screen, but xterm |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4802 // compatibility checking does not detect GNU screen. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4803 if (arg[0] == 83 && arg[1] >= 30600) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4804 { |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4805 term_props[TPR_CURSOR_STYLE].tpr_status = TPR_NO; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4806 term_props[TPR_CURSOR_BLINK].tpr_status = TPR_NO; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4807 } |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4808 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4809 // Xterm first responded to this request at patch level |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4810 // 95, so assume anything below 95 is not xterm and hopefully supports |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4811 // the underline RGB color sequence. |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4812 if (version < 95) |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4813 term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4814 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4815 // Getting the cursor style is only supported properly by xterm since |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4816 // version 279 (otherwise it returns 0x18). |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4817 if (version < 279) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4818 term_props[TPR_CURSOR_STYLE].tpr_status = TPR_NO; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4819 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4820 /* |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4821 * Take action on the detected properties. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4822 */ |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4823 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4824 // Unless the underline RGB color is expected to work, disable "t_8u". |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4825 // It does not work for the real Xterm, it resets the background color. |
28501
e1c6e1f3c1bb
patch 8.2.4775: SpellBad highlighting does not work in Konsole
Bram Moolenaar <Bram@vim.org>
parents:
28497
diff
changeset
|
4826 // This may cause some flicker. Alternative would be to set "t_8u" |
e1c6e1f3c1bb
patch 8.2.4775: SpellBad highlighting does not work in Konsole
Bram Moolenaar <Bram@vim.org>
parents:
28497
diff
changeset
|
4827 // here if the terminal is expected to support it, but that might |
e1c6e1f3c1bb
patch 8.2.4775: SpellBad highlighting does not work in Konsole
Bram Moolenaar <Bram@vim.org>
parents:
28497
diff
changeset
|
4828 // conflict with what was set in the .vimrc. |
20850
bf7453768034
patch 8.2.0977: t_8u is made empty for the wrong terminals
Bram Moolenaar <Bram@vim.org>
parents:
20838
diff
changeset
|
4829 if (term_props[TPR_UNDERLINE_RGB].tpr_status != TPR_YES && *T_8U != NUL) |
28501
e1c6e1f3c1bb
patch 8.2.4775: SpellBad highlighting does not work in Konsole
Bram Moolenaar <Bram@vim.org>
parents:
28497
diff
changeset
|
4830 { |
20854
bd56f4045f37
patch 8.2.0979: a couple of screendump tests fail
Bram Moolenaar <Bram@vim.org>
parents:
20852
diff
changeset
|
4831 set_string_option_direct((char_u *)"t_8u", -1, (char_u *)"", |
bd56f4045f37
patch 8.2.0979: a couple of screendump tests fail
Bram Moolenaar <Bram@vim.org>
parents:
20852
diff
changeset
|
4832 OPT_FREE, 0); |
28501
e1c6e1f3c1bb
patch 8.2.4775: SpellBad highlighting does not work in Konsole
Bram Moolenaar <Bram@vim.org>
parents:
28497
diff
changeset
|
4833 } |
28505
8751e815864e
patch 8.2.4777: screendump tests fail because of a redraw
Bram Moolenaar <Bram@vim.org>
parents:
28501
diff
changeset
|
4834 if (*T_8U != NUL && write_t_8u_state == MAYBE) |
8751e815864e
patch 8.2.4777: screendump tests fail because of a redraw
Bram Moolenaar <Bram@vim.org>
parents:
28501
diff
changeset
|
4835 // Did skip writing t_8u, a complete redraw is needed. |
8751e815864e
patch 8.2.4777: screendump tests fail because of a redraw
Bram Moolenaar <Bram@vim.org>
parents:
28501
diff
changeset
|
4836 redraw_later_clear(); |
8751e815864e
patch 8.2.4777: screendump tests fail because of a redraw
Bram Moolenaar <Bram@vim.org>
parents:
28501
diff
changeset
|
4837 write_t_8u_state = OK; // can otuput t_8u now |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4838 |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4839 // Only set 'ttymouse' automatically if it was not set |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4840 // by the user already. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4841 if (!option_was_set((char_u *)"ttym") |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4842 && (term_props[TPR_MOUSE].tpr_status == TPR_MOUSE_XTERM2 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4843 || term_props[TPR_MOUSE].tpr_status == TPR_MOUSE_SGR)) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4844 { |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28453
diff
changeset
|
4845 set_option_value_give_err((char_u *)"ttym", 0L, |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4846 term_props[TPR_MOUSE].tpr_status == TPR_MOUSE_SGR |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4847 ? (char_u *)"sgr" : (char_u *)"xterm2", 0); |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4848 } |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4849 |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4850 // Only request the cursor style if t_SH and t_RS are |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4851 // set. Only supported properly by xterm since version |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4852 // 279 (otherwise it returns 0x18). |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4853 // Only when getting the cursor style was detected to work. |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4854 // Not for Terminal.app, it can't handle t_RS, it |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4855 // echoes the characters to the screen. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4856 if (rcs_status.tr_progress == STATUS_GET |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4857 && term_props[TPR_CURSOR_STYLE].tpr_status == TPR_YES |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4858 && *T_CSH != NUL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4859 && *T_CRS != NUL) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4860 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
4861 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
4862 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
4863 #endif |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4864 LOG_TR(("Sending cursor style request")); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4865 out_str(T_CRS); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4866 termrequest_sent(&rcs_status); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4867 need_flush = TRUE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4868 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4869 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4870 // Only request the cursor blink mode if t_RC set. Not |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4871 // for Gnome terminal, it can't handle t_RC, it |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4872 // echoes the characters to the screen. |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4873 // Only when getting the cursor style was detected to work. |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4874 if (rbm_status.tr_progress == STATUS_GET |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4875 && term_props[TPR_CURSOR_BLINK].tpr_status == TPR_YES |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4876 && *T_CRC != NUL) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4877 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
4878 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
4879 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
4880 #endif |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4881 LOG_TR(("Sending cursor blink mode request")); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4882 out_str(T_CRC); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4883 termrequest_sent(&rbm_status); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4884 need_flush = TRUE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4885 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4886 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4887 if (need_flush) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4888 out_flush(); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4889 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4890 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4891 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4892 /* |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4893 * Handle a sequence with key and modifier, one of: |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4894 * {lead}27;{modifier};{key}~ |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4895 * {lead}{key};{modifier}u |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4896 * Returns the difference in length. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4897 */ |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4898 static int |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4899 handle_key_with_modifier( |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4900 int *arg, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4901 int trail, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4902 int csi_len, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4903 int offset, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4904 char_u *buf, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4905 int bufsize, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4906 int *buflen) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4907 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4908 int key; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4909 int modifiers; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4910 int new_slen; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4911 char_u string[MAX_KEY_CODE_LEN + 1]; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4912 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4913 seenModifyOtherKeys = TRUE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4914 if (trail == 'u') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4915 key = arg[0]; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4916 else |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4917 key = arg[2]; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4918 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4919 modifiers = decode_modifiers(arg[1]); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4920 |
22522
6c7e4db139a3
patch 8.2.1809: mapping some keys with Ctrl does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
22091
diff
changeset
|
4921 // Some keys need adjustment when the Ctrl modifier is used. |
6c7e4db139a3
patch 8.2.1809: mapping some keys with Ctrl does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
22091
diff
changeset
|
4922 key = may_adjust_key_for_ctrl(modifiers, key); |
6c7e4db139a3
patch 8.2.1809: mapping some keys with Ctrl does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
22091
diff
changeset
|
4923 |
20935
d64520bfafa0
patch 8.2.1019: mapping <M-S-a> does not work in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20927
diff
changeset
|
4924 // May remove the shift modifier if it's already included in the key. |
d64520bfafa0
patch 8.2.1019: mapping <M-S-a> does not work in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20927
diff
changeset
|
4925 modifiers = may_remove_shift_modifier(modifiers, key); |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4926 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4927 // insert modifiers with KS_MODIFIER |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4928 new_slen = modifiers2keycode(modifiers, &key, string); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4929 |
22764
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4930 if (IS_SPECIAL(key)) |
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4931 { |
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4932 string[new_slen++] = K_SPECIAL; |
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4933 string[new_slen++] = KEY2TERMCAP0(key); |
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4934 string[new_slen++] = KEY2TERMCAP1(key); |
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4935 } |
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4936 else if (has_mbyte) |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4937 new_slen += (*mb_char2bytes)(key, string + new_slen); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4938 else |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4939 string[new_slen++] = key; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4940 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4941 if (put_string_in_typebuf(offset, csi_len, string, new_slen, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4942 buf, bufsize, buflen) == FAIL) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4943 return -1; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4944 return new_slen - csi_len + offset; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4945 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4946 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4947 /* |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4948 * Handle a CSI escape sequence. |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4949 * - Xterm version string. |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4950 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4951 * - Cursor position report: {lead}{row};{col}R |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4952 * The final byte must be 'R'. It is used for checking the |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4953 * ambiguous-width character state. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4954 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4955 * - window position reply: {lead}3;{x};{y}t |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4956 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4957 * - key with modifiers when modifyOtherKeys is enabled: |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4958 * {lead}27;{modifier};{key}~ |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4959 * {lead}{key};{modifier}u |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4960 * Return 0 for no match, -1 for partial match, > 0 for full match. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4961 */ |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4962 static int |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4963 handle_csi( |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4964 char_u *tp, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4965 int len, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4966 char_u *argp, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4967 int offset, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4968 char_u *buf, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4969 int bufsize, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4970 int *buflen, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4971 char_u *key_name, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4972 int *slen) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4973 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4974 int first = -1; // optional char right after {lead} |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4975 int trail; // char that ends CSI sequence |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4976 int arg[3] = {-1, -1, -1}; // argument numbers |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4977 int argc; // number of arguments |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4978 char_u *ap = argp; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4979 int csi_len; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4980 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4981 // Check for non-digit after CSI. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4982 if (!VIM_ISDIGIT(*ap)) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4983 first = *ap++; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4984 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4985 // Find up to three argument numbers. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4986 for (argc = 0; argc < 3; ) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4987 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4988 if (ap >= tp + len) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4989 return -1; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4990 if (*ap == ';') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4991 arg[argc++] = -1; // omitted number |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4992 else if (VIM_ISDIGIT(*ap)) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4993 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4994 arg[argc] = 0; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4995 for (;;) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4996 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4997 if (ap >= tp + len) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4998 return -1; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4999 if (!VIM_ISDIGIT(*ap)) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5000 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5001 arg[argc] = arg[argc] * 10 + (*ap - '0'); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5002 ++ap; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5003 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5004 ++argc; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5005 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5006 if (*ap == ';') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5007 ++ap; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5008 else |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5009 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5010 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5011 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5012 // mrxvt has been reported to have "+" in the version. Assume |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5013 // the escape sequence ends with a letter or one of "{|}~". |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5014 while (ap < tp + len |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5015 && !(*ap >= '{' && *ap <= '~') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5016 && !ASCII_ISALPHA(*ap)) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5017 ++ap; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5018 if (ap >= tp + len) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5019 return -1; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5020 trail = *ap; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5021 csi_len = (int)(ap - tp) + 1; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5022 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5023 // Cursor position report: Eat it when there are 2 arguments |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5024 // and it ends in 'R'. Also when u7_status is not "sent", it |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5025 // may be from a previous Vim that just exited. But not for |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5026 // <S-F3>, it sends something similar, check for row and column |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5027 // to make sense. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5028 if (first == -1 && argc == 2 && trail == 'R') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5029 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5030 handle_u7_response(arg, tp, csi_len); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5031 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5032 key_name[0] = (int)KS_EXTRA; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5033 key_name[1] = (int)KE_IGNORE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5034 *slen = csi_len; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5035 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5036 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5037 // Version string: Eat it when there is at least one digit and |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5038 // it ends in 'c' |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5039 else if (*T_CRV != NUL && ap > argp + 1 && trail == 'c') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5040 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5041 handle_version_response(first, arg, argc, tp); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5042 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5043 *slen = csi_len; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5044 # ifdef FEAT_EVAL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5045 set_vim_var_string(VV_TERMRESPONSE, tp, *slen); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5046 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5047 apply_autocmds(EVENT_TERMRESPONSE, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5048 NULL, NULL, FALSE, curbuf); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5049 key_name[0] = (int)KS_EXTRA; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5050 key_name[1] = (int)KE_IGNORE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5051 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5052 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5053 // Check blinking cursor from xterm: |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5054 // {lead}?12;1$y set |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5055 // {lead}?12;2$y not set |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5056 // |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5057 // {lead} can be <Esc>[ or CSI |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5058 else if (rbm_status.tr_progress == STATUS_SENT |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5059 && first == '?' |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5060 && ap == argp + 6 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5061 && arg[0] == 12 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5062 && ap[-1] == '$' |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5063 && trail == 'y') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5064 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5065 initial_cursor_blink = (arg[1] == '1'); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5066 rbm_status.tr_progress = STATUS_GOT; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5067 LOG_TR(("Received cursor blinking mode response: %s", tp)); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5068 key_name[0] = (int)KS_EXTRA; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5069 key_name[1] = (int)KE_IGNORE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5070 *slen = csi_len; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5071 # ifdef FEAT_EVAL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5072 set_vim_var_string(VV_TERMBLINKRESP, tp, *slen); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5073 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5074 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5075 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5076 // Check for a window position response from the terminal: |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5077 // {lead}3;{x};{y}t |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5078 else if (did_request_winpos && argc == 3 && arg[0] == 3 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5079 && trail == 't') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5080 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5081 winpos_x = arg[1]; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5082 winpos_y = arg[2]; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5083 // got finished code: consume it |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5084 key_name[0] = (int)KS_EXTRA; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5085 key_name[1] = (int)KE_IGNORE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5086 *slen = csi_len; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5087 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5088 if (--did_request_winpos <= 0) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5089 winpos_status.tr_progress = STATUS_GOT; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5090 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5091 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5092 // Key with modifier: |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5093 // {lead}27;{modifier};{key}~ |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5094 // {lead}{key};{modifier}u |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5095 else if ((arg[0] == 27 && argc == 3 && trail == '~') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5096 || (argc == 2 && trail == 'u')) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5097 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5098 return len + handle_key_with_modifier(arg, trail, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5099 csi_len, offset, buf, bufsize, buflen); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5100 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5101 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5102 // else: Unknown CSI sequence. We could drop it, but then the |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5103 // user can't create a map for it. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5104 return 0; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5105 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5106 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5107 /* |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5108 * Handle an OSC sequence, fore/background color response from the terminal: |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5109 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5110 * {lead}{code};rgb:{rrrr}/{gggg}/{bbbb}{tail} |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5111 * or {lead}{code};rgb:{rr}/{gg}/{bb}{tail} |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5112 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5113 * {code} is 10 for foreground, 11 for background |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5114 * {lead} can be <Esc>] or OSC |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5115 * {tail} can be '\007', <Esc>\ or STERM. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5116 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5117 * Consume any code that starts with "{lead}11;", it's also |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5118 * possible that "rgba" is following. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5119 */ |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5120 static int |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5121 handle_osc(char_u *tp, char_u *argp, int len, char_u *key_name, int *slen) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5122 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5123 int i, j; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5124 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5125 j = 1 + (tp[0] == ESC); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5126 if (len >= j + 3 && (argp[0] != '1' |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5127 || (argp[1] != '1' && argp[1] != '0') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5128 || argp[2] != ';')) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5129 i = 0; // no match |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5130 else |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5131 for (i = j; i < len; ++i) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5132 if (tp[i] == '\007' || (tp[0] == OSC ? tp[i] == STERM |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5133 : (tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\'))) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5134 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5135 int is_bg = argp[1] == '1'; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5136 int is_4digit = i - j >= 21 && tp[j + 11] == '/' |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5137 && tp[j + 16] == '/'; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5138 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5139 if (i - j >= 15 && STRNCMP(tp + j + 3, "rgb:", 4) == 0 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5140 && (is_4digit |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5141 || (tp[j + 9] == '/' && tp[i + 12 == '/']))) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5142 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5143 char_u *tp_r = tp + j + 7; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5144 char_u *tp_g = tp + j + (is_4digit ? 12 : 10); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5145 char_u *tp_b = tp + j + (is_4digit ? 17 : 13); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5146 # ifdef FEAT_TERMINAL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5147 int rval, gval, bval; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5148 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5149 rval = hexhex2nr(tp_r); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5150 gval = hexhex2nr(tp_b); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5151 bval = hexhex2nr(tp_g); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5152 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5153 if (is_bg) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5154 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5155 char *new_bg_val = (3 * '6' < *tp_r + *tp_g + |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5156 *tp_b) ? "light" : "dark"; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5157 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5158 LOG_TR(("Received RBG response: %s", tp)); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5159 rbg_status.tr_progress = STATUS_GOT; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5160 # ifdef FEAT_TERMINAL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5161 bg_r = rval; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5162 bg_g = gval; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5163 bg_b = bval; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5164 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5165 if (!option_was_set((char_u *)"bg") |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5166 && STRCMP(p_bg, new_bg_val) != 0) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5167 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5168 // value differs, apply it |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28453
diff
changeset
|
5169 set_option_value_give_err((char_u *)"bg", |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28453
diff
changeset
|
5170 0L, (char_u *)new_bg_val, 0); |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5171 reset_option_was_set((char_u *)"bg"); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5172 redraw_asap(CLEAR); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5173 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5174 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5175 # ifdef FEAT_TERMINAL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5176 else |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5177 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5178 LOG_TR(("Received RFG response: %s", tp)); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5179 rfg_status.tr_progress = STATUS_GOT; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5180 fg_r = rval; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5181 fg_g = gval; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5182 fg_b = bval; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5183 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5184 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5185 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5186 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5187 // got finished code: consume it |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5188 key_name[0] = (int)KS_EXTRA; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5189 key_name[1] = (int)KE_IGNORE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5190 *slen = i + 1 + (tp[i] == ESC); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5191 # ifdef FEAT_EVAL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5192 set_vim_var_string(is_bg ? VV_TERMRBGRESP |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5193 : VV_TERMRFGRESP, tp, *slen); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5194 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5195 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5196 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5197 if (i == len) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5198 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5199 LOG_TR(("not enough characters for RB")); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5200 return FAIL; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5201 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5202 return OK; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5203 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5204 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5205 /* |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5206 * Check for key code response from xterm: |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5207 * {lead}{flag}+r<hex bytes><{tail} |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5208 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5209 * {lead} can be <Esc>P or DCS |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5210 * {flag} can be '0' or '1' |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5211 * {tail} can be Esc>\ or STERM |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5212 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5213 * Check for cursor shape response from xterm: |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5214 * {lead}1$r<digit> q{tail} |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5215 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5216 * {lead} can be <Esc>P or DCS |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5217 * {tail} can be <Esc>\ or STERM |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5218 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5219 * Consume any code that starts with "{lead}.+r" or "{lead}.$r". |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5220 */ |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5221 static int |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5222 handle_dcs(char_u *tp, char_u *argp, int len, char_u *key_name, int *slen) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5223 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5224 int i, j; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5225 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5226 j = 1 + (tp[0] == ESC); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5227 if (len < j + 3) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5228 i = len; // need more chars |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5229 else if ((argp[1] != '+' && argp[1] != '$') || argp[2] != 'r') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5230 i = 0; // no match |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5231 else if (argp[1] == '+') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5232 // key code response |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5233 for (i = j; i < len; ++i) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5234 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5235 if ((tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5236 || tp[i] == STERM) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5237 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5238 if (i - j >= 3) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5239 got_code_from_term(tp + j, i); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5240 key_name[0] = (int)KS_EXTRA; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5241 key_name[1] = (int)KE_IGNORE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5242 *slen = i + 1 + (tp[i] == ESC); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5243 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5244 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5245 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5246 else |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5247 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5248 // Probably the cursor shape response. Make sure that "i" |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5249 // is equal to "len" when there are not sufficient |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5250 // characters. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5251 for (i = j + 3; i < len; ++i) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5252 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5253 if (i - j == 3 && !isdigit(tp[i])) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5254 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5255 if (i - j == 4 && tp[i] != ' ') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5256 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5257 if (i - j == 5 && tp[i] != 'q') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5258 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5259 if (i - j == 6 && tp[i] != ESC && tp[i] != STERM) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5260 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5261 if ((i - j == 6 && tp[i] == STERM) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5262 || (i - j == 7 && tp[i] == '\\')) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5263 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5264 int number = argp[3] - '0'; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5265 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5266 // 0, 1 = block blink, 2 = block |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5267 // 3 = underline blink, 4 = underline |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5268 // 5 = vertical bar blink, 6 = vertical bar |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5269 number = number == 0 ? 1 : number; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5270 initial_cursor_shape = (number + 1) / 2; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5271 // The blink flag is actually inverted, compared to |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5272 // the value set with T_SH. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5273 initial_cursor_shape_blink = |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5274 (number & 1) ? FALSE : TRUE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5275 rcs_status.tr_progress = STATUS_GOT; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5276 LOG_TR(("Received cursor shape response: %s", tp)); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5277 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5278 key_name[0] = (int)KS_EXTRA; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5279 key_name[1] = (int)KE_IGNORE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5280 *slen = i + 1; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5281 # ifdef FEAT_EVAL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5282 set_vim_var_string(VV_TERMSTYLERESP, tp, *slen); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5283 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5284 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5285 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5286 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5287 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5288 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5289 if (i == len) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5290 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5291 // These codes arrive many together, each code can be |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5292 // truncated at any point. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5293 LOG_TR(("not enough characters for XT")); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5294 return FAIL; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5295 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5296 return OK; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5297 } |
20776
7728e309e013
patch 8.2.0940: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
20774
diff
changeset
|
5298 #endif // FEAT_TERMRESPONSE |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5299 |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5300 /* |
7 | 5301 * Check if typebuf.tb_buf[] contains a terminal key code. |
5302 * Check from typebuf.tb_buf[typebuf.tb_off] to typebuf.tb_buf[typebuf.tb_off | |
20727
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20705
diff
changeset
|
5303 * + "max_offset"]. |
7 | 5304 * Return 0 for no match, -1 for partial match, > 0 for full match. |
2672 | 5305 * Return KEYLEN_REMOVED when a key code was deleted. |
7 | 5306 * With a match, the match is removed, the replacement code is inserted in |
5307 * typebuf.tb_buf[] and the number of characters in typebuf.tb_buf[] is | |
5308 * returned. | |
3328 | 5309 * When "buf" is not NULL, buf[bufsize] is used instead of typebuf.tb_buf[]. |
5310 * "buflen" is then the length of the string in buf[] and is updated for | |
5311 * inserts and deletes. | |
7 | 5312 */ |
5313 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5314 check_termcode( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5315 int max_offset, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5316 char_u *buf, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5317 int bufsize, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5318 int *buflen) |
7 | 5319 { |
5320 char_u *tp; | |
5321 char_u *p; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5322 int slen = 0; // init for GCC |
180 | 5323 int modslen; |
7 | 5324 int len; |
2672 | 5325 int retval = 0; |
7 | 5326 int offset; |
5327 char_u key_name[2]; | |
180 | 5328 int modifiers; |
11565
91519a14ec1f
patch 8.0.0665: warning for uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
11563
diff
changeset
|
5329 char_u *modifiers_start = NULL; |
180 | 5330 int key; |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5331 int new_slen; // Length of what will replace the termcode |
7 | 5332 char_u string[MAX_KEY_CODE_LEN + 1]; |
5333 int i, j; | |
5334 int idx = 0; | |
5335 int cpo_koffset; | |
5336 | |
5337 cpo_koffset = (vim_strchr(p_cpo, CPO_KOFFSET) != NULL); | |
5338 | |
5339 /* | |
5340 * Speed up the checks for terminal codes by gathering all first bytes | |
5341 * used in termleader[]. Often this is just a single <Esc>. | |
5342 */ | |
5343 if (need_gather) | |
5344 gather_termleader(); | |
5345 | |
5346 /* | |
5347 * Check at several positions in typebuf.tb_buf[], to catch something like | |
5348 * "x<Up>" that can be mapped. Stop at max_offset, because characters | |
5349 * after that cannot be used for mapping, and with @r commands | |
4223 | 5350 * typebuf.tb_buf[] can become very long. |
7 | 5351 * This is used often, KEEP IT FAST! |
5352 */ | |
5353 for (offset = 0; offset < max_offset; ++offset) | |
5354 { | |
5355 if (buf == NULL) | |
5356 { | |
5357 if (offset >= typebuf.tb_len) | |
5358 break; | |
5359 tp = typebuf.tb_buf + typebuf.tb_off + offset; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5360 len = typebuf.tb_len - offset; // length of the input |
7 | 5361 } |
5362 else | |
5363 { | |
3328 | 5364 if (offset >= *buflen) |
7 | 5365 break; |
5366 tp = buf + offset; | |
3328 | 5367 len = *buflen - offset; |
7 | 5368 } |
5369 | |
5370 /* | |
5371 * Don't check characters after K_SPECIAL, those are already | |
5372 * translated terminal chars (avoid translating ~@^Hx). | |
5373 */ | |
5374 if (*tp == K_SPECIAL) | |
5375 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5376 offset += 2; // there are always 2 extra characters |
7 | 5377 continue; |
5378 } | |
5379 | |
5380 /* | |
5381 * Skip this position if the character does not appear as the first | |
5382 * character in term_strings. This speeds up a lot, since most | |
5383 * termcodes start with the same character (ESC or CSI). | |
5384 */ | |
5385 i = *tp; | |
5386 for (p = termleader; *p && *p != i; ++p) | |
5387 ; | |
5388 if (*p == NUL) | |
5389 continue; | |
5390 | |
5391 /* | |
5392 * Skip this position if p_ek is not set and tp[0] is an ESC and we | |
5393 * are in Insert mode. | |
5394 */ | |
5395 if (*tp == ESC && !p_ek && (State & INSERT)) | |
5396 continue; | |
5397 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5398 key_name[0] = NUL; // no key name found yet |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5399 key_name[1] = NUL; // no key name found yet |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5400 modifiers = 0; // no modifiers yet |
7 | 5401 |
5402 #ifdef FEAT_GUI | |
5403 if (gui.in_use) | |
5404 { | |
5405 /* | |
5406 * GUI special key codes are all of the form [CSI xx]. | |
5407 */ | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5408 if (*tp == CSI) // Special key from GUI |
7 | 5409 { |
5410 if (len < 3) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5411 return -1; // Shouldn't happen |
7 | 5412 slen = 3; |
5413 key_name[0] = tp[1]; | |
5414 key_name[1] = tp[2]; | |
5415 } | |
5416 } | |
5417 else | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5418 #endif // FEAT_GUI |
7 | 5419 { |
23774
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5420 int mouse_index_found = -1; |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5421 |
7 | 5422 for (idx = 0; idx < tc_len; ++idx) |
5423 { | |
5424 /* | |
5425 * Ignore the entry if we are not at the start of | |
5426 * typebuf.tb_buf[] | |
5427 * and there are not enough characters to make a match. | |
5428 * But only when the 'K' flag is in 'cpoptions'. | |
5429 */ | |
5430 slen = termcodes[idx].len; | |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
5431 modifiers_start = NULL; |
7 | 5432 if (cpo_koffset && offset && len < slen) |
5433 continue; | |
5434 if (STRNCMP(termcodes[idx].code, tp, | |
5435 (size_t)(slen > len ? len : slen)) == 0) | |
5436 { | |
26392
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5437 int looks_like_mouse_start = FALSE; |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5438 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5439 if (len < slen) // got a partial sequence |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5440 return -1; // need to get more chars |
7 | 5441 |
5442 /* | |
5443 * When found a keypad key, check if there is another key | |
5444 * that matches and use that one. This makes <Home> to be | |
5445 * found instead of <kHome> when they produce the same | |
5446 * key code. | |
5447 */ | |
5448 if (termcodes[idx].name[0] == 'K' | |
5449 && VIM_ISDIGIT(termcodes[idx].name[1])) | |
5450 { | |
5451 for (j = idx + 1; j < tc_len; ++j) | |
5452 if (termcodes[j].len == slen && | |
5453 STRNCMP(termcodes[idx].code, | |
5454 termcodes[j].code, slen) == 0) | |
5455 { | |
5456 idx = j; | |
5457 break; | |
5458 } | |
5459 } | |
5460 | |
23774
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5461 if (slen == 2 && len > 2 |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5462 && termcodes[idx].code[0] == ESC |
26392
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5463 && termcodes[idx].code[1] == '[') |
23774
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5464 { |
26392
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5465 // The mouse termcode "ESC [" is also the prefix of |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5466 // "ESC [ I" (focus gained) and other keys. Check some |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5467 // more bytes to find out. |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5468 if (!isdigit(tp[2])) |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5469 { |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5470 // ESC [ without number following: Only use it when |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5471 // there is no other match. |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5472 looks_like_mouse_start = TRUE; |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5473 } |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5474 else if (termcodes[idx].name[0] == KS_DEC_MOUSE) |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5475 { |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5476 char_u *nr = tp + 2; |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5477 int count = 0; |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5478 |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5479 // If a digit is following it could be a key with |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5480 // modifier, e.g., ESC [ 1;2P. Can be confused |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5481 // with DEC_MOUSE, which requires four numbers |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5482 // following. If not then it can't be a DEC_MOUSE |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5483 // code. |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5484 for (;;) |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5485 { |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5486 ++count; |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5487 (void)getdigits(&nr); |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5488 if (nr >= tp + len) |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5489 return -1; // partial sequence |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5490 if (*nr != ';') |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5491 break; |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5492 ++nr; |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5493 if (nr >= tp + len) |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5494 return -1; // partial sequence |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5495 } |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5496 if (count < 4) |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5497 continue; // no match |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5498 } |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5499 } |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5500 if (looks_like_mouse_start) |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5501 { |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5502 // Only use it when there is no other match. |
23774
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5503 if (mouse_index_found < 0) |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5504 mouse_index_found = idx; |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5505 } |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5506 else |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5507 { |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5508 key_name[0] = termcodes[idx].name[0]; |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5509 key_name[1] = termcodes[idx].name[1]; |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5510 break; |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5511 } |
7 | 5512 } |
179 | 5513 |
5514 /* | |
5515 * Check for code with modifier, like xterm uses: | |
180 | 5516 * <Esc>[123;*X (modslen == slen - 3) |
23406
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5517 * <Esc>[@;*X (matches <Esc>[X and <Esc>[1;9X ) |
180 | 5518 * Also <Esc>O*X and <M-O>*X (modslen == slen - 2). |
5519 * When there is a modifier the * matches a number. | |
5520 * When there is no modifier the ;* or * is omitted. | |
179 | 5521 */ |
23774
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5522 if (termcodes[idx].modlen > 0 && mouse_index_found < 0) |
179 | 5523 { |
23406
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5524 int at_code; |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5525 |
180 | 5526 modslen = termcodes[idx].modlen; |
5527 if (cpo_koffset && offset && len < modslen) | |
179 | 5528 continue; |
23406
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5529 at_code = termcodes[idx].code[modslen] == '@'; |
179 | 5530 if (STRNCMP(termcodes[idx].code, tp, |
180 | 5531 (size_t)(modslen > len ? len : modslen)) == 0) |
179 | 5532 { |
5533 int n; | |
180 | 5534 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5535 if (len <= modslen) // got a partial sequence |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5536 return -1; // need to get more chars |
179 | 5537 |
180 | 5538 if (tp[modslen] == termcodes[idx].code[slen - 1]) |
23406
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5539 // no modifiers |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5540 slen = modslen + 1; |
180 | 5541 else if (tp[modslen] != ';' && modslen == slen - 3) |
23406
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5542 // no match for "code;*X" with "code;" |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5543 continue; |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5544 else if (at_code && tp[modslen] != '1') |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5545 // no match for "<Esc>[@" with "<Esc>[1" |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5546 continue; |
179 | 5547 else |
5548 { | |
16485
b870146e09e1
patch 8.1.1246: cannot handle negative mouse coordinate from urxvt
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
5549 // Skip over the digits, the final char must |
b870146e09e1
patch 8.1.1246: cannot handle negative mouse coordinate from urxvt
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
5550 // follow. URXVT can use a negative value, thus |
b870146e09e1
patch 8.1.1246: cannot handle negative mouse coordinate from urxvt
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
5551 // also accept '-'. |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
5552 for (j = slen - 2; j < len && (isdigit(tp[j]) |
16485
b870146e09e1
patch 8.1.1246: cannot handle negative mouse coordinate from urxvt
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
5553 || tp[j] == '-' || tp[j] == ';'); ++j) |
179 | 5554 ; |
5555 ++j; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5556 if (len < j) // got a partial sequence |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5557 return -1; // need to get more chars |
180 | 5558 if (tp[j - 1] != termcodes[idx].code[slen - 1]) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5559 continue; // no match |
179 | 5560 |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
5561 modifiers_start = tp + slen - 2; |
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
5562 |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5563 // Match! Convert modifier bits. |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5564 n = atoi((char *)modifiers_start); |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5565 modifiers |= decode_modifiers(n); |
179 | 5566 |
5567 slen = j; | |
5568 } | |
5569 key_name[0] = termcodes[idx].name[0]; | |
5570 key_name[1] = termcodes[idx].name[1]; | |
5571 break; | |
5572 } | |
5573 } | |
7 | 5574 } |
23774
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5575 if (idx == tc_len && mouse_index_found >= 0) |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5576 { |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5577 key_name[0] = termcodes[mouse_index_found].name[0]; |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5578 key_name[1] = termcodes[mouse_index_found].name[1]; |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5579 } |
7 | 5580 } |
5581 | |
5582 #ifdef FEAT_TERMRESPONSE | |
3166 | 5583 if (key_name[0] == NUL |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5584 // Mouse codes of DEC and pterm start with <ESC>[. When |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5585 // detecting the start of these mouse codes they might as well be |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5586 // another key code or terminal response. |
6102 | 5587 # ifdef FEAT_MOUSE_DEC |
5588 || key_name[0] == KS_DEC_MOUSE | |
5589 # endif | |
5590 # ifdef FEAT_MOUSE_PTERM | |
5591 || key_name[0] == KS_PTERM_MOUSE | |
4223 | 5592 # endif |
6102 | 5593 ) |
7 | 5594 { |
18257
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5595 char_u *argp = tp[0] == ESC ? tp + 2 : tp + 1; |
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5596 |
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5597 /* |
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5598 * Check for responses from the terminal starting with {lead}: |
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5599 * "<Esc>[" or CSI followed by [0-9>?] |
4215 | 5600 * |
18257
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5601 * - Xterm version string: {lead}>{x};{vers};{y}c |
4215 | 5602 * Also eat other possible responses to t_RV, rxvt returns |
18257
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5603 * "{lead}?1;2c". |
4215 | 5604 * |
18257
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5605 * - Cursor position report: {lead}{row};{col}R |
6102 | 5606 * The final byte must be 'R'. It is used for checking the |
4215 | 5607 * ambiguous-width character state. |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
5608 * |
18257
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5609 * - window position reply: {lead}3;{x};{y}t |
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5610 * |
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5611 * - key with modifiers when modifyOtherKeys is enabled: |
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5612 * {lead}27;{modifier};{key}~ |
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5613 * {lead}{key};{modifier}u |
4215 | 5614 */ |
18257
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5615 if (((tp[0] == ESC && len >= 3 && tp[1] == '[') |
4395 | 5616 || (tp[0] == CSI && len >= 2)) |
18257
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5617 && (VIM_ISDIGIT(*argp) || *argp == '>' || *argp == '?')) |
7 | 5618 { |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5619 int resp = handle_csi(tp, len, argp, offset, buf, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5620 bufsize, buflen, key_name, &slen); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5621 if (resp != 0) |
7 | 5622 { |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5623 # ifdef DEBUG_TERMRESPONSE |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5624 if (resp == -1) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5625 LOG_TR(("Not enough characters for CSI sequence")); |
7 | 5626 # endif |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5627 return resp; |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
5628 } |
6901 | 5629 } |
5630 | |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5631 // Check for fore/background color response from the terminal, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5632 // starting} with <Esc>] or OSC |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5633 else if ((*T_RBG != NUL || *T_RFG != NUL) |
6901 | 5634 && ((tp[0] == ESC && len >= 2 && tp[1] == ']') |
5635 || tp[0] == OSC)) | |
5636 { | |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5637 if (handle_osc(tp, argp, len, key_name, &slen) == FAIL) |
6901 | 5638 return -1; |
7 | 5639 } |
5640 | |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5641 // Check for key code response from xterm, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5642 // starting with <Esc>P or DCS |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
5643 else if ((check_for_codes || rcs_status.tr_progress == STATUS_SENT) |
6901 | 5644 && ((tp[0] == ESC && len >= 2 && tp[1] == 'P') |
7 | 5645 || tp[0] == DCS)) |
5646 { | |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5647 if (handle_dcs(tp, argp, len, key_name, &slen) == FAIL) |
6901 | 5648 return -1; |
7 | 5649 } |
5650 } | |
5651 #endif | |
5652 | |
5653 if (key_name[0] == NUL) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5654 continue; // No match at this position, try next one |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5655 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5656 // We only get here when we have a complete termcode match |
7 | 5657 |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5658 #ifdef FEAT_GUI |
7 | 5659 /* |
5660 * Only in the GUI: Fetch the pointer coordinates of the scroll event | |
5661 * so that we know which window to scroll later. | |
5662 */ | |
5663 if (gui.in_use | |
5664 && key_name[0] == (int)KS_EXTRA | |
5665 && (key_name[1] == (int)KE_X1MOUSE | |
5666 || key_name[1] == (int)KE_X2MOUSE | |
24850
f8906bd5b277
patch 8.2.2963: GUI: mouse move may start Visual mode with a popup visible
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
5667 || key_name[1] == (int)KE_MOUSEMOVE_XY |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2347
diff
changeset
|
5668 || key_name[1] == (int)KE_MOUSELEFT |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2347
diff
changeset
|
5669 || key_name[1] == (int)KE_MOUSERIGHT |
7 | 5670 || key_name[1] == (int)KE_MOUSEDOWN |
5671 || key_name[1] == (int)KE_MOUSEUP)) | |
5672 { | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5673 char_u bytes[6]; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5674 int num_bytes = get_bytes_from_buf(tp + slen, bytes, 4); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5675 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5676 if (num_bytes == -1) // not enough coordinates |
7 | 5677 return -1; |
5678 mouse_col = 128 * (bytes[0] - ' ' - 1) + bytes[1] - ' ' - 1; | |
5679 mouse_row = 128 * (bytes[2] - ' ' - 1) + bytes[3] - ' ' - 1; | |
5680 slen += num_bytes; | |
24850
f8906bd5b277
patch 8.2.2963: GUI: mouse move may start Visual mode with a popup visible
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
5681 // equal to K_MOUSEMOVE |
f8906bd5b277
patch 8.2.2963: GUI: mouse move may start Visual mode with a popup visible
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
5682 if (key_name[1] == (int)KE_MOUSEMOVE_XY) |
f8906bd5b277
patch 8.2.2963: GUI: mouse move may start Visual mode with a popup visible
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
5683 key_name[1] = (int)KE_MOUSEMOVE; |
7 | 5684 } |
5685 else | |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5686 #endif |
7 | 5687 /* |
5688 * If it is a mouse click, get the coordinates. | |
5689 */ | |
3746 | 5690 if (key_name[0] == KS_MOUSE |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5691 #ifdef FEAT_MOUSE_GPM |
16523
a72ad8a8b249
patch 8.1.1265: when GPM mouse support is enabled double clicks do not work
Bram Moolenaar <Bram@vim.org>
parents:
16501
diff
changeset
|
5692 || key_name[0] == KS_GPM_MOUSE |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5693 #endif |
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5694 #ifdef FEAT_MOUSE_JSB |
3746 | 5695 || key_name[0] == KS_JSBTERM_MOUSE |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5696 #endif |
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5697 #ifdef FEAT_MOUSE_NET |
3746 | 5698 || key_name[0] == KS_NETTERM_MOUSE |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5699 #endif |
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5700 #ifdef FEAT_MOUSE_DEC |
3746 | 5701 || key_name[0] == KS_DEC_MOUSE |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5702 #endif |
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5703 #ifdef FEAT_MOUSE_PTERM |
3746 | 5704 || key_name[0] == KS_PTERM_MOUSE |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5705 #endif |
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5706 #ifdef FEAT_MOUSE_URXVT |
3746 | 5707 || key_name[0] == KS_URXVT_MOUSE |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5708 #endif |
3746 | 5709 || key_name[0] == KS_SGR_MOUSE |
16058
012f03e583e2
patch 8.1.1034: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
5710 || key_name[0] == KS_SGR_MOUSE_RELEASE) |
7 | 5711 { |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5712 if (check_termcode_mouse(tp, &slen, key_name, modifiers_start, idx, |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5713 &modifiers) == -1) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5714 return -1; |
7 | 5715 } |
5716 | |
5717 #ifdef FEAT_GUI | |
5718 /* | |
5719 * If using the GUI, then we get menu and scrollbar events. | |
5720 * | |
5721 * A menu event is encoded as K_SPECIAL, KS_MENU, KE_FILLER followed by | |
5722 * four bytes which are to be taken as a pointer to the vimmenu_T | |
5723 * structure. | |
5724 * | |
1221 | 5725 * A tab line event is encoded as K_SPECIAL KS_TABLINE nr, where "nr" |
685 | 5726 * is one byte with the tab index. |
5727 * | |
7 | 5728 * A scrollbar event is K_SPECIAL, KS_VER_SCROLLBAR, KE_FILLER followed |
5729 * by one byte representing the scrollbar number, and then four bytes | |
5730 * representing a long_u which is the new value of the scrollbar. | |
5731 * | |
5732 * A horizontal scrollbar event is K_SPECIAL, KS_HOR_SCROLLBAR, | |
5733 * KE_FILLER followed by four bytes representing a long_u which is the | |
5734 * new value of the scrollbar. | |
5735 */ | |
5736 # ifdef FEAT_MENU | |
5737 else if (key_name[0] == (int)KS_MENU) | |
5738 { | |
5739 long_u val; | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5740 int num_bytes = get_long_from_buf(tp + slen, &val); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5741 |
7 | 5742 if (num_bytes == -1) |
5743 return -1; | |
5744 current_menu = (vimmenu_T *)val; | |
5745 slen += num_bytes; | |
936 | 5746 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5747 // The menu may have been deleted right after it was used, check |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5748 // for that. |
936 | 5749 if (check_menu_pointer(root_menu, current_menu) == FAIL) |
5750 { | |
5751 key_name[0] = KS_EXTRA; | |
5752 key_name[1] = (int)KE_IGNORE; | |
5753 } | |
7 | 5754 } |
5755 # endif | |
685 | 5756 # ifdef FEAT_GUI_TABLINE |
5757 else if (key_name[0] == (int)KS_TABLINE) | |
5758 { | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5759 // Selecting tabline tab or using its menu. |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5760 char_u bytes[6]; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5761 int num_bytes = get_bytes_from_buf(tp + slen, bytes, 1); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5762 |
685 | 5763 if (num_bytes == -1) |
5764 return -1; | |
5765 current_tab = (int)bytes[0]; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5766 if (current_tab == 255) // -1 in a byte gives 255 |
1394 | 5767 current_tab = -1; |
685 | 5768 slen += num_bytes; |
5769 } | |
688 | 5770 else if (key_name[0] == (int)KS_TABMENU) |
5771 { | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5772 // Selecting tabline tab or using its menu. |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5773 char_u bytes[6]; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5774 int num_bytes = get_bytes_from_buf(tp + slen, bytes, 2); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5775 |
688 | 5776 if (num_bytes == -1) |
5777 return -1; | |
5778 current_tab = (int)bytes[0]; | |
5779 current_tabmenu = (int)bytes[1]; | |
5780 slen += num_bytes; | |
5781 } | |
685 | 5782 # endif |
7 | 5783 # ifndef USE_ON_FLY_SCROLL |
5784 else if (key_name[0] == (int)KS_VER_SCROLLBAR) | |
5785 { | |
5786 long_u val; | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5787 char_u bytes[6]; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5788 int num_bytes; |
7 | 5789 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5790 // Get the last scrollbar event in the queue of the same type |
7 | 5791 j = 0; |
5792 for (i = 0; tp[j] == CSI && tp[j + 1] == KS_VER_SCROLLBAR | |
5793 && tp[j + 2] != NUL; ++i) | |
5794 { | |
5795 j += 3; | |
5796 num_bytes = get_bytes_from_buf(tp + j, bytes, 1); | |
5797 if (num_bytes == -1) | |
5798 break; | |
5799 if (i == 0) | |
5800 current_scrollbar = (int)bytes[0]; | |
5801 else if (current_scrollbar != (int)bytes[0]) | |
5802 break; | |
5803 j += num_bytes; | |
5804 num_bytes = get_long_from_buf(tp + j, &val); | |
5805 if (num_bytes == -1) | |
5806 break; | |
5807 scrollbar_value = val; | |
5808 j += num_bytes; | |
5809 slen = j; | |
5810 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5811 if (i == 0) // not enough characters to make one |
7 | 5812 return -1; |
5813 } | |
5814 else if (key_name[0] == (int)KS_HOR_SCROLLBAR) | |
5815 { | |
5816 long_u val; | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5817 int num_bytes; |
7 | 5818 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5819 // Get the last horiz. scrollbar event in the queue |
7 | 5820 j = 0; |
5821 for (i = 0; tp[j] == CSI && tp[j + 1] == KS_HOR_SCROLLBAR | |
5822 && tp[j + 2] != NUL; ++i) | |
5823 { | |
5824 j += 3; | |
5825 num_bytes = get_long_from_buf(tp + j, &val); | |
5826 if (num_bytes == -1) | |
5827 break; | |
5828 scrollbar_value = val; | |
5829 j += num_bytes; | |
5830 slen = j; | |
5831 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5832 if (i == 0) // not enough characters to make one |
7 | 5833 return -1; |
5834 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5835 # endif // !USE_ON_FLY_SCROLL |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5836 #endif // FEAT_GUI |
7 | 5837 |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5838 #if (defined(UNIX) || defined(VMS)) |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5839 /* |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5840 * Handle FocusIn/FocusOut event sequences reported by XTerm. |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5841 * (CSI I/CSI O) |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5842 */ |
27930
1a702abffaf3
patch 8.2.4490: terminal focus reporting only works for xterm-like terminals
Bram Moolenaar <Bram@vim.org>
parents:
27684
diff
changeset
|
5843 if (key_name[0] == KS_EXTRA |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5844 # ifdef FEAT_GUI |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5845 && !gui.in_use |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5846 # endif |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5847 ) |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5848 { |
23620
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5849 if (key_name[1] == KE_FOCUSGAINED) |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5850 { |
23620
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5851 if (!focus_state) |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5852 { |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5853 ui_focus_change(TRUE); |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5854 did_cursorhold = TRUE; |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5855 focus_state = TRUE; |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5856 } |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5857 key_name[1] = (int)KE_IGNORE; |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5858 } |
23620
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5859 else if (key_name[1] == KE_FOCUSLOST) |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5860 { |
23620
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5861 if (focus_state) |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5862 { |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5863 ui_focus_change(FALSE); |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5864 did_cursorhold = TRUE; |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5865 focus_state = FALSE; |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5866 } |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5867 key_name[1] = (int)KE_IGNORE; |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5868 } |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5869 } |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5870 #endif |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5871 |
180 | 5872 /* |
5873 * Change <xHome> to <Home>, <xUp> to <Up>, etc. | |
5874 */ | |
5875 key = handle_x_keys(TERMCAP2KEY(key_name[0], key_name[1])); | |
5876 | |
5877 /* | |
5878 * Add any modifier codes to our string. | |
5879 */ | |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5880 new_slen = modifiers2keycode(modifiers, &key, string); |
180 | 5881 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5882 // Finally, add the special key code to our string |
180 | 5883 key_name[0] = KEY2TERMCAP0(key); |
5884 key_name[1] = KEY2TERMCAP1(key); | |
7 | 5885 if (key_name[0] == KS_KEY) |
1787 | 5886 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5887 // from ":set <M-b>=xx" |
1787 | 5888 if (has_mbyte) |
5889 new_slen += (*mb_char2bytes)(key_name[1], string + new_slen); | |
5890 else | |
5891 string[new_slen++] = key_name[1]; | |
5892 } | |
2672 | 5893 else if (new_slen == 0 && key_name[0] == KS_EXTRA |
5894 && key_name[1] == KE_IGNORE) | |
5895 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5896 // Do not put K_IGNORE into the buffer, do return KEYLEN_REMOVED |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5897 // to indicate what happened. |
2672 | 5898 retval = KEYLEN_REMOVED; |
5899 } | |
7 | 5900 else |
5901 { | |
5902 string[new_slen++] = K_SPECIAL; | |
5903 string[new_slen++] = key_name[0]; | |
5904 string[new_slen++] = key_name[1]; | |
5905 } | |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5906 if (put_string_in_typebuf(offset, slen, string, new_slen, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5907 buf, bufsize, buflen) == FAIL) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5908 return -1; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5909 return retval == 0 ? (len + new_slen - slen + offset) : retval; |
7 | 5910 } |
5911 | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5912 #ifdef FEAT_TERMRESPONSE |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
5913 LOG_TR(("normal character")); |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5914 #endif |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5915 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5916 return 0; // no match found |
7 | 5917 } |
5918 | |
12634
94566ecb55f0
patch 8.0.1195: can't build on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12632
diff
changeset
|
5919 #if (defined(FEAT_TERMINAL) && defined(FEAT_TERMRESPONSE)) || defined(PROTO) |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5920 /* |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5921 * Get the text foreground color, if known. |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5922 */ |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5923 void |
12640
a715f0b44532
patch 8.0.1198: older compilers don't know uint8_t
Christian Brabandt <cb@256bit.org>
parents:
12634
diff
changeset
|
5924 term_get_fg_color(char_u *r, char_u *g, char_u *b) |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5925 { |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
5926 if (rfg_status.tr_progress == STATUS_GOT) |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5927 { |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5928 *r = fg_r; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5929 *g = fg_g; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5930 *b = fg_b; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5931 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5932 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5933 |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5934 /* |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5935 * Get the text background color, if known. |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5936 */ |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5937 void |
12640
a715f0b44532
patch 8.0.1198: older compilers don't know uint8_t
Christian Brabandt <cb@256bit.org>
parents:
12634
diff
changeset
|
5938 term_get_bg_color(char_u *r, char_u *g, char_u *b) |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5939 { |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
5940 if (rbg_status.tr_progress == STATUS_GOT) |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5941 { |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5942 *r = bg_r; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5943 *g = bg_g; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5944 *b = bg_b; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5945 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5946 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5947 #endif |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5948 |
7 | 5949 /* |
5950 * Replace any terminal code strings in from[] with the equivalent internal | |
5951 * vim representation. This is used for the "from" and "to" part of a | |
5952 * mapping, and the "to" part of a menu command. | |
5953 * Any strings like "<C-UP>" are also replaced, unless 'cpoptions' contains | |
5954 * '<'. | |
5955 * K_SPECIAL by itself is replaced by K_SPECIAL KS_SPECIAL KE_FILLER. | |
5956 * | |
5957 * The replacement is done in result[] and finally copied into allocated | |
5958 * memory. If this all works well *bufp is set to the allocated memory and a | |
5959 * pointer to it is returned. If something fails *bufp is set to NULL and from | |
5960 * is returned. | |
5961 * | |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5962 * CTRL-V characters are removed. When "flags" has REPTERM_FROM_PART, a |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5963 * trailing CTRL-V is included, otherwise it is removed (for ":map xx ^V", maps |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5964 * xx to nothing). When 'cpoptions' does not contain 'B', a backslash can be |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5965 * used instead of a CTRL-V. |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5966 * |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5967 * Flags: |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5968 * REPTERM_FROM_PART see above |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5969 * REPTERM_DO_LT also translate <lt> |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5970 * REPTERM_SPECIAL always accept <key> notation |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5971 * REPTERM_NO_SIMPLIFY do not simplify <C-H> to 0x08 and set 8th bit for <A-x> |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5972 * |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5973 * "did_simplify" is set when some <C-H> or <A-x> code was simplified, unless |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5974 * it is NULL. |
7 | 5975 */ |
859 | 5976 char_u * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5977 replace_termcodes( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5978 char_u *from, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5979 char_u **bufp, |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5980 int flags, |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5981 int *did_simplify) |
7 | 5982 { |
5983 int i; | |
5984 int slen; | |
5985 int key; | |
28497
7c4a9e20c178
patch 8.2.4773: build failure without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
28457
diff
changeset
|
5986 size_t dlen = 0; |
7 | 5987 char_u *src; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5988 int do_backslash; // backslash is a special character |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5989 int do_special; // recognize <> key codes |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5990 int do_key_code; // recognize raw key codes |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5991 char_u *result; // buffer for resulting string |
28453
862068e9e2a7
patch 8.2.4751: mapping <SID>name.Func does not work for autoload script
Bram Moolenaar <Bram@vim.org>
parents:
28447
diff
changeset
|
5992 garray_T ga; |
7 | 5993 |
5994 do_backslash = (vim_strchr(p_cpo, CPO_BSLASH) == NULL); | |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5995 do_special = (vim_strchr(p_cpo, CPO_SPECI) == NULL) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5996 || (flags & REPTERM_SPECIAL); |
7 | 5997 do_key_code = (vim_strchr(p_cpo, CPO_KEYCODE) == NULL); |
28453
862068e9e2a7
patch 8.2.4751: mapping <SID>name.Func does not work for autoload script
Bram Moolenaar <Bram@vim.org>
parents:
28447
diff
changeset
|
5998 src = from; |
7 | 5999 |
6000 /* | |
6001 * Allocate space for the translation. Worst case a single character is | |
6002 * replaced by 6 bytes (shifted special key), plus a NUL at the end. | |
28453
862068e9e2a7
patch 8.2.4751: mapping <SID>name.Func does not work for autoload script
Bram Moolenaar <Bram@vim.org>
parents:
28447
diff
changeset
|
6003 * In the rare case more might be needed ga_grow() must be called again. |
7 | 6004 */ |
28453
862068e9e2a7
patch 8.2.4751: mapping <SID>name.Func does not work for autoload script
Bram Moolenaar <Bram@vim.org>
parents:
28447
diff
changeset
|
6005 ga_init2(&ga, 1L, 100); |
28497
7c4a9e20c178
patch 8.2.4773: build failure without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
28457
diff
changeset
|
6006 if (ga_grow(&ga, (int)(STRLEN(src) * 6 + 1)) == FAIL) // out of memory |
7 | 6007 { |
6008 *bufp = NULL; | |
6009 return from; | |
6010 } | |
28453
862068e9e2a7
patch 8.2.4751: mapping <SID>name.Func does not work for autoload script
Bram Moolenaar <Bram@vim.org>
parents:
28447
diff
changeset
|
6011 result = ga.ga_data; |
7 | 6012 |
6013 /* | |
6014 * Check for #n at start only: function key n | |
6015 */ | |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
6016 if ((flags & REPTERM_FROM_PART) && src[0] == '#' && VIM_ISDIGIT(src[1])) |
7 | 6017 { |
6018 result[dlen++] = K_SPECIAL; | |
6019 result[dlen++] = 'k'; | |
6020 if (src[1] == '0') | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6021 result[dlen++] = ';'; // #0 is F10 is "k;" |
7 | 6022 else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6023 result[dlen++] = src[1]; // #3 is F3 is "k3" |
7 | 6024 src += 2; |
6025 } | |
6026 | |
6027 /* | |
6028 * Copy each byte from *from to result[dlen] | |
6029 */ | |
6030 while (*src != NUL) | |
6031 { | |
6032 /* | |
6033 * If 'cpoptions' does not contain '<', check for special key codes, | |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2347
diff
changeset
|
6034 * like "<C-S-LeftMouse>" |
7 | 6035 */ |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
6036 if (do_special && ((flags & REPTERM_DO_LT) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
6037 || STRNCMP(src, "<lt>", 4) != 0)) |
7 | 6038 { |
6039 #ifdef FEAT_EVAL | |
6040 /* | |
28447
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28013
diff
changeset
|
6041 * Change <SID>Func to K_SNR <script-nr> _Func. This name is used |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28013
diff
changeset
|
6042 * for script-locla user functions. |
7 | 6043 * (room: 5 * 6 = 30 bytes; needed: 3 + <nr> + 1 <= 14) |
28447
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28013
diff
changeset
|
6044 * Also change <SID>name.Func to K_SNR <import-script-nr> _Func. |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28013
diff
changeset
|
6045 * Only if "name" is recognized as an import. |
7 | 6046 */ |
6047 if (STRNICMP(src, "<SID>", 5) == 0) | |
6048 { | |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14581
diff
changeset
|
6049 if (current_sctx.sc_sid <= 0) |
26439
b18f3b0f317c
patch 8.2.3750: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
6050 emsg(_(e_using_sid_not_in_script_context)); |
7 | 6051 else |
6052 { | |
28447
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28013
diff
changeset
|
6053 char_u *dot; |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28013
diff
changeset
|
6054 long sid = current_sctx.sc_sid; |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28013
diff
changeset
|
6055 |
7 | 6056 src += 5; |
28447
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28013
diff
changeset
|
6057 if (in_vim9script() |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28013
diff
changeset
|
6058 && (dot = vim_strchr(src, '.')) != NULL) |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28013
diff
changeset
|
6059 { |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28013
diff
changeset
|
6060 imported_T *imp = find_imported(src, dot - src, FALSE); |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28013
diff
changeset
|
6061 |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28013
diff
changeset
|
6062 if (imp != NULL) |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28013
diff
changeset
|
6063 { |
28453
862068e9e2a7
patch 8.2.4751: mapping <SID>name.Func does not work for autoload script
Bram Moolenaar <Bram@vim.org>
parents:
28447
diff
changeset
|
6064 scriptitem_T *si = SCRIPT_ITEM(imp->imp_sid); |
862068e9e2a7
patch 8.2.4751: mapping <SID>name.Func does not work for autoload script
Bram Moolenaar <Bram@vim.org>
parents:
28447
diff
changeset
|
6065 size_t len; |
862068e9e2a7
patch 8.2.4751: mapping <SID>name.Func does not work for autoload script
Bram Moolenaar <Bram@vim.org>
parents:
28447
diff
changeset
|
6066 |
862068e9e2a7
patch 8.2.4751: mapping <SID>name.Func does not work for autoload script
Bram Moolenaar <Bram@vim.org>
parents:
28447
diff
changeset
|
6067 src = dot + 1; |
862068e9e2a7
patch 8.2.4751: mapping <SID>name.Func does not work for autoload script
Bram Moolenaar <Bram@vim.org>
parents:
28447
diff
changeset
|
6068 if (si->sn_autoload_prefix != NULL) |
862068e9e2a7
patch 8.2.4751: mapping <SID>name.Func does not work for autoload script
Bram Moolenaar <Bram@vim.org>
parents:
28447
diff
changeset
|
6069 { |
862068e9e2a7
patch 8.2.4751: mapping <SID>name.Func does not work for autoload script
Bram Moolenaar <Bram@vim.org>
parents:
28447
diff
changeset
|
6070 // Turn "<SID>name.Func" |
862068e9e2a7
patch 8.2.4751: mapping <SID>name.Func does not work for autoload script
Bram Moolenaar <Bram@vim.org>
parents:
28447
diff
changeset
|
6071 // into "scriptname#Func". |
862068e9e2a7
patch 8.2.4751: mapping <SID>name.Func does not work for autoload script
Bram Moolenaar <Bram@vim.org>
parents:
28447
diff
changeset
|
6072 len = STRLEN(si->sn_autoload_prefix); |
28497
7c4a9e20c178
patch 8.2.4773: build failure without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
28457
diff
changeset
|
6073 if (ga_grow(&ga, |
7c4a9e20c178
patch 8.2.4773: build failure without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
28457
diff
changeset
|
6074 (int)(STRLEN(src) * 6 + len + 1)) == FAIL) |
28453
862068e9e2a7
patch 8.2.4751: mapping <SID>name.Func does not work for autoload script
Bram Moolenaar <Bram@vim.org>
parents:
28447
diff
changeset
|
6075 { |
862068e9e2a7
patch 8.2.4751: mapping <SID>name.Func does not work for autoload script
Bram Moolenaar <Bram@vim.org>
parents:
28447
diff
changeset
|
6076 ga_clear(&ga); |
862068e9e2a7
patch 8.2.4751: mapping <SID>name.Func does not work for autoload script
Bram Moolenaar <Bram@vim.org>
parents:
28447
diff
changeset
|
6077 *bufp = NULL; |
862068e9e2a7
patch 8.2.4751: mapping <SID>name.Func does not work for autoload script
Bram Moolenaar <Bram@vim.org>
parents:
28447
diff
changeset
|
6078 return from; |
862068e9e2a7
patch 8.2.4751: mapping <SID>name.Func does not work for autoload script
Bram Moolenaar <Bram@vim.org>
parents:
28447
diff
changeset
|
6079 } |
862068e9e2a7
patch 8.2.4751: mapping <SID>name.Func does not work for autoload script
Bram Moolenaar <Bram@vim.org>
parents:
28447
diff
changeset
|
6080 result = ga.ga_data; |
862068e9e2a7
patch 8.2.4751: mapping <SID>name.Func does not work for autoload script
Bram Moolenaar <Bram@vim.org>
parents:
28447
diff
changeset
|
6081 STRCPY(result + dlen, si->sn_autoload_prefix); |
862068e9e2a7
patch 8.2.4751: mapping <SID>name.Func does not work for autoload script
Bram Moolenaar <Bram@vim.org>
parents:
28447
diff
changeset
|
6082 dlen += len; |
862068e9e2a7
patch 8.2.4751: mapping <SID>name.Func does not work for autoload script
Bram Moolenaar <Bram@vim.org>
parents:
28447
diff
changeset
|
6083 continue; |
862068e9e2a7
patch 8.2.4751: mapping <SID>name.Func does not work for autoload script
Bram Moolenaar <Bram@vim.org>
parents:
28447
diff
changeset
|
6084 } |
28447
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28013
diff
changeset
|
6085 sid = imp->imp_sid; |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28013
diff
changeset
|
6086 } |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28013
diff
changeset
|
6087 } |
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28013
diff
changeset
|
6088 |
7 | 6089 result[dlen++] = K_SPECIAL; |
6090 result[dlen++] = (int)KS_EXTRA; | |
6091 result[dlen++] = (int)KE_SNR; | |
28447
6f753a8125f0
patch 8.2.4748: cannot use an imported function in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
28013
diff
changeset
|
6092 sprintf((char *)result + dlen, "%ld", sid); |
28497
7c4a9e20c178
patch 8.2.4773: build failure without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
28457
diff
changeset
|
6093 dlen += STRLEN(result + dlen); |
7 | 6094 result[dlen++] = '_'; |
6095 continue; | |
6096 } | |
6097 } | |
6098 #endif | |
20603
c2570baa2e4c
patch 8.2.0855: GUI tests fail because the test doesn't use a modifier
Bram Moolenaar <Bram@vim.org>
parents:
20591
diff
changeset
|
6099 slen = trans_special(&src, result + dlen, FSK_KEYCODE |
c2570baa2e4c
patch 8.2.0855: GUI tests fail because the test doesn't use a modifier
Bram Moolenaar <Bram@vim.org>
parents:
20591
diff
changeset
|
6100 | ((flags & REPTERM_NO_SIMPLIFY) ? 0 : FSK_SIMPLIFY), |
c2570baa2e4c
patch 8.2.0855: GUI tests fail because the test doesn't use a modifier
Bram Moolenaar <Bram@vim.org>
parents:
20591
diff
changeset
|
6101 did_simplify); |
7 | 6102 if (slen) |
6103 { | |
6104 dlen += slen; | |
6105 continue; | |
6106 } | |
6107 } | |
6108 | |
6109 /* | |
6110 * If 'cpoptions' does not contain 'k', see if it's an actual key-code. | |
6111 * Note that this is also checked after replacing the <> form. | |
6112 * Single character codes are NOT replaced (e.g. ^H or DEL), because | |
6113 * it could be a character in the file. | |
6114 */ | |
6115 if (do_key_code) | |
6116 { | |
6117 i = find_term_bykeys(src); | |
6118 if (i >= 0) | |
6119 { | |
6120 result[dlen++] = K_SPECIAL; | |
6121 result[dlen++] = termcodes[i].name[0]; | |
6122 result[dlen++] = termcodes[i].name[1]; | |
6123 src += termcodes[i].len; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6124 // If terminal code matched, continue after it. |
7 | 6125 continue; |
6126 } | |
6127 } | |
6128 | |
6129 #ifdef FEAT_EVAL | |
6130 if (do_special) | |
6131 { | |
6132 char_u *p, *s, len; | |
6133 | |
6134 /* | |
6135 * Replace <Leader> by the value of "mapleader". | |
6136 * Replace <LocalLeader> by the value of "maplocalleader". | |
6137 * If "mapleader" or "maplocalleader" isn't set use a backslash. | |
6138 */ | |
6139 if (STRNICMP(src, "<Leader>", 8) == 0) | |
6140 { | |
6141 len = 8; | |
6142 p = get_var_value((char_u *)"g:mapleader"); | |
6143 } | |
6144 else if (STRNICMP(src, "<LocalLeader>", 13) == 0) | |
6145 { | |
6146 len = 13; | |
6147 p = get_var_value((char_u *)"g:maplocalleader"); | |
6148 } | |
6149 else | |
6150 { | |
6151 len = 0; | |
6152 p = NULL; | |
6153 } | |
6154 if (len != 0) | |
6155 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6156 // Allow up to 8 * 6 characters for "mapleader". |
7 | 6157 if (p == NULL || *p == NUL || STRLEN(p) > 8 * 6) |
6158 s = (char_u *)"\\"; | |
6159 else | |
6160 s = p; | |
6161 while (*s != NUL) | |
6162 result[dlen++] = *s++; | |
6163 src += len; | |
6164 continue; | |
6165 } | |
6166 } | |
6167 #endif | |
6168 | |
6169 /* | |
6170 * Remove CTRL-V and ignore the next character. | |
6171 * For "from" side the CTRL-V at the end is included, for the "to" | |
6172 * part it is removed. | |
6173 * If 'cpoptions' does not contain 'B', also accept a backslash. | |
6174 */ | |
6175 key = *src; | |
6176 if (key == Ctrl_V || (do_backslash && key == '\\')) | |
6177 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6178 ++src; // skip CTRL-V or backslash |
7 | 6179 if (*src == NUL) |
6180 { | |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
6181 if (flags & REPTERM_FROM_PART) |
7 | 6182 result[dlen++] = key; |
6183 break; | |
6184 } | |
6185 } | |
6186 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6187 // skip multibyte char correctly |
474 | 6188 for (i = (*mb_ptr2len)(src); i > 0; --i) |
7 | 6189 { |
6190 /* | |
6191 * If the character is K_SPECIAL, replace it with K_SPECIAL | |
6192 * KS_SPECIAL KE_FILLER. | |
6193 * If compiled with the GUI replace CSI with K_CSI. | |
6194 */ | |
6195 if (*src == K_SPECIAL) | |
6196 { | |
6197 result[dlen++] = K_SPECIAL; | |
6198 result[dlen++] = KS_SPECIAL; | |
6199 result[dlen++] = KE_FILLER; | |
6200 } | |
6201 # ifdef FEAT_GUI | |
6202 else if (*src == CSI) | |
6203 { | |
6204 result[dlen++] = K_SPECIAL; | |
6205 result[dlen++] = KS_EXTRA; | |
6206 result[dlen++] = (int)KE_CSI; | |
6207 } | |
6208 # endif | |
6209 else | |
6210 result[dlen++] = *src; | |
6211 ++src; | |
6212 } | |
6213 } | |
6214 result[dlen] = NUL; | |
6215 | |
6216 /* | |
6217 * Copy the new string to allocated memory. | |
6218 * If this fails, just return from. | |
6219 */ | |
6220 if ((*bufp = vim_strsave(result)) != NULL) | |
6221 from = *bufp; | |
6222 vim_free(result); | |
6223 return from; | |
6224 } | |
6225 | |
6226 /* | |
6227 * Find a termcode with keys 'src' (must be NUL terminated). | |
6228 * Return the index in termcodes[], or -1 if not found. | |
6229 */ | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
6230 static int |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6231 find_term_bykeys(char_u *src) |
7 | 6232 { |
6233 int i; | |
3290 | 6234 int slen = (int)STRLEN(src); |
7 | 6235 |
6236 for (i = 0; i < tc_len; ++i) | |
6237 { | |
3273 | 6238 if (slen == termcodes[i].len |
6239 && STRNCMP(termcodes[i].code, src, (size_t)slen) == 0) | |
7 | 6240 return i; |
6241 } | |
6242 return -1; | |
6243 } | |
6244 | |
6245 /* | |
6246 * Gather the first characters in the terminal key codes into a string. | |
6247 * Used to speed up check_termcode(). | |
6248 */ | |
6249 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6250 gather_termleader(void) |
7 | 6251 { |
6252 int i; | |
6253 int len = 0; | |
6254 | |
6255 #ifdef FEAT_GUI | |
6256 if (gui.in_use) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6257 termleader[len++] = CSI; // the GUI codes are not in termcodes[] |
7 | 6258 #endif |
6259 #ifdef FEAT_TERMRESPONSE | |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
6260 if (check_for_codes || *T_CRS != NUL) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6261 termleader[len++] = DCS; // the termcode response starts with DCS |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6262 // in 8-bit mode |
7 | 6263 #endif |
6264 termleader[len] = NUL; | |
6265 | |
6266 for (i = 0; i < tc_len; ++i) | |
6267 if (vim_strchr(termleader, termcodes[i].code[0]) == NULL) | |
6268 { | |
6269 termleader[len++] = termcodes[i].code[0]; | |
6270 termleader[len] = NUL; | |
6271 } | |
6272 | |
6273 need_gather = FALSE; | |
6274 } | |
6275 | |
6276 /* | |
6277 * Show all termcodes (for ":set termcap") | |
6278 * This code looks a lot like showoptions(), but is different. | |
26400
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26392
diff
changeset
|
6279 * "flags" can have OPT_ONECOLUMN. |
7 | 6280 */ |
6281 void | |
26400
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26392
diff
changeset
|
6282 show_termcodes(int flags) |
7 | 6283 { |
6284 int col; | |
6285 int *items; | |
6286 int item_count; | |
6287 int run; | |
6288 int row, rows; | |
6289 int cols; | |
6290 int i; | |
6291 int len; | |
6292 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6293 #define INC3 27 // try to make three columns |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6294 #define INC2 40 // try to make two columns |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6295 #define GAP 2 // spaces between columns |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6296 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6297 if (tc_len == 0) // no terminal codes (must be GUI) |
7 | 6298 return; |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
6299 items = ALLOC_MULT(int, tc_len); |
7 | 6300 if (items == NULL) |
6301 return; | |
6302 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6303 // Highlight title |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6304 msg_puts_title(_("\n--- Terminal keys ---")); |
7 | 6305 |
6306 /* | |
26400
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26392
diff
changeset
|
6307 * Do the loop three times: |
7 | 6308 * 1. display the short items (non-strings and short strings) |
180 | 6309 * 2. display the medium items (medium length strings) |
6310 * 3. display the long items (remaining strings) | |
26400
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26392
diff
changeset
|
6311 * When "flags" has OPT_ONECOLUMN do everything in 3. |
7 | 6312 */ |
26400
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26392
diff
changeset
|
6313 for (run = (flags & OPT_ONECOLUMN) ? 3 : 1; run <= 3 && !got_int; ++run) |
7 | 6314 { |
6315 /* | |
6316 * collect the items in items[] | |
6317 */ | |
6318 item_count = 0; | |
6319 for (i = 0; i < tc_len; i++) | |
6320 { | |
6321 len = show_one_termcode(termcodes[i].name, | |
6322 termcodes[i].code, FALSE); | |
26400
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26392
diff
changeset
|
6323 if ((flags & OPT_ONECOLUMN) || |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26392
diff
changeset
|
6324 (len <= INC3 - GAP ? run == 1 |
180 | 6325 : len <= INC2 - GAP ? run == 2 |
26400
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26392
diff
changeset
|
6326 : run == 3)) |
7 | 6327 items[item_count++] = i; |
6328 } | |
6329 | |
6330 /* | |
6331 * display the items | |
6332 */ | |
180 | 6333 if (run <= 2) |
7 | 6334 { |
180 | 6335 cols = (Columns + GAP) / (run == 1 ? INC3 : INC2); |
7 | 6336 if (cols == 0) |
6337 cols = 1; | |
6338 rows = (item_count + cols - 1) / cols; | |
6339 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6340 else // run == 3 |
7 | 6341 rows = item_count; |
6342 for (row = 0; row < rows && !got_int; ++row) | |
6343 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6344 msg_putchar('\n'); // go to next line |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6345 if (got_int) // 'q' typed in more |
7 | 6346 break; |
6347 col = 0; | |
6348 for (i = row; i < item_count; i += rows) | |
6349 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6350 msg_col = col; // make columns |
7 | 6351 show_one_termcode(termcodes[items[i]].name, |
6352 termcodes[items[i]].code, TRUE); | |
180 | 6353 if (run == 2) |
6354 col += INC2; | |
6355 else | |
6356 col += INC3; | |
7 | 6357 } |
6358 out_flush(); | |
6359 ui_breakcheck(); | |
6360 } | |
6361 } | |
6362 vim_free(items); | |
6363 } | |
6364 | |
6365 /* | |
6366 * Show one termcode entry. | |
6367 * Output goes into IObuff[] | |
6368 */ | |
6369 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6370 show_one_termcode(char_u *name, char_u *code, int printit) |
7 | 6371 { |
6372 char_u *p; | |
6373 int len; | |
6374 | |
6375 if (name[0] > '~') | |
6376 { | |
6377 IObuff[0] = ' '; | |
6378 IObuff[1] = ' '; | |
6379 IObuff[2] = ' '; | |
6380 IObuff[3] = ' '; | |
6381 } | |
6382 else | |
6383 { | |
6384 IObuff[0] = 't'; | |
6385 IObuff[1] = '_'; | |
6386 IObuff[2] = name[0]; | |
6387 IObuff[3] = name[1]; | |
6388 } | |
6389 IObuff[4] = ' '; | |
6390 | |
6391 p = get_special_key_name(TERMCAP2KEY(name[0], name[1]), 0); | |
6392 if (p[1] != 't') | |
6393 STRCPY(IObuff + 5, p); | |
6394 else | |
6395 IObuff[5] = NUL; | |
6396 len = (int)STRLEN(IObuff); | |
6397 do | |
6398 IObuff[len++] = ' '; | |
6399 while (len < 17); | |
6400 IObuff[len] = NUL; | |
6401 if (code == NULL) | |
6402 len += 4; | |
6403 else | |
6404 len += vim_strsize(code); | |
6405 | |
6406 if (printit) | |
6407 { | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6408 msg_puts((char *)IObuff); |
7 | 6409 if (code == NULL) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6410 msg_puts("NULL"); |
7 | 6411 else |
6412 msg_outtrans(code); | |
6413 } | |
6414 return len; | |
6415 } | |
6416 | |
6417 #if defined(FEAT_TERMRESPONSE) || defined(PROTO) | |
6418 /* | |
6419 * For Xterm >= 140 compiled with OPT_TCAP_QUERY: Obtain the actually used | |
6420 * termcap codes from the terminal itself. | |
6421 * We get them one by one to avoid a very long response string. | |
6422 */ | |
6102 | 6423 static int xt_index_in = 0; |
6424 static int xt_index_out = 0; | |
6425 | |
7 | 6426 static void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6427 req_codes_from_term(void) |
7 | 6428 { |
6429 xt_index_out = 0; | |
6430 xt_index_in = 0; | |
6431 req_more_codes_from_term(); | |
6432 } | |
6433 | |
6434 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6435 req_more_codes_from_term(void) |
7 | 6436 { |
28013
dbf6d5ea7a1f
patch 8.2.4531: LGTM warnings for condition and buffer size
Bram Moolenaar <Bram@vim.org>
parents:
27996
diff
changeset
|
6437 char buf[23]; // extra size to shut up LGTM |
7 | 6438 int old_idx = xt_index_out; |
6439 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6440 // Don't do anything when going to exit. |
7 | 6441 if (exiting) |
6442 return; | |
6443 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6444 // Send up to 10 more requests out than we received. Avoid sending too |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6445 // many, there can be a buffer overflow somewhere. |
7 | 6446 while (xt_index_out < xt_index_in + 10 && key_names[xt_index_out] != NULL) |
6447 { | |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6448 char *key_name = key_names[xt_index_out]; |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6449 |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
6450 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
6451 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
6452 #endif |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6453 LOG_TR(("Requesting XT %d: %s", xt_index_out, key_name)); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6454 sprintf(buf, "\033P+q%02x%02x\033\\", key_name[0], key_name[1]); |
7 | 6455 out_str_nf((char_u *)buf); |
6456 ++xt_index_out; | |
6457 } | |
6458 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6459 // Send the codes out right away. |
7 | 6460 if (xt_index_out != old_idx) |
6461 out_flush(); | |
6462 } | |
6463 | |
6464 /* | |
6465 * Decode key code response from xterm: '<Esc>P1+r<name>=<string><Esc>\'. | |
6466 * A "0" instead of the "1" indicates a code that isn't supported. | |
6467 * Both <name> and <string> are encoded in hex. | |
6468 * "code" points to the "0" or "1". | |
6469 */ | |
6470 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6471 got_code_from_term(char_u *code, int len) |
7 | 6472 { |
6473 #define XT_LEN 100 | |
6474 char_u name[3]; | |
6475 char_u str[XT_LEN]; | |
6476 int i; | |
6477 int j = 0; | |
6478 int c; | |
6479 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6480 // A '1' means the code is supported, a '0' means it isn't. |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6481 // When half the length is > XT_LEN we can't use it. |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6482 // Our names are currently all 2 characters. |
7 | 6483 if (code[0] == '1' && code[7] == '=' && len / 2 < XT_LEN) |
6484 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6485 // Get the name from the response and find it in the table. |
7 | 6486 name[0] = hexhex2nr(code + 3); |
6487 name[1] = hexhex2nr(code + 5); | |
6488 name[2] = NUL; | |
6489 for (i = 0; key_names[i] != NULL; ++i) | |
6490 { | |
6491 if (STRCMP(key_names[i], name) == 0) | |
6492 { | |
6493 xt_index_in = i; | |
6494 break; | |
6495 } | |
6496 } | |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6497 |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6498 LOG_TR(("Received XT %d: %s", xt_index_in, (char *)name)); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6499 |
7 | 6500 if (key_names[i] != NULL) |
6501 { | |
6502 for (i = 8; (c = hexhex2nr(code + i)) >= 0; i += 2) | |
6503 str[j++] = c; | |
6504 str[j] = NUL; | |
6505 if (name[0] == 'C' && name[1] == 'o') | |
6506 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6507 // Color count is not a key code. |
26670
a77b661439f9
patch 8.2.3864: cannot disable requesting key codes from xterm
Bram Moolenaar <Bram@vim.org>
parents:
26439
diff
changeset
|
6508 may_adjust_color_count(atoi((char *)str)); |
7 | 6509 } |
6510 else | |
6511 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6512 // First delete any existing entry with the same code. |
7 | 6513 i = find_term_bykeys(str); |
6514 if (i >= 0) | |
6515 del_termcode_idx(i); | |
180 | 6516 add_termcode(name, str, ATC_FROM_TERM); |
7 | 6517 } |
6518 } | |
6519 } | |
6520 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6521 // May request more codes now that we received one. |
7 | 6522 ++xt_index_in; |
6523 req_more_codes_from_term(); | |
6524 } | |
6525 | |
6526 /* | |
6527 * Check if there are any unanswered requests and deal with them. | |
6528 * This is called before starting an external program or getting direct | |
6529 * keyboard input. We don't want responses to be send to that program or | |
6530 * handled as typed text. | |
6531 */ | |
6532 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6533 check_for_codes_from_term(void) |
7 | 6534 { |
6535 int c; | |
6536 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6537 // If no codes requested or all are answered, no need to wait. |
7 | 6538 if (xt_index_out == 0 || xt_index_out == xt_index_in) |
6539 return; | |
6540 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6541 // Vgetc() will check for and handle any response. |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6542 // Keep calling vpeekc() until we don't get any responses. |
7 | 6543 ++no_mapping; |
6544 ++allow_keys; | |
6545 for (;;) | |
6546 { | |
6547 c = vpeekc(); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6548 if (c == NUL) // nothing available |
7 | 6549 break; |
6550 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6551 // If a response is recognized it's replaced with K_IGNORE, must read |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6552 // it from the input stream. If there is no K_IGNORE we can't do |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6553 // anything, break here (there might be some responses further on, but |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6554 // we don't want to throw away any typed chars). |
7 | 6555 if (c != K_SPECIAL && c != K_IGNORE) |
6556 break; | |
6557 c = vgetc(); | |
6558 if (c != K_IGNORE) | |
6559 { | |
6560 vungetc(c); | |
6561 break; | |
6562 } | |
6563 } | |
6564 --no_mapping; | |
6565 --allow_keys; | |
6566 } | |
6567 #endif | |
6568 | |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
6569 #if (defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL))) || defined(PROTO) |
7 | 6570 static char ksme_str[20]; |
6571 static char ksmr_str[20]; | |
6572 static char ksmd_str[20]; | |
6573 | |
6574 /* | |
6575 * For Win32 console: update termcap codes for existing console attributes. | |
6576 */ | |
6577 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6578 update_tcap(int attr) |
7 | 6579 { |
6580 struct builtin_term *p; | |
6581 | |
6582 p = find_builtin_term(DEFAULT_TERM); | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
6583 sprintf(ksme_str, "\033|%dm", attr); |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
6584 sprintf(ksmd_str, "\033|%dm", attr | 0x08); // FOREGROUND_INTENSITY |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
6585 sprintf(ksmr_str, "\033|%dm", ((attr & 0x0F) << 4) | ((attr & 0xF0) >> 4)); |
7 | 6586 |
6587 while (p->bt_string != NULL) | |
6588 { | |
6589 if (p->bt_entry == (int)KS_ME) | |
6590 p->bt_string = &ksme_str[0]; | |
6591 else if (p->bt_entry == (int)KS_MR) | |
6592 p->bt_string = &ksmr_str[0]; | |
6593 else if (p->bt_entry == (int)KS_MD) | |
6594 p->bt_string = &ksmd_str[0]; | |
6595 ++p; | |
6596 } | |
6597 } | |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6598 |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6599 # ifdef FEAT_TERMGUICOLORS |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6600 # define KSSIZE 20 |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6601 struct ks_tbl_s |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6602 { |
14806
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6603 int code; // value of KS_ |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6604 char *vtp; // code in vtp mode |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6605 char *vtp2; // code in vtp2 mode |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6606 char buf[KSSIZE]; // save buffer in non-vtp mode |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6607 char vbuf[KSSIZE]; // save buffer in vtp mode |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6608 char v2buf[KSSIZE]; // save buffer in vtp2 mode |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6609 char arr[KSSIZE]; // real buffer |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6610 }; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6611 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6612 static struct ks_tbl_s ks_tbl[] = |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6613 { |
14806
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6614 {(int)KS_ME, "\033|0m", "\033|0m"}, // normal |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6615 {(int)KS_MR, "\033|7m", "\033|7m"}, // reverse |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6616 {(int)KS_MD, "\033|1m", "\033|1m"}, // bold |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6617 {(int)KS_SO, "\033|91m", "\033|91m"}, // standout: bright red text |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6618 {(int)KS_SE, "\033|39m", "\033|39m"}, // standout end: default color |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6619 {(int)KS_CZH, "\033|95m", "\033|95m"}, // italic: bright magenta text |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6620 {(int)KS_CZR, "\033|0m", "\033|0m"}, // italic end |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6621 {(int)KS_US, "\033|4m", "\033|4m"}, // underscore |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6622 {(int)KS_UE, "\033|24m", "\033|24m"}, // underscore end |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6623 # ifdef TERMINFO |
14806
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6624 {(int)KS_CAB, "\033|%p1%db", "\033|%p14%dm"}, // set background color |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6625 {(int)KS_CAF, "\033|%p1%df", "\033|%p13%dm"}, // set foreground color |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
6626 {(int)KS_CS, "\033|%p1%d;%p2%dR", "\033|%p1%d;%p2%dR"}, |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
6627 {(int)KS_CSV, "\033|%p1%d;%p2%dV", "\033|%p1%d;%p2%dV"}, |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6628 # else |
14806
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6629 {(int)KS_CAB, "\033|%db", "\033|4%dm"}, // set background color |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6630 {(int)KS_CAF, "\033|%df", "\033|3%dm"}, // set foreground color |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
6631 {(int)KS_CS, "\033|%d;%dR", "\033|%d;%dR"}, |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
6632 {(int)KS_CSV, "\033|%d;%dV", "\033|%d;%dV"}, |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6633 # endif |
14806
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6634 {(int)KS_CCO, "256", "256"}, // colors |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6635 {(int)KS_NAME} // terminator |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6636 }; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6637 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6638 static struct builtin_term * |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6639 find_first_tcap( |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6640 char_u *name, |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6641 int code) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6642 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6643 struct builtin_term *p; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6644 |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6645 for (p = find_builtin_term(name); p->bt_string != NULL; ++p) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6646 if (p->bt_entry == code) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6647 return p; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6648 return NULL; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6649 } |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6650 # endif |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6651 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6652 /* |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6653 * For Win32 console: replace the sequence immediately after termguicolors. |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6654 */ |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6655 void |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6656 swap_tcap(void) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6657 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6658 # ifdef FEAT_TERMGUICOLORS |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6659 static int init_done = FALSE; |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6660 static int curr_mode; |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6661 struct ks_tbl_s *ks; |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6662 struct builtin_term *bt; |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6663 int mode; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6664 enum |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6665 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6666 CMODEINDEX, |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6667 CMODE24, |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6668 CMODE256 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6669 }; |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6670 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6671 // buffer initialization |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6672 if (!init_done) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6673 { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6674 for (ks = ks_tbl; ks->code != (int)KS_NAME; ks++) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6675 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6676 bt = find_first_tcap(DEFAULT_TERM, ks->code); |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6677 if (bt != NULL) |
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6678 { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6679 STRNCPY(ks->buf, bt->bt_string, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6680 STRNCPY(ks->vbuf, ks->vtp, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6681 STRNCPY(ks->v2buf, ks->vtp2, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6682 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6683 STRNCPY(ks->arr, bt->bt_string, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6684 bt->bt_string = &ks->arr[0]; |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6685 } |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6686 } |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6687 init_done = TRUE; |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6688 curr_mode = CMODEINDEX; |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6689 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6690 |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6691 if (p_tgc) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6692 mode = CMODE24; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6693 else if (t_colors >= 256) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6694 mode = CMODE256; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6695 else |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6696 mode = CMODEINDEX; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6697 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6698 for (ks = ks_tbl; ks->code != (int)KS_NAME; ks++) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6699 { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6700 bt = find_first_tcap(DEFAULT_TERM, ks->code); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6701 if (bt != NULL) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6702 { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6703 switch (curr_mode) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6704 { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6705 case CMODEINDEX: |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6706 STRNCPY(&ks->buf[0], bt->bt_string, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6707 break; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6708 case CMODE24: |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6709 STRNCPY(&ks->vbuf[0], bt->bt_string, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6710 break; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6711 default: |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6712 STRNCPY(&ks->v2buf[0], bt->bt_string, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6713 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6714 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6715 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6716 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6717 if (mode != curr_mode) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6718 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6719 for (ks = ks_tbl; ks->code != (int)KS_NAME; ks++) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6720 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6721 bt = find_first_tcap(DEFAULT_TERM, ks->code); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6722 if (bt != NULL) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6723 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6724 switch (mode) |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6725 { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6726 case CMODEINDEX: |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6727 STRNCPY(bt->bt_string, &ks->buf[0], KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6728 break; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6729 case CMODE24: |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6730 STRNCPY(bt->bt_string, &ks->vbuf[0], KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6731 break; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6732 default: |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6733 STRNCPY(bt->bt_string, &ks->v2buf[0], KSSIZE); |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6734 } |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6735 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6736 } |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6737 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6738 curr_mode = mode; |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6739 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6740 # endif |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6741 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6742 |
7 | 6743 #endif |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6744 |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6745 |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
6746 #if (defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))) || defined(FEAT_TERMINAL) \ |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6747 || defined(PROTO) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6748 static int cube_value[] = { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6749 0x00, 0x5F, 0x87, 0xAF, 0xD7, 0xFF |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6750 }; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6751 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6752 static int grey_ramp[] = { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6753 0x08, 0x12, 0x1C, 0x26, 0x30, 0x3A, 0x44, 0x4E, 0x58, 0x62, 0x6C, 0x76, |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6754 0x80, 0x8A, 0x94, 0x9E, 0xA8, 0xB2, 0xBC, 0xC6, 0xD0, 0xDA, 0xE4, 0xEE |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6755 }; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6756 |
13839
ca8953d36264
patch 8.0.1791: using uint8_t does not work everywhere
Christian Brabandt <cb@256bit.org>
parents:
13827
diff
changeset
|
6757 static char_u ansi_table[16][4] = { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6758 // R G B idx |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6759 { 0, 0, 0, 1}, // black |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6760 {224, 0, 0, 2}, // dark red |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6761 { 0, 224, 0, 3}, // dark green |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6762 {224, 224, 0, 4}, // dark yellow / brown |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6763 { 0, 0, 224, 5}, // dark blue |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6764 {224, 0, 224, 6}, // dark magenta |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6765 { 0, 224, 224, 7}, // dark cyan |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6766 {224, 224, 224, 8}, // light grey |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6767 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6768 {128, 128, 128, 9}, // dark grey |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6769 {255, 64, 64, 10}, // light red |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6770 { 64, 255, 64, 11}, // light green |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6771 {255, 255, 64, 12}, // yellow |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6772 { 64, 64, 255, 13}, // light blue |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6773 {255, 64, 255, 14}, // light magenta |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6774 { 64, 255, 255, 15}, // light cyan |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6775 {255, 255, 255, 16}, // white |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6776 }; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6777 |
20500
03826c672315
patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20450
diff
changeset
|
6778 #define ANSI_INDEX_NONE 0 |
03826c672315
patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20450
diff
changeset
|
6779 |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6780 void |
13839
ca8953d36264
patch 8.0.1791: using uint8_t does not work everywhere
Christian Brabandt <cb@256bit.org>
parents:
13827
diff
changeset
|
6781 cterm_color2rgb(int nr, char_u *r, char_u *g, char_u *b, char_u *ansi_idx) |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6782 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6783 int idx; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6784 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6785 if (nr < 16) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6786 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6787 *r = ansi_table[nr][0]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6788 *g = ansi_table[nr][1]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6789 *b = ansi_table[nr][2]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6790 *ansi_idx = ansi_table[nr][3]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6791 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6792 else if (nr < 232) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6793 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6794 // 216 color cube |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6795 idx = nr - 16; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6796 *r = cube_value[idx / 36 % 6]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6797 *g = cube_value[idx / 6 % 6]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6798 *b = cube_value[idx % 6]; |
20500
03826c672315
patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20450
diff
changeset
|
6799 *ansi_idx = ANSI_INDEX_NONE; |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6800 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6801 else if (nr < 256) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6802 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6803 // 24 grey scale ramp |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6804 idx = nr - 232; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6805 *r = grey_ramp[idx]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6806 *g = grey_ramp[idx]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6807 *b = grey_ramp[idx]; |
20500
03826c672315
patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20450
diff
changeset
|
6808 *ansi_idx = ANSI_INDEX_NONE; |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6809 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6810 else |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6811 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6812 *r = 0; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6813 *g = 0; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6814 *b = 0; |
20500
03826c672315
patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20450
diff
changeset
|
6815 *ansi_idx = ANSI_INDEX_NONE; |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6816 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6817 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6818 #endif |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15852
diff
changeset
|
6819 |
19405
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6820 /* |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6821 * Replace K_BS by <BS> and K_DEL by <DEL> |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6822 */ |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6823 void |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6824 term_replace_bs_del_keycode(char_u *ta_buf, int ta_len, int len) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6825 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6826 int i; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6827 int c; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6828 |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6829 for (i = ta_len; i < ta_len + len; ++i) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6830 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6831 if (ta_buf[i] == CSI && len - i > 2) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6832 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6833 c = TERMCAP2KEY(ta_buf[i + 1], ta_buf[i + 2]); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6834 if (c == K_DEL || c == K_KDEL || c == K_BS) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6835 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6836 mch_memmove(ta_buf + i + 1, ta_buf + i + 3, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6837 (size_t)(len - i - 2)); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6838 if (c == K_DEL || c == K_KDEL) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6839 ta_buf[i] = DEL; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6840 else |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6841 ta_buf[i] = Ctrl_H; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6842 len -= 2; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6843 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6844 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6845 else if (ta_buf[i] == '\r') |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6846 ta_buf[i] = '\n'; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6847 if (has_mbyte) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6848 i += (*mb_ptr2len_len)(ta_buf + i, ta_len + len - i) - 1; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6849 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6850 } |