Mercurial > vim
annotate src/term.c @ 27490:fb4c30606b4a v8.2.4273
patch 8.2.4273: the EBCDIC support is outdated
Commit: https://github.com/vim/vim/commit/424bcae1fb0f69e0aef5e0cf84fd771cf34a0fb7
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jan 31 14:59:41 2022 +0000
patch 8.2.4273: the EBCDIC support is outdated
Problem: The EBCDIC support is outdated.
Solution: Remove the EBCDIC support.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 31 Jan 2022 16:00:09 +0100 |
parents | 268f6a3511df |
children | 1761cc771623 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9939
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 /* | |
10 * | |
11 * term.c: functions for controlling the terminal | |
12 * | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
13 * primitive termcap support for Amiga and Win32 included |
7 | 14 * |
15 * NOTE: padding and variable substitution is not performed, | |
16 * when compiling without HAVE_TGETENT, we use tputs() and tgoto() dummies. | |
17 */ | |
18 | |
19 /* | |
20 * Some systems have a prototype for tgetstr() with (char *) instead of | |
21 * (char **). This define removes that prototype. We include our own prototype | |
22 * below. | |
23 */ | |
24 #define tgetstr tgetstr_defined_wrong | |
16378
3d6b282e2d6e
patch 8.1.1194: typos and small problems in source files
Bram Moolenaar <Bram@vim.org>
parents:
16245
diff
changeset
|
25 |
7 | 26 #include "vim.h" |
27 | |
28 #ifdef HAVE_TGETENT | |
29 # ifdef HAVE_TERMIOS_H | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
30 # include <termios.h> // seems to be required for some Linux |
7 | 31 # endif |
32 # ifdef HAVE_TERMCAP_H | |
33 # include <termcap.h> | |
34 # endif | |
35 | |
36 /* | |
37 * A few linux systems define outfuntype in termcap.h to be used as the third | |
38 * argument for tputs(). | |
39 */ | |
40 # ifdef VMS | |
23408
bdda90ed5f6c
patch 8.2.2247: VMS: various smaller problems
Bram Moolenaar <Bram@vim.org>
parents:
23406
diff
changeset
|
41 # define TPUTSFUNCAST (void (*)(unsigned int)) |
7 | 42 # else |
43 # ifdef HAVE_OUTFUNTYPE | |
44 # define TPUTSFUNCAST (outfuntype) | |
45 # else | |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
46 # define TPUTSFUNCAST (int (*)(int)) |
7 | 47 # endif |
48 # endif | |
49 #endif | |
50 | |
51 #undef tgetstr | |
52 | |
53 /* | |
54 * Here are the builtin termcap entries. They are not stored as complete | |
2823 | 55 * structures with all entries, as such a structure is too big. |
7 | 56 * |
57 * The entries are compact, therefore they normally are included even when | |
58 * HAVE_TGETENT is defined. When HAVE_TGETENT is defined, the builtin entries | |
59 * can be accessed with "builtin_amiga", "builtin_ansi", "builtin_debug", etc. | |
60 * | |
61 * Each termcap is a list of builtin_term structures. It always starts with | |
62 * KS_NAME, which separates the entries. See parse_builtin_tcap() for all | |
63 * details. | |
64 * bt_entry is either a KS_xxx code (>= 0), or a K_xxx code. | |
65 * | |
66 * Entries marked with "guessed" may be wrong. | |
67 */ | |
68 struct builtin_term | |
69 { | |
70 int bt_entry; | |
71 char *bt_string; | |
72 }; | |
73 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
74 // start of keys that are not directly used by Vim but can be mapped |
7 | 75 #define BT_EXTRA_KEYS 0x101 |
76 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
77 static void parse_builtin_tcap(char_u *s); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
78 static void gather_termleader(void); |
7 | 79 #ifdef FEAT_TERMRESPONSE |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
80 static void req_codes_from_term(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
81 static void req_more_codes_from_term(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
82 static void got_code_from_term(char_u *code, int len); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
83 static void check_for_codes_from_term(void); |
7 | 84 #endif |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
85 static void del_termcode_idx(int idx); |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
86 static int find_term_bykeys(char_u *src); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
87 static int term_is_builtin(char_u *name); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
88 static int term_7to8bit(char_u *p); |
7 | 89 |
90 #ifdef HAVE_TGETENT | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
91 static char *tgetent_error(char_u *, char_u *); |
7 | 92 |
93 /* | |
94 * Here is our own prototype for tgetstr(), any prototypes from the include | |
95 * files have been disabled by the define at the start of this file. | |
96 */ | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
97 char *tgetstr(char *, char **); |
7 | 98 |
99 # ifdef FEAT_TERMRESPONSE | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
100 // Change this to "if 1" to debug what happens with termresponse. |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
101 # if 0 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
102 # define DEBUG_TERMRESPONSE |
25475
038eb6d9003a
patch 8.2.3274: macro for printf format check can be simplified
Bram Moolenaar <Bram@vim.org>
parents:
25429
diff
changeset
|
103 static void log_tr(const char *fmt, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2); |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
104 # define LOG_TR(msg) log_tr msg |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
105 # else |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
106 # define LOG_TR(msg) do { /**/ } while (0) |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
107 # endif |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
108 |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
109 typedef enum { |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
110 STATUS_GET, // send request when switching to RAW mode |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
111 STATUS_SENT, // did send request, checking for response |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
112 STATUS_GOT, // received response |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
113 STATUS_FAIL // timed out |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
114 } request_progress_T; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
115 |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
116 typedef struct { |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
117 request_progress_T tr_progress; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
118 time_t tr_start; // when request was sent, -1 for never |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
119 } termrequest_T; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
120 |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
121 # define TERMREQUEST_INIT {STATUS_GET, -1} |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
122 |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
123 // Request Terminal Version status: |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
124 static termrequest_T crv_status = TERMREQUEST_INIT; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
125 |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
126 // Request Cursor position report: |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
127 static termrequest_T u7_status = TERMREQUEST_INIT; |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
128 |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
129 // Request xterm compatibility check: |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
130 static termrequest_T xcc_status = TERMREQUEST_INIT; |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
131 |
12634
94566ecb55f0
patch 8.0.1195: can't build on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12632
diff
changeset
|
132 # ifdef FEAT_TERMINAL |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
133 // Request foreground color report: |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
134 static termrequest_T rfg_status = TERMREQUEST_INIT; |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
135 static int fg_r = 0; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
136 static int fg_g = 0; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
137 static int fg_b = 0; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
138 static int bg_r = 255; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
139 static int bg_g = 255; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
140 static int bg_b = 255; |
12634
94566ecb55f0
patch 8.0.1195: can't build on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12632
diff
changeset
|
141 # endif |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
142 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
143 // Request background color report: |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
144 static termrequest_T rbg_status = TERMREQUEST_INIT; |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
145 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
146 // Request cursor blinking mode report: |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
147 static termrequest_T rbm_status = TERMREQUEST_INIT; |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
148 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
149 // Request cursor style report: |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
150 static termrequest_T rcs_status = TERMREQUEST_INIT; |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
151 |
19195
2ef19eed524a
patch 8.2.0156: various typos in source files and tests
Bram Moolenaar <Bram@vim.org>
parents:
19178
diff
changeset
|
152 // Request window's position report: |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
153 static termrequest_T winpos_status = TERMREQUEST_INIT; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
154 |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
155 static termrequest_T *all_termrequests[] = { |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
156 &crv_status, |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
157 &u7_status, |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
158 &xcc_status, |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
159 # ifdef FEAT_TERMINAL |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
160 &rfg_status, |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
161 # endif |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
162 &rbg_status, |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
163 &rbm_status, |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
164 &rcs_status, |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
165 &winpos_status, |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
166 NULL |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
167 }; |
7 | 168 # endif |
169 | |
170 /* | |
171 * Don't declare these variables if termcap.h contains them. | |
172 * Autoconf checks if these variables should be declared extern (not all | |
173 * systems have them). | |
174 * Some versions define ospeed to be speed_t, but that is incompatible with | |
175 * BSD, where ospeed is short and speed_t is long. | |
176 */ | |
177 # ifndef HAVE_OSPEED | |
178 # ifdef OSPEED_EXTERN | |
179 extern short ospeed; | |
180 # else | |
181 short ospeed; | |
182 # endif | |
183 # endif | |
184 # ifndef HAVE_UP_BC_PC | |
185 # ifdef UP_BC_PC_EXTERN | |
186 extern char *UP, *BC, PC; | |
187 # else | |
188 char *UP, *BC, PC; | |
189 # endif | |
190 # endif | |
191 | |
192 # define TGETSTR(s, p) vim_tgetstr((s), (p)) | |
193 # 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
|
194 static char_u *vim_tgetstr(char *s, char_u **pp); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
195 #endif // HAVE_TGETENT |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
196 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
197 static int detected_8bit = FALSE; // detected 8-bit terminal |
7 | 198 |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
199 #if (defined(UNIX) || defined(VMS)) |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
200 static int focus_mode = FALSE; // xterm's "focus reporting" availability |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
201 static int focus_state = FALSE; // TRUE if the terminal window gains focus |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
202 #endif |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
203 |
12184
76fbd85c3cea
patch 8.0.0972: compiler warnings for unused variables
Christian Brabandt <cb@256bit.org>
parents:
12174
diff
changeset
|
204 #ifdef FEAT_TERMRESPONSE |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
205 // When the cursor shape was detected these values are used: |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
206 // 1: block, 2: underline, 3: vertical bar |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
207 static int initial_cursor_shape = 0; |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
208 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
209 // The blink flag from the style response may be inverted from the actual |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
210 // blinking state, xterm XORs the flags. |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
211 static int initial_cursor_shape_blink = FALSE; |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
212 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
213 // The blink flag from the blinking-cursor mode response |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
214 static int initial_cursor_blink = FALSE; |
12184
76fbd85c3cea
patch 8.0.0972: compiler warnings for unused variables
Christian Brabandt <cb@256bit.org>
parents:
12174
diff
changeset
|
215 #endif |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
216 |
298 | 217 static struct builtin_term builtin_termcaps[] = |
7 | 218 { |
219 | |
220 #if defined(FEAT_GUI) | |
221 /* | |
222 * GUI pseudo term-cap. | |
223 */ | |
224 {(int)KS_NAME, "gui"}, | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
225 {(int)KS_CE, "\033|$"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
226 {(int)KS_AL, "\033|i"}, |
7 | 227 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
228 {(int)KS_CAL, "\033|%p1%dI"}, |
7 | 229 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
230 {(int)KS_CAL, "\033|%dI"}, |
7 | 231 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
232 {(int)KS_DL, "\033|d"}, |
7 | 233 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
234 {(int)KS_CDL, "\033|%p1%dD"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
235 {(int)KS_CS, "\033|%p1%d;%p2%dR"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
236 {(int)KS_CSV, "\033|%p1%d;%p2%dV"}, |
7 | 237 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
238 {(int)KS_CDL, "\033|%dD"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
239 {(int)KS_CS, "\033|%d;%dR"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
240 {(int)KS_CSV, "\033|%d;%dV"}, |
7 | 241 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
242 {(int)KS_CL, "\033|C"}, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
243 // attributes switched on with 'h', off with * 'H' |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
244 {(int)KS_ME, "\033|31H"}, // HL_ALL |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
245 {(int)KS_MR, "\033|1h"}, // HL_INVERSE |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
246 {(int)KS_MD, "\033|2h"}, // HL_BOLD |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
247 {(int)KS_SE, "\033|16H"}, // HL_STANDOUT |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
248 {(int)KS_SO, "\033|16h"}, // HL_STANDOUT |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
249 {(int)KS_UE, "\033|8H"}, // HL_UNDERLINE |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
250 {(int)KS_US, "\033|8h"}, // HL_UNDERLINE |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
251 {(int)KS_UCE, "\033|8C"}, // HL_UNDERCURL |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
252 {(int)KS_UCS, "\033|8c"}, // HL_UNDERCURL |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
253 {(int)KS_STE, "\033|4C"}, // HL_STRIKETHROUGH |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
254 {(int)KS_STS, "\033|4c"}, // HL_STRIKETHROUGH |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
255 {(int)KS_CZR, "\033|4H"}, // HL_ITALIC |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
256 {(int)KS_CZH, "\033|4h"}, // HL_ITALIC |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
257 {(int)KS_VB, "\033|f"}, |
7 | 258 {(int)KS_MS, "y"}, |
259 {(int)KS_UT, "y"}, | |
6602 | 260 {(int)KS_XN, "y"}, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
261 {(int)KS_LE, "\b"}, // cursor-left = BS |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
262 {(int)KS_ND, "\014"}, // cursor-right = CTRL-L |
7 | 263 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
264 {(int)KS_CM, "\033|%p1%d;%p2%dM"}, |
7 | 265 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
266 {(int)KS_CM, "\033|%d;%dM"}, |
7 | 267 # endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
268 // there are no key sequences here, the GUI sequences are recognized |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
269 // in check_termcode() |
7 | 270 #endif |
271 | |
272 #ifndef NO_BUILTIN_TCAPS | |
273 | |
274 # if defined(AMIGA) || defined(ALL_BUILTIN_TCAPS) | |
275 /* | |
276 * Amiga console window, default for Amiga | |
277 */ | |
278 {(int)KS_NAME, "amiga"}, | |
279 {(int)KS_CE, "\033[K"}, | |
280 {(int)KS_CD, "\033[J"}, | |
281 {(int)KS_AL, "\033[L"}, | |
282 # ifdef TERMINFO | |
283 {(int)KS_CAL, "\033[%p1%dL"}, | |
284 # else | |
285 {(int)KS_CAL, "\033[%dL"}, | |
286 # endif | |
287 {(int)KS_DL, "\033[M"}, | |
288 # ifdef TERMINFO | |
289 {(int)KS_CDL, "\033[%p1%dM"}, | |
290 # else | |
291 {(int)KS_CDL, "\033[%dM"}, | |
292 # endif | |
293 {(int)KS_CL, "\014"}, | |
294 {(int)KS_VI, "\033[0 p"}, | |
295 {(int)KS_VE, "\033[1 p"}, | |
296 {(int)KS_ME, "\033[0m"}, | |
297 {(int)KS_MR, "\033[7m"}, | |
298 {(int)KS_MD, "\033[1m"}, | |
299 {(int)KS_SE, "\033[0m"}, | |
300 {(int)KS_SO, "\033[33m"}, | |
301 {(int)KS_US, "\033[4m"}, | |
302 {(int)KS_UE, "\033[0m"}, | |
303 {(int)KS_CZH, "\033[3m"}, | |
304 {(int)KS_CZR, "\033[0m"}, | |
22956
9c8af140b2da
patch 8.2.2025: Amiga: Not all colors are used on OS4
Bram Moolenaar <Bram@vim.org>
parents:
22764
diff
changeset
|
305 #if defined(__amigaos4__) || defined(__MORPHOS__) || defined(__AROS__) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
306 {(int)KS_CCO, "8"}, // allow 8 colors |
7 | 307 # ifdef TERMINFO |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
308 {(int)KS_CAB, "\033[4%p1%dm"},// set background color |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
309 {(int)KS_CAF, "\033[3%p1%dm"},// set foreground color |
7 | 310 # else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
311 {(int)KS_CAB, "\033[4%dm"}, // set background color |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
312 {(int)KS_CAF, "\033[3%dm"}, // set foreground color |
7 | 313 # endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
314 {(int)KS_OP, "\033[m"}, // reset colors |
7 | 315 #endif |
316 {(int)KS_MS, "y"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
317 {(int)KS_UT, "y"}, // guessed |
7 | 318 {(int)KS_LE, "\b"}, |
319 # ifdef TERMINFO | |
320 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
321 # else | |
322 {(int)KS_CM, "\033[%i%d;%dH"}, | |
323 # endif | |
324 #if defined(__MORPHOS__) | |
325 {(int)KS_SR, "\033M"}, | |
326 #endif | |
327 # ifdef TERMINFO | |
328 {(int)KS_CRI, "\033[%p1%dC"}, | |
329 # else | |
330 {(int)KS_CRI, "\033[%dC"}, | |
331 # endif | |
332 {K_UP, "\233A"}, | |
333 {K_DOWN, "\233B"}, | |
334 {K_LEFT, "\233D"}, | |
335 {K_RIGHT, "\233C"}, | |
336 {K_S_UP, "\233T"}, | |
337 {K_S_DOWN, "\233S"}, | |
338 {K_S_LEFT, "\233 A"}, | |
339 {K_S_RIGHT, "\233 @"}, | |
340 {K_S_TAB, "\233Z"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
341 {K_F1, "\233\060~"},// some compilers don't dig "\2330" |
7 | 342 {K_F2, "\233\061~"}, |
343 {K_F3, "\233\062~"}, | |
344 {K_F4, "\233\063~"}, | |
345 {K_F5, "\233\064~"}, | |
346 {K_F6, "\233\065~"}, | |
347 {K_F7, "\233\066~"}, | |
348 {K_F8, "\233\067~"}, | |
349 {K_F9, "\233\070~"}, | |
350 {K_F10, "\233\071~"}, | |
351 {K_S_F1, "\233\061\060~"}, | |
352 {K_S_F2, "\233\061\061~"}, | |
353 {K_S_F3, "\233\061\062~"}, | |
354 {K_S_F4, "\233\061\063~"}, | |
355 {K_S_F5, "\233\061\064~"}, | |
356 {K_S_F6, "\233\061\065~"}, | |
357 {K_S_F7, "\233\061\066~"}, | |
358 {K_S_F8, "\233\061\067~"}, | |
359 {K_S_F9, "\233\061\070~"}, | |
360 {K_S_F10, "\233\061\071~"}, | |
361 {K_HELP, "\233?~"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
362 {K_INS, "\233\064\060~"}, // 101 key keyboard |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
363 {K_PAGEUP, "\233\064\061~"}, // 101 key keyboard |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
364 {K_PAGEDOWN, "\233\064\062~"}, // 101 key keyboard |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
365 {K_HOME, "\233\064\064~"}, // 101 key keyboard |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
366 {K_END, "\233\064\065~"}, // 101 key keyboard |
7 | 367 |
368 {BT_EXTRA_KEYS, ""}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
369 {TERMCAP2KEY('#', '2'), "\233\065\064~"}, // shifted home key |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
370 {TERMCAP2KEY('#', '3'), "\233\065\060~"}, // shifted insert key |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
371 {TERMCAP2KEY('*', '7'), "\233\065\065~"}, // shifted end key |
7 | 372 # endif |
373 | |
20591
4411c2b96af9
patch 8.2.0849: BeOS code is not maintained and probably unused
Bram Moolenaar <Bram@vim.org>
parents:
20589
diff
changeset
|
374 # ifdef ALL_BUILTIN_TCAPS |
7 | 375 /* |
20591
4411c2b96af9
patch 8.2.0849: BeOS code is not maintained and probably unused
Bram Moolenaar <Bram@vim.org>
parents:
20589
diff
changeset
|
376 * almost standard ANSI terminal |
7 | 377 */ |
378 {(int)KS_CE, "\033[K"}, | |
379 {(int)KS_CD, "\033[J"}, | |
380 {(int)KS_AL, "\033[L"}, | |
381 # ifdef TERMINFO | |
382 {(int)KS_CAL, "\033[%p1%dL"}, | |
383 # else | |
384 {(int)KS_CAL, "\033[%dL"}, | |
385 # endif | |
386 {(int)KS_DL, "\033[M"}, | |
387 # ifdef TERMINFO | |
388 {(int)KS_CDL, "\033[%p1%dM"}, | |
389 # else | |
390 {(int)KS_CDL, "\033[%dM"}, | |
391 # endif | |
392 {(int)KS_CL, "\033[H\033[2J"}, | |
393 #ifdef notyet | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
394 {(int)KS_VI, "[VI]"}, // cursor invisible, VT320: CSI ? 25 l |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
395 {(int)KS_VE, "[VE]"}, // cursor visible, VT320: CSI ? 25 h |
7 | 396 #endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
397 {(int)KS_ME, "\033[m"}, // normal mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
398 {(int)KS_MR, "\033[7m"}, // reverse |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
399 {(int)KS_MD, "\033[1m"}, // bold |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
400 {(int)KS_SO, "\033[31m"}, // standout mode: red |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
401 {(int)KS_SE, "\033[m"}, // standout end |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
402 {(int)KS_CZH, "\033[35m"}, // italic: purple |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
403 {(int)KS_CZR, "\033[m"}, // italic end |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
404 {(int)KS_US, "\033[4m"}, // underscore mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
405 {(int)KS_UE, "\033[m"}, // underscore end |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
406 {(int)KS_CCO, "8"}, // allow 8 colors |
7 | 407 # ifdef TERMINFO |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
408 {(int)KS_CAB, "\033[4%p1%dm"},// set background color |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
409 {(int)KS_CAF, "\033[3%p1%dm"},// set foreground color |
7 | 410 # else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
411 {(int)KS_CAB, "\033[4%dm"}, // set background color |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
412 {(int)KS_CAF, "\033[3%dm"}, // set foreground color |
7 | 413 # endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
414 {(int)KS_OP, "\033[m"}, // reset colors |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
415 {(int)KS_MS, "y"}, // safe to move cur in reverse mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
416 {(int)KS_UT, "y"}, // guessed |
7 | 417 {(int)KS_LE, "\b"}, |
418 # ifdef TERMINFO | |
419 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
420 # else | |
421 {(int)KS_CM, "\033[%i%d;%dH"}, | |
422 # endif | |
423 {(int)KS_SR, "\033M"}, | |
424 # ifdef TERMINFO | |
425 {(int)KS_CRI, "\033[%p1%dC"}, | |
426 # else | |
427 {(int)KS_CRI, "\033[%dC"}, | |
428 # endif | |
429 | |
430 {K_UP, "\033[A"}, | |
431 {K_DOWN, "\033[B"}, | |
432 {K_LEFT, "\033[D"}, | |
433 {K_RIGHT, "\033[C"}, | |
434 # endif | |
435 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
436 # if defined(UNIX) || defined(ALL_BUILTIN_TCAPS) || defined(SOME_BUILTIN_TCAPS) |
7 | 437 /* |
438 * standard ANSI terminal, default for unix | |
439 */ | |
440 {(int)KS_NAME, "ansi"}, | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
441 {(int)KS_CE, "\033[K"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
442 {(int)KS_AL, "\033[L"}, |
7 | 443 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
444 {(int)KS_CAL, "\033[%p1%dL"}, |
7 | 445 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
446 {(int)KS_CAL, "\033[%dL"}, |
7 | 447 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
448 {(int)KS_DL, "\033[M"}, |
7 | 449 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
450 {(int)KS_CDL, "\033[%p1%dM"}, |
7 | 451 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
452 {(int)KS_CDL, "\033[%dM"}, |
7 | 453 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
454 {(int)KS_CL, "\033[H\033[2J"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
455 {(int)KS_ME, "\033[0m"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
456 {(int)KS_MR, "\033[7m"}, |
7 | 457 {(int)KS_MS, "y"}, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
458 {(int)KS_UT, "y"}, // guessed |
7 | 459 {(int)KS_LE, "\b"}, |
460 # ifdef TERMINFO | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
461 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, |
7 | 462 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
463 {(int)KS_CM, "\033[%i%d;%dH"}, |
7 | 464 # endif |
465 # ifdef TERMINFO | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
466 {(int)KS_CRI, "\033[%p1%dC"}, |
7 | 467 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
468 {(int)KS_CRI, "\033[%dC"}, |
7 | 469 # endif |
470 # endif | |
471 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
472 # if defined(ALL_BUILTIN_TCAPS) |
7 | 473 /* |
474 * These codes are valid when nansi.sys or equivalent has been installed. | |
475 * Function keys on a PC are preceded with a NUL. These are converted into | |
476 * K_NUL '\316' in mch_inchar(), because we cannot handle NULs in key codes. | |
477 * CTRL-arrow is used instead of SHIFT-arrow. | |
478 */ | |
479 {(int)KS_NAME, "pcansi"}, | |
480 {(int)KS_DL, "\033[M"}, | |
481 {(int)KS_AL, "\033[L"}, | |
482 {(int)KS_CE, "\033[K"}, | |
483 {(int)KS_CL, "\033[2J"}, | |
484 {(int)KS_ME, "\033[0m"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
485 {(int)KS_MR, "\033[5m"}, // reverse: black on lightgrey |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
486 {(int)KS_MD, "\033[1m"}, // bold: white text |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
487 {(int)KS_SE, "\033[0m"}, // standout end |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
488 {(int)KS_SO, "\033[31m"}, // standout: white on blue |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
489 {(int)KS_CZH, "\033[34;43m"}, // italic mode: blue text on yellow |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
490 {(int)KS_CZR, "\033[0m"}, // italic mode end |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
491 {(int)KS_US, "\033[36;41m"}, // underscore mode: cyan text on red |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
492 {(int)KS_UE, "\033[0m"}, // underscore mode end |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
493 {(int)KS_CCO, "8"}, // allow 8 colors |
7 | 494 # ifdef TERMINFO |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
495 {(int)KS_CAB, "\033[4%p1%dm"},// set background color |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
496 {(int)KS_CAF, "\033[3%p1%dm"},// set foreground color |
7 | 497 # else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
498 {(int)KS_CAB, "\033[4%dm"}, // set background color |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
499 {(int)KS_CAF, "\033[3%dm"}, // set foreground color |
7 | 500 # endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
501 {(int)KS_OP, "\033[0m"}, // reset colors |
7 | 502 {(int)KS_MS, "y"}, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
503 {(int)KS_UT, "y"}, // guessed |
7 | 504 {(int)KS_LE, "\b"}, |
505 # ifdef TERMINFO | |
506 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
507 # else | |
508 {(int)KS_CM, "\033[%i%d;%dH"}, | |
509 # endif | |
510 # ifdef TERMINFO | |
511 {(int)KS_CRI, "\033[%p1%dC"}, | |
512 # else | |
513 {(int)KS_CRI, "\033[%dC"}, | |
514 # endif | |
515 {K_UP, "\316H"}, | |
516 {K_DOWN, "\316P"}, | |
517 {K_LEFT, "\316K"}, | |
518 {K_RIGHT, "\316M"}, | |
519 {K_S_LEFT, "\316s"}, | |
520 {K_S_RIGHT, "\316t"}, | |
521 {K_F1, "\316;"}, | |
522 {K_F2, "\316<"}, | |
523 {K_F3, "\316="}, | |
524 {K_F4, "\316>"}, | |
525 {K_F5, "\316?"}, | |
526 {K_F6, "\316@"}, | |
527 {K_F7, "\316A"}, | |
528 {K_F8, "\316B"}, | |
529 {K_F9, "\316C"}, | |
530 {K_F10, "\316D"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
531 {K_F11, "\316\205"}, // guessed |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
532 {K_F12, "\316\206"}, // guessed |
7 | 533 {K_S_F1, "\316T"}, |
534 {K_S_F2, "\316U"}, | |
535 {K_S_F3, "\316V"}, | |
536 {K_S_F4, "\316W"}, | |
537 {K_S_F5, "\316X"}, | |
538 {K_S_F6, "\316Y"}, | |
539 {K_S_F7, "\316Z"}, | |
540 {K_S_F8, "\316["}, | |
541 {K_S_F9, "\316\\"}, | |
542 {K_S_F10, "\316]"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
543 {K_S_F11, "\316\207"}, // guessed |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
544 {K_S_F12, "\316\210"}, // guessed |
7 | 545 {K_INS, "\316R"}, |
546 {K_DEL, "\316S"}, | |
547 {K_HOME, "\316G"}, | |
548 {K_END, "\316O"}, | |
549 {K_PAGEDOWN, "\316Q"}, | |
550 {K_PAGEUP, "\316I"}, | |
551 # endif | |
552 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15852
diff
changeset
|
553 # if defined(MSWIN) || defined(ALL_BUILTIN_TCAPS) |
7 | 554 /* |
555 * These codes are valid for the Win32 Console . The entries that start with | |
556 * ESC | are translated into console calls in os_win32.c. The function keys | |
557 * are also translated in os_win32.c. | |
558 */ | |
559 {(int)KS_NAME, "win32"}, | |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
560 {(int)KS_CE, "\033|K"}, // clear to end of line |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
561 {(int)KS_AL, "\033|L"}, // add new blank line |
7 | 562 # ifdef TERMINFO |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
563 {(int)KS_CAL, "\033|%p1%dL"}, // add number of new blank lines |
7 | 564 # else |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
565 {(int)KS_CAL, "\033|%dL"}, // add number of new blank lines |
7 | 566 # endif |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
567 {(int)KS_DL, "\033|M"}, // delete line |
7 | 568 # ifdef TERMINFO |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
569 {(int)KS_CDL, "\033|%p1%dM"}, // delete number of lines |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
570 {(int)KS_CSV, "\033|%p1%d;%p2%dV"}, |
7 | 571 # else |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
572 {(int)KS_CDL, "\033|%dM"}, // delete number of lines |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
573 {(int)KS_CSV, "\033|%d;%dV"}, |
7 | 574 # endif |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
575 {(int)KS_CL, "\033|J"}, // clear screen |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
576 {(int)KS_CD, "\033|j"}, // clear to end of display |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
577 {(int)KS_VI, "\033|v"}, // cursor invisible |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
578 {(int)KS_VE, "\033|V"}, // cursor visible |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
579 |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
580 {(int)KS_ME, "\033|0m"}, // normal |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
581 {(int)KS_MR, "\033|112m"}, // reverse: black on lightgray |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
582 {(int)KS_MD, "\033|15m"}, // bold: white on black |
7 | 583 #if 1 |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
584 {(int)KS_SO, "\033|31m"}, // standout: white on blue |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
585 {(int)KS_SE, "\033|0m"}, // standout end |
7 | 586 #else |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
587 {(int)KS_SO, "\033|F"}, // standout: high intensity |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
588 {(int)KS_SE, "\033|f"}, // standout end |
7 | 589 #endif |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
590 {(int)KS_CZH, "\033|225m"}, // italic: blue text on yellow |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
591 {(int)KS_CZR, "\033|0m"}, // italic end |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
592 {(int)KS_US, "\033|67m"}, // underscore: cyan text on red |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
593 {(int)KS_UE, "\033|0m"}, // underscore end |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
594 {(int)KS_CCO, "16"}, // allow 16 colors |
7 | 595 # ifdef TERMINFO |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
596 {(int)KS_CAB, "\033|%p1%db"}, // set background color |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
597 {(int)KS_CAF, "\033|%p1%df"}, // set foreground color |
7 | 598 # else |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
599 {(int)KS_CAB, "\033|%db"}, // set background color |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
600 {(int)KS_CAF, "\033|%df"}, // set foreground color |
7 | 601 # endif |
602 | |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
603 {(int)KS_MS, "y"}, // save to move cur in reverse mode |
7 | 604 {(int)KS_UT, "y"}, |
6602 | 605 {(int)KS_XN, "y"}, |
7 | 606 {(int)KS_LE, "\b"}, |
607 # ifdef TERMINFO | |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
608 {(int)KS_CM, "\033|%i%p1%d;%p2%dH"}, // cursor motion |
7 | 609 # else |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
610 {(int)KS_CM, "\033|%i%d;%dH"}, // cursor motion |
7 | 611 # endif |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
612 {(int)KS_VB, "\033|B"}, // visual bell |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
613 {(int)KS_TI, "\033|S"}, // put terminal in termcap mode |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
614 {(int)KS_TE, "\033|E"}, // out of termcap mode |
7 | 615 # ifdef TERMINFO |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
616 {(int)KS_CS, "\033|%i%p1%d;%p2%dr"}, // scroll region |
7 | 617 # else |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
618 {(int)KS_CS, "\033|%i%d;%dr"}, // scroll region |
7 | 619 # endif |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
620 # ifdef FEAT_TERMGUICOLORS |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
621 {(int)KS_8F, "\033|38;2;%lu;%lu;%lum"}, |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
622 {(int)KS_8B, "\033|48;2;%lu;%lu;%lum"}, |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
623 # endif |
7 | 624 |
625 {K_UP, "\316H"}, | |
626 {K_DOWN, "\316P"}, | |
627 {K_LEFT, "\316K"}, | |
628 {K_RIGHT, "\316M"}, | |
629 {K_S_UP, "\316\304"}, | |
630 {K_S_DOWN, "\316\317"}, | |
631 {K_S_LEFT, "\316\311"}, | |
632 {K_C_LEFT, "\316s"}, | |
633 {K_S_RIGHT, "\316\313"}, | |
634 {K_C_RIGHT, "\316t"}, | |
635 {K_S_TAB, "\316\017"}, | |
636 {K_F1, "\316;"}, | |
637 {K_F2, "\316<"}, | |
638 {K_F3, "\316="}, | |
639 {K_F4, "\316>"}, | |
640 {K_F5, "\316?"}, | |
641 {K_F6, "\316@"}, | |
642 {K_F7, "\316A"}, | |
643 {K_F8, "\316B"}, | |
644 {K_F9, "\316C"}, | |
645 {K_F10, "\316D"}, | |
646 {K_F11, "\316\205"}, | |
647 {K_F12, "\316\206"}, | |
648 {K_S_F1, "\316T"}, | |
649 {K_S_F2, "\316U"}, | |
650 {K_S_F3, "\316V"}, | |
651 {K_S_F4, "\316W"}, | |
652 {K_S_F5, "\316X"}, | |
653 {K_S_F6, "\316Y"}, | |
654 {K_S_F7, "\316Z"}, | |
655 {K_S_F8, "\316["}, | |
656 {K_S_F9, "\316\\"}, | |
657 {K_S_F10, "\316]"}, | |
658 {K_S_F11, "\316\207"}, | |
659 {K_S_F12, "\316\210"}, | |
660 {K_INS, "\316R"}, | |
661 {K_DEL, "\316S"}, | |
662 {K_HOME, "\316G"}, | |
663 {K_S_HOME, "\316\302"}, | |
664 {K_C_HOME, "\316w"}, | |
665 {K_END, "\316O"}, | |
666 {K_S_END, "\316\315"}, | |
667 {K_C_END, "\316u"}, | |
668 {K_PAGEDOWN, "\316Q"}, | |
669 {K_PAGEUP, "\316I"}, | |
670 {K_KPLUS, "\316N"}, | |
671 {K_KMINUS, "\316J"}, | |
672 {K_KMULTIPLY, "\316\067"}, | |
673 {K_K0, "\316\332"}, | |
674 {K_K1, "\316\336"}, | |
675 {K_K2, "\316\342"}, | |
676 {K_K3, "\316\346"}, | |
677 {K_K4, "\316\352"}, | |
678 {K_K5, "\316\356"}, | |
679 {K_K6, "\316\362"}, | |
680 {K_K7, "\316\366"}, | |
681 {K_K8, "\316\372"}, | |
682 {K_K9, "\316\376"}, | |
16182
bed0d7200635
patch 8.1.1096: MS-Windows: cannot distinguish BS and CTRL-H
Bram Moolenaar <Bram@vim.org>
parents:
16058
diff
changeset
|
683 {K_BS, "\316x"}, |
7 | 684 # endif |
685 | |
686 # if defined(VMS) || defined(ALL_BUILTIN_TCAPS) | |
687 /* | |
688 * VT320 is working as an ANSI terminal compatible DEC terminal. | |
689 * (it covers VT1x0, VT2x0 and VT3x0 up to VT320 on VMS as well) | |
690 * TODO:- rewrite ESC[ codes to CSI | |
691 * - keyboard languages (CSI ? 26 n) | |
692 */ | |
693 {(int)KS_NAME, "vt320"}, | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
694 {(int)KS_CE, "\033[K"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
695 {(int)KS_AL, "\033[L"}, |
7 | 696 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
697 {(int)KS_CAL, "\033[%p1%dL"}, |
7 | 698 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
699 {(int)KS_CAL, "\033[%dL"}, |
7 | 700 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
701 {(int)KS_DL, "\033[M"}, |
7 | 702 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
703 {(int)KS_CDL, "\033[%p1%dM"}, |
7 | 704 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
705 {(int)KS_CDL, "\033[%dM"}, |
7 | 706 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
707 {(int)KS_CL, "\033[H\033[2J"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
708 {(int)KS_CD, "\033[J"}, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
709 {(int)KS_CCO, "8"}, // allow 8 colors |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
710 {(int)KS_ME, "\033[0m"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
711 {(int)KS_MR, "\033[7m"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
712 {(int)KS_MD, "\033[1m"}, // bold mode |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
713 {(int)KS_SE, "\033[22m"},// normal mode |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
714 {(int)KS_UE, "\033[24m"},// exit underscore mode |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
715 {(int)KS_US, "\033[4m"}, // underscore mode |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
716 {(int)KS_CZH, "\033[34;43m"}, // italic mode: blue text on yellow |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
717 {(int)KS_CZR, "\033[0m"}, // italic mode end |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
718 {(int)KS_CAB, "\033[4%dm"}, // set background color (ANSI) |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
719 {(int)KS_CAF, "\033[3%dm"}, // set foreground color (ANSI) |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
720 {(int)KS_CSB, "\033[102;%dm"}, // set screen background color |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
721 {(int)KS_CSF, "\033[101;%dm"}, // set screen foreground color |
7 | 722 {(int)KS_MS, "y"}, |
723 {(int)KS_UT, "y"}, | |
6602 | 724 {(int)KS_XN, "y"}, |
7 | 725 {(int)KS_LE, "\b"}, |
726 # ifdef TERMINFO | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
727 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, |
7 | 728 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
729 {(int)KS_CM, "\033[%i%d;%dH"}, |
7 | 730 # endif |
731 # ifdef TERMINFO | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
732 {(int)KS_CRI, "\033[%p1%dC"}, |
7 | 733 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
734 {(int)KS_CRI, "\033[%dC"}, |
7 | 735 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
736 {K_UP, "\033[A"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
737 {K_DOWN, "\033[B"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
738 {K_RIGHT, "\033[C"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
739 {K_LEFT, "\033[D"}, |
14252
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
740 // Note: cursor key sequences for application cursor mode are omitted, |
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
741 // because they interfere with typed commands: <Esc>OA. |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
742 {K_F1, "\033[11~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
743 {K_F2, "\033[12~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
744 {K_F3, "\033[13~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
745 {K_F4, "\033[14~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
746 {K_F5, "\033[15~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
747 {K_F6, "\033[17~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
748 {K_F7, "\033[18~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
749 {K_F8, "\033[19~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
750 {K_F9, "\033[20~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
751 {K_F10, "\033[21~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
752 {K_F11, "\033[23~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
753 {K_F12, "\033[24~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
754 {K_F13, "\033[25~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
755 {K_F14, "\033[26~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
756 {K_F15, "\033[28~"}, // Help |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
757 {K_F16, "\033[29~"}, // Select |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
758 {K_F17, "\033[31~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
759 {K_F18, "\033[32~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
760 {K_F19, "\033[33~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
761 {K_F20, "\033[34~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
762 {K_INS, "\033[2~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
763 {K_DEL, "\033[3~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
764 {K_HOME, "\033[1~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
765 {K_END, "\033[4~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
766 {K_PAGEUP, "\033[5~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
767 {K_PAGEDOWN, "\033[6~"}, |
14252
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
768 // These sequences starting with <Esc> O may interfere with what the user |
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
769 // is typing. Remove these if that bothers you. |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
770 {K_KPLUS, "\033Ok"}, // keypad plus |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
771 {K_KMINUS, "\033Om"}, // keypad minus |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
772 {K_KDIVIDE, "\033Oo"}, // keypad / |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
773 {K_KMULTIPLY, "\033Oj"}, // keypad * |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
774 {K_KENTER, "\033OM"}, // keypad Enter |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
775 {K_K0, "\033Op"}, // keypad 0 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
776 {K_K1, "\033Oq"}, // keypad 1 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
777 {K_K2, "\033Or"}, // keypad 2 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
778 {K_K3, "\033Os"}, // keypad 3 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
779 {K_K4, "\033Ot"}, // keypad 4 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
780 {K_K5, "\033Ou"}, // keypad 5 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
781 {K_K6, "\033Ov"}, // keypad 6 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
782 {K_K7, "\033Ow"}, // keypad 7 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
783 {K_K8, "\033Ox"}, // keypad 8 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
784 {K_K9, "\033Oy"}, // keypad 9 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
785 {K_BS, "\x7f"}, // for some reason 0177 doesn't work |
7 | 786 # endif |
787 | |
21329
bb3f60b0aca0
patch 8.2.1215: Atari MiNT support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
21226
diff
changeset
|
788 # if defined(ALL_BUILTIN_TCAPS) |
7 | 789 /* |
790 * Ordinary vt52 | |
791 */ | |
792 {(int)KS_NAME, "vt52"}, | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
793 {(int)KS_CE, "\033K"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
794 {(int)KS_CD, "\033J"}, |
7264
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
795 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
796 {(int)KS_CM, "\033Y%p1%' '%+%c%p2%' '%+%c"}, |
7264
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
797 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
798 {(int)KS_CM, "\033Y%+ %+ "}, |
7264
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
799 # endif |
7 | 800 {(int)KS_LE, "\b"}, |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
801 {(int)KS_SR, "\033I"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
802 {(int)KS_AL, "\033L"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
803 {(int)KS_DL, "\033M"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
804 {K_UP, "\033A"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
805 {K_DOWN, "\033B"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
806 {K_LEFT, "\033D"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
807 {K_RIGHT, "\033C"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
808 {K_F1, "\033P"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
809 {K_F2, "\033Q"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
810 {K_F3, "\033R"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
811 {(int)KS_CL, "\033H\033J"}, |
7 | 812 {(int)KS_MS, "y"}, |
813 # endif | |
814 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
815 # 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
|
816 {(int)KS_NAME, "xterm"}, |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
817 {(int)KS_CE, "\033[K"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
818 {(int)KS_AL, "\033[L"}, |
7 | 819 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
820 {(int)KS_CAL, "\033[%p1%dL"}, |
7 | 821 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
822 {(int)KS_CAL, "\033[%dL"}, |
7 | 823 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
824 {(int)KS_DL, "\033[M"}, |
7 | 825 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
826 {(int)KS_CDL, "\033[%p1%dM"}, |
7 | 827 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
828 {(int)KS_CDL, "\033[%dM"}, |
7 | 829 # endif |
830 # ifdef TERMINFO | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
831 {(int)KS_CS, "\033[%i%p1%d;%p2%dr"}, |
7 | 832 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
833 {(int)KS_CS, "\033[%i%d;%dr"}, |
7 | 834 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
835 {(int)KS_CL, "\033[H\033[2J"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
836 {(int)KS_CD, "\033[J"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
837 {(int)KS_ME, "\033[m"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
838 {(int)KS_MR, "\033[7m"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
839 {(int)KS_MD, "\033[1m"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
840 {(int)KS_UE, "\033[m"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
841 {(int)KS_US, "\033[4m"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
842 {(int)KS_STE, "\033[29m"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
843 {(int)KS_STS, "\033[9m"}, |
7 | 844 {(int)KS_MS, "y"}, |
845 {(int)KS_UT, "y"}, | |
846 {(int)KS_LE, "\b"}, | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
847 {(int)KS_VI, "\033[?25l"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
848 {(int)KS_VE, "\033[?25h"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
849 {(int)KS_VS, "\033[?12h"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
850 {(int)KS_CVS, "\033[?12l"}, |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
851 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
852 {(int)KS_CSH, "\033[%p1%d q"}, |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
853 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
854 {(int)KS_CSH, "\033[%d q"}, |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
855 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
856 {(int)KS_CRC, "\033[?12$p"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
857 {(int)KS_CRS, "\033P$q q\033\\"}, |
7 | 858 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
859 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, |
7 | 860 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
861 {(int)KS_CM, "\033[%i%d;%dH"}, |
7 | 862 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
863 {(int)KS_SR, "\033M"}, |
7 | 864 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
865 {(int)KS_CRI, "\033[%p1%dC"}, |
7 | 866 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
867 {(int)KS_CRI, "\033[%dC"}, |
7 | 868 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
869 {(int)KS_KS, "\033[?1h\033="}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
870 {(int)KS_KE, "\033[?1l\033>"}, |
7 | 871 # ifdef FEAT_XTERM_SAVE |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
872 {(int)KS_TI, "\0337\033[?47h"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
873 {(int)KS_TE, "\033[?47l\0338"}, |
7 | 874 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
875 {(int)KS_CTI, "\033[>4;2m"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
876 {(int)KS_CTE, "\033[>4;m"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
877 {(int)KS_CIS, "\033]1;"}, |
7 | 878 {(int)KS_CIE, "\007"}, |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
879 {(int)KS_TS, "\033]2;"}, |
7 | 880 {(int)KS_FS, "\007"}, |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
881 {(int)KS_CSC, "\033]12;"}, |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
882 {(int)KS_CEC, "\007"}, |
7 | 883 # ifdef TERMINFO |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
884 {(int)KS_CWS, "\033[8;%p1%d;%p2%dt"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
885 {(int)KS_CWP, "\033[3;%p1%d;%p2%dt"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
886 {(int)KS_CGP, "\033[13t"}, |
7 | 887 # else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
888 {(int)KS_CWS, "\033[8;%d;%dt"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
889 {(int)KS_CWP, "\033[3;%d;%dt"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
890 {(int)KS_CGP, "\033[13t"}, |
7 | 891 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
892 {(int)KS_CRV, "\033[>c"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
893 {(int)KS_RFG, "\033]10;?\007"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
894 {(int)KS_RBG, "\033]11;?\007"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
895 {(int)KS_U7, "\033[6n"}, |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
896 # ifdef FEAT_TERMGUICOLORS |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
897 // These are printf strings, not terminal codes. |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
898 {(int)KS_8F, "\033[38;2;%lu;%lu;%lum"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
899 {(int)KS_8B, "\033[48;2;%lu;%lu;%lum"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
900 {(int)KS_8U, "\033[58;2;%lu;%lu;%lum"}, |
8985
42eb58c9da92
commit https://github.com/vim/vim/commit/b2fa54a84078e2b8dc3c7c7bfbccf6b75c0788d0
Christian Brabandt <cb@256bit.org>
parents:
8981
diff
changeset
|
901 # endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
902 {(int)KS_CAU, "\033[58;5;%dm"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
903 {(int)KS_CBE, "\033[?2004h"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
904 {(int)KS_CBD, "\033[?2004l"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
905 {(int)KS_CST, "\033[22;2t"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
906 {(int)KS_CRT, "\033[23;2t"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
907 {(int)KS_SSI, "\033[22;1t"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
908 {(int)KS_SRI, "\033[23;1t"}, |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
909 # if (defined(UNIX) || defined(VMS)) |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
910 {(int)KS_FD, "\033[?1004l"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
911 {(int)KS_FE, "\033[?1004h"}, |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
912 # endif |
180 | 913 |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
914 {K_UP, "\033O*A"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
915 {K_DOWN, "\033O*B"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
916 {K_RIGHT, "\033O*C"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
917 {K_LEFT, "\033O*D"}, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
918 // An extra set of cursor keys for vt100 mode |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
919 {K_XUP, "\033[@;*A"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
920 {K_XDOWN, "\033[@;*B"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
921 {K_XRIGHT, "\033[@;*C"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
922 {K_XLEFT, "\033[@;*D"}, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
923 // An extra set of function keys for vt100 mode |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
924 {K_XF1, "\033O*P"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
925 {K_XF2, "\033O*Q"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
926 {K_XF3, "\033O*R"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
927 {K_XF4, "\033O*S"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
928 {K_F1, "\033[11;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
929 {K_F2, "\033[12;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
930 {K_F3, "\033[13;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
931 {K_F4, "\033[14;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
932 {K_F5, "\033[15;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
933 {K_F6, "\033[17;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
934 {K_F7, "\033[18;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
935 {K_F8, "\033[19;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
936 {K_F9, "\033[20;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
937 {K_F10, "\033[21;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
938 {K_F11, "\033[23;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
939 {K_F12, "\033[24;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
940 {K_S_TAB, "\033[Z"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
941 {K_HELP, "\033[28;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
942 {K_UNDO, "\033[26;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
943 {K_INS, "\033[2;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
944 {K_HOME, "\033[1;*H"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
945 // {K_S_HOME, "\033O2H"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
946 // {K_C_HOME, "\033O5H"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
947 {K_KHOME, "\033[1;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
948 {K_XHOME, "\033O*H"}, // other Home |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
949 {K_ZHOME, "\033[7;*~"}, // other Home |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
950 {K_END, "\033[1;*F"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
951 // {K_S_END, "\033O2F"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
952 // {K_C_END, "\033O5F"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
953 {K_KEND, "\033[4;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
954 {K_XEND, "\033O*F"}, // other End |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
955 {K_ZEND, "\033[8;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
956 {K_PAGEUP, "\033[5;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
957 {K_PAGEDOWN, "\033[6;*~"}, |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
958 {K_KPLUS, "\033O*k"}, // keypad plus |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
959 {K_KMINUS, "\033O*m"}, // keypad minus |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
960 {K_KDIVIDE, "\033O*o"}, // keypad / |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
961 {K_KMULTIPLY, "\033O*j"}, // keypad * |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
962 {K_KENTER, "\033O*M"}, // keypad Enter |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
963 {K_KPOINT, "\033O*n"}, // keypad . |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
964 {K_K0, "\033O*p"}, // keypad 0 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
965 {K_K1, "\033O*q"}, // keypad 1 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
966 {K_K2, "\033O*r"}, // keypad 2 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
967 {K_K3, "\033O*s"}, // keypad 3 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
968 {K_K4, "\033O*t"}, // keypad 4 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
969 {K_K5, "\033O*u"}, // keypad 5 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
970 {K_K6, "\033O*v"}, // keypad 6 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
971 {K_K7, "\033O*w"}, // keypad 7 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
972 {K_K8, "\033O*x"}, // keypad 8 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
973 {K_K9, "\033O*y"}, // keypad 9 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
974 {K_KDEL, "\033[3;*~"}, // keypad Del |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
975 {K_PS, "\033[200~"}, // paste start |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
976 {K_PE, "\033[201~"}, // paste end |
7 | 977 |
978 {BT_EXTRA_KEYS, ""}, | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
979 {TERMCAP2KEY('k', '0'), "\033[10;*~"}, // F0 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
980 {TERMCAP2KEY('F', '3'), "\033[25;*~"}, // F13 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
981 // F14 and F15 are missing, because they send the same codes as the undo |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
982 // and help key, although they don't work on all keyboards. |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
983 {TERMCAP2KEY('F', '6'), "\033[29;*~"}, // F16 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
984 {TERMCAP2KEY('F', '7'), "\033[31;*~"}, // F17 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
985 {TERMCAP2KEY('F', '8'), "\033[32;*~"}, // F18 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
986 {TERMCAP2KEY('F', '9'), "\033[33;*~"}, // F19 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
987 {TERMCAP2KEY('F', 'A'), "\033[34;*~"}, // F20 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
988 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
989 {TERMCAP2KEY('F', 'B'), "\033[42;*~"}, // F21 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
990 {TERMCAP2KEY('F', 'C'), "\033[43;*~"}, // F22 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
991 {TERMCAP2KEY('F', 'D'), "\033[44;*~"}, // F23 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
992 {TERMCAP2KEY('F', 'E'), "\033[45;*~"}, // F24 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
993 {TERMCAP2KEY('F', 'F'), "\033[46;*~"}, // F25 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
994 {TERMCAP2KEY('F', 'G'), "\033[47;*~"}, // F26 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
995 {TERMCAP2KEY('F', 'H'), "\033[48;*~"}, // F27 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
996 {TERMCAP2KEY('F', 'I'), "\033[49;*~"}, // F28 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
997 {TERMCAP2KEY('F', 'J'), "\033[50;*~"}, // F29 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
998 {TERMCAP2KEY('F', 'K'), "\033[51;*~"}, // F30 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
999 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
1000 {TERMCAP2KEY('F', 'L'), "\033[52;*~"}, // F31 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
1001 {TERMCAP2KEY('F', 'M'), "\033[53;*~"}, // F32 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
1002 {TERMCAP2KEY('F', 'N'), "\033[54;*~"}, // F33 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
1003 {TERMCAP2KEY('F', 'O'), "\033[55;*~"}, // F34 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
1004 {TERMCAP2KEY('F', 'P'), "\033[56;*~"}, // F35 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
1005 {TERMCAP2KEY('F', 'Q'), "\033[57;*~"}, // F36 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
1006 {TERMCAP2KEY('F', 'R'), "\033[58;*~"}, // F37 |
7 | 1007 # endif |
1008 | |
1009 # if defined(UNIX) || defined(ALL_BUILTIN_TCAPS) | |
1010 /* | |
1011 * iris-ansi for Silicon Graphics machines. | |
1012 */ | |
1013 {(int)KS_NAME, "iris-ansi"}, | |
1014 {(int)KS_CE, "\033[K"}, | |
1015 {(int)KS_CD, "\033[J"}, | |
1016 {(int)KS_AL, "\033[L"}, | |
1017 # ifdef TERMINFO | |
1018 {(int)KS_CAL, "\033[%p1%dL"}, | |
1019 # else | |
1020 {(int)KS_CAL, "\033[%dL"}, | |
1021 # endif | |
1022 {(int)KS_DL, "\033[M"}, | |
1023 # ifdef TERMINFO | |
1024 {(int)KS_CDL, "\033[%p1%dM"}, | |
1025 # else | |
1026 {(int)KS_CDL, "\033[%dM"}, | |
1027 # endif | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1028 #if 0 // The scroll region is not working as Vim expects. |
7 | 1029 # ifdef TERMINFO |
1030 {(int)KS_CS, "\033[%i%p1%d;%p2%dr"}, | |
1031 # else | |
1032 {(int)KS_CS, "\033[%i%d;%dr"}, | |
1033 # endif | |
1034 #endif | |
1035 {(int)KS_CL, "\033[H\033[2J"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1036 {(int)KS_VE, "\033[9/y\033[12/y"}, // These aren't documented |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1037 {(int)KS_VS, "\033[10/y\033[=1h\033[=2l"}, // These aren't documented |
7 | 1038 {(int)KS_TI, "\033[=6h"}, |
1039 {(int)KS_TE, "\033[=6l"}, | |
1040 {(int)KS_SE, "\033[21;27m"}, | |
1041 {(int)KS_SO, "\033[1;7m"}, | |
1042 {(int)KS_ME, "\033[m"}, | |
1043 {(int)KS_MR, "\033[7m"}, | |
1044 {(int)KS_MD, "\033[1m"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1045 {(int)KS_CCO, "8"}, // allow 8 colors |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1046 {(int)KS_CZH, "\033[3m"}, // italic mode on |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1047 {(int)KS_CZR, "\033[23m"}, // italic mode off |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1048 {(int)KS_US, "\033[4m"}, // underline on |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1049 {(int)KS_UE, "\033[24m"}, // underline off |
7 | 1050 # ifdef TERMINFO |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1051 {(int)KS_CAB, "\033[4%p1%dm"}, // set background color (ANSI) |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1052 {(int)KS_CAF, "\033[3%p1%dm"}, // set foreground color (ANSI) |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1053 {(int)KS_CSB, "\033[102;%p1%dm"}, // set screen background color |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1054 {(int)KS_CSF, "\033[101;%p1%dm"}, // set screen foreground color |
7 | 1055 # else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1056 {(int)KS_CAB, "\033[4%dm"}, // set background color (ANSI) |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1057 {(int)KS_CAF, "\033[3%dm"}, // set foreground color (ANSI) |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1058 {(int)KS_CSB, "\033[102;%dm"}, // set screen background color |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1059 {(int)KS_CSF, "\033[101;%dm"}, // set screen foreground color |
7 | 1060 # endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1061 {(int)KS_MS, "y"}, // guessed |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1062 {(int)KS_UT, "y"}, // guessed |
7 | 1063 {(int)KS_LE, "\b"}, |
1064 # ifdef TERMINFO | |
1065 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
1066 # else | |
1067 {(int)KS_CM, "\033[%i%d;%dH"}, | |
1068 # endif | |
1069 {(int)KS_SR, "\033M"}, | |
1070 # ifdef TERMINFO | |
1071 {(int)KS_CRI, "\033[%p1%dC"}, | |
1072 # else | |
1073 {(int)KS_CRI, "\033[%dC"}, | |
1074 # endif | |
1075 {(int)KS_CIS, "\033P3.y"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1076 {(int)KS_CIE, "\234"}, // ST "String Terminator" |
7 | 1077 {(int)KS_TS, "\033P1.y"}, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1078 {(int)KS_FS, "\234"}, // ST "String Terminator" |
7 | 1079 # ifdef TERMINFO |
1080 {(int)KS_CWS, "\033[203;%p1%d;%p2%d/y"}, | |
1081 {(int)KS_CWP, "\033[205;%p1%d;%p2%d/y"}, | |
1082 # else | |
1083 {(int)KS_CWS, "\033[203;%d;%d/y"}, | |
1084 {(int)KS_CWP, "\033[205;%d;%d/y"}, | |
1085 # endif | |
1086 {K_UP, "\033[A"}, | |
1087 {K_DOWN, "\033[B"}, | |
1088 {K_LEFT, "\033[D"}, | |
1089 {K_RIGHT, "\033[C"}, | |
1090 {K_S_UP, "\033[161q"}, | |
1091 {K_S_DOWN, "\033[164q"}, | |
1092 {K_S_LEFT, "\033[158q"}, | |
1093 {K_S_RIGHT, "\033[167q"}, | |
1094 {K_F1, "\033[001q"}, | |
1095 {K_F2, "\033[002q"}, | |
1096 {K_F3, "\033[003q"}, | |
1097 {K_F4, "\033[004q"}, | |
1098 {K_F5, "\033[005q"}, | |
1099 {K_F6, "\033[006q"}, | |
1100 {K_F7, "\033[007q"}, | |
1101 {K_F8, "\033[008q"}, | |
1102 {K_F9, "\033[009q"}, | |
1103 {K_F10, "\033[010q"}, | |
1104 {K_F11, "\033[011q"}, | |
1105 {K_F12, "\033[012q"}, | |
1106 {K_S_F1, "\033[013q"}, | |
1107 {K_S_F2, "\033[014q"}, | |
1108 {K_S_F3, "\033[015q"}, | |
1109 {K_S_F4, "\033[016q"}, | |
1110 {K_S_F5, "\033[017q"}, | |
1111 {K_S_F6, "\033[018q"}, | |
1112 {K_S_F7, "\033[019q"}, | |
1113 {K_S_F8, "\033[020q"}, | |
1114 {K_S_F9, "\033[021q"}, | |
1115 {K_S_F10, "\033[022q"}, | |
1116 {K_S_F11, "\033[023q"}, | |
1117 {K_S_F12, "\033[024q"}, | |
1118 {K_INS, "\033[139q"}, | |
1119 {K_HOME, "\033[H"}, | |
1120 {K_END, "\033[146q"}, | |
1121 {K_PAGEUP, "\033[150q"}, | |
1122 {K_PAGEDOWN, "\033[154q"}, | |
1123 # endif | |
1124 | |
1125 # if defined(DEBUG) || defined(ALL_BUILTIN_TCAPS) | |
1126 /* | |
1127 * for debugging | |
1128 */ | |
1129 {(int)KS_NAME, "debug"}, | |
1130 {(int)KS_CE, "[CE]"}, | |
1131 {(int)KS_CD, "[CD]"}, | |
1132 {(int)KS_AL, "[AL]"}, | |
1133 # ifdef TERMINFO | |
1134 {(int)KS_CAL, "[CAL%p1%d]"}, | |
1135 # else | |
1136 {(int)KS_CAL, "[CAL%d]"}, | |
1137 # endif | |
1138 {(int)KS_DL, "[DL]"}, | |
1139 # ifdef TERMINFO | |
1140 {(int)KS_CDL, "[CDL%p1%d]"}, | |
1141 # else | |
1142 {(int)KS_CDL, "[CDL%d]"}, | |
1143 # endif | |
1144 # ifdef TERMINFO | |
1145 {(int)KS_CS, "[%p1%dCS%p2%d]"}, | |
1146 # else | |
1147 {(int)KS_CS, "[%dCS%d]"}, | |
1148 # endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12429
diff
changeset
|
1149 # ifdef TERMINFO |
7 | 1150 {(int)KS_CSV, "[%p1%dCSV%p2%d]"}, |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12429
diff
changeset
|
1151 # else |
7 | 1152 {(int)KS_CSV, "[%dCSV%d]"}, |
1153 # endif | |
1154 # ifdef TERMINFO | |
1155 {(int)KS_CAB, "[CAB%p1%d]"}, | |
1156 {(int)KS_CAF, "[CAF%p1%d]"}, | |
1157 {(int)KS_CSB, "[CSB%p1%d]"}, | |
1158 {(int)KS_CSF, "[CSF%p1%d]"}, | |
1159 # else | |
1160 {(int)KS_CAB, "[CAB%d]"}, | |
1161 {(int)KS_CAF, "[CAF%d]"}, | |
1162 {(int)KS_CSB, "[CSB%d]"}, | |
1163 {(int)KS_CSF, "[CSF%d]"}, | |
1164 # endif | |
20619
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
1165 {(int)KS_CAU, "[CAU%d]"}, |
7 | 1166 {(int)KS_OP, "[OP]"}, |
1167 {(int)KS_LE, "[LE]"}, | |
1168 {(int)KS_CL, "[CL]"}, | |
1169 {(int)KS_VI, "[VI]"}, | |
1170 {(int)KS_VE, "[VE]"}, | |
1171 {(int)KS_VS, "[VS]"}, | |
1172 {(int)KS_ME, "[ME]"}, | |
1173 {(int)KS_MR, "[MR]"}, | |
1174 {(int)KS_MB, "[MB]"}, | |
1175 {(int)KS_MD, "[MD]"}, | |
1176 {(int)KS_SE, "[SE]"}, | |
1177 {(int)KS_SO, "[SO]"}, | |
1178 {(int)KS_UE, "[UE]"}, | |
1179 {(int)KS_US, "[US]"}, | |
205 | 1180 {(int)KS_UCE, "[UCE]"}, |
1181 {(int)KS_UCS, "[UCS]"}, | |
12317
2a8890b80923
patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents:
12307
diff
changeset
|
1182 {(int)KS_STE, "[STE]"}, |
2a8890b80923
patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents:
12307
diff
changeset
|
1183 {(int)KS_STS, "[STS]"}, |
7 | 1184 {(int)KS_MS, "[MS]"}, |
1185 {(int)KS_UT, "[UT]"}, | |
6602 | 1186 {(int)KS_XN, "[XN]"}, |
7 | 1187 # ifdef TERMINFO |
1188 {(int)KS_CM, "[%p1%dCM%p2%d]"}, | |
1189 # else | |
1190 {(int)KS_CM, "[%dCM%d]"}, | |
1191 # endif | |
1192 {(int)KS_SR, "[SR]"}, | |
1193 # ifdef TERMINFO | |
1194 {(int)KS_CRI, "[CRI%p1%d]"}, | |
1195 # else | |
1196 {(int)KS_CRI, "[CRI%d]"}, | |
1197 # endif | |
1198 {(int)KS_VB, "[VB]"}, | |
1199 {(int)KS_KS, "[KS]"}, | |
1200 {(int)KS_KE, "[KE]"}, | |
1201 {(int)KS_TI, "[TI]"}, | |
1202 {(int)KS_TE, "[TE]"}, | |
1203 {(int)KS_CIS, "[CIS]"}, | |
1204 {(int)KS_CIE, "[CIE]"}, | |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
1205 {(int)KS_CSC, "[CSC]"}, |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
1206 {(int)KS_CEC, "[CEC]"}, |
7 | 1207 {(int)KS_TS, "[TS]"}, |
1208 {(int)KS_FS, "[FS]"}, | |
1209 # ifdef TERMINFO | |
1210 {(int)KS_CWS, "[%p1%dCWS%p2%d]"}, | |
1211 {(int)KS_CWP, "[%p1%dCWP%p2%d]"}, | |
1212 # else | |
1213 {(int)KS_CWS, "[%dCWS%d]"}, | |
1214 {(int)KS_CWP, "[%dCWP%d]"}, | |
1215 # endif | |
1216 {(int)KS_CRV, "[CRV]"}, | |
4215 | 1217 {(int)KS_U7, "[U7]"}, |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
1218 {(int)KS_RFG, "[RFG]"}, |
6874 | 1219 {(int)KS_RBG, "[RBG]"}, |
7 | 1220 {K_UP, "[KU]"}, |
1221 {K_DOWN, "[KD]"}, | |
1222 {K_LEFT, "[KL]"}, | |
1223 {K_RIGHT, "[KR]"}, | |
180 | 1224 {K_XUP, "[xKU]"}, |
1225 {K_XDOWN, "[xKD]"}, | |
1226 {K_XLEFT, "[xKL]"}, | |
1227 {K_XRIGHT, "[xKR]"}, | |
7 | 1228 {K_S_UP, "[S-KU]"}, |
1229 {K_S_DOWN, "[S-KD]"}, | |
1230 {K_S_LEFT, "[S-KL]"}, | |
1231 {K_C_LEFT, "[C-KL]"}, | |
1232 {K_S_RIGHT, "[S-KR]"}, | |
1233 {K_C_RIGHT, "[C-KR]"}, | |
1234 {K_F1, "[F1]"}, | |
1235 {K_XF1, "[xF1]"}, | |
1236 {K_F2, "[F2]"}, | |
1237 {K_XF2, "[xF2]"}, | |
1238 {K_F3, "[F3]"}, | |
1239 {K_XF3, "[xF3]"}, | |
1240 {K_F4, "[F4]"}, | |
1241 {K_XF4, "[xF4]"}, | |
1242 {K_F5, "[F5]"}, | |
1243 {K_F6, "[F6]"}, | |
1244 {K_F7, "[F7]"}, | |
1245 {K_F8, "[F8]"}, | |
1246 {K_F9, "[F9]"}, | |
1247 {K_F10, "[F10]"}, | |
1248 {K_F11, "[F11]"}, | |
1249 {K_F12, "[F12]"}, | |
1250 {K_S_F1, "[S-F1]"}, | |
1251 {K_S_XF1, "[S-xF1]"}, | |
1252 {K_S_F2, "[S-F2]"}, | |
1253 {K_S_XF2, "[S-xF2]"}, | |
1254 {K_S_F3, "[S-F3]"}, | |
1255 {K_S_XF3, "[S-xF3]"}, | |
1256 {K_S_F4, "[S-F4]"}, | |
1257 {K_S_XF4, "[S-xF4]"}, | |
1258 {K_S_F5, "[S-F5]"}, | |
1259 {K_S_F6, "[S-F6]"}, | |
1260 {K_S_F7, "[S-F7]"}, | |
1261 {K_S_F8, "[S-F8]"}, | |
1262 {K_S_F9, "[S-F9]"}, | |
1263 {K_S_F10, "[S-F10]"}, | |
1264 {K_S_F11, "[S-F11]"}, | |
1265 {K_S_F12, "[S-F12]"}, | |
1266 {K_HELP, "[HELP]"}, | |
1267 {K_UNDO, "[UNDO]"}, | |
1268 {K_BS, "[BS]"}, | |
1269 {K_INS, "[INS]"}, | |
1270 {K_KINS, "[KINS]"}, | |
1271 {K_DEL, "[DEL]"}, | |
1272 {K_KDEL, "[KDEL]"}, | |
1273 {K_HOME, "[HOME]"}, | |
1274 {K_S_HOME, "[C-HOME]"}, | |
1275 {K_C_HOME, "[C-HOME]"}, | |
1276 {K_KHOME, "[KHOME]"}, | |
1277 {K_XHOME, "[XHOME]"}, | |
230 | 1278 {K_ZHOME, "[ZHOME]"}, |
7 | 1279 {K_END, "[END]"}, |
1280 {K_S_END, "[C-END]"}, | |
1281 {K_C_END, "[C-END]"}, | |
1282 {K_KEND, "[KEND]"}, | |
1283 {K_XEND, "[XEND]"}, | |
230 | 1284 {K_ZEND, "[ZEND]"}, |
7 | 1285 {K_PAGEUP, "[PAGEUP]"}, |
1286 {K_PAGEDOWN, "[PAGEDOWN]"}, | |
1287 {K_KPAGEUP, "[KPAGEUP]"}, | |
1288 {K_KPAGEDOWN, "[KPAGEDOWN]"}, | |
1289 {K_MOUSE, "[MOUSE]"}, | |
1290 {K_KPLUS, "[KPLUS]"}, | |
1291 {K_KMINUS, "[KMINUS]"}, | |
1292 {K_KDIVIDE, "[KDIVIDE]"}, | |
1293 {K_KMULTIPLY, "[KMULTIPLY]"}, | |
1294 {K_KENTER, "[KENTER]"}, | |
1295 {K_KPOINT, "[KPOINT]"}, | |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
1296 {K_PS, "[PASTE-START]"}, |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
1297 {K_PE, "[PASTE-END]"}, |
7 | 1298 {K_K0, "[K0]"}, |
1299 {K_K1, "[K1]"}, | |
1300 {K_K2, "[K2]"}, | |
1301 {K_K3, "[K3]"}, | |
1302 {K_K4, "[K4]"}, | |
1303 {K_K5, "[K5]"}, | |
1304 {K_K6, "[K6]"}, | |
1305 {K_K7, "[K7]"}, | |
1306 {K_K8, "[K8]"}, | |
1307 {K_K9, "[K9]"}, | |
1308 # endif | |
1309 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1310 #endif // NO_BUILTIN_TCAPS |
7 | 1311 |
1312 /* | |
1313 * The most minimal terminal: only clear screen and cursor positioning | |
1314 * Always included. | |
1315 */ | |
1316 {(int)KS_NAME, "dumb"}, | |
1317 {(int)KS_CL, "\014"}, | |
1318 #ifdef TERMINFO | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
1319 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, |
7 | 1320 #else |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
1321 {(int)KS_CM, "\033[%i%d;%dH"}, |
7 | 1322 #endif |
1323 | |
1324 /* | |
1325 * end marker | |
1326 */ | |
1327 {(int)KS_NAME, NULL} | |
1328 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1329 }; // end of builtin_termcaps |
7 | 1330 |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1331 #if defined(FEAT_TERMGUICOLORS) || defined(PROTO) |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
1332 static guicolor_T |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1333 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
|
1334 { |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
1335 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
|
1336 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1337 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1338 guicolor_T |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1339 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
|
1340 { |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1341 guicolor_T t; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1342 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1343 if (*name == NUL) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1344 return INVALCOLOR; |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1345 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
|
1346 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1347 if (t == INVALCOLOR) |
26057
92c424550367
patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents:
25475
diff
changeset
|
1348 semsg(_(e_cannot_allocate_color_str), name); |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1349 return t; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1350 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1351 |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
1352 guicolor_T |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1353 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
|
1354 { |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
1355 return color; |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1356 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1357 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1358 |
7 | 1359 /* |
1360 * DEFAULT_TERM is used, when no terminal is specified with -T option or $TERM. | |
1361 */ | |
1362 #ifdef AMIGA | |
1363 # define DEFAULT_TERM (char_u *)"amiga" | |
1364 #endif | |
1365 | |
1366 #ifdef MSWIN | |
1367 # define DEFAULT_TERM (char_u *)"win32" | |
1368 #endif | |
1369 | |
21329
bb3f60b0aca0
patch 8.2.1215: Atari MiNT support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
21226
diff
changeset
|
1370 #if defined(UNIX) |
7 | 1371 # define DEFAULT_TERM (char_u *)"ansi" |
1372 #endif | |
1373 | |
1374 #ifdef VMS | |
1375 # define DEFAULT_TERM (char_u *)"vt320" | |
1376 #endif | |
1377 | |
19526
22f0dda71638
patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
19489
diff
changeset
|
1378 #ifdef __HAIKU__ |
22f0dda71638
patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
19489
diff
changeset
|
1379 # undef DEFAULT_TERM |
22f0dda71638
patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
19489
diff
changeset
|
1380 # define DEFAULT_TERM (char_u *)"xterm" |
22f0dda71638
patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
19489
diff
changeset
|
1381 #endif |
22f0dda71638
patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
19489
diff
changeset
|
1382 |
7 | 1383 #ifndef DEFAULT_TERM |
1384 # define DEFAULT_TERM (char_u *)"dumb" | |
1385 #endif | |
1386 | |
1387 /* | |
1388 * Term_strings contains currently used terminal output strings. | |
1389 * It is initialized with the default values by parse_builtin_tcap(). | |
1390 * The values can be changed by setting the option with the same name. | |
1391 */ | |
1392 char_u *(term_strings[(int)KS_LAST + 1]); | |
1393 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1394 static int need_gather = FALSE; // need to fill termleader[] |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1395 static char_u termleader[256 + 1]; // for check_termcode() |
7 | 1396 #ifdef FEAT_TERMRESPONSE |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1397 static int check_for_codes = FALSE; // check for key code response |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1398 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1399 /* |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1400 * Structure and table to store terminal features that can be detected by |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1401 * querying the terminal. Either by inspecting the termresponse or a more |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1402 * specific request. Besides this there are: |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1403 * t_colors - number of colors supported |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1404 */ |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1405 typedef struct { |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1406 char *tpr_name; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1407 int tpr_set_by_termresponse; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1408 int tpr_status; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1409 } termprop_T; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1410 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1411 // Values for tpr_status. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1412 #define TPR_UNKNOWN 'u' |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1413 #define TPR_YES 'y' |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1414 #define TPR_NO 'n' |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1415 #define TPR_MOUSE_XTERM 'x' // use "xterm" for 'ttymouse' |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1416 #define TPR_MOUSE_XTERM2 '2' // use "xterm2" for 'ttymouse' |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1417 #define TPR_MOUSE_SGR 's' // use "sgr" for 'ttymouse' |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1418 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1419 // can request the cursor style without messing up the display |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1420 #define TPR_CURSOR_STYLE 0 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1421 // can request the cursor blink mode without messing up the display |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1422 #define TPR_CURSOR_BLINK 1 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1423 // can set the underline color with t_8u without resetting other colors |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1424 #define TPR_UNDERLINE_RGB 2 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1425 // mouse support - TPR_MOUSE_XTERM, TPR_MOUSE_XTERM2 or TPR_MOUSE_SGR |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1426 #define TPR_MOUSE 3 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1427 // table size |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1428 #define TPR_COUNT 4 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1429 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1430 static termprop_T term_props[TPR_COUNT]; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1431 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1432 /* |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1433 * Initialize the term_props table. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1434 * When "all" is FALSE only set those that are detected from the version |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1435 * response. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1436 */ |
20836
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1437 void |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1438 init_term_props(int all) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1439 { |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1440 int i; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1441 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1442 term_props[TPR_CURSOR_STYLE].tpr_name = "cursor_style"; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1443 term_props[TPR_CURSOR_STYLE].tpr_set_by_termresponse = FALSE; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1444 term_props[TPR_CURSOR_BLINK].tpr_name = "cursor_blink_mode"; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1445 term_props[TPR_CURSOR_BLINK].tpr_set_by_termresponse = FALSE; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1446 term_props[TPR_UNDERLINE_RGB].tpr_name = "underline_rgb"; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1447 term_props[TPR_UNDERLINE_RGB].tpr_set_by_termresponse = TRUE; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1448 term_props[TPR_MOUSE].tpr_name = "mouse"; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1449 term_props[TPR_MOUSE].tpr_set_by_termresponse = TRUE; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1450 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1451 for (i = 0; i < TPR_COUNT; ++i) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1452 if (all || term_props[i].tpr_set_by_termresponse) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1453 term_props[i].tpr_status = TPR_UNKNOWN; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1454 } |
7 | 1455 #endif |
1456 | |
20836
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1457 #if defined(FEAT_EVAL) || defined(PROTO) |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1458 void |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1459 f_terminalprops(typval_T *argvars UNUSED, typval_T *rettv) |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1460 { |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1461 # ifdef FEAT_TERMRESPONSE |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1462 int i; |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1463 # endif |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1464 |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1465 if (rettv_dict_alloc(rettv) != OK) |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1466 return; |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1467 # ifdef FEAT_TERMRESPONSE |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1468 for (i = 0; i < TPR_COUNT; ++i) |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1469 { |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1470 char_u value[2]; |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1471 |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1472 value[0] = term_props[i].tpr_status; |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1473 value[1] = NUL; |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1474 dict_add_string(rettv->vval.v_dict, term_props[i].tpr_name, value); |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1475 } |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1476 # endif |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1477 } |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1478 #endif |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1479 |
7 | 1480 static struct builtin_term * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1481 find_builtin_term(char_u *term) |
7 | 1482 { |
1483 struct builtin_term *p; | |
1484 | |
1485 p = builtin_termcaps; | |
1486 while (p->bt_string != NULL) | |
1487 { | |
1488 if (p->bt_entry == (int)KS_NAME) | |
1489 { | |
1490 #ifdef UNIX | |
1491 if (STRCMP(p->bt_string, "iris-ansi") == 0 && vim_is_iris(term)) | |
1492 return p; | |
1493 else if (STRCMP(p->bt_string, "xterm") == 0 && vim_is_xterm(term)) | |
1494 return p; | |
1495 else | |
1496 #endif | |
1497 #ifdef VMS | |
1498 if (STRCMP(p->bt_string, "vt320") == 0 && vim_is_vt300(term)) | |
1499 return p; | |
1500 else | |
1501 #endif | |
1502 if (STRCMP(term, p->bt_string) == 0) | |
1503 return p; | |
1504 } | |
1505 ++p; | |
1506 } | |
1507 return p; | |
1508 } | |
1509 | |
1510 /* | |
1511 * Parsing of the builtin termcap entries. | |
1512 * Caller should check if 'name' is a valid builtin term. | |
1513 * The terminal's name is not set, as this is already done in termcapinit(). | |
1514 */ | |
1515 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1516 parse_builtin_tcap(char_u *term) |
7 | 1517 { |
1518 struct builtin_term *p; | |
1519 char_u name[2]; | |
1520 int term_8bit; | |
1521 | |
1522 p = find_builtin_term(term); | |
1523 term_8bit = term_is_8bit(term); | |
1524 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1525 // Do not parse if builtin term not found |
7 | 1526 if (p->bt_string == NULL) |
1527 return; | |
1528 | |
1529 for (++p; p->bt_entry != (int)KS_NAME && p->bt_entry != BT_EXTRA_KEYS; ++p) | |
1530 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1531 if ((int)p->bt_entry >= 0) // KS_xx entry |
7 | 1532 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1533 // Only set the value if it wasn't set yet. |
7 | 1534 if (term_strings[p->bt_entry] == NULL |
1535 || term_strings[p->bt_entry] == empty_option) | |
1536 { | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1537 #ifdef FEAT_EVAL |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1538 int opt_idx = -1; |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1539 #endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1540 // 8bit terminal: use CSI instead of <Esc>[ |
7 | 1541 if (term_8bit && term_7to8bit((char_u *)p->bt_string) != 0) |
1542 { | |
1543 char_u *s, *t; | |
1544 | |
1545 s = vim_strsave((char_u *)p->bt_string); | |
1546 if (s != NULL) | |
1547 { | |
1548 for (t = s; *t; ++t) | |
1549 if (term_7to8bit(t)) | |
1550 { | |
1551 *t = term_7to8bit(t); | |
14321
6bcac243b9de
patch 8.1.0176: overlapping string argument for strcpy()
Christian Brabandt <cb@256bit.org>
parents:
14282
diff
changeset
|
1552 STRMOVE(t + 1, t + 2); |
7 | 1553 } |
1554 term_strings[p->bt_entry] = s; | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1555 #ifdef FEAT_EVAL |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1556 opt_idx = |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1557 #endif |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1558 set_term_option_alloced( |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1559 &term_strings[p->bt_entry]); |
7 | 1560 } |
1561 } | |
1562 else | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1563 { |
7 | 1564 term_strings[p->bt_entry] = (char_u *)p->bt_string; |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1565 #ifdef FEAT_EVAL |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1566 opt_idx = get_term_opt_idx(&term_strings[p->bt_entry]); |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1567 #endif |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1568 } |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1569 #ifdef FEAT_EVAL |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1570 set_term_option_sctx_idx(NULL, opt_idx); |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1571 #endif |
7 | 1572 } |
1573 } | |
1574 else | |
1575 { | |
1576 name[0] = KEY2TERMCAP0((int)p->bt_entry); | |
1577 name[1] = KEY2TERMCAP1((int)p->bt_entry); | |
1578 if (find_termcode(name) == NULL) | |
1579 add_termcode(name, (char_u *)p->bt_string, term_8bit); | |
1580 } | |
1581 } | |
1582 } | |
11739
5c69c6d9e2eb
patch 8.0.0752: build fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11731
diff
changeset
|
1583 |
7 | 1584 /* |
1585 * Set number of colors. | |
1586 * Store it as a number in t_colors. | |
1587 * Store it as a string in T_CCO (using nr_colors[]). | |
1588 */ | |
19997
3d1de9093c01
patch 8.2.0554: the GUI doesn't set t_Co
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
1589 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1590 set_color_count(int nr) |
7 | 1591 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1592 char_u nr_colors[20]; // string for number of colors |
7 | 1593 |
1594 t_colors = nr; | |
1595 if (t_colors > 1) | |
1596 sprintf((char *)nr_colors, "%d", t_colors); | |
1597 else | |
1598 *nr_colors = NUL; | |
694 | 1599 set_string_option_direct((char_u *)"t_Co", -1, nr_colors, OPT_FREE, 0); |
7 | 1600 } |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1601 |
11739
5c69c6d9e2eb
patch 8.0.0752: build fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11731
diff
changeset
|
1602 #if defined(FEAT_TERMRESPONSE) |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1603 /* |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1604 * Set the color count to "val" and redraw if it changed. |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1605 */ |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1606 static void |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1607 may_adjust_color_count(int val) |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1608 { |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1609 if (val != t_colors) |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1610 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1611 // Nr of colors changed, initialize highlighting and |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1612 // redraw everything. This causes a redraw, which usually |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1613 // clears the message. Try keeping the message if it |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1614 // might work. |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1615 set_keep_msg_from_hist(); |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1616 set_color_count(val); |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1617 init_highlight(TRUE, FALSE); |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1618 # ifdef DEBUG_TERMRESPONSE |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1619 { |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
1620 int r = redraw_asap(CLEAR); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
1621 |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
1622 log_tr("Received t_Co, redraw_asap(): %d", r); |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1623 } |
20524
bed30e6b5a09
patch 8.2.0816: terminal test fails when compiled with Athena
Bram Moolenaar <Bram@vim.org>
parents:
20500
diff
changeset
|
1624 # else |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1625 redraw_asap(CLEAR); |
20524
bed30e6b5a09
patch 8.2.0816: terminal test fails when compiled with Athena
Bram Moolenaar <Bram@vim.org>
parents:
20500
diff
changeset
|
1626 # endif |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1627 } |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1628 } |
7 | 1629 #endif |
1630 | |
1631 #ifdef HAVE_TGETENT | |
1632 static char *(key_names[]) = | |
1633 { | |
20524
bed30e6b5a09
patch 8.2.0816: terminal test fails when compiled with Athena
Bram Moolenaar <Bram@vim.org>
parents:
20500
diff
changeset
|
1634 # ifdef FEAT_TERMRESPONSE |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1635 // Do this one first, it may cause a screen redraw. |
7 | 1636 "Co", |
20524
bed30e6b5a09
patch 8.2.0816: terminal test fails when compiled with Athena
Bram Moolenaar <Bram@vim.org>
parents:
20500
diff
changeset
|
1637 # endif |
7 | 1638 "ku", "kd", "kr", "kl", |
1639 "#2", "#4", "%i", "*7", | |
1640 "k1", "k2", "k3", "k4", "k5", "k6", | |
1641 "k7", "k8", "k9", "k;", "F1", "F2", | |
1642 "%1", "&8", "kb", "kI", "kD", "kh", | |
1643 "@7", "kP", "kN", "K1", "K3", "K4", "K5", "kB", | |
1644 NULL | |
1645 }; | |
1646 #endif | |
1647 | |
13874
fc2f175e8169
patch 8.0.1808: can't build without TGETENT
Christian Brabandt <cb@256bit.org>
parents:
13872
diff
changeset
|
1648 #ifdef HAVE_TGETENT |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1649 static void |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1650 get_term_entries(int *height, int *width) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1651 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1652 static struct { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1653 enum SpecialKey dest; // index in term_strings[] |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1654 char *name; // termcap name for string |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1655 } string_names[] = |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1656 { {KS_CE, "ce"}, {KS_AL, "al"}, {KS_CAL,"AL"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1657 {KS_DL, "dl"}, {KS_CDL,"DL"}, {KS_CS, "cs"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1658 {KS_CL, "cl"}, {KS_CD, "cd"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1659 {KS_VI, "vi"}, {KS_VE, "ve"}, {KS_MB, "mb"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1660 {KS_ME, "me"}, {KS_MR, "mr"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1661 {KS_MD, "md"}, {KS_SE, "se"}, {KS_SO, "so"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1662 {KS_CZH,"ZH"}, {KS_CZR,"ZR"}, {KS_UE, "ue"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1663 {KS_US, "us"}, {KS_UCE, "Ce"}, {KS_UCS, "Cs"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1664 {KS_STE,"Te"}, {KS_STS,"Ts"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1665 {KS_CM, "cm"}, {KS_SR, "sr"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1666 {KS_CRI,"RI"}, {KS_VB, "vb"}, {KS_KS, "ks"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1667 {KS_KE, "ke"}, {KS_TI, "ti"}, {KS_TE, "te"}, |
18299
a9cf41bcb5d6
patch 8.1.2144: side effects when using t_ti to enable modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18295
diff
changeset
|
1668 {KS_CTI, "TI"}, {KS_CTE, "TE"}, |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1669 {KS_BC, "bc"}, {KS_CSB,"Sb"}, {KS_CSF,"Sf"}, |
20619
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
1670 {KS_CAB,"AB"}, {KS_CAF,"AF"}, {KS_CAU,"AU"}, |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
1671 {KS_LE, "le"}, |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1672 {KS_ND, "nd"}, {KS_OP, "op"}, {KS_CRV, "RV"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1673 {KS_VS, "vs"}, {KS_CVS, "VS"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1674 {KS_CIS, "IS"}, {KS_CIE, "IE"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1675 {KS_CSC, "SC"}, {KS_CEC, "EC"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1676 {KS_TS, "ts"}, {KS_FS, "fs"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1677 {KS_CWP, "WP"}, {KS_CWS, "WS"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1678 {KS_CSI, "SI"}, {KS_CEI, "EI"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1679 {KS_U7, "u7"}, {KS_RFG, "RF"}, {KS_RBG, "RB"}, |
20619
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
1680 {KS_8F, "8f"}, {KS_8B, "8b"}, {KS_8U, "8u"}, |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1681 {KS_CBE, "BE"}, {KS_CBD, "BD"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1682 {KS_CPS, "PS"}, {KS_CPE, "PE"}, |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
1683 {KS_CST, "ST"}, {KS_CRT, "RT"}, |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
1684 {KS_SSI, "Si"}, {KS_SRI, "Ri"}, |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1685 {(enum SpecialKey)0, NULL} |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1686 }; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1687 int i; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1688 char_u *p; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1689 static char_u tstrbuf[TBUFSZ]; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1690 char_u *tp = tstrbuf; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1691 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1692 /* |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1693 * get output strings |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1694 */ |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1695 for (i = 0; string_names[i].name != NULL; ++i) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1696 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1697 if (TERM_STR(string_names[i].dest) == NULL |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1698 || TERM_STR(string_names[i].dest) == empty_option) |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1699 { |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1700 TERM_STR(string_names[i].dest) = TGETSTR(string_names[i].name, &tp); |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1701 #ifdef FEAT_EVAL |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1702 set_term_option_sctx_idx(string_names[i].name, -1); |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1703 #endif |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1704 } |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1705 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1706 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1707 // tgetflag() returns 1 if the flag is present, 0 if not and |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1708 // possibly -1 if the flag doesn't exist. |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1709 if ((T_MS == NULL || T_MS == empty_option) && tgetflag("ms") > 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1710 T_MS = (char_u *)"y"; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1711 if ((T_XS == NULL || T_XS == empty_option) && tgetflag("xs") > 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1712 T_XS = (char_u *)"y"; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1713 if ((T_XN == NULL || T_XN == empty_option) && tgetflag("xn") > 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1714 T_XN = (char_u *)"y"; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1715 if ((T_DB == NULL || T_DB == empty_option) && tgetflag("db") > 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1716 T_DB = (char_u *)"y"; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1717 if ((T_DA == NULL || T_DA == empty_option) && tgetflag("da") > 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1718 T_DA = (char_u *)"y"; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1719 if ((T_UT == NULL || T_UT == empty_option) && tgetflag("ut") > 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1720 T_UT = (char_u *)"y"; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1721 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1722 /* |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1723 * get key codes |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1724 */ |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1725 for (i = 0; key_names[i] != NULL; ++i) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1726 if (find_termcode((char_u *)key_names[i]) == NULL) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1727 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1728 p = TGETSTR(key_names[i], &tp); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1729 // if cursor-left == backspace, ignore it (televideo 925) |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1730 if (p != NULL |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1731 && (*p != Ctrl_H |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1732 || key_names[i][0] != 'k' |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1733 || key_names[i][1] != 'l')) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1734 add_termcode((char_u *)key_names[i], p, FALSE); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1735 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1736 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1737 if (*height == 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1738 *height = tgetnum("li"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1739 if (*width == 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1740 *width = tgetnum("co"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1741 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1742 /* |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1743 * Get number of colors (if not done already). |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1744 */ |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1745 if (TERM_STR(KS_CCO) == NULL || TERM_STR(KS_CCO) == empty_option) |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1746 { |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1747 set_color_count(tgetnum("Co")); |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1748 #ifdef FEAT_EVAL |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1749 set_term_option_sctx_idx("Co", -1); |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1750 #endif |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1751 } |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1752 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1753 # ifndef hpux |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1754 BC = (char *)TGETSTR("bc", &tp); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1755 UP = (char *)TGETSTR("up", &tp); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1756 p = TGETSTR("pc", &tp); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1757 if (p) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1758 PC = *p; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1759 # endif |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1760 } |
13874
fc2f175e8169
patch 8.0.1808: can't build without TGETENT
Christian Brabandt <cb@256bit.org>
parents:
13872
diff
changeset
|
1761 #endif |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1762 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1763 static void |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
1764 report_term_error(char *error_msg, char_u *term) |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1765 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1766 struct builtin_term *termp; |
21624
1d75baa22d9a
patch 8.2.1362: last entry of ":set term=xxx" overwritten by error message
Bram Moolenaar <Bram@vim.org>
parents:
21329
diff
changeset
|
1767 int i; |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1768 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1769 mch_errmsg("\r\n"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1770 if (error_msg != NULL) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1771 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
1772 mch_errmsg(error_msg); |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1773 mch_errmsg("\r\n"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1774 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1775 mch_errmsg("'"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1776 mch_errmsg((char *)term); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1777 mch_errmsg(_("' not known. Available builtin terminals are:")); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1778 mch_errmsg("\r\n"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1779 for (termp = &(builtin_termcaps[0]); termp->bt_string != NULL; ++termp) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1780 { |
25429
2aefea114696
patch 8.2.3251: listing builtin_gui as an available terminal is confusing
Bram Moolenaar <Bram@vim.org>
parents:
24850
diff
changeset
|
1781 if (termp->bt_entry == (int)KS_NAME |
2aefea114696
patch 8.2.3251: listing builtin_gui as an available terminal is confusing
Bram Moolenaar <Bram@vim.org>
parents:
24850
diff
changeset
|
1782 && STRCMP(termp->bt_string, "gui") != 0) |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1783 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1784 #ifdef HAVE_TGETENT |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1785 mch_errmsg(" builtin_"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1786 #else |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1787 mch_errmsg(" "); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1788 #endif |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1789 mch_errmsg(termp->bt_string); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1790 mch_errmsg("\r\n"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1791 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1792 } |
21624
1d75baa22d9a
patch 8.2.1362: last entry of ":set term=xxx" overwritten by error message
Bram Moolenaar <Bram@vim.org>
parents:
21329
diff
changeset
|
1793 // Output extra 'cmdheight' line breaks to avoid that the following error |
1d75baa22d9a
patch 8.2.1362: last entry of ":set term=xxx" overwritten by error message
Bram Moolenaar <Bram@vim.org>
parents:
21329
diff
changeset
|
1794 // message overwrites the last terminal name. |
1d75baa22d9a
patch 8.2.1362: last entry of ":set term=xxx" overwritten by error message
Bram Moolenaar <Bram@vim.org>
parents:
21329
diff
changeset
|
1795 for (i = 1; i < p_ch; ++i) |
1d75baa22d9a
patch 8.2.1362: last entry of ":set term=xxx" overwritten by error message
Bram Moolenaar <Bram@vim.org>
parents:
21329
diff
changeset
|
1796 mch_errmsg("\r\n"); |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1797 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1798 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1799 static void |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1800 report_default_term(char_u *term) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1801 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1802 mch_errmsg(_("defaulting to '")); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1803 mch_errmsg((char *)term); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1804 mch_errmsg("'\r\n"); |
22742
f7f2d73ff85e
patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Bram Moolenaar <Bram@vim.org>
parents:
22522
diff
changeset
|
1805 if (emsg_silent == 0 && !in_assert_fails) |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1806 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1807 screen_start(); // don't know where cursor is now |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1808 out_flush(); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1809 if (!is_not_a_term()) |
18642
bbea1f108187
patch 8.1.2313: debugging where a delay comes from is not easy
Bram Moolenaar <Bram@vim.org>
parents:
18430
diff
changeset
|
1810 ui_delay(2007L, TRUE); |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1811 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1812 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1813 |
7 | 1814 /* |
1815 * Set terminal options for terminal "term". | |
1816 * Return OK if terminal 'term' was found in a termcap, FAIL otherwise. | |
1817 * | |
1818 * While doing this, until ttest(), some options may be NULL, be careful. | |
1819 */ | |
1820 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1821 set_termname(char_u *term) |
7 | 1822 { |
1823 struct builtin_term *termp; | |
1824 #ifdef HAVE_TGETENT | |
1825 int builtin_first = p_tbi; | |
1826 int try; | |
1827 int termcap_cleared = FALSE; | |
1828 #endif | |
1829 int width = 0, height = 0; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
1830 char *error_msg = NULL; |
7 | 1831 char_u *bs_p, *del_p; |
1832 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1833 // In silect mode (ex -s) we don't use the 'term' option. |
168 | 1834 if (silent_mode) |
1835 return OK; | |
1836 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1837 detected_8bit = FALSE; // reset 8-bit detection |
7 | 1838 |
1839 if (term_is_builtin(term)) | |
1840 { | |
1841 term += 8; | |
1842 #ifdef HAVE_TGETENT | |
1843 builtin_first = 1; | |
1844 #endif | |
1845 } | |
1846 | |
1847 /* | |
1848 * If HAVE_TGETENT is not defined, only the builtin termcap is used, otherwise: | |
1849 * If builtin_first is TRUE: | |
1850 * 0. try builtin termcap | |
1851 * 1. try external termcap | |
1852 * 2. if both fail default to a builtin terminal | |
1853 * If builtin_first is FALSE: | |
1854 * 1. try external termcap | |
1855 * 2. try builtin termcap, if both fail default to a builtin terminal | |
1856 */ | |
1857 #ifdef HAVE_TGETENT | |
1858 for (try = builtin_first ? 0 : 1; try < 3; ++try) | |
1859 { | |
1860 /* | |
1861 * Use external termcap | |
1862 */ | |
1863 if (try == 1) | |
1864 { | |
1865 char_u tbuf[TBUFSZ]; | |
1866 | |
1867 /* | |
1868 * If the external termcap does not have a matching entry, try the | |
1869 * builtin ones. | |
1870 */ | |
1871 if ((error_msg = tgetent_error(tbuf, term)) == NULL) | |
1872 { | |
1873 if (!termcap_cleared) | |
1874 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1875 clear_termoptions(); // clear old options |
7 | 1876 termcap_cleared = TRUE; |
1877 } | |
1878 | |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1879 get_term_entries(&height, &width); |
7 | 1880 } |
1881 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1882 else // try == 0 || try == 2 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1883 #endif // HAVE_TGETENT |
7 | 1884 /* |
1885 * Use builtin termcap | |
1886 */ | |
1887 { | |
1888 #ifdef HAVE_TGETENT | |
1889 /* | |
1890 * If builtin termcap was already used, there is no need to search | |
1891 * for the builtin termcap again, quit now. | |
1892 */ | |
1893 if (try == 2 && builtin_first && termcap_cleared) | |
1894 break; | |
1895 #endif | |
1896 /* | |
1897 * search for 'term' in builtin_termcaps[] | |
1898 */ | |
1899 termp = find_builtin_term(term); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1900 if (termp->bt_string == NULL) // did not find it |
7 | 1901 { |
1902 #ifdef HAVE_TGETENT | |
1903 /* | |
1904 * If try == 0, first try the external termcap. If that is not | |
1905 * found we'll get back here with try == 2. | |
1906 * If termcap_cleared is set we used the external termcap, | |
1907 * don't complain about not finding the term in the builtin | |
1908 * termcap. | |
1909 */ | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1910 if (try == 0) // try external one |
7 | 1911 continue; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1912 if (termcap_cleared) // found in external termcap |
7 | 1913 break; |
1914 #endif | |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1915 report_term_error(error_msg, term); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1916 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1917 // when user typed :set term=xxx, quit here |
7 | 1918 if (starting != NO_SCREEN) |
1919 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1920 screen_start(); // don't know where cursor is now |
7 | 1921 wait_return(TRUE); |
1922 return FAIL; | |
1923 } | |
1924 term = DEFAULT_TERM; | |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1925 report_default_term(term); |
694 | 1926 set_string_option_direct((char_u *)"term", -1, term, |
1927 OPT_FREE, 0); | |
7 | 1928 display_errors(); |
1929 } | |
1930 out_flush(); | |
1931 #ifdef HAVE_TGETENT | |
1932 if (!termcap_cleared) | |
1933 { | |
1934 #endif | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1935 clear_termoptions(); // clear old options |
7 | 1936 #ifdef HAVE_TGETENT |
1937 termcap_cleared = TRUE; | |
1938 } | |
1939 #endif | |
1940 parse_builtin_tcap(term); | |
1941 #ifdef FEAT_GUI | |
1942 if (term_is_gui(term)) | |
1943 { | |
1944 out_flush(); | |
1945 gui_init(); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1946 // If starting the GUI failed, don't do any of the other |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1947 // things for this terminal |
7 | 1948 if (!gui.in_use) |
1949 return FAIL; | |
1950 #ifdef HAVE_TGETENT | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1951 break; // don't try using external termcap |
7 | 1952 #endif |
1953 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1954 #endif // FEAT_GUI |
7 | 1955 } |
1956 #ifdef HAVE_TGETENT | |
1957 } | |
1958 #endif | |
1959 | |
1960 /* | |
1961 * special: There is no info in the termcap about whether the cursor | |
1962 * positioning is relative to the start of the screen or to the start of the | |
1963 * scrolling region. We just guess here. Only msdos pcterm is known to do it | |
1964 * relative. | |
1965 */ | |
1966 if (STRCMP(term, "pcterm") == 0) | |
1967 T_CCS = (char_u *)"yes"; | |
1968 else | |
1969 T_CCS = empty_option; | |
1970 | |
1971 #ifdef UNIX | |
1972 /* | |
1973 * Any "stty" settings override the default for t_kb from the termcap. | |
1974 * This is in os_unix.c, because it depends a lot on the version of unix that | |
1975 * is being used. | |
1976 * Don't do this when the GUI is active, it uses "t_kb" and "t_kD" directly. | |
1977 */ | |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
1978 # ifdef FEAT_GUI |
7 | 1979 if (!gui.in_use) |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
1980 # endif |
7 | 1981 get_stty(); |
1982 #endif | |
1983 | |
1984 /* | |
1985 * If the termcap has no entry for 'bs' and/or 'del' and the ioctl() also | |
1986 * didn't work, use the default CTRL-H | |
1987 * The default for t_kD is DEL, unless t_kb is DEL. | |
1988 * The vim_strsave'd strings are probably lost forever, well it's only two | |
1989 * bytes. Don't do this when the GUI is active, it uses "t_kb" and "t_kD" | |
1990 * directly. | |
1991 */ | |
1992 #ifdef FEAT_GUI | |
1993 if (!gui.in_use) | |
1994 #endif | |
1995 { | |
1996 bs_p = find_termcode((char_u *)"kb"); | |
1997 del_p = find_termcode((char_u *)"kD"); | |
1998 if (bs_p == NULL || *bs_p == NUL) | |
1999 add_termcode((char_u *)"kb", (bs_p = (char_u *)CTRL_H_STR), FALSE); | |
2000 if ((del_p == NULL || *del_p == NUL) && | |
2001 (bs_p == NULL || *bs_p != DEL)) | |
2002 add_termcode((char_u *)"kD", (char_u *)DEL_STR, FALSE); | |
2003 } | |
2004 | |
2005 #if defined(UNIX) || defined(VMS) | |
2006 term_is_xterm = vim_is_xterm(term); | |
2007 #endif | |
18352
94e1a49b879e
patch 8.1.2170: cannot build without the +termresponse feature
Bram Moolenaar <Bram@vim.org>
parents:
18350
diff
changeset
|
2008 #ifdef FEAT_TERMRESPONSE |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
2009 // Reset terminal properties that are set based on the termresponse, which |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
2010 // will be sent out soon. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
2011 init_term_props(FALSE); |
18352
94e1a49b879e
patch 8.1.2170: cannot build without the +termresponse feature
Bram Moolenaar <Bram@vim.org>
parents:
18350
diff
changeset
|
2012 #endif |
7 | 2013 |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
2014 #if defined(UNIX) || defined(VMS) |
7 | 2015 /* |
2016 * For Unix, set the 'ttymouse' option to the type of mouse to be used. | |
2017 * The termcode for the mouse is added as a side effect in option.c. | |
2018 */ | |
2019 { | |
11563
2547bbe6716e
patch 8.0.0664: mouse does not work in tmux
Christian Brabandt <cb@256bit.org>
parents:
11557
diff
changeset
|
2020 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
|
2021 |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
2022 # ifdef FEAT_MOUSE_XTERM |
1623 | 2023 if (use_xterm_like_mouse(term)) |
7 | 2024 { |
2025 if (use_xterm_mouse()) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2026 p = NULL; // keep existing value, might be "xterm2" |
7 | 2027 else |
2028 p = (char_u *)"xterm"; | |
2029 } | |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
2030 # endif |
7 | 2031 if (p != NULL) |
3980 | 2032 { |
7 | 2033 set_option_value((char_u *)"ttym", 0L, p, 0); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2034 // Reset the WAS_SET flag, 'ttymouse' can be set to "sgr" or |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2035 // "xterm2" in check_termcode(). |
3980 | 2036 reset_option_was_set((char_u *)"ttym"); |
2037 } | |
7 | 2038 if (p == NULL |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
2039 # ifdef FEAT_GUI |
7 | 2040 || gui.in_use |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
2041 # endif |
7 | 2042 ) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2043 check_mouse_termcode(); // set mouse termcode anyway |
7 | 2044 } |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
2045 #else |
7 | 2046 set_mouse_termcode(KS_MOUSE, (char_u *)"\233M"); |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
2047 #endif |
7 | 2048 |
23632
8da1d91d751c
patch 8.2.2358: wrong #ifdef for use_xterm_like_mouse()
Bram Moolenaar <Bram@vim.org>
parents:
23620
diff
changeset
|
2049 #ifdef FEAT_MOUSE_XTERM |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2050 // focus reporting is supported by xterm compatible terminals and tmux. |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2051 if (use_xterm_like_mouse(term)) |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2052 { |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2053 char_u name[3]; |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2054 |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2055 // handle focus in event |
23632
8da1d91d751c
patch 8.2.2358: wrong #ifdef for use_xterm_like_mouse()
Bram Moolenaar <Bram@vim.org>
parents:
23620
diff
changeset
|
2056 name[0] = KS_EXTRA; |
8da1d91d751c
patch 8.2.2358: wrong #ifdef for use_xterm_like_mouse()
Bram Moolenaar <Bram@vim.org>
parents:
23620
diff
changeset
|
2057 name[1] = KE_FOCUSGAINED; |
8da1d91d751c
patch 8.2.2358: wrong #ifdef for use_xterm_like_mouse()
Bram Moolenaar <Bram@vim.org>
parents:
23620
diff
changeset
|
2058 name[2] = NUL; |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2059 add_termcode(name, (char_u *)"\033[I", FALSE); |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2060 |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2061 // handle focus out event |
23632
8da1d91d751c
patch 8.2.2358: wrong #ifdef for use_xterm_like_mouse()
Bram Moolenaar <Bram@vim.org>
parents:
23620
diff
changeset
|
2062 name[1] = KE_FOCUSLOST; |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2063 add_termcode(name, (char_u *)"\033[O", FALSE); |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2064 |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2065 focus_mode = TRUE; |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2066 focus_state = TRUE; |
24045
1b56d4c75d19
patch 8.2.2564: focus events end Insert mode if 'esckeys' is not set
Bram Moolenaar <Bram@vim.org>
parents:
23774
diff
changeset
|
2067 need_gather = TRUE; |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2068 } |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2069 #endif |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2070 |
7 | 2071 #ifdef USE_TERM_CONSOLE |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2072 // DEFAULT_TERM indicates that it is the machine console. |
7 | 2073 if (STRCMP(term, DEFAULT_TERM) != 0) |
2074 term_console = FALSE; | |
2075 else | |
2076 { | |
2077 term_console = TRUE; | |
2078 # ifdef AMIGA | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2079 win_resize_on(); // enable window resizing reports |
7 | 2080 # endif |
2081 } | |
2082 #endif | |
2083 | |
2084 #if defined(UNIX) || defined(VMS) | |
2085 /* | |
2086 * 'ttyfast' is default on for xterm, iris-ansi and a few others. | |
2087 */ | |
2088 if (vim_is_fastterm(term)) | |
2089 p_tf = TRUE; | |
2090 #endif | |
2091 #ifdef USE_TERM_CONSOLE | |
2092 /* | |
2093 * 'ttyfast' is default on consoles | |
2094 */ | |
2095 if (term_console) | |
2096 p_tf = TRUE; | |
2097 #endif | |
2098 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2099 ttest(TRUE); // make sure we have a valid set of terminal codes |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2100 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2101 full_screen = TRUE; // we can use termcap codes from now on |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2102 set_term_defaults(); // use current values as defaults |
7 | 2103 #ifdef FEAT_TERMRESPONSE |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
2104 LOG_TR(("setting crv_status to STATUS_GET")); |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2105 crv_status.tr_progress = STATUS_GET; // Get terminal version later |
7 | 2106 #endif |
2107 | |
2108 /* | |
2109 * Initialize the terminal with the appropriate termcap codes. | |
2110 * Set the mouse and window title if possible. | |
2111 * Don't do this when starting, need to parse the .vimrc first, because it | |
2112 * may redefine t_TI etc. | |
2113 */ | |
2114 if (starting != NO_SCREEN) | |
2115 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2116 starttermcap(); // may change terminal mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2117 setmouse(); // may start using the mouse |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2118 maketitle(); // may display window title |
7 | 2119 } |
2120 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2121 // display initial screen after ttest() checking. jw. |
7 | 2122 if (width <= 0 || height <= 0) |
2123 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2124 // termcap failed to report size |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2125 // set defaults, in case ui_get_shellsize() also fails |
7 | 2126 width = 80; |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15852
diff
changeset
|
2127 #if defined(MSWIN) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2128 height = 25; // console is often 25 lines |
7 | 2129 #else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2130 height = 24; // most terminals are 24 lines |
7 | 2131 #endif |
2132 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2133 set_shellsize(width, height, FALSE); // may change Rows |
7 | 2134 if (starting != NO_SCREEN) |
2135 { | |
2136 if (scroll_region) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2137 scroll_region_reset(); // In case Rows changed |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2138 check_map_keycodes(); // check mappings for terminal codes used |
7 | 2139 |
2140 { | |
19489
31ac050a29a7
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
2141 buf_T *buf; |
31ac050a29a7
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
2142 aco_save_T aco; |
7 | 2143 |
2144 /* | |
2145 * Execute the TermChanged autocommands for each buffer that is | |
2146 * loaded. | |
2147 */ | |
19489
31ac050a29a7
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
2148 FOR_ALL_BUFFERS(buf) |
7 | 2149 { |
2150 if (curbuf->b_ml.ml_mfp != NULL) | |
19489
31ac050a29a7
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
2151 { |
31ac050a29a7
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
2152 aucmd_prepbuf(&aco, buf); |
7 | 2153 apply_autocmds(EVENT_TERMCHANGED, NULL, NULL, FALSE, |
2154 curbuf); | |
19489
31ac050a29a7
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
2155 // restore curwin/curbuf and a few other things |
31ac050a29a7
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
2156 aucmd_restbuf(&aco); |
31ac050a29a7
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
2157 } |
7 | 2158 } |
2159 } | |
2160 } | |
2161 | |
2162 #ifdef FEAT_TERMRESPONSE | |
2163 may_req_termresponse(); | |
2164 #endif | |
2165 | |
2166 return OK; | |
2167 } | |
2168 | |
26177
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2169 #if defined(EXITFREE) || defined(PROTO) |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2170 |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2171 # ifdef HAVE_DEL_CURTERM |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2172 # undef TERMINAL // name clash in term.h |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2173 # include <term.h> // declares cur_term |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2174 # endif |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2175 |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2176 /* |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2177 * If supported, delete "cur_term", which caches terminal related entries. |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2178 * Avoids that valgrind reports possibly lost memory. |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2179 */ |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2180 void |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2181 free_cur_term() |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2182 { |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2183 # ifdef HAVE_DEL_CURTERM |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2184 if (cur_term) |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2185 del_curterm(cur_term); |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2186 # endif |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2187 } |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2188 |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2189 #endif |
13e09dc59f0f
patch 8.2.3620: memory leak reported in libtlib
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2190 |
7 | 2191 #ifdef HAVE_TGETENT |
2192 /* | |
2193 * Call tgetent() | |
2194 * Return error message if it fails, NULL if it's OK. | |
2195 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
2196 static char * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2197 tgetent_error(char_u *tbuf, char_u *term) |
7 | 2198 { |
2199 int i; | |
2200 | |
18838
8dabdfc7c799
patch 8.1.2406: leaking memory in test_paste and test_registers
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
2201 // Note: Valgrind may report a leak here, because the library keeps one |
8dabdfc7c799
patch 8.1.2406: leaking memory in test_paste and test_registers
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
2202 // buffer around that we can't ever free. |
7 | 2203 i = TGETENT(tbuf, term); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2204 if (i < 0 // -1 is always an error |
7 | 2205 # ifdef TGETENT_ZERO_ERR |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2206 || i == 0 // sometimes zero is also an error |
7 | 2207 # endif |
2208 ) | |
2209 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2210 // On FreeBSD tputs() gets a SEGV after a tgetent() which fails. Call |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2211 // tgetent() with the always existing "dumb" entry to avoid a crash or |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2212 // hang. |
7 | 2213 (void)TGETENT(tbuf, "dumb"); |
2214 | |
2215 if (i < 0) | |
2216 # ifdef TGETENT_ZERO_ERR | |
26917
d91aea2a612c
patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
2217 return _(e_cannot_open_termcap_file); |
7 | 2218 if (i == 0) |
2219 # endif | |
2220 #ifdef TERMINFO | |
26917
d91aea2a612c
patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
2221 return _(e_terminal_entry_not_found_in_terminfo); |
7 | 2222 #else |
26917
d91aea2a612c
patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
2223 return _(e_terminal_entry_not_found_in_termcap); |
7 | 2224 #endif |
2225 } | |
2226 return NULL; | |
2227 } | |
2228 | |
2229 /* | |
2230 * Some versions of tgetstr() have been reported to return -1 instead of NULL. | |
2231 * Fix that here. | |
2232 */ | |
2233 static char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2234 vim_tgetstr(char *s, char_u **pp) |
7 | 2235 { |
2236 char *p; | |
2237 | |
2238 p = tgetstr(s, (char **)pp); | |
2239 if (p == (char *)-1) | |
2240 p = NULL; | |
2241 return (char_u *)p; | |
2242 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2243 #endif // HAVE_TGETENT |
7 | 2244 |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
2245 #if defined(HAVE_TGETENT) && (defined(UNIX) || defined(VMS) || defined(MACOS_X)) |
7 | 2246 /* |
2247 * Get Columns and Rows from the termcap. Used after a window signal if the | |
2248 * ioctl() fails. It doesn't make sense to call tgetent each time if the "co" | |
2249 * and "li" entries never change. But on some systems this works. | |
2250 * Errors while getting the entries are ignored. | |
2251 */ | |
2252 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2253 getlinecol( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2254 long *cp, // pointer to columns |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2255 long *rp) // pointer to rows |
7 | 2256 { |
2257 char_u tbuf[TBUFSZ]; | |
2258 | |
2259 if (T_NAME != NULL && *T_NAME != NUL && tgetent_error(tbuf, T_NAME) == NULL) | |
2260 { | |
2261 if (*cp == 0) | |
2262 *cp = tgetnum("co"); | |
2263 if (*rp == 0) | |
2264 *rp = tgetnum("li"); | |
2265 } | |
2266 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2267 #endif // defined(HAVE_TGETENT) && defined(UNIX) |
7 | 2268 |
2269 /* | |
2270 * Get a string entry from the termcap and add it to the list of termcodes. | |
2271 * Used for <t_xx> special keys. | |
2272 * Give an error message for failure when not sourcing. | |
2273 * If force given, replace an existing entry. | |
2274 * Return FAIL if the entry was not found, OK if the entry was added. | |
2275 */ | |
2276 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2277 add_termcap_entry(char_u *name, int force) |
7 | 2278 { |
2279 char_u *term; | |
2280 int key; | |
2281 struct builtin_term *termp; | |
2282 #ifdef HAVE_TGETENT | |
2283 char_u *string; | |
2284 int i; | |
2285 int builtin_first; | |
2286 char_u tbuf[TBUFSZ]; | |
2287 char_u tstrbuf[TBUFSZ]; | |
2288 char_u *tp = tstrbuf; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
2289 char *error_msg = NULL; |
7 | 2290 #endif |
2291 | |
2292 /* | |
2293 * If the GUI is running or will start in a moment, we only support the keys | |
2294 * that the GUI can produce. | |
2295 */ | |
2296 #ifdef FEAT_GUI | |
2297 if (gui.in_use || gui.starting) | |
2298 return gui_mch_haskey(name); | |
2299 #endif | |
2300 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2301 if (!force && find_termcode(name) != NULL) // it's already there |
7 | 2302 return OK; |
2303 | |
2304 term = T_NAME; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2305 if (term == NULL || *term == NUL) // 'term' not defined yet |
7 | 2306 return FAIL; |
2307 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2308 if (term_is_builtin(term)) // name starts with "builtin_" |
7 | 2309 { |
2310 term += 8; | |
2311 #ifdef HAVE_TGETENT | |
2312 builtin_first = TRUE; | |
2313 #endif | |
2314 } | |
2315 #ifdef HAVE_TGETENT | |
2316 else | |
2317 builtin_first = p_tbi; | |
2318 #endif | |
2319 | |
2320 #ifdef HAVE_TGETENT | |
2321 /* | |
2322 * We can get the entry from the builtin termcap and from the external one. | |
2323 * If 'ttybuiltin' is on or the terminal name starts with "builtin_", try | |
2324 * builtin termcap first. | |
2325 * If 'ttybuiltin' is off, try external termcap first. | |
2326 */ | |
2327 for (i = 0; i < 2; ++i) | |
2328 { | |
7210
08b50e436093
commit https://github.com/vim/vim/commit/98b30a473a58ae98c280e0383c8b1e08c0ebced5
Christian Brabandt <cb@256bit.org>
parents:
6901
diff
changeset
|
2329 if ((!builtin_first) == i) |
7 | 2330 #endif |
2331 /* | |
2332 * Search in builtin termcap | |
2333 */ | |
2334 { | |
2335 termp = find_builtin_term(term); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2336 if (termp->bt_string != NULL) // found it |
7 | 2337 { |
2338 key = TERMCAP2KEY(name[0], name[1]); | |
13406
4e30f3f4cb78
patch 8.0.1577: virtual replace test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13398
diff
changeset
|
2339 ++termp; |
7 | 2340 while (termp->bt_entry != (int)KS_NAME) |
2341 { | |
2342 if ((int)termp->bt_entry == key) | |
2343 { | |
2344 add_termcode(name, (char_u *)termp->bt_string, | |
2345 term_is_8bit(term)); | |
2346 return OK; | |
2347 } | |
2348 ++termp; | |
2349 } | |
2350 } | |
2351 } | |
2352 #ifdef HAVE_TGETENT | |
2353 else | |
2354 /* | |
2355 * Search in external termcap | |
2356 */ | |
2357 { | |
2358 error_msg = tgetent_error(tbuf, term); | |
2359 if (error_msg == NULL) | |
2360 { | |
2361 string = TGETSTR((char *)name, &tp); | |
2362 if (string != NULL && *string != NUL) | |
2363 { | |
2364 add_termcode(name, string, FALSE); | |
2365 return OK; | |
2366 } | |
2367 } | |
2368 } | |
2369 } | |
2370 #endif | |
2371 | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18838
diff
changeset
|
2372 if (SOURCING_NAME == NULL) |
7 | 2373 { |
2374 #ifdef HAVE_TGETENT | |
2375 if (error_msg != NULL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
2376 emsg(error_msg); |
7 | 2377 else |
2378 #endif | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
2379 semsg(_(e_no_str_entry_in_termcap), name); |
7 | 2380 } |
2381 return FAIL; | |
2382 } | |
2383 | |
2384 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2385 term_is_builtin(char_u *name) |
7 | 2386 { |
2387 return (STRNCMP(name, "builtin_", (size_t)8) == 0); | |
2388 } | |
2389 | |
2390 /* | |
2391 * Return TRUE if terminal "name" uses CSI instead of <Esc>[. | |
2392 * Assume that the terminal is using 8-bit controls when the name contains | |
2393 * "8bit", like in "xterm-8bit". | |
2394 */ | |
2395 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2396 term_is_8bit(char_u *name) |
7 | 2397 { |
2398 return (detected_8bit || strstr((char *)name, "8bit") != NULL); | |
2399 } | |
2400 | |
2401 /* | |
2402 * Translate terminal control chars from 7-bit to 8-bit: | |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
2403 * <Esc>[ -> CSI <M_C_[> |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
2404 * <Esc>] -> OSC <M-C-]> |
7 | 2405 * <Esc>O -> <M-C-O> |
2406 */ | |
2407 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2408 term_7to8bit(char_u *p) |
7 | 2409 { |
2410 if (*p == ESC) | |
2411 { | |
2412 if (p[1] == '[') | |
2413 return CSI; | |
2414 if (p[1] == ']') | |
6901 | 2415 return OSC; |
7 | 2416 if (p[1] == 'O') |
2417 return 0x8f; | |
2418 } | |
2419 return 0; | |
2420 } | |
2421 | |
13762
9de2b25932eb
patch 8.0.1753: various warnings from a static analyser
Christian Brabandt <cb@256bit.org>
parents:
13573
diff
changeset
|
2422 #if defined(FEAT_GUI) || defined(PROTO) |
7 | 2423 int |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2424 term_is_gui(char_u *name) |
7 | 2425 { |
2426 return (STRCMP(name, "builtin_gui") == 0 || STRCMP(name, "gui") == 0); | |
2427 } | |
2428 #endif | |
2429 | |
2430 #if !defined(HAVE_TGETENT) || defined(AMIGA) || defined(PROTO) | |
2431 | |
2432 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2433 tltoa(unsigned long i) |
7 | 2434 { |
2435 static char_u buf[16]; | |
2436 char_u *p; | |
2437 | |
2438 p = buf + 15; | |
2439 *p = '\0'; | |
2440 do | |
2441 { | |
2442 --p; | |
2443 *p = (char_u) (i % 10 + '0'); | |
2444 i /= 10; | |
2445 } | |
2446 while (i > 0 && p > buf); | |
2447 return p; | |
2448 } | |
2449 #endif | |
2450 | |
2451 #ifndef HAVE_TGETENT | |
2452 | |
2453 /* | |
2454 * minimal tgoto() implementation. | |
2455 * no padding and we only parse for %i %d and %+char | |
2456 */ | |
298 | 2457 static char * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2458 tgoto(char *cm, int x, int y) |
7 | 2459 { |
2460 static char buf[30]; | |
2461 char *p, *s, *e; | |
2462 | |
2463 if (!cm) | |
2464 return "OOPS"; | |
2465 e = buf + 29; | |
2466 for (s = buf; s < e && *cm; cm++) | |
2467 { | |
2468 if (*cm != '%') | |
2469 { | |
2470 *s++ = *cm; | |
2471 continue; | |
2472 } | |
2473 switch (*++cm) | |
2474 { | |
2475 case 'd': | |
2476 p = (char *)tltoa((unsigned long)y); | |
2477 y = x; | |
2478 while (*p) | |
2479 *s++ = *p++; | |
2480 break; | |
2481 case 'i': | |
2482 x++; | |
2483 y++; | |
2484 break; | |
2485 case '+': | |
2486 *s++ = (char)(*++cm + y); | |
2487 y = x; | |
2488 break; | |
2489 case '%': | |
2490 *s++ = *cm; | |
2491 break; | |
2492 default: | |
2493 return "OOPS"; | |
2494 } | |
2495 } | |
2496 *s = '\0'; | |
2497 return buf; | |
2498 } | |
2499 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2500 #endif // HAVE_TGETENT |
7 | 2501 |
2502 /* | |
2503 * Set the terminal name and initialize the terminal options. | |
2504 * If "name" is NULL or empty, get the terminal name from the environment. | |
2505 * If that fails, use the default terminal name. | |
2506 */ | |
2507 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2508 termcapinit(char_u *name) |
7 | 2509 { |
2510 char_u *term; | |
2511 | |
2512 if (name != NULL && *name == NUL) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2513 name = NULL; // empty name is equal to no name |
7 | 2514 term = name; |
2515 | |
2516 #ifndef MSWIN | |
2517 if (term == NULL) | |
2518 term = mch_getenv((char_u *)"TERM"); | |
2519 #endif | |
2520 if (term == NULL || *term == NUL) | |
2521 term = DEFAULT_TERM; | |
694 | 2522 set_string_option_direct((char_u *)"term", -1, term, OPT_FREE, 0); |
7 | 2523 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2524 // Set the default terminal name. |
7 | 2525 set_string_default("term", term); |
2526 set_string_default("ttytype", term); | |
2527 | |
2528 /* | |
2529 * Avoid using "term" here, because the next mch_getenv() may overwrite it. | |
2530 */ | |
2531 set_termname(T_NAME != NULL ? T_NAME : term); | |
2532 } | |
2533 | |
2534 /* | |
16200
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2535 * The number of calls to ui_write is reduced by using "out_buf". |
7 | 2536 */ |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
2537 #define OUT_SIZE 2047 |
16200
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2538 |
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2539 // add one to allow mch_write() in os_win32.c to append a NUL |
7 | 2540 static char_u out_buf[OUT_SIZE + 1]; |
16200
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2541 |
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2542 static int out_pos = 0; // number of chars in out_buf |
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2543 |
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2544 // Since the maximum number of SGR parameters shown as a normal value range is |
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2545 // 16, the escape sequence length can be 4 * 16 + lead + tail. |
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2546 #define MAX_ESC_SEQ_LEN 80 |
7 | 2547 |
2548 /* | |
2549 * out_flush(): flush the output buffer | |
2550 */ | |
2551 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2552 out_flush(void) |
7 | 2553 { |
2554 int len; | |
2555 | |
2556 if (out_pos != 0) | |
2557 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2558 // set out_pos to 0 before ui_write, to avoid recursiveness |
7 | 2559 len = out_pos; |
2560 out_pos = 0; | |
24194
9f64c420f280
patch 8.2.2638: cannot write a message to the terminal from the GUI
Bram Moolenaar <Bram@vim.org>
parents:
24045
diff
changeset
|
2561 ui_write(out_buf, len, FALSE); |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2562 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2563 if (ch_log_output) |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2564 { |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2565 out_buf[len] = NUL; |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2566 ch_log(NULL, "raw %s output: \"%s\"", |
23610
07f9e4a54178
patch 8.2.2347: build failure without GUI
Bram Moolenaar <Bram@vim.org>
parents:
23606
diff
changeset
|
2567 # ifdef FEAT_GUI |
07f9e4a54178
patch 8.2.2347: build failure without GUI
Bram Moolenaar <Bram@vim.org>
parents:
23606
diff
changeset
|
2568 (gui.in_use && !gui.dying && !gui.starting) ? "GUI" : |
07f9e4a54178
patch 8.2.2347: build failure without GUI
Bram Moolenaar <Bram@vim.org>
parents:
23606
diff
changeset
|
2569 # endif |
07f9e4a54178
patch 8.2.2347: build failure without GUI
Bram Moolenaar <Bram@vim.org>
parents:
23606
diff
changeset
|
2570 "terminal", |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2571 out_buf); |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2572 ch_log_output = FALSE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2573 } |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2574 #endif |
7 | 2575 } |
2576 } | |
2577 | |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2578 /* |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
2579 * out_flush_cursor(): flush the output buffer and redraw the cursor. |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
2580 * Does not flush recursively in the GUI to avoid slow drawing. |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2581 */ |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2582 void |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2583 out_flush_cursor( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2584 int force UNUSED, // when TRUE, update cursor even when not moved |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2585 int clear_selection UNUSED) // clear selection under cursor |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2586 { |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2587 mch_disable_flush(); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2588 out_flush(); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2589 mch_enable_flush(); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2590 #ifdef FEAT_GUI |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2591 if (gui.in_use) |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2592 { |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2593 gui_update_cursor(force, clear_selection); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2594 gui_may_flush(); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2595 } |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2596 #endif |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2597 } |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2598 |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2599 |
7 | 2600 /* |
2601 * Sometimes a byte out of a multi-byte character is written with out_char(). | |
2602 * To avoid flushing half of the character, call this function first. | |
2603 */ | |
2604 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2605 out_flush_check(void) |
7 | 2606 { |
2607 if (enc_dbcs != 0 && out_pos >= OUT_SIZE - MB_MAXBYTES) | |
2608 out_flush(); | |
2609 } | |
2610 | |
2611 #ifdef FEAT_GUI | |
2612 /* | |
2613 * out_trash(): Throw away the contents of the output buffer | |
2614 */ | |
2615 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2616 out_trash(void) |
7 | 2617 { |
2618 out_pos = 0; | |
2619 } | |
2620 #endif | |
2621 | |
2622 /* | |
2623 * out_char(c): put a byte into the output buffer. | |
2624 * Flush it if it becomes full. | |
2625 * This should not be used for outputting text on the screen (use functions | |
2626 * like msg_puts() and screen_putchar() for that). | |
2627 */ | |
2628 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2629 out_char(unsigned c) |
7 | 2630 { |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12640
diff
changeset
|
2631 #if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(MACOS_X) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2632 if (c == '\n') // turn LF into CR-LF (CRMOD doesn't seem to do this) |
7 | 2633 out_char('\r'); |
2634 #endif | |
2635 | |
2636 out_buf[out_pos++] = c; | |
2637 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2638 // For testing we flush each time. |
7 | 2639 if (out_pos >= OUT_SIZE || p_wd) |
2640 out_flush(); | |
2641 } | |
2642 | |
2643 /* | |
18430
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
2644 * Output "c" like out_char(), but don't flush when p_wd is set. |
7 | 2645 */ |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2646 static int |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2647 out_char_nf(int c) |
7 | 2648 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2649 out_buf[out_pos++] = (unsigned)c; |
7 | 2650 |
2651 if (out_pos >= OUT_SIZE) | |
2652 out_flush(); | |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2653 return (unsigned)c; |
7 | 2654 } |
2655 | |
2656 /* | |
18430
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
2657 * A never-padding out_str(). |
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
2658 * Use this whenever you don't want to run the string through tputs(). |
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
2659 * tputs() above is harmless, but tputs() from the termcap library |
7 | 2660 * is likely to strip off leading digits, that it mistakes for padding |
2661 * information, and "%i", "%d", etc. | |
2662 * This should only be used for writing terminal codes, not for outputting | |
2663 * normal text (use functions like msg_puts() and screen_putchar() for that). | |
2664 */ | |
2665 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2666 out_str_nf(char_u *s) |
7 | 2667 { |
16200
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2668 // avoid terminal strings being split up |
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2669 if (out_pos > OUT_SIZE - MAX_ESC_SEQ_LEN) |
7 | 2670 out_flush(); |
16200
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2671 |
7 | 2672 while (*s) |
2673 out_char_nf(*s++); | |
2674 | |
16200
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2675 // For testing we write one string at a time. |
7 | 2676 if (p_wd) |
2677 out_flush(); | |
2678 } | |
2679 | |
2680 /* | |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2681 * 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
|
2682 * 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
|
2683 * it at the wrong time. |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2684 * Note: Only for terminal strings. |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2685 */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2686 void |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2687 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
|
2688 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2689 if (s != NULL && *s) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2690 { |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2691 #ifdef HAVE_TGETENT |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2692 char_u *p; |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2693 #endif |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2694 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2695 #ifdef FEAT_GUI |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2696 // Don't use tputs() when GUI is used, ncurses crashes. |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2697 if (gui.in_use) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2698 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2699 out_str_nf(s); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2700 return; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2701 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2702 #endif |
16200
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2703 if (out_pos > OUT_SIZE - MAX_ESC_SEQ_LEN) |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2704 out_flush(); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2705 #ifdef HAVE_TGETENT |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2706 for (p = s; *s; ++s) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2707 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2708 // flush just before delay command |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2709 if (*s == '$' && *(s + 1) == '<') |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2710 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2711 char_u save_c = *s; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2712 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
|
2713 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2714 *s = NUL; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2715 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
|
2716 *s = save_c; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2717 out_flush(); |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2718 # ifdef ELAPSED_FUNC |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2719 // Only sleep here if we can limit this happening in |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2720 // vim_beep(). |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2721 p = vim_strchr(s, '>'); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2722 if (p == NULL || duration <= 0) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2723 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2724 // can't parse the time, don't sleep here |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2725 p = s; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2726 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2727 else |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2728 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2729 ++p; |
23648
b7d3c79075c5
patch 8.2.2366: when using ":sleep" the cursor is always displayed
Bram Moolenaar <Bram@vim.org>
parents:
23632
diff
changeset
|
2730 do_sleep(duration, FALSE); |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2731 } |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2732 # else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2733 // Rely on the terminal library to sleep. |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2734 p = s; |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2735 # endif |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2736 break; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2737 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2738 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2739 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
|
2740 #else |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2741 while (*s) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2742 out_char_nf(*s++); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2743 #endif |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2744 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2745 // For testing we write one string at a time. |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2746 if (p_wd) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2747 out_flush(); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2748 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2749 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2750 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2751 /* |
7 | 2752 * out_str(s): Put a character string a byte at a time into the output buffer. |
18430
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
2753 * If HAVE_TGETENT is defined use tputs(), the termcap parser. (jw) |
7 | 2754 * This should only be used for writing terminal codes, not for outputting |
2755 * normal text (use functions like msg_puts() and screen_putchar() for that). | |
2756 */ | |
2757 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2758 out_str(char_u *s) |
7 | 2759 { |
2760 if (s != NULL && *s) | |
2761 { | |
2762 #ifdef FEAT_GUI | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2763 // Don't use tputs() when GUI is used, ncurses crashes. |
7 | 2764 if (gui.in_use) |
2765 { | |
2766 out_str_nf(s); | |
2767 return; | |
2768 } | |
2769 #endif | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2770 // avoid terminal strings being split up |
16200
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2771 if (out_pos > OUT_SIZE - MAX_ESC_SEQ_LEN) |
7 | 2772 out_flush(); |
2773 #ifdef HAVE_TGETENT | |
2774 tputs((char *)s, 1, TPUTSFUNCAST out_char_nf); | |
2775 #else | |
2776 while (*s) | |
2777 out_char_nf(*s++); | |
2778 #endif | |
2779 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2780 // For testing we write one string at a time. |
7 | 2781 if (p_wd) |
2782 out_flush(); | |
2783 } | |
2784 } | |
2785 | |
2786 /* | |
2787 * cursor positioning using termcap parser. (jw) | |
2788 */ | |
2789 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2790 term_windgoto(int row, int col) |
7 | 2791 { |
2792 OUT_STR(tgoto((char *)T_CM, col, row)); | |
2793 } | |
2794 | |
2795 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2796 term_cursor_right(int i) |
7 | 2797 { |
2798 OUT_STR(tgoto((char *)T_CRI, 0, i)); | |
2799 } | |
2800 | |
2801 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2802 term_append_lines(int line_count) |
7 | 2803 { |
2804 OUT_STR(tgoto((char *)T_CAL, 0, line_count)); | |
2805 } | |
2806 | |
2807 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2808 term_delete_lines(int line_count) |
7 | 2809 { |
2810 OUT_STR(tgoto((char *)T_CDL, 0, line_count)); | |
2811 } | |
2812 | |
2813 #if defined(HAVE_TGETENT) || defined(PROTO) | |
2814 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2815 term_set_winpos(int x, int y) |
7 | 2816 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2817 // Can't handle a negative value here |
7 | 2818 if (x < 0) |
2819 x = 0; | |
2820 if (y < 0) | |
2821 y = 0; | |
2822 OUT_STR(tgoto((char *)T_CWP, y, x)); | |
2823 } | |
2824 | |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2825 # 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
|
2826 /* |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2827 * 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
|
2828 */ |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2829 static int |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2830 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
|
2831 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2832 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
|
2833 && termcap_active |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2834 # ifdef UNIX |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2835 && (is_not_a_term() || (isatty(1) && isatty(read_cmd_fd))) |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2836 # endif |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2837 && p_ek; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2838 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2839 |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2840 /* |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2841 * Set "status" to STATUS_SENT. |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2842 */ |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2843 static void |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2844 termrequest_sent(termrequest_T *status) |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2845 { |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2846 status->tr_progress = STATUS_SENT; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2847 status->tr_start = time(NULL); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2848 } |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2849 |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2850 /* |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2851 * Return TRUE if any of the requests are in STATUS_SENT. |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2852 */ |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2853 static int |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2854 termrequest_any_pending() |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2855 { |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2856 int i; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2857 time_t now = time(NULL); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2858 |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2859 for (i = 0; all_termrequests[i] != NULL; ++i) |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2860 { |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2861 if (all_termrequests[i]->tr_progress == STATUS_SENT) |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2862 { |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2863 if (all_termrequests[i]->tr_start > 0 && now > 0 |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2864 && all_termrequests[i]->tr_start + 2 < now) |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2865 // Sent the request more than 2 seconds ago and didn't get a |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2866 // response, assume it failed. |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2867 all_termrequests[i]->tr_progress = STATUS_FAIL; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2868 else |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2869 return TRUE; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2870 } |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2871 } |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2872 return FALSE; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2873 } |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2874 |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2875 static int winpos_x = -1; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2876 static int winpos_y = -1; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2877 static int did_request_winpos = 0; |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2878 |
16245
e0a6298bd70f
patch 8.1.1127: getwinpos() doesn't work in terminal on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents:
16200
diff
changeset
|
2879 # if defined(FEAT_EVAL) || defined(FEAT_TERMINAL) || defined(PROTO) |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2880 /* |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2881 * 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
|
2882 * 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
|
2883 */ |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2884 int |
13379
0f9dd1b43244
patch 8.0.1563: timeout of getwinposx() can be too short
Christian Brabandt <cb@256bit.org>
parents:
13365
diff
changeset
|
2885 term_get_winpos(int *x, int *y, varnumber_T timeout) |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2886 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2887 int count = 0; |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2888 int prev_winpos_x = winpos_x; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2889 int prev_winpos_y = winpos_y; |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2890 |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2891 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
|
2892 return FAIL; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2893 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
|
2894 winpos_y = -1; |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2895 ++did_request_winpos; |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2896 termrequest_sent(&winpos_status); |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2897 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
|
2898 out_flush(); |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2899 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2900 // Try reading the result for "timeout" msec. |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2901 while (count++ <= timeout / 10 && !got_int) |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2902 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2903 (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
|
2904 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
|
2905 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2906 *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
|
2907 *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
|
2908 return OK; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2909 } |
18642
bbea1f108187
patch 8.1.2313: debugging where a delay comes from is not easy
Bram Moolenaar <Bram@vim.org>
parents:
18430
diff
changeset
|
2910 ui_delay(10L, FALSE); |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2911 } |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2912 // Do not reset "did_request_winpos", if we timed out the response might |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2913 // still come later and we must consume it. |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2914 |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2915 winpos_x = prev_winpos_x; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2916 winpos_y = prev_winpos_y; |
13762
9de2b25932eb
patch 8.0.1753: various warnings from a static analyser
Christian Brabandt <cb@256bit.org>
parents:
13573
diff
changeset
|
2917 if (timeout < 10 && prev_winpos_y >= 0 && prev_winpos_x >= 0) |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2918 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2919 // Polling: return previous values if we have them. |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2920 *x = winpos_x; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2921 *y = winpos_y; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2922 return OK; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2923 } |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2924 |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2925 return FALSE; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2926 } |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2927 # endif |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2928 # endif |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2929 |
7 | 2930 void |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
2931 term_set_winsize(int height, int width) |
7 | 2932 { |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
2933 OUT_STR(tgoto((char *)T_CWS, width, height)); |
7 | 2934 } |
2935 #endif | |
2936 | |
2937 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2938 term_color(char_u *s, int n) |
7 | 2939 { |
2940 char buf[20]; | |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2941 int i = *s == CSI ? 1 : 2; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2942 // index in s[] just after <Esc>[ or CSI |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2943 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2944 // Special handling of 16 colors, because termcap can't handle it |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2945 // Also accept "\e[3%dm" for TERMINFO, it is sometimes used |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2946 // Also accept CSI instead of <Esc>[ |
7 | 2947 if (n >= 8 && t_colors >= 16 |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
2948 && ((s[0] == ESC && s[1] == '[') |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
2949 #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
2950 || (s[0] == ESC && s[1] == '|') |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
2951 #endif |
20437
3bb4dea4a164
patch 8.2.0773: switching to raw mode every time ":" is used
Bram Moolenaar <Bram@vim.org>
parents:
20425
diff
changeset
|
2952 || (s[0] == CSI && (i = 1) == 1)) |
7 | 2953 && s[i] != NUL |
2954 && (STRCMP(s + i + 1, "%p1%dm") == 0 | |
2955 || STRCMP(s + i + 1, "%dm") == 0) | |
2956 && (s[i] == '3' || s[i] == '4')) | |
2957 { | |
2958 #ifdef TERMINFO | |
9068
0a3bc9fdea20
commit https://github.com/vim/vim/commit/827b165b2aebad2cfe98cc6d5804c6c0fe8afd89
Christian Brabandt <cb@256bit.org>
parents:
9027
diff
changeset
|
2959 char *format = "%s%s%%p1%%dm"; |
7 | 2960 #else |
9068
0a3bc9fdea20
commit https://github.com/vim/vim/commit/827b165b2aebad2cfe98cc6d5804c6c0fe8afd89
Christian Brabandt <cb@256bit.org>
parents:
9027
diff
changeset
|
2961 char *format = "%s%s%%dm"; |
7 | 2962 #endif |
14007
5d6e8dedfc73
patch 8.1.0021: clang warns for undefined behavior
Christian Brabandt <cb@256bit.org>
parents:
13874
diff
changeset
|
2963 char *lead = i == 2 ? ( |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
2964 #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS) |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
2965 s[1] == '|' ? "\033|" : |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
2966 #endif |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
2967 "\033[") : "\233"; |
14007
5d6e8dedfc73
patch 8.1.0021: clang warns for undefined behavior
Christian Brabandt <cb@256bit.org>
parents:
13874
diff
changeset
|
2968 char *tail = s[i] == '3' ? (n >= 16 ? "38;5;" : "9") |
5d6e8dedfc73
patch 8.1.0021: clang warns for undefined behavior
Christian Brabandt <cb@256bit.org>
parents:
13874
diff
changeset
|
2969 : (n >= 16 ? "48;5;" : "10"); |
5d6e8dedfc73
patch 8.1.0021: clang warns for undefined behavior
Christian Brabandt <cb@256bit.org>
parents:
13874
diff
changeset
|
2970 |
5d6e8dedfc73
patch 8.1.0021: clang warns for undefined behavior
Christian Brabandt <cb@256bit.org>
parents:
13874
diff
changeset
|
2971 sprintf(buf, format, lead, tail); |
7 | 2972 OUT_STR(tgoto(buf, 0, n >= 16 ? n : n - 8)); |
2973 } | |
2974 else | |
2975 OUT_STR(tgoto((char *)s, 0, n)); | |
2976 } | |
2977 | |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2978 void |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2979 term_fg_color(int n) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2980 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2981 // Use "AF" termcap entry if present, "Sf" entry otherwise |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2982 if (*T_CAF) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2983 term_color(T_CAF, n); |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2984 else if (*T_CSF) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2985 term_color(T_CSF, n); |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2986 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2987 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2988 void |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2989 term_bg_color(int n) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2990 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2991 // Use "AB" termcap entry if present, "Sb" entry otherwise |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2992 if (*T_CAB) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2993 term_color(T_CAB, n); |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2994 else if (*T_CSB) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2995 term_color(T_CSB, n); |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2996 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2997 |
20619
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
2998 void |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
2999 term_ul_color(int n) |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3000 { |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3001 if (*T_CAU) |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3002 term_color(T_CAU, n); |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3003 } |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3004 |
18679
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3005 /* |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3006 * Return "dark" or "light" depending on the kind of terminal. |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3007 * This is just guessing! Recognized are: |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3008 * "linux" Linux console |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3009 * "screen.linux" Linux console with screen |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3010 * "cygwin.*" Cygwin shell |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3011 * "putty.*" Putty program |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3012 * We also check the COLORFGBG environment variable, which is set by |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3013 * rxvt and derivatives. This variable contains either two or three |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3014 * values separated by semicolons; we want the last value in either |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3015 * case. If this value is 0-6 or 8, our background is dark. |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3016 */ |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3017 char_u * |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3018 term_bg_default(void) |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3019 { |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3020 #if defined(MSWIN) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3021 // DOS console is nearly always black |
18679
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3022 return (char_u *)"dark"; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3023 #else |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3024 char_u *p; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3025 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3026 if (STRCMP(T_NAME, "linux") == 0 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3027 || STRCMP(T_NAME, "screen.linux") == 0 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3028 || STRNCMP(T_NAME, "cygwin", 6) == 0 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3029 || STRNCMP(T_NAME, "putty", 5) == 0 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3030 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3031 && (p = vim_strrchr(p, ';')) != NULL |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3032 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8') |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3033 && p[2] == NUL)) |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3034 return (char_u *)"dark"; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3035 return (char_u *)"light"; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3036 #endif |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3037 } |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3038 |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
3039 #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
|
3040 |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3041 #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
|
3042 #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
|
3043 #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
|
3044 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3045 static void |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3046 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
|
3047 { |
8975
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
3048 #define MAX_COLOR_STR_LEN 100 |
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
3049 char buf[MAX_COLOR_STR_LEN]; |
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
3050 |
8981
3b51b0aeb9a3
commit https://github.com/vim/vim/commit/a1c487eef71d1673e57511453009de9cb4c9af51
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
3051 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
|
3052 (char *)s, RED(rgb), GREEN(rgb), BLUE(rgb)); |
20589
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3053 #ifdef FEAT_VTP |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3054 if (use_wt()) |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3055 { |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3056 out_flush(); |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3057 buf[1] = '['; |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3058 vtp_printf(buf); |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3059 } |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3060 else |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3061 #endif |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3062 OUT_STR(buf); |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3063 } |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3064 |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3065 void |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3066 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
|
3067 { |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3068 term_rgb_color(T_8F, rgb); |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3069 } |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3070 |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3071 void |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3072 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
|
3073 { |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3074 term_rgb_color(T_8B, rgb); |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3075 } |
20619
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3076 |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3077 void |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3078 term_ul_rgb_color(guicolor_T rgb) |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3079 { |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3080 term_rgb_color(T_8U, rgb); |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3081 } |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3082 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3083 |
26336
a2e6da79274d
patch 8.2.3699: the +title feature adds a lot of #ifdef but little code
Bram Moolenaar <Bram@vim.org>
parents:
26177
diff
changeset
|
3084 #if (defined(UNIX) || defined(VMS) || defined(MACOS_X)) || defined(PROTO) |
7 | 3085 /* |
3086 * Generic function to set window title, using t_ts and t_fs. | |
3087 */ | |
3088 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3089 term_settitle(char_u *title) |
7 | 3090 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3091 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3092 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3093 #endif |
18430
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
3094 // t_ts takes one argument: column in status line |
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
3095 OUT_STR(tgoto((char *)T_TS, 0, 0)); // set title start |
7 | 3096 out_str_nf(title); |
18430
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
3097 out_str(T_FS); // set title end |
7 | 3098 out_flush(); |
3099 } | |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3100 |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3101 /* |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3102 * Tell the terminal to push (save) the title and/or icon, so that it can be |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3103 * popped (restored) later. |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3104 */ |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3105 void |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3106 term_push_title(int which) |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3107 { |
16586
5ebb2c87d1f5
patch 8.1.1296: crash when using invalid command line argument
Bram Moolenaar <Bram@vim.org>
parents:
16523
diff
changeset
|
3108 if ((which & SAVE_RESTORE_TITLE) && T_CST != NULL && *T_CST != NUL) |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3109 { |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3110 OUT_STR(T_CST); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3111 out_flush(); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3112 } |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3113 |
16586
5ebb2c87d1f5
patch 8.1.1296: crash when using invalid command line argument
Bram Moolenaar <Bram@vim.org>
parents:
16523
diff
changeset
|
3114 if ((which & SAVE_RESTORE_ICON) && T_SSI != NULL && *T_SSI != NUL) |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3115 { |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3116 OUT_STR(T_SSI); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3117 out_flush(); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3118 } |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3119 } |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3120 |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3121 /* |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3122 * Tell the terminal to pop the title and/or icon. |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3123 */ |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3124 void |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3125 term_pop_title(int which) |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3126 { |
16586
5ebb2c87d1f5
patch 8.1.1296: crash when using invalid command line argument
Bram Moolenaar <Bram@vim.org>
parents:
16523
diff
changeset
|
3127 if ((which & SAVE_RESTORE_TITLE) && T_CRT != NULL && *T_CRT != NUL) |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3128 { |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3129 OUT_STR(T_CRT); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3130 out_flush(); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3131 } |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3132 |
16586
5ebb2c87d1f5
patch 8.1.1296: crash when using invalid command line argument
Bram Moolenaar <Bram@vim.org>
parents:
16523
diff
changeset
|
3133 if ((which & SAVE_RESTORE_ICON) && T_SRI != NULL && *T_SRI != NUL) |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3134 { |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3135 OUT_STR(T_SRI); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3136 out_flush(); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3137 } |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3138 } |
7 | 3139 #endif |
3140 | |
3141 /* | |
3142 * Make sure we have a valid set or terminal options. | |
3143 * Replace all entries that are NULL by empty_option | |
3144 */ | |
3145 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3146 ttest(int pairs) |
7 | 3147 { |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
3148 char_u *env_colors; |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
3149 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3150 check_options(); // make sure no options are NULL |
7 | 3151 |
3152 /* | |
3153 * MUST have "cm": cursor motion. | |
3154 */ | |
3155 if (*T_CM == NUL) | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
3156 emsg(_(e_terminal_capability_cm_required)); |
7 | 3157 |
3158 /* | |
3159 * if "cs" defined, use a scroll region, it's faster. | |
3160 */ | |
3161 if (*T_CS != NUL) | |
3162 scroll_region = TRUE; | |
3163 else | |
3164 scroll_region = FALSE; | |
3165 | |
3166 if (pairs) | |
3167 { | |
3168 /* | |
3169 * optional pairs | |
3170 */ | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3171 // TP goes to normal mode for TI (invert) and TB (bold) |
7 | 3172 if (*T_ME == NUL) |
3173 T_ME = T_MR = T_MD = T_MB = empty_option; | |
3174 if (*T_SO == NUL || *T_SE == NUL) | |
3175 T_SO = T_SE = empty_option; | |
3176 if (*T_US == NUL || *T_UE == NUL) | |
3177 T_US = T_UE = empty_option; | |
3178 if (*T_CZH == NUL || *T_CZR == NUL) | |
3179 T_CZH = T_CZR = empty_option; | |
3180 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3181 // T_VE is needed even though T_VI is not defined |
7 | 3182 if (*T_VE == NUL) |
3183 T_VI = empty_option; | |
3184 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3185 // if 'mr' or 'me' is not defined use 'so' and 'se' |
7 | 3186 if (*T_ME == NUL) |
3187 { | |
3188 T_ME = T_SE; | |
3189 T_MR = T_SO; | |
3190 T_MD = T_SO; | |
3191 } | |
3192 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3193 // if 'so' or 'se' is not defined use 'mr' and 'me' |
7 | 3194 if (*T_SO == NUL) |
3195 { | |
3196 T_SE = T_ME; | |
3197 if (*T_MR == NUL) | |
3198 T_SO = T_MD; | |
3199 else | |
3200 T_SO = T_MR; | |
3201 } | |
3202 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3203 // if 'ZH' or 'ZR' is not defined use 'mr' and 'me' |
7 | 3204 if (*T_CZH == NUL) |
3205 { | |
3206 T_CZR = T_ME; | |
3207 if (*T_MR == NUL) | |
3208 T_CZH = T_MD; | |
3209 else | |
3210 T_CZH = T_MR; | |
3211 } | |
3212 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3213 // "Sb" and "Sf" come in pairs |
7 | 3214 if (*T_CSB == NUL || *T_CSF == NUL) |
3215 { | |
3216 T_CSB = empty_option; | |
3217 T_CSF = empty_option; | |
3218 } | |
3219 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3220 // "AB" and "AF" come in pairs |
7 | 3221 if (*T_CAB == NUL || *T_CAF == NUL) |
3222 { | |
3223 T_CAB = empty_option; | |
3224 T_CAF = empty_option; | |
3225 } | |
3226 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3227 // if 'Sb' and 'AB' are not defined, reset "Co" |
7 | 3228 if (*T_CSB == NUL && *T_CAB == NUL) |
1941 | 3229 free_one_termoption(T_CCO); |
7 | 3230 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3231 // Set 'weirdinvert' according to value of 't_xs' |
7 | 3232 p_wiv = (*T_XS != NUL); |
3233 } | |
3234 need_gather = TRUE; | |
3235 | |
20181
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3236 // Set t_colors to the value of $COLORS or t_Co. Ignore $COLORS in the |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3237 // GUI. |
7 | 3238 t_colors = atoi((char *)T_CCO); |
20181
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3239 #ifdef FEAT_GUI |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3240 if (!gui.in_use) |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3241 #endif |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
3242 { |
20181
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3243 env_colors = mch_getenv((char_u *)"COLORS"); |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3244 if (env_colors != NULL && isdigit(*env_colors)) |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3245 { |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3246 int colors = atoi((char *)env_colors); |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3247 |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3248 if (colors != t_colors) |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3249 set_color_count(colors); |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3250 } |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
3251 } |
7 | 3252 } |
3253 | |
3254 #if (defined(FEAT_GUI) && (defined(FEAT_MENU) || !defined(USE_ON_FLY_SCROLL))) \ | |
3255 || defined(PROTO) | |
3256 /* | |
3257 * Represent the given long_u as individual bytes, with the most significant | |
3258 * byte first, and store them in dst. | |
3259 */ | |
3260 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3261 add_long_to_buf(long_u val, char_u *dst) |
7 | 3262 { |
3263 int i; | |
3264 int shift; | |
3265 | |
1883 | 3266 for (i = 1; i <= (int)sizeof(long_u); i++) |
7 | 3267 { |
3268 shift = 8 * (sizeof(long_u) - i); | |
3269 dst[i - 1] = (char_u) ((val >> shift) & 0xff); | |
3270 } | |
3271 } | |
3272 | |
3273 /* | |
3274 * Interpret the next string of bytes in buf as a long integer, with the most | |
3275 * significant byte first. Note that it is assumed that buf has been through | |
3276 * inchar(), so that NUL and K_SPECIAL will be represented as three bytes each. | |
3277 * Puts result in val, and returns the number of bytes read from buf | |
3278 * (between sizeof(long_u) and 2 * sizeof(long_u)), or -1 if not enough bytes | |
3279 * were present. | |
3280 */ | |
3281 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3282 get_long_from_buf(char_u *buf, long_u *val) |
7 | 3283 { |
3284 int len; | |
3285 char_u bytes[sizeof(long_u)]; | |
3286 int i; | |
3287 int shift; | |
3288 | |
3289 *val = 0; | |
3290 len = get_bytes_from_buf(buf, bytes, (int)sizeof(long_u)); | |
3291 if (len != -1) | |
3292 { | |
1883 | 3293 for (i = 0; i < (int)sizeof(long_u); i++) |
7 | 3294 { |
3295 shift = 8 * (sizeof(long_u) - 1 - i); | |
3296 *val += (long_u)bytes[i] << shift; | |
3297 } | |
3298 } | |
3299 return len; | |
3300 } | |
3301 #endif | |
3302 | |
3303 /* | |
3304 * Read the next num_bytes bytes from buf, and store them in bytes. Assume | |
3305 * that buf has been through inchar(). Returns the actual number of bytes used | |
3306 * from buf (between num_bytes and num_bytes*2), or -1 if not enough bytes were | |
3307 * available. | |
3308 */ | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
3309 int |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3310 get_bytes_from_buf(char_u *buf, char_u *bytes, int num_bytes) |
7 | 3311 { |
3312 int len = 0; | |
3313 int i; | |
3314 char_u c; | |
3315 | |
3316 for (i = 0; i < num_bytes; i++) | |
3317 { | |
3318 if ((c = buf[len++]) == NUL) | |
3319 return -1; | |
3320 if (c == K_SPECIAL) | |
3321 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3322 if (buf[len] == NUL || buf[len + 1] == NUL) // cannot happen? |
7 | 3323 return -1; |
3324 if (buf[len++] == (int)KS_ZERO) | |
3325 c = NUL; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3326 // else it should be KS_SPECIAL; when followed by KE_FILLER c is |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3327 // K_SPECIAL, or followed by KE_CSI and c must be CSI. |
5076
19ed30f7cef7
updated for version 7.3.1281
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
3328 if (buf[len++] == (int)KE_CSI) |
19ed30f7cef7
updated for version 7.3.1281
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
3329 c = CSI; |
7 | 3330 } |
1160 | 3331 else if (c == CSI && buf[len] == KS_EXTRA |
3332 && buf[len + 1] == (int)KE_CSI) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3333 // CSI is stored as CSI KS_SPECIAL KE_CSI to avoid confusion with |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3334 // the start of a special key, see add_to_input_buf_csi(). |
667 | 3335 len += 2; |
7 | 3336 bytes[i] = c; |
3337 } | |
3338 return len; | |
3339 } | |
3340 | |
3341 /* | |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3342 * 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
|
3343 * too big. |
7 | 3344 */ |
3345 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3346 check_shellsize(void) |
7 | 3347 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3348 if (Rows < min_rows()) // need room for one window and command line |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3349 Rows = min_rows(); |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3350 limit_screen_size(); |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3351 } |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3352 |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3353 /* |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3354 * 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
|
3355 */ |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3356 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3357 limit_screen_size(void) |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3358 { |
7 | 3359 if (Columns < MIN_COLUMNS) |
3360 Columns = MIN_COLUMNS; | |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3361 else if (Columns > 10000) |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3362 Columns = 10000; |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3363 if (Rows > 1000) |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3364 Rows = 1000; |
7 | 3365 } |
3366 | |
41 | 3367 /* |
3368 * Invoked just before the screen structures are going to be (re)allocated. | |
3369 */ | |
7 | 3370 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3371 win_new_shellsize(void) |
7 | 3372 { |
3373 static int old_Rows = 0; | |
3374 static int old_Columns = 0; | |
3375 | |
3376 if (old_Rows != Rows || old_Columns != Columns) | |
3377 ui_new_shellsize(); | |
3378 if (old_Rows != Rows) | |
3379 { | |
24228
1e85e76f9e76
patch 8.2.2655: The -w command line argument doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24194
diff
changeset
|
3380 // If 'window' uses the whole screen, keep it using that. |
1e85e76f9e76
patch 8.2.2655: The -w command line argument doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24194
diff
changeset
|
3381 // Don't change it when set with "-w size" on the command line. |
1e85e76f9e76
patch 8.2.2655: The -w command line argument doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24194
diff
changeset
|
3382 if (p_window == old_Rows - 1 || (old_Rows == 0 && p_window == 0)) |
164 | 3383 p_window = Rows - 1; |
7 | 3384 old_Rows = Rows; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3385 shell_new_rows(); // update window sizes |
7 | 3386 } |
3387 if (old_Columns != Columns) | |
3388 { | |
3389 old_Columns = Columns; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3390 shell_new_columns(); // update window sizes |
7 | 3391 } |
3392 } | |
3393 | |
3394 /* | |
3395 * Call this function when the Vim shell has been resized in any way. | |
3396 * Will obtain the current size and redraw (also when size didn't change). | |
3397 */ | |
3398 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3399 shell_resized(void) |
7 | 3400 { |
3401 set_shellsize(0, 0, FALSE); | |
3402 } | |
3403 | |
3404 /* | |
3405 * Check if the shell size changed. Handle a resize. | |
3406 * When the size didn't change, nothing happens. | |
3407 */ | |
3408 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3409 shell_resized_check(void) |
7 | 3410 { |
3411 int old_Rows = Rows; | |
3412 int old_Columns = Columns; | |
3413 | |
3770 | 3414 if (!exiting |
3415 #ifdef FEAT_GUI | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3416 // Do not get the size when executing a shell command during |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3417 // startup. |
3770 | 3418 && !gui.starting |
3419 #endif | |
3420 ) | |
2673 | 3421 { |
3422 (void)ui_get_shellsize(); | |
3423 check_shellsize(); | |
3424 if (old_Rows != Rows || old_Columns != Columns) | |
3425 shell_resized(); | |
3426 } | |
7 | 3427 } |
3428 | |
3429 /* | |
3430 * Set size of the Vim shell. | |
3431 * If 'mustset' is TRUE, we must set Rows and Columns, do not get the real | |
3432 * window size (this is used for the :win command). | |
3433 * If 'mustset' is FALSE, we may try to get the real window size and if | |
3434 * it fails use 'width' and 'height'. | |
3435 */ | |
3436 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3437 set_shellsize(int width, int height, int mustset) |
7 | 3438 { |
3439 static int busy = FALSE; | |
3440 | |
3441 /* | |
3442 * Avoid recursiveness, can happen when setting the window size causes | |
3443 * another window-changed signal. | |
3444 */ | |
3445 if (busy) | |
3446 return; | |
3447 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3448 if (width < 0 || height < 0) // just checking... |
7 | 3449 return; |
3450 | |
3068 | 3451 if (State == HITRETURN || State == SETWSIZE) |
7 | 3452 { |
17330
b2918bd457cb
patch 8.1.1664: GUI resize may cause changing Rows at a bad time
Bram Moolenaar <Bram@vim.org>
parents:
16961
diff
changeset
|
3453 // postpone the resizing |
7 | 3454 State = SETWSIZE; |
3455 return; | |
3456 } | |
3457 | |
17330
b2918bd457cb
patch 8.1.1664: GUI resize may cause changing Rows at a bad time
Bram Moolenaar <Bram@vim.org>
parents:
16961
diff
changeset
|
3458 if (updating_screen) |
b2918bd457cb
patch 8.1.1664: GUI resize may cause changing Rows at a bad time
Bram Moolenaar <Bram@vim.org>
parents:
16961
diff
changeset
|
3459 // resizing while in update_screen() may cause a crash |
b2918bd457cb
patch 8.1.1664: GUI resize may cause changing Rows at a bad time
Bram Moolenaar <Bram@vim.org>
parents:
16961
diff
changeset
|
3460 return; |
b2918bd457cb
patch 8.1.1664: GUI resize may cause changing Rows at a bad time
Bram Moolenaar <Bram@vim.org>
parents:
16961
diff
changeset
|
3461 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3462 // curwin->w_buffer can be NULL when we are closing a window and the |
23410
ae3421daa981
patch 8.2.2248: ASAN error on exit with GUI
Bram Moolenaar <Bram@vim.org>
parents:
23408
diff
changeset
|
3463 // buffer (or window) has already been closed and removing a scrollbar |
ae3421daa981
patch 8.2.2248: ASAN error on exit with GUI
Bram Moolenaar <Bram@vim.org>
parents:
23408
diff
changeset
|
3464 // causes a resize event. Don't resize then, it will happen after entering |
ae3421daa981
patch 8.2.2248: ASAN error on exit with GUI
Bram Moolenaar <Bram@vim.org>
parents:
23408
diff
changeset
|
3465 // another buffer. |
ae3421daa981
patch 8.2.2248: ASAN error on exit with GUI
Bram Moolenaar <Bram@vim.org>
parents:
23408
diff
changeset
|
3466 if (curwin->w_buffer == NULL || curwin->w_lines == NULL) |
3068 | 3467 return; |
3468 | |
7 | 3469 ++busy; |
3470 | |
3471 #ifdef AMIGA | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3472 out_flush(); // must do this before mch_get_shellsize() for |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3473 // some obscure reason |
7 | 3474 #endif |
3475 | |
3476 if (mustset || (ui_get_shellsize() == FAIL && height != 0)) | |
3477 { | |
3478 Rows = height; | |
3479 Columns = width; | |
3480 check_shellsize(); | |
3481 ui_set_shellsize(mustset); | |
3482 } | |
3483 else | |
3484 check_shellsize(); | |
3485 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3486 // The window layout used to be adjusted here, but it now happens in |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3487 // screenalloc() (also invoked from screenclear()). That is because the |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3488 // "busy" check above may skip this, but not screenalloc(). |
7 | 3489 |
3490 if (State != ASKMORE && State != EXTERNCMD && State != CONFIRM) | |
3491 screenclear(); | |
3492 else | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3493 screen_start(); // don't know where cursor is now |
7 | 3494 |
3495 if (starting != NO_SCREEN) | |
3496 { | |
3497 maketitle(); | |
26336
a2e6da79274d
patch 8.2.3699: the +title feature adds a lot of #ifdef but little code
Bram Moolenaar <Bram@vim.org>
parents:
26177
diff
changeset
|
3498 |
7 | 3499 changed_line_abv_curs(); |
3500 invalidate_botline(); | |
3501 | |
3502 /* | |
3503 * We only redraw when it's needed: | |
3504 * - While at the more prompt or executing an external command, don't | |
3505 * redraw, but position the cursor. | |
3506 * - While editing the command line, only redraw that. | |
3507 * - in Ex mode, don't redraw anything. | |
3508 * - Otherwise, redraw right now, and position the cursor. | |
3509 * Always need to call update_screen() or screenalloc(), to make | |
3510 * sure Rows/Columns and the size of ScreenLines[] is correct! | |
3511 */ | |
3512 if (State == ASKMORE || State == EXTERNCMD || State == CONFIRM | |
3513 || exmode_active) | |
3514 { | |
3515 screenalloc(FALSE); | |
3516 repeat_message(); | |
3517 } | |
3518 else | |
3519 { | |
1024 | 3520 if (curwin->w_p_scb) |
3521 do_check_scrollbind(TRUE); | |
3522 if (State & CMDLINE) | |
648 | 3523 { |
1024 | 3524 update_screen(NOT_VALID); |
3525 redrawcmdline(); | |
648 | 3526 } |
3527 else | |
1024 | 3528 { |
3529 update_topline(); | |
3530 if (pum_visible()) | |
3531 { | |
3532 redraw_later(NOT_VALID); | |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12513
diff
changeset
|
3533 ins_compl_show_pum(); |
1024 | 3534 } |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12513
diff
changeset
|
3535 update_screen(NOT_VALID); |
1024 | 3536 if (redrawing()) |
3537 setcursor(); | |
3538 } | |
7 | 3539 } |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3540 cursor_on(); // redrawing may have switched it off |
7 | 3541 } |
3542 out_flush(); | |
3543 --busy; | |
3544 } | |
3545 | |
3546 /* | |
3547 * Set the terminal to TMODE_RAW (for Normal mode) or TMODE_COOK (for external | |
3548 * commands and Ex mode). | |
3549 */ | |
3550 void | |
20450
d5d89c24eec7
patch 8.2.0779: tmode_T not used everywhere
Bram Moolenaar <Bram@vim.org>
parents:
20439
diff
changeset
|
3551 settmode(tmode_T tmode) |
7 | 3552 { |
3553 #ifdef FEAT_GUI | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3554 // don't set the term where gvim was started to any mode |
7 | 3555 if (gui.in_use) |
3556 return; | |
3557 #endif | |
3558 | |
3559 if (full_screen) | |
3560 { | |
3561 /* | |
20437
3bb4dea4a164
patch 8.2.0773: switching to raw mode every time ":" is used
Bram Moolenaar <Bram@vim.org>
parents:
20425
diff
changeset
|
3562 * When returning after calling a shell cur_tmode is TMODE_UNKNOWN, |
3bb4dea4a164
patch 8.2.0773: switching to raw mode every time ":" is used
Bram Moolenaar <Bram@vim.org>
parents:
20425
diff
changeset
|
3563 * set the terminal to raw mode, even though we think it already is, |
3bb4dea4a164
patch 8.2.0773: switching to raw mode every time ":" is used
Bram Moolenaar <Bram@vim.org>
parents:
20425
diff
changeset
|
3564 * because the shell program may have reset the terminal mode. |
7 | 3565 * When we think the terminal is normal, don't try to set it to |
3566 * normal again, because that causes problems (logout!) on some | |
3567 * machines. | |
3568 */ | |
20437
3bb4dea4a164
patch 8.2.0773: switching to raw mode every time ":" is used
Bram Moolenaar <Bram@vim.org>
parents:
20425
diff
changeset
|
3569 if (tmode != cur_tmode) |
7 | 3570 { |
3571 #ifdef FEAT_TERMRESPONSE | |
1691 | 3572 # ifdef FEAT_GUI |
3573 if (!gui.in_use && !gui.starting) | |
3574 # endif | |
3575 { | |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3576 // May need to check for T_CRV response and termcodes, it |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3577 // doesn't work in Cooked mode, an external program may get |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3578 // them. |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3579 if (tmode != TMODE_RAW && termrequest_any_pending()) |
1691 | 3580 (void)vpeekc_nomap(); |
3581 check_for_codes_from_term(); | |
3582 } | |
7 | 3583 #endif |
3584 if (tmode != TMODE_RAW) | |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3585 mch_setmouse(FALSE); // switch mouse off |
20439
d4b2a8675b78
patch 8.2.0774: t_TI and t_TE are output when using 'visualbell'
Bram Moolenaar <Bram@vim.org>
parents:
20437
diff
changeset
|
3586 |
d4b2a8675b78
patch 8.2.0774: t_TI and t_TE are output when using 'visualbell'
Bram Moolenaar <Bram@vim.org>
parents:
20437
diff
changeset
|
3587 // Disable bracketed paste and modifyOtherKeys in cooked mode. |
d4b2a8675b78
patch 8.2.0774: t_TI and t_TE are output when using 'visualbell'
Bram Moolenaar <Bram@vim.org>
parents:
20437
diff
changeset
|
3588 // Avoid doing this too often, on some terminals the codes are not |
d4b2a8675b78
patch 8.2.0774: t_TI and t_TE are output when using 'visualbell'
Bram Moolenaar <Bram@vim.org>
parents:
20437
diff
changeset
|
3589 // handled properly. |
d4b2a8675b78
patch 8.2.0774: t_TI and t_TE are output when using 'visualbell'
Bram Moolenaar <Bram@vim.org>
parents:
20437
diff
changeset
|
3590 if (termcap_active && tmode != TMODE_SLEEP |
d4b2a8675b78
patch 8.2.0774: t_TI and t_TE are output when using 'visualbell'
Bram Moolenaar <Bram@vim.org>
parents:
20437
diff
changeset
|
3591 && cur_tmode != TMODE_SLEEP) |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3592 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3593 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3594 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3595 #endif |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3596 if (tmode != TMODE_RAW) |
20425
426ef48be465
patch 8.2.0767: modifyOtherKeys active when using a shell command in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
20181
diff
changeset
|
3597 { |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3598 out_str(T_BD); // disable bracketed paste mode |
20425
426ef48be465
patch 8.2.0767: modifyOtherKeys active when using a shell command in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
20181
diff
changeset
|
3599 out_str(T_CTE); // possibly disables modifyOtherKeys |
426ef48be465
patch 8.2.0767: modifyOtherKeys active when using a shell command in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
20181
diff
changeset
|
3600 } |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3601 else |
20425
426ef48be465
patch 8.2.0767: modifyOtherKeys active when using a shell command in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
20181
diff
changeset
|
3602 { |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3603 out_str(T_BE); // enable bracketed paste mode (should |
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3604 // be before mch_settmode(). |
20425
426ef48be465
patch 8.2.0767: modifyOtherKeys active when using a shell command in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
20181
diff
changeset
|
3605 out_str(T_CTI); // possibly enables modifyOtherKeys |
426ef48be465
patch 8.2.0767: modifyOtherKeys active when using a shell command in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
20181
diff
changeset
|
3606 } |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3607 } |
7 | 3608 out_flush(); |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3609 mch_settmode(tmode); // machine specific function |
7 | 3610 cur_tmode = tmode; |
3611 if (tmode == TMODE_RAW) | |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3612 setmouse(); // may switch mouse on |
7 | 3613 out_flush(); |
3614 } | |
3615 #ifdef FEAT_TERMRESPONSE | |
3616 may_req_termresponse(); | |
3617 #endif | |
3618 } | |
3619 } | |
3620 | |
3621 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3622 starttermcap(void) |
7 | 3623 { |
3624 if (full_screen && !termcap_active) | |
3625 { | |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3626 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3627 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3628 #endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3629 out_str(T_TI); // start termcap mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3630 out_str(T_CTI); // start "raw" mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3631 out_str(T_KS); // start "keypad transmit" mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3632 out_str(T_BE); // enable bracketed paste mode |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3633 |
24045
1b56d4c75d19
patch 8.2.2564: focus events end Insert mode if 'esckeys' is not set
Bram Moolenaar <Bram@vim.org>
parents:
23774
diff
changeset
|
3634 #if defined(UNIX) || defined(VMS) |
1b56d4c75d19
patch 8.2.2564: focus events end Insert mode if 'esckeys' is not set
Bram Moolenaar <Bram@vim.org>
parents:
23774
diff
changeset
|
3635 // Enable xterm's focus reporting mode when 'esckeys' is set. |
1b56d4c75d19
patch 8.2.2564: focus events end Insert mode if 'esckeys' is not set
Bram Moolenaar <Bram@vim.org>
parents:
23774
diff
changeset
|
3636 if (focus_mode && p_ek && *T_FE != NUL) |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3637 out_str(T_FE); |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3638 #endif |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3639 |
7 | 3640 out_flush(); |
3641 termcap_active = TRUE; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3642 screen_start(); // don't know where cursor is now |
7 | 3643 #ifdef FEAT_TERMRESPONSE |
1691 | 3644 # ifdef FEAT_GUI |
3645 if (!gui.in_use && !gui.starting) | |
3646 # endif | |
3647 { | |
3648 may_req_termresponse(); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3649 // Immediately check for a response. If t_Co changes, we don't |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3650 // want to redraw with wrong colors first. |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3651 if (crv_status.tr_progress == STATUS_SENT) |
1691 | 3652 check_for_codes_from_term(); |
3653 } | |
7 | 3654 #endif |
3655 } | |
3656 } | |
3657 | |
3658 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3659 stoptermcap(void) |
7 | 3660 { |
3661 screen_stop_highlight(); | |
3662 reset_cterm_colors(); | |
3663 if (termcap_active) | |
3664 { | |
3665 #ifdef FEAT_TERMRESPONSE | |
1691 | 3666 # ifdef FEAT_GUI |
3667 if (!gui.in_use && !gui.starting) | |
3668 # endif | |
3669 { | |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3670 // May need to discard T_CRV, T_U7 or T_RBG response. |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3671 if (termrequest_any_pending()) |
4391 | 3672 { |
3673 # ifdef UNIX | |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3674 // Give the terminal a chance to respond. |
21927
88070e222e82
patch 8.2.1513: cannot interrupt shell used for filename expansion
Bram Moolenaar <Bram@vim.org>
parents:
21624
diff
changeset
|
3675 mch_delay(100L, 0); |
4391 | 3676 # endif |
3677 # ifdef TCIFLUSH | |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3678 // Discard data received but not read. |
4391 | 3679 if (exiting) |
3680 tcflush(fileno(stdin), TCIFLUSH); | |
3681 # endif | |
3682 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3683 // Check for termcodes first, otherwise an external program may |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3684 // get them. |
1691 | 3685 check_for_codes_from_term(); |
3686 } | |
7 | 3687 #endif |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3688 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3689 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3690 #endif |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3691 |
24045
1b56d4c75d19
patch 8.2.2564: focus events end Insert mode if 'esckeys' is not set
Bram Moolenaar <Bram@vim.org>
parents:
23774
diff
changeset
|
3692 #if defined(UNIX) || defined(VMS) |
1b56d4c75d19
patch 8.2.2564: focus events end Insert mode if 'esckeys' is not set
Bram Moolenaar <Bram@vim.org>
parents:
23774
diff
changeset
|
3693 // Disable xterm's focus reporting mode if 'esckeys' is set. |
1b56d4c75d19
patch 8.2.2564: focus events end Insert mode if 'esckeys' is not set
Bram Moolenaar <Bram@vim.org>
parents:
23774
diff
changeset
|
3694 if (focus_mode && p_ek && *T_FD != NUL) |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3695 out_str(T_FD); |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3696 #endif |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3697 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3698 out_str(T_BD); // disable bracketed paste mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3699 out_str(T_KE); // stop "keypad transmit" mode |
7 | 3700 out_flush(); |
3701 termcap_active = FALSE; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3702 cursor_on(); // just in case it is still off |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3703 out_str(T_CTE); // stop "raw" mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3704 out_str(T_TE); // stop termcap mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3705 screen_start(); // don't know where cursor is now |
7 | 3706 out_flush(); |
3707 } | |
3708 } | |
3709 | |
5932 | 3710 #if defined(FEAT_TERMRESPONSE) || defined(PROTO) |
7 | 3711 /* |
3712 * Request version string (for xterm) when needed. | |
3713 * Only do this after switching to raw mode, otherwise the result will be | |
3714 * echoed. | |
626 | 3715 * Only do this after startup has finished, to avoid that the response comes |
1221 | 3716 * while executing "-c !cmd" or even after "-c quit". |
7 | 3717 * Only do this after termcap mode has been started, otherwise the codes for |
3718 * the cursor keys may be wrong. | |
620 | 3719 * Only do this when 'esckeys' is on, otherwise the response causes trouble in |
3720 * Insert mode. | |
164 | 3721 * On Unix only do it when both output and input are a tty (avoid writing |
3722 * request to terminal while reading from a file). | |
7 | 3723 * The result is caught in check_termcode(). |
3724 */ | |
626 | 3725 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3726 may_req_termresponse(void) |
7 | 3727 { |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3728 if (crv_status.tr_progress == STATUS_GET |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
3729 && can_get_termresponse() |
626 | 3730 && starting == 0 |
7 | 3731 && *T_CRV != NUL) |
3732 { | |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3733 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3734 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3735 #endif |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3736 LOG_TR(("Sending CRV request")); |
7 | 3737 out_str(T_CRV); |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3738 termrequest_sent(&crv_status); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3739 // check for the characters now, otherwise they might be eaten by |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3740 // get_keystroke() |
7 | 3741 out_flush(); |
3742 (void)vpeekc_nomap(); | |
3743 } | |
3744 } | |
4215 | 3745 |
3746 /* | |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3747 * Send sequences to the terminal and check with t_u7 how the cursor moves, to |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3748 * find out properties of the terminal. |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
3749 * Note that this goes out before T_CRV, so that the result can be used when |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
3750 * the termresponse arrives. |
4215 | 3751 */ |
3752 void | |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3753 check_terminal_behavior(void) |
4215 | 3754 { |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3755 int did_send = FALSE; |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3756 |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3757 if (!can_get_termresponse() || starting != 0 || *T_U7 == NUL) |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3758 return; |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3759 |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3760 if (u7_status.tr_progress == STATUS_GET |
4215 | 3761 && !option_was_set((char_u *)"ambiwidth")) |
3762 { | |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3763 char_u buf[16]; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3764 |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3765 // Ambiguous width check. |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3766 // Check how the terminal treats ambiguous character width (UAX #11). |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3767 // First, we move the cursor to (1, 0) and print a test ambiguous |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3768 // character \u25bd (WHITE DOWN-POINTING TRIANGLE) and then query |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3769 // the current cursor position. If the terminal treats \u25bd as |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3770 // single width, the position is (1, 1), or if it is treated as double |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3771 // width, that will be (1, 2). This function has the side effect that |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3772 // changes cursor position, so it must be called immediately after |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3773 // entering termcap mode. |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3774 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3775 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3776 #endif |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3777 LOG_TR(("Sending request for ambiwidth check")); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3778 // Do this in the second row. In the first row the returned sequence |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3779 // may be CSI 1;2R, which is the same as <S-F3>. |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3780 term_windgoto(1, 0); |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3781 buf[mb_char2bytes(0x25bd, buf)] = NUL; |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3782 out_str(buf); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3783 out_str(T_U7); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3784 termrequest_sent(&u7_status); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3785 out_flush(); |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3786 did_send = TRUE; |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3787 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3788 // This overwrites a few characters on the screen, a redraw is needed |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3789 // after this. Clear them out for now. |
17482
6cf077f59152
patch 8.1.1739: deleted match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents:
17330
diff
changeset
|
3790 screen_stop_highlight(); |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3791 term_windgoto(1, 0); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3792 out_str((char_u *)" "); |
21226
421c4ed6b949
patch 8.2.1164: text cleared by checking terminal properties not redrawn
Bram Moolenaar <Bram@vim.org>
parents:
20935
diff
changeset
|
3793 line_was_clobbered(1); |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3794 } |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3795 |
27004
671664c5faa4
patch 8.2.4031: crash in xterm with only two lines
Bram Moolenaar <Bram@vim.org>
parents:
26917
diff
changeset
|
3796 if (xcc_status.tr_progress == STATUS_GET && Rows > 2) |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3797 { |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3798 // 2. Check compatibility with xterm. |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3799 // We move the cursor to (2, 0), print a test sequence and then query |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3800 // the current cursor position. If the terminal properly handles |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3801 // unknown DCS string and CSI sequence with intermediate byte, the test |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3802 // sequence is ignored and the cursor does not move. If the terminal |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3803 // handles test sequence incorrectly, a garbage string is displayed and |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3804 // the cursor does move. |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3805 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3806 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3807 #endif |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3808 LOG_TR(("Sending xterm compatibility test sequence.")); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3809 // Do this in the third row. Second row is used by ambiguous |
23229
b545334ae654
patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents:
22956
diff
changeset
|
3810 // character width check. |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3811 term_windgoto(2, 0); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3812 // send the test DCS string. |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3813 out_str((char_u *)"\033Pzz\033\\"); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3814 // send the test CSI sequence with intermediate byte. |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3815 out_str((char_u *)"\033[0%m"); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3816 out_str(T_U7); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3817 termrequest_sent(&xcc_status); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3818 out_flush(); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3819 did_send = TRUE; |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3820 |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3821 // If the terminal handles test sequence incorrectly, garbage text is |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3822 // displayed. Clear them out for now. |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3823 screen_stop_highlight(); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3824 term_windgoto(2, 0); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3825 out_str((char_u *)" "); |
21226
421c4ed6b949
patch 8.2.1164: text cleared by checking terminal properties not redrawn
Bram Moolenaar <Bram@vim.org>
parents:
20935
diff
changeset
|
3826 line_was_clobbered(2); |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3827 } |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3828 |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3829 if (did_send) |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3830 { |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3831 term_windgoto(0, 0); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3832 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3833 // Need to reset the known cursor position. |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3834 screen_start(); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3835 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3836 // check for the characters now, otherwise they might be eaten by |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3837 // get_keystroke() |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3838 out_flush(); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3839 (void)vpeekc_nomap(); |
4215 | 3840 } |
3841 } | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3842 |
6874 | 3843 /* |
6885 | 3844 * Similar to requesting the version string: Request the terminal background |
3845 * color when it is the right moment. | |
6874 | 3846 */ |
3847 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3848 may_req_bg_color(void) |
6874 | 3849 { |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3850 if (can_get_termresponse() && starting == 0) |
6874 | 3851 { |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3852 int didit = FALSE; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3853 |
12640
a715f0b44532
patch 8.0.1198: older compilers don't know uint8_t
Christian Brabandt <cb@256bit.org>
parents:
12634
diff
changeset
|
3854 # ifdef FEAT_TERMINAL |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3855 // Only request foreground if t_RF is set. |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3856 if (rfg_status.tr_progress == STATUS_GET && *T_RFG != NUL) |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3857 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3858 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3859 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3860 #endif |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3861 LOG_TR(("Sending FG request")); |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3862 out_str(T_RFG); |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3863 termrequest_sent(&rfg_status); |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3864 didit = TRUE; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3865 } |
12640
a715f0b44532
patch 8.0.1198: older compilers don't know uint8_t
Christian Brabandt <cb@256bit.org>
parents:
12634
diff
changeset
|
3866 # endif |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3867 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3868 // Only request background if t_RB is set. |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3869 if (rbg_status.tr_progress == STATUS_GET && *T_RBG != NUL) |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3870 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3871 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3872 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3873 #endif |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3874 LOG_TR(("Sending BG request")); |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3875 out_str(T_RBG); |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3876 termrequest_sent(&rbg_status); |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3877 didit = TRUE; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3878 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3879 |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3880 if (didit) |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3881 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3882 // check for the characters now, otherwise they might be eaten by |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3883 // get_keystroke() |
12232
1553d1a4bf7c
patch 8.0.0996: Mac: t_RS is echoed on the screne in Terminal.app
Christian Brabandt <cb@256bit.org>
parents:
12226
diff
changeset
|
3884 out_flush(); |
1553d1a4bf7c
patch 8.0.0996: Mac: t_RS is echoed on the screne in Terminal.app
Christian Brabandt <cb@256bit.org>
parents:
12226
diff
changeset
|
3885 (void)vpeekc_nomap(); |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3886 } |
6874 | 3887 } |
3888 } | |
3889 | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3890 # ifdef DEBUG_TERMRESPONSE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3891 static void |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3892 log_tr(const char *fmt, ...) |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3893 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3894 static FILE *fd_tr = NULL; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3895 static proftime_T start; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3896 proftime_T now; |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3897 va_list ap; |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3898 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3899 if (fd_tr == NULL) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3900 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3901 fd_tr = fopen("termresponse.log", "w"); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3902 profile_start(&start); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3903 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3904 now = start; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3905 profile_end(&now); |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3906 fprintf(fd_tr, "%s: %s ", profile_msg(&now), |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3907 must_redraw == NOT_VALID ? "NV" |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3908 : must_redraw == CLEAR ? "CL" : " "); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3909 va_start(ap, fmt); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3910 vfprintf(fd_tr, fmt, ap); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3911 va_end(ap); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3912 fputc('\n', fd_tr); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3913 fflush(fd_tr); |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3914 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3915 # endif |
7 | 3916 #endif |
3917 | |
3918 /* | |
3919 * Return TRUE when saving and restoring the screen. | |
3920 */ | |
3921 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3922 swapping_screen(void) |
7 | 3923 { |
3924 return (full_screen && *T_TI != NUL); | |
3925 } | |
3926 | |
3927 /* | |
3928 * By outputting the 'cursor very visible' termcap code, for some windowed | |
3929 * terminals this makes the screen scrolled to the correct position. | |
3930 * Used when starting Vim or returning from a shell. | |
3931 */ | |
3932 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3933 scroll_start(void) |
7 | 3934 { |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3935 if (*T_VS != NUL && *T_CVS != NUL) |
7 | 3936 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3937 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3938 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3939 #endif |
7 | 3940 out_str(T_VS); |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3941 out_str(T_CVS); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3942 screen_start(); // don't know where cursor is now |
7 | 3943 } |
3944 } | |
3945 | |
24428
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
3946 // True if cursor is not visible |
7 | 3947 static int cursor_is_off = FALSE; |
3948 | |
24428
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
3949 // True if cursor is not visible due to an ongoing cursor-less sleep |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
3950 static int cursor_is_asleep = FALSE; |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
3951 |
7 | 3952 /* |
14581
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3953 * Enable the cursor without checking if it's already enabled. |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3954 */ |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3955 void |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3956 cursor_on_force(void) |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3957 { |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3958 out_str(T_VE); |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3959 cursor_is_off = FALSE; |
24428
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
3960 cursor_is_asleep = FALSE; |
14581
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3961 } |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3962 |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3963 /* |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3964 * Enable the cursor if it's currently off. |
7 | 3965 */ |
3966 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3967 cursor_on(void) |
7 | 3968 { |
24428
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
3969 if (cursor_is_off && !cursor_is_asleep) |
14581
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3970 cursor_on_force(); |
7 | 3971 } |
3972 | |
3973 /* | |
3974 * Disable the cursor. | |
3975 */ | |
3976 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3977 cursor_off(void) |
7 | 3978 { |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3979 if (full_screen && !cursor_is_off) |
7 | 3980 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3981 out_str(T_VI); // disable cursor |
7 | 3982 cursor_is_off = TRUE; |
3983 } | |
3984 } | |
3985 | |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
27004
diff
changeset
|
3986 #ifdef FEAT_GUI |
24428
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
3987 /* |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
3988 * Check whether the cursor is invisible due to an ongoing cursor-less sleep |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
3989 */ |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
3990 int |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
3991 cursor_is_sleeping(void) |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
3992 { |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
3993 return cursor_is_asleep; |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
3994 } |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
27004
diff
changeset
|
3995 #endif |
24428
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
3996 |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
3997 /* |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
3998 * Disable the cursor and mark it disabled by cursor-less sleep |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
3999 */ |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4000 void |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4001 cursor_sleep(void) |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4002 { |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4003 cursor_is_asleep = TRUE; |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4004 cursor_off(); |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4005 } |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4006 |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4007 /* |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4008 * Enable the cursor and mark it not disabled by cursor-less sleep |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4009 */ |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4010 void |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4011 cursor_unsleep(void) |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4012 { |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4013 cursor_is_asleep = FALSE; |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4014 cursor_on(); |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4015 } |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24228
diff
changeset
|
4016 |
39 | 4017 #if defined(CURSOR_SHAPE) || defined(PROTO) |
7 | 4018 /* |
6727 | 4019 * Set cursor shape to match Insert or Replace mode. |
36 | 4020 */ |
4021 void | |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4022 term_cursor_mode(int forced) |
36 | 4023 { |
12078
d21b8f31b296
patch 8.0.0919: cursor color isn't set on startup
Christian Brabandt <cb@256bit.org>
parents:
12076
diff
changeset
|
4024 static int showing_mode = -1; |
6727 | 4025 char_u *p; |
4026 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4027 // Only do something when redrawing the screen and we can restore the |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4028 // mode. |
6727 | 4029 if (!full_screen || *T_CEI == NUL) |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4030 { |
12184
76fbd85c3cea
patch 8.0.0972: compiler warnings for unused variables
Christian Brabandt <cb@256bit.org>
parents:
12174
diff
changeset
|
4031 # ifdef FEAT_TERMRESPONSE |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4032 if (forced && initial_cursor_shape > 0) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4033 // Restore to initial values. |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4034 term_cursor_shape(initial_cursor_shape, initial_cursor_blink); |
12184
76fbd85c3cea
patch 8.0.0972: compiler warnings for unused variables
Christian Brabandt <cb@256bit.org>
parents:
12174
diff
changeset
|
4035 # endif |
36 | 4036 return; |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4037 } |
36 | 4038 |
6727 | 4039 if ((State & REPLACE) == REPLACE) |
36 | 4040 { |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4041 if (forced || showing_mode != REPLACE) |
6727 | 4042 { |
4043 if (*T_CSR != NUL) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4044 p = T_CSR; // Replace mode cursor |
6727 | 4045 else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4046 p = T_CSI; // fall back to Insert mode cursor |
6727 | 4047 if (*p != NUL) |
4048 { | |
4049 out_str(p); | |
4050 showing_mode = REPLACE; | |
4051 } | |
4052 } | |
36 | 4053 } |
6727 | 4054 else if (State & INSERT) |
36 | 4055 { |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4056 if ((forced || showing_mode != INSERT) && *T_CSI != NUL) |
6727 | 4057 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4058 out_str(T_CSI); // Insert mode cursor |
6727 | 4059 showing_mode = INSERT; |
4060 } | |
4061 } | |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4062 else if (forced || showing_mode != NORMAL) |
6727 | 4063 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4064 out_str(T_CEI); // non-Insert mode cursor |
6727 | 4065 showing_mode = NORMAL; |
36 | 4066 } |
4067 } | |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4068 |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4069 # if defined(FEAT_TERMINAL) || defined(PROTO) |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4070 void |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4071 term_cursor_color(char_u *color) |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4072 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4073 if (*T_CSC != NUL) |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4074 { |
18430
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
4075 out_str(T_CSC); // set cursor color start |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4076 out_str_nf(color); |
18430
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
4077 out_str(T_CEC); // set cursor color end |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4078 out_flush(); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4079 } |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4080 } |
12172
444793fce117
patch 8.0.0966: build failure without terminal feature
Christian Brabandt <cb@256bit.org>
parents:
12170
diff
changeset
|
4081 # endif |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4082 |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4083 int |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4084 blink_state_is_inverted() |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4085 { |
12261
875d7cc9b127
patch 8.0.1010: build failure without termresponse feature
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
4086 #ifdef FEAT_TERMRESPONSE |
16936
73e6ed2f69a2
patch 8.1.1469: no test for checking the cursor style response
Bram Moolenaar <Bram@vim.org>
parents:
16926
diff
changeset
|
4087 return rbm_status.tr_progress == STATUS_GOT |
73e6ed2f69a2
patch 8.1.1469: no test for checking the cursor style response
Bram Moolenaar <Bram@vim.org>
parents:
16926
diff
changeset
|
4088 && rcs_status.tr_progress == STATUS_GOT |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4089 && initial_cursor_blink != initial_cursor_shape_blink; |
12261
875d7cc9b127
patch 8.0.1010: build failure without termresponse feature
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
4090 #else |
875d7cc9b127
patch 8.0.1010: build failure without termresponse feature
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
4091 return FALSE; |
875d7cc9b127
patch 8.0.1010: build failure without termresponse feature
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
4092 #endif |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4093 } |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4094 |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4095 /* |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
4096 * "shape": 1 = block, 2 = underline, 3 = vertical bar |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4097 */ |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4098 void |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4099 term_cursor_shape(int shape, int blink) |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4100 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4101 if (*T_CSH != NUL) |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4102 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4103 OUT_STR(tgoto((char *)T_CSH, 0, shape * 2 - blink)); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4104 out_flush(); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4105 } |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4106 else |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
4107 { |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4108 int do_blink = blink; |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4109 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4110 // t_SH is empty: try setting just the blink state. |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4111 // The blink flags are XORed together, if the initial blinking from |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4112 // style and shape differs, we need to invert the flag here. |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4113 if (blink_state_is_inverted()) |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4114 do_blink = !blink; |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4115 |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4116 if (do_blink && *T_VS != NUL) |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4117 { |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4118 out_str(T_VS); |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4119 out_flush(); |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4120 } |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4121 else if (!do_blink && *T_CVS != NUL) |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4122 { |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4123 out_str(T_CVS); |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4124 out_flush(); |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4125 } |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
4126 } |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4127 } |
39 | 4128 #endif |
36 | 4129 |
4130 /* | |
7 | 4131 * Set scrolling region for window 'wp'. |
4132 * The region starts 'off' lines from the start of the window. | |
4133 * Also set the vertical scroll region for a vertically split window. Always | |
4134 * the full width of the window, excluding the vertical separator. | |
4135 */ | |
4136 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4137 scroll_region_set(win_T *wp, int off) |
7 | 4138 { |
4139 OUT_STR(tgoto((char *)T_CS, W_WINROW(wp) + wp->w_height - 1, | |
4140 W_WINROW(wp) + off)); | |
4141 if (*T_CSV != NUL && wp->w_width != Columns) | |
12513
3ca08bf99396
patch 8.0.1135: W_WINCOL() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12497
diff
changeset
|
4142 OUT_STR(tgoto((char *)T_CSV, wp->w_wincol + wp->w_width - 1, |
3ca08bf99396
patch 8.0.1135: W_WINCOL() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12497
diff
changeset
|
4143 wp->w_wincol)); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4144 screen_start(); // don't know where cursor is now |
7 | 4145 } |
4146 | |
4147 /* | |
4148 * Reset scrolling region to the whole screen. | |
4149 */ | |
4150 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4151 scroll_region_reset(void) |
7 | 4152 { |
4153 OUT_STR(tgoto((char *)T_CS, (int)Rows - 1, 0)); | |
4154 if (*T_CSV != NUL) | |
4155 OUT_STR(tgoto((char *)T_CSV, (int)Columns - 1, 0)); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4156 screen_start(); // don't know where cursor is now |
7 | 4157 } |
4158 | |
4159 | |
4160 /* | |
4161 * List of terminal codes that are currently recognized. | |
4162 */ | |
4163 | |
298 | 4164 static struct termcode |
7 | 4165 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4166 char_u name[2]; // termcap name of entry |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4167 char_u *code; // terminal code (in allocated memory) |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4168 int len; // STRLEN(code) |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4169 int modlen; // length of part before ";*~". |
7 | 4170 } *termcodes = NULL; |
4171 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4172 static int tc_max_len = 0; // number of entries that termcodes[] can hold |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4173 static int tc_len = 0; // current number of entries in termcodes[] |
7 | 4174 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
4175 static int termcode_star(char_u *code, int len); |
180 | 4176 |
7 | 4177 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4178 clear_termcodes(void) |
7 | 4179 { |
4180 while (tc_len > 0) | |
4181 vim_free(termcodes[--tc_len].code); | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
4182 VIM_CLEAR(termcodes); |
7 | 4183 tc_max_len = 0; |
4184 | |
4185 #ifdef HAVE_TGETENT | |
4186 BC = (char *)empty_option; | |
4187 UP = (char *)empty_option; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4188 PC = NUL; // set pad character to NUL |
7 | 4189 ospeed = 0; |
4190 #endif | |
4191 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4192 need_gather = TRUE; // need to fill termleader[] |
7 | 4193 } |
4194 | |
180 | 4195 #define ATC_FROM_TERM 55 |
4196 | |
7 | 4197 /* |
4198 * Add a new entry to the list of terminal codes. | |
4199 * The list is kept alphabetical for ":set termcap" | |
180 | 4200 * "flags" is TRUE when replacing 7-bit by 8-bit controls is desired. |
4201 * "flags" can also be ATC_FROM_TERM for got_code_from_term(). | |
7 | 4202 */ |
4203 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4204 add_termcode(char_u *name, char_u *string, int flags) |
7 | 4205 { |
4206 struct termcode *new_tc; | |
4207 int i, j; | |
4208 char_u *s; | |
179 | 4209 int len; |
7 | 4210 |
4211 if (string == NULL || *string == NUL) | |
4212 { | |
4213 del_termcode(name); | |
4214 return; | |
4215 } | |
4216 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15852
diff
changeset
|
4217 #if defined(MSWIN) && !defined(FEAT_GUI) |
20830
9064044fd4f6
patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents:
20778
diff
changeset
|
4218 s = vim_strnsave(string, STRLEN(string) + 1); |
6047 | 4219 #else |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4220 # ifdef VIMDLL |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4221 if (!gui.in_use) |
20830
9064044fd4f6
patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents:
20778
diff
changeset
|
4222 s = vim_strnsave(string, STRLEN(string) + 1); |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4223 else |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4224 # endif |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4225 s = vim_strsave(string); |
6047 | 4226 #endif |
7 | 4227 if (s == NULL) |
4228 return; | |
4229 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4230 // Change leading <Esc>[ to CSI, change <Esc>O to <M-O>. |
180 | 4231 if (flags != 0 && flags != ATC_FROM_TERM && term_7to8bit(string) != 0) |
7 | 4232 { |
1623 | 4233 STRMOVE(s, s + 1); |
7 | 4234 s[0] = term_7to8bit(string); |
4235 } | |
6047 | 4236 |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4237 #if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL)) |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4238 # ifdef VIMDLL |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4239 if (!gui.in_use) |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4240 # endif |
6047 | 4241 { |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4242 if (s[0] == K_NUL) |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4243 { |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4244 STRMOVE(s + 1, s); |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4245 s[1] = 3; |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4246 } |
6047 | 4247 } |
4248 #endif | |
4249 | |
179 | 4250 len = (int)STRLEN(s); |
7 | 4251 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4252 need_gather = TRUE; // need to fill termleader[] |
7 | 4253 |
4254 /* | |
4255 * need to make space for more entries | |
4256 */ | |
4257 if (tc_len == tc_max_len) | |
4258 { | |
4259 tc_max_len += 20; | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
4260 new_tc = ALLOC_MULT(struct termcode, tc_max_len); |
7 | 4261 if (new_tc == NULL) |
4262 { | |
4263 tc_max_len -= 20; | |
24737
e97a14604f65
patch 8.2.2907: memory leak when running out of memory
Bram Moolenaar <Bram@vim.org>
parents:
24428
diff
changeset
|
4264 vim_free(s); |
7 | 4265 return; |
4266 } | |
4267 for (i = 0; i < tc_len; ++i) | |
4268 new_tc[i] = termcodes[i]; | |
4269 vim_free(termcodes); | |
4270 termcodes = new_tc; | |
4271 } | |
4272 | |
4273 /* | |
4274 * Look for existing entry with the same name, it is replaced. | |
4275 * Look for an existing entry that is alphabetical higher, the new entry | |
4276 * is inserted in front of it. | |
4277 */ | |
4278 for (i = 0; i < tc_len; ++i) | |
4279 { | |
4280 if (termcodes[i].name[0] < name[0]) | |
4281 continue; | |
4282 if (termcodes[i].name[0] == name[0]) | |
4283 { | |
4284 if (termcodes[i].name[1] < name[1]) | |
4285 continue; | |
4286 /* | |
180 | 4287 * Exact match: May replace old code. |
7 | 4288 */ |
4289 if (termcodes[i].name[1] == name[1]) | |
4290 { | |
180 | 4291 if (flags == ATC_FROM_TERM && (j = termcode_star( |
4292 termcodes[i].code, termcodes[i].len)) > 0) | |
179 | 4293 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4294 // Don't replace ESC[123;*X or ESC O*X with another when |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4295 // invoked from got_code_from_term(). |
180 | 4296 if (len == termcodes[i].len - j |
179 | 4297 && STRNCMP(s, termcodes[i].code, len - 1) == 0 |
180 | 4298 && s[len - 1] |
4299 == termcodes[i].code[termcodes[i].len - 1]) | |
179 | 4300 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4301 // They are equal but for the ";*": don't add it. |
179 | 4302 vim_free(s); |
4303 return; | |
4304 } | |
4305 } | |
4306 else | |
4307 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4308 // Replace old code. |
179 | 4309 vim_free(termcodes[i].code); |
4310 --tc_len; | |
4311 break; | |
4312 } | |
7 | 4313 } |
4314 } | |
4315 /* | |
4316 * Found alphabetical larger entry, move rest to insert new entry | |
4317 */ | |
4318 for (j = tc_len; j > i; --j) | |
4319 termcodes[j] = termcodes[j - 1]; | |
4320 break; | |
4321 } | |
4322 | |
4323 termcodes[i].name[0] = name[0]; | |
4324 termcodes[i].name[1] = name[1]; | |
4325 termcodes[i].code = s; | |
179 | 4326 termcodes[i].len = len; |
180 | 4327 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4328 // For xterm we recognize special codes like "ESC[42;*X" and "ESC O*X" that |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4329 // accept modifiers. |
180 | 4330 termcodes[i].modlen = 0; |
4331 j = termcode_star(s, len); | |
4332 if (j > 0) | |
23406
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
4333 { |
180 | 4334 termcodes[i].modlen = len - 1 - j; |
23406
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
4335 // For "CSI[@;X" the "@" is not included in "modlen". |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
4336 if (termcodes[i].code[termcodes[i].modlen - 1] == '@') |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
4337 --termcodes[i].modlen; |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
4338 } |
7 | 4339 ++tc_len; |
4340 } | |
4341 | |
180 | 4342 /* |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
4343 * Check termcode "code[len]" for ending in ;*X or *X. |
180 | 4344 * 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
|
4345 * Return 0 if not found, 2 for ;*X and 1 for *X. |
180 | 4346 */ |
4347 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4348 termcode_star(char_u *code, int len) |
180 | 4349 { |
23406
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
4350 // Shortest is <M-O>*X. With ; shortest is <CSI>@;*X |
180 | 4351 if (len >= 3 && code[len - 2] == '*') |
4352 { | |
4353 if (len >= 5 && code[len - 3] == ';') | |
4354 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
|
4355 else |
180 | 4356 return 1; |
4357 } | |
4358 return 0; | |
4359 } | |
4360 | |
7 | 4361 char_u * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4362 find_termcode(char_u *name) |
7 | 4363 { |
4364 int i; | |
4365 | |
4366 for (i = 0; i < tc_len; ++i) | |
4367 if (termcodes[i].name[0] == name[0] && termcodes[i].name[1] == name[1]) | |
4368 return termcodes[i].code; | |
4369 return NULL; | |
4370 } | |
4371 | |
4372 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4373 get_termcode(int i) |
7 | 4374 { |
4375 if (i >= tc_len) | |
4376 return NULL; | |
4377 return &termcodes[i].name[0]; | |
4378 } | |
4379 | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4380 /* |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4381 * Returns the length of the terminal code at index 'idx'. |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4382 */ |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4383 int |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4384 get_termcode_len(int idx) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4385 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4386 return termcodes[idx].len; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4387 } |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4388 |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4389 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4390 del_termcode(char_u *name) |
7 | 4391 { |
4392 int i; | |
4393 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4394 if (termcodes == NULL) // nothing there yet |
7 | 4395 return; |
4396 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4397 need_gather = TRUE; // need to fill termleader[] |
7 | 4398 |
4399 for (i = 0; i < tc_len; ++i) | |
4400 if (termcodes[i].name[0] == name[0] && termcodes[i].name[1] == name[1]) | |
4401 { | |
4402 del_termcode_idx(i); | |
4403 return; | |
4404 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4405 // not found. Give error message? |
7 | 4406 } |
4407 | |
4408 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4409 del_termcode_idx(int idx) |
7 | 4410 { |
4411 int i; | |
4412 | |
4413 vim_free(termcodes[idx].code); | |
4414 --tc_len; | |
4415 for (i = idx; i < tc_len; ++i) | |
4416 termcodes[i] = termcodes[i + 1]; | |
4417 } | |
4418 | |
4419 #ifdef FEAT_TERMRESPONSE | |
4420 /* | |
4421 * Called when detected that the terminal sends 8-bit codes. | |
4422 * Convert all 7-bit codes to their 8-bit equivalent. | |
4423 */ | |
4424 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4425 switch_to_8bit(void) |
7 | 4426 { |
4427 int i; | |
4428 int c; | |
4429 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4430 // Only need to do something when not already using 8-bit codes. |
7 | 4431 if (!term_is_8bit(T_NAME)) |
4432 { | |
4433 for (i = 0; i < tc_len; ++i) | |
4434 { | |
4435 c = term_7to8bit(termcodes[i].code); | |
4436 if (c != 0) | |
4437 { | |
1623 | 4438 STRMOVE(termcodes[i].code + 1, termcodes[i].code + 2); |
7 | 4439 termcodes[i].code[0] = c; |
4440 } | |
4441 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4442 need_gather = TRUE; // need to fill termleader[] |
7 | 4443 } |
4444 detected_8bit = TRUE; | |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
4445 LOG_TR(("Switching to 8 bit")); |
7 | 4446 } |
4447 #endif | |
4448 | |
4449 #ifdef CHECK_DOUBLE_CLICK | |
4450 static linenr_T orig_topline = 0; | |
4451 # ifdef FEAT_DIFF | |
4452 static int orig_topfill = 0; | |
4453 # endif | |
4454 #endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12429
diff
changeset
|
4455 #if defined(CHECK_DOUBLE_CLICK) || defined(PROTO) |
7 | 4456 /* |
26771
fc859aea8cec
patch 8.2.3914: various spelling mistakes in comments
Bram Moolenaar <Bram@vim.org>
parents:
26670
diff
changeset
|
4457 * Checking for double-clicks ourselves. |
7 | 4458 * "orig_topline" is used to avoid detecting a double-click when the window |
4459 * contents scrolled (e.g., when 'scrolloff' is non-zero). | |
4460 */ | |
4461 /* | |
4462 * Set orig_topline. Used when jumping to another window, so that a double | |
4463 * click still works. | |
4464 */ | |
4465 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4466 set_mouse_topline(win_T *wp) |
7 | 4467 { |
4468 orig_topline = wp->w_topline; | |
4469 # ifdef FEAT_DIFF | |
4470 orig_topfill = wp->w_topfill; | |
4471 # endif | |
4472 } | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4473 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4474 /* |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4475 * Returns TRUE if the top line and top fill of window 'wp' matches the saved |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4476 * topline and topfill. |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4477 */ |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4478 int |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4479 is_mouse_topline(win_T *wp) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4480 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4481 return orig_topline == wp->w_topline |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4482 #ifdef FEAT_DIFF |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4483 && orig_topfill == wp->w_topfill |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4484 #endif |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4485 ; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4486 } |
7 | 4487 #endif |
4488 | |
4489 /* | |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4490 * Put "string[new_slen]" in typebuf, or in "buf[bufsize]" if "buf" is not NULL. |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4491 * Remove "slen" bytes. |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4492 * Returns FAIL for error. |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4493 */ |
20727
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20705
diff
changeset
|
4494 int |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4495 put_string_in_typebuf( |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4496 int offset, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4497 int slen, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4498 char_u *string, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4499 int new_slen, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4500 char_u *buf, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4501 int bufsize, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4502 int *buflen) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4503 { |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4504 int extra = new_slen - slen; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4505 |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4506 string[new_slen] = NUL; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4507 if (buf == NULL) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4508 { |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4509 if (extra < 0) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4510 // remove matched chars, taking care of noremap |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4511 del_typebuf(-extra, offset); |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4512 else if (extra > 0) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4513 // insert the extra space we need |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4514 ins_typebuf(string + slen, REMAP_YES, offset, FALSE, FALSE); |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4515 |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4516 // Careful: del_typebuf() and ins_typebuf() may have reallocated |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4517 // typebuf.tb_buf[]! |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4518 mch_memmove(typebuf.tb_buf + typebuf.tb_off + offset, string, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4519 (size_t)new_slen); |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4520 } |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4521 else |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4522 { |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4523 if (extra < 0) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4524 // remove matched characters |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4525 mch_memmove(buf + offset, buf + offset - extra, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4526 (size_t)(*buflen + offset + extra)); |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4527 else if (extra > 0) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4528 { |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4529 // Insert the extra space we need. If there is insufficient |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4530 // space return -1. |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4531 if (*buflen + extra + new_slen >= bufsize) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4532 return FAIL; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4533 mch_memmove(buf + offset + extra, buf + offset, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4534 (size_t)(*buflen - offset)); |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4535 } |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4536 mch_memmove(buf + offset, string, (size_t)new_slen); |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4537 *buflen = *buflen + extra + new_slen; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4538 } |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4539 return OK; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4540 } |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4541 |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4542 /* |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4543 * Decode a modifier number as xterm provides it into MOD_MASK bits. |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4544 */ |
18717
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4545 int |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4546 decode_modifiers(int n) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4547 { |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4548 int code = n - 1; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4549 int modifiers = 0; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4550 |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4551 if (code & 1) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4552 modifiers |= MOD_MASK_SHIFT; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4553 if (code & 2) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4554 modifiers |= MOD_MASK_ALT; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4555 if (code & 4) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4556 modifiers |= MOD_MASK_CTRL; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4557 if (code & 8) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4558 modifiers |= MOD_MASK_META; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4559 return modifiers; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4560 } |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4561 |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4562 static int |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4563 modifiers2keycode(int modifiers, int *key, char_u *string) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4564 { |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4565 int new_slen = 0; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4566 |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4567 if (modifiers != 0) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4568 { |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4569 // Some keys have the modifier included. Need to handle that here to |
22764
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4570 // make mappings work. This may result in a special key, such as |
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4571 // K_S_TAB. |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4572 *key = simplify_key(*key, &modifiers); |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4573 if (modifiers != 0) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4574 { |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4575 string[new_slen++] = K_SPECIAL; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4576 string[new_slen++] = (int)KS_MODIFIER; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4577 string[new_slen++] = modifiers; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4578 } |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4579 } |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4580 return new_slen; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4581 } |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4582 |
20776
7728e309e013
patch 8.2.0940: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
20774
diff
changeset
|
4583 #ifdef FEAT_TERMRESPONSE |
7728e309e013
patch 8.2.0940: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
20774
diff
changeset
|
4584 /* |
7728e309e013
patch 8.2.0940: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
20774
diff
changeset
|
4585 * Handle a cursor position report. |
7728e309e013
patch 8.2.0940: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
20774
diff
changeset
|
4586 */ |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4587 static void |
20776
7728e309e013
patch 8.2.0940: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
20774
diff
changeset
|
4588 handle_u7_response(int *arg, char_u *tp UNUSED, int csi_len UNUSED) |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4589 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4590 if (arg[0] == 2 && arg[1] >= 2) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4591 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4592 char *aw = NULL; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4593 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4594 LOG_TR(("Received U7 status: %s", tp)); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4595 u7_status.tr_progress = STATUS_GOT; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4596 did_cursorhold = TRUE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4597 if (arg[1] == 2) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4598 aw = "single"; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4599 else if (arg[1] == 3) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4600 aw = "double"; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4601 if (aw != NULL && STRCMP(aw, p_ambw) != 0) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4602 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4603 // Setting the option causes a screen redraw. Do |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4604 // that right away if possible, keeping any |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4605 // messages. |
20776
7728e309e013
patch 8.2.0940: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
20774
diff
changeset
|
4606 set_option_value((char_u *)"ambw", 0L, (char_u *)aw, 0); |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4607 # ifdef DEBUG_TERMRESPONSE |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4608 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4609 int r = redraw_asap(CLEAR); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4610 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4611 log_tr("set 'ambiwidth', redraw_asap(): %d", r); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4612 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4613 # else |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4614 redraw_asap(CLEAR); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4615 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4616 # ifdef FEAT_EVAL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4617 set_vim_var_string(VV_TERMU7RESP, tp, csi_len); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4618 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4619 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4620 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4621 else if (arg[0] == 3) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4622 { |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4623 int value; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4624 |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4625 LOG_TR(("Received compatibility test result: %s", tp)); |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4626 xcc_status.tr_progress = STATUS_GOT; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4627 |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4628 // Third row: xterm compatibility test. |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4629 // If the cursor is on the first column then the terminal can handle |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4630 // the request for cursor style and blinking. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4631 value = arg[1] == 1 ? TPR_YES : TPR_NO; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4632 term_props[TPR_CURSOR_STYLE].tpr_status = value; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4633 term_props[TPR_CURSOR_BLINK].tpr_status = value; |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4634 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4635 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4636 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4637 /* |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4638 * Handle a response to T_CRV: {lead}{first}{x};{vers};{y}c |
23229
b545334ae654
patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents:
22956
diff
changeset
|
4639 * Xterm and alike use '>' for {first}. |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4640 * Rxvt sends "{lead}?1;2c". |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4641 */ |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4642 static void |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4643 handle_version_response(int first, int *arg, int argc, char_u *tp) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4644 { |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4645 // The xterm version. It is set to zero when it can't be an actual xterm |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4646 // version. |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4647 int version = arg[1]; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4648 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4649 LOG_TR(("Received CRV response: %s", tp)); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4650 crv_status.tr_progress = STATUS_GOT; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4651 did_cursorhold = TRUE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4652 |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4653 // Reset terminal properties that are set based on the termresponse. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4654 // Mainly useful for tests that send the termresponse multiple times. |
20836
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
4655 // For testing all props can be reset. |
20838
020aec2e8de9
patch 8.2.0971: build with tiny features fails
Bram Moolenaar <Bram@vim.org>
parents:
20836
diff
changeset
|
4656 init_term_props( |
020aec2e8de9
patch 8.2.0971: build with tiny features fails
Bram Moolenaar <Bram@vim.org>
parents:
20836
diff
changeset
|
4657 #ifdef FEAT_EVAL |
020aec2e8de9
patch 8.2.0971: build with tiny features fails
Bram Moolenaar <Bram@vim.org>
parents:
20836
diff
changeset
|
4658 reset_term_props_on_termresponse |
020aec2e8de9
patch 8.2.0971: build with tiny features fails
Bram Moolenaar <Bram@vim.org>
parents:
20836
diff
changeset
|
4659 #else |
020aec2e8de9
patch 8.2.0971: build with tiny features fails
Bram Moolenaar <Bram@vim.org>
parents:
20836
diff
changeset
|
4660 FALSE |
020aec2e8de9
patch 8.2.0971: build with tiny features fails
Bram Moolenaar <Bram@vim.org>
parents:
20836
diff
changeset
|
4661 #endif |
020aec2e8de9
patch 8.2.0971: build with tiny features fails
Bram Moolenaar <Bram@vim.org>
parents:
20836
diff
changeset
|
4662 ); |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4663 |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4664 // If this code starts with CSI, you can bet that the |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4665 // terminal uses 8-bit codes. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4666 if (tp[0] == CSI) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4667 switch_to_8bit(); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4668 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4669 // Screen sends 40500. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4670 // rxvt sends its version number: "20703" is 2.7.3. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4671 // Ignore it for when the user has set 'term' to xterm, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4672 // even though it's an rxvt. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4673 if (version > 20000) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4674 version = 0; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4675 |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4676 // Figure out more if the reeponse is CSI > 99 ; 99 ; 99 c |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4677 if (first == '>' && argc == 3) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4678 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4679 int need_flush = FALSE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4680 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4681 // mintty 2.9.5 sends 77;20905;0c. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4682 // (77 is ASCII 'M' for mintty.) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4683 if (arg[0] == 77) |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4684 { |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4685 // mintty can do SGR mouse reporting |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4686 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4687 } |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4688 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4689 // If xterm version >= 141 try to get termcap codes. For other |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4690 // terminals the request should be ignored. |
26670
a77b661439f9
patch 8.2.3864: cannot disable requesting key codes from xterm
Bram Moolenaar <Bram@vim.org>
parents:
26439
diff
changeset
|
4691 if (version >= 141 && p_xtermcodes) |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4692 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4693 LOG_TR(("Enable checking for XT codes")); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4694 check_for_codes = TRUE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4695 need_gather = TRUE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4696 req_codes_from_term(); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4697 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4698 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4699 // libvterm sends 0;100;0 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4700 if (version == 100 && arg[0] == 0 && arg[2] == 0) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4701 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4702 // If run from Vim $COLORS is set to the number of |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4703 // colors the terminal supports. Otherwise assume |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4704 // 256, libvterm supports even more. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4705 if (mch_getenv((char_u *)"COLORS") == NULL) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4706 may_adjust_color_count(256); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4707 // Libvterm can handle SGR mouse reporting. |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4708 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4709 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4710 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4711 if (version == 95) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4712 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4713 // Mac Terminal.app sends 1;95;0 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4714 if (arg[0] == 1 && arg[2] == 0) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4715 { |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4716 term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4717 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4718 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4719 // iTerm2 sends 0;95;0 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4720 else if (arg[0] == 0 && arg[2] == 0) |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4721 { |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4722 // iTerm2 can do SGR mouse reporting |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4723 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4724 } |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4725 // old iTerm2 sends 0;95; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4726 else if (arg[0] == 0 && arg[2] == -1) |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4727 term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES; |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4728 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4729 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4730 // screen sends 83;40500;0 83 is 'S' in ASCII. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4731 if (arg[0] == 83) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4732 { |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4733 // screen supports SGR mouse codes since 4.7.0 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4734 if (arg[1] >= 40700) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4735 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4736 else |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4737 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_XTERM; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4738 } |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4739 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4740 // If no recognized terminal has set mouse behavior, assume xterm. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4741 if (term_props[TPR_MOUSE].tpr_status == TPR_UNKNOWN) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4742 { |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4743 // Xterm version 277 supports SGR. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4744 // Xterm version >= 95 supports mouse dragging. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4745 if (version >= 277) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4746 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4747 else if (version >= 95) |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4748 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_XTERM2; |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4749 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4750 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4751 // Detect terminals that set $TERM to something like |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4752 // "xterm-256color" but are not fully xterm compatible. |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4753 // |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4754 // Gnome terminal sends 1;3801;0, 1;4402;0 or 1;2501;0. |
20850
bf7453768034
patch 8.2.0977: t_8u is made empty for the wrong terminals
Bram Moolenaar <Bram@vim.org>
parents:
20838
diff
changeset
|
4755 // Newer Gnome-terminal sends 65;6001;1. |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4756 // xfce4-terminal sends 1;2802;0. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4757 // screen sends 83;40500;0 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4758 // Assuming any version number over 2500 is not an |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4759 // xterm (without the limit for rxvt and screen). |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4760 if (arg[1] >= 2500) |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4761 term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4762 |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4763 else if (version == 136 && arg[2] == 0) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4764 { |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4765 term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4766 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4767 // PuTTY sends 0;136;0 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4768 if (arg[0] == 0) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4769 { |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4770 // supports sgr-like mouse reporting. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4771 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4772 } |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4773 // vandyke SecureCRT sends 1;136;0 |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4774 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4775 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4776 // Konsole sends 0;115;0 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4777 else if (version == 115 && arg[0] == 0 && arg[2] == 0) |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4778 term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES; |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4779 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4780 // GNU screen sends 83;30600;0, 83;40500;0, etc. |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4781 // 30600/40500 is a version number of GNU screen. DA2 support is added |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4782 // on 3.6. DCS string has a special meaning to GNU screen, but xterm |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4783 // compatibility checking does not detect GNU screen. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4784 if (arg[0] == 83 && arg[1] >= 30600) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4785 { |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4786 term_props[TPR_CURSOR_STYLE].tpr_status = TPR_NO; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4787 term_props[TPR_CURSOR_BLINK].tpr_status = TPR_NO; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4788 } |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4789 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4790 // Xterm first responded to this request at patch level |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4791 // 95, so assume anything below 95 is not xterm and hopefully supports |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4792 // the underline RGB color sequence. |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4793 if (version < 95) |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4794 term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4795 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4796 // Getting the cursor style is only supported properly by xterm since |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4797 // version 279 (otherwise it returns 0x18). |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4798 if (version < 279) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4799 term_props[TPR_CURSOR_STYLE].tpr_status = TPR_NO; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4800 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4801 /* |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4802 * Take action on the detected properties. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4803 */ |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4804 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4805 // Unless the underline RGB color is expected to work, disable "t_8u". |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4806 // It does not work for the real Xterm, it resets the background color. |
20850
bf7453768034
patch 8.2.0977: t_8u is made empty for the wrong terminals
Bram Moolenaar <Bram@vim.org>
parents:
20838
diff
changeset
|
4807 if (term_props[TPR_UNDERLINE_RGB].tpr_status != TPR_YES && *T_8U != NUL) |
20854
bd56f4045f37
patch 8.2.0979: a couple of screendump tests fail
Bram Moolenaar <Bram@vim.org>
parents:
20852
diff
changeset
|
4808 set_string_option_direct((char_u *)"t_8u", -1, (char_u *)"", |
bd56f4045f37
patch 8.2.0979: a couple of screendump tests fail
Bram Moolenaar <Bram@vim.org>
parents:
20852
diff
changeset
|
4809 OPT_FREE, 0); |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4810 |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4811 // Only set 'ttymouse' automatically if it was not set |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4812 // by the user already. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4813 if (!option_was_set((char_u *)"ttym") |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4814 && (term_props[TPR_MOUSE].tpr_status == TPR_MOUSE_XTERM2 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4815 || term_props[TPR_MOUSE].tpr_status == TPR_MOUSE_SGR)) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4816 { |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4817 set_option_value((char_u *)"ttym", 0L, |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4818 term_props[TPR_MOUSE].tpr_status == TPR_MOUSE_SGR |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4819 ? (char_u *)"sgr" : (char_u *)"xterm2", 0); |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4820 } |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4821 |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4822 // Only request the cursor style if t_SH and t_RS are |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4823 // set. Only supported properly by xterm since version |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4824 // 279 (otherwise it returns 0x18). |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4825 // Only when getting the cursor style was detected to work. |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4826 // Not for Terminal.app, it can't handle t_RS, it |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4827 // echoes the characters to the screen. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4828 if (rcs_status.tr_progress == STATUS_GET |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4829 && term_props[TPR_CURSOR_STYLE].tpr_status == TPR_YES |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4830 && *T_CSH != NUL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4831 && *T_CRS != NUL) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4832 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
4833 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
4834 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
4835 #endif |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4836 LOG_TR(("Sending cursor style request")); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4837 out_str(T_CRS); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4838 termrequest_sent(&rcs_status); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4839 need_flush = TRUE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4840 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4841 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4842 // Only request the cursor blink mode if t_RC set. Not |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4843 // for Gnome terminal, it can't handle t_RC, it |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4844 // echoes the characters to the screen. |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4845 // Only when getting the cursor style was detected to work. |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4846 if (rbm_status.tr_progress == STATUS_GET |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4847 && term_props[TPR_CURSOR_BLINK].tpr_status == TPR_YES |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4848 && *T_CRC != NUL) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4849 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
4850 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
4851 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
4852 #endif |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4853 LOG_TR(("Sending cursor blink mode request")); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4854 out_str(T_CRC); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4855 termrequest_sent(&rbm_status); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4856 need_flush = TRUE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4857 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4858 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4859 if (need_flush) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4860 out_flush(); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4861 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4862 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4863 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4864 /* |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4865 * Handle a sequence with key and modifier, one of: |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4866 * {lead}27;{modifier};{key}~ |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4867 * {lead}{key};{modifier}u |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4868 * Returns the difference in length. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4869 */ |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4870 static int |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4871 handle_key_with_modifier( |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4872 int *arg, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4873 int trail, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4874 int csi_len, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4875 int offset, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4876 char_u *buf, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4877 int bufsize, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4878 int *buflen) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4879 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4880 int key; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4881 int modifiers; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4882 int new_slen; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4883 char_u string[MAX_KEY_CODE_LEN + 1]; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4884 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4885 seenModifyOtherKeys = TRUE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4886 if (trail == 'u') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4887 key = arg[0]; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4888 else |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4889 key = arg[2]; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4890 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4891 modifiers = decode_modifiers(arg[1]); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4892 |
22522
6c7e4db139a3
patch 8.2.1809: mapping some keys with Ctrl does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
22091
diff
changeset
|
4893 // Some keys need adjustment when the Ctrl modifier is used. |
6c7e4db139a3
patch 8.2.1809: mapping some keys with Ctrl does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
22091
diff
changeset
|
4894 key = may_adjust_key_for_ctrl(modifiers, key); |
6c7e4db139a3
patch 8.2.1809: mapping some keys with Ctrl does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
22091
diff
changeset
|
4895 |
20935
d64520bfafa0
patch 8.2.1019: mapping <M-S-a> does not work in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20927
diff
changeset
|
4896 // May remove the shift modifier if it's already included in the key. |
d64520bfafa0
patch 8.2.1019: mapping <M-S-a> does not work in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20927
diff
changeset
|
4897 modifiers = may_remove_shift_modifier(modifiers, key); |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4898 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4899 // insert modifiers with KS_MODIFIER |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4900 new_slen = modifiers2keycode(modifiers, &key, string); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4901 |
22764
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4902 if (IS_SPECIAL(key)) |
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4903 { |
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4904 string[new_slen++] = K_SPECIAL; |
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4905 string[new_slen++] = KEY2TERMCAP0(key); |
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4906 string[new_slen++] = KEY2TERMCAP1(key); |
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4907 } |
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4908 else if (has_mbyte) |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4909 new_slen += (*mb_char2bytes)(key, string + new_slen); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4910 else |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4911 string[new_slen++] = key; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4912 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4913 if (put_string_in_typebuf(offset, csi_len, string, new_slen, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4914 buf, bufsize, buflen) == FAIL) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4915 return -1; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4916 return new_slen - csi_len + offset; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4917 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4918 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4919 /* |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4920 * Handle a CSI escape sequence. |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4921 * - Xterm version string. |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4922 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4923 * - Cursor position report: {lead}{row};{col}R |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4924 * The final byte must be 'R'. It is used for checking the |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4925 * ambiguous-width character state. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4926 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4927 * - window position reply: {lead}3;{x};{y}t |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4928 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4929 * - key with modifiers when modifyOtherKeys is enabled: |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4930 * {lead}27;{modifier};{key}~ |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4931 * {lead}{key};{modifier}u |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4932 * Return 0 for no match, -1 for partial match, > 0 for full match. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4933 */ |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4934 static int |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4935 handle_csi( |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4936 char_u *tp, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4937 int len, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4938 char_u *argp, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4939 int offset, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4940 char_u *buf, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4941 int bufsize, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4942 int *buflen, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4943 char_u *key_name, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4944 int *slen) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4945 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4946 int first = -1; // optional char right after {lead} |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4947 int trail; // char that ends CSI sequence |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4948 int arg[3] = {-1, -1, -1}; // argument numbers |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4949 int argc; // number of arguments |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4950 char_u *ap = argp; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4951 int csi_len; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4952 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4953 // Check for non-digit after CSI. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4954 if (!VIM_ISDIGIT(*ap)) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4955 first = *ap++; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4956 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4957 // Find up to three argument numbers. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4958 for (argc = 0; argc < 3; ) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4959 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4960 if (ap >= tp + len) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4961 return -1; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4962 if (*ap == ';') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4963 arg[argc++] = -1; // omitted number |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4964 else if (VIM_ISDIGIT(*ap)) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4965 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4966 arg[argc] = 0; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4967 for (;;) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4968 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4969 if (ap >= tp + len) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4970 return -1; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4971 if (!VIM_ISDIGIT(*ap)) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4972 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4973 arg[argc] = arg[argc] * 10 + (*ap - '0'); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4974 ++ap; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4975 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4976 ++argc; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4977 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4978 if (*ap == ';') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4979 ++ap; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4980 else |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4981 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4982 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4983 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4984 // mrxvt has been reported to have "+" in the version. Assume |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4985 // the escape sequence ends with a letter or one of "{|}~". |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4986 while (ap < tp + len |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4987 && !(*ap >= '{' && *ap <= '~') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4988 && !ASCII_ISALPHA(*ap)) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4989 ++ap; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4990 if (ap >= tp + len) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4991 return -1; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4992 trail = *ap; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4993 csi_len = (int)(ap - tp) + 1; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4994 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4995 // Cursor position report: Eat it when there are 2 arguments |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4996 // and it ends in 'R'. Also when u7_status is not "sent", it |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4997 // may be from a previous Vim that just exited. But not for |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4998 // <S-F3>, it sends something similar, check for row and column |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4999 // to make sense. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5000 if (first == -1 && argc == 2 && trail == 'R') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5001 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5002 handle_u7_response(arg, tp, csi_len); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5003 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5004 key_name[0] = (int)KS_EXTRA; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5005 key_name[1] = (int)KE_IGNORE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5006 *slen = csi_len; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5007 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5008 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5009 // Version string: Eat it when there is at least one digit and |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5010 // it ends in 'c' |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5011 else if (*T_CRV != NUL && ap > argp + 1 && trail == 'c') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5012 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5013 handle_version_response(first, arg, argc, tp); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5014 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5015 *slen = csi_len; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5016 # ifdef FEAT_EVAL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5017 set_vim_var_string(VV_TERMRESPONSE, tp, *slen); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5018 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5019 apply_autocmds(EVENT_TERMRESPONSE, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5020 NULL, NULL, FALSE, curbuf); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5021 key_name[0] = (int)KS_EXTRA; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5022 key_name[1] = (int)KE_IGNORE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5023 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5024 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5025 // Check blinking cursor from xterm: |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5026 // {lead}?12;1$y set |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5027 // {lead}?12;2$y not set |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5028 // |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5029 // {lead} can be <Esc>[ or CSI |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5030 else if (rbm_status.tr_progress == STATUS_SENT |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5031 && first == '?' |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5032 && ap == argp + 6 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5033 && arg[0] == 12 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5034 && ap[-1] == '$' |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5035 && trail == 'y') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5036 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5037 initial_cursor_blink = (arg[1] == '1'); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5038 rbm_status.tr_progress = STATUS_GOT; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5039 LOG_TR(("Received cursor blinking mode response: %s", tp)); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5040 key_name[0] = (int)KS_EXTRA; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5041 key_name[1] = (int)KE_IGNORE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5042 *slen = csi_len; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5043 # ifdef FEAT_EVAL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5044 set_vim_var_string(VV_TERMBLINKRESP, tp, *slen); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5045 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5046 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5047 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5048 // Check for a window position response from the terminal: |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5049 // {lead}3;{x};{y}t |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5050 else if (did_request_winpos && argc == 3 && arg[0] == 3 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5051 && trail == 't') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5052 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5053 winpos_x = arg[1]; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5054 winpos_y = arg[2]; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5055 // got finished code: consume it |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5056 key_name[0] = (int)KS_EXTRA; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5057 key_name[1] = (int)KE_IGNORE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5058 *slen = csi_len; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5059 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5060 if (--did_request_winpos <= 0) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5061 winpos_status.tr_progress = STATUS_GOT; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5062 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5063 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5064 // Key with modifier: |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5065 // {lead}27;{modifier};{key}~ |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5066 // {lead}{key};{modifier}u |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5067 else if ((arg[0] == 27 && argc == 3 && trail == '~') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5068 || (argc == 2 && trail == 'u')) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5069 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5070 return len + handle_key_with_modifier(arg, trail, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5071 csi_len, offset, buf, bufsize, buflen); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5072 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5073 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5074 // else: Unknown CSI sequence. We could drop it, but then the |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5075 // user can't create a map for it. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5076 return 0; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5077 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5078 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5079 /* |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5080 * Handle an OSC sequence, fore/background color response from the terminal: |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5081 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5082 * {lead}{code};rgb:{rrrr}/{gggg}/{bbbb}{tail} |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5083 * or {lead}{code};rgb:{rr}/{gg}/{bb}{tail} |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5084 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5085 * {code} is 10 for foreground, 11 for background |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5086 * {lead} can be <Esc>] or OSC |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5087 * {tail} can be '\007', <Esc>\ or STERM. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5088 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5089 * Consume any code that starts with "{lead}11;", it's also |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5090 * possible that "rgba" is following. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5091 */ |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5092 static int |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5093 handle_osc(char_u *tp, char_u *argp, int len, char_u *key_name, int *slen) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5094 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5095 int i, j; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5096 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5097 j = 1 + (tp[0] == ESC); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5098 if (len >= j + 3 && (argp[0] != '1' |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5099 || (argp[1] != '1' && argp[1] != '0') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5100 || argp[2] != ';')) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5101 i = 0; // no match |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5102 else |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5103 for (i = j; i < len; ++i) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5104 if (tp[i] == '\007' || (tp[0] == OSC ? tp[i] == STERM |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5105 : (tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\'))) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5106 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5107 int is_bg = argp[1] == '1'; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5108 int is_4digit = i - j >= 21 && tp[j + 11] == '/' |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5109 && tp[j + 16] == '/'; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5110 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5111 if (i - j >= 15 && STRNCMP(tp + j + 3, "rgb:", 4) == 0 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5112 && (is_4digit |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5113 || (tp[j + 9] == '/' && tp[i + 12 == '/']))) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5114 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5115 char_u *tp_r = tp + j + 7; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5116 char_u *tp_g = tp + j + (is_4digit ? 12 : 10); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5117 char_u *tp_b = tp + j + (is_4digit ? 17 : 13); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5118 # ifdef FEAT_TERMINAL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5119 int rval, gval, bval; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5120 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5121 rval = hexhex2nr(tp_r); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5122 gval = hexhex2nr(tp_b); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5123 bval = hexhex2nr(tp_g); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5124 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5125 if (is_bg) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5126 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5127 char *new_bg_val = (3 * '6' < *tp_r + *tp_g + |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5128 *tp_b) ? "light" : "dark"; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5129 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5130 LOG_TR(("Received RBG response: %s", tp)); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5131 rbg_status.tr_progress = STATUS_GOT; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5132 # ifdef FEAT_TERMINAL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5133 bg_r = rval; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5134 bg_g = gval; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5135 bg_b = bval; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5136 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5137 if (!option_was_set((char_u *)"bg") |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5138 && STRCMP(p_bg, new_bg_val) != 0) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5139 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5140 // value differs, apply it |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5141 set_option_value((char_u *)"bg", 0L, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5142 (char_u *)new_bg_val, 0); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5143 reset_option_was_set((char_u *)"bg"); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5144 redraw_asap(CLEAR); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5145 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5146 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5147 # ifdef FEAT_TERMINAL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5148 else |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5149 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5150 LOG_TR(("Received RFG response: %s", tp)); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5151 rfg_status.tr_progress = STATUS_GOT; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5152 fg_r = rval; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5153 fg_g = gval; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5154 fg_b = bval; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5155 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5156 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5157 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5158 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5159 // got finished code: consume it |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5160 key_name[0] = (int)KS_EXTRA; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5161 key_name[1] = (int)KE_IGNORE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5162 *slen = i + 1 + (tp[i] == ESC); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5163 # ifdef FEAT_EVAL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5164 set_vim_var_string(is_bg ? VV_TERMRBGRESP |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5165 : VV_TERMRFGRESP, tp, *slen); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5166 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5167 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5168 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5169 if (i == len) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5170 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5171 LOG_TR(("not enough characters for RB")); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5172 return FAIL; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5173 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5174 return OK; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5175 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5176 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5177 /* |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5178 * Check for key code response from xterm: |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5179 * {lead}{flag}+r<hex bytes><{tail} |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5180 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5181 * {lead} can be <Esc>P or DCS |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5182 * {flag} can be '0' or '1' |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5183 * {tail} can be Esc>\ or STERM |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5184 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5185 * Check for cursor shape response from xterm: |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5186 * {lead}1$r<digit> q{tail} |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5187 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5188 * {lead} can be <Esc>P or DCS |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5189 * {tail} can be <Esc>\ or STERM |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5190 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5191 * Consume any code that starts with "{lead}.+r" or "{lead}.$r". |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5192 */ |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5193 static int |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5194 handle_dcs(char_u *tp, char_u *argp, int len, char_u *key_name, int *slen) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5195 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5196 int i, j; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5197 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5198 j = 1 + (tp[0] == ESC); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5199 if (len < j + 3) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5200 i = len; // need more chars |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5201 else if ((argp[1] != '+' && argp[1] != '$') || argp[2] != 'r') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5202 i = 0; // no match |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5203 else if (argp[1] == '+') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5204 // key code response |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5205 for (i = j; i < len; ++i) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5206 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5207 if ((tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5208 || tp[i] == STERM) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5209 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5210 if (i - j >= 3) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5211 got_code_from_term(tp + j, i); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5212 key_name[0] = (int)KS_EXTRA; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5213 key_name[1] = (int)KE_IGNORE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5214 *slen = i + 1 + (tp[i] == ESC); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5215 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5216 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5217 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5218 else |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5219 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5220 // Probably the cursor shape response. Make sure that "i" |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5221 // is equal to "len" when there are not sufficient |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5222 // characters. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5223 for (i = j + 3; i < len; ++i) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5224 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5225 if (i - j == 3 && !isdigit(tp[i])) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5226 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5227 if (i - j == 4 && tp[i] != ' ') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5228 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5229 if (i - j == 5 && tp[i] != 'q') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5230 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5231 if (i - j == 6 && tp[i] != ESC && tp[i] != STERM) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5232 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5233 if ((i - j == 6 && tp[i] == STERM) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5234 || (i - j == 7 && tp[i] == '\\')) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5235 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5236 int number = argp[3] - '0'; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5237 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5238 // 0, 1 = block blink, 2 = block |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5239 // 3 = underline blink, 4 = underline |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5240 // 5 = vertical bar blink, 6 = vertical bar |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5241 number = number == 0 ? 1 : number; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5242 initial_cursor_shape = (number + 1) / 2; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5243 // The blink flag is actually inverted, compared to |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5244 // the value set with T_SH. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5245 initial_cursor_shape_blink = |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5246 (number & 1) ? FALSE : TRUE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5247 rcs_status.tr_progress = STATUS_GOT; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5248 LOG_TR(("Received cursor shape response: %s", tp)); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5249 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5250 key_name[0] = (int)KS_EXTRA; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5251 key_name[1] = (int)KE_IGNORE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5252 *slen = i + 1; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5253 # ifdef FEAT_EVAL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5254 set_vim_var_string(VV_TERMSTYLERESP, tp, *slen); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5255 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5256 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5257 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5258 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5259 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5260 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5261 if (i == len) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5262 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5263 // These codes arrive many together, each code can be |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5264 // truncated at any point. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5265 LOG_TR(("not enough characters for XT")); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5266 return FAIL; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5267 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5268 return OK; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5269 } |
20776
7728e309e013
patch 8.2.0940: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
20774
diff
changeset
|
5270 #endif // FEAT_TERMRESPONSE |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5271 |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5272 /* |
7 | 5273 * Check if typebuf.tb_buf[] contains a terminal key code. |
5274 * Check from typebuf.tb_buf[typebuf.tb_off] to typebuf.tb_buf[typebuf.tb_off | |
20727
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20705
diff
changeset
|
5275 * + "max_offset"]. |
7 | 5276 * Return 0 for no match, -1 for partial match, > 0 for full match. |
2672 | 5277 * Return KEYLEN_REMOVED when a key code was deleted. |
7 | 5278 * With a match, the match is removed, the replacement code is inserted in |
5279 * typebuf.tb_buf[] and the number of characters in typebuf.tb_buf[] is | |
5280 * returned. | |
3328 | 5281 * When "buf" is not NULL, buf[bufsize] is used instead of typebuf.tb_buf[]. |
5282 * "buflen" is then the length of the string in buf[] and is updated for | |
5283 * inserts and deletes. | |
7 | 5284 */ |
5285 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5286 check_termcode( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5287 int max_offset, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5288 char_u *buf, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5289 int bufsize, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5290 int *buflen) |
7 | 5291 { |
5292 char_u *tp; | |
5293 char_u *p; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5294 int slen = 0; // init for GCC |
180 | 5295 int modslen; |
7 | 5296 int len; |
2672 | 5297 int retval = 0; |
7 | 5298 int offset; |
5299 char_u key_name[2]; | |
180 | 5300 int modifiers; |
11565
91519a14ec1f
patch 8.0.0665: warning for uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
11563
diff
changeset
|
5301 char_u *modifiers_start = NULL; |
180 | 5302 int key; |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5303 int new_slen; // Length of what will replace the termcode |
7 | 5304 char_u string[MAX_KEY_CODE_LEN + 1]; |
5305 int i, j; | |
5306 int idx = 0; | |
5307 int cpo_koffset; | |
5308 | |
5309 cpo_koffset = (vim_strchr(p_cpo, CPO_KOFFSET) != NULL); | |
5310 | |
5311 /* | |
5312 * Speed up the checks for terminal codes by gathering all first bytes | |
5313 * used in termleader[]. Often this is just a single <Esc>. | |
5314 */ | |
5315 if (need_gather) | |
5316 gather_termleader(); | |
5317 | |
5318 /* | |
5319 * Check at several positions in typebuf.tb_buf[], to catch something like | |
5320 * "x<Up>" that can be mapped. Stop at max_offset, because characters | |
5321 * after that cannot be used for mapping, and with @r commands | |
4223 | 5322 * typebuf.tb_buf[] can become very long. |
7 | 5323 * This is used often, KEEP IT FAST! |
5324 */ | |
5325 for (offset = 0; offset < max_offset; ++offset) | |
5326 { | |
5327 if (buf == NULL) | |
5328 { | |
5329 if (offset >= typebuf.tb_len) | |
5330 break; | |
5331 tp = typebuf.tb_buf + typebuf.tb_off + offset; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5332 len = typebuf.tb_len - offset; // length of the input |
7 | 5333 } |
5334 else | |
5335 { | |
3328 | 5336 if (offset >= *buflen) |
7 | 5337 break; |
5338 tp = buf + offset; | |
3328 | 5339 len = *buflen - offset; |
7 | 5340 } |
5341 | |
5342 /* | |
5343 * Don't check characters after K_SPECIAL, those are already | |
5344 * translated terminal chars (avoid translating ~@^Hx). | |
5345 */ | |
5346 if (*tp == K_SPECIAL) | |
5347 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5348 offset += 2; // there are always 2 extra characters |
7 | 5349 continue; |
5350 } | |
5351 | |
5352 /* | |
5353 * Skip this position if the character does not appear as the first | |
5354 * character in term_strings. This speeds up a lot, since most | |
5355 * termcodes start with the same character (ESC or CSI). | |
5356 */ | |
5357 i = *tp; | |
5358 for (p = termleader; *p && *p != i; ++p) | |
5359 ; | |
5360 if (*p == NUL) | |
5361 continue; | |
5362 | |
5363 /* | |
5364 * Skip this position if p_ek is not set and tp[0] is an ESC and we | |
5365 * are in Insert mode. | |
5366 */ | |
5367 if (*tp == ESC && !p_ek && (State & INSERT)) | |
5368 continue; | |
5369 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5370 key_name[0] = NUL; // no key name found yet |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5371 key_name[1] = NUL; // no key name found yet |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5372 modifiers = 0; // no modifiers yet |
7 | 5373 |
5374 #ifdef FEAT_GUI | |
5375 if (gui.in_use) | |
5376 { | |
5377 /* | |
5378 * GUI special key codes are all of the form [CSI xx]. | |
5379 */ | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5380 if (*tp == CSI) // Special key from GUI |
7 | 5381 { |
5382 if (len < 3) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5383 return -1; // Shouldn't happen |
7 | 5384 slen = 3; |
5385 key_name[0] = tp[1]; | |
5386 key_name[1] = tp[2]; | |
5387 } | |
5388 } | |
5389 else | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5390 #endif // FEAT_GUI |
7 | 5391 { |
23774
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5392 int mouse_index_found = -1; |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5393 |
7 | 5394 for (idx = 0; idx < tc_len; ++idx) |
5395 { | |
5396 /* | |
5397 * Ignore the entry if we are not at the start of | |
5398 * typebuf.tb_buf[] | |
5399 * and there are not enough characters to make a match. | |
5400 * But only when the 'K' flag is in 'cpoptions'. | |
5401 */ | |
5402 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
|
5403 modifiers_start = NULL; |
7 | 5404 if (cpo_koffset && offset && len < slen) |
5405 continue; | |
5406 if (STRNCMP(termcodes[idx].code, tp, | |
5407 (size_t)(slen > len ? len : slen)) == 0) | |
5408 { | |
26392
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5409 int looks_like_mouse_start = FALSE; |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5410 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5411 if (len < slen) // got a partial sequence |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5412 return -1; // need to get more chars |
7 | 5413 |
5414 /* | |
5415 * When found a keypad key, check if there is another key | |
5416 * that matches and use that one. This makes <Home> to be | |
5417 * found instead of <kHome> when they produce the same | |
5418 * key code. | |
5419 */ | |
5420 if (termcodes[idx].name[0] == 'K' | |
5421 && VIM_ISDIGIT(termcodes[idx].name[1])) | |
5422 { | |
5423 for (j = idx + 1; j < tc_len; ++j) | |
5424 if (termcodes[j].len == slen && | |
5425 STRNCMP(termcodes[idx].code, | |
5426 termcodes[j].code, slen) == 0) | |
5427 { | |
5428 idx = j; | |
5429 break; | |
5430 } | |
5431 } | |
5432 | |
23774
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5433 if (slen == 2 && len > 2 |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5434 && termcodes[idx].code[0] == ESC |
26392
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5435 && termcodes[idx].code[1] == '[') |
23774
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5436 { |
26392
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5437 // The mouse termcode "ESC [" is also the prefix of |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5438 // "ESC [ I" (focus gained) and other keys. Check some |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5439 // more bytes to find out. |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5440 if (!isdigit(tp[2])) |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5441 { |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5442 // ESC [ without number following: Only use it when |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5443 // there is no other match. |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5444 looks_like_mouse_start = TRUE; |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5445 } |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5446 else if (termcodes[idx].name[0] == KS_DEC_MOUSE) |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5447 { |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5448 char_u *nr = tp + 2; |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5449 int count = 0; |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5450 |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5451 // If a digit is following it could be a key with |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5452 // modifier, e.g., ESC [ 1;2P. Can be confused |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5453 // with DEC_MOUSE, which requires four numbers |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5454 // following. If not then it can't be a DEC_MOUSE |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5455 // code. |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5456 for (;;) |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5457 { |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5458 ++count; |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5459 (void)getdigits(&nr); |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5460 if (nr >= tp + len) |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5461 return -1; // partial sequence |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5462 if (*nr != ';') |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5463 break; |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5464 ++nr; |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5465 if (nr >= tp + len) |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5466 return -1; // partial sequence |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5467 } |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5468 if (count < 4) |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5469 continue; // no match |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5470 } |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5471 } |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5472 if (looks_like_mouse_start) |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5473 { |
201243ceaa18
patch 8.2.3727: in a gnome terminal keys are recognized as mouse events
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
5474 // Only use it when there is no other match. |
23774
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5475 if (mouse_index_found < 0) |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5476 mouse_index_found = idx; |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5477 } |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5478 else |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5479 { |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5480 key_name[0] = termcodes[idx].name[0]; |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5481 key_name[1] = termcodes[idx].name[1]; |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5482 break; |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5483 } |
7 | 5484 } |
179 | 5485 |
5486 /* | |
5487 * Check for code with modifier, like xterm uses: | |
180 | 5488 * <Esc>[123;*X (modslen == slen - 3) |
23406
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5489 * <Esc>[@;*X (matches <Esc>[X and <Esc>[1;9X ) |
180 | 5490 * Also <Esc>O*X and <M-O>*X (modslen == slen - 2). |
5491 * When there is a modifier the * matches a number. | |
5492 * When there is no modifier the ;* or * is omitted. | |
179 | 5493 */ |
23774
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5494 if (termcodes[idx].modlen > 0 && mouse_index_found < 0) |
179 | 5495 { |
23406
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5496 int at_code; |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5497 |
180 | 5498 modslen = termcodes[idx].modlen; |
5499 if (cpo_koffset && offset && len < modslen) | |
179 | 5500 continue; |
23406
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5501 at_code = termcodes[idx].code[modslen] == '@'; |
179 | 5502 if (STRNCMP(termcodes[idx].code, tp, |
180 | 5503 (size_t)(modslen > len ? len : modslen)) == 0) |
179 | 5504 { |
5505 int n; | |
180 | 5506 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5507 if (len <= modslen) // got a partial sequence |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5508 return -1; // need to get more chars |
179 | 5509 |
180 | 5510 if (tp[modslen] == termcodes[idx].code[slen - 1]) |
23406
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5511 // no modifiers |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5512 slen = modslen + 1; |
180 | 5513 else if (tp[modslen] != ';' && modslen == slen - 3) |
23406
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5514 // no match for "code;*X" with "code;" |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5515 continue; |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5516 else if (at_code && tp[modslen] != '1') |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5517 // no match for "<Esc>[@" with "<Esc>[1" |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5518 continue; |
179 | 5519 else |
5520 { | |
16485
b870146e09e1
patch 8.1.1246: cannot handle negative mouse coordinate from urxvt
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
5521 // Skip over the digits, the final char must |
b870146e09e1
patch 8.1.1246: cannot handle negative mouse coordinate from urxvt
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
5522 // follow. URXVT can use a negative value, thus |
b870146e09e1
patch 8.1.1246: cannot handle negative mouse coordinate from urxvt
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
5523 // also accept '-'. |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
5524 for (j = slen - 2; j < len && (isdigit(tp[j]) |
16485
b870146e09e1
patch 8.1.1246: cannot handle negative mouse coordinate from urxvt
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
5525 || tp[j] == '-' || tp[j] == ';'); ++j) |
179 | 5526 ; |
5527 ++j; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5528 if (len < j) // got a partial sequence |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5529 return -1; // need to get more chars |
180 | 5530 if (tp[j - 1] != termcodes[idx].code[slen - 1]) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5531 continue; // no match |
179 | 5532 |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
5533 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
|
5534 |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5535 // Match! Convert modifier bits. |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5536 n = atoi((char *)modifiers_start); |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5537 modifiers |= decode_modifiers(n); |
179 | 5538 |
5539 slen = j; | |
5540 } | |
5541 key_name[0] = termcodes[idx].name[0]; | |
5542 key_name[1] = termcodes[idx].name[1]; | |
5543 break; | |
5544 } | |
5545 } | |
7 | 5546 } |
23774
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5547 if (idx == tc_len && mouse_index_found >= 0) |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5548 { |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5549 key_name[0] = termcodes[mouse_index_found].name[0]; |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5550 key_name[1] = termcodes[mouse_index_found].name[1]; |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5551 } |
7 | 5552 } |
5553 | |
5554 #ifdef FEAT_TERMRESPONSE | |
3166 | 5555 if (key_name[0] == NUL |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5556 // Mouse codes of DEC and pterm start with <ESC>[. When |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5557 // detecting the start of these mouse codes they might as well be |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5558 // another key code or terminal response. |
6102 | 5559 # ifdef FEAT_MOUSE_DEC |
5560 || key_name[0] == KS_DEC_MOUSE | |
5561 # endif | |
5562 # ifdef FEAT_MOUSE_PTERM | |
5563 || key_name[0] == KS_PTERM_MOUSE | |
4223 | 5564 # endif |
6102 | 5565 ) |
7 | 5566 { |
18257
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5567 char_u *argp = tp[0] == ESC ? tp + 2 : tp + 1; |
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5568 |
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5569 /* |
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5570 * Check for responses from the terminal starting with {lead}: |
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5571 * "<Esc>[" or CSI followed by [0-9>?] |
4215 | 5572 * |
18257
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5573 * - Xterm version string: {lead}>{x};{vers};{y}c |
4215 | 5574 * Also eat other possible responses to t_RV, rxvt returns |
18257
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5575 * "{lead}?1;2c". |
4215 | 5576 * |
18257
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5577 * - Cursor position report: {lead}{row};{col}R |
6102 | 5578 * The final byte must be 'R'. It is used for checking the |
4215 | 5579 * 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
|
5580 * |
18257
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5581 * - window position reply: {lead}3;{x};{y}t |
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5582 * |
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5583 * - key with modifiers when modifyOtherKeys is enabled: |
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5584 * {lead}27;{modifier};{key}~ |
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5585 * {lead}{key};{modifier}u |
4215 | 5586 */ |
18257
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5587 if (((tp[0] == ESC && len >= 3 && tp[1] == '[') |
4395 | 5588 || (tp[0] == CSI && len >= 2)) |
18257
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5589 && (VIM_ISDIGIT(*argp) || *argp == '>' || *argp == '?')) |
7 | 5590 { |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5591 int resp = handle_csi(tp, len, argp, offset, buf, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5592 bufsize, buflen, key_name, &slen); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5593 if (resp != 0) |
7 | 5594 { |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5595 # ifdef DEBUG_TERMRESPONSE |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5596 if (resp == -1) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5597 LOG_TR(("Not enough characters for CSI sequence")); |
7 | 5598 # endif |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5599 return resp; |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
5600 } |
6901 | 5601 } |
5602 | |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5603 // Check for fore/background color response from the terminal, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5604 // starting} with <Esc>] or OSC |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5605 else if ((*T_RBG != NUL || *T_RFG != NUL) |
6901 | 5606 && ((tp[0] == ESC && len >= 2 && tp[1] == ']') |
5607 || tp[0] == OSC)) | |
5608 { | |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5609 if (handle_osc(tp, argp, len, key_name, &slen) == FAIL) |
6901 | 5610 return -1; |
7 | 5611 } |
5612 | |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5613 // Check for key code response from xterm, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5614 // starting with <Esc>P or DCS |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
5615 else if ((check_for_codes || rcs_status.tr_progress == STATUS_SENT) |
6901 | 5616 && ((tp[0] == ESC && len >= 2 && tp[1] == 'P') |
7 | 5617 || tp[0] == DCS)) |
5618 { | |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5619 if (handle_dcs(tp, argp, len, key_name, &slen) == FAIL) |
6901 | 5620 return -1; |
7 | 5621 } |
5622 } | |
5623 #endif | |
5624 | |
5625 if (key_name[0] == NUL) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5626 continue; // No match at this position, try next one |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5627 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5628 // We only get here when we have a complete termcode match |
7 | 5629 |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5630 #ifdef FEAT_GUI |
7 | 5631 /* |
5632 * Only in the GUI: Fetch the pointer coordinates of the scroll event | |
5633 * so that we know which window to scroll later. | |
5634 */ | |
5635 if (gui.in_use | |
5636 && key_name[0] == (int)KS_EXTRA | |
5637 && (key_name[1] == (int)KE_X1MOUSE | |
5638 || key_name[1] == (int)KE_X2MOUSE | |
24850
f8906bd5b277
patch 8.2.2963: GUI: mouse move may start Visual mode with a popup visible
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
5639 || key_name[1] == (int)KE_MOUSEMOVE_XY |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2347
diff
changeset
|
5640 || key_name[1] == (int)KE_MOUSELEFT |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2347
diff
changeset
|
5641 || key_name[1] == (int)KE_MOUSERIGHT |
7 | 5642 || key_name[1] == (int)KE_MOUSEDOWN |
5643 || key_name[1] == (int)KE_MOUSEUP)) | |
5644 { | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5645 char_u bytes[6]; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5646 int num_bytes = get_bytes_from_buf(tp + slen, bytes, 4); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5647 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5648 if (num_bytes == -1) // not enough coordinates |
7 | 5649 return -1; |
5650 mouse_col = 128 * (bytes[0] - ' ' - 1) + bytes[1] - ' ' - 1; | |
5651 mouse_row = 128 * (bytes[2] - ' ' - 1) + bytes[3] - ' ' - 1; | |
5652 slen += num_bytes; | |
24850
f8906bd5b277
patch 8.2.2963: GUI: mouse move may start Visual mode with a popup visible
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
5653 // equal to K_MOUSEMOVE |
f8906bd5b277
patch 8.2.2963: GUI: mouse move may start Visual mode with a popup visible
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
5654 if (key_name[1] == (int)KE_MOUSEMOVE_XY) |
f8906bd5b277
patch 8.2.2963: GUI: mouse move may start Visual mode with a popup visible
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
5655 key_name[1] = (int)KE_MOUSEMOVE; |
7 | 5656 } |
5657 else | |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5658 #endif |
7 | 5659 /* |
5660 * If it is a mouse click, get the coordinates. | |
5661 */ | |
3746 | 5662 if (key_name[0] == KS_MOUSE |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5663 #ifdef FEAT_MOUSE_GPM |
16523
a72ad8a8b249
patch 8.1.1265: when GPM mouse support is enabled double clicks do not work
Bram Moolenaar <Bram@vim.org>
parents:
16501
diff
changeset
|
5664 || key_name[0] == KS_GPM_MOUSE |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5665 #endif |
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5666 #ifdef FEAT_MOUSE_JSB |
3746 | 5667 || key_name[0] == KS_JSBTERM_MOUSE |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5668 #endif |
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5669 #ifdef FEAT_MOUSE_NET |
3746 | 5670 || key_name[0] == KS_NETTERM_MOUSE |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5671 #endif |
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5672 #ifdef FEAT_MOUSE_DEC |
3746 | 5673 || key_name[0] == KS_DEC_MOUSE |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5674 #endif |
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5675 #ifdef FEAT_MOUSE_PTERM |
3746 | 5676 || key_name[0] == KS_PTERM_MOUSE |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5677 #endif |
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5678 #ifdef FEAT_MOUSE_URXVT |
3746 | 5679 || key_name[0] == KS_URXVT_MOUSE |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5680 #endif |
3746 | 5681 || key_name[0] == KS_SGR_MOUSE |
16058
012f03e583e2
patch 8.1.1034: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
5682 || key_name[0] == KS_SGR_MOUSE_RELEASE) |
7 | 5683 { |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5684 if (check_termcode_mouse(tp, &slen, key_name, modifiers_start, idx, |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5685 &modifiers) == -1) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5686 return -1; |
7 | 5687 } |
5688 | |
5689 #ifdef FEAT_GUI | |
5690 /* | |
5691 * If using the GUI, then we get menu and scrollbar events. | |
5692 * | |
5693 * A menu event is encoded as K_SPECIAL, KS_MENU, KE_FILLER followed by | |
5694 * four bytes which are to be taken as a pointer to the vimmenu_T | |
5695 * structure. | |
5696 * | |
1221 | 5697 * A tab line event is encoded as K_SPECIAL KS_TABLINE nr, where "nr" |
685 | 5698 * is one byte with the tab index. |
5699 * | |
7 | 5700 * A scrollbar event is K_SPECIAL, KS_VER_SCROLLBAR, KE_FILLER followed |
5701 * by one byte representing the scrollbar number, and then four bytes | |
5702 * representing a long_u which is the new value of the scrollbar. | |
5703 * | |
5704 * A horizontal scrollbar event is K_SPECIAL, KS_HOR_SCROLLBAR, | |
5705 * KE_FILLER followed by four bytes representing a long_u which is the | |
5706 * new value of the scrollbar. | |
5707 */ | |
5708 # ifdef FEAT_MENU | |
5709 else if (key_name[0] == (int)KS_MENU) | |
5710 { | |
5711 long_u val; | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5712 int num_bytes = get_long_from_buf(tp + slen, &val); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5713 |
7 | 5714 if (num_bytes == -1) |
5715 return -1; | |
5716 current_menu = (vimmenu_T *)val; | |
5717 slen += num_bytes; | |
936 | 5718 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5719 // The menu may have been deleted right after it was used, check |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5720 // for that. |
936 | 5721 if (check_menu_pointer(root_menu, current_menu) == FAIL) |
5722 { | |
5723 key_name[0] = KS_EXTRA; | |
5724 key_name[1] = (int)KE_IGNORE; | |
5725 } | |
7 | 5726 } |
5727 # endif | |
685 | 5728 # ifdef FEAT_GUI_TABLINE |
5729 else if (key_name[0] == (int)KS_TABLINE) | |
5730 { | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5731 // Selecting tabline tab or using its menu. |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5732 char_u bytes[6]; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5733 int num_bytes = get_bytes_from_buf(tp + slen, bytes, 1); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5734 |
685 | 5735 if (num_bytes == -1) |
5736 return -1; | |
5737 current_tab = (int)bytes[0]; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5738 if (current_tab == 255) // -1 in a byte gives 255 |
1394 | 5739 current_tab = -1; |
685 | 5740 slen += num_bytes; |
5741 } | |
688 | 5742 else if (key_name[0] == (int)KS_TABMENU) |
5743 { | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5744 // Selecting tabline tab or using its menu. |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5745 char_u bytes[6]; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5746 int num_bytes = get_bytes_from_buf(tp + slen, bytes, 2); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5747 |
688 | 5748 if (num_bytes == -1) |
5749 return -1; | |
5750 current_tab = (int)bytes[0]; | |
5751 current_tabmenu = (int)bytes[1]; | |
5752 slen += num_bytes; | |
5753 } | |
685 | 5754 # endif |
7 | 5755 # ifndef USE_ON_FLY_SCROLL |
5756 else if (key_name[0] == (int)KS_VER_SCROLLBAR) | |
5757 { | |
5758 long_u val; | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5759 char_u bytes[6]; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5760 int num_bytes; |
7 | 5761 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5762 // Get the last scrollbar event in the queue of the same type |
7 | 5763 j = 0; |
5764 for (i = 0; tp[j] == CSI && tp[j + 1] == KS_VER_SCROLLBAR | |
5765 && tp[j + 2] != NUL; ++i) | |
5766 { | |
5767 j += 3; | |
5768 num_bytes = get_bytes_from_buf(tp + j, bytes, 1); | |
5769 if (num_bytes == -1) | |
5770 break; | |
5771 if (i == 0) | |
5772 current_scrollbar = (int)bytes[0]; | |
5773 else if (current_scrollbar != (int)bytes[0]) | |
5774 break; | |
5775 j += num_bytes; | |
5776 num_bytes = get_long_from_buf(tp + j, &val); | |
5777 if (num_bytes == -1) | |
5778 break; | |
5779 scrollbar_value = val; | |
5780 j += num_bytes; | |
5781 slen = j; | |
5782 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5783 if (i == 0) // not enough characters to make one |
7 | 5784 return -1; |
5785 } | |
5786 else if (key_name[0] == (int)KS_HOR_SCROLLBAR) | |
5787 { | |
5788 long_u val; | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5789 int num_bytes; |
7 | 5790 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5791 // Get the last horiz. scrollbar event in the queue |
7 | 5792 j = 0; |
5793 for (i = 0; tp[j] == CSI && tp[j + 1] == KS_HOR_SCROLLBAR | |
5794 && tp[j + 2] != NUL; ++i) | |
5795 { | |
5796 j += 3; | |
5797 num_bytes = get_long_from_buf(tp + j, &val); | |
5798 if (num_bytes == -1) | |
5799 break; | |
5800 scrollbar_value = val; | |
5801 j += num_bytes; | |
5802 slen = j; | |
5803 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5804 if (i == 0) // not enough characters to make one |
7 | 5805 return -1; |
5806 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5807 # endif // !USE_ON_FLY_SCROLL |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5808 #endif // FEAT_GUI |
7 | 5809 |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5810 #if (defined(UNIX) || defined(VMS)) |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5811 /* |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5812 * Handle FocusIn/FocusOut event sequences reported by XTerm. |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5813 * (CSI I/CSI O) |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5814 */ |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5815 if (focus_mode |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5816 # ifdef FEAT_GUI |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5817 && !gui.in_use |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5818 # endif |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5819 && key_name[0] == KS_EXTRA |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5820 ) |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5821 { |
23620
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5822 if (key_name[1] == KE_FOCUSGAINED) |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5823 { |
23620
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5824 if (!focus_state) |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5825 { |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5826 ui_focus_change(TRUE); |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5827 did_cursorhold = TRUE; |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5828 focus_state = TRUE; |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5829 } |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5830 key_name[1] = (int)KE_IGNORE; |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5831 } |
23620
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5832 else if (key_name[1] == KE_FOCUSLOST) |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5833 { |
23620
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5834 if (focus_state) |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5835 { |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5836 ui_focus_change(FALSE); |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5837 did_cursorhold = TRUE; |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5838 focus_state = FALSE; |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5839 } |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5840 key_name[1] = (int)KE_IGNORE; |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5841 } |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5842 } |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5843 #endif |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5844 |
180 | 5845 /* |
5846 * Change <xHome> to <Home>, <xUp> to <Up>, etc. | |
5847 */ | |
5848 key = handle_x_keys(TERMCAP2KEY(key_name[0], key_name[1])); | |
5849 | |
5850 /* | |
5851 * Add any modifier codes to our string. | |
5852 */ | |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5853 new_slen = modifiers2keycode(modifiers, &key, string); |
180 | 5854 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5855 // Finally, add the special key code to our string |
180 | 5856 key_name[0] = KEY2TERMCAP0(key); |
5857 key_name[1] = KEY2TERMCAP1(key); | |
7 | 5858 if (key_name[0] == KS_KEY) |
1787 | 5859 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5860 // from ":set <M-b>=xx" |
1787 | 5861 if (has_mbyte) |
5862 new_slen += (*mb_char2bytes)(key_name[1], string + new_slen); | |
5863 else | |
5864 string[new_slen++] = key_name[1]; | |
5865 } | |
2672 | 5866 else if (new_slen == 0 && key_name[0] == KS_EXTRA |
5867 && key_name[1] == KE_IGNORE) | |
5868 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5869 // Do not put K_IGNORE into the buffer, do return KEYLEN_REMOVED |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5870 // to indicate what happened. |
2672 | 5871 retval = KEYLEN_REMOVED; |
5872 } | |
7 | 5873 else |
5874 { | |
5875 string[new_slen++] = K_SPECIAL; | |
5876 string[new_slen++] = key_name[0]; | |
5877 string[new_slen++] = key_name[1]; | |
5878 } | |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5879 if (put_string_in_typebuf(offset, slen, string, new_slen, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5880 buf, bufsize, buflen) == FAIL) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5881 return -1; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5882 return retval == 0 ? (len + new_slen - slen + offset) : retval; |
7 | 5883 } |
5884 | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5885 #ifdef FEAT_TERMRESPONSE |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
5886 LOG_TR(("normal character")); |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5887 #endif |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5888 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5889 return 0; // no match found |
7 | 5890 } |
5891 | |
12634
94566ecb55f0
patch 8.0.1195: can't build on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12632
diff
changeset
|
5892 #if (defined(FEAT_TERMINAL) && defined(FEAT_TERMRESPONSE)) || defined(PROTO) |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5893 /* |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5894 * Get the text foreground color, if known. |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5895 */ |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5896 void |
12640
a715f0b44532
patch 8.0.1198: older compilers don't know uint8_t
Christian Brabandt <cb@256bit.org>
parents:
12634
diff
changeset
|
5897 term_get_fg_color(char_u *r, char_u *g, char_u *b) |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5898 { |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
5899 if (rfg_status.tr_progress == STATUS_GOT) |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5900 { |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5901 *r = fg_r; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5902 *g = fg_g; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5903 *b = fg_b; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5904 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5905 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5906 |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5907 /* |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5908 * Get the text background color, if known. |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5909 */ |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5910 void |
12640
a715f0b44532
patch 8.0.1198: older compilers don't know uint8_t
Christian Brabandt <cb@256bit.org>
parents:
12634
diff
changeset
|
5911 term_get_bg_color(char_u *r, char_u *g, char_u *b) |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5912 { |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
5913 if (rbg_status.tr_progress == STATUS_GOT) |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5914 { |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5915 *r = bg_r; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5916 *g = bg_g; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5917 *b = bg_b; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5918 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5919 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5920 #endif |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5921 |
7 | 5922 /* |
5923 * Replace any terminal code strings in from[] with the equivalent internal | |
5924 * vim representation. This is used for the "from" and "to" part of a | |
5925 * mapping, and the "to" part of a menu command. | |
5926 * Any strings like "<C-UP>" are also replaced, unless 'cpoptions' contains | |
5927 * '<'. | |
5928 * K_SPECIAL by itself is replaced by K_SPECIAL KS_SPECIAL KE_FILLER. | |
5929 * | |
5930 * The replacement is done in result[] and finally copied into allocated | |
5931 * memory. If this all works well *bufp is set to the allocated memory and a | |
5932 * pointer to it is returned. If something fails *bufp is set to NULL and from | |
5933 * is returned. | |
5934 * | |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5935 * CTRL-V characters are removed. When "flags" has REPTERM_FROM_PART, a |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5936 * trailing CTRL-V is included, otherwise it is removed (for ":map xx ^V", maps |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5937 * xx to nothing). When 'cpoptions' does not contain 'B', a backslash can be |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5938 * used instead of a CTRL-V. |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5939 * |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5940 * Flags: |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5941 * REPTERM_FROM_PART see above |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5942 * REPTERM_DO_LT also translate <lt> |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5943 * REPTERM_SPECIAL always accept <key> notation |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5944 * REPTERM_NO_SIMPLIFY do not simplify <C-H> to 0x08 and set 8th bit for <A-x> |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5945 * |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5946 * "did_simplify" is set when some <C-H> or <A-x> code was simplified, unless |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5947 * it is NULL. |
7 | 5948 */ |
859 | 5949 char_u * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5950 replace_termcodes( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5951 char_u *from, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5952 char_u **bufp, |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5953 int flags, |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5954 int *did_simplify) |
7 | 5955 { |
5956 int i; | |
5957 int slen; | |
5958 int key; | |
5959 int dlen = 0; | |
5960 char_u *src; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5961 int do_backslash; // backslash is a special character |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5962 int do_special; // recognize <> key codes |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5963 int do_key_code; // recognize raw key codes |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5964 char_u *result; // buffer for resulting string |
7 | 5965 |
5966 do_backslash = (vim_strchr(p_cpo, CPO_BSLASH) == NULL); | |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5967 do_special = (vim_strchr(p_cpo, CPO_SPECI) == NULL) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5968 || (flags & REPTERM_SPECIAL); |
7 | 5969 do_key_code = (vim_strchr(p_cpo, CPO_KEYCODE) == NULL); |
5970 | |
5971 /* | |
5972 * Allocate space for the translation. Worst case a single character is | |
5973 * replaced by 6 bytes (shifted special key), plus a NUL at the end. | |
5974 */ | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16642
diff
changeset
|
5975 result = alloc(STRLEN(from) * 6 + 1); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5976 if (result == NULL) // out of memory |
7 | 5977 { |
5978 *bufp = NULL; | |
5979 return from; | |
5980 } | |
5981 | |
5982 src = from; | |
5983 | |
5984 /* | |
5985 * Check for #n at start only: function key n | |
5986 */ | |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5987 if ((flags & REPTERM_FROM_PART) && src[0] == '#' && VIM_ISDIGIT(src[1])) |
7 | 5988 { |
5989 result[dlen++] = K_SPECIAL; | |
5990 result[dlen++] = 'k'; | |
5991 if (src[1] == '0') | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5992 result[dlen++] = ';'; // #0 is F10 is "k;" |
7 | 5993 else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5994 result[dlen++] = src[1]; // #3 is F3 is "k3" |
7 | 5995 src += 2; |
5996 } | |
5997 | |
5998 /* | |
5999 * Copy each byte from *from to result[dlen] | |
6000 */ | |
6001 while (*src != NUL) | |
6002 { | |
6003 /* | |
6004 * 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
|
6005 * like "<C-S-LeftMouse>" |
7 | 6006 */ |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
6007 if (do_special && ((flags & REPTERM_DO_LT) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
6008 || STRNCMP(src, "<lt>", 4) != 0)) |
7 | 6009 { |
6010 #ifdef FEAT_EVAL | |
6011 /* | |
6012 * Replace <SID> by K_SNR <script-nr> _. | |
6013 * (room: 5 * 6 = 30 bytes; needed: 3 + <nr> + 1 <= 14) | |
6014 */ | |
6015 if (STRNICMP(src, "<SID>", 5) == 0) | |
6016 { | |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14581
diff
changeset
|
6017 if (current_sctx.sc_sid <= 0) |
26439
b18f3b0f317c
patch 8.2.3750: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
6018 emsg(_(e_using_sid_not_in_script_context)); |
7 | 6019 else |
6020 { | |
6021 src += 5; | |
6022 result[dlen++] = K_SPECIAL; | |
6023 result[dlen++] = (int)KS_EXTRA; | |
6024 result[dlen++] = (int)KE_SNR; | |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14581
diff
changeset
|
6025 sprintf((char *)result + dlen, "%ld", |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14581
diff
changeset
|
6026 (long)current_sctx.sc_sid); |
7 | 6027 dlen += (int)STRLEN(result + dlen); |
6028 result[dlen++] = '_'; | |
6029 continue; | |
6030 } | |
6031 } | |
6032 #endif | |
6033 | |
20603
c2570baa2e4c
patch 8.2.0855: GUI tests fail because the test doesn't use a modifier
Bram Moolenaar <Bram@vim.org>
parents:
20591
diff
changeset
|
6034 slen = trans_special(&src, result + dlen, FSK_KEYCODE |
c2570baa2e4c
patch 8.2.0855: GUI tests fail because the test doesn't use a modifier
Bram Moolenaar <Bram@vim.org>
parents:
20591
diff
changeset
|
6035 | ((flags & REPTERM_NO_SIMPLIFY) ? 0 : FSK_SIMPLIFY), |
c2570baa2e4c
patch 8.2.0855: GUI tests fail because the test doesn't use a modifier
Bram Moolenaar <Bram@vim.org>
parents:
20591
diff
changeset
|
6036 did_simplify); |
7 | 6037 if (slen) |
6038 { | |
6039 dlen += slen; | |
6040 continue; | |
6041 } | |
6042 } | |
6043 | |
6044 /* | |
6045 * If 'cpoptions' does not contain 'k', see if it's an actual key-code. | |
6046 * Note that this is also checked after replacing the <> form. | |
6047 * Single character codes are NOT replaced (e.g. ^H or DEL), because | |
6048 * it could be a character in the file. | |
6049 */ | |
6050 if (do_key_code) | |
6051 { | |
6052 i = find_term_bykeys(src); | |
6053 if (i >= 0) | |
6054 { | |
6055 result[dlen++] = K_SPECIAL; | |
6056 result[dlen++] = termcodes[i].name[0]; | |
6057 result[dlen++] = termcodes[i].name[1]; | |
6058 src += termcodes[i].len; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6059 // If terminal code matched, continue after it. |
7 | 6060 continue; |
6061 } | |
6062 } | |
6063 | |
6064 #ifdef FEAT_EVAL | |
6065 if (do_special) | |
6066 { | |
6067 char_u *p, *s, len; | |
6068 | |
6069 /* | |
6070 * Replace <Leader> by the value of "mapleader". | |
6071 * Replace <LocalLeader> by the value of "maplocalleader". | |
6072 * If "mapleader" or "maplocalleader" isn't set use a backslash. | |
6073 */ | |
6074 if (STRNICMP(src, "<Leader>", 8) == 0) | |
6075 { | |
6076 len = 8; | |
6077 p = get_var_value((char_u *)"g:mapleader"); | |
6078 } | |
6079 else if (STRNICMP(src, "<LocalLeader>", 13) == 0) | |
6080 { | |
6081 len = 13; | |
6082 p = get_var_value((char_u *)"g:maplocalleader"); | |
6083 } | |
6084 else | |
6085 { | |
6086 len = 0; | |
6087 p = NULL; | |
6088 } | |
6089 if (len != 0) | |
6090 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6091 // Allow up to 8 * 6 characters for "mapleader". |
7 | 6092 if (p == NULL || *p == NUL || STRLEN(p) > 8 * 6) |
6093 s = (char_u *)"\\"; | |
6094 else | |
6095 s = p; | |
6096 while (*s != NUL) | |
6097 result[dlen++] = *s++; | |
6098 src += len; | |
6099 continue; | |
6100 } | |
6101 } | |
6102 #endif | |
6103 | |
6104 /* | |
6105 * Remove CTRL-V and ignore the next character. | |
6106 * For "from" side the CTRL-V at the end is included, for the "to" | |
6107 * part it is removed. | |
6108 * If 'cpoptions' does not contain 'B', also accept a backslash. | |
6109 */ | |
6110 key = *src; | |
6111 if (key == Ctrl_V || (do_backslash && key == '\\')) | |
6112 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6113 ++src; // skip CTRL-V or backslash |
7 | 6114 if (*src == NUL) |
6115 { | |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
6116 if (flags & REPTERM_FROM_PART) |
7 | 6117 result[dlen++] = key; |
6118 break; | |
6119 } | |
6120 } | |
6121 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6122 // skip multibyte char correctly |
474 | 6123 for (i = (*mb_ptr2len)(src); i > 0; --i) |
7 | 6124 { |
6125 /* | |
6126 * If the character is K_SPECIAL, replace it with K_SPECIAL | |
6127 * KS_SPECIAL KE_FILLER. | |
6128 * If compiled with the GUI replace CSI with K_CSI. | |
6129 */ | |
6130 if (*src == K_SPECIAL) | |
6131 { | |
6132 result[dlen++] = K_SPECIAL; | |
6133 result[dlen++] = KS_SPECIAL; | |
6134 result[dlen++] = KE_FILLER; | |
6135 } | |
6136 # ifdef FEAT_GUI | |
6137 else if (*src == CSI) | |
6138 { | |
6139 result[dlen++] = K_SPECIAL; | |
6140 result[dlen++] = KS_EXTRA; | |
6141 result[dlen++] = (int)KE_CSI; | |
6142 } | |
6143 # endif | |
6144 else | |
6145 result[dlen++] = *src; | |
6146 ++src; | |
6147 } | |
6148 } | |
6149 result[dlen] = NUL; | |
6150 | |
6151 /* | |
6152 * Copy the new string to allocated memory. | |
6153 * If this fails, just return from. | |
6154 */ | |
6155 if ((*bufp = vim_strsave(result)) != NULL) | |
6156 from = *bufp; | |
6157 vim_free(result); | |
6158 return from; | |
6159 } | |
6160 | |
6161 /* | |
6162 * Find a termcode with keys 'src' (must be NUL terminated). | |
6163 * Return the index in termcodes[], or -1 if not found. | |
6164 */ | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
6165 static int |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6166 find_term_bykeys(char_u *src) |
7 | 6167 { |
6168 int i; | |
3290 | 6169 int slen = (int)STRLEN(src); |
7 | 6170 |
6171 for (i = 0; i < tc_len; ++i) | |
6172 { | |
3273 | 6173 if (slen == termcodes[i].len |
6174 && STRNCMP(termcodes[i].code, src, (size_t)slen) == 0) | |
7 | 6175 return i; |
6176 } | |
6177 return -1; | |
6178 } | |
6179 | |
6180 /* | |
6181 * Gather the first characters in the terminal key codes into a string. | |
6182 * Used to speed up check_termcode(). | |
6183 */ | |
6184 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6185 gather_termleader(void) |
7 | 6186 { |
6187 int i; | |
6188 int len = 0; | |
6189 | |
6190 #ifdef FEAT_GUI | |
6191 if (gui.in_use) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6192 termleader[len++] = CSI; // the GUI codes are not in termcodes[] |
7 | 6193 #endif |
6194 #ifdef FEAT_TERMRESPONSE | |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
6195 if (check_for_codes || *T_CRS != NUL) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6196 termleader[len++] = DCS; // the termcode response starts with DCS |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6197 // in 8-bit mode |
7 | 6198 #endif |
6199 termleader[len] = NUL; | |
6200 | |
6201 for (i = 0; i < tc_len; ++i) | |
6202 if (vim_strchr(termleader, termcodes[i].code[0]) == NULL) | |
6203 { | |
6204 termleader[len++] = termcodes[i].code[0]; | |
6205 termleader[len] = NUL; | |
6206 } | |
6207 | |
6208 need_gather = FALSE; | |
6209 } | |
6210 | |
6211 /* | |
6212 * Show all termcodes (for ":set termcap") | |
6213 * This code looks a lot like showoptions(), but is different. | |
26400
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26392
diff
changeset
|
6214 * "flags" can have OPT_ONECOLUMN. |
7 | 6215 */ |
6216 void | |
26400
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26392
diff
changeset
|
6217 show_termcodes(int flags) |
7 | 6218 { |
6219 int col; | |
6220 int *items; | |
6221 int item_count; | |
6222 int run; | |
6223 int row, rows; | |
6224 int cols; | |
6225 int i; | |
6226 int len; | |
6227 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6228 #define INC3 27 // try to make three columns |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6229 #define INC2 40 // try to make two columns |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6230 #define GAP 2 // spaces between columns |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6231 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6232 if (tc_len == 0) // no terminal codes (must be GUI) |
7 | 6233 return; |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
6234 items = ALLOC_MULT(int, tc_len); |
7 | 6235 if (items == NULL) |
6236 return; | |
6237 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6238 // Highlight title |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6239 msg_puts_title(_("\n--- Terminal keys ---")); |
7 | 6240 |
6241 /* | |
26400
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26392
diff
changeset
|
6242 * Do the loop three times: |
7 | 6243 * 1. display the short items (non-strings and short strings) |
180 | 6244 * 2. display the medium items (medium length strings) |
6245 * 3. display the long items (remaining strings) | |
26400
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26392
diff
changeset
|
6246 * When "flags" has OPT_ONECOLUMN do everything in 3. |
7 | 6247 */ |
26400
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26392
diff
changeset
|
6248 for (run = (flags & OPT_ONECOLUMN) ? 3 : 1; run <= 3 && !got_int; ++run) |
7 | 6249 { |
6250 /* | |
6251 * collect the items in items[] | |
6252 */ | |
6253 item_count = 0; | |
6254 for (i = 0; i < tc_len; i++) | |
6255 { | |
6256 len = show_one_termcode(termcodes[i].name, | |
6257 termcodes[i].code, FALSE); | |
26400
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26392
diff
changeset
|
6258 if ((flags & OPT_ONECOLUMN) || |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26392
diff
changeset
|
6259 (len <= INC3 - GAP ? run == 1 |
180 | 6260 : len <= INC2 - GAP ? run == 2 |
26400
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26392
diff
changeset
|
6261 : run == 3)) |
7 | 6262 items[item_count++] = i; |
6263 } | |
6264 | |
6265 /* | |
6266 * display the items | |
6267 */ | |
180 | 6268 if (run <= 2) |
7 | 6269 { |
180 | 6270 cols = (Columns + GAP) / (run == 1 ? INC3 : INC2); |
7 | 6271 if (cols == 0) |
6272 cols = 1; | |
6273 rows = (item_count + cols - 1) / cols; | |
6274 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6275 else // run == 3 |
7 | 6276 rows = item_count; |
6277 for (row = 0; row < rows && !got_int; ++row) | |
6278 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6279 msg_putchar('\n'); // go to next line |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6280 if (got_int) // 'q' typed in more |
7 | 6281 break; |
6282 col = 0; | |
6283 for (i = row; i < item_count; i += rows) | |
6284 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6285 msg_col = col; // make columns |
7 | 6286 show_one_termcode(termcodes[items[i]].name, |
6287 termcodes[items[i]].code, TRUE); | |
180 | 6288 if (run == 2) |
6289 col += INC2; | |
6290 else | |
6291 col += INC3; | |
7 | 6292 } |
6293 out_flush(); | |
6294 ui_breakcheck(); | |
6295 } | |
6296 } | |
6297 vim_free(items); | |
6298 } | |
6299 | |
6300 /* | |
6301 * Show one termcode entry. | |
6302 * Output goes into IObuff[] | |
6303 */ | |
6304 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6305 show_one_termcode(char_u *name, char_u *code, int printit) |
7 | 6306 { |
6307 char_u *p; | |
6308 int len; | |
6309 | |
6310 if (name[0] > '~') | |
6311 { | |
6312 IObuff[0] = ' '; | |
6313 IObuff[1] = ' '; | |
6314 IObuff[2] = ' '; | |
6315 IObuff[3] = ' '; | |
6316 } | |
6317 else | |
6318 { | |
6319 IObuff[0] = 't'; | |
6320 IObuff[1] = '_'; | |
6321 IObuff[2] = name[0]; | |
6322 IObuff[3] = name[1]; | |
6323 } | |
6324 IObuff[4] = ' '; | |
6325 | |
6326 p = get_special_key_name(TERMCAP2KEY(name[0], name[1]), 0); | |
6327 if (p[1] != 't') | |
6328 STRCPY(IObuff + 5, p); | |
6329 else | |
6330 IObuff[5] = NUL; | |
6331 len = (int)STRLEN(IObuff); | |
6332 do | |
6333 IObuff[len++] = ' '; | |
6334 while (len < 17); | |
6335 IObuff[len] = NUL; | |
6336 if (code == NULL) | |
6337 len += 4; | |
6338 else | |
6339 len += vim_strsize(code); | |
6340 | |
6341 if (printit) | |
6342 { | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6343 msg_puts((char *)IObuff); |
7 | 6344 if (code == NULL) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6345 msg_puts("NULL"); |
7 | 6346 else |
6347 msg_outtrans(code); | |
6348 } | |
6349 return len; | |
6350 } | |
6351 | |
6352 #if defined(FEAT_TERMRESPONSE) || defined(PROTO) | |
6353 /* | |
6354 * For Xterm >= 140 compiled with OPT_TCAP_QUERY: Obtain the actually used | |
6355 * termcap codes from the terminal itself. | |
6356 * We get them one by one to avoid a very long response string. | |
6357 */ | |
6102 | 6358 static int xt_index_in = 0; |
6359 static int xt_index_out = 0; | |
6360 | |
7 | 6361 static void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6362 req_codes_from_term(void) |
7 | 6363 { |
6364 xt_index_out = 0; | |
6365 xt_index_in = 0; | |
6366 req_more_codes_from_term(); | |
6367 } | |
6368 | |
6369 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6370 req_more_codes_from_term(void) |
7 | 6371 { |
6372 char buf[11]; | |
6373 int old_idx = xt_index_out; | |
6374 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6375 // Don't do anything when going to exit. |
7 | 6376 if (exiting) |
6377 return; | |
6378 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6379 // Send up to 10 more requests out than we received. Avoid sending too |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6380 // many, there can be a buffer overflow somewhere. |
7 | 6381 while (xt_index_out < xt_index_in + 10 && key_names[xt_index_out] != NULL) |
6382 { | |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6383 char *key_name = key_names[xt_index_out]; |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6384 |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
6385 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
6386 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
6387 #endif |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6388 LOG_TR(("Requesting XT %d: %s", xt_index_out, key_name)); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6389 sprintf(buf, "\033P+q%02x%02x\033\\", key_name[0], key_name[1]); |
7 | 6390 out_str_nf((char_u *)buf); |
6391 ++xt_index_out; | |
6392 } | |
6393 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6394 // Send the codes out right away. |
7 | 6395 if (xt_index_out != old_idx) |
6396 out_flush(); | |
6397 } | |
6398 | |
6399 /* | |
6400 * Decode key code response from xterm: '<Esc>P1+r<name>=<string><Esc>\'. | |
6401 * A "0" instead of the "1" indicates a code that isn't supported. | |
6402 * Both <name> and <string> are encoded in hex. | |
6403 * "code" points to the "0" or "1". | |
6404 */ | |
6405 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6406 got_code_from_term(char_u *code, int len) |
7 | 6407 { |
6408 #define XT_LEN 100 | |
6409 char_u name[3]; | |
6410 char_u str[XT_LEN]; | |
6411 int i; | |
6412 int j = 0; | |
6413 int c; | |
6414 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6415 // A '1' means the code is supported, a '0' means it isn't. |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6416 // When half the length is > XT_LEN we can't use it. |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6417 // Our names are currently all 2 characters. |
7 | 6418 if (code[0] == '1' && code[7] == '=' && len / 2 < XT_LEN) |
6419 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6420 // Get the name from the response and find it in the table. |
7 | 6421 name[0] = hexhex2nr(code + 3); |
6422 name[1] = hexhex2nr(code + 5); | |
6423 name[2] = NUL; | |
6424 for (i = 0; key_names[i] != NULL; ++i) | |
6425 { | |
6426 if (STRCMP(key_names[i], name) == 0) | |
6427 { | |
6428 xt_index_in = i; | |
6429 break; | |
6430 } | |
6431 } | |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6432 |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6433 LOG_TR(("Received XT %d: %s", xt_index_in, (char *)name)); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6434 |
7 | 6435 if (key_names[i] != NULL) |
6436 { | |
6437 for (i = 8; (c = hexhex2nr(code + i)) >= 0; i += 2) | |
6438 str[j++] = c; | |
6439 str[j] = NUL; | |
6440 if (name[0] == 'C' && name[1] == 'o') | |
6441 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6442 // Color count is not a key code. |
26670
a77b661439f9
patch 8.2.3864: cannot disable requesting key codes from xterm
Bram Moolenaar <Bram@vim.org>
parents:
26439
diff
changeset
|
6443 may_adjust_color_count(atoi((char *)str)); |
7 | 6444 } |
6445 else | |
6446 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6447 // First delete any existing entry with the same code. |
7 | 6448 i = find_term_bykeys(str); |
6449 if (i >= 0) | |
6450 del_termcode_idx(i); | |
180 | 6451 add_termcode(name, str, ATC_FROM_TERM); |
7 | 6452 } |
6453 } | |
6454 } | |
6455 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6456 // May request more codes now that we received one. |
7 | 6457 ++xt_index_in; |
6458 req_more_codes_from_term(); | |
6459 } | |
6460 | |
6461 /* | |
6462 * Check if there are any unanswered requests and deal with them. | |
6463 * This is called before starting an external program or getting direct | |
6464 * keyboard input. We don't want responses to be send to that program or | |
6465 * handled as typed text. | |
6466 */ | |
6467 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6468 check_for_codes_from_term(void) |
7 | 6469 { |
6470 int c; | |
6471 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6472 // If no codes requested or all are answered, no need to wait. |
7 | 6473 if (xt_index_out == 0 || xt_index_out == xt_index_in) |
6474 return; | |
6475 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6476 // Vgetc() will check for and handle any response. |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6477 // Keep calling vpeekc() until we don't get any responses. |
7 | 6478 ++no_mapping; |
6479 ++allow_keys; | |
6480 for (;;) | |
6481 { | |
6482 c = vpeekc(); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6483 if (c == NUL) // nothing available |
7 | 6484 break; |
6485 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6486 // If a response is recognized it's replaced with K_IGNORE, must read |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6487 // it from the input stream. If there is no K_IGNORE we can't do |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6488 // anything, break here (there might be some responses further on, but |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6489 // we don't want to throw away any typed chars). |
7 | 6490 if (c != K_SPECIAL && c != K_IGNORE) |
6491 break; | |
6492 c = vgetc(); | |
6493 if (c != K_IGNORE) | |
6494 { | |
6495 vungetc(c); | |
6496 break; | |
6497 } | |
6498 } | |
6499 --no_mapping; | |
6500 --allow_keys; | |
6501 } | |
6502 #endif | |
6503 | |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
6504 #if (defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL))) || defined(PROTO) |
7 | 6505 static char ksme_str[20]; |
6506 static char ksmr_str[20]; | |
6507 static char ksmd_str[20]; | |
6508 | |
6509 /* | |
6510 * For Win32 console: update termcap codes for existing console attributes. | |
6511 */ | |
6512 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6513 update_tcap(int attr) |
7 | 6514 { |
6515 struct builtin_term *p; | |
6516 | |
6517 p = find_builtin_term(DEFAULT_TERM); | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
6518 sprintf(ksme_str, "\033|%dm", attr); |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
6519 sprintf(ksmd_str, "\033|%dm", attr | 0x08); // FOREGROUND_INTENSITY |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
6520 sprintf(ksmr_str, "\033|%dm", ((attr & 0x0F) << 4) | ((attr & 0xF0) >> 4)); |
7 | 6521 |
6522 while (p->bt_string != NULL) | |
6523 { | |
6524 if (p->bt_entry == (int)KS_ME) | |
6525 p->bt_string = &ksme_str[0]; | |
6526 else if (p->bt_entry == (int)KS_MR) | |
6527 p->bt_string = &ksmr_str[0]; | |
6528 else if (p->bt_entry == (int)KS_MD) | |
6529 p->bt_string = &ksmd_str[0]; | |
6530 ++p; | |
6531 } | |
6532 } | |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6533 |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6534 # ifdef FEAT_TERMGUICOLORS |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6535 # define KSSIZE 20 |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6536 struct ks_tbl_s |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6537 { |
14806
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6538 int code; // value of KS_ |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6539 char *vtp; // code in vtp mode |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6540 char *vtp2; // code in vtp2 mode |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6541 char buf[KSSIZE]; // save buffer in non-vtp mode |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6542 char vbuf[KSSIZE]; // save buffer in vtp mode |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6543 char v2buf[KSSIZE]; // save buffer in vtp2 mode |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6544 char arr[KSSIZE]; // real buffer |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6545 }; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6546 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6547 static struct ks_tbl_s ks_tbl[] = |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6548 { |
14806
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6549 {(int)KS_ME, "\033|0m", "\033|0m"}, // normal |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6550 {(int)KS_MR, "\033|7m", "\033|7m"}, // reverse |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6551 {(int)KS_MD, "\033|1m", "\033|1m"}, // bold |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6552 {(int)KS_SO, "\033|91m", "\033|91m"}, // standout: bright red text |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6553 {(int)KS_SE, "\033|39m", "\033|39m"}, // standout end: default color |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6554 {(int)KS_CZH, "\033|95m", "\033|95m"}, // italic: bright magenta text |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6555 {(int)KS_CZR, "\033|0m", "\033|0m"}, // italic end |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6556 {(int)KS_US, "\033|4m", "\033|4m"}, // underscore |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6557 {(int)KS_UE, "\033|24m", "\033|24m"}, // underscore end |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6558 # ifdef TERMINFO |
14806
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6559 {(int)KS_CAB, "\033|%p1%db", "\033|%p14%dm"}, // set background color |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6560 {(int)KS_CAF, "\033|%p1%df", "\033|%p13%dm"}, // set foreground color |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
6561 {(int)KS_CS, "\033|%p1%d;%p2%dR", "\033|%p1%d;%p2%dR"}, |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
6562 {(int)KS_CSV, "\033|%p1%d;%p2%dV", "\033|%p1%d;%p2%dV"}, |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6563 # else |
14806
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6564 {(int)KS_CAB, "\033|%db", "\033|4%dm"}, // set background color |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6565 {(int)KS_CAF, "\033|%df", "\033|3%dm"}, // set foreground color |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
6566 {(int)KS_CS, "\033|%d;%dR", "\033|%d;%dR"}, |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
6567 {(int)KS_CSV, "\033|%d;%dV", "\033|%d;%dV"}, |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6568 # endif |
14806
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6569 {(int)KS_CCO, "256", "256"}, // colors |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6570 {(int)KS_NAME} // terminator |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6571 }; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6572 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6573 static struct builtin_term * |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6574 find_first_tcap( |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6575 char_u *name, |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6576 int code) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6577 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6578 struct builtin_term *p; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6579 |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6580 for (p = find_builtin_term(name); p->bt_string != NULL; ++p) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6581 if (p->bt_entry == code) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6582 return p; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6583 return NULL; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6584 } |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6585 # endif |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6586 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6587 /* |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6588 * For Win32 console: replace the sequence immediately after termguicolors. |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6589 */ |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6590 void |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6591 swap_tcap(void) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6592 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6593 # ifdef FEAT_TERMGUICOLORS |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6594 static int init_done = FALSE; |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6595 static int curr_mode; |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6596 struct ks_tbl_s *ks; |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6597 struct builtin_term *bt; |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6598 int mode; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6599 enum |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6600 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6601 CMODEINDEX, |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6602 CMODE24, |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6603 CMODE256 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6604 }; |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6605 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6606 // buffer initialization |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6607 if (!init_done) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6608 { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6609 for (ks = ks_tbl; ks->code != (int)KS_NAME; ks++) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6610 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6611 bt = find_first_tcap(DEFAULT_TERM, ks->code); |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6612 if (bt != NULL) |
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6613 { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6614 STRNCPY(ks->buf, bt->bt_string, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6615 STRNCPY(ks->vbuf, ks->vtp, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6616 STRNCPY(ks->v2buf, ks->vtp2, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6617 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6618 STRNCPY(ks->arr, bt->bt_string, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6619 bt->bt_string = &ks->arr[0]; |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6620 } |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6621 } |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6622 init_done = TRUE; |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6623 curr_mode = CMODEINDEX; |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6624 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6625 |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6626 if (p_tgc) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6627 mode = CMODE24; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6628 else if (t_colors >= 256) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6629 mode = CMODE256; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6630 else |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6631 mode = CMODEINDEX; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6632 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6633 for (ks = ks_tbl; ks->code != (int)KS_NAME; ks++) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6634 { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6635 bt = find_first_tcap(DEFAULT_TERM, ks->code); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6636 if (bt != NULL) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6637 { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6638 switch (curr_mode) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6639 { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6640 case CMODEINDEX: |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6641 STRNCPY(&ks->buf[0], bt->bt_string, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6642 break; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6643 case CMODE24: |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6644 STRNCPY(&ks->vbuf[0], bt->bt_string, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6645 break; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6646 default: |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6647 STRNCPY(&ks->v2buf[0], bt->bt_string, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6648 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6649 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6650 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6651 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6652 if (mode != curr_mode) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6653 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6654 for (ks = ks_tbl; ks->code != (int)KS_NAME; ks++) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6655 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6656 bt = find_first_tcap(DEFAULT_TERM, ks->code); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6657 if (bt != NULL) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6658 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6659 switch (mode) |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6660 { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6661 case CMODEINDEX: |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6662 STRNCPY(bt->bt_string, &ks->buf[0], KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6663 break; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6664 case CMODE24: |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6665 STRNCPY(bt->bt_string, &ks->vbuf[0], KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6666 break; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6667 default: |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6668 STRNCPY(bt->bt_string, &ks->v2buf[0], KSSIZE); |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6669 } |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6670 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6671 } |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6672 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6673 curr_mode = mode; |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6674 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6675 # endif |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6676 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6677 |
7 | 6678 #endif |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6679 |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6680 |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
6681 #if (defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))) || defined(FEAT_TERMINAL) \ |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6682 || defined(PROTO) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6683 static int cube_value[] = { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6684 0x00, 0x5F, 0x87, 0xAF, 0xD7, 0xFF |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6685 }; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6686 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6687 static int grey_ramp[] = { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6688 0x08, 0x12, 0x1C, 0x26, 0x30, 0x3A, 0x44, 0x4E, 0x58, 0x62, 0x6C, 0x76, |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6689 0x80, 0x8A, 0x94, 0x9E, 0xA8, 0xB2, 0xBC, 0xC6, 0xD0, 0xDA, 0xE4, 0xEE |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6690 }; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6691 |
13839
ca8953d36264
patch 8.0.1791: using uint8_t does not work everywhere
Christian Brabandt <cb@256bit.org>
parents:
13827
diff
changeset
|
6692 static char_u ansi_table[16][4] = { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6693 // R G B idx |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6694 { 0, 0, 0, 1}, // black |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6695 {224, 0, 0, 2}, // dark red |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6696 { 0, 224, 0, 3}, // dark green |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6697 {224, 224, 0, 4}, // dark yellow / brown |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6698 { 0, 0, 224, 5}, // dark blue |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6699 {224, 0, 224, 6}, // dark magenta |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6700 { 0, 224, 224, 7}, // dark cyan |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6701 {224, 224, 224, 8}, // light grey |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6702 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6703 {128, 128, 128, 9}, // dark grey |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6704 {255, 64, 64, 10}, // light red |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6705 { 64, 255, 64, 11}, // light green |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6706 {255, 255, 64, 12}, // yellow |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6707 { 64, 64, 255, 13}, // light blue |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6708 {255, 64, 255, 14}, // light magenta |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6709 { 64, 255, 255, 15}, // light cyan |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6710 {255, 255, 255, 16}, // white |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6711 }; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6712 |
20500
03826c672315
patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20450
diff
changeset
|
6713 #define ANSI_INDEX_NONE 0 |
03826c672315
patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20450
diff
changeset
|
6714 |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6715 void |
13839
ca8953d36264
patch 8.0.1791: using uint8_t does not work everywhere
Christian Brabandt <cb@256bit.org>
parents:
13827
diff
changeset
|
6716 cterm_color2rgb(int nr, char_u *r, char_u *g, char_u *b, char_u *ansi_idx) |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6717 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6718 int idx; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6719 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6720 if (nr < 16) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6721 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6722 *r = ansi_table[nr][0]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6723 *g = ansi_table[nr][1]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6724 *b = ansi_table[nr][2]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6725 *ansi_idx = ansi_table[nr][3]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6726 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6727 else if (nr < 232) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6728 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6729 // 216 color cube |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6730 idx = nr - 16; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6731 *r = cube_value[idx / 36 % 6]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6732 *g = cube_value[idx / 6 % 6]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6733 *b = cube_value[idx % 6]; |
20500
03826c672315
patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20450
diff
changeset
|
6734 *ansi_idx = ANSI_INDEX_NONE; |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6735 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6736 else if (nr < 256) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6737 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6738 // 24 grey scale ramp |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6739 idx = nr - 232; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6740 *r = grey_ramp[idx]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6741 *g = grey_ramp[idx]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6742 *b = grey_ramp[idx]; |
20500
03826c672315
patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20450
diff
changeset
|
6743 *ansi_idx = ANSI_INDEX_NONE; |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6744 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6745 else |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6746 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6747 *r = 0; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6748 *g = 0; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6749 *b = 0; |
20500
03826c672315
patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20450
diff
changeset
|
6750 *ansi_idx = ANSI_INDEX_NONE; |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6751 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6752 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6753 #endif |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15852
diff
changeset
|
6754 |
19405
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6755 /* |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6756 * Replace K_BS by <BS> and K_DEL by <DEL> |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6757 */ |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6758 void |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6759 term_replace_bs_del_keycode(char_u *ta_buf, int ta_len, int len) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6760 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6761 int i; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6762 int c; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6763 |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6764 for (i = ta_len; i < ta_len + len; ++i) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6765 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6766 if (ta_buf[i] == CSI && len - i > 2) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6767 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6768 c = TERMCAP2KEY(ta_buf[i + 1], ta_buf[i + 2]); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6769 if (c == K_DEL || c == K_KDEL || c == K_BS) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6770 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6771 mch_memmove(ta_buf + i + 1, ta_buf + i + 3, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6772 (size_t)(len - i - 2)); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6773 if (c == K_DEL || c == K_KDEL) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6774 ta_buf[i] = DEL; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6775 else |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6776 ta_buf[i] = Ctrl_H; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6777 len -= 2; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6778 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6779 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6780 else if (ta_buf[i] == '\r') |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6781 ta_buf[i] = '\n'; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6782 if (has_mbyte) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6783 i += (*mb_ptr2len_len)(ta_buf + i, ta_len + len - i) - 1; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6784 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6785 } |