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