Mercurial > vim
annotate src/term.c @ 11615:568ea579d20e v8.0.0690
patch 8.0.0690: compiler warning on non-Unix system
commit https://github.com/vim/vim/commit/c2226845eb207bcd1a24e1afa941acbfecbc5170
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jun 29 22:27:24 2017 +0200
patch 8.0.0690: compiler warning on non-Unix system
Problem: Compiler warning on non-Unix system.
Solution: Add #ifdef. (John Marriott)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 29 Jun 2017 22:30:04 +0200 |
parents | 0a5d405e2520 |
children | d06f3576823a |
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 | |
25 #define tgetstr tgetstr_defined_wrong | |
26 #include "vim.h" | |
27 | |
28 #ifdef HAVE_TGETENT | |
29 # ifdef HAVE_TERMIOS_H | |
30 # include <termios.h> /* seems to be required for some Linux */ | |
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 */ | |
40 # ifdef VMS | |
41 # define TPUTSFUNCAST | |
42 # else | |
43 # ifdef HAVE_OUTFUNTYPE | |
44 # define TPUTSFUNCAST (outfuntype) | |
45 # else | |
46 # define TPUTSFUNCAST (int (*)()) | |
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 | |
74 /* start of keys that are not directly used by Vim but can be mapped */ | |
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 struct builtin_term *find_builtin_term(char_u *name); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
78 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
|
79 static void term_color(char_u *s, int n); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
80 static void gather_termleader(void); |
7 | 81 #ifdef FEAT_TERMRESPONSE |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
82 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
|
83 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
|
84 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
|
85 static void check_for_codes_from_term(void); |
7 | 86 #endif |
87 #if defined(FEAT_GUI) \ | |
1623 | 88 || (defined(FEAT_MOUSE) && (!defined(UNIX) || defined(FEAT_MOUSE_XTERM) \ |
89 || defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE))) | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
90 static int get_bytes_from_buf(char_u *, char_u *, int); |
7 | 91 #endif |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
92 static void del_termcode_idx(int idx); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
93 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
|
94 static int term_7to8bit(char_u *p); |
7 | 95 #ifdef FEAT_TERMRESPONSE |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
96 static void switch_to_8bit(void); |
7 | 97 #endif |
98 | |
99 #ifdef HAVE_TGETENT | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
100 static char_u *tgetent_error(char_u *, char_u *); |
7 | 101 |
102 /* | |
103 * Here is our own prototype for tgetstr(), any prototypes from the include | |
104 * files have been disabled by the define at the start of this file. | |
105 */ | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
106 char *tgetstr(char *, char **); |
7 | 107 |
108 # ifdef FEAT_TERMRESPONSE | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
109 /* Change this to "if 1" to debug what happens with termresponse. */ |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
110 # if 0 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
111 # define DEBUG_TERMRESPONSE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
112 static void log_tr(char *msg); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
113 # define LOG_TR(msg) log_tr(msg) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
114 # else |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
115 # define LOG_TR(msg) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
116 # endif |
7 | 117 /* Request Terminal Version status: */ |
118 # define CRV_GET 1 /* send T_CRV when switched to RAW mode */ | |
119 # define CRV_SENT 2 /* did send T_CRV, waiting for answer */ | |
120 # define CRV_GOT 3 /* received T_CRV response */ | |
121 static int crv_status = CRV_GET; | |
4215 | 122 /* Request Cursor position report: */ |
123 # define U7_GET 1 /* send T_U7 when switched to RAW mode */ | |
124 # define U7_SENT 2 /* did send T_U7, waiting for answer */ | |
125 # define U7_GOT 3 /* received T_U7 response */ | |
126 static int u7_status = U7_GET; | |
6874 | 127 /* Request background color report: */ |
128 # define RBG_GET 1 /* send T_RBG when switched to RAW mode */ | |
129 # define RBG_SENT 2 /* did send T_RBG, waiting for answer */ | |
130 # define RBG_GOT 3 /* received T_RBG response */ | |
131 static int rbg_status = RBG_GET; | |
7 | 132 # endif |
133 | |
134 /* | |
135 * Don't declare these variables if termcap.h contains them. | |
136 * Autoconf checks if these variables should be declared extern (not all | |
137 * systems have them). | |
138 * Some versions define ospeed to be speed_t, but that is incompatible with | |
139 * BSD, where ospeed is short and speed_t is long. | |
140 */ | |
141 # ifndef HAVE_OSPEED | |
142 # ifdef OSPEED_EXTERN | |
143 extern short ospeed; | |
144 # else | |
145 short ospeed; | |
146 # endif | |
147 # endif | |
148 # ifndef HAVE_UP_BC_PC | |
149 # ifdef UP_BC_PC_EXTERN | |
150 extern char *UP, *BC, PC; | |
151 # else | |
152 char *UP, *BC, PC; | |
153 # endif | |
154 # endif | |
155 | |
156 # define TGETSTR(s, p) vim_tgetstr((s), (p)) | |
157 # 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
|
158 static char_u *vim_tgetstr(char *s, char_u **pp); |
7 | 159 #endif /* HAVE_TGETENT */ |
160 | |
161 static int detected_8bit = FALSE; /* detected 8-bit terminal */ | |
162 | |
298 | 163 static struct builtin_term builtin_termcaps[] = |
7 | 164 { |
165 | |
166 #if defined(FEAT_GUI) | |
167 /* | |
168 * GUI pseudo term-cap. | |
169 */ | |
170 {(int)KS_NAME, "gui"}, | |
171 {(int)KS_CE, IF_EB("\033|$", ESC_STR "|$")}, | |
172 {(int)KS_AL, IF_EB("\033|i", ESC_STR "|i")}, | |
173 # ifdef TERMINFO | |
174 {(int)KS_CAL, IF_EB("\033|%p1%dI", ESC_STR "|%p1%dI")}, | |
175 # else | |
176 {(int)KS_CAL, IF_EB("\033|%dI", ESC_STR "|%dI")}, | |
177 # endif | |
178 {(int)KS_DL, IF_EB("\033|d", ESC_STR "|d")}, | |
179 # ifdef TERMINFO | |
180 {(int)KS_CDL, IF_EB("\033|%p1%dD", ESC_STR "|%p1%dD")}, | |
181 {(int)KS_CS, IF_EB("\033|%p1%d;%p2%dR", ESC_STR "|%p1%d;%p2%dR")}, | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
182 # ifdef FEAT_WINDOWS |
7 | 183 {(int)KS_CSV, IF_EB("\033|%p1%d;%p2%dV", ESC_STR "|%p1%d;%p2%dV")}, |
184 # endif | |
185 # else | |
186 {(int)KS_CDL, IF_EB("\033|%dD", ESC_STR "|%dD")}, | |
187 {(int)KS_CS, IF_EB("\033|%d;%dR", ESC_STR "|%d;%dR")}, | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
188 # ifdef FEAT_WINDOWS |
7 | 189 {(int)KS_CSV, IF_EB("\033|%d;%dV", ESC_STR "|%d;%dV")}, |
190 # endif | |
191 # endif | |
192 {(int)KS_CL, IF_EB("\033|C", ESC_STR "|C")}, | |
193 /* attributes switched on with 'h', off with * 'H' */ | |
194 {(int)KS_ME, IF_EB("\033|31H", ESC_STR "|31H")}, /* HL_ALL */ | |
195 {(int)KS_MR, IF_EB("\033|1h", ESC_STR "|1h")}, /* HL_INVERSE */ | |
196 {(int)KS_MD, IF_EB("\033|2h", ESC_STR "|2h")}, /* HL_BOLD */ | |
197 {(int)KS_SE, IF_EB("\033|16H", ESC_STR "|16H")}, /* HL_STANDOUT */ | |
198 {(int)KS_SO, IF_EB("\033|16h", ESC_STR "|16h")}, /* HL_STANDOUT */ | |
199 {(int)KS_UE, IF_EB("\033|8H", ESC_STR "|8H")}, /* HL_UNDERLINE */ | |
200 {(int)KS_US, IF_EB("\033|8h", ESC_STR "|8h")}, /* HL_UNDERLINE */ | |
205 | 201 {(int)KS_UCE, IF_EB("\033|8C", ESC_STR "|8C")}, /* HL_UNDERCURL */ |
202 {(int)KS_UCS, IF_EB("\033|8c", ESC_STR "|8c")}, /* HL_UNDERCURL */ | |
7 | 203 {(int)KS_CZR, IF_EB("\033|4H", ESC_STR "|4H")}, /* HL_ITALIC */ |
204 {(int)KS_CZH, IF_EB("\033|4h", ESC_STR "|4h")}, /* HL_ITALIC */ | |
205 {(int)KS_VB, IF_EB("\033|f", ESC_STR "|f")}, | |
206 {(int)KS_MS, "y"}, | |
207 {(int)KS_UT, "y"}, | |
6602 | 208 {(int)KS_XN, "y"}, |
7 | 209 {(int)KS_LE, "\b"}, /* cursor-left = BS */ |
210 {(int)KS_ND, "\014"}, /* cursor-right = CTRL-L */ | |
211 # ifdef TERMINFO | |
212 {(int)KS_CM, IF_EB("\033|%p1%d;%p2%dM", ESC_STR "|%p1%d;%p2%dM")}, | |
213 # else | |
214 {(int)KS_CM, IF_EB("\033|%d;%dM", ESC_STR "|%d;%dM")}, | |
215 # endif | |
216 /* there are no key sequences here, the GUI sequences are recognized | |
205 | 217 * in check_termcode() */ |
7 | 218 #endif |
219 | |
220 #ifndef NO_BUILTIN_TCAPS | |
221 | |
222 # if defined(AMIGA) || defined(ALL_BUILTIN_TCAPS) | |
223 /* | |
224 * Amiga console window, default for Amiga | |
225 */ | |
226 {(int)KS_NAME, "amiga"}, | |
227 {(int)KS_CE, "\033[K"}, | |
228 {(int)KS_CD, "\033[J"}, | |
229 {(int)KS_AL, "\033[L"}, | |
230 # ifdef TERMINFO | |
231 {(int)KS_CAL, "\033[%p1%dL"}, | |
232 # else | |
233 {(int)KS_CAL, "\033[%dL"}, | |
234 # endif | |
235 {(int)KS_DL, "\033[M"}, | |
236 # ifdef TERMINFO | |
237 {(int)KS_CDL, "\033[%p1%dM"}, | |
238 # else | |
239 {(int)KS_CDL, "\033[%dM"}, | |
240 # endif | |
241 {(int)KS_CL, "\014"}, | |
242 {(int)KS_VI, "\033[0 p"}, | |
243 {(int)KS_VE, "\033[1 p"}, | |
244 {(int)KS_ME, "\033[0m"}, | |
245 {(int)KS_MR, "\033[7m"}, | |
246 {(int)KS_MD, "\033[1m"}, | |
247 {(int)KS_SE, "\033[0m"}, | |
248 {(int)KS_SO, "\033[33m"}, | |
249 {(int)KS_US, "\033[4m"}, | |
250 {(int)KS_UE, "\033[0m"}, | |
251 {(int)KS_CZH, "\033[3m"}, | |
252 {(int)KS_CZR, "\033[0m"}, | |
253 #if defined(__MORPHOS__) || defined(__AROS__) | |
254 {(int)KS_CCO, "8"}, /* allow 8 colors */ | |
255 # ifdef TERMINFO | |
256 {(int)KS_CAB, "\033[4%p1%dm"},/* set background color */ | |
257 {(int)KS_CAF, "\033[3%p1%dm"},/* set foreground color */ | |
258 # else | |
259 {(int)KS_CAB, "\033[4%dm"}, /* set background color */ | |
260 {(int)KS_CAF, "\033[3%dm"}, /* set foreground color */ | |
261 # endif | |
262 {(int)KS_OP, "\033[m"}, /* reset colors */ | |
263 #endif | |
264 {(int)KS_MS, "y"}, | |
265 {(int)KS_UT, "y"}, /* guessed */ | |
266 {(int)KS_LE, "\b"}, | |
267 # ifdef TERMINFO | |
268 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
269 # else | |
270 {(int)KS_CM, "\033[%i%d;%dH"}, | |
271 # endif | |
272 #if defined(__MORPHOS__) | |
273 {(int)KS_SR, "\033M"}, | |
274 #endif | |
275 # ifdef TERMINFO | |
276 {(int)KS_CRI, "\033[%p1%dC"}, | |
277 # else | |
278 {(int)KS_CRI, "\033[%dC"}, | |
279 # endif | |
280 {K_UP, "\233A"}, | |
281 {K_DOWN, "\233B"}, | |
282 {K_LEFT, "\233D"}, | |
283 {K_RIGHT, "\233C"}, | |
284 {K_S_UP, "\233T"}, | |
285 {K_S_DOWN, "\233S"}, | |
286 {K_S_LEFT, "\233 A"}, | |
287 {K_S_RIGHT, "\233 @"}, | |
288 {K_S_TAB, "\233Z"}, | |
289 {K_F1, "\233\060~"},/* some compilers don't dig "\2330" */ | |
290 {K_F2, "\233\061~"}, | |
291 {K_F3, "\233\062~"}, | |
292 {K_F4, "\233\063~"}, | |
293 {K_F5, "\233\064~"}, | |
294 {K_F6, "\233\065~"}, | |
295 {K_F7, "\233\066~"}, | |
296 {K_F8, "\233\067~"}, | |
297 {K_F9, "\233\070~"}, | |
298 {K_F10, "\233\071~"}, | |
299 {K_S_F1, "\233\061\060~"}, | |
300 {K_S_F2, "\233\061\061~"}, | |
301 {K_S_F3, "\233\061\062~"}, | |
302 {K_S_F4, "\233\061\063~"}, | |
303 {K_S_F5, "\233\061\064~"}, | |
304 {K_S_F6, "\233\061\065~"}, | |
305 {K_S_F7, "\233\061\066~"}, | |
306 {K_S_F8, "\233\061\067~"}, | |
307 {K_S_F9, "\233\061\070~"}, | |
308 {K_S_F10, "\233\061\071~"}, | |
309 {K_HELP, "\233?~"}, | |
310 {K_INS, "\233\064\060~"}, /* 101 key keyboard */ | |
311 {K_PAGEUP, "\233\064\061~"}, /* 101 key keyboard */ | |
312 {K_PAGEDOWN, "\233\064\062~"}, /* 101 key keyboard */ | |
313 {K_HOME, "\233\064\064~"}, /* 101 key keyboard */ | |
314 {K_END, "\233\064\065~"}, /* 101 key keyboard */ | |
315 | |
316 {BT_EXTRA_KEYS, ""}, | |
317 {TERMCAP2KEY('#', '2'), "\233\065\064~"}, /* shifted home key */ | |
318 {TERMCAP2KEY('#', '3'), "\233\065\060~"}, /* shifted insert key */ | |
319 {TERMCAP2KEY('*', '7'), "\233\065\065~"}, /* shifted end key */ | |
320 # endif | |
321 | |
322 # if defined(__BEOS__) || defined(ALL_BUILTIN_TCAPS) | |
323 /* | |
324 * almost standard ANSI terminal, default for bebox | |
325 */ | |
326 {(int)KS_NAME, "beos-ansi"}, | |
327 {(int)KS_CE, "\033[K"}, | |
328 {(int)KS_CD, "\033[J"}, | |
329 {(int)KS_AL, "\033[L"}, | |
330 # ifdef TERMINFO | |
331 {(int)KS_CAL, "\033[%p1%dL"}, | |
332 # else | |
333 {(int)KS_CAL, "\033[%dL"}, | |
334 # endif | |
335 {(int)KS_DL, "\033[M"}, | |
336 # ifdef TERMINFO | |
337 {(int)KS_CDL, "\033[%p1%dM"}, | |
338 # else | |
339 {(int)KS_CDL, "\033[%dM"}, | |
340 # endif | |
341 #ifdef BEOS_PR_OR_BETTER | |
342 # ifdef TERMINFO | |
343 {(int)KS_CS, "\033[%i%p1%d;%p2%dr"}, | |
344 # else | |
345 {(int)KS_CS, "\033[%i%d;%dr"}, /* scroll region */ | |
346 # endif | |
347 #endif | |
348 {(int)KS_CL, "\033[H\033[2J"}, | |
349 #ifdef notyet | |
350 {(int)KS_VI, "[VI]"}, /* cursor invisible, VT320: CSI ? 25 l */ | |
351 {(int)KS_VE, "[VE]"}, /* cursor visible, VT320: CSI ? 25 h */ | |
352 #endif | |
353 {(int)KS_ME, "\033[m"}, /* normal mode */ | |
354 {(int)KS_MR, "\033[7m"}, /* reverse */ | |
355 {(int)KS_MD, "\033[1m"}, /* bold */ | |
356 {(int)KS_SO, "\033[31m"}, /* standout mode: red */ | |
357 {(int)KS_SE, "\033[m"}, /* standout end */ | |
358 {(int)KS_CZH, "\033[35m"}, /* italic: purple */ | |
359 {(int)KS_CZR, "\033[m"}, /* italic end */ | |
360 {(int)KS_US, "\033[4m"}, /* underscore mode */ | |
361 {(int)KS_UE, "\033[m"}, /* underscore end */ | |
362 {(int)KS_CCO, "8"}, /* allow 8 colors */ | |
363 # ifdef TERMINFO | |
364 {(int)KS_CAB, "\033[4%p1%dm"},/* set background color */ | |
365 {(int)KS_CAF, "\033[3%p1%dm"},/* set foreground color */ | |
366 # else | |
367 {(int)KS_CAB, "\033[4%dm"}, /* set background color */ | |
368 {(int)KS_CAF, "\033[3%dm"}, /* set foreground color */ | |
369 # endif | |
370 {(int)KS_OP, "\033[m"}, /* reset colors */ | |
371 {(int)KS_MS, "y"}, /* safe to move cur in reverse mode */ | |
372 {(int)KS_UT, "y"}, /* guessed */ | |
373 {(int)KS_LE, "\b"}, | |
374 # ifdef TERMINFO | |
375 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
376 # else | |
377 {(int)KS_CM, "\033[%i%d;%dH"}, | |
378 # endif | |
379 {(int)KS_SR, "\033M"}, | |
380 # ifdef TERMINFO | |
381 {(int)KS_CRI, "\033[%p1%dC"}, | |
382 # else | |
383 {(int)KS_CRI, "\033[%dC"}, | |
384 # endif | |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
385 # if defined(BEOS_DR8) |
7 | 386 {(int)KS_DB, ""}, /* hack! see screen.c */ |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
387 # endif |
7 | 388 |
389 {K_UP, "\033[A"}, | |
390 {K_DOWN, "\033[B"}, | |
391 {K_LEFT, "\033[D"}, | |
392 {K_RIGHT, "\033[C"}, | |
393 # endif | |
394 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
395 # if defined(UNIX) || defined(ALL_BUILTIN_TCAPS) || defined(SOME_BUILTIN_TCAPS) |
7 | 396 /* |
397 * standard ANSI terminal, default for unix | |
398 */ | |
399 {(int)KS_NAME, "ansi"}, | |
400 {(int)KS_CE, IF_EB("\033[K", ESC_STR "[K")}, | |
401 {(int)KS_AL, IF_EB("\033[L", ESC_STR "[L")}, | |
402 # ifdef TERMINFO | |
403 {(int)KS_CAL, IF_EB("\033[%p1%dL", ESC_STR "[%p1%dL")}, | |
404 # else | |
405 {(int)KS_CAL, IF_EB("\033[%dL", ESC_STR "[%dL")}, | |
406 # endif | |
407 {(int)KS_DL, IF_EB("\033[M", ESC_STR "[M")}, | |
408 # ifdef TERMINFO | |
409 {(int)KS_CDL, IF_EB("\033[%p1%dM", ESC_STR "[%p1%dM")}, | |
410 # else | |
411 {(int)KS_CDL, IF_EB("\033[%dM", ESC_STR "[%dM")}, | |
412 # endif | |
413 {(int)KS_CL, IF_EB("\033[H\033[2J", ESC_STR "[H" ESC_STR_nc "[2J")}, | |
414 {(int)KS_ME, IF_EB("\033[0m", ESC_STR "[0m")}, | |
415 {(int)KS_MR, IF_EB("\033[7m", ESC_STR "[7m")}, | |
416 {(int)KS_MS, "y"}, | |
417 {(int)KS_UT, "y"}, /* guessed */ | |
418 {(int)KS_LE, "\b"}, | |
419 # ifdef TERMINFO | |
420 {(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", ESC_STR "[%i%p1%d;%p2%dH")}, | |
421 # else | |
422 {(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")}, | |
423 # endif | |
424 # ifdef TERMINFO | |
425 {(int)KS_CRI, IF_EB("\033[%p1%dC", ESC_STR "[%p1%dC")}, | |
426 # else | |
427 {(int)KS_CRI, IF_EB("\033[%dC", ESC_STR "[%dC")}, | |
428 # endif | |
429 # endif | |
430 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
431 # if defined(ALL_BUILTIN_TCAPS) |
7 | 432 /* |
433 * These codes are valid when nansi.sys or equivalent has been installed. | |
434 * Function keys on a PC are preceded with a NUL. These are converted into | |
435 * K_NUL '\316' in mch_inchar(), because we cannot handle NULs in key codes. | |
436 * CTRL-arrow is used instead of SHIFT-arrow. | |
437 */ | |
438 {(int)KS_NAME, "pcansi"}, | |
439 {(int)KS_DL, "\033[M"}, | |
440 {(int)KS_AL, "\033[L"}, | |
441 {(int)KS_CE, "\033[K"}, | |
442 {(int)KS_CL, "\033[2J"}, | |
443 {(int)KS_ME, "\033[0m"}, | |
444 {(int)KS_MR, "\033[5m"}, /* reverse: black on lightgrey */ | |
445 {(int)KS_MD, "\033[1m"}, /* bold: white text */ | |
446 {(int)KS_SE, "\033[0m"}, /* standout end */ | |
447 {(int)KS_SO, "\033[31m"}, /* standout: white on blue */ | |
448 {(int)KS_CZH, "\033[34;43m"}, /* italic mode: blue text on yellow */ | |
449 {(int)KS_CZR, "\033[0m"}, /* italic mode end */ | |
450 {(int)KS_US, "\033[36;41m"}, /* underscore mode: cyan text on red */ | |
451 {(int)KS_UE, "\033[0m"}, /* underscore mode end */ | |
452 {(int)KS_CCO, "8"}, /* allow 8 colors */ | |
453 # ifdef TERMINFO | |
454 {(int)KS_CAB, "\033[4%p1%dm"},/* set background color */ | |
455 {(int)KS_CAF, "\033[3%p1%dm"},/* set foreground color */ | |
456 # else | |
457 {(int)KS_CAB, "\033[4%dm"}, /* set background color */ | |
458 {(int)KS_CAF, "\033[3%dm"}, /* set foreground color */ | |
459 # endif | |
460 {(int)KS_OP, "\033[0m"}, /* reset colors */ | |
461 {(int)KS_MS, "y"}, | |
462 {(int)KS_UT, "y"}, /* guessed */ | |
463 {(int)KS_LE, "\b"}, | |
464 # ifdef TERMINFO | |
465 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
466 # else | |
467 {(int)KS_CM, "\033[%i%d;%dH"}, | |
468 # endif | |
469 # ifdef TERMINFO | |
470 {(int)KS_CRI, "\033[%p1%dC"}, | |
471 # else | |
472 {(int)KS_CRI, "\033[%dC"}, | |
473 # endif | |
474 {K_UP, "\316H"}, | |
475 {K_DOWN, "\316P"}, | |
476 {K_LEFT, "\316K"}, | |
477 {K_RIGHT, "\316M"}, | |
478 {K_S_LEFT, "\316s"}, | |
479 {K_S_RIGHT, "\316t"}, | |
480 {K_F1, "\316;"}, | |
481 {K_F2, "\316<"}, | |
482 {K_F3, "\316="}, | |
483 {K_F4, "\316>"}, | |
484 {K_F5, "\316?"}, | |
485 {K_F6, "\316@"}, | |
486 {K_F7, "\316A"}, | |
487 {K_F8, "\316B"}, | |
488 {K_F9, "\316C"}, | |
489 {K_F10, "\316D"}, | |
490 {K_F11, "\316\205"}, /* guessed */ | |
491 {K_F12, "\316\206"}, /* guessed */ | |
492 {K_S_F1, "\316T"}, | |
493 {K_S_F2, "\316U"}, | |
494 {K_S_F3, "\316V"}, | |
495 {K_S_F4, "\316W"}, | |
496 {K_S_F5, "\316X"}, | |
497 {K_S_F6, "\316Y"}, | |
498 {K_S_F7, "\316Z"}, | |
499 {K_S_F8, "\316["}, | |
500 {K_S_F9, "\316\\"}, | |
501 {K_S_F10, "\316]"}, | |
502 {K_S_F11, "\316\207"}, /* guessed */ | |
503 {K_S_F12, "\316\210"}, /* guessed */ | |
504 {K_INS, "\316R"}, | |
505 {K_DEL, "\316S"}, | |
506 {K_HOME, "\316G"}, | |
507 {K_END, "\316O"}, | |
508 {K_PAGEDOWN, "\316Q"}, | |
509 {K_PAGEUP, "\316I"}, | |
510 # endif | |
511 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
512 # if defined(WIN3264) || defined(ALL_BUILTIN_TCAPS) |
7 | 513 /* |
514 * These codes are valid for the Win32 Console . The entries that start with | |
515 * ESC | are translated into console calls in os_win32.c. The function keys | |
516 * are also translated in os_win32.c. | |
517 */ | |
518 {(int)KS_NAME, "win32"}, | |
519 {(int)KS_CE, "\033|K"}, /* clear to end of line */ | |
520 {(int)KS_AL, "\033|L"}, /* add new blank line */ | |
521 # ifdef TERMINFO | |
522 {(int)KS_CAL, "\033|%p1%dL"}, /* add number of new blank lines */ | |
523 # else | |
524 {(int)KS_CAL, "\033|%dL"}, /* add number of new blank lines */ | |
525 # endif | |
526 {(int)KS_DL, "\033|M"}, /* delete line */ | |
527 # ifdef TERMINFO | |
528 {(int)KS_CDL, "\033|%p1%dM"}, /* delete number of lines */ | |
529 # else | |
530 {(int)KS_CDL, "\033|%dM"}, /* delete number of lines */ | |
531 # endif | |
532 {(int)KS_CL, "\033|J"}, /* clear screen */ | |
533 {(int)KS_CD, "\033|j"}, /* clear to end of display */ | |
534 {(int)KS_VI, "\033|v"}, /* cursor invisible */ | |
535 {(int)KS_VE, "\033|V"}, /* cursor visible */ | |
536 | |
537 {(int)KS_ME, "\033|0m"}, /* normal */ | |
538 {(int)KS_MR, "\033|112m"}, /* reverse: black on lightgray */ | |
539 {(int)KS_MD, "\033|15m"}, /* bold: white on black */ | |
540 #if 1 | |
541 {(int)KS_SO, "\033|31m"}, /* standout: white on blue */ | |
542 {(int)KS_SE, "\033|0m"}, /* standout end */ | |
543 #else | |
544 {(int)KS_SO, "\033|F"}, /* standout: high intensity */ | |
545 {(int)KS_SE, "\033|f"}, /* standout end */ | |
546 #endif | |
547 {(int)KS_CZH, "\033|225m"}, /* italic: blue text on yellow */ | |
548 {(int)KS_CZR, "\033|0m"}, /* italic end */ | |
549 {(int)KS_US, "\033|67m"}, /* underscore: cyan text on red */ | |
550 {(int)KS_UE, "\033|0m"}, /* underscore end */ | |
551 {(int)KS_CCO, "16"}, /* allow 16 colors */ | |
552 # ifdef TERMINFO | |
553 {(int)KS_CAB, "\033|%p1%db"}, /* set background color */ | |
554 {(int)KS_CAF, "\033|%p1%df"}, /* set foreground color */ | |
555 # else | |
556 {(int)KS_CAB, "\033|%db"}, /* set background color */ | |
557 {(int)KS_CAF, "\033|%df"}, /* set foreground color */ | |
558 # endif | |
559 | |
560 {(int)KS_MS, "y"}, /* save to move cur in reverse mode */ | |
561 {(int)KS_UT, "y"}, | |
6602 | 562 {(int)KS_XN, "y"}, |
7 | 563 {(int)KS_LE, "\b"}, |
564 # ifdef TERMINFO | |
565 {(int)KS_CM, "\033|%i%p1%d;%p2%dH"},/* cursor motion */ | |
566 # else | |
567 {(int)KS_CM, "\033|%i%d;%dH"},/* cursor motion */ | |
568 # endif | |
569 {(int)KS_VB, "\033|B"}, /* visual bell */ | |
570 {(int)KS_TI, "\033|S"}, /* put terminal in termcap mode */ | |
571 {(int)KS_TE, "\033|E"}, /* out of termcap mode */ | |
572 # ifdef TERMINFO | |
573 {(int)KS_CS, "\033|%i%p1%d;%p2%dr"},/* scroll region */ | |
574 # else | |
575 {(int)KS_CS, "\033|%i%d;%dr"},/* scroll region */ | |
576 # endif | |
577 | |
578 {K_UP, "\316H"}, | |
579 {K_DOWN, "\316P"}, | |
580 {K_LEFT, "\316K"}, | |
581 {K_RIGHT, "\316M"}, | |
582 {K_S_UP, "\316\304"}, | |
583 {K_S_DOWN, "\316\317"}, | |
584 {K_S_LEFT, "\316\311"}, | |
585 {K_C_LEFT, "\316s"}, | |
586 {K_S_RIGHT, "\316\313"}, | |
587 {K_C_RIGHT, "\316t"}, | |
588 {K_S_TAB, "\316\017"}, | |
589 {K_F1, "\316;"}, | |
590 {K_F2, "\316<"}, | |
591 {K_F3, "\316="}, | |
592 {K_F4, "\316>"}, | |
593 {K_F5, "\316?"}, | |
594 {K_F6, "\316@"}, | |
595 {K_F7, "\316A"}, | |
596 {K_F8, "\316B"}, | |
597 {K_F9, "\316C"}, | |
598 {K_F10, "\316D"}, | |
599 {K_F11, "\316\205"}, | |
600 {K_F12, "\316\206"}, | |
601 {K_S_F1, "\316T"}, | |
602 {K_S_F2, "\316U"}, | |
603 {K_S_F3, "\316V"}, | |
604 {K_S_F4, "\316W"}, | |
605 {K_S_F5, "\316X"}, | |
606 {K_S_F6, "\316Y"}, | |
607 {K_S_F7, "\316Z"}, | |
608 {K_S_F8, "\316["}, | |
609 {K_S_F9, "\316\\"}, | |
610 {K_S_F10, "\316]"}, | |
611 {K_S_F11, "\316\207"}, | |
612 {K_S_F12, "\316\210"}, | |
613 {K_INS, "\316R"}, | |
614 {K_DEL, "\316S"}, | |
615 {K_HOME, "\316G"}, | |
616 {K_S_HOME, "\316\302"}, | |
617 {K_C_HOME, "\316w"}, | |
618 {K_END, "\316O"}, | |
619 {K_S_END, "\316\315"}, | |
620 {K_C_END, "\316u"}, | |
621 {K_PAGEDOWN, "\316Q"}, | |
622 {K_PAGEUP, "\316I"}, | |
623 {K_KPLUS, "\316N"}, | |
624 {K_KMINUS, "\316J"}, | |
625 {K_KMULTIPLY, "\316\067"}, | |
626 {K_K0, "\316\332"}, | |
627 {K_K1, "\316\336"}, | |
628 {K_K2, "\316\342"}, | |
629 {K_K3, "\316\346"}, | |
630 {K_K4, "\316\352"}, | |
631 {K_K5, "\316\356"}, | |
632 {K_K6, "\316\362"}, | |
633 {K_K7, "\316\366"}, | |
634 {K_K8, "\316\372"}, | |
635 {K_K9, "\316\376"}, | |
636 # endif | |
637 | |
638 # if defined(VMS) || defined(ALL_BUILTIN_TCAPS) | |
639 /* | |
640 * VT320 is working as an ANSI terminal compatible DEC terminal. | |
641 * (it covers VT1x0, VT2x0 and VT3x0 up to VT320 on VMS as well) | |
642 * Note: K_F1...K_F5 are for internal use, should not be defined. | |
643 * TODO:- rewrite ESC[ codes to CSI | |
644 * - keyboard languages (CSI ? 26 n) | |
645 */ | |
646 {(int)KS_NAME, "vt320"}, | |
647 {(int)KS_CE, IF_EB("\033[K", ESC_STR "[K")}, | |
648 {(int)KS_AL, IF_EB("\033[L", ESC_STR "[L")}, | |
649 # ifdef TERMINFO | |
650 {(int)KS_CAL, IF_EB("\033[%p1%dL", ESC_STR "[%p1%dL")}, | |
651 # else | |
652 {(int)KS_CAL, IF_EB("\033[%dL", ESC_STR "[%dL")}, | |
653 # endif | |
654 {(int)KS_DL, IF_EB("\033[M", ESC_STR "[M")}, | |
655 # ifdef TERMINFO | |
656 {(int)KS_CDL, IF_EB("\033[%p1%dM", ESC_STR "[%p1%dM")}, | |
657 # else | |
658 {(int)KS_CDL, IF_EB("\033[%dM", ESC_STR "[%dM")}, | |
659 # endif | |
660 {(int)KS_CL, IF_EB("\033[H\033[2J", ESC_STR "[H" ESC_STR_nc "[2J")}, | |
22 | 661 {(int)KS_CD, IF_EB("\033[J", ESC_STR "[J")}, |
662 {(int)KS_CCO, "8"}, /* allow 8 colors */ | |
7 | 663 {(int)KS_ME, IF_EB("\033[0m", ESC_STR "[0m")}, |
664 {(int)KS_MR, IF_EB("\033[7m", ESC_STR "[7m")}, | |
344 | 665 {(int)KS_MD, IF_EB("\033[1m", ESC_STR "[1m")}, /* bold mode */ |
666 {(int)KS_SE, IF_EB("\033[22m", ESC_STR "[22m")},/* normal mode */ | |
667 {(int)KS_UE, IF_EB("\033[24m", ESC_STR "[24m")},/* exit underscore mode */ | |
668 {(int)KS_US, IF_EB("\033[4m", ESC_STR "[4m")}, /* underscore mode */ | |
669 {(int)KS_CZH, IF_EB("\033[34;43m", ESC_STR "[34;43m")}, /* italic mode: blue text on yellow */ | |
670 {(int)KS_CZR, IF_EB("\033[0m", ESC_STR "[0m")}, /* italic mode end */ | |
671 {(int)KS_CAB, IF_EB("\033[4%dm", ESC_STR "[4%dm")}, /* set background color (ANSI) */ | |
672 {(int)KS_CAF, IF_EB("\033[3%dm", ESC_STR "[3%dm")}, /* set foreground color (ANSI) */ | |
673 {(int)KS_CSB, IF_EB("\033[102;%dm", ESC_STR "[102;%dm")}, /* set screen background color */ | |
674 {(int)KS_CSF, IF_EB("\033[101;%dm", ESC_STR "[101;%dm")}, /* set screen foreground color */ | |
7 | 675 {(int)KS_MS, "y"}, |
676 {(int)KS_UT, "y"}, | |
6602 | 677 {(int)KS_XN, "y"}, |
7 | 678 {(int)KS_LE, "\b"}, |
679 # ifdef TERMINFO | |
680 {(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", | |
681 ESC_STR "[%i%p1%d;%p2%dH")}, | |
682 # else | |
683 {(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")}, | |
684 # endif | |
685 # ifdef TERMINFO | |
686 {(int)KS_CRI, IF_EB("\033[%p1%dC", ESC_STR "[%p1%dC")}, | |
687 # else | |
688 {(int)KS_CRI, IF_EB("\033[%dC", ESC_STR "[%dC")}, | |
689 # endif | |
690 {K_UP, IF_EB("\033[A", ESC_STR "[A")}, | |
691 {K_DOWN, IF_EB("\033[B", ESC_STR "[B")}, | |
692 {K_RIGHT, IF_EB("\033[C", ESC_STR "[C")}, | |
693 {K_LEFT, IF_EB("\033[D", ESC_STR "[D")}, | |
344 | 694 {K_F1, IF_EB("\033[11~", ESC_STR "[11~")}, |
695 {K_F2, IF_EB("\033[12~", ESC_STR "[12~")}, | |
696 {K_F3, IF_EB("\033[13~", ESC_STR "[13~")}, | |
697 {K_F4, IF_EB("\033[14~", ESC_STR "[14~")}, | |
698 {K_F5, IF_EB("\033[15~", ESC_STR "[15~")}, | |
7 | 699 {K_F6, IF_EB("\033[17~", ESC_STR "[17~")}, |
700 {K_F7, IF_EB("\033[18~", ESC_STR "[18~")}, | |
701 {K_F8, IF_EB("\033[19~", ESC_STR "[19~")}, | |
702 {K_F9, IF_EB("\033[20~", ESC_STR "[20~")}, | |
703 {K_F10, IF_EB("\033[21~", ESC_STR "[21~")}, | |
344 | 704 {K_F11, IF_EB("\033[23~", ESC_STR "[23~")}, |
7 | 705 {K_F12, IF_EB("\033[24~", ESC_STR "[24~")}, |
706 {K_F13, IF_EB("\033[25~", ESC_STR "[25~")}, | |
707 {K_F14, IF_EB("\033[26~", ESC_STR "[26~")}, | |
708 {K_F15, IF_EB("\033[28~", ESC_STR "[28~")}, /* Help */ | |
709 {K_F16, IF_EB("\033[29~", ESC_STR "[29~")}, /* Select */ | |
710 {K_F17, IF_EB("\033[31~", ESC_STR "[31~")}, | |
711 {K_F18, IF_EB("\033[32~", ESC_STR "[32~")}, | |
712 {K_F19, IF_EB("\033[33~", ESC_STR "[33~")}, | |
713 {K_F20, IF_EB("\033[34~", ESC_STR "[34~")}, | |
714 {K_INS, IF_EB("\033[2~", ESC_STR "[2~")}, | |
715 {K_DEL, IF_EB("\033[3~", ESC_STR "[3~")}, | |
716 {K_HOME, IF_EB("\033[1~", ESC_STR "[1~")}, | |
717 {K_END, IF_EB("\033[4~", ESC_STR "[4~")}, | |
718 {K_PAGEUP, IF_EB("\033[5~", ESC_STR "[5~")}, | |
719 {K_PAGEDOWN, IF_EB("\033[6~", ESC_STR "[6~")}, | |
720 {K_KPLUS, IF_EB("\033Ok", ESC_STR "Ok")}, /* keypad plus */ | |
721 {K_KMINUS, IF_EB("\033Om", ESC_STR "Om")}, /* keypad minus */ | |
722 {K_KDIVIDE, IF_EB("\033Oo", ESC_STR "Oo")}, /* keypad / */ | |
723 {K_KMULTIPLY, IF_EB("\033Oj", ESC_STR "Oj")}, /* keypad * */ | |
724 {K_KENTER, IF_EB("\033OM", ESC_STR "OM")}, /* keypad Enter */ | |
725 {K_BS, "\x7f"}, /* for some reason 0177 doesn't work */ | |
726 # endif | |
727 | |
728 # if defined(ALL_BUILTIN_TCAPS) || defined(__MINT__) | |
729 /* | |
730 * Ordinary vt52 | |
731 */ | |
732 {(int)KS_NAME, "vt52"}, | |
733 {(int)KS_CE, IF_EB("\033K", ESC_STR "K")}, | |
734 {(int)KS_CD, IF_EB("\033J", ESC_STR "J")}, | |
7264
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
735 # ifdef TERMINFO |
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
736 {(int)KS_CM, IF_EB("\033Y%p1%' '%+%c%p2%' '%+%c", |
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
737 ESC_STR "Y%p1%' '%+%c%p2%' '%+%c")}, |
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
738 # else |
7 | 739 {(int)KS_CM, IF_EB("\033Y%+ %+ ", ESC_STR "Y%+ %+ ")}, |
7264
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
740 # endif |
7 | 741 {(int)KS_LE, "\b"}, |
7264
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
742 {(int)KS_SR, IF_EB("\033I", ESC_STR "I")}, |
7 | 743 {(int)KS_AL, IF_EB("\033L", ESC_STR "L")}, |
744 {(int)KS_DL, IF_EB("\033M", ESC_STR "M")}, | |
7264
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
745 {K_UP, IF_EB("\033A", ESC_STR "A")}, |
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
746 {K_DOWN, IF_EB("\033B", ESC_STR "B")}, |
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
747 {K_LEFT, IF_EB("\033D", ESC_STR "D")}, |
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
748 {K_RIGHT, IF_EB("\033C", ESC_STR "C")}, |
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
749 {K_F1, IF_EB("\033P", ESC_STR "P")}, |
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
750 {K_F2, IF_EB("\033Q", ESC_STR "Q")}, |
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
751 {K_F3, IF_EB("\033R", ESC_STR "R")}, |
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
752 # ifdef __MINT__ |
7 | 753 {(int)KS_CL, IF_EB("\033E", ESC_STR "E")}, |
754 {(int)KS_VE, IF_EB("\033e", ESC_STR "e")}, | |
755 {(int)KS_VI, IF_EB("\033f", ESC_STR "f")}, | |
756 {(int)KS_SO, IF_EB("\033p", ESC_STR "p")}, | |
757 {(int)KS_SE, IF_EB("\033q", ESC_STR "q")}, | |
758 {K_S_UP, IF_EB("\033a", ESC_STR "a")}, | |
759 {K_S_DOWN, IF_EB("\033b", ESC_STR "b")}, | |
760 {K_S_LEFT, IF_EB("\033d", ESC_STR "d")}, | |
761 {K_S_RIGHT, IF_EB("\033c", ESC_STR "c")}, | |
762 {K_F4, IF_EB("\033S", ESC_STR "S")}, | |
763 {K_F5, IF_EB("\033T", ESC_STR "T")}, | |
764 {K_F6, IF_EB("\033U", ESC_STR "U")}, | |
765 {K_F7, IF_EB("\033V", ESC_STR "V")}, | |
766 {K_F8, IF_EB("\033W", ESC_STR "W")}, | |
767 {K_F9, IF_EB("\033X", ESC_STR "X")}, | |
768 {K_F10, IF_EB("\033Y", ESC_STR "Y")}, | |
769 {K_S_F1, IF_EB("\033p", ESC_STR "p")}, | |
770 {K_S_F2, IF_EB("\033q", ESC_STR "q")}, | |
771 {K_S_F3, IF_EB("\033r", ESC_STR "r")}, | |
772 {K_S_F4, IF_EB("\033s", ESC_STR "s")}, | |
773 {K_S_F5, IF_EB("\033t", ESC_STR "t")}, | |
774 {K_S_F6, IF_EB("\033u", ESC_STR "u")}, | |
775 {K_S_F7, IF_EB("\033v", ESC_STR "v")}, | |
776 {K_S_F8, IF_EB("\033w", ESC_STR "w")}, | |
777 {K_S_F9, IF_EB("\033x", ESC_STR "x")}, | |
778 {K_S_F10, IF_EB("\033y", ESC_STR "y")}, | |
779 {K_INS, IF_EB("\033I", ESC_STR "I")}, | |
780 {K_HOME, IF_EB("\033E", ESC_STR "E")}, | |
781 {K_PAGEDOWN, IF_EB("\033b", ESC_STR "b")}, | |
782 {K_PAGEUP, IF_EB("\033a", ESC_STR "a")}, | |
783 # else | |
784 {(int)KS_CL, IF_EB("\033H\033J", ESC_STR "H" ESC_STR_nc "J")}, | |
785 {(int)KS_MS, "y"}, | |
786 # endif | |
787 # endif | |
788 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
789 # 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
|
790 {(int)KS_NAME, "xterm"}, |
7 | 791 {(int)KS_CE, IF_EB("\033[K", ESC_STR "[K")}, |
792 {(int)KS_AL, IF_EB("\033[L", ESC_STR "[L")}, | |
793 # ifdef TERMINFO | |
794 {(int)KS_CAL, IF_EB("\033[%p1%dL", ESC_STR "[%p1%dL")}, | |
795 # else | |
796 {(int)KS_CAL, IF_EB("\033[%dL", ESC_STR "[%dL")}, | |
797 # endif | |
798 {(int)KS_DL, IF_EB("\033[M", ESC_STR "[M")}, | |
799 # ifdef TERMINFO | |
800 {(int)KS_CDL, IF_EB("\033[%p1%dM", ESC_STR "[%p1%dM")}, | |
801 # else | |
802 {(int)KS_CDL, IF_EB("\033[%dM", ESC_STR "[%dM")}, | |
803 # endif | |
804 # ifdef TERMINFO | |
805 {(int)KS_CS, IF_EB("\033[%i%p1%d;%p2%dr", | |
806 ESC_STR "[%i%p1%d;%p2%dr")}, | |
807 # else | |
808 {(int)KS_CS, IF_EB("\033[%i%d;%dr", ESC_STR "[%i%d;%dr")}, | |
809 # endif | |
810 {(int)KS_CL, IF_EB("\033[H\033[2J", ESC_STR "[H" ESC_STR_nc "[2J")}, | |
811 {(int)KS_CD, IF_EB("\033[J", ESC_STR "[J")}, | |
812 {(int)KS_ME, IF_EB("\033[m", ESC_STR "[m")}, | |
813 {(int)KS_MR, IF_EB("\033[7m", ESC_STR "[7m")}, | |
814 {(int)KS_MD, IF_EB("\033[1m", ESC_STR "[1m")}, | |
815 {(int)KS_UE, IF_EB("\033[m", ESC_STR "[m")}, | |
816 {(int)KS_US, IF_EB("\033[4m", ESC_STR "[4m")}, | |
817 {(int)KS_MS, "y"}, | |
818 {(int)KS_UT, "y"}, | |
819 {(int)KS_LE, "\b"}, | |
820 # ifdef TERMINFO | |
821 {(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", | |
822 ESC_STR "[%i%p1%d;%p2%dH")}, | |
823 # else | |
824 {(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")}, | |
825 # endif | |
826 {(int)KS_SR, IF_EB("\033M", ESC_STR "M")}, | |
827 # ifdef TERMINFO | |
828 {(int)KS_CRI, IF_EB("\033[%p1%dC", ESC_STR "[%p1%dC")}, | |
829 # else | |
830 {(int)KS_CRI, IF_EB("\033[%dC", ESC_STR "[%dC")}, | |
831 # endif | |
832 {(int)KS_KS, IF_EB("\033[?1h\033=", ESC_STR "[?1h" ESC_STR_nc "=")}, | |
833 {(int)KS_KE, IF_EB("\033[?1l\033>", ESC_STR "[?1l" ESC_STR_nc ">")}, | |
834 # ifdef FEAT_XTERM_SAVE | |
835 {(int)KS_TI, IF_EB("\0337\033[?47h", ESC_STR "7" ESC_STR_nc "[?47h")}, | |
836 {(int)KS_TE, IF_EB("\033[2J\033[?47l\0338", | |
837 ESC_STR "[2J" ESC_STR_nc "[?47l" ESC_STR_nc "8")}, | |
838 # endif | |
839 {(int)KS_CIS, IF_EB("\033]1;", ESC_STR "]1;")}, | |
840 {(int)KS_CIE, "\007"}, | |
841 {(int)KS_TS, IF_EB("\033]2;", ESC_STR "]2;")}, | |
842 {(int)KS_FS, "\007"}, | |
843 # ifdef TERMINFO | |
844 {(int)KS_CWS, IF_EB("\033[8;%p1%d;%p2%dt", | |
845 ESC_STR "[8;%p1%d;%p2%dt")}, | |
846 {(int)KS_CWP, IF_EB("\033[3;%p1%d;%p2%dt", | |
847 ESC_STR "[3;%p1%d;%p2%dt")}, | |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
848 {(int)KS_CGP, IF_EB("\033[13t", ESC_STR "[13t")}, |
7 | 849 # else |
850 {(int)KS_CWS, IF_EB("\033[8;%d;%dt", ESC_STR "[8;%d;%dt")}, | |
851 {(int)KS_CWP, IF_EB("\033[3;%d;%dt", ESC_STR "[3;%d;%dt")}, | |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
852 {(int)KS_CGP, IF_EB("\033[13t", ESC_STR "[13t")}, |
7 | 853 # endif |
854 {(int)KS_CRV, IF_EB("\033[>c", ESC_STR "[>c")}, | |
6874 | 855 {(int)KS_RBG, IF_EB("\033]11;?\007", ESC_STR "]11;?\007")}, |
4215 | 856 {(int)KS_U7, IF_EB("\033[6n", ESC_STR "[6n")}, |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
857 # ifdef FEAT_TERMGUICOLORS |
8985
42eb58c9da92
commit https://github.com/vim/vim/commit/b2fa54a84078e2b8dc3c7c7bfbccf6b75c0788d0
Christian Brabandt <cb@256bit.org>
parents:
8981
diff
changeset
|
858 /* These are printf strings, not terminal codes. */ |
42eb58c9da92
commit https://github.com/vim/vim/commit/b2fa54a84078e2b8dc3c7c7bfbccf6b75c0788d0
Christian Brabandt <cb@256bit.org>
parents:
8981
diff
changeset
|
859 {(int)KS_8F, IF_EB("\033[38;2;%lu;%lu;%lum", ESC_STR "[38;2;%lu;%lu;%lum")}, |
42eb58c9da92
commit https://github.com/vim/vim/commit/b2fa54a84078e2b8dc3c7c7bfbccf6b75c0788d0
Christian Brabandt <cb@256bit.org>
parents:
8981
diff
changeset
|
860 {(int)KS_8B, IF_EB("\033[48;2;%lu;%lu;%lum", ESC_STR "[48;2;%lu;%lu;%lum")}, |
42eb58c9da92
commit https://github.com/vim/vim/commit/b2fa54a84078e2b8dc3c7c7bfbccf6b75c0788d0
Christian Brabandt <cb@256bit.org>
parents:
8981
diff
changeset
|
861 # endif |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
862 {(int)KS_CBE, IF_EB("\033[?2004h", ESC_STR "[?2004h")}, |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
863 {(int)KS_CBD, IF_EB("\033[?2004l", ESC_STR "[?2004l")}, |
180 | 864 |
865 {K_UP, IF_EB("\033O*A", ESC_STR "O*A")}, | |
866 {K_DOWN, IF_EB("\033O*B", ESC_STR "O*B")}, | |
867 {K_RIGHT, IF_EB("\033O*C", ESC_STR "O*C")}, | |
868 {K_LEFT, IF_EB("\033O*D", ESC_STR "O*D")}, | |
869 /* An extra set of cursor keys for vt100 mode */ | |
870 {K_XUP, IF_EB("\033[1;*A", ESC_STR "[1;*A")}, | |
871 {K_XDOWN, IF_EB("\033[1;*B", ESC_STR "[1;*B")}, | |
872 {K_XRIGHT, IF_EB("\033[1;*C", ESC_STR "[1;*C")}, | |
873 {K_XLEFT, IF_EB("\033[1;*D", ESC_STR "[1;*D")}, | |
7 | 874 /* An extra set of function keys for vt100 mode */ |
180 | 875 {K_XF1, IF_EB("\033O*P", ESC_STR "O*P")}, |
876 {K_XF2, IF_EB("\033O*Q", ESC_STR "O*Q")}, | |
877 {K_XF3, IF_EB("\033O*R", ESC_STR "O*R")}, | |
878 {K_XF4, IF_EB("\033O*S", ESC_STR "O*S")}, | |
179 | 879 {K_F1, IF_EB("\033[11;*~", ESC_STR "[11;*~")}, |
880 {K_F2, IF_EB("\033[12;*~", ESC_STR "[12;*~")}, | |
881 {K_F3, IF_EB("\033[13;*~", ESC_STR "[13;*~")}, | |
882 {K_F4, IF_EB("\033[14;*~", ESC_STR "[14;*~")}, | |
883 {K_F5, IF_EB("\033[15;*~", ESC_STR "[15;*~")}, | |
884 {K_F6, IF_EB("\033[17;*~", ESC_STR "[17;*~")}, | |
885 {K_F7, IF_EB("\033[18;*~", ESC_STR "[18;*~")}, | |
886 {K_F8, IF_EB("\033[19;*~", ESC_STR "[19;*~")}, | |
887 {K_F9, IF_EB("\033[20;*~", ESC_STR "[20;*~")}, | |
888 {K_F10, IF_EB("\033[21;*~", ESC_STR "[21;*~")}, | |
889 {K_F11, IF_EB("\033[23;*~", ESC_STR "[23;*~")}, | |
890 {K_F12, IF_EB("\033[24;*~", ESC_STR "[24;*~")}, | |
7 | 891 {K_S_TAB, IF_EB("\033[Z", ESC_STR "[Z")}, |
179 | 892 {K_HELP, IF_EB("\033[28;*~", ESC_STR "[28;*~")}, |
893 {K_UNDO, IF_EB("\033[26;*~", ESC_STR "[26;*~")}, | |
894 {K_INS, IF_EB("\033[2;*~", ESC_STR "[2;*~")}, | |
895 {K_HOME, IF_EB("\033[1;*H", ESC_STR "[1;*H")}, | |
180 | 896 /* {K_S_HOME, IF_EB("\033O2H", ESC_STR "O2H")}, */ |
897 /* {K_C_HOME, IF_EB("\033O5H", ESC_STR "O5H")}, */ | |
230 | 898 {K_KHOME, IF_EB("\033[1;*~", ESC_STR "[1;*~")}, |
180 | 899 {K_XHOME, IF_EB("\033O*H", ESC_STR "O*H")}, /* other Home */ |
230 | 900 {K_ZHOME, IF_EB("\033[7;*~", ESC_STR "[7;*~")}, /* other Home */ |
179 | 901 {K_END, IF_EB("\033[1;*F", ESC_STR "[1;*F")}, |
180 | 902 /* {K_S_END, IF_EB("\033O2F", ESC_STR "O2F")}, */ |
903 /* {K_C_END, IF_EB("\033O5F", ESC_STR "O5F")}, */ | |
179 | 904 {K_KEND, IF_EB("\033[4;*~", ESC_STR "[4;*~")}, |
180 | 905 {K_XEND, IF_EB("\033O*F", ESC_STR "O*F")}, /* other End */ |
230 | 906 {K_ZEND, IF_EB("\033[8;*~", ESC_STR "[8;*~")}, |
179 | 907 {K_PAGEUP, IF_EB("\033[5;*~", ESC_STR "[5;*~")}, |
908 {K_PAGEDOWN, IF_EB("\033[6;*~", ESC_STR "[6;*~")}, | |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
909 {K_KPLUS, IF_EB("\033O*k", ESC_STR "O*k")}, /* keypad plus */ |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
910 {K_KMINUS, IF_EB("\033O*m", ESC_STR "O*m")}, /* keypad minus */ |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
911 {K_KDIVIDE, IF_EB("\033O*o", ESC_STR "O*o")}, /* keypad / */ |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
912 {K_KMULTIPLY, IF_EB("\033O*j", ESC_STR "O*j")}, /* keypad * */ |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
913 {K_KENTER, IF_EB("\033O*M", ESC_STR "O*M")}, /* keypad Enter */ |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
914 {K_KPOINT, IF_EB("\033O*n", ESC_STR "O*n")}, /* keypad . */ |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
915 {K_KDEL, IF_EB("\033[3;*~", ESC_STR "[3;*~")}, /* keypad Del */ |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
916 {K_PS, IF_EB("\033[200~", ESC_STR "[200~")}, /* paste start */ |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
917 {K_PE, IF_EB("\033[201~", ESC_STR "[201~")}, /* paste end */ |
7 | 918 |
919 {BT_EXTRA_KEYS, ""}, | |
179 | 920 {TERMCAP2KEY('k', '0'), IF_EB("\033[10;*~", ESC_STR "[10;*~")}, /* F0 */ |
921 {TERMCAP2KEY('F', '3'), IF_EB("\033[25;*~", ESC_STR "[25;*~")}, /* F13 */ | |
922 /* F14 and F15 are missing, because they send the same codes as the undo | |
923 * and help key, although they don't work on all keyboards. */ | |
924 {TERMCAP2KEY('F', '6'), IF_EB("\033[29;*~", ESC_STR "[29;*~")}, /* F16 */ | |
925 {TERMCAP2KEY('F', '7'), IF_EB("\033[31;*~", ESC_STR "[31;*~")}, /* F17 */ | |
926 {TERMCAP2KEY('F', '8'), IF_EB("\033[32;*~", ESC_STR "[32;*~")}, /* F18 */ | |
927 {TERMCAP2KEY('F', '9'), IF_EB("\033[33;*~", ESC_STR "[33;*~")}, /* F19 */ | |
928 {TERMCAP2KEY('F', 'A'), IF_EB("\033[34;*~", ESC_STR "[34;*~")}, /* F20 */ | |
929 | |
930 {TERMCAP2KEY('F', 'B'), IF_EB("\033[42;*~", ESC_STR "[42;*~")}, /* F21 */ | |
931 {TERMCAP2KEY('F', 'C'), IF_EB("\033[43;*~", ESC_STR "[43;*~")}, /* F22 */ | |
932 {TERMCAP2KEY('F', 'D'), IF_EB("\033[44;*~", ESC_STR "[44;*~")}, /* F23 */ | |
933 {TERMCAP2KEY('F', 'E'), IF_EB("\033[45;*~", ESC_STR "[45;*~")}, /* F24 */ | |
934 {TERMCAP2KEY('F', 'F'), IF_EB("\033[46;*~", ESC_STR "[46;*~")}, /* F25 */ | |
935 {TERMCAP2KEY('F', 'G'), IF_EB("\033[47;*~", ESC_STR "[47;*~")}, /* F26 */ | |
936 {TERMCAP2KEY('F', 'H'), IF_EB("\033[48;*~", ESC_STR "[48;*~")}, /* F27 */ | |
937 {TERMCAP2KEY('F', 'I'), IF_EB("\033[49;*~", ESC_STR "[49;*~")}, /* F28 */ | |
938 {TERMCAP2KEY('F', 'J'), IF_EB("\033[50;*~", ESC_STR "[50;*~")}, /* F29 */ | |
939 {TERMCAP2KEY('F', 'K'), IF_EB("\033[51;*~", ESC_STR "[51;*~")}, /* F30 */ | |
940 | |
941 {TERMCAP2KEY('F', 'L'), IF_EB("\033[52;*~", ESC_STR "[52;*~")}, /* F31 */ | |
942 {TERMCAP2KEY('F', 'M'), IF_EB("\033[53;*~", ESC_STR "[53;*~")}, /* F32 */ | |
943 {TERMCAP2KEY('F', 'N'), IF_EB("\033[54;*~", ESC_STR "[54;*~")}, /* F33 */ | |
944 {TERMCAP2KEY('F', 'O'), IF_EB("\033[55;*~", ESC_STR "[55;*~")}, /* F34 */ | |
945 {TERMCAP2KEY('F', 'P'), IF_EB("\033[56;*~", ESC_STR "[56;*~")}, /* F35 */ | |
946 {TERMCAP2KEY('F', 'Q'), IF_EB("\033[57;*~", ESC_STR "[57;*~")}, /* F36 */ | |
947 {TERMCAP2KEY('F', 'R'), IF_EB("\033[58;*~", ESC_STR "[58;*~")}, /* F37 */ | |
7 | 948 # endif |
949 | |
950 # if defined(UNIX) || defined(ALL_BUILTIN_TCAPS) | |
951 /* | |
952 * iris-ansi for Silicon Graphics machines. | |
953 */ | |
954 {(int)KS_NAME, "iris-ansi"}, | |
955 {(int)KS_CE, "\033[K"}, | |
956 {(int)KS_CD, "\033[J"}, | |
957 {(int)KS_AL, "\033[L"}, | |
958 # ifdef TERMINFO | |
959 {(int)KS_CAL, "\033[%p1%dL"}, | |
960 # else | |
961 {(int)KS_CAL, "\033[%dL"}, | |
962 # endif | |
963 {(int)KS_DL, "\033[M"}, | |
964 # ifdef TERMINFO | |
965 {(int)KS_CDL, "\033[%p1%dM"}, | |
966 # else | |
967 {(int)KS_CDL, "\033[%dM"}, | |
968 # endif | |
969 #if 0 /* The scroll region is not working as Vim expects. */ | |
970 # ifdef TERMINFO | |
971 {(int)KS_CS, "\033[%i%p1%d;%p2%dr"}, | |
972 # else | |
973 {(int)KS_CS, "\033[%i%d;%dr"}, | |
974 # endif | |
975 #endif | |
976 {(int)KS_CL, "\033[H\033[2J"}, | |
977 {(int)KS_VE, "\033[9/y\033[12/y"}, /* These aren't documented */ | |
978 {(int)KS_VS, "\033[10/y\033[=1h\033[=2l"}, /* These aren't documented */ | |
979 {(int)KS_TI, "\033[=6h"}, | |
980 {(int)KS_TE, "\033[=6l"}, | |
981 {(int)KS_SE, "\033[21;27m"}, | |
982 {(int)KS_SO, "\033[1;7m"}, | |
983 {(int)KS_ME, "\033[m"}, | |
984 {(int)KS_MR, "\033[7m"}, | |
985 {(int)KS_MD, "\033[1m"}, | |
986 {(int)KS_CCO, "8"}, /* allow 8 colors */ | |
987 {(int)KS_CZH, "\033[3m"}, /* italic mode on */ | |
988 {(int)KS_CZR, "\033[23m"}, /* italic mode off */ | |
989 {(int)KS_US, "\033[4m"}, /* underline on */ | |
990 {(int)KS_UE, "\033[24m"}, /* underline off */ | |
991 # ifdef TERMINFO | |
992 {(int)KS_CAB, "\033[4%p1%dm"}, /* set background color (ANSI) */ | |
993 {(int)KS_CAF, "\033[3%p1%dm"}, /* set foreground color (ANSI) */ | |
994 {(int)KS_CSB, "\033[102;%p1%dm"}, /* set screen background color */ | |
995 {(int)KS_CSF, "\033[101;%p1%dm"}, /* set screen foreground color */ | |
996 # else | |
997 {(int)KS_CAB, "\033[4%dm"}, /* set background color (ANSI) */ | |
998 {(int)KS_CAF, "\033[3%dm"}, /* set foreground color (ANSI) */ | |
999 {(int)KS_CSB, "\033[102;%dm"}, /* set screen background color */ | |
1000 {(int)KS_CSF, "\033[101;%dm"}, /* set screen foreground color */ | |
1001 # endif | |
1002 {(int)KS_MS, "y"}, /* guessed */ | |
1003 {(int)KS_UT, "y"}, /* guessed */ | |
1004 {(int)KS_LE, "\b"}, | |
1005 # ifdef TERMINFO | |
1006 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
1007 # else | |
1008 {(int)KS_CM, "\033[%i%d;%dH"}, | |
1009 # endif | |
1010 {(int)KS_SR, "\033M"}, | |
1011 # ifdef TERMINFO | |
1012 {(int)KS_CRI, "\033[%p1%dC"}, | |
1013 # else | |
1014 {(int)KS_CRI, "\033[%dC"}, | |
1015 # endif | |
1016 {(int)KS_CIS, "\033P3.y"}, | |
1017 {(int)KS_CIE, "\234"}, /* ST "String Terminator" */ | |
1018 {(int)KS_TS, "\033P1.y"}, | |
1019 {(int)KS_FS, "\234"}, /* ST "String Terminator" */ | |
1020 # ifdef TERMINFO | |
1021 {(int)KS_CWS, "\033[203;%p1%d;%p2%d/y"}, | |
1022 {(int)KS_CWP, "\033[205;%p1%d;%p2%d/y"}, | |
1023 # else | |
1024 {(int)KS_CWS, "\033[203;%d;%d/y"}, | |
1025 {(int)KS_CWP, "\033[205;%d;%d/y"}, | |
1026 # endif | |
1027 {K_UP, "\033[A"}, | |
1028 {K_DOWN, "\033[B"}, | |
1029 {K_LEFT, "\033[D"}, | |
1030 {K_RIGHT, "\033[C"}, | |
1031 {K_S_UP, "\033[161q"}, | |
1032 {K_S_DOWN, "\033[164q"}, | |
1033 {K_S_LEFT, "\033[158q"}, | |
1034 {K_S_RIGHT, "\033[167q"}, | |
1035 {K_F1, "\033[001q"}, | |
1036 {K_F2, "\033[002q"}, | |
1037 {K_F3, "\033[003q"}, | |
1038 {K_F4, "\033[004q"}, | |
1039 {K_F5, "\033[005q"}, | |
1040 {K_F6, "\033[006q"}, | |
1041 {K_F7, "\033[007q"}, | |
1042 {K_F8, "\033[008q"}, | |
1043 {K_F9, "\033[009q"}, | |
1044 {K_F10, "\033[010q"}, | |
1045 {K_F11, "\033[011q"}, | |
1046 {K_F12, "\033[012q"}, | |
1047 {K_S_F1, "\033[013q"}, | |
1048 {K_S_F2, "\033[014q"}, | |
1049 {K_S_F3, "\033[015q"}, | |
1050 {K_S_F4, "\033[016q"}, | |
1051 {K_S_F5, "\033[017q"}, | |
1052 {K_S_F6, "\033[018q"}, | |
1053 {K_S_F7, "\033[019q"}, | |
1054 {K_S_F8, "\033[020q"}, | |
1055 {K_S_F9, "\033[021q"}, | |
1056 {K_S_F10, "\033[022q"}, | |
1057 {K_S_F11, "\033[023q"}, | |
1058 {K_S_F12, "\033[024q"}, | |
1059 {K_INS, "\033[139q"}, | |
1060 {K_HOME, "\033[H"}, | |
1061 {K_END, "\033[146q"}, | |
1062 {K_PAGEUP, "\033[150q"}, | |
1063 {K_PAGEDOWN, "\033[154q"}, | |
1064 # endif | |
1065 | |
1066 # if defined(DEBUG) || defined(ALL_BUILTIN_TCAPS) | |
1067 /* | |
1068 * for debugging | |
1069 */ | |
1070 {(int)KS_NAME, "debug"}, | |
1071 {(int)KS_CE, "[CE]"}, | |
1072 {(int)KS_CD, "[CD]"}, | |
1073 {(int)KS_AL, "[AL]"}, | |
1074 # ifdef TERMINFO | |
1075 {(int)KS_CAL, "[CAL%p1%d]"}, | |
1076 # else | |
1077 {(int)KS_CAL, "[CAL%d]"}, | |
1078 # endif | |
1079 {(int)KS_DL, "[DL]"}, | |
1080 # ifdef TERMINFO | |
1081 {(int)KS_CDL, "[CDL%p1%d]"}, | |
1082 # else | |
1083 {(int)KS_CDL, "[CDL%d]"}, | |
1084 # endif | |
1085 # ifdef TERMINFO | |
1086 {(int)KS_CS, "[%p1%dCS%p2%d]"}, | |
1087 # else | |
1088 {(int)KS_CS, "[%dCS%d]"}, | |
1089 # endif | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
1090 # ifdef FEAT_WINDOWS |
7 | 1091 # ifdef TERMINFO |
1092 {(int)KS_CSV, "[%p1%dCSV%p2%d]"}, | |
1093 # else | |
1094 {(int)KS_CSV, "[%dCSV%d]"}, | |
1095 # endif | |
1096 # endif | |
1097 # ifdef TERMINFO | |
1098 {(int)KS_CAB, "[CAB%p1%d]"}, | |
1099 {(int)KS_CAF, "[CAF%p1%d]"}, | |
1100 {(int)KS_CSB, "[CSB%p1%d]"}, | |
1101 {(int)KS_CSF, "[CSF%p1%d]"}, | |
1102 # else | |
1103 {(int)KS_CAB, "[CAB%d]"}, | |
1104 {(int)KS_CAF, "[CAF%d]"}, | |
1105 {(int)KS_CSB, "[CSB%d]"}, | |
1106 {(int)KS_CSF, "[CSF%d]"}, | |
1107 # endif | |
1108 {(int)KS_OP, "[OP]"}, | |
1109 {(int)KS_LE, "[LE]"}, | |
1110 {(int)KS_CL, "[CL]"}, | |
1111 {(int)KS_VI, "[VI]"}, | |
1112 {(int)KS_VE, "[VE]"}, | |
1113 {(int)KS_VS, "[VS]"}, | |
1114 {(int)KS_ME, "[ME]"}, | |
1115 {(int)KS_MR, "[MR]"}, | |
1116 {(int)KS_MB, "[MB]"}, | |
1117 {(int)KS_MD, "[MD]"}, | |
1118 {(int)KS_SE, "[SE]"}, | |
1119 {(int)KS_SO, "[SO]"}, | |
1120 {(int)KS_UE, "[UE]"}, | |
1121 {(int)KS_US, "[US]"}, | |
205 | 1122 {(int)KS_UCE, "[UCE]"}, |
1123 {(int)KS_UCS, "[UCS]"}, | |
7 | 1124 {(int)KS_MS, "[MS]"}, |
1125 {(int)KS_UT, "[UT]"}, | |
6602 | 1126 {(int)KS_XN, "[XN]"}, |
7 | 1127 # ifdef TERMINFO |
1128 {(int)KS_CM, "[%p1%dCM%p2%d]"}, | |
1129 # else | |
1130 {(int)KS_CM, "[%dCM%d]"}, | |
1131 # endif | |
1132 {(int)KS_SR, "[SR]"}, | |
1133 # ifdef TERMINFO | |
1134 {(int)KS_CRI, "[CRI%p1%d]"}, | |
1135 # else | |
1136 {(int)KS_CRI, "[CRI%d]"}, | |
1137 # endif | |
1138 {(int)KS_VB, "[VB]"}, | |
1139 {(int)KS_KS, "[KS]"}, | |
1140 {(int)KS_KE, "[KE]"}, | |
1141 {(int)KS_TI, "[TI]"}, | |
1142 {(int)KS_TE, "[TE]"}, | |
1143 {(int)KS_CIS, "[CIS]"}, | |
1144 {(int)KS_CIE, "[CIE]"}, | |
1145 {(int)KS_TS, "[TS]"}, | |
1146 {(int)KS_FS, "[FS]"}, | |
1147 # ifdef TERMINFO | |
1148 {(int)KS_CWS, "[%p1%dCWS%p2%d]"}, | |
1149 {(int)KS_CWP, "[%p1%dCWP%p2%d]"}, | |
1150 # else | |
1151 {(int)KS_CWS, "[%dCWS%d]"}, | |
1152 {(int)KS_CWP, "[%dCWP%d]"}, | |
1153 # endif | |
1154 {(int)KS_CRV, "[CRV]"}, | |
4215 | 1155 {(int)KS_U7, "[U7]"}, |
6874 | 1156 {(int)KS_RBG, "[RBG]"}, |
7 | 1157 {K_UP, "[KU]"}, |
1158 {K_DOWN, "[KD]"}, | |
1159 {K_LEFT, "[KL]"}, | |
1160 {K_RIGHT, "[KR]"}, | |
180 | 1161 {K_XUP, "[xKU]"}, |
1162 {K_XDOWN, "[xKD]"}, | |
1163 {K_XLEFT, "[xKL]"}, | |
1164 {K_XRIGHT, "[xKR]"}, | |
7 | 1165 {K_S_UP, "[S-KU]"}, |
1166 {K_S_DOWN, "[S-KD]"}, | |
1167 {K_S_LEFT, "[S-KL]"}, | |
1168 {K_C_LEFT, "[C-KL]"}, | |
1169 {K_S_RIGHT, "[S-KR]"}, | |
1170 {K_C_RIGHT, "[C-KR]"}, | |
1171 {K_F1, "[F1]"}, | |
1172 {K_XF1, "[xF1]"}, | |
1173 {K_F2, "[F2]"}, | |
1174 {K_XF2, "[xF2]"}, | |
1175 {K_F3, "[F3]"}, | |
1176 {K_XF3, "[xF3]"}, | |
1177 {K_F4, "[F4]"}, | |
1178 {K_XF4, "[xF4]"}, | |
1179 {K_F5, "[F5]"}, | |
1180 {K_F6, "[F6]"}, | |
1181 {K_F7, "[F7]"}, | |
1182 {K_F8, "[F8]"}, | |
1183 {K_F9, "[F9]"}, | |
1184 {K_F10, "[F10]"}, | |
1185 {K_F11, "[F11]"}, | |
1186 {K_F12, "[F12]"}, | |
1187 {K_S_F1, "[S-F1]"}, | |
1188 {K_S_XF1, "[S-xF1]"}, | |
1189 {K_S_F2, "[S-F2]"}, | |
1190 {K_S_XF2, "[S-xF2]"}, | |
1191 {K_S_F3, "[S-F3]"}, | |
1192 {K_S_XF3, "[S-xF3]"}, | |
1193 {K_S_F4, "[S-F4]"}, | |
1194 {K_S_XF4, "[S-xF4]"}, | |
1195 {K_S_F5, "[S-F5]"}, | |
1196 {K_S_F6, "[S-F6]"}, | |
1197 {K_S_F7, "[S-F7]"}, | |
1198 {K_S_F8, "[S-F8]"}, | |
1199 {K_S_F9, "[S-F9]"}, | |
1200 {K_S_F10, "[S-F10]"}, | |
1201 {K_S_F11, "[S-F11]"}, | |
1202 {K_S_F12, "[S-F12]"}, | |
1203 {K_HELP, "[HELP]"}, | |
1204 {K_UNDO, "[UNDO]"}, | |
1205 {K_BS, "[BS]"}, | |
1206 {K_INS, "[INS]"}, | |
1207 {K_KINS, "[KINS]"}, | |
1208 {K_DEL, "[DEL]"}, | |
1209 {K_KDEL, "[KDEL]"}, | |
1210 {K_HOME, "[HOME]"}, | |
1211 {K_S_HOME, "[C-HOME]"}, | |
1212 {K_C_HOME, "[C-HOME]"}, | |
1213 {K_KHOME, "[KHOME]"}, | |
1214 {K_XHOME, "[XHOME]"}, | |
230 | 1215 {K_ZHOME, "[ZHOME]"}, |
7 | 1216 {K_END, "[END]"}, |
1217 {K_S_END, "[C-END]"}, | |
1218 {K_C_END, "[C-END]"}, | |
1219 {K_KEND, "[KEND]"}, | |
1220 {K_XEND, "[XEND]"}, | |
230 | 1221 {K_ZEND, "[ZEND]"}, |
7 | 1222 {K_PAGEUP, "[PAGEUP]"}, |
1223 {K_PAGEDOWN, "[PAGEDOWN]"}, | |
1224 {K_KPAGEUP, "[KPAGEUP]"}, | |
1225 {K_KPAGEDOWN, "[KPAGEDOWN]"}, | |
1226 {K_MOUSE, "[MOUSE]"}, | |
1227 {K_KPLUS, "[KPLUS]"}, | |
1228 {K_KMINUS, "[KMINUS]"}, | |
1229 {K_KDIVIDE, "[KDIVIDE]"}, | |
1230 {K_KMULTIPLY, "[KMULTIPLY]"}, | |
1231 {K_KENTER, "[KENTER]"}, | |
1232 {K_KPOINT, "[KPOINT]"}, | |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
1233 {K_PS, "[PASTE-START]"}, |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
1234 {K_PE, "[PASTE-END]"}, |
7 | 1235 {K_K0, "[K0]"}, |
1236 {K_K1, "[K1]"}, | |
1237 {K_K2, "[K2]"}, | |
1238 {K_K3, "[K3]"}, | |
1239 {K_K4, "[K4]"}, | |
1240 {K_K5, "[K5]"}, | |
1241 {K_K6, "[K6]"}, | |
1242 {K_K7, "[K7]"}, | |
1243 {K_K8, "[K8]"}, | |
1244 {K_K9, "[K9]"}, | |
1245 # endif | |
1246 | |
1247 #endif /* NO_BUILTIN_TCAPS */ | |
1248 | |
1249 /* | |
1250 * The most minimal terminal: only clear screen and cursor positioning | |
1251 * Always included. | |
1252 */ | |
1253 {(int)KS_NAME, "dumb"}, | |
1254 {(int)KS_CL, "\014"}, | |
1255 #ifdef TERMINFO | |
1256 {(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", | |
1257 ESC_STR "[%i%p1%d;%p2%dH")}, | |
1258 #else | |
1259 {(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")}, | |
1260 #endif | |
1261 | |
1262 /* | |
1263 * end marker | |
1264 */ | |
1265 {(int)KS_NAME, NULL} | |
1266 | |
1267 }; /* end of builtin_termcaps */ | |
1268 | |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1269 #if defined(FEAT_TERMGUICOLORS) || defined(PROTO) |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1270 guicolor_T |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1271 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
|
1272 { |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
1273 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
|
1274 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1275 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1276 guicolor_T |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1277 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
|
1278 { |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1279 guicolor_T t; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1280 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1281 if (*name == NUL) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1282 return INVALCOLOR; |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1283 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
|
1284 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1285 if (t == INVALCOLOR) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1286 EMSG2(_("E254: Cannot allocate color %s"), name); |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1287 return t; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1288 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1289 |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
1290 guicolor_T |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1291 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
|
1292 { |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
1293 return color; |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1294 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1295 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1296 |
7 | 1297 /* |
1298 * DEFAULT_TERM is used, when no terminal is specified with -T option or $TERM. | |
1299 */ | |
1300 #ifdef AMIGA | |
1301 # define DEFAULT_TERM (char_u *)"amiga" | |
1302 #endif | |
1303 | |
1304 #ifdef MSWIN | |
1305 # define DEFAULT_TERM (char_u *)"win32" | |
1306 #endif | |
1307 | |
1308 #if defined(UNIX) && !defined(__MINT__) | |
1309 # define DEFAULT_TERM (char_u *)"ansi" | |
1310 #endif | |
1311 | |
1312 #ifdef __MINT__ | |
1313 # define DEFAULT_TERM (char_u *)"vt52" | |
1314 #endif | |
1315 | |
1316 #ifdef VMS | |
1317 # define DEFAULT_TERM (char_u *)"vt320" | |
1318 #endif | |
1319 | |
1320 #ifdef __BEOS__ | |
1321 # undef DEFAULT_TERM | |
1322 # define DEFAULT_TERM (char_u *)"beos-ansi" | |
1323 #endif | |
1324 | |
1325 #ifndef DEFAULT_TERM | |
1326 # define DEFAULT_TERM (char_u *)"dumb" | |
1327 #endif | |
1328 | |
1329 /* | |
1330 * Term_strings contains currently used terminal output strings. | |
1331 * It is initialized with the default values by parse_builtin_tcap(). | |
1332 * The values can be changed by setting the option with the same name. | |
1333 */ | |
1334 char_u *(term_strings[(int)KS_LAST + 1]); | |
1335 | |
1221 | 1336 static int need_gather = FALSE; /* need to fill termleader[] */ |
1337 static char_u termleader[256 + 1]; /* for check_termcode() */ | |
7 | 1338 #ifdef FEAT_TERMRESPONSE |
1221 | 1339 static int check_for_codes = FALSE; /* check for key code response */ |
7 | 1340 #endif |
1341 | |
1342 static struct builtin_term * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1343 find_builtin_term(char_u *term) |
7 | 1344 { |
1345 struct builtin_term *p; | |
1346 | |
1347 p = builtin_termcaps; | |
1348 while (p->bt_string != NULL) | |
1349 { | |
1350 if (p->bt_entry == (int)KS_NAME) | |
1351 { | |
1352 #ifdef UNIX | |
1353 if (STRCMP(p->bt_string, "iris-ansi") == 0 && vim_is_iris(term)) | |
1354 return p; | |
1355 else if (STRCMP(p->bt_string, "xterm") == 0 && vim_is_xterm(term)) | |
1356 return p; | |
1357 else | |
1358 #endif | |
1359 #ifdef VMS | |
1360 if (STRCMP(p->bt_string, "vt320") == 0 && vim_is_vt300(term)) | |
1361 return p; | |
1362 else | |
1363 #endif | |
1364 if (STRCMP(term, p->bt_string) == 0) | |
1365 return p; | |
1366 } | |
1367 ++p; | |
1368 } | |
1369 return p; | |
1370 } | |
1371 | |
1372 /* | |
1373 * Parsing of the builtin termcap entries. | |
1374 * Caller should check if 'name' is a valid builtin term. | |
1375 * The terminal's name is not set, as this is already done in termcapinit(). | |
1376 */ | |
1377 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1378 parse_builtin_tcap(char_u *term) |
7 | 1379 { |
1380 struct builtin_term *p; | |
1381 char_u name[2]; | |
1382 int term_8bit; | |
1383 | |
1384 p = find_builtin_term(term); | |
1385 term_8bit = term_is_8bit(term); | |
1386 | |
1387 /* Do not parse if builtin term not found */ | |
1388 if (p->bt_string == NULL) | |
1389 return; | |
1390 | |
1391 for (++p; p->bt_entry != (int)KS_NAME && p->bt_entry != BT_EXTRA_KEYS; ++p) | |
1392 { | |
1393 if ((int)p->bt_entry >= 0) /* KS_xx entry */ | |
1394 { | |
1395 /* Only set the value if it wasn't set yet. */ | |
1396 if (term_strings[p->bt_entry] == NULL | |
1397 || term_strings[p->bt_entry] == empty_option) | |
1398 { | |
1399 /* 8bit terminal: use CSI instead of <Esc>[ */ | |
1400 if (term_8bit && term_7to8bit((char_u *)p->bt_string) != 0) | |
1401 { | |
1402 char_u *s, *t; | |
1403 | |
1404 s = vim_strsave((char_u *)p->bt_string); | |
1405 if (s != NULL) | |
1406 { | |
1407 for (t = s; *t; ++t) | |
1408 if (term_7to8bit(t)) | |
1409 { | |
1410 *t = term_7to8bit(t); | |
1411 STRCPY(t + 1, t + 2); | |
1412 } | |
1413 term_strings[p->bt_entry] = s; | |
1414 set_term_option_alloced(&term_strings[p->bt_entry]); | |
1415 } | |
1416 } | |
1417 else | |
1418 term_strings[p->bt_entry] = (char_u *)p->bt_string; | |
1419 } | |
1420 } | |
1421 else | |
1422 { | |
1423 name[0] = KEY2TERMCAP0((int)p->bt_entry); | |
1424 name[1] = KEY2TERMCAP1((int)p->bt_entry); | |
1425 if (find_termcode(name) == NULL) | |
1426 add_termcode(name, (char_u *)p->bt_string, term_8bit); | |
1427 } | |
1428 } | |
1429 } | |
1430 #if defined(HAVE_TGETENT) || defined(FEAT_TERMRESPONSE) | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1431 static void set_color_count(int nr); |
7 | 1432 |
1433 /* | |
1434 * Set number of colors. | |
1435 * Store it as a number in t_colors. | |
1436 * Store it as a string in T_CCO (using nr_colors[]). | |
1437 */ | |
1438 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1439 set_color_count(int nr) |
7 | 1440 { |
1441 char_u nr_colors[20]; /* string for number of colors */ | |
1442 | |
1443 t_colors = nr; | |
1444 if (t_colors > 1) | |
1445 sprintf((char *)nr_colors, "%d", t_colors); | |
1446 else | |
1447 *nr_colors = NUL; | |
694 | 1448 set_string_option_direct((char_u *)"t_Co", -1, nr_colors, OPT_FREE, 0); |
7 | 1449 } |
1450 #endif | |
1451 | |
1452 #ifdef HAVE_TGETENT | |
1453 static char *(key_names[]) = | |
1454 { | |
1455 #ifdef FEAT_TERMRESPONSE | |
1456 /* Do this one first, it may cause a screen redraw. */ | |
1457 "Co", | |
1458 #endif | |
1459 "ku", "kd", "kr", "kl", | |
1460 "#2", "#4", "%i", "*7", | |
1461 "k1", "k2", "k3", "k4", "k5", "k6", | |
1462 "k7", "k8", "k9", "k;", "F1", "F2", | |
1463 "%1", "&8", "kb", "kI", "kD", "kh", | |
1464 "@7", "kP", "kN", "K1", "K3", "K4", "K5", "kB", | |
1465 NULL | |
1466 }; | |
1467 #endif | |
1468 | |
1469 /* | |
1470 * Set terminal options for terminal "term". | |
1471 * Return OK if terminal 'term' was found in a termcap, FAIL otherwise. | |
1472 * | |
1473 * While doing this, until ttest(), some options may be NULL, be careful. | |
1474 */ | |
1475 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1476 set_termname(char_u *term) |
7 | 1477 { |
1478 struct builtin_term *termp; | |
1479 #ifdef HAVE_TGETENT | |
1480 int builtin_first = p_tbi; | |
1481 int try; | |
1482 int termcap_cleared = FALSE; | |
1483 #endif | |
1484 int width = 0, height = 0; | |
1485 char_u *error_msg = NULL; | |
1486 char_u *bs_p, *del_p; | |
1487 | |
168 | 1488 /* In silect mode (ex -s) we don't use the 'term' option. */ |
1489 if (silent_mode) | |
1490 return OK; | |
1491 | |
7 | 1492 detected_8bit = FALSE; /* reset 8-bit detection */ |
1493 | |
1494 if (term_is_builtin(term)) | |
1495 { | |
1496 term += 8; | |
1497 #ifdef HAVE_TGETENT | |
1498 builtin_first = 1; | |
1499 #endif | |
1500 } | |
1501 | |
1502 /* | |
1503 * If HAVE_TGETENT is not defined, only the builtin termcap is used, otherwise: | |
1504 * If builtin_first is TRUE: | |
1505 * 0. try builtin termcap | |
1506 * 1. try external termcap | |
1507 * 2. if both fail default to a builtin terminal | |
1508 * If builtin_first is FALSE: | |
1509 * 1. try external termcap | |
1510 * 2. try builtin termcap, if both fail default to a builtin terminal | |
1511 */ | |
1512 #ifdef HAVE_TGETENT | |
1513 for (try = builtin_first ? 0 : 1; try < 3; ++try) | |
1514 { | |
1515 /* | |
1516 * Use external termcap | |
1517 */ | |
1518 if (try == 1) | |
1519 { | |
1520 char_u *p; | |
1521 static char_u tstrbuf[TBUFSZ]; | |
1522 int i; | |
1523 char_u tbuf[TBUFSZ]; | |
1524 char_u *tp; | |
1525 static struct { | |
1526 enum SpecialKey dest; /* index in term_strings[] */ | |
1527 char *name; /* termcap name for string */ | |
1528 } string_names[] = | |
1529 { {KS_CE, "ce"}, {KS_AL, "al"}, {KS_CAL,"AL"}, | |
1530 {KS_DL, "dl"}, {KS_CDL,"DL"}, {KS_CS, "cs"}, | |
1531 {KS_CL, "cl"}, {KS_CD, "cd"}, | |
1532 {KS_VI, "vi"}, {KS_VE, "ve"}, {KS_MB, "mb"}, | |
1533 {KS_VS, "vs"}, {KS_ME, "me"}, {KS_MR, "mr"}, | |
1534 {KS_MD, "md"}, {KS_SE, "se"}, {KS_SO, "so"}, | |
1535 {KS_CZH,"ZH"}, {KS_CZR,"ZR"}, {KS_UE, "ue"}, | |
205 | 1536 {KS_US, "us"}, {KS_UCE, "Ce"}, {KS_UCS, "Cs"}, |
1537 {KS_CM, "cm"}, {KS_SR, "sr"}, | |
7 | 1538 {KS_CRI,"RI"}, {KS_VB, "vb"}, {KS_KS, "ks"}, |
1539 {KS_KE, "ke"}, {KS_TI, "ti"}, {KS_TE, "te"}, | |
1540 {KS_BC, "bc"}, {KS_CSB,"Sb"}, {KS_CSF,"Sf"}, | |
1541 {KS_CAB,"AB"}, {KS_CAF,"AF"}, {KS_LE, "le"}, | |
1542 {KS_ND, "nd"}, {KS_OP, "op"}, {KS_CRV, "RV"}, | |
1543 {KS_CIS, "IS"}, {KS_CIE, "IE"}, | |
1544 {KS_TS, "ts"}, {KS_FS, "fs"}, | |
1545 {KS_CWP, "WP"}, {KS_CWS, "WS"}, | |
36 | 1546 {KS_CSI, "SI"}, {KS_CEI, "EI"}, |
6882 | 1547 {KS_U7, "u7"}, {KS_RBG, "RB"}, |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1548 {KS_8F, "8f"}, {KS_8B, "8b"}, |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
1549 {KS_CBE, "BE"}, {KS_CBD, "BD"}, |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
1550 {KS_CPS, "PS"}, {KS_CPE, "PE"}, |
7 | 1551 {(enum SpecialKey)0, NULL} |
1552 }; | |
1553 | |
1554 /* | |
1555 * If the external termcap does not have a matching entry, try the | |
1556 * builtin ones. | |
1557 */ | |
1558 if ((error_msg = tgetent_error(tbuf, term)) == NULL) | |
1559 { | |
1560 tp = tstrbuf; | |
1561 if (!termcap_cleared) | |
1562 { | |
1563 clear_termoptions(); /* clear old options */ | |
1564 termcap_cleared = TRUE; | |
1565 } | |
1566 | |
1567 /* get output strings */ | |
1568 for (i = 0; string_names[i].name != NULL; ++i) | |
1569 { | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
10676
diff
changeset
|
1570 if (TERM_STR(string_names[i].dest) == NULL |
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
10676
diff
changeset
|
1571 || TERM_STR(string_names[i].dest) == empty_option) |
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
10676
diff
changeset
|
1572 TERM_STR(string_names[i].dest) = |
7 | 1573 TGETSTR(string_names[i].name, &tp); |
1574 } | |
1575 | |
1576 /* tgetflag() returns 1 if the flag is present, 0 if not and | |
1577 * possibly -1 if the flag doesn't exist. */ | |
1578 if ((T_MS == NULL || T_MS == empty_option) | |
1579 && tgetflag("ms") > 0) | |
1580 T_MS = (char_u *)"y"; | |
1581 if ((T_XS == NULL || T_XS == empty_option) | |
1582 && tgetflag("xs") > 0) | |
1583 T_XS = (char_u *)"y"; | |
6602 | 1584 if ((T_XN == NULL || T_XN == empty_option) |
1585 && tgetflag("xn") > 0) | |
1586 T_XN = (char_u *)"y"; | |
7 | 1587 if ((T_DB == NULL || T_DB == empty_option) |
1588 && tgetflag("db") > 0) | |
1589 T_DB = (char_u *)"y"; | |
1590 if ((T_DA == NULL || T_DA == empty_option) | |
1591 && tgetflag("da") > 0) | |
1592 T_DA = (char_u *)"y"; | |
1593 if ((T_UT == NULL || T_UT == empty_option) | |
1594 && tgetflag("ut") > 0) | |
1595 T_UT = (char_u *)"y"; | |
1596 | |
1597 | |
1598 /* | |
1599 * get key codes | |
1600 */ | |
1601 for (i = 0; key_names[i] != NULL; ++i) | |
1602 { | |
1603 if (find_termcode((char_u *)key_names[i]) == NULL) | |
1604 { | |
1605 p = TGETSTR(key_names[i], &tp); | |
1606 /* if cursor-left == backspace, ignore it (televideo | |
1607 * 925) */ | |
1608 if (p != NULL | |
1609 && (*p != Ctrl_H | |
1610 || key_names[i][0] != 'k' | |
1611 || key_names[i][1] != 'l')) | |
1612 add_termcode((char_u *)key_names[i], p, FALSE); | |
1613 } | |
1614 } | |
1615 | |
1616 if (height == 0) | |
1617 height = tgetnum("li"); | |
1618 if (width == 0) | |
1619 width = tgetnum("co"); | |
1620 | |
1621 /* | |
1622 * Get number of colors (if not done already). | |
1623 */ | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
10676
diff
changeset
|
1624 if (TERM_STR(KS_CCO) == NULL |
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
10676
diff
changeset
|
1625 || TERM_STR(KS_CCO) == empty_option) |
7 | 1626 set_color_count(tgetnum("Co")); |
1627 | |
1628 # ifndef hpux | |
1629 BC = (char *)TGETSTR("bc", &tp); | |
1630 UP = (char *)TGETSTR("up", &tp); | |
1631 p = TGETSTR("pc", &tp); | |
1632 if (p) | |
1633 PC = *p; | |
1634 # endif /* hpux */ | |
1635 } | |
1636 } | |
1637 else /* try == 0 || try == 2 */ | |
1638 #endif /* HAVE_TGETENT */ | |
1639 /* | |
1640 * Use builtin termcap | |
1641 */ | |
1642 { | |
1643 #ifdef HAVE_TGETENT | |
1644 /* | |
1645 * If builtin termcap was already used, there is no need to search | |
1646 * for the builtin termcap again, quit now. | |
1647 */ | |
1648 if (try == 2 && builtin_first && termcap_cleared) | |
1649 break; | |
1650 #endif | |
1651 /* | |
1652 * search for 'term' in builtin_termcaps[] | |
1653 */ | |
1654 termp = find_builtin_term(term); | |
1655 if (termp->bt_string == NULL) /* did not find it */ | |
1656 { | |
1657 #ifdef HAVE_TGETENT | |
1658 /* | |
1659 * If try == 0, first try the external termcap. If that is not | |
1660 * found we'll get back here with try == 2. | |
1661 * If termcap_cleared is set we used the external termcap, | |
1662 * don't complain about not finding the term in the builtin | |
1663 * termcap. | |
1664 */ | |
1665 if (try == 0) /* try external one */ | |
1666 continue; | |
1667 if (termcap_cleared) /* found in external termcap */ | |
1668 break; | |
1669 #endif | |
1670 | |
1671 mch_errmsg("\r\n"); | |
1672 if (error_msg != NULL) | |
1673 { | |
1674 mch_errmsg((char *)error_msg); | |
1675 mch_errmsg("\r\n"); | |
1676 } | |
1677 mch_errmsg("'"); | |
1678 mch_errmsg((char *)term); | |
1679 mch_errmsg(_("' not known. Available builtin terminals are:")); | |
1680 mch_errmsg("\r\n"); | |
1681 for (termp = &(builtin_termcaps[0]); termp->bt_string != NULL; | |
1682 ++termp) | |
1683 { | |
1684 if (termp->bt_entry == (int)KS_NAME) | |
1685 { | |
1686 #ifdef HAVE_TGETENT | |
1687 mch_errmsg(" builtin_"); | |
1688 #else | |
1689 mch_errmsg(" "); | |
1690 #endif | |
1691 mch_errmsg(termp->bt_string); | |
1692 mch_errmsg("\r\n"); | |
1693 } | |
1694 } | |
1695 /* when user typed :set term=xxx, quit here */ | |
1696 if (starting != NO_SCREEN) | |
1697 { | |
1698 screen_start(); /* don't know where cursor is now */ | |
1699 wait_return(TRUE); | |
1700 return FAIL; | |
1701 } | |
1702 term = DEFAULT_TERM; | |
1703 mch_errmsg(_("defaulting to '")); | |
1704 mch_errmsg((char *)term); | |
1705 mch_errmsg("'\r\n"); | |
1706 if (emsg_silent == 0) | |
1707 { | |
1708 screen_start(); /* don't know where cursor is now */ | |
1709 out_flush(); | |
11307
6e1c19d3de03
patch 8.0.0539: startup test fails on Mac
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1710 if (!is_not_a_term()) |
6e1c19d3de03
patch 8.0.0539: startup test fails on Mac
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1711 ui_delay(2000L, TRUE); |
7 | 1712 } |
694 | 1713 set_string_option_direct((char_u *)"term", -1, term, |
1714 OPT_FREE, 0); | |
7 | 1715 display_errors(); |
1716 } | |
1717 out_flush(); | |
1718 #ifdef HAVE_TGETENT | |
1719 if (!termcap_cleared) | |
1720 { | |
1721 #endif | |
1722 clear_termoptions(); /* clear old options */ | |
1723 #ifdef HAVE_TGETENT | |
1724 termcap_cleared = TRUE; | |
1725 } | |
1726 #endif | |
1727 parse_builtin_tcap(term); | |
1728 #ifdef FEAT_GUI | |
1729 if (term_is_gui(term)) | |
1730 { | |
1731 out_flush(); | |
1732 gui_init(); | |
1733 /* If starting the GUI failed, don't do any of the other | |
1734 * things for this terminal */ | |
1735 if (!gui.in_use) | |
1736 return FAIL; | |
1737 #ifdef HAVE_TGETENT | |
1738 break; /* don't try using external termcap */ | |
1739 #endif | |
1740 } | |
1741 #endif /* FEAT_GUI */ | |
1742 } | |
1743 #ifdef HAVE_TGETENT | |
1744 } | |
1745 #endif | |
1746 | |
1747 /* | |
1748 * special: There is no info in the termcap about whether the cursor | |
1749 * positioning is relative to the start of the screen or to the start of the | |
1750 * scrolling region. We just guess here. Only msdos pcterm is known to do it | |
1751 * relative. | |
1752 */ | |
1753 if (STRCMP(term, "pcterm") == 0) | |
1754 T_CCS = (char_u *)"yes"; | |
1755 else | |
1756 T_CCS = empty_option; | |
1757 | |
1758 #ifdef UNIX | |
1759 /* | |
1760 * Any "stty" settings override the default for t_kb from the termcap. | |
1761 * This is in os_unix.c, because it depends a lot on the version of unix that | |
1762 * is being used. | |
1763 * Don't do this when the GUI is active, it uses "t_kb" and "t_kD" directly. | |
1764 */ | |
1765 #ifdef FEAT_GUI | |
1766 if (!gui.in_use) | |
1767 #endif | |
1768 get_stty(); | |
1769 #endif | |
1770 | |
1771 /* | |
1772 * If the termcap has no entry for 'bs' and/or 'del' and the ioctl() also | |
1773 * didn't work, use the default CTRL-H | |
1774 * The default for t_kD is DEL, unless t_kb is DEL. | |
1775 * The vim_strsave'd strings are probably lost forever, well it's only two | |
1776 * bytes. Don't do this when the GUI is active, it uses "t_kb" and "t_kD" | |
1777 * directly. | |
1778 */ | |
1779 #ifdef FEAT_GUI | |
1780 if (!gui.in_use) | |
1781 #endif | |
1782 { | |
1783 bs_p = find_termcode((char_u *)"kb"); | |
1784 del_p = find_termcode((char_u *)"kD"); | |
1785 if (bs_p == NULL || *bs_p == NUL) | |
1786 add_termcode((char_u *)"kb", (bs_p = (char_u *)CTRL_H_STR), FALSE); | |
1787 if ((del_p == NULL || *del_p == NUL) && | |
1788 (bs_p == NULL || *bs_p != DEL)) | |
1789 add_termcode((char_u *)"kD", (char_u *)DEL_STR, FALSE); | |
1790 } | |
1791 | |
1792 #if defined(UNIX) || defined(VMS) | |
1793 term_is_xterm = vim_is_xterm(term); | |
1794 #endif | |
1795 | |
1796 #ifdef FEAT_MOUSE | |
1797 # if defined(UNIX) || defined(VMS) | |
1798 # ifdef FEAT_MOUSE_TTY | |
1799 /* | |
1800 * For Unix, set the 'ttymouse' option to the type of mouse to be used. | |
1801 * The termcode for the mouse is added as a side effect in option.c. | |
1802 */ | |
1803 { | |
11563
2547bbe6716e
patch 8.0.0664: mouse does not work in tmux
Christian Brabandt <cb@256bit.org>
parents:
11557
diff
changeset
|
1804 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
|
1805 |
7 | 1806 # ifdef FEAT_MOUSE_XTERM |
1623 | 1807 if (use_xterm_like_mouse(term)) |
7 | 1808 { |
1809 if (use_xterm_mouse()) | |
1810 p = NULL; /* keep existing value, might be "xterm2" */ | |
1811 else | |
1812 p = (char_u *)"xterm"; | |
1813 } | |
1814 # endif | |
1815 if (p != NULL) | |
3980 | 1816 { |
7 | 1817 set_option_value((char_u *)"ttym", 0L, p, 0); |
3980 | 1818 /* Reset the WAS_SET flag, 'ttymouse' can be set to "sgr" or |
1819 * "xterm2" in check_termcode(). */ | |
1820 reset_option_was_set((char_u *)"ttym"); | |
1821 } | |
7 | 1822 if (p == NULL |
1823 # ifdef FEAT_GUI | |
1824 || gui.in_use | |
1825 # endif | |
1826 ) | |
1827 check_mouse_termcode(); /* set mouse termcode anyway */ | |
1828 } | |
1829 # endif | |
1830 # else | |
1831 set_mouse_termcode(KS_MOUSE, (char_u *)"\233M"); | |
1832 # endif | |
1833 #endif /* FEAT_MOUSE */ | |
1834 | |
1835 #ifdef USE_TERM_CONSOLE | |
1836 /* DEFAULT_TERM indicates that it is the machine console. */ | |
1837 if (STRCMP(term, DEFAULT_TERM) != 0) | |
1838 term_console = FALSE; | |
1839 else | |
1840 { | |
1841 term_console = TRUE; | |
1842 # ifdef AMIGA | |
1843 win_resize_on(); /* enable window resizing reports */ | |
1844 # endif | |
1845 } | |
1846 #endif | |
1847 | |
1848 #if defined(UNIX) || defined(VMS) | |
1849 /* | |
1850 * 'ttyfast' is default on for xterm, iris-ansi and a few others. | |
1851 */ | |
1852 if (vim_is_fastterm(term)) | |
1853 p_tf = TRUE; | |
1854 #endif | |
1855 #ifdef USE_TERM_CONSOLE | |
1856 /* | |
1857 * 'ttyfast' is default on consoles | |
1858 */ | |
1859 if (term_console) | |
1860 p_tf = TRUE; | |
1861 #endif | |
1862 | |
1863 ttest(TRUE); /* make sure we have a valid set of terminal codes */ | |
1864 | |
1865 full_screen = TRUE; /* we can use termcap codes from now on */ | |
1866 set_term_defaults(); /* use current values as defaults */ | |
1867 #ifdef FEAT_TERMRESPONSE | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
1868 LOG_TR("setting crv_status to CRV_GET"); |
7 | 1869 crv_status = CRV_GET; /* Get terminal version later */ |
1870 #endif | |
1871 | |
1872 /* | |
1873 * Initialize the terminal with the appropriate termcap codes. | |
1874 * Set the mouse and window title if possible. | |
1875 * Don't do this when starting, need to parse the .vimrc first, because it | |
1876 * may redefine t_TI etc. | |
1877 */ | |
1878 if (starting != NO_SCREEN) | |
1879 { | |
1880 starttermcap(); /* may change terminal mode */ | |
1881 #ifdef FEAT_MOUSE | |
1882 setmouse(); /* may start using the mouse */ | |
1883 #endif | |
1884 #ifdef FEAT_TITLE | |
1885 maketitle(); /* may display window title */ | |
1886 #endif | |
1887 } | |
1888 | |
1889 /* display initial screen after ttest() checking. jw. */ | |
1890 if (width <= 0 || height <= 0) | |
1891 { | |
1892 /* termcap failed to report size */ | |
1893 /* set defaults, in case ui_get_shellsize() also fails */ | |
1894 width = 80; | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
1895 #if defined(WIN3264) |
7 | 1896 height = 25; /* console is often 25 lines */ |
1897 #else | |
1898 height = 24; /* most terminals are 24 lines */ | |
1899 #endif | |
1900 } | |
1901 set_shellsize(width, height, FALSE); /* may change Rows */ | |
1902 if (starting != NO_SCREEN) | |
1903 { | |
1904 if (scroll_region) | |
1905 scroll_region_reset(); /* In case Rows changed */ | |
1906 check_map_keycodes(); /* check mappings for terminal codes used */ | |
1907 | |
1908 #ifdef FEAT_AUTOCMD | |
1909 { | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9125
diff
changeset
|
1910 bufref_T old_curbuf; |
7 | 1911 |
1912 /* | |
1913 * Execute the TermChanged autocommands for each buffer that is | |
1914 * loaded. | |
1915 */ | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9125
diff
changeset
|
1916 set_bufref(&old_curbuf, curbuf); |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9628
diff
changeset
|
1917 FOR_ALL_BUFFERS(curbuf) |
7 | 1918 { |
1919 if (curbuf->b_ml.ml_mfp != NULL) | |
1920 apply_autocmds(EVENT_TERMCHANGED, NULL, NULL, FALSE, | |
1921 curbuf); | |
1922 } | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9125
diff
changeset
|
1923 if (bufref_valid(&old_curbuf)) |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9125
diff
changeset
|
1924 curbuf = old_curbuf.br_buf; |
7 | 1925 } |
1926 #endif | |
1927 } | |
1928 | |
1929 #ifdef FEAT_TERMRESPONSE | |
1930 may_req_termresponse(); | |
1931 #endif | |
1932 | |
1933 return OK; | |
1934 } | |
1935 | |
1936 #if defined(FEAT_MOUSE) || defined(PROTO) | |
1937 | |
1938 # ifdef FEAT_MOUSE_TTY | |
1939 # define HMT_NORMAL 1 | |
1940 # define HMT_NETTERM 2 | |
1941 # define HMT_DEC 4 | |
1942 # define HMT_JSBTERM 8 | |
1943 # define HMT_PTERM 16 | |
3176 | 1944 # define HMT_URXVT 32 |
3746 | 1945 # define HMT_SGR 64 |
11563
2547bbe6716e
patch 8.0.0664: mouse does not work in tmux
Christian Brabandt <cb@256bit.org>
parents:
11557
diff
changeset
|
1946 # define HMT_SGR_REL 128 |
7 | 1947 static int has_mouse_termcode = 0; |
1948 # endif | |
1949 | |
1623 | 1950 # if (!defined(UNIX) || defined(FEAT_MOUSE_TTY)) || defined(PROTO) |
7 | 1951 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1952 set_mouse_termcode( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1953 int n, /* KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1954 char_u *s) |
7 | 1955 { |
1956 char_u name[2]; | |
1957 | |
1958 name[0] = n; | |
1959 name[1] = KE_FILLER; | |
1960 add_termcode(name, s, FALSE); | |
1961 # ifdef FEAT_MOUSE_TTY | |
1962 # ifdef FEAT_MOUSE_JSB | |
1963 if (n == KS_JSBTERM_MOUSE) | |
1964 has_mouse_termcode |= HMT_JSBTERM; | |
1965 else | |
1966 # endif | |
1967 # ifdef FEAT_MOUSE_NET | |
1968 if (n == KS_NETTERM_MOUSE) | |
1969 has_mouse_termcode |= HMT_NETTERM; | |
1970 else | |
1971 # endif | |
1972 # ifdef FEAT_MOUSE_DEC | |
1973 if (n == KS_DEC_MOUSE) | |
1974 has_mouse_termcode |= HMT_DEC; | |
1975 else | |
1976 # endif | |
1977 # ifdef FEAT_MOUSE_PTERM | |
1978 if (n == KS_PTERM_MOUSE) | |
1979 has_mouse_termcode |= HMT_PTERM; | |
1980 else | |
1981 # endif | |
3176 | 1982 # ifdef FEAT_MOUSE_URXVT |
1983 if (n == KS_URXVT_MOUSE) | |
1984 has_mouse_termcode |= HMT_URXVT; | |
1985 else | |
1986 # endif | |
3746 | 1987 # ifdef FEAT_MOUSE_SGR |
1988 if (n == KS_SGR_MOUSE) | |
1989 has_mouse_termcode |= HMT_SGR; | |
11563
2547bbe6716e
patch 8.0.0664: mouse does not work in tmux
Christian Brabandt <cb@256bit.org>
parents:
11557
diff
changeset
|
1990 else if (n == KS_SGR_MOUSE_RELEASE) |
2547bbe6716e
patch 8.0.0664: mouse does not work in tmux
Christian Brabandt <cb@256bit.org>
parents:
11557
diff
changeset
|
1991 has_mouse_termcode |= HMT_SGR_REL; |
3746 | 1992 else |
1993 # endif | |
7 | 1994 has_mouse_termcode |= HMT_NORMAL; |
1995 # endif | |
1996 } | |
1997 # endif | |
1998 | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7307
diff
changeset
|
1999 # if ((defined(UNIX) || defined(VMS)) \ |
1623 | 2000 && defined(FEAT_MOUSE_TTY)) || defined(PROTO) |
7 | 2001 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2002 del_mouse_termcode( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2003 int n) /* KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE */ |
7 | 2004 { |
2005 char_u name[2]; | |
2006 | |
2007 name[0] = n; | |
2008 name[1] = KE_FILLER; | |
2009 del_termcode(name); | |
2010 # ifdef FEAT_MOUSE_TTY | |
2011 # ifdef FEAT_MOUSE_JSB | |
2012 if (n == KS_JSBTERM_MOUSE) | |
2013 has_mouse_termcode &= ~HMT_JSBTERM; | |
2014 else | |
2015 # endif | |
2016 # ifdef FEAT_MOUSE_NET | |
2017 if (n == KS_NETTERM_MOUSE) | |
2018 has_mouse_termcode &= ~HMT_NETTERM; | |
2019 else | |
2020 # endif | |
2021 # ifdef FEAT_MOUSE_DEC | |
2022 if (n == KS_DEC_MOUSE) | |
2023 has_mouse_termcode &= ~HMT_DEC; | |
2024 else | |
2025 # endif | |
2026 # ifdef FEAT_MOUSE_PTERM | |
2027 if (n == KS_PTERM_MOUSE) | |
2028 has_mouse_termcode &= ~HMT_PTERM; | |
2029 else | |
2030 # endif | |
3176 | 2031 # ifdef FEAT_MOUSE_URXVT |
2032 if (n == KS_URXVT_MOUSE) | |
2033 has_mouse_termcode &= ~HMT_URXVT; | |
2034 else | |
2035 # endif | |
3746 | 2036 # ifdef FEAT_MOUSE_SGR |
2037 if (n == KS_SGR_MOUSE) | |
2038 has_mouse_termcode &= ~HMT_SGR; | |
11563
2547bbe6716e
patch 8.0.0664: mouse does not work in tmux
Christian Brabandt <cb@256bit.org>
parents:
11557
diff
changeset
|
2039 else if (n == KS_SGR_MOUSE_RELEASE) |
2547bbe6716e
patch 8.0.0664: mouse does not work in tmux
Christian Brabandt <cb@256bit.org>
parents:
11557
diff
changeset
|
2040 has_mouse_termcode &= ~HMT_SGR_REL; |
3746 | 2041 else |
2042 # endif | |
7 | 2043 has_mouse_termcode &= ~HMT_NORMAL; |
2044 # endif | |
2045 } | |
2046 # endif | |
2047 #endif | |
2048 | |
2049 #ifdef HAVE_TGETENT | |
2050 /* | |
2051 * Call tgetent() | |
2052 * Return error message if it fails, NULL if it's OK. | |
2053 */ | |
2054 static char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2055 tgetent_error(char_u *tbuf, char_u *term) |
7 | 2056 { |
2057 int i; | |
2058 | |
2059 i = TGETENT(tbuf, term); | |
2060 if (i < 0 /* -1 is always an error */ | |
2061 # ifdef TGETENT_ZERO_ERR | |
2062 || i == 0 /* sometimes zero is also an error */ | |
2063 # endif | |
2064 ) | |
2065 { | |
2066 /* On FreeBSD tputs() gets a SEGV after a tgetent() which fails. Call | |
2067 * tgetent() with the always existing "dumb" entry to avoid a crash or | |
2068 * hang. */ | |
2069 (void)TGETENT(tbuf, "dumb"); | |
2070 | |
2071 if (i < 0) | |
2072 # ifdef TGETENT_ZERO_ERR | |
2073 return (char_u *)_("E557: Cannot open termcap file"); | |
2074 if (i == 0) | |
2075 # endif | |
2076 #ifdef TERMINFO | |
2077 return (char_u *)_("E558: Terminal entry not found in terminfo"); | |
2078 #else | |
2079 return (char_u *)_("E559: Terminal entry not found in termcap"); | |
2080 #endif | |
2081 } | |
2082 return NULL; | |
2083 } | |
2084 | |
2085 /* | |
2086 * Some versions of tgetstr() have been reported to return -1 instead of NULL. | |
2087 * Fix that here. | |
2088 */ | |
2089 static char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2090 vim_tgetstr(char *s, char_u **pp) |
7 | 2091 { |
2092 char *p; | |
2093 | |
2094 p = tgetstr(s, (char **)pp); | |
2095 if (p == (char *)-1) | |
2096 p = NULL; | |
2097 return (char_u *)p; | |
2098 } | |
2099 #endif /* HAVE_TGETENT */ | |
2100 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
2101 #if defined(HAVE_TGETENT) && (defined(UNIX) || defined(VMS) || defined(MACOS_X)) |
7 | 2102 /* |
2103 * Get Columns and Rows from the termcap. Used after a window signal if the | |
2104 * ioctl() fails. It doesn't make sense to call tgetent each time if the "co" | |
2105 * and "li" entries never change. But on some systems this works. | |
2106 * Errors while getting the entries are ignored. | |
2107 */ | |
2108 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2109 getlinecol( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2110 long *cp, /* pointer to columns */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2111 long *rp) /* pointer to rows */ |
7 | 2112 { |
2113 char_u tbuf[TBUFSZ]; | |
2114 | |
2115 if (T_NAME != NULL && *T_NAME != NUL && tgetent_error(tbuf, T_NAME) == NULL) | |
2116 { | |
2117 if (*cp == 0) | |
2118 *cp = tgetnum("co"); | |
2119 if (*rp == 0) | |
2120 *rp = tgetnum("li"); | |
2121 } | |
2122 } | |
2123 #endif /* defined(HAVE_TGETENT) && defined(UNIX) */ | |
2124 | |
2125 /* | |
2126 * Get a string entry from the termcap and add it to the list of termcodes. | |
2127 * Used for <t_xx> special keys. | |
2128 * Give an error message for failure when not sourcing. | |
2129 * If force given, replace an existing entry. | |
2130 * Return FAIL if the entry was not found, OK if the entry was added. | |
2131 */ | |
2132 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2133 add_termcap_entry(char_u *name, int force) |
7 | 2134 { |
2135 char_u *term; | |
2136 int key; | |
2137 struct builtin_term *termp; | |
2138 #ifdef HAVE_TGETENT | |
2139 char_u *string; | |
2140 int i; | |
2141 int builtin_first; | |
2142 char_u tbuf[TBUFSZ]; | |
2143 char_u tstrbuf[TBUFSZ]; | |
2144 char_u *tp = tstrbuf; | |
2145 char_u *error_msg = NULL; | |
2146 #endif | |
2147 | |
2148 /* | |
2149 * If the GUI is running or will start in a moment, we only support the keys | |
2150 * that the GUI can produce. | |
2151 */ | |
2152 #ifdef FEAT_GUI | |
2153 if (gui.in_use || gui.starting) | |
2154 return gui_mch_haskey(name); | |
2155 #endif | |
2156 | |
2157 if (!force && find_termcode(name) != NULL) /* it's already there */ | |
2158 return OK; | |
2159 | |
2160 term = T_NAME; | |
2161 if (term == NULL || *term == NUL) /* 'term' not defined yet */ | |
2162 return FAIL; | |
2163 | |
2164 if (term_is_builtin(term)) /* name starts with "builtin_" */ | |
2165 { | |
2166 term += 8; | |
2167 #ifdef HAVE_TGETENT | |
2168 builtin_first = TRUE; | |
2169 #endif | |
2170 } | |
2171 #ifdef HAVE_TGETENT | |
2172 else | |
2173 builtin_first = p_tbi; | |
2174 #endif | |
2175 | |
2176 #ifdef HAVE_TGETENT | |
2177 /* | |
2178 * We can get the entry from the builtin termcap and from the external one. | |
2179 * If 'ttybuiltin' is on or the terminal name starts with "builtin_", try | |
2180 * builtin termcap first. | |
2181 * If 'ttybuiltin' is off, try external termcap first. | |
2182 */ | |
2183 for (i = 0; i < 2; ++i) | |
2184 { | |
7210
08b50e436093
commit https://github.com/vim/vim/commit/98b30a473a58ae98c280e0383c8b1e08c0ebced5
Christian Brabandt <cb@256bit.org>
parents:
6901
diff
changeset
|
2185 if ((!builtin_first) == i) |
7 | 2186 #endif |
2187 /* | |
2188 * Search in builtin termcap | |
2189 */ | |
2190 { | |
2191 termp = find_builtin_term(term); | |
2192 if (termp->bt_string != NULL) /* found it */ | |
2193 { | |
2194 key = TERMCAP2KEY(name[0], name[1]); | |
2195 while (termp->bt_entry != (int)KS_NAME) | |
2196 { | |
2197 if ((int)termp->bt_entry == key) | |
2198 { | |
2199 add_termcode(name, (char_u *)termp->bt_string, | |
2200 term_is_8bit(term)); | |
2201 return OK; | |
2202 } | |
2203 ++termp; | |
2204 } | |
2205 } | |
2206 } | |
2207 #ifdef HAVE_TGETENT | |
2208 else | |
2209 /* | |
2210 * Search in external termcap | |
2211 */ | |
2212 { | |
2213 error_msg = tgetent_error(tbuf, term); | |
2214 if (error_msg == NULL) | |
2215 { | |
2216 string = TGETSTR((char *)name, &tp); | |
2217 if (string != NULL && *string != NUL) | |
2218 { | |
2219 add_termcode(name, string, FALSE); | |
2220 return OK; | |
2221 } | |
2222 } | |
2223 } | |
2224 } | |
2225 #endif | |
2226 | |
2227 if (sourcing_name == NULL) | |
2228 { | |
2229 #ifdef HAVE_TGETENT | |
2230 if (error_msg != NULL) | |
2231 EMSG(error_msg); | |
2232 else | |
2233 #endif | |
2234 EMSG2(_("E436: No \"%s\" entry in termcap"), name); | |
2235 } | |
2236 return FAIL; | |
2237 } | |
2238 | |
2239 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2240 term_is_builtin(char_u *name) |
7 | 2241 { |
2242 return (STRNCMP(name, "builtin_", (size_t)8) == 0); | |
2243 } | |
2244 | |
2245 /* | |
2246 * Return TRUE if terminal "name" uses CSI instead of <Esc>[. | |
2247 * Assume that the terminal is using 8-bit controls when the name contains | |
2248 * "8bit", like in "xterm-8bit". | |
2249 */ | |
2250 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2251 term_is_8bit(char_u *name) |
7 | 2252 { |
2253 return (detected_8bit || strstr((char *)name, "8bit") != NULL); | |
2254 } | |
2255 | |
2256 /* | |
2257 * Translate terminal control chars from 7-bit to 8-bit: | |
2258 * <Esc>[ -> CSI | |
2259 * <Esc>] -> <M-C-]> | |
2260 * <Esc>O -> <M-C-O> | |
2261 */ | |
2262 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2263 term_7to8bit(char_u *p) |
7 | 2264 { |
2265 if (*p == ESC) | |
2266 { | |
2267 if (p[1] == '[') | |
2268 return CSI; | |
2269 if (p[1] == ']') | |
6901 | 2270 return OSC; |
7 | 2271 if (p[1] == 'O') |
2272 return 0x8f; | |
2273 } | |
2274 return 0; | |
2275 } | |
2276 | |
2277 #ifdef FEAT_GUI | |
2278 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2279 term_is_gui(char_u *name) |
7 | 2280 { |
2281 return (STRCMP(name, "builtin_gui") == 0 || STRCMP(name, "gui") == 0); | |
2282 } | |
2283 #endif | |
2284 | |
2285 #if !defined(HAVE_TGETENT) || defined(AMIGA) || defined(PROTO) | |
2286 | |
2287 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2288 tltoa(unsigned long i) |
7 | 2289 { |
2290 static char_u buf[16]; | |
2291 char_u *p; | |
2292 | |
2293 p = buf + 15; | |
2294 *p = '\0'; | |
2295 do | |
2296 { | |
2297 --p; | |
2298 *p = (char_u) (i % 10 + '0'); | |
2299 i /= 10; | |
2300 } | |
2301 while (i > 0 && p > buf); | |
2302 return p; | |
2303 } | |
2304 #endif | |
2305 | |
2306 #ifndef HAVE_TGETENT | |
2307 | |
2308 /* | |
2309 * minimal tgoto() implementation. | |
2310 * no padding and we only parse for %i %d and %+char | |
2311 */ | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
2312 static char *tgoto(char *, int, int); |
298 | 2313 |
2314 static char * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2315 tgoto(char *cm, int x, int y) |
7 | 2316 { |
2317 static char buf[30]; | |
2318 char *p, *s, *e; | |
2319 | |
2320 if (!cm) | |
2321 return "OOPS"; | |
2322 e = buf + 29; | |
2323 for (s = buf; s < e && *cm; cm++) | |
2324 { | |
2325 if (*cm != '%') | |
2326 { | |
2327 *s++ = *cm; | |
2328 continue; | |
2329 } | |
2330 switch (*++cm) | |
2331 { | |
2332 case 'd': | |
2333 p = (char *)tltoa((unsigned long)y); | |
2334 y = x; | |
2335 while (*p) | |
2336 *s++ = *p++; | |
2337 break; | |
2338 case 'i': | |
2339 x++; | |
2340 y++; | |
2341 break; | |
2342 case '+': | |
2343 *s++ = (char)(*++cm + y); | |
2344 y = x; | |
2345 break; | |
2346 case '%': | |
2347 *s++ = *cm; | |
2348 break; | |
2349 default: | |
2350 return "OOPS"; | |
2351 } | |
2352 } | |
2353 *s = '\0'; | |
2354 return buf; | |
2355 } | |
2356 | |
2357 #endif /* HAVE_TGETENT */ | |
2358 | |
2359 /* | |
2360 * Set the terminal name and initialize the terminal options. | |
2361 * If "name" is NULL or empty, get the terminal name from the environment. | |
2362 * If that fails, use the default terminal name. | |
2363 */ | |
2364 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2365 termcapinit(char_u *name) |
7 | 2366 { |
2367 char_u *term; | |
2368 | |
2369 if (name != NULL && *name == NUL) | |
2370 name = NULL; /* empty name is equal to no name */ | |
2371 term = name; | |
2372 | |
2373 #ifdef __BEOS__ | |
2374 /* | |
2375 * TERM environment variable is normally set to 'ansi' on the Bebox; | |
2376 * Since the BeBox doesn't quite support full ANSI yet, we use our | |
2377 * own custom 'ansi-beos' termcap instead, unless the -T option has | |
2378 * been given on the command line. | |
2379 */ | |
2380 if (term == NULL | |
2381 && strcmp((char *)mch_getenv((char_u *)"TERM"), "ansi") == 0) | |
2382 term = DEFAULT_TERM; | |
2383 #endif | |
2384 #ifndef MSWIN | |
2385 if (term == NULL) | |
2386 term = mch_getenv((char_u *)"TERM"); | |
2387 #endif | |
2388 if (term == NULL || *term == NUL) | |
2389 term = DEFAULT_TERM; | |
694 | 2390 set_string_option_direct((char_u *)"term", -1, term, OPT_FREE, 0); |
7 | 2391 |
2392 /* Set the default terminal name. */ | |
2393 set_string_default("term", term); | |
2394 set_string_default("ttytype", term); | |
2395 | |
2396 /* | |
2397 * Avoid using "term" here, because the next mch_getenv() may overwrite it. | |
2398 */ | |
2399 set_termname(T_NAME != NULL ? T_NAME : term); | |
2400 } | |
2401 | |
2402 /* | |
2403 * the number of calls to ui_write is reduced by using the buffer "out_buf" | |
2404 */ | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
2405 #define OUT_SIZE 2047 |
7 | 2406 /* Add one to allow mch_write() in os_win32.c to append a NUL */ |
2407 static char_u out_buf[OUT_SIZE + 1]; | |
2408 static int out_pos = 0; /* number of chars in out_buf */ | |
2409 | |
2410 /* | |
2411 * out_flush(): flush the output buffer | |
2412 */ | |
2413 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2414 out_flush(void) |
7 | 2415 { |
2416 int len; | |
2417 | |
2418 if (out_pos != 0) | |
2419 { | |
2420 /* set out_pos to 0 before ui_write, to avoid recursiveness */ | |
2421 len = out_pos; | |
2422 out_pos = 0; | |
2423 ui_write(out_buf, len); | |
2424 } | |
2425 } | |
2426 | |
2427 #if defined(FEAT_MBYTE) || defined(PROTO) | |
2428 /* | |
2429 * Sometimes a byte out of a multi-byte character is written with out_char(). | |
2430 * To avoid flushing half of the character, call this function first. | |
2431 */ | |
2432 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2433 out_flush_check(void) |
7 | 2434 { |
2435 if (enc_dbcs != 0 && out_pos >= OUT_SIZE - MB_MAXBYTES) | |
2436 out_flush(); | |
2437 } | |
2438 #endif | |
2439 | |
2440 #ifdef FEAT_GUI | |
2441 /* | |
2442 * out_trash(): Throw away the contents of the output buffer | |
2443 */ | |
2444 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2445 out_trash(void) |
7 | 2446 { |
2447 out_pos = 0; | |
2448 } | |
2449 #endif | |
2450 | |
2451 /* | |
2452 * out_char(c): put a byte into the output buffer. | |
2453 * Flush it if it becomes full. | |
2454 * This should not be used for outputting text on the screen (use functions | |
2455 * like msg_puts() and screen_putchar() for that). | |
2456 */ | |
2457 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2458 out_char(unsigned c) |
7 | 2459 { |
2460 #if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(MACOS_X_UNIX) | |
2461 if (c == '\n') /* turn LF into CR-LF (CRMOD doesn't seem to do this) */ | |
2462 out_char('\r'); | |
2463 #endif | |
2464 | |
2465 out_buf[out_pos++] = c; | |
2466 | |
2467 /* For testing we flush each time. */ | |
2468 if (out_pos >= OUT_SIZE || p_wd) | |
2469 out_flush(); | |
2470 } | |
2471 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
2472 static void out_char_nf(unsigned); |
7 | 2473 |
2474 /* | |
2475 * out_char_nf(c): like out_char(), but don't flush when p_wd is set | |
2476 */ | |
2477 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2478 out_char_nf(unsigned c) |
7 | 2479 { |
2480 #if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(MACOS_X_UNIX) | |
2481 if (c == '\n') /* turn LF into CR-LF (CRMOD doesn't seem to do this) */ | |
2482 out_char_nf('\r'); | |
2483 #endif | |
2484 | |
2485 out_buf[out_pos++] = c; | |
2486 | |
2487 if (out_pos >= OUT_SIZE) | |
2488 out_flush(); | |
2489 } | |
2490 | |
2237
770485470e59
Add a few #ifdefs to exclude functions that are not used. (Domnique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
1941
diff
changeset
|
2491 #if defined(FEAT_TITLE) || defined(FEAT_MOUSE_TTY) || defined(FEAT_GUI) \ |
770485470e59
Add a few #ifdefs to exclude functions that are not used. (Domnique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
1941
diff
changeset
|
2492 || defined(FEAT_TERMRESPONSE) || defined(PROTO) |
7 | 2493 /* |
2494 * A never-padding out_str. | |
2495 * use this whenever you don't want to run the string through tputs. | |
2496 * tputs above is harmless, but tputs from the termcap library | |
2497 * is likely to strip off leading digits, that it mistakes for padding | |
2498 * information, and "%i", "%d", etc. | |
2499 * This should only be used for writing terminal codes, not for outputting | |
2500 * normal text (use functions like msg_puts() and screen_putchar() for that). | |
2501 */ | |
2502 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2503 out_str_nf(char_u *s) |
7 | 2504 { |
2505 if (out_pos > OUT_SIZE - 20) /* avoid terminal strings being split up */ | |
2506 out_flush(); | |
2507 while (*s) | |
2508 out_char_nf(*s++); | |
2509 | |
2510 /* For testing we write one string at a time. */ | |
2511 if (p_wd) | |
2512 out_flush(); | |
2513 } | |
2237
770485470e59
Add a few #ifdefs to exclude functions that are not used. (Domnique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
1941
diff
changeset
|
2514 #endif |
7 | 2515 |
2516 /* | |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2517 * 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
|
2518 * 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
|
2519 * it at the wrong time. |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2520 * Note: Only for terminal strings. |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2521 */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2522 void |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2523 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
|
2524 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2525 if (s != NULL && *s) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2526 { |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2527 #ifdef HAVE_TGETENT |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2528 char_u *p; |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2529 #endif |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2530 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2531 #ifdef FEAT_GUI |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2532 /* Don't use tputs() when GUI is used, ncurses crashes. */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2533 if (gui.in_use) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2534 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2535 out_str_nf(s); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2536 return; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2537 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2538 #endif |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2539 if (out_pos > OUT_SIZE - 20) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2540 out_flush(); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2541 #ifdef HAVE_TGETENT |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2542 for (p = s; *s; ++s) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2543 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2544 /* flush just before delay command */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2545 if (*s == '$' && *(s + 1) == '<') |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2546 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2547 char_u save_c = *s; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2548 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
|
2549 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2550 *s = NUL; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2551 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
|
2552 *s = save_c; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2553 out_flush(); |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2554 # ifdef ELAPSED_FUNC |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2555 /* Only sleep here if we can limit this happening in |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2556 * vim_beep(). */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2557 p = vim_strchr(s, '>'); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2558 if (p == NULL || duration <= 0) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2559 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2560 /* can't parse the time, don't sleep here */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2561 p = s; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2562 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2563 else |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2564 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2565 ++p; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2566 do_sleep(duration); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2567 } |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2568 # else |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2569 /* Rely on the terminal library to sleep. */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2570 p = s; |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2571 # endif |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2572 break; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2573 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2574 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2575 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
|
2576 #else |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2577 while (*s) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2578 out_char_nf(*s++); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2579 #endif |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2580 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2581 /* For testing we write one string at a time. */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2582 if (p_wd) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2583 out_flush(); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2584 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2585 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2586 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2587 /* |
7 | 2588 * out_str(s): Put a character string a byte at a time into the output buffer. |
2589 * If HAVE_TGETENT is defined use the termcap parser. (jw) | |
2590 * This should only be used for writing terminal codes, not for outputting | |
2591 * normal text (use functions like msg_puts() and screen_putchar() for that). | |
2592 */ | |
2593 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2594 out_str(char_u *s) |
7 | 2595 { |
2596 if (s != NULL && *s) | |
2597 { | |
2598 #ifdef FEAT_GUI | |
2599 /* Don't use tputs() when GUI is used, ncurses crashes. */ | |
2600 if (gui.in_use) | |
2601 { | |
2602 out_str_nf(s); | |
2603 return; | |
2604 } | |
2605 #endif | |
2606 /* avoid terminal strings being split up */ | |
2607 if (out_pos > OUT_SIZE - 20) | |
2608 out_flush(); | |
2609 #ifdef HAVE_TGETENT | |
2610 tputs((char *)s, 1, TPUTSFUNCAST out_char_nf); | |
2611 #else | |
2612 while (*s) | |
2613 out_char_nf(*s++); | |
2614 #endif | |
2615 | |
2616 /* For testing we write one string at a time. */ | |
2617 if (p_wd) | |
2618 out_flush(); | |
2619 } | |
2620 } | |
2621 | |
2622 /* | |
2623 * cursor positioning using termcap parser. (jw) | |
2624 */ | |
2625 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2626 term_windgoto(int row, int col) |
7 | 2627 { |
2628 OUT_STR(tgoto((char *)T_CM, col, row)); | |
2629 } | |
2630 | |
2631 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2632 term_cursor_right(int i) |
7 | 2633 { |
2634 OUT_STR(tgoto((char *)T_CRI, 0, i)); | |
2635 } | |
2636 | |
2637 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2638 term_append_lines(int line_count) |
7 | 2639 { |
2640 OUT_STR(tgoto((char *)T_CAL, 0, line_count)); | |
2641 } | |
2642 | |
2643 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2644 term_delete_lines(int line_count) |
7 | 2645 { |
2646 OUT_STR(tgoto((char *)T_CDL, 0, line_count)); | |
2647 } | |
2648 | |
2649 #if defined(HAVE_TGETENT) || defined(PROTO) | |
2650 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2651 term_set_winpos(int x, int y) |
7 | 2652 { |
2653 /* Can't handle a negative value here */ | |
2654 if (x < 0) | |
2655 x = 0; | |
2656 if (y < 0) | |
2657 y = 0; | |
2658 OUT_STR(tgoto((char *)T_CWP, y, x)); | |
2659 } | |
2660 | |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2661 # 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
|
2662 /* |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2663 * 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
|
2664 */ |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2665 static int |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2666 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
|
2667 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2668 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
|
2669 && termcap_active |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2670 # ifdef UNIX |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2671 && (is_not_a_term() || (isatty(1) && isatty(read_cmd_fd))) |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2672 # endif |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2673 && p_ek; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2674 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2675 |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2676 static int winpos_x; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2677 static int winpos_y; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2678 static int waiting_for_winpos = FALSE; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2679 |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2680 /* |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2681 * 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
|
2682 * 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
|
2683 */ |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2684 int |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2685 term_get_winpos(int *x, int *y) |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2686 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2687 int count = 0; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2688 |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2689 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
|
2690 return FAIL; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2691 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
|
2692 winpos_y = -1; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2693 waiting_for_winpos = TRUE; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2694 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
|
2695 out_flush(); |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2696 |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2697 /* Try reading the result for 100 msec. */ |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2698 while (count++ < 10) |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2699 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2700 (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
|
2701 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
|
2702 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2703 *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
|
2704 *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
|
2705 waiting_for_winpos = FALSE; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2706 return OK; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2707 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2708 ui_delay(10, FALSE); |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2709 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2710 waiting_for_winpos = FALSE; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2711 return FALSE; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2712 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2713 # endif |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2714 |
7 | 2715 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2716 term_set_winsize(int width, int height) |
7 | 2717 { |
2718 OUT_STR(tgoto((char *)T_CWS, height, width)); | |
2719 } | |
2720 #endif | |
2721 | |
2722 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2723 term_fg_color(int n) |
7 | 2724 { |
2725 /* Use "AF" termcap entry if present, "Sf" entry otherwise */ | |
2726 if (*T_CAF) | |
2727 term_color(T_CAF, n); | |
2728 else if (*T_CSF) | |
2729 term_color(T_CSF, n); | |
2730 } | |
2731 | |
2732 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2733 term_bg_color(int n) |
7 | 2734 { |
2735 /* Use "AB" termcap entry if present, "Sb" entry otherwise */ | |
2736 if (*T_CAB) | |
2737 term_color(T_CAB, n); | |
2738 else if (*T_CSB) | |
2739 term_color(T_CSB, n); | |
2740 } | |
2741 | |
2742 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2743 term_color(char_u *s, int n) |
7 | 2744 { |
2745 char buf[20]; | |
2746 int i = 2; /* index in s[] just after <Esc>[ or CSI */ | |
2747 | |
2748 /* Special handling of 16 colors, because termcap can't handle it */ | |
2749 /* Also accept "\e[3%dm" for TERMINFO, it is sometimes used */ | |
2750 /* Also accept CSI instead of <Esc>[ */ | |
2751 if (n >= 8 && t_colors >= 16 | |
2752 && ((s[0] == ESC && s[1] == '[') || (s[0] == CSI && (i = 1) == 1)) | |
2753 && s[i] != NUL | |
2754 && (STRCMP(s + i + 1, "%p1%dm") == 0 | |
2755 || STRCMP(s + i + 1, "%dm") == 0) | |
2756 && (s[i] == '3' || s[i] == '4')) | |
2757 { | |
2758 #ifdef TERMINFO | |
9068
0a3bc9fdea20
commit https://github.com/vim/vim/commit/827b165b2aebad2cfe98cc6d5804c6c0fe8afd89
Christian Brabandt <cb@256bit.org>
parents:
9027
diff
changeset
|
2759 char *format = "%s%s%%p1%%dm"; |
7 | 2760 #else |
9068
0a3bc9fdea20
commit https://github.com/vim/vim/commit/827b165b2aebad2cfe98cc6d5804c6c0fe8afd89
Christian Brabandt <cb@256bit.org>
parents:
9027
diff
changeset
|
2761 char *format = "%s%s%%dm"; |
7 | 2762 #endif |
9068
0a3bc9fdea20
commit https://github.com/vim/vim/commit/827b165b2aebad2cfe98cc6d5804c6c0fe8afd89
Christian Brabandt <cb@256bit.org>
parents:
9027
diff
changeset
|
2763 sprintf(buf, format, |
7 | 2764 i == 2 ? IF_EB("\033[", ESC_STR "[") : "\233", |
2765 s[i] == '3' ? (n >= 16 ? "38;5;" : "9") | |
2766 : (n >= 16 ? "48;5;" : "10")); | |
2767 OUT_STR(tgoto(buf, 0, n >= 16 ? n : n - 8)); | |
2768 } | |
2769 else | |
2770 OUT_STR(tgoto((char *)s, 0, n)); | |
2771 } | |
2772 | |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
2773 #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
|
2774 |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2775 #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
|
2776 #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
|
2777 #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
|
2778 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2779 static void |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2780 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
|
2781 { |
8975
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
2782 #define MAX_COLOR_STR_LEN 100 |
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
2783 char buf[MAX_COLOR_STR_LEN]; |
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
2784 |
8981
3b51b0aeb9a3
commit https://github.com/vim/vim/commit/a1c487eef71d1673e57511453009de9cb4c9af51
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
2785 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
|
2786 (char *)s, RED(rgb), GREEN(rgb), BLUE(rgb)); |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2787 OUT_STR(buf); |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2788 } |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2789 |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2790 void |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2791 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
|
2792 { |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2793 term_rgb_color(T_8F, rgb); |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2794 } |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2795 |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2796 void |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2797 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
|
2798 { |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2799 term_rgb_color(T_8B, rgb); |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2800 } |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2801 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2802 |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7307
diff
changeset
|
2803 #if (defined(FEAT_TITLE) && (defined(UNIX) || defined(VMS) \ |
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7307
diff
changeset
|
2804 || defined(MACOS_X))) || defined(PROTO) |
7 | 2805 /* |
2806 * Generic function to set window title, using t_ts and t_fs. | |
2807 */ | |
2808 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2809 term_settitle(char_u *title) |
7 | 2810 { |
2811 /* t_ts takes one argument: column in status line */ | |
2812 OUT_STR(tgoto((char *)T_TS, 0, 0)); /* set title start */ | |
2813 out_str_nf(title); | |
2814 out_str(T_FS); /* set title end */ | |
2815 out_flush(); | |
2816 } | |
2817 #endif | |
2818 | |
2819 /* | |
2820 * Make sure we have a valid set or terminal options. | |
2821 * Replace all entries that are NULL by empty_option | |
2822 */ | |
2823 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2824 ttest(int pairs) |
7 | 2825 { |
2826 check_options(); /* make sure no options are NULL */ | |
2827 | |
2828 /* | |
2829 * MUST have "cm": cursor motion. | |
2830 */ | |
2831 if (*T_CM == NUL) | |
2832 EMSG(_("E437: terminal capability \"cm\" required")); | |
2833 | |
2834 /* | |
2835 * if "cs" defined, use a scroll region, it's faster. | |
2836 */ | |
2837 if (*T_CS != NUL) | |
2838 scroll_region = TRUE; | |
2839 else | |
2840 scroll_region = FALSE; | |
2841 | |
2842 if (pairs) | |
2843 { | |
2844 /* | |
2845 * optional pairs | |
2846 */ | |
2847 /* TP goes to normal mode for TI (invert) and TB (bold) */ | |
2848 if (*T_ME == NUL) | |
2849 T_ME = T_MR = T_MD = T_MB = empty_option; | |
2850 if (*T_SO == NUL || *T_SE == NUL) | |
2851 T_SO = T_SE = empty_option; | |
2852 if (*T_US == NUL || *T_UE == NUL) | |
2853 T_US = T_UE = empty_option; | |
2854 if (*T_CZH == NUL || *T_CZR == NUL) | |
2855 T_CZH = T_CZR = empty_option; | |
2856 | |
2857 /* T_VE is needed even though T_VI is not defined */ | |
2858 if (*T_VE == NUL) | |
2859 T_VI = empty_option; | |
2860 | |
2861 /* if 'mr' or 'me' is not defined use 'so' and 'se' */ | |
2862 if (*T_ME == NUL) | |
2863 { | |
2864 T_ME = T_SE; | |
2865 T_MR = T_SO; | |
2866 T_MD = T_SO; | |
2867 } | |
2868 | |
2869 /* if 'so' or 'se' is not defined use 'mr' and 'me' */ | |
2870 if (*T_SO == NUL) | |
2871 { | |
2872 T_SE = T_ME; | |
2873 if (*T_MR == NUL) | |
2874 T_SO = T_MD; | |
2875 else | |
2876 T_SO = T_MR; | |
2877 } | |
2878 | |
2879 /* if 'ZH' or 'ZR' is not defined use 'mr' and 'me' */ | |
2880 if (*T_CZH == NUL) | |
2881 { | |
2882 T_CZR = T_ME; | |
2883 if (*T_MR == NUL) | |
2884 T_CZH = T_MD; | |
2885 else | |
2886 T_CZH = T_MR; | |
2887 } | |
2888 | |
2889 /* "Sb" and "Sf" come in pairs */ | |
2890 if (*T_CSB == NUL || *T_CSF == NUL) | |
2891 { | |
2892 T_CSB = empty_option; | |
2893 T_CSF = empty_option; | |
2894 } | |
2895 | |
2896 /* "AB" and "AF" come in pairs */ | |
2897 if (*T_CAB == NUL || *T_CAF == NUL) | |
2898 { | |
2899 T_CAB = empty_option; | |
2900 T_CAF = empty_option; | |
2901 } | |
2902 | |
2903 /* if 'Sb' and 'AB' are not defined, reset "Co" */ | |
2904 if (*T_CSB == NUL && *T_CAB == NUL) | |
1941 | 2905 free_one_termoption(T_CCO); |
7 | 2906 |
2907 /* Set 'weirdinvert' according to value of 't_xs' */ | |
2908 p_wiv = (*T_XS != NUL); | |
2909 } | |
2910 need_gather = TRUE; | |
2911 | |
2912 /* Set t_colors to the value of t_Co. */ | |
2913 t_colors = atoi((char *)T_CCO); | |
2914 } | |
2915 | |
2916 #if (defined(FEAT_GUI) && (defined(FEAT_MENU) || !defined(USE_ON_FLY_SCROLL))) \ | |
2917 || defined(PROTO) | |
2918 /* | |
2919 * Represent the given long_u as individual bytes, with the most significant | |
2920 * byte first, and store them in dst. | |
2921 */ | |
2922 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2923 add_long_to_buf(long_u val, char_u *dst) |
7 | 2924 { |
2925 int i; | |
2926 int shift; | |
2927 | |
1883 | 2928 for (i = 1; i <= (int)sizeof(long_u); i++) |
7 | 2929 { |
2930 shift = 8 * (sizeof(long_u) - i); | |
2931 dst[i - 1] = (char_u) ((val >> shift) & 0xff); | |
2932 } | |
2933 } | |
2934 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
2935 static int get_long_from_buf(char_u *buf, long_u *val); |
7 | 2936 |
2937 /* | |
2938 * Interpret the next string of bytes in buf as a long integer, with the most | |
2939 * significant byte first. Note that it is assumed that buf has been through | |
2940 * inchar(), so that NUL and K_SPECIAL will be represented as three bytes each. | |
2941 * Puts result in val, and returns the number of bytes read from buf | |
2942 * (between sizeof(long_u) and 2 * sizeof(long_u)), or -1 if not enough bytes | |
2943 * were present. | |
2944 */ | |
2945 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2946 get_long_from_buf(char_u *buf, long_u *val) |
7 | 2947 { |
2948 int len; | |
2949 char_u bytes[sizeof(long_u)]; | |
2950 int i; | |
2951 int shift; | |
2952 | |
2953 *val = 0; | |
2954 len = get_bytes_from_buf(buf, bytes, (int)sizeof(long_u)); | |
2955 if (len != -1) | |
2956 { | |
1883 | 2957 for (i = 0; i < (int)sizeof(long_u); i++) |
7 | 2958 { |
2959 shift = 8 * (sizeof(long_u) - 1 - i); | |
2960 *val += (long_u)bytes[i] << shift; | |
2961 } | |
2962 } | |
2963 return len; | |
2964 } | |
2965 #endif | |
2966 | |
2967 #if defined(FEAT_GUI) \ | |
1623 | 2968 || (defined(FEAT_MOUSE) && (!defined(UNIX) || defined(FEAT_MOUSE_XTERM) \ |
2969 || defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE))) | |
7 | 2970 /* |
2971 * Read the next num_bytes bytes from buf, and store them in bytes. Assume | |
2972 * that buf has been through inchar(). Returns the actual number of bytes used | |
2973 * from buf (between num_bytes and num_bytes*2), or -1 if not enough bytes were | |
2974 * available. | |
2975 */ | |
2976 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2977 get_bytes_from_buf(char_u *buf, char_u *bytes, int num_bytes) |
7 | 2978 { |
2979 int len = 0; | |
2980 int i; | |
2981 char_u c; | |
2982 | |
2983 for (i = 0; i < num_bytes; i++) | |
2984 { | |
2985 if ((c = buf[len++]) == NUL) | |
2986 return -1; | |
2987 if (c == K_SPECIAL) | |
2988 { | |
2989 if (buf[len] == NUL || buf[len + 1] == NUL) /* cannot happen? */ | |
2990 return -1; | |
2991 if (buf[len++] == (int)KS_ZERO) | |
2992 c = NUL; | |
5076
19ed30f7cef7
updated for version 7.3.1281
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
2993 /* else it should be KS_SPECIAL; when followed by KE_FILLER c is |
19ed30f7cef7
updated for version 7.3.1281
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
2994 * K_SPECIAL, or followed by KE_CSI and c must be CSI. */ |
19ed30f7cef7
updated for version 7.3.1281
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
2995 if (buf[len++] == (int)KE_CSI) |
19ed30f7cef7
updated for version 7.3.1281
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
2996 c = CSI; |
7 | 2997 } |
1160 | 2998 else if (c == CSI && buf[len] == KS_EXTRA |
2999 && buf[len + 1] == (int)KE_CSI) | |
667 | 3000 /* CSI is stored as CSI KS_SPECIAL KE_CSI to avoid confusion with |
3001 * the start of a special key, see add_to_input_buf_csi(). */ | |
3002 len += 2; | |
7 | 3003 bytes[i] = c; |
3004 } | |
3005 return len; | |
3006 } | |
3007 #endif | |
3008 | |
3009 /* | |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3010 * 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
|
3011 * too big. |
7 | 3012 */ |
3013 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3014 check_shellsize(void) |
7 | 3015 { |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3016 if (Rows < min_rows()) /* need room for one window and command line */ |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3017 Rows = min_rows(); |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3018 limit_screen_size(); |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3019 } |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3020 |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3021 /* |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3022 * 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
|
3023 */ |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3024 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3025 limit_screen_size(void) |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3026 { |
7 | 3027 if (Columns < MIN_COLUMNS) |
3028 Columns = MIN_COLUMNS; | |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3029 else if (Columns > 10000) |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3030 Columns = 10000; |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3031 if (Rows > 1000) |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3032 Rows = 1000; |
7 | 3033 } |
3034 | |
41 | 3035 /* |
3036 * Invoked just before the screen structures are going to be (re)allocated. | |
3037 */ | |
7 | 3038 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3039 win_new_shellsize(void) |
7 | 3040 { |
3041 static int old_Rows = 0; | |
3042 static int old_Columns = 0; | |
3043 | |
3044 if (old_Rows != Rows || old_Columns != Columns) | |
3045 ui_new_shellsize(); | |
3046 if (old_Rows != Rows) | |
3047 { | |
164 | 3048 /* if 'window' uses the whole screen, keep it using that */ |
179 | 3049 if (p_window == old_Rows - 1 || old_Rows == 0) |
164 | 3050 p_window = Rows - 1; |
7 | 3051 old_Rows = Rows; |
3052 shell_new_rows(); /* update window sizes */ | |
3053 } | |
3054 if (old_Columns != Columns) | |
3055 { | |
3056 old_Columns = Columns; | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
3057 #ifdef FEAT_WINDOWS |
7 | 3058 shell_new_columns(); /* update window sizes */ |
3059 #endif | |
3060 } | |
3061 } | |
3062 | |
3063 /* | |
3064 * Call this function when the Vim shell has been resized in any way. | |
3065 * Will obtain the current size and redraw (also when size didn't change). | |
3066 */ | |
3067 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3068 shell_resized(void) |
7 | 3069 { |
3070 set_shellsize(0, 0, FALSE); | |
3071 } | |
3072 | |
3073 /* | |
3074 * Check if the shell size changed. Handle a resize. | |
3075 * When the size didn't change, nothing happens. | |
3076 */ | |
3077 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3078 shell_resized_check(void) |
7 | 3079 { |
3080 int old_Rows = Rows; | |
3081 int old_Columns = Columns; | |
3082 | |
3770 | 3083 if (!exiting |
3084 #ifdef FEAT_GUI | |
3085 /* Do not get the size when executing a shell command during | |
3086 * startup. */ | |
3087 && !gui.starting | |
3088 #endif | |
3089 ) | |
2673 | 3090 { |
3091 (void)ui_get_shellsize(); | |
3092 check_shellsize(); | |
3093 if (old_Rows != Rows || old_Columns != Columns) | |
3094 shell_resized(); | |
3095 } | |
7 | 3096 } |
3097 | |
3098 /* | |
3099 * Set size of the Vim shell. | |
3100 * If 'mustset' is TRUE, we must set Rows and Columns, do not get the real | |
3101 * window size (this is used for the :win command). | |
3102 * If 'mustset' is FALSE, we may try to get the real window size and if | |
3103 * it fails use 'width' and 'height'. | |
3104 */ | |
3105 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3106 set_shellsize(int width, int height, int mustset) |
7 | 3107 { |
3108 static int busy = FALSE; | |
3109 | |
3110 /* | |
3111 * Avoid recursiveness, can happen when setting the window size causes | |
3112 * another window-changed signal. | |
3113 */ | |
3114 if (busy) | |
3115 return; | |
3116 | |
3117 if (width < 0 || height < 0) /* just checking... */ | |
3118 return; | |
3119 | |
3068 | 3120 if (State == HITRETURN || State == SETWSIZE) |
7 | 3121 { |
3068 | 3122 /* postpone the resizing */ |
7 | 3123 State = SETWSIZE; |
3124 return; | |
3125 } | |
3126 | |
3068 | 3127 /* curwin->w_buffer can be NULL when we are closing a window and the |
3128 * buffer has already been closed and removing a scrollbar causes a resize | |
3129 * event. Don't resize then, it will happen after entering another buffer. | |
3130 */ | |
3131 if (curwin->w_buffer == NULL) | |
3132 return; | |
3133 | |
7 | 3134 ++busy; |
3135 | |
3136 #ifdef AMIGA | |
3137 out_flush(); /* must do this before mch_get_shellsize() for | |
3138 some obscure reason */ | |
3139 #endif | |
3140 | |
3141 if (mustset || (ui_get_shellsize() == FAIL && height != 0)) | |
3142 { | |
3143 Rows = height; | |
3144 Columns = width; | |
3145 check_shellsize(); | |
3146 ui_set_shellsize(mustset); | |
3147 } | |
3148 else | |
3149 check_shellsize(); | |
3150 | |
3151 /* The window layout used to be adjusted here, but it now happens in | |
3152 * screenalloc() (also invoked from screenclear()). That is because the | |
3153 * "busy" check above may skip this, but not screenalloc(). */ | |
3154 | |
3155 if (State != ASKMORE && State != EXTERNCMD && State != CONFIRM) | |
3156 screenclear(); | |
3157 else | |
3158 screen_start(); /* don't know where cursor is now */ | |
3159 | |
3160 if (starting != NO_SCREEN) | |
3161 { | |
3162 #ifdef FEAT_TITLE | |
3163 maketitle(); | |
3164 #endif | |
3165 changed_line_abv_curs(); | |
3166 invalidate_botline(); | |
3167 | |
3168 /* | |
3169 * We only redraw when it's needed: | |
3170 * - While at the more prompt or executing an external command, don't | |
3171 * redraw, but position the cursor. | |
3172 * - While editing the command line, only redraw that. | |
3173 * - in Ex mode, don't redraw anything. | |
3174 * - Otherwise, redraw right now, and position the cursor. | |
3175 * Always need to call update_screen() or screenalloc(), to make | |
3176 * sure Rows/Columns and the size of ScreenLines[] is correct! | |
3177 */ | |
3178 if (State == ASKMORE || State == EXTERNCMD || State == CONFIRM | |
3179 || exmode_active) | |
3180 { | |
3181 screenalloc(FALSE); | |
3182 repeat_message(); | |
3183 } | |
3184 else | |
3185 { | |
1024 | 3186 #ifdef FEAT_SCROLLBIND |
3187 if (curwin->w_p_scb) | |
3188 do_check_scrollbind(TRUE); | |
3189 #endif | |
3190 if (State & CMDLINE) | |
648 | 3191 { |
1024 | 3192 update_screen(NOT_VALID); |
3193 redrawcmdline(); | |
648 | 3194 } |
3195 else | |
1024 | 3196 { |
3197 update_topline(); | |
3198 #if defined(FEAT_INS_EXPAND) | |
3199 if (pum_visible()) | |
3200 { | |
3201 redraw_later(NOT_VALID); | |
3202 ins_compl_show_pum(); /* This includes the redraw. */ | |
3203 } | |
3204 else | |
648 | 3205 #endif |
1024 | 3206 update_screen(NOT_VALID); |
3207 if (redrawing()) | |
3208 setcursor(); | |
3209 } | |
7 | 3210 } |
3211 cursor_on(); /* redrawing may have switched it off */ | |
3212 } | |
3213 out_flush(); | |
3214 --busy; | |
3215 } | |
3216 | |
3217 /* | |
3218 * Set the terminal to TMODE_RAW (for Normal mode) or TMODE_COOK (for external | |
3219 * commands and Ex mode). | |
3220 */ | |
3221 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3222 settmode(int tmode) |
7 | 3223 { |
3224 #ifdef FEAT_GUI | |
3225 /* don't set the term where gvim was started to any mode */ | |
3226 if (gui.in_use) | |
3227 return; | |
3228 #endif | |
3229 | |
3230 if (full_screen) | |
3231 { | |
3232 /* | |
3233 * When returning after calling a shell we want to really set the | |
3234 * terminal to raw mode, even though we think it already is, because | |
3235 * the shell program may have reset the terminal mode. | |
3236 * When we think the terminal is normal, don't try to set it to | |
3237 * normal again, because that causes problems (logout!) on some | |
3238 * machines. | |
3239 */ | |
3240 if (tmode != TMODE_COOK || cur_tmode != TMODE_COOK) | |
3241 { | |
3242 #ifdef FEAT_TERMRESPONSE | |
1691 | 3243 # ifdef FEAT_GUI |
3244 if (!gui.in_use && !gui.starting) | |
3245 # endif | |
3246 { | |
3247 /* May need to check for T_CRV response and termcodes, it | |
3248 * doesn't work in Cooked mode, an external program may get | |
3249 * them. */ | |
4215 | 3250 if (tmode != TMODE_RAW && (crv_status == CRV_SENT |
6874 | 3251 || u7_status == U7_SENT |
3252 || rbg_status == RBG_SENT)) | |
1691 | 3253 (void)vpeekc_nomap(); |
3254 check_for_codes_from_term(); | |
3255 } | |
7 | 3256 #endif |
3257 #ifdef FEAT_MOUSE_TTY | |
3258 if (tmode != TMODE_RAW) | |
11368
253e66dd1428
patch 8.0.0569: bracketed paste is still enabled in a shell command
Christian Brabandt <cb@256bit.org>
parents:
11315
diff
changeset
|
3259 mch_setmouse(FALSE); /* switch mouse off */ |
7 | 3260 #endif |
11368
253e66dd1428
patch 8.0.0569: bracketed paste is still enabled in a shell command
Christian Brabandt <cb@256bit.org>
parents:
11315
diff
changeset
|
3261 if (tmode != TMODE_RAW) |
253e66dd1428
patch 8.0.0569: bracketed paste is still enabled in a shell command
Christian Brabandt <cb@256bit.org>
parents:
11315
diff
changeset
|
3262 out_str(T_BD); /* disable bracketed paste mode */ |
7 | 3263 out_flush(); |
11368
253e66dd1428
patch 8.0.0569: bracketed paste is still enabled in a shell command
Christian Brabandt <cb@256bit.org>
parents:
11315
diff
changeset
|
3264 mch_settmode(tmode); /* machine specific function */ |
7 | 3265 cur_tmode = tmode; |
3266 #ifdef FEAT_MOUSE | |
3267 if (tmode == TMODE_RAW) | |
11368
253e66dd1428
patch 8.0.0569: bracketed paste is still enabled in a shell command
Christian Brabandt <cb@256bit.org>
parents:
11315
diff
changeset
|
3268 setmouse(); /* may switch mouse on */ |
7 | 3269 #endif |
11368
253e66dd1428
patch 8.0.0569: bracketed paste is still enabled in a shell command
Christian Brabandt <cb@256bit.org>
parents:
11315
diff
changeset
|
3270 if (tmode == TMODE_RAW) |
253e66dd1428
patch 8.0.0569: bracketed paste is still enabled in a shell command
Christian Brabandt <cb@256bit.org>
parents:
11315
diff
changeset
|
3271 out_str(T_BE); /* enable bracketed paste mode */ |
7 | 3272 out_flush(); |
3273 } | |
3274 #ifdef FEAT_TERMRESPONSE | |
3275 may_req_termresponse(); | |
3276 #endif | |
3277 } | |
3278 } | |
3279 | |
3280 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3281 starttermcap(void) |
7 | 3282 { |
3283 if (full_screen && !termcap_active) | |
3284 { | |
3285 out_str(T_TI); /* start termcap mode */ | |
3286 out_str(T_KS); /* start "keypad transmit" mode */ | |
10676
b8c04c007d39
patch 8.0.0228: pasting in xterm on the command line has PasteStart
Christian Brabandt <cb@256bit.org>
parents:
10640
diff
changeset
|
3287 out_str(T_BE); /* enable bracketed paste mode */ |
7 | 3288 out_flush(); |
3289 termcap_active = TRUE; | |
3290 screen_start(); /* don't know where cursor is now */ | |
3291 #ifdef FEAT_TERMRESPONSE | |
1691 | 3292 # ifdef FEAT_GUI |
3293 if (!gui.in_use && !gui.starting) | |
3294 # endif | |
3295 { | |
3296 may_req_termresponse(); | |
3297 /* Immediately check for a response. If t_Co changes, we don't | |
3298 * want to redraw with wrong colors first. */ | |
5927 | 3299 if (crv_status == CRV_SENT) |
1691 | 3300 check_for_codes_from_term(); |
3301 } | |
7 | 3302 #endif |
3303 } | |
3304 } | |
3305 | |
3306 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3307 stoptermcap(void) |
7 | 3308 { |
3309 screen_stop_highlight(); | |
3310 reset_cterm_colors(); | |
3311 if (termcap_active) | |
3312 { | |
3313 #ifdef FEAT_TERMRESPONSE | |
1691 | 3314 # ifdef FEAT_GUI |
3315 if (!gui.in_use && !gui.starting) | |
3316 # endif | |
3317 { | |
6874 | 3318 /* May need to discard T_CRV, T_U7 or T_RBG response. */ |
3319 if (crv_status == CRV_SENT || u7_status == U7_SENT | |
3320 || rbg_status == RBG_SENT) | |
4391 | 3321 { |
3322 # ifdef UNIX | |
3323 /* Give the terminal a chance to respond. */ | |
3324 mch_delay(100L, FALSE); | |
3325 # endif | |
3326 # ifdef TCIFLUSH | |
3327 /* Discard data received but not read. */ | |
3328 if (exiting) | |
3329 tcflush(fileno(stdin), TCIFLUSH); | |
3330 # endif | |
3331 } | |
1691 | 3332 /* Check for termcodes first, otherwise an external program may |
3333 * get them. */ | |
3334 check_for_codes_from_term(); | |
3335 } | |
7 | 3336 #endif |
10676
b8c04c007d39
patch 8.0.0228: pasting in xterm on the command line has PasteStart
Christian Brabandt <cb@256bit.org>
parents:
10640
diff
changeset
|
3337 out_str(T_BD); /* disable bracketed paste mode */ |
7 | 3338 out_str(T_KE); /* stop "keypad transmit" mode */ |
3339 out_flush(); | |
3340 termcap_active = FALSE; | |
3341 cursor_on(); /* just in case it is still off */ | |
3342 out_str(T_TE); /* stop termcap mode */ | |
3343 screen_start(); /* don't know where cursor is now */ | |
3344 out_flush(); | |
3345 } | |
3346 } | |
3347 | |
5932 | 3348 #if defined(FEAT_TERMRESPONSE) || defined(PROTO) |
7 | 3349 /* |
3350 * Request version string (for xterm) when needed. | |
3351 * Only do this after switching to raw mode, otherwise the result will be | |
3352 * echoed. | |
626 | 3353 * Only do this after startup has finished, to avoid that the response comes |
1221 | 3354 * while executing "-c !cmd" or even after "-c quit". |
7 | 3355 * Only do this after termcap mode has been started, otherwise the codes for |
3356 * the cursor keys may be wrong. | |
620 | 3357 * Only do this when 'esckeys' is on, otherwise the response causes trouble in |
3358 * Insert mode. | |
164 | 3359 * On Unix only do it when both output and input are a tty (avoid writing |
3360 * request to terminal while reading from a file). | |
7 | 3361 * The result is caught in check_termcode(). |
3362 */ | |
626 | 3363 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3364 may_req_termresponse(void) |
7 | 3365 { |
3366 if (crv_status == CRV_GET | |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
3367 && can_get_termresponse() |
626 | 3368 && starting == 0 |
7 | 3369 && *T_CRV != NUL) |
3370 { | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3371 LOG_TR("Sending CRV"); |
7 | 3372 out_str(T_CRV); |
3373 crv_status = CRV_SENT; | |
3374 /* check for the characters now, otherwise they might be eaten by | |
3375 * get_keystroke() */ | |
3376 out_flush(); | |
3377 (void)vpeekc_nomap(); | |
3378 } | |
3379 } | |
4215 | 3380 |
3381 # if defined(FEAT_MBYTE) || defined(PROTO) | |
3382 /* | |
3383 * Check how the terminal treats ambiguous character width (UAX #11). | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3384 * First, we move the cursor to (1, 0) and print a test ambiguous character |
4215 | 3385 * \u25bd (WHITE DOWN-POINTING TRIANGLE) and query current cursor position. |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3386 * If the terminal treats \u25bd as single width, the position is (1, 1), |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3387 * or if it is treated as double width, that will be (1, 2). |
4215 | 3388 * This function has the side effect that changes cursor position, so |
3389 * it must be called immediately after entering termcap mode. | |
3390 */ | |
3391 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3392 may_req_ambiguous_char_width(void) |
4215 | 3393 { |
3394 if (u7_status == U7_GET | |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
3395 && 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
|
3396 && starting == 0 |
4215 | 3397 && *T_U7 != NUL |
3398 && !option_was_set((char_u *)"ambiwidth")) | |
3399 { | |
3400 char_u buf[16]; | |
3401 | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3402 LOG_TR("Sending U7 request"); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3403 /* Do this in the second row. In the first row the returned sequence |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3404 * may be CSI 1;2R, which is the same as <S-F3>. */ |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3405 term_windgoto(1, 0); |
4215 | 3406 buf[mb_char2bytes(0x25bd, buf)] = 0; |
3407 out_str(buf); | |
3408 out_str(T_U7); | |
3409 u7_status = U7_SENT; | |
5724 | 3410 out_flush(); |
11455
08e60ce4cbf3
patch 8.0.0611: the screen is not redrawn after sending t_u7
Christian Brabandt <cb@256bit.org>
parents:
11453
diff
changeset
|
3411 |
08e60ce4cbf3
patch 8.0.0611: the screen is not redrawn after sending t_u7
Christian Brabandt <cb@256bit.org>
parents:
11453
diff
changeset
|
3412 /* This overwrites a few characters on the screen, a redraw is needed |
08e60ce4cbf3
patch 8.0.0611: the screen is not redrawn after sending t_u7
Christian Brabandt <cb@256bit.org>
parents:
11453
diff
changeset
|
3413 * after this. Clear them out for now. */ |
5724 | 3414 term_windgoto(1, 0); |
4215 | 3415 out_str((char_u *)" "); |
3416 term_windgoto(0, 0); | |
11455
08e60ce4cbf3
patch 8.0.0611: the screen is not redrawn after sending t_u7
Christian Brabandt <cb@256bit.org>
parents:
11453
diff
changeset
|
3417 |
4215 | 3418 /* check for the characters now, otherwise they might be eaten by |
3419 * get_keystroke() */ | |
3420 out_flush(); | |
3421 (void)vpeekc_nomap(); | |
3422 } | |
3423 } | |
3424 # endif | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3425 |
6874 | 3426 /* |
6885 | 3427 * Similar to requesting the version string: Request the terminal background |
3428 * color when it is the right moment. | |
6874 | 3429 */ |
3430 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3431 may_req_bg_color(void) |
6874 | 3432 { |
3433 if (rbg_status == RBG_GET | |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
3434 && 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
|
3435 && starting == 0 |
6874 | 3436 && *T_RBG != NUL |
3437 && !option_was_set((char_u *)"bg")) | |
3438 { | |
3439 LOG_TR("Sending BG request"); | |
3440 out_str(T_RBG); | |
3441 rbg_status = RBG_SENT; | |
3442 /* check for the characters now, otherwise they might be eaten by | |
3443 * get_keystroke() */ | |
3444 out_flush(); | |
3445 (void)vpeekc_nomap(); | |
3446 } | |
3447 } | |
3448 | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3449 # ifdef DEBUG_TERMRESPONSE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3450 static void |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3451 log_tr(char *msg) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3452 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3453 static FILE *fd_tr = NULL; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3454 static proftime_T start; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3455 proftime_T now; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3456 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3457 if (fd_tr == NULL) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3458 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3459 fd_tr = fopen("termresponse.log", "w"); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3460 profile_start(&start); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3461 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3462 now = start; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3463 profile_end(&now); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3464 fprintf(fd_tr, "%s: %s %s\n", |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3465 profile_msg(&now), |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3466 must_redraw == NOT_VALID ? "NV" |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3467 : must_redraw == CLEAR ? "CL" : " ", |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3468 msg); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3469 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3470 # endif |
7 | 3471 #endif |
3472 | |
3473 /* | |
3474 * Return TRUE when saving and restoring the screen. | |
3475 */ | |
3476 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3477 swapping_screen(void) |
7 | 3478 { |
3479 return (full_screen && *T_TI != NUL); | |
3480 } | |
3481 | |
3482 #ifdef FEAT_MOUSE | |
3483 /* | |
3484 * setmouse() - switch mouse on/off depending on current mode and 'mouse' | |
3485 */ | |
3486 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3487 setmouse(void) |
7 | 3488 { |
3489 # ifdef FEAT_MOUSE_TTY | |
3490 int checkfor; | |
3491 # endif | |
3492 | |
3493 # ifdef FEAT_MOUSESHAPE | |
3494 update_mouseshape(-1); | |
3495 # endif | |
3496 | |
3497 # ifdef FEAT_MOUSE_TTY /* Should be outside proc, but may break MOUSESHAPE */ | |
3498 # ifdef FEAT_GUI | |
3499 /* In the GUI the mouse is always enabled. */ | |
3500 if (gui.in_use) | |
3501 return; | |
3502 # endif | |
3503 /* be quick when mouse is off */ | |
3504 if (*p_mouse == NUL || has_mouse_termcode == 0) | |
3505 return; | |
3506 | |
3507 /* don't switch mouse on when not in raw mode (Ex mode) */ | |
3508 if (cur_tmode != TMODE_RAW) | |
3509 { | |
3510 mch_setmouse(FALSE); | |
3511 return; | |
3512 } | |
3513 | |
3514 if (VIsual_active) | |
3515 checkfor = MOUSE_VISUAL; | |
5735 | 3516 else if (State == HITRETURN || State == ASKMORE || State == SETWSIZE) |
7 | 3517 checkfor = MOUSE_RETURN; |
3518 else if (State & INSERT) | |
3519 checkfor = MOUSE_INSERT; | |
3520 else if (State & CMDLINE) | |
3521 checkfor = MOUSE_COMMAND; | |
3522 else if (State == CONFIRM || State == EXTERNCMD) | |
3523 checkfor = ' '; /* don't use mouse for ":confirm" or ":!cmd" */ | |
3524 else | |
3525 checkfor = MOUSE_NORMAL; /* assume normal mode */ | |
3526 | |
3527 if (mouse_has(checkfor)) | |
3528 mch_setmouse(TRUE); | |
3529 else | |
3530 mch_setmouse(FALSE); | |
3531 # endif | |
3532 } | |
3533 | |
3534 /* | |
3535 * Return TRUE if | |
3536 * - "c" is in 'mouse', or | |
3537 * - 'a' is in 'mouse' and "c" is in MOUSE_A, or | |
3538 * - the current buffer is a help file and 'h' is in 'mouse' and we are in a | |
3539 * normal editing mode (not at hit-return message). | |
3540 */ | |
3541 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3542 mouse_has(int c) |
7 | 3543 { |
3544 char_u *p; | |
3545 | |
3546 for (p = p_mouse; *p; ++p) | |
3547 switch (*p) | |
3548 { | |
3549 case 'a': if (vim_strchr((char_u *)MOUSE_A, c) != NULL) | |
3550 return TRUE; | |
3551 break; | |
3552 case MOUSE_HELP: if (c != MOUSE_RETURN && curbuf->b_help) | |
3553 return TRUE; | |
3554 break; | |
3555 default: if (c == *p) return TRUE; break; | |
3556 } | |
3557 return FALSE; | |
3558 } | |
3559 | |
3560 /* | |
3561 * Return TRUE when 'mousemodel' is set to "popup" or "popup_setpos". | |
3562 */ | |
3563 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3564 mouse_model_popup(void) |
7 | 3565 { |
3566 return (p_mousem[0] == 'p'); | |
3567 } | |
3568 #endif | |
3569 | |
3570 /* | |
3571 * By outputting the 'cursor very visible' termcap code, for some windowed | |
3572 * terminals this makes the screen scrolled to the correct position. | |
3573 * Used when starting Vim or returning from a shell. | |
3574 */ | |
3575 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3576 scroll_start(void) |
7 | 3577 { |
3578 if (*T_VS != NUL) | |
3579 { | |
3580 out_str(T_VS); | |
3581 out_str(T_VE); | |
3582 screen_start(); /* don't know where cursor is now */ | |
3583 } | |
3584 } | |
3585 | |
3586 static int cursor_is_off = FALSE; | |
3587 | |
3588 /* | |
3589 * Enable the cursor. | |
3590 */ | |
3591 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3592 cursor_on(void) |
7 | 3593 { |
3594 if (cursor_is_off) | |
3595 { | |
3596 out_str(T_VE); | |
3597 cursor_is_off = FALSE; | |
3598 } | |
3599 } | |
3600 | |
3601 /* | |
3602 * Disable the cursor. | |
3603 */ | |
3604 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3605 cursor_off(void) |
7 | 3606 { |
3607 if (full_screen) | |
3608 { | |
3609 if (!cursor_is_off) | |
3610 out_str(T_VI); /* disable cursor */ | |
3611 cursor_is_off = TRUE; | |
3612 } | |
3613 } | |
3614 | |
39 | 3615 #if defined(CURSOR_SHAPE) || defined(PROTO) |
7 | 3616 /* |
6727 | 3617 * Set cursor shape to match Insert or Replace mode. |
36 | 3618 */ |
3619 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3620 term_cursor_shape(void) |
36 | 3621 { |
6727 | 3622 static int showing_mode = NORMAL; |
3623 char_u *p; | |
3624 | |
3625 /* Only do something when redrawing the screen and we can restore the | |
3626 * mode. */ | |
3627 if (!full_screen || *T_CEI == NUL) | |
36 | 3628 return; |
3629 | |
6727 | 3630 if ((State & REPLACE) == REPLACE) |
36 | 3631 { |
6727 | 3632 if (showing_mode != REPLACE) |
3633 { | |
3634 if (*T_CSR != NUL) | |
3635 p = T_CSR; /* Replace mode cursor */ | |
3636 else | |
3637 p = T_CSI; /* fall back to Insert mode cursor */ | |
3638 if (*p != NUL) | |
3639 { | |
3640 out_str(p); | |
3641 showing_mode = REPLACE; | |
3642 } | |
3643 } | |
36 | 3644 } |
6727 | 3645 else if (State & INSERT) |
36 | 3646 { |
6727 | 3647 if (showing_mode != INSERT && *T_CSI != NUL) |
3648 { | |
3649 out_str(T_CSI); /* Insert mode cursor */ | |
3650 showing_mode = INSERT; | |
3651 } | |
3652 } | |
3653 else if (showing_mode != NORMAL) | |
3654 { | |
3655 out_str(T_CEI); /* non-Insert mode cursor */ | |
3656 showing_mode = NORMAL; | |
36 | 3657 } |
3658 } | |
39 | 3659 #endif |
36 | 3660 |
3661 /* | |
7 | 3662 * Set scrolling region for window 'wp'. |
3663 * The region starts 'off' lines from the start of the window. | |
3664 * Also set the vertical scroll region for a vertically split window. Always | |
3665 * the full width of the window, excluding the vertical separator. | |
3666 */ | |
3667 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3668 scroll_region_set(win_T *wp, int off) |
7 | 3669 { |
3670 OUT_STR(tgoto((char *)T_CS, W_WINROW(wp) + wp->w_height - 1, | |
3671 W_WINROW(wp) + off)); | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
3672 #ifdef FEAT_WINDOWS |
7 | 3673 if (*T_CSV != NUL && wp->w_width != Columns) |
3674 OUT_STR(tgoto((char *)T_CSV, W_WINCOL(wp) + wp->w_width - 1, | |
3675 W_WINCOL(wp))); | |
3676 #endif | |
3677 screen_start(); /* don't know where cursor is now */ | |
3678 } | |
3679 | |
3680 /* | |
3681 * Reset scrolling region to the whole screen. | |
3682 */ | |
3683 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3684 scroll_region_reset(void) |
7 | 3685 { |
3686 OUT_STR(tgoto((char *)T_CS, (int)Rows - 1, 0)); | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
3687 #ifdef FEAT_WINDOWS |
7 | 3688 if (*T_CSV != NUL) |
3689 OUT_STR(tgoto((char *)T_CSV, (int)Columns - 1, 0)); | |
3690 #endif | |
3691 screen_start(); /* don't know where cursor is now */ | |
3692 } | |
3693 | |
3694 | |
3695 /* | |
3696 * List of terminal codes that are currently recognized. | |
3697 */ | |
3698 | |
298 | 3699 static struct termcode |
7 | 3700 { |
3701 char_u name[2]; /* termcap name of entry */ | |
3702 char_u *code; /* terminal code (in allocated memory) */ | |
3703 int len; /* STRLEN(code) */ | |
179 | 3704 int modlen; /* length of part before ";*~". */ |
7 | 3705 } *termcodes = NULL; |
3706 | |
3707 static int tc_max_len = 0; /* number of entries that termcodes[] can hold */ | |
3708 static int tc_len = 0; /* current number of entries in termcodes[] */ | |
3709 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
3710 static int termcode_star(char_u *code, int len); |
180 | 3711 |
7 | 3712 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3713 clear_termcodes(void) |
7 | 3714 { |
3715 while (tc_len > 0) | |
3716 vim_free(termcodes[--tc_len].code); | |
3717 vim_free(termcodes); | |
3718 termcodes = NULL; | |
3719 tc_max_len = 0; | |
3720 | |
3721 #ifdef HAVE_TGETENT | |
3722 BC = (char *)empty_option; | |
3723 UP = (char *)empty_option; | |
3724 PC = NUL; /* set pad character to NUL */ | |
3725 ospeed = 0; | |
3726 #endif | |
3727 | |
3728 need_gather = TRUE; /* need to fill termleader[] */ | |
3729 } | |
3730 | |
180 | 3731 #define ATC_FROM_TERM 55 |
3732 | |
7 | 3733 /* |
3734 * Add a new entry to the list of terminal codes. | |
3735 * The list is kept alphabetical for ":set termcap" | |
180 | 3736 * "flags" is TRUE when replacing 7-bit by 8-bit controls is desired. |
3737 * "flags" can also be ATC_FROM_TERM for got_code_from_term(). | |
7 | 3738 */ |
3739 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3740 add_termcode(char_u *name, char_u *string, int flags) |
7 | 3741 { |
3742 struct termcode *new_tc; | |
3743 int i, j; | |
3744 char_u *s; | |
179 | 3745 int len; |
7 | 3746 |
3747 if (string == NULL || *string == NUL) | |
3748 { | |
3749 del_termcode(name); | |
3750 return; | |
3751 } | |
3752 | |
6047 | 3753 #if defined(WIN3264) && !defined(FEAT_GUI) |
3754 s = vim_strnsave(string, (int)STRLEN(string) + 1); | |
3755 #else | |
7 | 3756 s = vim_strsave(string); |
6047 | 3757 #endif |
7 | 3758 if (s == NULL) |
3759 return; | |
3760 | |
3761 /* Change leading <Esc>[ to CSI, change <Esc>O to <M-O>. */ | |
180 | 3762 if (flags != 0 && flags != ATC_FROM_TERM && term_7to8bit(string) != 0) |
7 | 3763 { |
1623 | 3764 STRMOVE(s, s + 1); |
7 | 3765 s[0] = term_7to8bit(string); |
3766 } | |
6047 | 3767 |
3768 #if defined(WIN3264) && !defined(FEAT_GUI) | |
3769 if (s[0] == K_NUL) | |
3770 { | |
6102 | 3771 STRMOVE(s + 1, s); |
3772 s[1] = 3; | |
6047 | 3773 } |
3774 #endif | |
3775 | |
179 | 3776 len = (int)STRLEN(s); |
7 | 3777 |
3778 need_gather = TRUE; /* need to fill termleader[] */ | |
3779 | |
3780 /* | |
3781 * need to make space for more entries | |
3782 */ | |
3783 if (tc_len == tc_max_len) | |
3784 { | |
3785 tc_max_len += 20; | |
3786 new_tc = (struct termcode *)alloc( | |
3787 (unsigned)(tc_max_len * sizeof(struct termcode))); | |
3788 if (new_tc == NULL) | |
3789 { | |
3790 tc_max_len -= 20; | |
3791 return; | |
3792 } | |
3793 for (i = 0; i < tc_len; ++i) | |
3794 new_tc[i] = termcodes[i]; | |
3795 vim_free(termcodes); | |
3796 termcodes = new_tc; | |
3797 } | |
3798 | |
3799 /* | |
3800 * Look for existing entry with the same name, it is replaced. | |
3801 * Look for an existing entry that is alphabetical higher, the new entry | |
3802 * is inserted in front of it. | |
3803 */ | |
3804 for (i = 0; i < tc_len; ++i) | |
3805 { | |
3806 if (termcodes[i].name[0] < name[0]) | |
3807 continue; | |
3808 if (termcodes[i].name[0] == name[0]) | |
3809 { | |
3810 if (termcodes[i].name[1] < name[1]) | |
3811 continue; | |
3812 /* | |
180 | 3813 * Exact match: May replace old code. |
7 | 3814 */ |
3815 if (termcodes[i].name[1] == name[1]) | |
3816 { | |
180 | 3817 if (flags == ATC_FROM_TERM && (j = termcode_star( |
3818 termcodes[i].code, termcodes[i].len)) > 0) | |
179 | 3819 { |
180 | 3820 /* Don't replace ESC[123;*X or ESC O*X with another when |
3821 * invoked from got_code_from_term(). */ | |
3822 if (len == termcodes[i].len - j | |
179 | 3823 && STRNCMP(s, termcodes[i].code, len - 1) == 0 |
180 | 3824 && s[len - 1] |
3825 == termcodes[i].code[termcodes[i].len - 1]) | |
179 | 3826 { |
180 | 3827 /* They are equal but for the ";*": don't add it. */ |
179 | 3828 vim_free(s); |
3829 return; | |
3830 } | |
3831 } | |
3832 else | |
3833 { | |
180 | 3834 /* Replace old code. */ |
179 | 3835 vim_free(termcodes[i].code); |
3836 --tc_len; | |
3837 break; | |
3838 } | |
7 | 3839 } |
3840 } | |
3841 /* | |
3842 * Found alphabetical larger entry, move rest to insert new entry | |
3843 */ | |
3844 for (j = tc_len; j > i; --j) | |
3845 termcodes[j] = termcodes[j - 1]; | |
3846 break; | |
3847 } | |
3848 | |
3849 termcodes[i].name[0] = name[0]; | |
3850 termcodes[i].name[1] = name[1]; | |
3851 termcodes[i].code = s; | |
179 | 3852 termcodes[i].len = len; |
180 | 3853 |
3854 /* For xterm we recognize special codes like "ESC[42;*X" and "ESC O*X" that | |
3855 * accept modifiers. */ | |
3856 termcodes[i].modlen = 0; | |
3857 j = termcode_star(s, len); | |
3858 if (j > 0) | |
3859 termcodes[i].modlen = len - 1 - j; | |
7 | 3860 ++tc_len; |
3861 } | |
3862 | |
180 | 3863 /* |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
3864 * Check termcode "code[len]" for ending in ;*X or *X. |
180 | 3865 * 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
|
3866 * Return 0 if not found, 2 for ;*X and 1 for *X. |
180 | 3867 */ |
3868 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3869 termcode_star(char_u *code, int len) |
180 | 3870 { |
3871 /* Shortest is <M-O>*X. With ; shortest is <CSI>1;*X */ | |
3872 if (len >= 3 && code[len - 2] == '*') | |
3873 { | |
3874 if (len >= 5 && code[len - 3] == ';') | |
3875 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
|
3876 else |
180 | 3877 return 1; |
3878 } | |
3879 return 0; | |
3880 } | |
3881 | |
7 | 3882 char_u * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3883 find_termcode(char_u *name) |
7 | 3884 { |
3885 int i; | |
3886 | |
3887 for (i = 0; i < tc_len; ++i) | |
3888 if (termcodes[i].name[0] == name[0] && termcodes[i].name[1] == name[1]) | |
3889 return termcodes[i].code; | |
3890 return NULL; | |
3891 } | |
3892 | |
3893 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) | |
3894 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3895 get_termcode(int i) |
7 | 3896 { |
3897 if (i >= tc_len) | |
3898 return NULL; | |
3899 return &termcodes[i].name[0]; | |
3900 } | |
3901 #endif | |
3902 | |
3903 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3904 del_termcode(char_u *name) |
7 | 3905 { |
3906 int i; | |
3907 | |
3908 if (termcodes == NULL) /* nothing there yet */ | |
3909 return; | |
3910 | |
3911 need_gather = TRUE; /* need to fill termleader[] */ | |
3912 | |
3913 for (i = 0; i < tc_len; ++i) | |
3914 if (termcodes[i].name[0] == name[0] && termcodes[i].name[1] == name[1]) | |
3915 { | |
3916 del_termcode_idx(i); | |
3917 return; | |
3918 } | |
3919 /* not found. Give error message? */ | |
3920 } | |
3921 | |
3922 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3923 del_termcode_idx(int idx) |
7 | 3924 { |
3925 int i; | |
3926 | |
3927 vim_free(termcodes[idx].code); | |
3928 --tc_len; | |
3929 for (i = idx; i < tc_len; ++i) | |
3930 termcodes[i] = termcodes[i + 1]; | |
3931 } | |
3932 | |
3933 #ifdef FEAT_TERMRESPONSE | |
3934 /* | |
3935 * Called when detected that the terminal sends 8-bit codes. | |
3936 * Convert all 7-bit codes to their 8-bit equivalent. | |
3937 */ | |
3938 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3939 switch_to_8bit(void) |
7 | 3940 { |
3941 int i; | |
3942 int c; | |
3943 | |
3944 /* Only need to do something when not already using 8-bit codes. */ | |
3945 if (!term_is_8bit(T_NAME)) | |
3946 { | |
3947 for (i = 0; i < tc_len; ++i) | |
3948 { | |
3949 c = term_7to8bit(termcodes[i].code); | |
3950 if (c != 0) | |
3951 { | |
1623 | 3952 STRMOVE(termcodes[i].code + 1, termcodes[i].code + 2); |
7 | 3953 termcodes[i].code[0] = c; |
3954 } | |
3955 } | |
3956 need_gather = TRUE; /* need to fill termleader[] */ | |
3957 } | |
3958 detected_8bit = TRUE; | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3959 LOG_TR("Switching to 8 bit"); |
7 | 3960 } |
3961 #endif | |
3962 | |
3963 #ifdef CHECK_DOUBLE_CLICK | |
3964 static linenr_T orig_topline = 0; | |
3965 # ifdef FEAT_DIFF | |
3966 static int orig_topfill = 0; | |
3967 # endif | |
3968 #endif | |
3969 #if (defined(FEAT_WINDOWS) && defined(CHECK_DOUBLE_CLICK)) || defined(PROTO) | |
3970 /* | |
3971 * Checking for double clicks ourselves. | |
3972 * "orig_topline" is used to avoid detecting a double-click when the window | |
3973 * contents scrolled (e.g., when 'scrolloff' is non-zero). | |
3974 */ | |
3975 /* | |
3976 * Set orig_topline. Used when jumping to another window, so that a double | |
3977 * click still works. | |
3978 */ | |
3979 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3980 set_mouse_topline(win_T *wp) |
7 | 3981 { |
3982 orig_topline = wp->w_topline; | |
3983 # ifdef FEAT_DIFF | |
3984 orig_topfill = wp->w_topfill; | |
3985 # endif | |
3986 } | |
3987 #endif | |
3988 | |
3989 /* | |
3990 * Check if typebuf.tb_buf[] contains a terminal key code. | |
3991 * Check from typebuf.tb_buf[typebuf.tb_off] to typebuf.tb_buf[typebuf.tb_off | |
3992 * + max_offset]. | |
3993 * Return 0 for no match, -1 for partial match, > 0 for full match. | |
2672 | 3994 * Return KEYLEN_REMOVED when a key code was deleted. |
7 | 3995 * With a match, the match is removed, the replacement code is inserted in |
3996 * typebuf.tb_buf[] and the number of characters in typebuf.tb_buf[] is | |
3997 * returned. | |
3328 | 3998 * When "buf" is not NULL, buf[bufsize] is used instead of typebuf.tb_buf[]. |
3999 * "buflen" is then the length of the string in buf[] and is updated for | |
4000 * inserts and deletes. | |
7 | 4001 */ |
4002 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4003 check_termcode( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4004 int max_offset, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4005 char_u *buf, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4006 int bufsize, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4007 int *buflen) |
7 | 4008 { |
4009 char_u *tp; | |
4010 char_u *p; | |
4011 int slen = 0; /* init for GCC */ | |
180 | 4012 int modslen; |
7 | 4013 int len; |
2672 | 4014 int retval = 0; |
7 | 4015 int offset; |
4016 char_u key_name[2]; | |
180 | 4017 int modifiers; |
11565
91519a14ec1f
patch 8.0.0665: warning for uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
11563
diff
changeset
|
4018 char_u *modifiers_start = NULL; |
180 | 4019 int key; |
7 | 4020 int new_slen; |
4021 int extra; | |
4022 char_u string[MAX_KEY_CODE_LEN + 1]; | |
4023 int i, j; | |
4024 int idx = 0; | |
4025 #ifdef FEAT_MOUSE | |
1623 | 4026 # if !defined(UNIX) || defined(FEAT_MOUSE_XTERM) || defined(FEAT_GUI) \ |
4027 || defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE) | |
7 | 4028 char_u bytes[6]; |
4029 int num_bytes; | |
4030 # endif | |
4031 int mouse_code = 0; /* init for GCC */ | |
4032 int is_click, is_drag; | |
4033 int wheel_code = 0; | |
4034 int current_button; | |
4035 static int held_button = MOUSE_RELEASE; | |
4036 static int orig_num_clicks = 1; | |
4037 static int orig_mouse_code = 0x0; | |
4038 # ifdef CHECK_DOUBLE_CLICK | |
4039 static int orig_mouse_col = 0; | |
4040 static int orig_mouse_row = 0; | |
4041 static struct timeval orig_mouse_time = {0, 0}; | |
4042 /* time of previous mouse click */ | |
4043 struct timeval mouse_time; /* time of current mouse click */ | |
4044 long timediff; /* elapsed time in msec */ | |
4045 # endif | |
4046 #endif | |
4047 int cpo_koffset; | |
4048 #ifdef FEAT_MOUSE_GPM | |
4049 extern int gpm_flag; /* gpm library variable */ | |
4050 #endif | |
4051 | |
4052 cpo_koffset = (vim_strchr(p_cpo, CPO_KOFFSET) != NULL); | |
4053 | |
4054 /* | |
4055 * Speed up the checks for terminal codes by gathering all first bytes | |
4056 * used in termleader[]. Often this is just a single <Esc>. | |
4057 */ | |
4058 if (need_gather) | |
4059 gather_termleader(); | |
4060 | |
4061 /* | |
4062 * Check at several positions in typebuf.tb_buf[], to catch something like | |
4063 * "x<Up>" that can be mapped. Stop at max_offset, because characters | |
4064 * after that cannot be used for mapping, and with @r commands | |
4223 | 4065 * typebuf.tb_buf[] can become very long. |
7 | 4066 * This is used often, KEEP IT FAST! |
4067 */ | |
4068 for (offset = 0; offset < max_offset; ++offset) | |
4069 { | |
4070 if (buf == NULL) | |
4071 { | |
4072 if (offset >= typebuf.tb_len) | |
4073 break; | |
4074 tp = typebuf.tb_buf + typebuf.tb_off + offset; | |
4075 len = typebuf.tb_len - offset; /* length of the input */ | |
4076 } | |
4077 else | |
4078 { | |
3328 | 4079 if (offset >= *buflen) |
7 | 4080 break; |
4081 tp = buf + offset; | |
3328 | 4082 len = *buflen - offset; |
7 | 4083 } |
4084 | |
4085 /* | |
4086 * Don't check characters after K_SPECIAL, those are already | |
4087 * translated terminal chars (avoid translating ~@^Hx). | |
4088 */ | |
4089 if (*tp == K_SPECIAL) | |
4090 { | |
4091 offset += 2; /* there are always 2 extra characters */ | |
4092 continue; | |
4093 } | |
4094 | |
4095 /* | |
4096 * Skip this position if the character does not appear as the first | |
4097 * character in term_strings. This speeds up a lot, since most | |
4098 * termcodes start with the same character (ESC or CSI). | |
4099 */ | |
4100 i = *tp; | |
4101 for (p = termleader; *p && *p != i; ++p) | |
4102 ; | |
4103 if (*p == NUL) | |
4104 continue; | |
4105 | |
4106 /* | |
4107 * Skip this position if p_ek is not set and tp[0] is an ESC and we | |
4108 * are in Insert mode. | |
4109 */ | |
4110 if (*tp == ESC && !p_ek && (State & INSERT)) | |
4111 continue; | |
4112 | |
4113 key_name[0] = NUL; /* no key name found yet */ | |
699 | 4114 key_name[1] = NUL; /* no key name found yet */ |
180 | 4115 modifiers = 0; /* no modifiers yet */ |
7 | 4116 |
4117 #ifdef FEAT_GUI | |
4118 if (gui.in_use) | |
4119 { | |
4120 /* | |
4121 * GUI special key codes are all of the form [CSI xx]. | |
4122 */ | |
4123 if (*tp == CSI) /* Special key from GUI */ | |
4124 { | |
4125 if (len < 3) | |
4126 return -1; /* Shouldn't happen */ | |
4127 slen = 3; | |
4128 key_name[0] = tp[1]; | |
4129 key_name[1] = tp[2]; | |
4130 } | |
4131 } | |
4132 else | |
4133 #endif /* FEAT_GUI */ | |
4134 { | |
4135 for (idx = 0; idx < tc_len; ++idx) | |
4136 { | |
4137 /* | |
4138 * Ignore the entry if we are not at the start of | |
4139 * typebuf.tb_buf[] | |
4140 * and there are not enough characters to make a match. | |
4141 * But only when the 'K' flag is in 'cpoptions'. | |
4142 */ | |
4143 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
|
4144 modifiers_start = NULL; |
7 | 4145 if (cpo_koffset && offset && len < slen) |
4146 continue; | |
4147 if (STRNCMP(termcodes[idx].code, tp, | |
4148 (size_t)(slen > len ? len : slen)) == 0) | |
4149 { | |
4150 if (len < slen) /* got a partial sequence */ | |
4151 return -1; /* need to get more chars */ | |
4152 | |
4153 /* | |
4154 * When found a keypad key, check if there is another key | |
4155 * that matches and use that one. This makes <Home> to be | |
4156 * found instead of <kHome> when they produce the same | |
4157 * key code. | |
4158 */ | |
4159 if (termcodes[idx].name[0] == 'K' | |
4160 && VIM_ISDIGIT(termcodes[idx].name[1])) | |
4161 { | |
4162 for (j = idx + 1; j < tc_len; ++j) | |
4163 if (termcodes[j].len == slen && | |
4164 STRNCMP(termcodes[idx].code, | |
4165 termcodes[j].code, slen) == 0) | |
4166 { | |
4167 idx = j; | |
4168 break; | |
4169 } | |
4170 } | |
4171 | |
4172 key_name[0] = termcodes[idx].name[0]; | |
4173 key_name[1] = termcodes[idx].name[1]; | |
4174 break; | |
4175 } | |
179 | 4176 |
4177 /* | |
4178 * Check for code with modifier, like xterm uses: | |
180 | 4179 * <Esc>[123;*X (modslen == slen - 3) |
4180 * Also <Esc>O*X and <M-O>*X (modslen == slen - 2). | |
4181 * When there is a modifier the * matches a number. | |
4182 * When there is no modifier the ;* or * is omitted. | |
179 | 4183 */ |
4184 if (termcodes[idx].modlen > 0) | |
4185 { | |
180 | 4186 modslen = termcodes[idx].modlen; |
4187 if (cpo_koffset && offset && len < modslen) | |
179 | 4188 continue; |
4189 if (STRNCMP(termcodes[idx].code, tp, | |
180 | 4190 (size_t)(modslen > len ? len : modslen)) == 0) |
179 | 4191 { |
4192 int n; | |
180 | 4193 |
4194 if (len <= modslen) /* got a partial sequence */ | |
179 | 4195 return -1; /* need to get more chars */ |
4196 | |
180 | 4197 if (tp[modslen] == termcodes[idx].code[slen - 1]) |
4198 slen = modslen + 1; /* no modifiers */ | |
4199 else if (tp[modslen] != ';' && modslen == slen - 3) | |
179 | 4200 continue; /* no match */ |
4201 else | |
4202 { | |
4203 /* Skip over the digits, the final char must | |
4204 * follow. */ | |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
4205 for (j = slen - 2; j < len && (isdigit(tp[j]) || tp[j] == ';'); ++j) |
179 | 4206 ; |
4207 ++j; | |
4208 if (len < j) /* got a partial sequence */ | |
4209 return -1; /* need to get more chars */ | |
180 | 4210 if (tp[j - 1] != termcodes[idx].code[slen - 1]) |
4211 continue; /* no match */ | |
179 | 4212 |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
4213 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
|
4214 |
179 | 4215 /* Match! Convert modifier bits. */ |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
4216 n = atoi((char *)modifiers_start) - 1; |
179 | 4217 if (n & 1) |
180 | 4218 modifiers |= MOD_MASK_SHIFT; |
179 | 4219 if (n & 2) |
180 | 4220 modifiers |= MOD_MASK_ALT; |
179 | 4221 if (n & 4) |
180 | 4222 modifiers |= MOD_MASK_CTRL; |
179 | 4223 if (n & 8) |
180 | 4224 modifiers |= MOD_MASK_META; |
179 | 4225 |
4226 slen = j; | |
4227 } | |
4228 key_name[0] = termcodes[idx].name[0]; | |
4229 key_name[1] = termcodes[idx].name[1]; | |
4230 break; | |
4231 } | |
4232 } | |
7 | 4233 } |
4234 } | |
4235 | |
4236 #ifdef FEAT_TERMRESPONSE | |
3166 | 4237 if (key_name[0] == NUL |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
4238 /* Mouse codes of DEC and pterm start with <ESC>[. When |
6102 | 4239 * detecting the start of these mouse codes they might as well be |
4240 * another key code or terminal response. */ | |
4241 # ifdef FEAT_MOUSE_DEC | |
4242 || key_name[0] == KS_DEC_MOUSE | |
4243 # endif | |
4244 # ifdef FEAT_MOUSE_PTERM | |
4245 || key_name[0] == KS_PTERM_MOUSE | |
4223 | 4246 # endif |
6102 | 4247 ) |
7 | 4248 { |
6102 | 4249 /* Check for some responses from the terminal starting with |
4250 * "<Esc>[" or CSI: | |
4215 | 4251 * |
6102 | 4252 * - Xterm version string: <Esc>[>{x};{vers};{y}c |
4215 | 4253 * Also eat other possible responses to t_RV, rxvt returns |
4254 * "<Esc>[?1;2c". Also accept CSI instead of <Esc>[. | |
4255 * mrxvt has been reported to have "+" in the version. Assume | |
4256 * the escape sequence ends with a letter or one of "{|}~". | |
4257 * | |
6102 | 4258 * - Cursor position report: <Esc>[{row};{col}R |
4259 * The final byte must be 'R'. It is used for checking the | |
4215 | 4260 * 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
|
4261 * |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4262 * - window position reply: <Esc>[3;{x};{y}t |
4215 | 4263 */ |
6901 | 4264 char_u *argp = tp[0] == ESC ? tp + 2 : tp + 1; |
4265 | |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4266 if ((*T_CRV != NUL || *T_U7 != NUL || waiting_for_winpos) |
6901 | 4267 && ((tp[0] == ESC && len >= 3 && tp[1] == '[') |
4395 | 4268 || (tp[0] == CSI && len >= 2)) |
6874 | 4269 && (VIM_ISDIGIT(*argp) || *argp == '>' || *argp == '?')) |
7 | 4270 { |
5724 | 4271 #ifdef FEAT_MBYTE |
4272 int col; | |
5743 | 4273 int row_char = NUL; |
5724 | 4274 #endif |
7 | 4275 j = 0; |
4276 extra = 0; | |
1552 | 4277 for (i = 2 + (tp[0] != CSI); i < len |
4278 && !(tp[i] >= '{' && tp[i] <= '~') | |
4279 && !ASCII_ISALPHA(tp[i]); ++i) | |
7 | 4280 if (tp[i] == ';' && ++j == 1) |
5724 | 4281 { |
4395 | 4282 extra = i + 1; |
5724 | 4283 #ifdef FEAT_MBYTE |
4284 row_char = tp[i - 1]; | |
4285 #endif | |
4286 } | |
7 | 4287 if (i == len) |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4288 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4289 LOG_TR("Not enough characters for CRV"); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4290 return -1; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4291 } |
4215 | 4292 #ifdef FEAT_MBYTE |
5724 | 4293 if (extra > 0) |
4294 col = atoi((char *)tp + extra); | |
4295 else | |
4296 col = 0; | |
4297 | |
4298 /* Eat it when it has 2 arguments and ends in 'R'. Also when | |
4299 * u7_status is not "sent", it may be from a previous Vim that | |
4300 * just exited. But not for <S-F3>, it sends something | |
4301 * similar, check for row and column to make sense. */ | |
6102 | 4302 if (j == 1 && tp[i] == 'R') |
4215 | 4303 { |
6102 | 4304 if (row_char == '2' && col >= 2) |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4305 { |
6102 | 4306 char *aw = NULL; |
4307 | |
4308 LOG_TR("Received U7 status"); | |
4309 u7_status = U7_GOT; | |
4310 # ifdef FEAT_AUTOCMD | |
4311 did_cursorhold = TRUE; | |
4312 # endif | |
4313 if (col == 2) | |
4314 aw = "single"; | |
4315 else if (col == 3) | |
4316 aw = "double"; | |
4317 if (aw != NULL && STRCMP(aw, p_ambw) != 0) | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4318 { |
6102 | 4319 /* Setting the option causes a screen redraw. Do |
4320 * that right away if possible, keeping any | |
4321 * messages. */ | |
4322 set_option_value((char_u *)"ambw", 0L, | |
4323 (char_u *)aw, 0); | |
4324 # ifdef DEBUG_TERMRESPONSE | |
4325 { | |
4326 char buf[100]; | |
4327 int r = redraw_asap(CLEAR); | |
4328 | |
4329 sprintf(buf, | |
4330 "set 'ambiwidth', redraw_asap(): %d", | |
4331 r); | |
4332 log_tr(buf); | |
4333 } | |
4334 # else | |
4335 redraw_asap(CLEAR); | |
4336 # endif | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4337 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4338 } |
4215 | 4339 key_name[0] = (int)KS_EXTRA; |
4340 key_name[1] = (int)KE_IGNORE; | |
4341 slen = i + 1; | |
4342 } | |
4343 else | |
4344 #endif | |
7 | 4345 /* eat it when at least one digit and ending in 'c' */ |
4215 | 4346 if (*T_CRV != NUL && i > 2 + (tp[0] != CSI) && tp[i] == 'c') |
7 | 4347 { |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4348 LOG_TR("Received CRV"); |
7 | 4349 crv_status = CRV_GOT; |
4262 | 4350 # ifdef FEAT_AUTOCMD |
4351 did_cursorhold = TRUE; | |
4352 # endif | |
7 | 4353 |
4354 /* If this code starts with CSI, you can bet that the | |
4355 * terminal uses 8-bit codes. */ | |
4356 if (tp[0] == CSI) | |
4357 switch_to_8bit(); | |
4358 | |
4359 /* rxvt sends its version number: "20703" is 2.7.3. | |
4360 * Ignore it for when the user has set 'term' to xterm, | |
4361 * even though it's an rxvt. */ | |
4395 | 4362 if (extra > 0) |
4363 extra = atoi((char *)tp + extra); | |
7 | 4364 if (extra > 20000) |
4365 extra = 0; | |
4366 | |
4367 if (tp[1 + (tp[0] != CSI)] == '>' && j == 2) | |
4368 { | |
3885 | 4369 /* Only set 'ttymouse' automatically if it was not set |
4370 * by the user already. */ | |
4371 if (!option_was_set((char_u *)"ttym")) | |
4372 { | |
3746 | 4373 # ifdef TTYM_SGR |
3885 | 4374 if (extra >= 277) |
4375 set_option_value((char_u *)"ttym", 0L, | |
3746 | 4376 (char_u *)"sgr", 0); |
3885 | 4377 else |
3746 | 4378 # endif |
3885 | 4379 /* if xterm version >= 95 use mouse dragging */ |
4380 if (extra >= 95) | |
4381 set_option_value((char_u *)"ttym", 0L, | |
7 | 4382 (char_u *)"xterm2", 0); |
3885 | 4383 } |
4384 | |
7 | 4385 /* if xterm version >= 141 try to get termcap codes */ |
4386 if (extra >= 141) | |
4387 { | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4388 LOG_TR("Enable checking for XT codes"); |
7 | 4389 check_for_codes = TRUE; |
4390 need_gather = TRUE; | |
4391 req_codes_from_term(); | |
4392 } | |
4393 } | |
4394 # ifdef FEAT_EVAL | |
4395 set_vim_var_string(VV_TERMRESPONSE, tp, i + 1); | |
4396 # endif | |
4397 # ifdef FEAT_AUTOCMD | |
4398 apply_autocmds(EVENT_TERMRESPONSE, | |
4399 NULL, NULL, FALSE, curbuf); | |
4400 # endif | |
4401 key_name[0] = (int)KS_EXTRA; | |
4402 key_name[1] = (int)KE_IGNORE; | |
4403 slen = i + 1; | |
4404 } | |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4405 |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4406 /* |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4407 * Check for a window position response 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
|
4408 * {lead}3;{x}:{y}t |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4409 */ |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4410 else if (waiting_for_winpos |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4411 && ((len >= 4 && tp[0] == ESC && tp[1] == '[') |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4412 || (len >= 3 && tp[0] == CSI)) |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4413 && tp[(j = 1 + (tp[0] == ESC))] == '3' |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4414 && tp[j + 1] == ';') |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4415 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4416 j += 2; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4417 for (i = j; i < len && vim_isdigit(tp[i]); ++i) |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4418 ; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4419 if (i < len && tp[i] == ';') |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4420 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4421 winpos_x = atoi((char *)tp + j); |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4422 j = i + 1; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4423 for (i = j; i < len && vim_isdigit(tp[i]); ++i) |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4424 ; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4425 if (i < len && tp[i] == 't') |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4426 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4427 winpos_y = atoi((char *)tp + j); |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4428 /* got finished code: consume it */ |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4429 key_name[0] = (int)KS_EXTRA; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4430 key_name[1] = (int)KE_IGNORE; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4431 slen = i + 1; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4432 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4433 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4434 if (i == len) |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4435 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4436 LOG_TR("not enough characters for winpos"); |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4437 return -1; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4438 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4439 } |
6901 | 4440 } |
4441 | |
4442 /* Check for background color response from the terminal: | |
4443 * | |
4444 * {lead}11;rgb:{rrrr}/{gggg}/{bbbb}{tail} | |
4445 * | |
4446 * {lead} can be <Esc>] or OSC | |
4447 * {tail} can be '\007', <Esc>\ or STERM. | |
4448 * | |
4449 * Consume any code that starts with "{lead}11;", it's also | |
4450 * possible that "rgba" is following. | |
4451 */ | |
4452 else if (*T_RBG != NUL | |
4453 && ((tp[0] == ESC && len >= 2 && tp[1] == ']') | |
4454 || tp[0] == OSC)) | |
4455 { | |
4456 j = 1 + (tp[0] == ESC); | |
4457 if (len >= j + 3 && (argp[0] != '1' | |
4458 || argp[1] != '1' || argp[2] != ';')) | |
4459 i = 0; /* no match */ | |
4460 else | |
4461 for (i = j; i < len; ++i) | |
4462 if (tp[i] == '\007' || (tp[0] == OSC ? tp[i] == STERM | |
4463 : (tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\'))) | |
4464 { | |
4465 if (i - j >= 21 && STRNCMP(tp + j + 3, "rgb:", 4) == 0 | |
4466 && tp[j + 11] == '/' && tp[j + 16] == '/' | |
4467 && !option_was_set((char_u *)"bg")) | |
11453
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4468 { |
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4469 char *newval = (3 * '6' < tp[j+7] + tp[j+12] |
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4470 + tp[j+17]) ? "light" : "dark"; |
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4471 |
6901 | 4472 LOG_TR("Received RBG"); |
4473 rbg_status = RBG_GOT; | |
11453
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4474 if (STRCMP(p_bg, newval) != 0) |
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4475 { |
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4476 /* value differs, apply it */ |
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4477 set_option_value((char_u *)"bg", 0L, |
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4478 (char_u *)newval, 0); |
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4479 reset_option_was_set((char_u *)"bg"); |
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4480 redraw_asap(CLEAR); |
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4481 } |
6901 | 4482 } |
4483 | |
4484 /* got finished code: consume it */ | |
4485 key_name[0] = (int)KS_EXTRA; | |
4486 key_name[1] = (int)KE_IGNORE; | |
4487 slen = i + 1 + (tp[i] == ESC); | |
4488 break; | |
4489 } | |
4490 if (i == len) | |
6874 | 4491 { |
6901 | 4492 LOG_TR("not enough characters for RB"); |
4493 return -1; | |
6874 | 4494 } |
7 | 4495 } |
4496 | |
6901 | 4497 /* Check for key code response from xterm: |
4498 * | |
4499 * {lead}{flag}+r<hex bytes><{tail} | |
4500 * | |
4501 * {lead} can be <Esc>P or DCS | |
4502 * {flag} can be '0' or '1' | |
4503 * {tail} can be Esc>\ or STERM | |
4504 * | |
4505 * Consume any code that starts with "{lead}.+r". | |
4506 */ | |
7 | 4507 else if (check_for_codes |
6901 | 4508 && ((tp[0] == ESC && len >= 2 && tp[1] == 'P') |
7 | 4509 || tp[0] == DCS)) |
4510 { | |
6901 | 4511 j = 1 + (tp[0] == ESC); |
4512 if (len >= j + 3 && (argp[1] != '+' || argp[2] != 'r')) | |
4513 i = 0; /* no match */ | |
4514 else | |
4515 for (i = j; i < len; ++i) | |
4516 if ((tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\') | |
7 | 4517 || tp[i] == STERM) |
4518 { | |
6901 | 4519 if (i - j >= 3) |
7 | 4520 got_code_from_term(tp + j, i); |
4521 key_name[0] = (int)KS_EXTRA; | |
4522 key_name[1] = (int)KE_IGNORE; | |
4523 slen = i + 1 + (tp[i] == ESC); | |
4524 break; | |
4525 } | |
4526 | |
4527 if (i == len) | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4528 { |
6901 | 4529 /* These codes arrive many together, each code can be |
4530 * truncated at any point. */ | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4531 LOG_TR("not enough characters for XT"); |
6901 | 4532 return -1; |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4533 } |
7 | 4534 } |
4535 } | |
4536 #endif | |
4537 | |
4538 if (key_name[0] == NUL) | |
4539 continue; /* No match at this position, try next one */ | |
4540 | |
4541 /* We only get here when we have a complete termcode match */ | |
4542 | |
4543 #ifdef FEAT_MOUSE | |
4544 # ifdef FEAT_GUI | |
4545 /* | |
4546 * Only in the GUI: Fetch the pointer coordinates of the scroll event | |
4547 * so that we know which window to scroll later. | |
4548 */ | |
4549 if (gui.in_use | |
4550 && key_name[0] == (int)KS_EXTRA | |
4551 && (key_name[1] == (int)KE_X1MOUSE | |
4552 || key_name[1] == (int)KE_X2MOUSE | |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2347
diff
changeset
|
4553 || key_name[1] == (int)KE_MOUSELEFT |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2347
diff
changeset
|
4554 || key_name[1] == (int)KE_MOUSERIGHT |
7 | 4555 || key_name[1] == (int)KE_MOUSEDOWN |
4556 || key_name[1] == (int)KE_MOUSEUP)) | |
4557 { | |
4558 num_bytes = get_bytes_from_buf(tp + slen, bytes, 4); | |
4559 if (num_bytes == -1) /* not enough coordinates */ | |
4560 return -1; | |
4561 mouse_col = 128 * (bytes[0] - ' ' - 1) + bytes[1] - ' ' - 1; | |
4562 mouse_row = 128 * (bytes[2] - ' ' - 1) + bytes[3] - ' ' - 1; | |
4563 slen += num_bytes; | |
4564 } | |
4565 else | |
4566 # endif | |
4567 /* | |
4568 * If it is a mouse click, get the coordinates. | |
4569 */ | |
3746 | 4570 if (key_name[0] == KS_MOUSE |
7 | 4571 # ifdef FEAT_MOUSE_JSB |
3746 | 4572 || key_name[0] == KS_JSBTERM_MOUSE |
7 | 4573 # endif |
4574 # ifdef FEAT_MOUSE_NET | |
3746 | 4575 || key_name[0] == KS_NETTERM_MOUSE |
7 | 4576 # endif |
4577 # ifdef FEAT_MOUSE_DEC | |
3746 | 4578 || key_name[0] == KS_DEC_MOUSE |
7 | 4579 # endif |
4580 # ifdef FEAT_MOUSE_PTERM | |
3746 | 4581 || key_name[0] == KS_PTERM_MOUSE |
7 | 4582 # endif |
3166 | 4583 # ifdef FEAT_MOUSE_URXVT |
3746 | 4584 || key_name[0] == KS_URXVT_MOUSE |
4585 # endif | |
4586 # ifdef FEAT_MOUSE_SGR | |
4587 || key_name[0] == KS_SGR_MOUSE | |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
4588 || key_name[0] == KS_SGR_MOUSE_RELEASE |
3166 | 4589 # endif |
7 | 4590 ) |
4591 { | |
4592 is_click = is_drag = FALSE; | |
4593 | |
1623 | 4594 # if !defined(UNIX) || defined(FEAT_MOUSE_XTERM) || defined(FEAT_GUI) \ |
4595 || defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE) | |
7 | 4596 if (key_name[0] == (int)KS_MOUSE) |
4597 { | |
4598 /* | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
4599 * For xterm we get "<t_mouse>scr", where |
7 | 4600 * s == encoded button state: |
4601 * 0x20 = left button down | |
4602 * 0x21 = middle button down | |
4603 * 0x22 = right button down | |
4604 * 0x23 = any button release | |
4605 * 0x60 = button 4 down (scroll wheel down) | |
4606 * 0x61 = button 5 down (scroll wheel up) | |
4607 * add 0x04 for SHIFT | |
4608 * add 0x08 for ALT | |
4609 * add 0x10 for CTRL | |
4610 * add 0x20 for mouse drag (0x40 is drag with left button) | |
4611 * c == column + ' ' + 1 == column + 33 | |
4612 * r == row + ' ' + 1 == row + 33 | |
4613 * | |
4614 * The coordinates are passed on through global variables. | |
4615 * Ugly, but this avoids trouble with mouse clicks at an | |
4616 * unexpected moment and allows for mapping them. | |
4617 */ | |
4618 for (;;) | |
4619 { | |
4620 #ifdef FEAT_GUI | |
4621 if (gui.in_use) | |
4622 { | |
4623 /* GUI uses more bits for columns > 223 */ | |
4624 num_bytes = get_bytes_from_buf(tp + slen, bytes, 5); | |
4625 if (num_bytes == -1) /* not enough coordinates */ | |
4626 return -1; | |
4627 mouse_code = bytes[0]; | |
4628 mouse_col = 128 * (bytes[1] - ' ' - 1) | |
4629 + bytes[2] - ' ' - 1; | |
4630 mouse_row = 128 * (bytes[3] - ' ' - 1) | |
4631 + bytes[4] - ' ' - 1; | |
4632 } | |
4633 else | |
4634 #endif | |
4635 { | |
4636 num_bytes = get_bytes_from_buf(tp + slen, bytes, 3); | |
4637 if (num_bytes == -1) /* not enough coordinates */ | |
4638 return -1; | |
4639 mouse_code = bytes[0]; | |
4640 mouse_col = bytes[1] - ' ' - 1; | |
4641 mouse_row = bytes[2] - ' ' - 1; | |
4642 } | |
4643 slen += num_bytes; | |
4644 | |
4645 /* If the following bytes is also a mouse code and it has | |
4646 * the same code, dump this one and get the next. This | |
4647 * makes dragging a whole lot faster. */ | |
4648 #ifdef FEAT_GUI | |
4649 if (gui.in_use) | |
4650 j = 3; | |
4651 else | |
4652 #endif | |
4653 j = termcodes[idx].len; | |
4654 if (STRNCMP(tp, tp + slen, (size_t)j) == 0 | |
4655 && tp[slen + j] == mouse_code | |
4656 && tp[slen + j + 1] != NUL | |
4657 && tp[slen + j + 2] != NUL | |
4658 #ifdef FEAT_GUI | |
4659 && (!gui.in_use | |
4660 || (tp[slen + j + 3] != NUL | |
4661 && tp[slen + j + 4] != NUL)) | |
4662 #endif | |
4663 ) | |
4664 slen += j; | |
4665 else | |
4666 break; | |
4667 } | |
3166 | 4668 } |
4669 | |
3746 | 4670 # if defined(FEAT_MOUSE_URXVT) || defined(FEAT_MOUSE_SGR) |
4671 if (key_name[0] == KS_URXVT_MOUSE | |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
4672 || key_name[0] == KS_SGR_MOUSE |
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
4673 || key_name[0] == KS_SGR_MOUSE_RELEASE) |
3166 | 4674 { |
11567
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4675 /* URXVT 1015 mouse reporting mode: |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4676 * Almost identical to xterm mouse mode, except the values |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4677 * are decimal instead of bytes. |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4678 * |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4679 * \033[%d;%d;%dM |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4680 * ^-- row |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4681 * ^----- column |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4682 * ^-------- code |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4683 * |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4684 * SGR 1006 mouse reporting mode: |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4685 * Almost identical to xterm mouse mode, except the values |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4686 * are decimal instead of bytes. |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4687 * |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4688 * \033[<%d;%d;%dM |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4689 * ^-- row |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4690 * ^----- column |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4691 * ^-------- code |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4692 * |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4693 * \033[<%d;%d;%dm : mouse release event |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4694 * ^-- row |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4695 * ^----- column |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4696 * ^-------- code |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4697 */ |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4698 p = modifiers_start; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4699 if (p == NULL) |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4700 return -1; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4701 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4702 mouse_code = getdigits(&p); |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4703 if (*p++ != ';') |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4704 return -1; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4705 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4706 /* when mouse reporting is SGR, add 32 to mouse code */ |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4707 if (key_name[0] == KS_SGR_MOUSE |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4708 || key_name[0] == KS_SGR_MOUSE_RELEASE) |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4709 mouse_code += 32; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4710 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4711 if (key_name[0] == KS_SGR_MOUSE_RELEASE) |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4712 mouse_code |= MOUSE_RELEASE; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4713 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4714 mouse_col = getdigits(&p) - 1; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4715 if (*p++ != ';') |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4716 return -1; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4717 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4718 mouse_row = getdigits(&p) - 1; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4719 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4720 /* The modifiers were the mouse coordinates, not the |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4721 * modifier keys (alt/shift/ctrl/meta) state. */ |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4722 modifiers = 0; |
3166 | 4723 } |
4724 # endif | |
4725 | |
4726 if (key_name[0] == (int)KS_MOUSE | |
4727 #ifdef FEAT_MOUSE_URXVT | |
4728 || key_name[0] == (int)KS_URXVT_MOUSE | |
4729 #endif | |
3746 | 4730 #ifdef FEAT_MOUSE_SGR |
4731 || key_name[0] == KS_SGR_MOUSE | |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
4732 || key_name[0] == KS_SGR_MOUSE_RELEASE |
3746 | 4733 #endif |
3166 | 4734 ) |
4735 { | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
4736 # if !defined(MSWIN) |
7 | 4737 /* |
4738 * Handle mouse events. | |
4739 * Recognize the xterm mouse wheel, but not in the GUI, the | |
4740 * Linux console with GPM and the MS-DOS or Win32 console | |
4741 * (multi-clicks use >= 0x60). | |
4742 */ | |
4743 if (mouse_code >= MOUSEWHEEL_LOW | |
4744 # ifdef FEAT_GUI | |
4745 && !gui.in_use | |
4746 # endif | |
4747 # ifdef FEAT_MOUSE_GPM | |
4748 && gpm_flag == 0 | |
4749 # endif | |
4750 ) | |
4751 { | |
4752 /* Keep the mouse_code before it's changed, so that we | |
4753 * remember that it was a mouse wheel click. */ | |
4754 wheel_code = mouse_code; | |
4755 } | |
4756 # ifdef FEAT_MOUSE_XTERM | |
4757 else if (held_button == MOUSE_RELEASE | |
4758 # ifdef FEAT_GUI | |
4759 && !gui.in_use | |
4760 # endif | |
4761 && (mouse_code == 0x23 || mouse_code == 0x24)) | |
4762 { | |
4763 /* Apparently used by rxvt scroll wheel. */ | |
4764 wheel_code = mouse_code - 0x23 + MOUSEWHEEL_LOW; | |
4765 } | |
4766 # endif | |
4767 | |
4768 # if defined(UNIX) && defined(FEAT_MOUSE_TTY) | |
4769 else if (use_xterm_mouse() > 1) | |
4770 { | |
4771 if (mouse_code & MOUSE_DRAG_XTERM) | |
4772 mouse_code |= MOUSE_DRAG; | |
4773 } | |
4774 # endif | |
4775 # ifdef FEAT_XCLIPBOARD | |
4776 else if (!(mouse_code & MOUSE_DRAG & ~MOUSE_CLICK_MASK)) | |
4777 { | |
4778 if ((mouse_code & MOUSE_RELEASE) == MOUSE_RELEASE) | |
4779 stop_xterm_trace(); | |
4780 else | |
4781 start_xterm_trace(mouse_code); | |
4782 } | |
4783 # endif | |
4784 # endif | |
4785 } | |
4786 # endif /* !UNIX || FEAT_MOUSE_XTERM */ | |
4787 # ifdef FEAT_MOUSE_NET | |
4788 if (key_name[0] == (int)KS_NETTERM_MOUSE) | |
4789 { | |
4790 int mc, mr; | |
4791 | |
4792 /* expect a rather limited sequence like: balancing { | |
4793 * \033}6,45\r | |
4794 * '6' is the row, 45 is the column | |
4795 */ | |
4796 p = tp + slen; | |
4797 mr = getdigits(&p); | |
4798 if (*p++ != ',') | |
4799 return -1; | |
4800 mc = getdigits(&p); | |
4801 if (*p++ != '\r') | |
4802 return -1; | |
4803 | |
4804 mouse_col = mc - 1; | |
4805 mouse_row = mr - 1; | |
4806 mouse_code = MOUSE_LEFT; | |
4807 slen += (int)(p - (tp + slen)); | |
4808 } | |
4809 # endif /* FEAT_MOUSE_NET */ | |
4810 # ifdef FEAT_MOUSE_JSB | |
4811 if (key_name[0] == (int)KS_JSBTERM_MOUSE) | |
4812 { | |
4813 int mult, val, iter, button, status; | |
4814 | |
4815 /* JSBTERM Input Model | |
4816 * \033[0~zw uniq escape sequence | |
4817 * (L-x) Left button pressed - not pressed x not reporting | |
4818 * (M-x) Middle button pressed - not pressed x not reporting | |
4819 * (R-x) Right button pressed - not pressed x not reporting | |
4820 * (SDmdu) Single , Double click, m mouse move d button down | |
4821 * u button up | |
4822 * ### X cursor position padded to 3 digits | |
4823 * ### Y cursor position padded to 3 digits | |
4824 * (s-x) SHIFT key pressed - not pressed x not reporting | |
4825 * (c-x) CTRL key pressed - not pressed x not reporting | |
2237
770485470e59
Add a few #ifdefs to exclude functions that are not used. (Domnique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
1941
diff
changeset
|
4826 * \033\\ terminating sequence |
7 | 4827 */ |
4828 | |
4829 p = tp + slen; | |
4830 button = mouse_code = 0; | |
4831 switch (*p++) | |
4832 { | |
4833 case 'L': button = 1; break; | |
4834 case '-': break; | |
4835 case 'x': break; /* ignore sequence */ | |
4836 default: return -1; /* Unknown Result */ | |
4837 } | |
4838 switch (*p++) | |
4839 { | |
4840 case 'M': button |= 2; break; | |
4841 case '-': break; | |
4842 case 'x': break; /* ignore sequence */ | |
4843 default: return -1; /* Unknown Result */ | |
4844 } | |
4845 switch (*p++) | |
4846 { | |
4847 case 'R': button |= 4; break; | |
4848 case '-': break; | |
4849 case 'x': break; /* ignore sequence */ | |
4850 default: return -1; /* Unknown Result */ | |
4851 } | |
4852 status = *p++; | |
4853 for (val = 0, mult = 100, iter = 0; iter < 3; iter++, | |
4854 mult /= 10, p++) | |
4855 if (*p >= '0' && *p <= '9') | |
4856 val += (*p - '0') * mult; | |
4857 else | |
4858 return -1; | |
4859 mouse_col = val; | |
4860 for (val = 0, mult = 100, iter = 0; iter < 3; iter++, | |
4861 mult /= 10, p++) | |
4862 if (*p >= '0' && *p <= '9') | |
4863 val += (*p - '0') * mult; | |
4864 else | |
4865 return -1; | |
4866 mouse_row = val; | |
4867 switch (*p++) | |
4868 { | |
4869 case 's': button |= 8; break; /* SHIFT key Pressed */ | |
4870 case '-': break; /* Not Pressed */ | |
4871 case 'x': break; /* Not Reporting */ | |
4872 default: return -1; /* Unknown Result */ | |
4873 } | |
4874 switch (*p++) | |
4875 { | |
4876 case 'c': button |= 16; break; /* CTRL key Pressed */ | |
4877 case '-': break; /* Not Pressed */ | |
4878 case 'x': break; /* Not Reporting */ | |
4879 default: return -1; /* Unknown Result */ | |
4880 } | |
4881 if (*p++ != '\033') | |
4882 return -1; | |
4883 if (*p++ != '\\') | |
4884 return -1; | |
4885 switch (status) | |
4886 { | |
4887 case 'D': /* Double Click */ | |
4888 case 'S': /* Single Click */ | |
4889 if (button & 1) mouse_code |= MOUSE_LEFT; | |
4890 if (button & 2) mouse_code |= MOUSE_MIDDLE; | |
4891 if (button & 4) mouse_code |= MOUSE_RIGHT; | |
4892 if (button & 8) mouse_code |= MOUSE_SHIFT; | |
4893 if (button & 16) mouse_code |= MOUSE_CTRL; | |
4894 break; | |
4895 case 'm': /* Mouse move */ | |
4896 if (button & 1) mouse_code |= MOUSE_LEFT; | |
4897 if (button & 2) mouse_code |= MOUSE_MIDDLE; | |
4898 if (button & 4) mouse_code |= MOUSE_RIGHT; | |
4899 if (button & 8) mouse_code |= MOUSE_SHIFT; | |
4900 if (button & 16) mouse_code |= MOUSE_CTRL; | |
4901 if ((button & 7) != 0) | |
4902 { | |
4903 held_button = mouse_code; | |
4904 mouse_code |= MOUSE_DRAG; | |
4905 } | |
4906 is_drag = TRUE; | |
4907 showmode(); | |
4908 break; | |
4909 case 'd': /* Button Down */ | |
4910 if (button & 1) mouse_code |= MOUSE_LEFT; | |
4911 if (button & 2) mouse_code |= MOUSE_MIDDLE; | |
4912 if (button & 4) mouse_code |= MOUSE_RIGHT; | |
4913 if (button & 8) mouse_code |= MOUSE_SHIFT; | |
4914 if (button & 16) mouse_code |= MOUSE_CTRL; | |
4915 break; | |
4916 case 'u': /* Button Up */ | |
4917 if (button & 1) | |
4918 mouse_code |= MOUSE_LEFT | MOUSE_RELEASE; | |
4919 if (button & 2) | |
4920 mouse_code |= MOUSE_MIDDLE | MOUSE_RELEASE; | |
4921 if (button & 4) | |
4922 mouse_code |= MOUSE_RIGHT | MOUSE_RELEASE; | |
4923 if (button & 8) | |
4924 mouse_code |= MOUSE_SHIFT; | |
4925 if (button & 16) | |
4926 mouse_code |= MOUSE_CTRL; | |
4927 break; | |
4928 default: return -1; /* Unknown Result */ | |
4929 } | |
4930 | |
4931 slen += (p - (tp + slen)); | |
4932 } | |
4933 # endif /* FEAT_MOUSE_JSB */ | |
4934 # ifdef FEAT_MOUSE_DEC | |
4935 if (key_name[0] == (int)KS_DEC_MOUSE) | |
4936 { | |
4937 /* The DEC Locator Input Model | |
4938 * Netterm delivers the code sequence: | |
4939 * \033[2;4;24;80&w (left button down) | |
4940 * \033[3;0;24;80&w (left button up) | |
4941 * \033[6;1;24;80&w (right button down) | |
4942 * \033[7;0;24;80&w (right button up) | |
4943 * CSI Pe ; Pb ; Pr ; Pc ; Pp & w | |
4944 * Pe is the event code | |
4945 * Pb is the button code | |
4946 * Pr is the row coordinate | |
4947 * Pc is the column coordinate | |
4948 * Pp is the third coordinate (page number) | |
4949 * Pe, the event code indicates what event caused this report | |
4950 * The following event codes are defined: | |
4951 * 0 - request, the terminal received an explicit request | |
4952 * for a locator report, but the locator is unavailable | |
4953 * 1 - request, the terminal received an explicit request | |
4954 * for a locator report | |
4955 * 2 - left button down | |
4956 * 3 - left button up | |
4957 * 4 - middle button down | |
4958 * 5 - middle button up | |
4959 * 6 - right button down | |
4960 * 7 - right button up | |
4961 * 8 - fourth button down | |
4962 * 9 - fourth button up | |
4963 * 10 - locator outside filter rectangle | |
4964 * Pb, the button code, ASCII decimal 0-15 indicating which | |
4965 * buttons are down if any. The state of the four buttons | |
4966 * on the locator correspond to the low four bits of the | |
4967 * decimal value, | |
4968 * "1" means button depressed | |
4969 * 0 - no buttons down, | |
4970 * 1 - right, | |
4971 * 2 - middle, | |
4972 * 4 - left, | |
4973 * 8 - fourth | |
4974 * Pr is the row coordinate of the locator position in the page, | |
4975 * encoded as an ASCII decimal value. | |
4976 * If Pr is omitted, the locator position is undefined | |
4977 * (outside the terminal window for example). | |
4978 * Pc is the column coordinate of the locator position in the | |
4979 * page, encoded as an ASCII decimal value. | |
4980 * If Pc is omitted, the locator position is undefined | |
4981 * (outside the terminal window for example). | |
4982 * Pp is the page coordinate of the locator position | |
4983 * encoded as an ASCII decimal value. | |
4984 * The page coordinate may be omitted if the locator is on | |
4985 * page one (the default). We ignore it anyway. | |
4986 */ | |
4987 int Pe, Pb, Pr, Pc; | |
4988 | |
4989 p = tp + slen; | |
4990 | |
4991 /* get event status */ | |
4992 Pe = getdigits(&p); | |
4993 if (*p++ != ';') | |
4994 return -1; | |
4995 | |
4996 /* get button status */ | |
4997 Pb = getdigits(&p); | |
4998 if (*p++ != ';') | |
4999 return -1; | |
5000 | |
5001 /* get row status */ | |
5002 Pr = getdigits(&p); | |
5003 if (*p++ != ';') | |
5004 return -1; | |
5005 | |
5006 /* get column status */ | |
5007 Pc = getdigits(&p); | |
5008 | |
5009 /* the page parameter is optional */ | |
5010 if (*p == ';') | |
5011 { | |
5012 p++; | |
5013 (void)getdigits(&p); | |
5014 } | |
5015 if (*p++ != '&') | |
5016 return -1; | |
5017 if (*p++ != 'w') | |
5018 return -1; | |
5019 | |
5020 mouse_code = 0; | |
5021 switch (Pe) | |
5022 { | |
5023 case 0: return -1; /* position request while unavailable */ | |
5024 case 1: /* a response to a locator position request includes | |
5025 the status of all buttons */ | |
5026 Pb &= 7; /* mask off and ignore fourth button */ | |
5027 if (Pb & 4) | |
5028 mouse_code = MOUSE_LEFT; | |
5029 if (Pb & 2) | |
5030 mouse_code = MOUSE_MIDDLE; | |
5031 if (Pb & 1) | |
5032 mouse_code = MOUSE_RIGHT; | |
5033 if (Pb) | |
5034 { | |
5035 held_button = mouse_code; | |
5036 mouse_code |= MOUSE_DRAG; | |
227 | 5037 WantQueryMouse = TRUE; |
7 | 5038 } |
5039 is_drag = TRUE; | |
5040 showmode(); | |
5041 break; | |
5042 case 2: mouse_code = MOUSE_LEFT; | |
227 | 5043 WantQueryMouse = TRUE; |
7 | 5044 break; |
5045 case 3: mouse_code = MOUSE_RELEASE | MOUSE_LEFT; | |
5046 break; | |
5047 case 4: mouse_code = MOUSE_MIDDLE; | |
227 | 5048 WantQueryMouse = TRUE; |
7 | 5049 break; |
5050 case 5: mouse_code = MOUSE_RELEASE | MOUSE_MIDDLE; | |
5051 break; | |
5052 case 6: mouse_code = MOUSE_RIGHT; | |
227 | 5053 WantQueryMouse = TRUE; |
7 | 5054 break; |
5055 case 7: mouse_code = MOUSE_RELEASE | MOUSE_RIGHT; | |
5056 break; | |
5057 case 8: return -1; /* fourth button down */ | |
5058 case 9: return -1; /* fourth button up */ | |
5059 case 10: return -1; /* mouse outside of filter rectangle */ | |
5060 default: return -1; /* should never occur */ | |
5061 } | |
5062 | |
5063 mouse_col = Pc - 1; | |
5064 mouse_row = Pr - 1; | |
5065 | |
5066 slen += (int)(p - (tp + slen)); | |
5067 } | |
5068 # endif /* FEAT_MOUSE_DEC */ | |
5069 # ifdef FEAT_MOUSE_PTERM | |
5070 if (key_name[0] == (int)KS_PTERM_MOUSE) | |
5071 { | |
2237
770485470e59
Add a few #ifdefs to exclude functions that are not used. (Domnique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
1941
diff
changeset
|
5072 int button, num_clicks, action; |
7 | 5073 |
5074 p = tp + slen; | |
5075 | |
5076 action = getdigits(&p); | |
5077 if (*p++ != ';') | |
5078 return -1; | |
5079 | |
5080 mouse_row = getdigits(&p); | |
5081 if (*p++ != ';') | |
5082 return -1; | |
5083 mouse_col = getdigits(&p); | |
5084 if (*p++ != ';') | |
5085 return -1; | |
5086 | |
5087 button = getdigits(&p); | |
5088 mouse_code = 0; | |
5089 | |
9929
579abc260d85
commit https://github.com/vim/vim/commit/de7762a2c1498e2dc43586feb5f982d661799f85
Christian Brabandt <cb@256bit.org>
parents:
9869
diff
changeset
|
5090 switch (button) |
7 | 5091 { |
5092 case 4: mouse_code = MOUSE_LEFT; break; | |
5093 case 1: mouse_code = MOUSE_RIGHT; break; | |
5094 case 2: mouse_code = MOUSE_MIDDLE; break; | |
5095 default: return -1; | |
5096 } | |
5097 | |
9929
579abc260d85
commit https://github.com/vim/vim/commit/de7762a2c1498e2dc43586feb5f982d661799f85
Christian Brabandt <cb@256bit.org>
parents:
9869
diff
changeset
|
5098 switch (action) |
7 | 5099 { |
5100 case 31: /* Initial press */ | |
5101 if (*p++ != ';') | |
5102 return -1; | |
5103 | |
5104 num_clicks = getdigits(&p); /* Not used */ | |
5105 break; | |
5106 | |
5107 case 32: /* Release */ | |
5108 mouse_code |= MOUSE_RELEASE; | |
5109 break; | |
5110 | |
5111 case 33: /* Drag */ | |
5112 held_button = mouse_code; | |
5113 mouse_code |= MOUSE_DRAG; | |
5114 break; | |
5115 | |
5116 default: | |
5117 return -1; | |
5118 } | |
5119 | |
5120 if (*p++ != 't') | |
5121 return -1; | |
5122 | |
5123 slen += (p - (tp + slen)); | |
5124 } | |
5125 # endif /* FEAT_MOUSE_PTERM */ | |
5126 | |
5127 /* Interpret the mouse code */ | |
5128 current_button = (mouse_code & MOUSE_CLICK_MASK); | |
5129 if (current_button == MOUSE_RELEASE | |
5130 # ifdef FEAT_MOUSE_XTERM | |
5131 && wheel_code == 0 | |
5132 # endif | |
5133 ) | |
5134 { | |
5135 /* | |
5136 * If we get a mouse drag or release event when | |
5137 * there is no mouse button held down (held_button == | |
5138 * MOUSE_RELEASE), produce a K_IGNORE below. | |
5139 * (can happen when you hold down two buttons | |
5140 * and then let them go, or click in the menu bar, but not | |
5141 * on a menu, and drag into the text). | |
5142 */ | |
5143 if ((mouse_code & MOUSE_DRAG) == MOUSE_DRAG) | |
5144 is_drag = TRUE; | |
5145 current_button = held_button; | |
5146 } | |
5147 else if (wheel_code == 0) | |
5148 { | |
5149 # ifdef CHECK_DOUBLE_CLICK | |
5150 # ifdef FEAT_MOUSE_GPM | |
5151 # ifdef FEAT_GUI | |
5152 /* | |
5153 * Only for Unix, when GUI or gpm is not active, we handle | |
5154 * multi-clicks here. | |
5155 */ | |
5156 if (gpm_flag == 0 && !gui.in_use) | |
5157 # else | |
5158 if (gpm_flag == 0) | |
5159 # endif | |
5160 # else | |
5161 # ifdef FEAT_GUI | |
5162 if (!gui.in_use) | |
5163 # endif | |
5164 # endif | |
5165 { | |
5166 /* | |
5167 * Compute the time elapsed since the previous mouse click. | |
5168 */ | |
5169 gettimeofday(&mouse_time, NULL); | |
9125
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5170 if (orig_mouse_time.tv_sec == 0) |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5171 { |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5172 /* |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5173 * Avoid computing the difference between mouse_time |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5174 * and orig_mouse_time for the first click, as the |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5175 * difference would be huge and would cause multiplication |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5176 * overflow. |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5177 */ |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5178 timediff = p_mouset; |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5179 } |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5180 else |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5181 { |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5182 timediff = (mouse_time.tv_usec |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5183 - orig_mouse_time.tv_usec) / 1000; |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5184 if (timediff < 0) |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5185 --orig_mouse_time.tv_sec; |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5186 timediff += (mouse_time.tv_sec |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5187 - orig_mouse_time.tv_sec) * 1000; |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5188 } |
7 | 5189 orig_mouse_time = mouse_time; |
5190 if (mouse_code == orig_mouse_code | |
5191 && timediff < p_mouset | |
5192 && orig_num_clicks != 4 | |
5193 && orig_mouse_col == mouse_col | |
5194 && orig_mouse_row == mouse_row | |
683 | 5195 && ((orig_topline == curwin->w_topline |
7 | 5196 #ifdef FEAT_DIFF |
683 | 5197 && orig_topfill == curwin->w_topfill |
7 | 5198 #endif |
683 | 5199 ) |
5200 #ifdef FEAT_WINDOWS | |
5201 /* Double click in tab pages line also works | |
5202 * when window contents changes. */ | |
5203 || (mouse_row == 0 && firstwin->w_winrow > 0) | |
5204 #endif | |
5205 ) | |
5206 ) | |
7 | 5207 ++orig_num_clicks; |
5208 else | |
5209 orig_num_clicks = 1; | |
5210 orig_mouse_col = mouse_col; | |
5211 orig_mouse_row = mouse_row; | |
5212 orig_topline = curwin->w_topline; | |
5213 #ifdef FEAT_DIFF | |
5214 orig_topfill = curwin->w_topfill; | |
5215 #endif | |
5216 } | |
5217 # if defined(FEAT_GUI) || defined(FEAT_MOUSE_GPM) | |
5218 else | |
5219 orig_num_clicks = NUM_MOUSE_CLICKS(mouse_code); | |
5220 # endif | |
5221 # else | |
5222 orig_num_clicks = NUM_MOUSE_CLICKS(mouse_code); | |
5223 # endif | |
5224 is_click = TRUE; | |
5225 orig_mouse_code = mouse_code; | |
5226 } | |
5227 if (!is_drag) | |
5228 held_button = mouse_code & MOUSE_CLICK_MASK; | |
5229 | |
5230 /* | |
5231 * Translate the actual mouse event into a pseudo mouse event. | |
5232 * First work out what modifiers are to be used. | |
5233 */ | |
5234 if (orig_mouse_code & MOUSE_SHIFT) | |
5235 modifiers |= MOD_MASK_SHIFT; | |
5236 if (orig_mouse_code & MOUSE_CTRL) | |
5237 modifiers |= MOD_MASK_CTRL; | |
5238 if (orig_mouse_code & MOUSE_ALT) | |
5239 modifiers |= MOD_MASK_ALT; | |
5240 if (orig_num_clicks == 2) | |
5241 modifiers |= MOD_MASK_2CLICK; | |
5242 else if (orig_num_clicks == 3) | |
5243 modifiers |= MOD_MASK_3CLICK; | |
5244 else if (orig_num_clicks == 4) | |
5245 modifiers |= MOD_MASK_4CLICK; | |
5246 | |
9929
579abc260d85
commit https://github.com/vim/vim/commit/de7762a2c1498e2dc43586feb5f982d661799f85
Christian Brabandt <cb@256bit.org>
parents:
9869
diff
changeset
|
5247 /* Work out our pseudo mouse event. Note that MOUSE_RELEASE gets |
579abc260d85
commit https://github.com/vim/vim/commit/de7762a2c1498e2dc43586feb5f982d661799f85
Christian Brabandt <cb@256bit.org>
parents:
9869
diff
changeset
|
5248 * added, then it's not mouse up/down. */ |
7 | 5249 key_name[0] = (int)KS_EXTRA; |
9929
579abc260d85
commit https://github.com/vim/vim/commit/de7762a2c1498e2dc43586feb5f982d661799f85
Christian Brabandt <cb@256bit.org>
parents:
9869
diff
changeset
|
5250 if (wheel_code != 0 |
579abc260d85
commit https://github.com/vim/vim/commit/de7762a2c1498e2dc43586feb5f982d661799f85
Christian Brabandt <cb@256bit.org>
parents:
9869
diff
changeset
|
5251 && (wheel_code & MOUSE_RELEASE) != MOUSE_RELEASE) |
2336
1a4a66f0c871
Make CTRL modifier work for mouse wheel. (Benjamin Haskell)
Bram Moolenaar <bram@vim.org>
parents:
2279
diff
changeset
|
5252 { |
1a4a66f0c871
Make CTRL modifier work for mouse wheel. (Benjamin Haskell)
Bram Moolenaar <bram@vim.org>
parents:
2279
diff
changeset
|
5253 if (wheel_code & MOUSE_CTRL) |
1a4a66f0c871
Make CTRL modifier work for mouse wheel. (Benjamin Haskell)
Bram Moolenaar <bram@vim.org>
parents:
2279
diff
changeset
|
5254 modifiers |= MOD_MASK_CTRL; |
2347
9228765d3e13
Also make ALT modifier work for mouse wheel. (Benjamin Haskell)
Bram Moolenaar <bram@vim.org>
parents:
2336
diff
changeset
|
5255 if (wheel_code & MOUSE_ALT) |
9228765d3e13
Also make ALT modifier work for mouse wheel. (Benjamin Haskell)
Bram Moolenaar <bram@vim.org>
parents:
2336
diff
changeset
|
5256 modifiers |= MOD_MASK_ALT; |
7 | 5257 key_name[1] = (wheel_code & 1) |
5258 ? (int)KE_MOUSEUP : (int)KE_MOUSEDOWN; | |
2336
1a4a66f0c871
Make CTRL modifier work for mouse wheel. (Benjamin Haskell)
Bram Moolenaar <bram@vim.org>
parents:
2279
diff
changeset
|
5259 } |
7 | 5260 else |
5261 key_name[1] = get_pseudo_mouse_code(current_button, | |
5262 is_click, is_drag); | |
7256
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5263 |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5264 /* Make sure the mouse position is valid. Some terminals may |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5265 * return weird values. */ |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5266 if (mouse_col >= Columns) |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5267 mouse_col = Columns - 1; |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5268 if (mouse_row >= Rows) |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5269 mouse_row = Rows - 1; |
7 | 5270 } |
5271 #endif /* FEAT_MOUSE */ | |
5272 | |
5273 #ifdef FEAT_GUI | |
5274 /* | |
5275 * If using the GUI, then we get menu and scrollbar events. | |
5276 * | |
5277 * A menu event is encoded as K_SPECIAL, KS_MENU, KE_FILLER followed by | |
5278 * four bytes which are to be taken as a pointer to the vimmenu_T | |
5279 * structure. | |
5280 * | |
1221 | 5281 * A tab line event is encoded as K_SPECIAL KS_TABLINE nr, where "nr" |
685 | 5282 * is one byte with the tab index. |
5283 * | |
7 | 5284 * A scrollbar event is K_SPECIAL, KS_VER_SCROLLBAR, KE_FILLER followed |
5285 * by one byte representing the scrollbar number, and then four bytes | |
5286 * representing a long_u which is the new value of the scrollbar. | |
5287 * | |
5288 * A horizontal scrollbar event is K_SPECIAL, KS_HOR_SCROLLBAR, | |
5289 * KE_FILLER followed by four bytes representing a long_u which is the | |
5290 * new value of the scrollbar. | |
5291 */ | |
5292 # ifdef FEAT_MENU | |
5293 else if (key_name[0] == (int)KS_MENU) | |
5294 { | |
5295 long_u val; | |
5296 | |
5297 num_bytes = get_long_from_buf(tp + slen, &val); | |
5298 if (num_bytes == -1) | |
5299 return -1; | |
5300 current_menu = (vimmenu_T *)val; | |
5301 slen += num_bytes; | |
936 | 5302 |
5303 /* The menu may have been deleted right after it was used, check | |
5304 * for that. */ | |
5305 if (check_menu_pointer(root_menu, current_menu) == FAIL) | |
5306 { | |
5307 key_name[0] = KS_EXTRA; | |
5308 key_name[1] = (int)KE_IGNORE; | |
5309 } | |
7 | 5310 } |
5311 # endif | |
685 | 5312 # ifdef FEAT_GUI_TABLINE |
5313 else if (key_name[0] == (int)KS_TABLINE) | |
5314 { | |
688 | 5315 /* Selecting tabline tab or using its menu. */ |
685 | 5316 num_bytes = get_bytes_from_buf(tp + slen, bytes, 1); |
5317 if (num_bytes == -1) | |
5318 return -1; | |
5319 current_tab = (int)bytes[0]; | |
1394 | 5320 if (current_tab == 255) /* -1 in a byte gives 255 */ |
5321 current_tab = -1; | |
685 | 5322 slen += num_bytes; |
5323 } | |
688 | 5324 else if (key_name[0] == (int)KS_TABMENU) |
5325 { | |
5326 /* Selecting tabline tab or using its menu. */ | |
5327 num_bytes = get_bytes_from_buf(tp + slen, bytes, 2); | |
5328 if (num_bytes == -1) | |
5329 return -1; | |
5330 current_tab = (int)bytes[0]; | |
5331 current_tabmenu = (int)bytes[1]; | |
5332 slen += num_bytes; | |
5333 } | |
685 | 5334 # endif |
7 | 5335 # ifndef USE_ON_FLY_SCROLL |
5336 else if (key_name[0] == (int)KS_VER_SCROLLBAR) | |
5337 { | |
5338 long_u val; | |
5339 | |
5340 /* Get the last scrollbar event in the queue of the same type */ | |
5341 j = 0; | |
5342 for (i = 0; tp[j] == CSI && tp[j + 1] == KS_VER_SCROLLBAR | |
5343 && tp[j + 2] != NUL; ++i) | |
5344 { | |
5345 j += 3; | |
5346 num_bytes = get_bytes_from_buf(tp + j, bytes, 1); | |
5347 if (num_bytes == -1) | |
5348 break; | |
5349 if (i == 0) | |
5350 current_scrollbar = (int)bytes[0]; | |
5351 else if (current_scrollbar != (int)bytes[0]) | |
5352 break; | |
5353 j += num_bytes; | |
5354 num_bytes = get_long_from_buf(tp + j, &val); | |
5355 if (num_bytes == -1) | |
5356 break; | |
5357 scrollbar_value = val; | |
5358 j += num_bytes; | |
5359 slen = j; | |
5360 } | |
5361 if (i == 0) /* not enough characters to make one */ | |
5362 return -1; | |
5363 } | |
5364 else if (key_name[0] == (int)KS_HOR_SCROLLBAR) | |
5365 { | |
5366 long_u val; | |
5367 | |
5368 /* Get the last horiz. scrollbar event in the queue */ | |
5369 j = 0; | |
5370 for (i = 0; tp[j] == CSI && tp[j + 1] == KS_HOR_SCROLLBAR | |
5371 && tp[j + 2] != NUL; ++i) | |
5372 { | |
5373 j += 3; | |
5374 num_bytes = get_long_from_buf(tp + j, &val); | |
5375 if (num_bytes == -1) | |
5376 break; | |
5377 scrollbar_value = val; | |
5378 j += num_bytes; | |
5379 slen = j; | |
5380 } | |
5381 if (i == 0) /* not enough characters to make one */ | |
5382 return -1; | |
5383 } | |
5384 # endif /* !USE_ON_FLY_SCROLL */ | |
5385 #endif /* FEAT_GUI */ | |
5386 | |
180 | 5387 /* |
5388 * Change <xHome> to <Home>, <xUp> to <Up>, etc. | |
5389 */ | |
5390 key = handle_x_keys(TERMCAP2KEY(key_name[0], key_name[1])); | |
5391 | |
5392 /* | |
5393 * Add any modifier codes to our string. | |
5394 */ | |
5395 new_slen = 0; /* Length of what will replace the termcode */ | |
5396 if (modifiers != 0) | |
5397 { | |
5398 /* Some keys have the modifier included. Need to handle that here | |
5399 * to make mappings work. */ | |
5400 key = simplify_key(key, &modifiers); | |
5401 if (modifiers != 0) | |
5402 { | |
5403 string[new_slen++] = K_SPECIAL; | |
5404 string[new_slen++] = (int)KS_MODIFIER; | |
5405 string[new_slen++] = modifiers; | |
5406 } | |
5407 } | |
5408 | |
7 | 5409 /* Finally, add the special key code to our string */ |
180 | 5410 key_name[0] = KEY2TERMCAP0(key); |
5411 key_name[1] = KEY2TERMCAP1(key); | |
7 | 5412 if (key_name[0] == KS_KEY) |
1787 | 5413 { |
5414 /* from ":set <M-b>=xx" */ | |
5415 #ifdef FEAT_MBYTE | |
5416 if (has_mbyte) | |
5417 new_slen += (*mb_char2bytes)(key_name[1], string + new_slen); | |
5418 else | |
5419 #endif | |
5420 string[new_slen++] = key_name[1]; | |
5421 } | |
2672 | 5422 else if (new_slen == 0 && key_name[0] == KS_EXTRA |
5423 && key_name[1] == KE_IGNORE) | |
5424 { | |
5425 /* Do not put K_IGNORE into the buffer, do return KEYLEN_REMOVED | |
5426 * to indicate what happened. */ | |
5427 retval = KEYLEN_REMOVED; | |
5428 } | |
7 | 5429 else |
5430 { | |
5431 string[new_slen++] = K_SPECIAL; | |
5432 string[new_slen++] = key_name[0]; | |
5433 string[new_slen++] = key_name[1]; | |
5434 } | |
5435 string[new_slen] = NUL; | |
5436 extra = new_slen - slen; | |
5437 if (buf == NULL) | |
5438 { | |
5439 if (extra < 0) | |
5440 /* remove matched chars, taking care of noremap */ | |
5441 del_typebuf(-extra, offset); | |
5442 else if (extra > 0) | |
5443 /* insert the extra space we need */ | |
5444 ins_typebuf(string + slen, REMAP_YES, offset, FALSE, FALSE); | |
5445 | |
5446 /* | |
5447 * Careful: del_typebuf() and ins_typebuf() may have reallocated | |
5448 * typebuf.tb_buf[]! | |
5449 */ | |
5450 mch_memmove(typebuf.tb_buf + typebuf.tb_off + offset, string, | |
5451 (size_t)new_slen); | |
5452 } | |
5453 else | |
5454 { | |
5455 if (extra < 0) | |
5456 /* remove matched characters */ | |
5457 mch_memmove(buf + offset, buf + offset - extra, | |
3328 | 5458 (size_t)(*buflen + offset + extra)); |
7 | 5459 else if (extra > 0) |
3328 | 5460 { |
5461 /* Insert the extra space we need. If there is insufficient | |
5462 * space return -1. */ | |
5463 if (*buflen + extra + new_slen >= bufsize) | |
5464 return -1; | |
7 | 5465 mch_memmove(buf + offset + extra, buf + offset, |
3328 | 5466 (size_t)(*buflen - offset)); |
5467 } | |
7 | 5468 mch_memmove(buf + offset, string, (size_t)new_slen); |
3328 | 5469 *buflen = *buflen + extra + new_slen; |
7 | 5470 } |
2672 | 5471 return retval == 0 ? (len + extra + offset) : retval; |
7 | 5472 } |
5473 | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5474 #ifdef FEAT_TERMRESPONSE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5475 LOG_TR("normal character"); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5476 #endif |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5477 |
7 | 5478 return 0; /* no match found */ |
5479 } | |
5480 | |
5481 /* | |
5482 * Replace any terminal code strings in from[] with the equivalent internal | |
5483 * vim representation. This is used for the "from" and "to" part of a | |
5484 * mapping, and the "to" part of a menu command. | |
5485 * Any strings like "<C-UP>" are also replaced, unless 'cpoptions' contains | |
5486 * '<'. | |
5487 * K_SPECIAL by itself is replaced by K_SPECIAL KS_SPECIAL KE_FILLER. | |
5488 * | |
5489 * The replacement is done in result[] and finally copied into allocated | |
5490 * memory. If this all works well *bufp is set to the allocated memory and a | |
5491 * pointer to it is returned. If something fails *bufp is set to NULL and from | |
5492 * is returned. | |
5493 * | |
5494 * CTRL-V characters are removed. When "from_part" is TRUE, a trailing CTRL-V | |
5495 * is included, otherwise it is removed (for ":map xx ^V", maps xx to | |
5496 * nothing). When 'cpoptions' does not contain 'B', a backslash can be used | |
5497 * instead of a CTRL-V. | |
5498 */ | |
859 | 5499 char_u * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5500 replace_termcodes( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5501 char_u *from, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5502 char_u **bufp, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5503 int from_part, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5504 int do_lt, /* also translate <lt> */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5505 int special) /* always accept <key> notation */ |
7 | 5506 { |
5507 int i; | |
5508 int slen; | |
5509 int key; | |
5510 int dlen = 0; | |
5511 char_u *src; | |
5512 int do_backslash; /* backslash is a special character */ | |
5513 int do_special; /* recognize <> key codes */ | |
5514 int do_key_code; /* recognize raw key codes */ | |
5515 char_u *result; /* buffer for resulting string */ | |
5516 | |
5517 do_backslash = (vim_strchr(p_cpo, CPO_BSLASH) == NULL); | |
859 | 5518 do_special = (vim_strchr(p_cpo, CPO_SPECI) == NULL) || special; |
7 | 5519 do_key_code = (vim_strchr(p_cpo, CPO_KEYCODE) == NULL); |
5520 | |
5521 /* | |
5522 * Allocate space for the translation. Worst case a single character is | |
5523 * replaced by 6 bytes (shifted special key), plus a NUL at the end. | |
5524 */ | |
5525 result = alloc((unsigned)STRLEN(from) * 6 + 1); | |
5526 if (result == NULL) /* out of memory */ | |
5527 { | |
5528 *bufp = NULL; | |
5529 return from; | |
5530 } | |
5531 | |
5532 src = from; | |
5533 | |
5534 /* | |
5535 * Check for #n at start only: function key n | |
5536 */ | |
5537 if (from_part && src[0] == '#' && VIM_ISDIGIT(src[1])) /* function key */ | |
5538 { | |
5539 result[dlen++] = K_SPECIAL; | |
5540 result[dlen++] = 'k'; | |
5541 if (src[1] == '0') | |
5542 result[dlen++] = ';'; /* #0 is F10 is "k;" */ | |
5543 else | |
5544 result[dlen++] = src[1]; /* #3 is F3 is "k3" */ | |
5545 src += 2; | |
5546 } | |
5547 | |
5548 /* | |
5549 * Copy each byte from *from to result[dlen] | |
5550 */ | |
5551 while (*src != NUL) | |
5552 { | |
5553 /* | |
5554 * 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
|
5555 * like "<C-S-LeftMouse>" |
7 | 5556 */ |
5557 if (do_special && (do_lt || STRNCMP(src, "<lt>", 4) != 0)) | |
5558 { | |
5559 #ifdef FEAT_EVAL | |
5560 /* | |
5561 * Replace <SID> by K_SNR <script-nr> _. | |
5562 * (room: 5 * 6 = 30 bytes; needed: 3 + <nr> + 1 <= 14) | |
5563 */ | |
5564 if (STRNICMP(src, "<SID>", 5) == 0) | |
5565 { | |
5566 if (current_SID <= 0) | |
5567 EMSG(_(e_usingsid)); | |
5568 else | |
5569 { | |
5570 src += 5; | |
5571 result[dlen++] = K_SPECIAL; | |
5572 result[dlen++] = (int)KS_EXTRA; | |
5573 result[dlen++] = (int)KE_SNR; | |
5574 sprintf((char *)result + dlen, "%ld", (long)current_SID); | |
5575 dlen += (int)STRLEN(result + dlen); | |
5576 result[dlen++] = '_'; | |
5577 continue; | |
5578 } | |
5579 } | |
5580 #endif | |
5581 | |
9869
989d44d35a66
commit https://github.com/vim/vim/commit/35a4cfa200917dd171b1fff3cd5b6cee9add673d
Christian Brabandt <cb@256bit.org>
parents:
9814
diff
changeset
|
5582 slen = trans_special(&src, result + dlen, TRUE, FALSE); |
7 | 5583 if (slen) |
5584 { | |
5585 dlen += slen; | |
5586 continue; | |
5587 } | |
5588 } | |
5589 | |
5590 /* | |
5591 * If 'cpoptions' does not contain 'k', see if it's an actual key-code. | |
5592 * Note that this is also checked after replacing the <> form. | |
5593 * Single character codes are NOT replaced (e.g. ^H or DEL), because | |
5594 * it could be a character in the file. | |
5595 */ | |
5596 if (do_key_code) | |
5597 { | |
5598 i = find_term_bykeys(src); | |
5599 if (i >= 0) | |
5600 { | |
5601 result[dlen++] = K_SPECIAL; | |
5602 result[dlen++] = termcodes[i].name[0]; | |
5603 result[dlen++] = termcodes[i].name[1]; | |
5604 src += termcodes[i].len; | |
5605 /* If terminal code matched, continue after it. */ | |
5606 continue; | |
5607 } | |
5608 } | |
5609 | |
5610 #ifdef FEAT_EVAL | |
5611 if (do_special) | |
5612 { | |
5613 char_u *p, *s, len; | |
5614 | |
5615 /* | |
5616 * Replace <Leader> by the value of "mapleader". | |
5617 * Replace <LocalLeader> by the value of "maplocalleader". | |
5618 * If "mapleader" or "maplocalleader" isn't set use a backslash. | |
5619 */ | |
5620 if (STRNICMP(src, "<Leader>", 8) == 0) | |
5621 { | |
5622 len = 8; | |
5623 p = get_var_value((char_u *)"g:mapleader"); | |
5624 } | |
5625 else if (STRNICMP(src, "<LocalLeader>", 13) == 0) | |
5626 { | |
5627 len = 13; | |
5628 p = get_var_value((char_u *)"g:maplocalleader"); | |
5629 } | |
5630 else | |
5631 { | |
5632 len = 0; | |
5633 p = NULL; | |
5634 } | |
5635 if (len != 0) | |
5636 { | |
5637 /* Allow up to 8 * 6 characters for "mapleader". */ | |
5638 if (p == NULL || *p == NUL || STRLEN(p) > 8 * 6) | |
5639 s = (char_u *)"\\"; | |
5640 else | |
5641 s = p; | |
5642 while (*s != NUL) | |
5643 result[dlen++] = *s++; | |
5644 src += len; | |
5645 continue; | |
5646 } | |
5647 } | |
5648 #endif | |
5649 | |
5650 /* | |
5651 * Remove CTRL-V and ignore the next character. | |
5652 * For "from" side the CTRL-V at the end is included, for the "to" | |
5653 * part it is removed. | |
5654 * If 'cpoptions' does not contain 'B', also accept a backslash. | |
5655 */ | |
5656 key = *src; | |
5657 if (key == Ctrl_V || (do_backslash && key == '\\')) | |
5658 { | |
5659 ++src; /* skip CTRL-V or backslash */ | |
5660 if (*src == NUL) | |
5661 { | |
5662 if (from_part) | |
5663 result[dlen++] = key; | |
5664 break; | |
5665 } | |
5666 } | |
5667 | |
5668 #ifdef FEAT_MBYTE | |
5669 /* skip multibyte char correctly */ | |
474 | 5670 for (i = (*mb_ptr2len)(src); i > 0; --i) |
7 | 5671 #endif |
5672 { | |
5673 /* | |
5674 * If the character is K_SPECIAL, replace it with K_SPECIAL | |
5675 * KS_SPECIAL KE_FILLER. | |
5676 * If compiled with the GUI replace CSI with K_CSI. | |
5677 */ | |
5678 if (*src == K_SPECIAL) | |
5679 { | |
5680 result[dlen++] = K_SPECIAL; | |
5681 result[dlen++] = KS_SPECIAL; | |
5682 result[dlen++] = KE_FILLER; | |
5683 } | |
5684 # ifdef FEAT_GUI | |
5685 else if (*src == CSI) | |
5686 { | |
5687 result[dlen++] = K_SPECIAL; | |
5688 result[dlen++] = KS_EXTRA; | |
5689 result[dlen++] = (int)KE_CSI; | |
5690 } | |
5691 # endif | |
5692 else | |
5693 result[dlen++] = *src; | |
5694 ++src; | |
5695 } | |
5696 } | |
5697 result[dlen] = NUL; | |
5698 | |
5699 /* | |
5700 * Copy the new string to allocated memory. | |
5701 * If this fails, just return from. | |
5702 */ | |
5703 if ((*bufp = vim_strsave(result)) != NULL) | |
5704 from = *bufp; | |
5705 vim_free(result); | |
5706 return from; | |
5707 } | |
5708 | |
5709 /* | |
5710 * Find a termcode with keys 'src' (must be NUL terminated). | |
5711 * Return the index in termcodes[], or -1 if not found. | |
5712 */ | |
5713 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5714 find_term_bykeys(char_u *src) |
7 | 5715 { |
5716 int i; | |
3290 | 5717 int slen = (int)STRLEN(src); |
7 | 5718 |
5719 for (i = 0; i < tc_len; ++i) | |
5720 { | |
3273 | 5721 if (slen == termcodes[i].len |
5722 && STRNCMP(termcodes[i].code, src, (size_t)slen) == 0) | |
7 | 5723 return i; |
5724 } | |
5725 return -1; | |
5726 } | |
5727 | |
5728 /* | |
5729 * Gather the first characters in the terminal key codes into a string. | |
5730 * Used to speed up check_termcode(). | |
5731 */ | |
5732 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5733 gather_termleader(void) |
7 | 5734 { |
5735 int i; | |
5736 int len = 0; | |
5737 | |
5738 #ifdef FEAT_GUI | |
5739 if (gui.in_use) | |
5740 termleader[len++] = CSI; /* the GUI codes are not in termcodes[] */ | |
5741 #endif | |
5742 #ifdef FEAT_TERMRESPONSE | |
5743 if (check_for_codes) | |
5744 termleader[len++] = DCS; /* the termcode response starts with DCS | |
5745 in 8-bit mode */ | |
5746 #endif | |
5747 termleader[len] = NUL; | |
5748 | |
5749 for (i = 0; i < tc_len; ++i) | |
5750 if (vim_strchr(termleader, termcodes[i].code[0]) == NULL) | |
5751 { | |
5752 termleader[len++] = termcodes[i].code[0]; | |
5753 termleader[len] = NUL; | |
5754 } | |
5755 | |
5756 need_gather = FALSE; | |
5757 } | |
5758 | |
5759 /* | |
5760 * Show all termcodes (for ":set termcap") | |
5761 * This code looks a lot like showoptions(), but is different. | |
5762 */ | |
5763 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5764 show_termcodes(void) |
7 | 5765 { |
5766 int col; | |
5767 int *items; | |
5768 int item_count; | |
5769 int run; | |
5770 int row, rows; | |
5771 int cols; | |
5772 int i; | |
5773 int len; | |
5774 | |
180 | 5775 #define INC3 27 /* try to make three columns */ |
5776 #define INC2 40 /* try to make two columns */ | |
7 | 5777 #define GAP 2 /* spaces between columns */ |
5778 | |
5779 if (tc_len == 0) /* no terminal codes (must be GUI) */ | |
5780 return; | |
5781 items = (int *)alloc((unsigned)(sizeof(int) * tc_len)); | |
5782 if (items == NULL) | |
5783 return; | |
5784 | |
5785 /* Highlight title */ | |
5786 MSG_PUTS_TITLE(_("\n--- Terminal keys ---")); | |
5787 | |
5788 /* | |
5789 * do the loop two times: | |
5790 * 1. display the short items (non-strings and short strings) | |
180 | 5791 * 2. display the medium items (medium length strings) |
5792 * 3. display the long items (remaining strings) | |
7 | 5793 */ |
180 | 5794 for (run = 1; run <= 3 && !got_int; ++run) |
7 | 5795 { |
5796 /* | |
5797 * collect the items in items[] | |
5798 */ | |
5799 item_count = 0; | |
5800 for (i = 0; i < tc_len; i++) | |
5801 { | |
5802 len = show_one_termcode(termcodes[i].name, | |
5803 termcodes[i].code, FALSE); | |
180 | 5804 if (len <= INC3 - GAP ? run == 1 |
5805 : len <= INC2 - GAP ? run == 2 | |
5806 : run == 3) | |
7 | 5807 items[item_count++] = i; |
5808 } | |
5809 | |
5810 /* | |
5811 * display the items | |
5812 */ | |
180 | 5813 if (run <= 2) |
7 | 5814 { |
180 | 5815 cols = (Columns + GAP) / (run == 1 ? INC3 : INC2); |
7 | 5816 if (cols == 0) |
5817 cols = 1; | |
5818 rows = (item_count + cols - 1) / cols; | |
5819 } | |
180 | 5820 else /* run == 3 */ |
7 | 5821 rows = item_count; |
5822 for (row = 0; row < rows && !got_int; ++row) | |
5823 { | |
5824 msg_putchar('\n'); /* go to next line */ | |
5825 if (got_int) /* 'q' typed in more */ | |
5826 break; | |
5827 col = 0; | |
5828 for (i = row; i < item_count; i += rows) | |
5829 { | |
5830 msg_col = col; /* make columns */ | |
5831 show_one_termcode(termcodes[items[i]].name, | |
5832 termcodes[items[i]].code, TRUE); | |
180 | 5833 if (run == 2) |
5834 col += INC2; | |
5835 else | |
5836 col += INC3; | |
7 | 5837 } |
5838 out_flush(); | |
5839 ui_breakcheck(); | |
5840 } | |
5841 } | |
5842 vim_free(items); | |
5843 } | |
5844 | |
5845 /* | |
5846 * Show one termcode entry. | |
5847 * Output goes into IObuff[] | |
5848 */ | |
5849 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5850 show_one_termcode(char_u *name, char_u *code, int printit) |
7 | 5851 { |
5852 char_u *p; | |
5853 int len; | |
5854 | |
5855 if (name[0] > '~') | |
5856 { | |
5857 IObuff[0] = ' '; | |
5858 IObuff[1] = ' '; | |
5859 IObuff[2] = ' '; | |
5860 IObuff[3] = ' '; | |
5861 } | |
5862 else | |
5863 { | |
5864 IObuff[0] = 't'; | |
5865 IObuff[1] = '_'; | |
5866 IObuff[2] = name[0]; | |
5867 IObuff[3] = name[1]; | |
5868 } | |
5869 IObuff[4] = ' '; | |
5870 | |
5871 p = get_special_key_name(TERMCAP2KEY(name[0], name[1]), 0); | |
5872 if (p[1] != 't') | |
5873 STRCPY(IObuff + 5, p); | |
5874 else | |
5875 IObuff[5] = NUL; | |
5876 len = (int)STRLEN(IObuff); | |
5877 do | |
5878 IObuff[len++] = ' '; | |
5879 while (len < 17); | |
5880 IObuff[len] = NUL; | |
5881 if (code == NULL) | |
5882 len += 4; | |
5883 else | |
5884 len += vim_strsize(code); | |
5885 | |
5886 if (printit) | |
5887 { | |
5888 msg_puts(IObuff); | |
5889 if (code == NULL) | |
5890 msg_puts((char_u *)"NULL"); | |
5891 else | |
5892 msg_outtrans(code); | |
5893 } | |
5894 return len; | |
5895 } | |
5896 | |
5897 #if defined(FEAT_TERMRESPONSE) || defined(PROTO) | |
5898 /* | |
5899 * For Xterm >= 140 compiled with OPT_TCAP_QUERY: Obtain the actually used | |
5900 * termcap codes from the terminal itself. | |
5901 * We get them one by one to avoid a very long response string. | |
5902 */ | |
6102 | 5903 static int xt_index_in = 0; |
5904 static int xt_index_out = 0; | |
5905 | |
7 | 5906 static void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5907 req_codes_from_term(void) |
7 | 5908 { |
5909 xt_index_out = 0; | |
5910 xt_index_in = 0; | |
5911 req_more_codes_from_term(); | |
5912 } | |
5913 | |
5914 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5915 req_more_codes_from_term(void) |
7 | 5916 { |
5917 char buf[11]; | |
5918 int old_idx = xt_index_out; | |
5919 | |
5920 /* Don't do anything when going to exit. */ | |
5921 if (exiting) | |
5922 return; | |
5923 | |
5924 /* Send up to 10 more requests out than we received. Avoid sending too | |
5925 * many, there can be a buffer overflow somewhere. */ | |
5926 while (xt_index_out < xt_index_in + 10 && key_names[xt_index_out] != NULL) | |
5927 { | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5928 # ifdef DEBUG_TERMRESPONSE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5929 char dbuf[100]; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5930 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5931 sprintf(dbuf, "Requesting XT %d: %s", |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5932 xt_index_out, key_names[xt_index_out]); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5933 log_tr(dbuf); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5934 # endif |
7 | 5935 sprintf(buf, "\033P+q%02x%02x\033\\", |
5936 key_names[xt_index_out][0], key_names[xt_index_out][1]); | |
5937 out_str_nf((char_u *)buf); | |
5938 ++xt_index_out; | |
5939 } | |
5940 | |
5941 /* Send the codes out right away. */ | |
5942 if (xt_index_out != old_idx) | |
5943 out_flush(); | |
5944 } | |
5945 | |
5946 /* | |
5947 * Decode key code response from xterm: '<Esc>P1+r<name>=<string><Esc>\'. | |
5948 * A "0" instead of the "1" indicates a code that isn't supported. | |
5949 * Both <name> and <string> are encoded in hex. | |
5950 * "code" points to the "0" or "1". | |
5951 */ | |
5952 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5953 got_code_from_term(char_u *code, int len) |
7 | 5954 { |
5955 #define XT_LEN 100 | |
5956 char_u name[3]; | |
5957 char_u str[XT_LEN]; | |
5958 int i; | |
5959 int j = 0; | |
5960 int c; | |
5961 | |
5962 /* A '1' means the code is supported, a '0' means it isn't. | |
5963 * When half the length is > XT_LEN we can't use it. | |
5964 * Our names are currently all 2 characters. */ | |
5965 if (code[0] == '1' && code[7] == '=' && len / 2 < XT_LEN) | |
5966 { | |
5967 /* Get the name from the response and find it in the table. */ | |
5968 name[0] = hexhex2nr(code + 3); | |
5969 name[1] = hexhex2nr(code + 5); | |
5970 name[2] = NUL; | |
5971 for (i = 0; key_names[i] != NULL; ++i) | |
5972 { | |
5973 if (STRCMP(key_names[i], name) == 0) | |
5974 { | |
5975 xt_index_in = i; | |
5976 break; | |
5977 } | |
5978 } | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5979 # ifdef DEBUG_TERMRESPONSE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5980 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5981 char buf[100]; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5982 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5983 sprintf(buf, "Received XT %d: %s", xt_index_in, (char *)name); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5984 log_tr(buf); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5985 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5986 # endif |
7 | 5987 if (key_names[i] != NULL) |
5988 { | |
5989 for (i = 8; (c = hexhex2nr(code + i)) >= 0; i += 2) | |
5990 str[j++] = c; | |
5991 str[j] = NUL; | |
5992 if (name[0] == 'C' && name[1] == 'o') | |
5993 { | |
5994 /* Color count is not a key code. */ | |
5995 i = atoi((char *)str); | |
5996 if (i != t_colors) | |
5997 { | |
5998 /* Nr of colors changed, initialize highlighting and | |
680 | 5999 * redraw everything. This causes a redraw, which usually |
6000 * clears the message. Try keeping the message if it | |
6001 * might work. */ | |
6002 set_keep_msg_from_hist(); | |
7 | 6003 set_color_count(i); |
6004 init_highlight(TRUE, FALSE); | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6005 #ifdef DEBUG_TERMRESPONSE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6006 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6007 char buf[100]; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6008 int r = redraw_asap(CLEAR); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6009 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6010 sprintf(buf, "Received t_Co, redraw_asap(): %d", r); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6011 log_tr(buf); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6012 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6013 #else |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6014 redraw_asap(CLEAR); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6015 #endif |
7 | 6016 } |
6017 } | |
6018 else | |
6019 { | |
6020 /* First delete any existing entry with the same code. */ | |
6021 i = find_term_bykeys(str); | |
6022 if (i >= 0) | |
6023 del_termcode_idx(i); | |
180 | 6024 add_termcode(name, str, ATC_FROM_TERM); |
7 | 6025 } |
6026 } | |
6027 } | |
6028 | |
6029 /* May request more codes now that we received one. */ | |
6030 ++xt_index_in; | |
6031 req_more_codes_from_term(); | |
6032 } | |
6033 | |
6034 /* | |
6035 * Check if there are any unanswered requests and deal with them. | |
6036 * This is called before starting an external program or getting direct | |
6037 * keyboard input. We don't want responses to be send to that program or | |
6038 * handled as typed text. | |
6039 */ | |
6040 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6041 check_for_codes_from_term(void) |
7 | 6042 { |
6043 int c; | |
6044 | |
6045 /* If no codes requested or all are answered, no need to wait. */ | |
6046 if (xt_index_out == 0 || xt_index_out == xt_index_in) | |
6047 return; | |
6048 | |
6049 /* Vgetc() will check for and handle any response. | |
6050 * Keep calling vpeekc() until we don't get any responses. */ | |
6051 ++no_mapping; | |
6052 ++allow_keys; | |
6053 for (;;) | |
6054 { | |
6055 c = vpeekc(); | |
6056 if (c == NUL) /* nothing available */ | |
6057 break; | |
6058 | |
6059 /* If a response is recognized it's replaced with K_IGNORE, must read | |
6060 * it from the input stream. If there is no K_IGNORE we can't do | |
6061 * anything, break here (there might be some responses further on, but | |
6062 * we don't want to throw away any typed chars). */ | |
6063 if (c != K_SPECIAL && c != K_IGNORE) | |
6064 break; | |
6065 c = vgetc(); | |
6066 if (c != K_IGNORE) | |
6067 { | |
6068 vungetc(c); | |
6069 break; | |
6070 } | |
6071 } | |
6072 --no_mapping; | |
6073 --allow_keys; | |
6074 } | |
6075 #endif | |
6076 | |
6077 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) | |
6078 /* | |
6079 * Translate an internal mapping/abbreviation representation into the | |
6080 * corresponding external one recognized by :map/:abbrev commands; | |
6081 * respects the current B/k/< settings of 'cpoption'. | |
6082 * | |
6083 * This function is called when expanding mappings/abbreviations on the | |
1902 | 6084 * command-line, and for building the "Ambiguous mapping..." error message. |
7 | 6085 * |
6086 * It uses a growarray to build the translation string since the | |
6087 * latter can be wider than the original description. The caller has to | |
6088 * free the string afterwards. | |
6089 * | |
6090 * Returns NULL when there is a problem. | |
6091 */ | |
6092 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6093 translate_mapping( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6094 char_u *str, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6095 int expmap) /* TRUE when expanding mappings on command-line */ |
7 | 6096 { |
6097 garray_T ga; | |
6098 int c; | |
6099 int modifiers; | |
6100 int cpo_bslash; | |
6101 int cpo_special; | |
6102 int cpo_keycode; | |
6103 | |
6104 ga_init(&ga); | |
6105 ga.ga_itemsize = 1; | |
6106 ga.ga_growsize = 40; | |
6107 | |
6108 cpo_bslash = (vim_strchr(p_cpo, CPO_BSLASH) != NULL); | |
6109 cpo_special = (vim_strchr(p_cpo, CPO_SPECI) != NULL); | |
6110 cpo_keycode = (vim_strchr(p_cpo, CPO_KEYCODE) == NULL); | |
6111 | |
6112 for (; *str; ++str) | |
6113 { | |
6114 c = *str; | |
6115 if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL) | |
6116 { | |
6117 modifiers = 0; | |
6118 if (str[1] == KS_MODIFIER) | |
6119 { | |
6120 str++; | |
6121 modifiers = *++str; | |
6122 c = *++str; | |
6123 } | |
6124 if (cpo_special && cpo_keycode && c == K_SPECIAL && !modifiers) | |
6125 { | |
6126 int i; | |
6127 | |
6128 /* try to find special key in termcodes */ | |
6129 for (i = 0; i < tc_len; ++i) | |
6130 if (termcodes[i].name[0] == str[1] | |
6131 && termcodes[i].name[1] == str[2]) | |
6132 break; | |
6133 if (i < tc_len) | |
6134 { | |
6135 ga_concat(&ga, termcodes[i].code); | |
6136 str += 2; | |
6137 continue; /* for (str) */ | |
6138 } | |
6139 } | |
6140 if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL) | |
6141 { | |
6142 if (expmap && cpo_special) | |
6143 { | |
6144 ga_clear(&ga); | |
6145 return NULL; | |
6146 } | |
6147 c = TO_SPECIAL(str[1], str[2]); | |
6148 if (c == K_ZERO) /* display <Nul> as ^@ */ | |
6149 c = NUL; | |
6150 str += 2; | |
6151 } | |
6152 if (IS_SPECIAL(c) || modifiers) /* special key */ | |
6153 { | |
6154 if (expmap && cpo_special) | |
6155 { | |
6156 ga_clear(&ga); | |
6157 return NULL; | |
6158 } | |
6159 ga_concat(&ga, get_special_key_name(c, modifiers)); | |
6160 continue; /* for (str) */ | |
6161 } | |
6162 } | |
6163 if (c == ' ' || c == '\t' || c == Ctrl_J || c == Ctrl_V | |
6164 || (c == '<' && !cpo_special) || (c == '\\' && !cpo_bslash)) | |
6165 ga_append(&ga, cpo_bslash ? Ctrl_V : '\\'); | |
6166 if (c) | |
6167 ga_append(&ga, c); | |
6168 } | |
6169 ga_append(&ga, NUL); | |
6170 return (char_u *)(ga.ga_data); | |
6171 } | |
6172 #endif | |
6173 | |
6174 #if (defined(WIN3264) && !defined(FEAT_GUI)) || defined(PROTO) | |
6175 static char ksme_str[20]; | |
6176 static char ksmr_str[20]; | |
6177 static char ksmd_str[20]; | |
6178 | |
6179 /* | |
6180 * For Win32 console: update termcap codes for existing console attributes. | |
6181 */ | |
6182 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6183 update_tcap(int attr) |
7 | 6184 { |
6185 struct builtin_term *p; | |
6186 | |
6187 p = find_builtin_term(DEFAULT_TERM); | |
6188 sprintf(ksme_str, IF_EB("\033|%dm", ESC_STR "|%dm"), attr); | |
6189 sprintf(ksmd_str, IF_EB("\033|%dm", ESC_STR "|%dm"), | |
6190 attr | 0x08); /* FOREGROUND_INTENSITY */ | |
6191 sprintf(ksmr_str, IF_EB("\033|%dm", ESC_STR "|%dm"), | |
6192 ((attr & 0x0F) << 4) | ((attr & 0xF0) >> 4)); | |
6193 | |
6194 while (p->bt_string != NULL) | |
6195 { | |
6196 if (p->bt_entry == (int)KS_ME) | |
6197 p->bt_string = &ksme_str[0]; | |
6198 else if (p->bt_entry == (int)KS_MR) | |
6199 p->bt_string = &ksmr_str[0]; | |
6200 else if (p->bt_entry == (int)KS_MD) | |
6201 p->bt_string = &ksmd_str[0]; | |
6202 ++p; | |
6203 } | |
6204 } | |
6205 #endif | |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6206 |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
6207 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) || defined(PROTO) |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6208 static int |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6209 hex_digit(int c) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6210 { |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6211 if (isdigit(c)) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6212 return c - '0'; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6213 c = TOLOWER_ASC(c); |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6214 if (c >= 'a' && c <= 'f') |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6215 return c - 'a' + 10; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6216 return 0x1ffffff; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6217 } |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6218 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6219 guicolor_T |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6220 gui_get_color_cmn(char_u *name) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6221 { |
10512
675dfe47ab69
commit https://github.com/vim/vim/commit/287266527abc163e191a06dd70518bbbdab4468f
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
6222 /* On MS-Windows an RGB macro is available and it produces 0x00bbggrr color |
675dfe47ab69
commit https://github.com/vim/vim/commit/287266527abc163e191a06dd70518bbbdab4468f
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
6223 * values as used by the MS-Windows GDI api. It should be used only for |
675dfe47ab69
commit https://github.com/vim/vim/commit/287266527abc163e191a06dd70518bbbdab4468f
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
6224 * MS-Windows GDI builds. */ |
675dfe47ab69
commit https://github.com/vim/vim/commit/287266527abc163e191a06dd70518bbbdab4468f
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
6225 # if defined(RGB) && defined(WIN32) && !defined(FEAT_GUI) |
675dfe47ab69
commit https://github.com/vim/vim/commit/287266527abc163e191a06dd70518bbbdab4468f
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
6226 # undef RGB |
675dfe47ab69
commit https://github.com/vim/vim/commit/287266527abc163e191a06dd70518bbbdab4468f
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
6227 # endif |
9021
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6228 # ifndef RGB |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6229 # define RGB(r, g, b) ((r<<16) | (g<<8) | (b)) |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6230 # endif |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6231 # define LINE_LEN 100 |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6232 FILE *fd; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6233 char line[LINE_LEN]; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6234 char_u *fname; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6235 int r, g, b, i; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6236 guicolor_T color; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6237 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6238 struct rgbcolor_table_S { |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6239 char_u *color_name; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6240 guicolor_T color; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6241 }; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6242 |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6243 /* Only non X11 colors (not present in rgb.txt) and colors in |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6244 * color_names[], useful when $VIMRUNTIME is not found,. */ |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6245 static struct rgbcolor_table_S rgb_table[] = { |
9021
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6246 {(char_u *)"black", RGB(0x00, 0x00, 0x00)}, |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6247 {(char_u *)"blue", RGB(0x00, 0x00, 0xFF)}, |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6248 {(char_u *)"brown", RGB(0xA5, 0x2A, 0x2A)}, |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6249 {(char_u *)"cyan", RGB(0x00, 0xFF, 0xFF)}, |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6250 {(char_u *)"darkblue", RGB(0x00, 0x00, 0x8B)}, |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6251 {(char_u *)"darkcyan", RGB(0x00, 0x8B, 0x8B)}, |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6252 {(char_u *)"darkgray", RGB(0xA9, 0xA9, 0xA9)}, |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6253 {(char_u *)"darkgreen", RGB(0x00, 0x64, 0x00)}, |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6254 {(char_u *)"darkgrey", RGB(0xA9, 0xA9, 0xA9)}, |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6255 {(char_u *)"darkmagenta", RGB(0x8B, 0x00, 0x8B)}, |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6256 {(char_u *)"darkred", RGB(0x8B, 0x00, 0x00)}, |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6257 {(char_u *)"darkyellow", RGB(0x8B, 0x8B, 0x00)}, /* No X11 */ |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6258 {(char_u *)"gray", RGB(0xBE, 0xBE, 0xBE)}, |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6259 {(char_u *)"green", RGB(0x00, 0xFF, 0x00)}, |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6260 {(char_u *)"grey", RGB(0xBE, 0xBE, 0xBE)}, |
9814
045937335095
commit https://github.com/vim/vim/commit/2147746cf816fad00e301c6638df28a4287c9aae
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
6261 {(char_u *)"grey40", RGB(0x66, 0x66, 0x66)}, |
9601
9cc49b86f613
commit https://github.com/vim/vim/commit/ca8942c6e331a69ddd533dd78931f399f7dcaa79
Christian Brabandt <cb@256bit.org>
parents:
9591
diff
changeset
|
6262 {(char_u *)"grey90", RGB(0xE5, 0xE5, 0xE5)}, |
9021
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6263 {(char_u *)"lightblue", RGB(0xAD, 0xD8, 0xE6)}, |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6264 {(char_u *)"lightcyan", RGB(0xE0, 0xFF, 0xFF)}, |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6265 {(char_u *)"lightgray", RGB(0xD3, 0xD3, 0xD3)}, |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6266 {(char_u *)"lightgreen", RGB(0x90, 0xEE, 0x90)}, |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6267 {(char_u *)"lightgrey", RGB(0xD3, 0xD3, 0xD3)}, |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6268 {(char_u *)"lightmagenta", RGB(0xFF, 0x8B, 0xFF)}, /* No X11 */ |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6269 {(char_u *)"lightred", RGB(0xFF, 0x8B, 0x8B)}, /* No X11 */ |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6270 {(char_u *)"lightyellow", RGB(0xFF, 0xFF, 0xE0)}, |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6271 {(char_u *)"magenta", RGB(0xFF, 0x00, 0xFF)}, |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6272 {(char_u *)"red", RGB(0xFF, 0x00, 0x00)}, |
9601
9cc49b86f613
commit https://github.com/vim/vim/commit/ca8942c6e331a69ddd533dd78931f399f7dcaa79
Christian Brabandt <cb@256bit.org>
parents:
9591
diff
changeset
|
6273 {(char_u *)"seagreen", RGB(0x2E, 0x8B, 0x57)}, |
9021
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6274 {(char_u *)"white", RGB(0xFF, 0xFF, 0xFF)}, |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6275 {(char_u *)"yellow", RGB(0xFF, 0xFF, 0x00)}, |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6276 }; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6277 |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6278 static struct rgbcolor_table_S *colornames_table; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6279 static int size = 0; |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6280 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6281 if (name[0] == '#' && STRLEN(name) == 7) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6282 { |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6283 /* Name is in "#rrggbb" format */ |
9021
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6284 color = RGB(((hex_digit(name[1]) << 4) + hex_digit(name[2])), |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6285 ((hex_digit(name[3]) << 4) + hex_digit(name[4])), |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6286 ((hex_digit(name[5]) << 4) + hex_digit(name[6]))); |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6287 if (color > 0xffffff) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6288 return INVALCOLOR; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6289 return color; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6290 } |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6291 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6292 /* Check if the name is one of the colors we know */ |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6293 for (i = 0; i < (int)(sizeof(rgb_table) / sizeof(rgb_table[0])); i++) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6294 if (STRICMP(name, rgb_table[i].color_name) == 0) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6295 return rgb_table[i].color; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6296 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6297 /* |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6298 * Last attempt. Look in the file "$VIM/rgb.txt". |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6299 */ |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6300 if (size == 0) |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6301 { |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6302 int counting; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6303 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6304 /* colornames_table not yet initialized */ |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6305 fname = expand_env_save((char_u *)"$VIMRUNTIME/rgb.txt"); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6306 if (fname == NULL) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6307 return INVALCOLOR; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6308 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6309 fd = fopen((char *)fname, "rt"); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6310 vim_free(fname); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6311 if (fd == NULL) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6312 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6313 if (p_verbose > 1) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6314 verb_msg((char_u *)_("Cannot open $VIMRUNTIME/rgb.txt")); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6315 return INVALCOLOR; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6316 } |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6317 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6318 for (counting = 1; counting >= 0; --counting) |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6319 { |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6320 if (!counting) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6321 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6322 colornames_table = (struct rgbcolor_table_S *)alloc( |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6323 (unsigned)(sizeof(struct rgbcolor_table_S) * size)); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6324 if (colornames_table == NULL) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6325 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6326 fclose(fd); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6327 return INVALCOLOR; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6328 } |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6329 rewind(fd); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6330 } |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6331 size = 0; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6332 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6333 while (!feof(fd)) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6334 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6335 size_t len; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6336 int pos; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6337 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6338 ignoredp = fgets(line, LINE_LEN, fd); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6339 len = strlen(line); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6340 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6341 if (len <= 1 || line[len - 1] != '\n') |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6342 continue; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6343 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6344 line[len - 1] = '\0'; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6345 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6346 i = sscanf(line, "%d %d %d %n", &r, &g, &b, &pos); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6347 if (i != 3) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6348 continue; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6349 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6350 if (!counting) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6351 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6352 char_u *s = vim_strsave((char_u *)line + pos); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6353 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6354 if (s == NULL) |
9628
fefd0551aa9d
commit https://github.com/vim/vim/commit/2e45d21c819272051f7ef4436f483e4b2ecfb369
Christian Brabandt <cb@256bit.org>
parents:
9601
diff
changeset
|
6355 { |
fefd0551aa9d
commit https://github.com/vim/vim/commit/2e45d21c819272051f7ef4436f483e4b2ecfb369
Christian Brabandt <cb@256bit.org>
parents:
9601
diff
changeset
|
6356 fclose(fd); |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6357 return INVALCOLOR; |
9628
fefd0551aa9d
commit https://github.com/vim/vim/commit/2e45d21c819272051f7ef4436f483e4b2ecfb369
Christian Brabandt <cb@256bit.org>
parents:
9601
diff
changeset
|
6358 } |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6359 colornames_table[size].color_name = s; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6360 colornames_table[size].color = (guicolor_T)RGB(r, g, b); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6361 } |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6362 size++; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6363 } |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6364 } |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6365 fclose(fd); |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6366 } |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6367 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6368 for (i = 0; i < size; i++) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6369 if (STRICMP(name, colornames_table[i].color_name) == 0) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6370 return colornames_table[i].color; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6371 |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6372 return INVALCOLOR; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6373 } |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6374 #endif |