Mercurial > vim
annotate src/term.c @ 23992:faca24acb37f v8.2.2538
patch 8.2.2538: crash when using Python list iterator
Commit: https://github.com/vim/vim/commit/21578271bb717f7ab7b8728e9efa54c3b60ee7e4
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Feb 21 19:12:47 2021 +0100
patch 8.2.2538: crash when using Python list iterator
Problem: Crash when using Python list iterator.
Solution: Increment the list reference count. (closes https://github.com/vim/vim/issues/7886)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 21 Feb 2021 19:15:03 +0100 |
parents | 646ca2893d85 |
children | 1b56d4c75d19 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9939
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 /* | |
10 * | |
11 * term.c: functions for controlling the terminal | |
12 * | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
13 * primitive termcap support for Amiga and Win32 included |
7 | 14 * |
15 * NOTE: padding and variable substitution is not performed, | |
16 * when compiling without HAVE_TGETENT, we use tputs() and tgoto() dummies. | |
17 */ | |
18 | |
19 /* | |
20 * Some systems have a prototype for tgetstr() with (char *) instead of | |
21 * (char **). This define removes that prototype. We include our own prototype | |
22 * below. | |
23 */ | |
24 #define tgetstr tgetstr_defined_wrong | |
16378
3d6b282e2d6e
patch 8.1.1194: typos and small problems in source files
Bram Moolenaar <Bram@vim.org>
parents:
16245
diff
changeset
|
25 |
7 | 26 #include "vim.h" |
27 | |
28 #ifdef HAVE_TGETENT | |
29 # ifdef HAVE_TERMIOS_H | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
30 # include <termios.h> // seems to be required for some Linux |
7 | 31 # endif |
32 # ifdef HAVE_TERMCAP_H | |
33 # include <termcap.h> | |
34 # endif | |
35 | |
36 /* | |
37 * A few linux systems define outfuntype in termcap.h to be used as the third | |
38 * argument for tputs(). | |
39 */ | |
40 # ifdef VMS | |
23408
bdda90ed5f6c
patch 8.2.2247: VMS: various smaller problems
Bram Moolenaar <Bram@vim.org>
parents:
23406
diff
changeset
|
41 # define TPUTSFUNCAST (void (*)(unsigned int)) |
7 | 42 # else |
43 # ifdef HAVE_OUTFUNTYPE | |
44 # define TPUTSFUNCAST (outfuntype) | |
45 # else | |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
46 # define TPUTSFUNCAST (int (*)(int)) |
7 | 47 # endif |
48 # endif | |
49 #endif | |
50 | |
51 #undef tgetstr | |
52 | |
53 /* | |
54 * Here are the builtin termcap entries. They are not stored as complete | |
2823 | 55 * structures with all entries, as such a structure is too big. |
7 | 56 * |
57 * The entries are compact, therefore they normally are included even when | |
58 * HAVE_TGETENT is defined. When HAVE_TGETENT is defined, the builtin entries | |
59 * can be accessed with "builtin_amiga", "builtin_ansi", "builtin_debug", etc. | |
60 * | |
61 * Each termcap is a list of builtin_term structures. It always starts with | |
62 * KS_NAME, which separates the entries. See parse_builtin_tcap() for all | |
63 * details. | |
64 * bt_entry is either a KS_xxx code (>= 0), or a K_xxx code. | |
65 * | |
66 * Entries marked with "guessed" may be wrong. | |
67 */ | |
68 struct builtin_term | |
69 { | |
70 int bt_entry; | |
71 char *bt_string; | |
72 }; | |
73 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
74 // start of keys that are not directly used by Vim but can be mapped |
7 | 75 #define BT_EXTRA_KEYS 0x101 |
76 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
77 static void parse_builtin_tcap(char_u *s); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
78 static void gather_termleader(void); |
7 | 79 #ifdef FEAT_TERMRESPONSE |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
80 static void req_codes_from_term(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
81 static void req_more_codes_from_term(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
82 static void got_code_from_term(char_u *code, int len); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
83 static void check_for_codes_from_term(void); |
7 | 84 #endif |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
85 static void del_termcode_idx(int idx); |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
86 static int find_term_bykeys(char_u *src); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
87 static int term_is_builtin(char_u *name); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
88 static int term_7to8bit(char_u *p); |
7 | 89 |
90 #ifdef HAVE_TGETENT | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
91 static char *tgetent_error(char_u *, char_u *); |
7 | 92 |
93 /* | |
94 * Here is our own prototype for tgetstr(), any prototypes from the include | |
95 * files have been disabled by the define at the start of this file. | |
96 */ | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
97 char *tgetstr(char *, char **); |
7 | 98 |
99 # ifdef FEAT_TERMRESPONSE | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
100 // Change this to "if 1" to debug what happens with termresponse. |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
101 # if 0 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
102 # define DEBUG_TERMRESPONSE |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
103 static void log_tr(const char *fmt, ...); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
104 # define LOG_TR(msg) log_tr msg |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
105 # else |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
106 # define LOG_TR(msg) do { /**/ } while (0) |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
107 # endif |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
108 |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
109 typedef enum { |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
110 STATUS_GET, // send request when switching to RAW mode |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
111 STATUS_SENT, // did send request, checking for response |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
112 STATUS_GOT, // received response |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
113 STATUS_FAIL // timed out |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
114 } request_progress_T; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
115 |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
116 typedef struct { |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
117 request_progress_T tr_progress; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
118 time_t tr_start; // when request was sent, -1 for never |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
119 } termrequest_T; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
120 |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
121 # define TERMREQUEST_INIT {STATUS_GET, -1} |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
122 |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
123 // Request Terminal Version status: |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
124 static termrequest_T crv_status = TERMREQUEST_INIT; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
125 |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
126 // Request Cursor position report: |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
127 static termrequest_T u7_status = TERMREQUEST_INIT; |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
128 |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
129 // Request xterm compatibility check: |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
130 static termrequest_T xcc_status = TERMREQUEST_INIT; |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
131 |
12634
94566ecb55f0
patch 8.0.1195: can't build on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12632
diff
changeset
|
132 # ifdef FEAT_TERMINAL |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
133 // Request foreground color report: |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
134 static termrequest_T rfg_status = TERMREQUEST_INIT; |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
135 static int fg_r = 0; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
136 static int fg_g = 0; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
137 static int fg_b = 0; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
138 static int bg_r = 255; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
139 static int bg_g = 255; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
140 static int bg_b = 255; |
12634
94566ecb55f0
patch 8.0.1195: can't build on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12632
diff
changeset
|
141 # endif |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
142 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
143 // Request background color report: |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
144 static termrequest_T rbg_status = TERMREQUEST_INIT; |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
145 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
146 // Request cursor blinking mode report: |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
147 static termrequest_T rbm_status = TERMREQUEST_INIT; |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
148 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
149 // Request cursor style report: |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
150 static termrequest_T rcs_status = TERMREQUEST_INIT; |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
151 |
19195
2ef19eed524a
patch 8.2.0156: various typos in source files and tests
Bram Moolenaar <Bram@vim.org>
parents:
19178
diff
changeset
|
152 // Request window's position report: |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
153 static termrequest_T winpos_status = TERMREQUEST_INIT; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
154 |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
155 static termrequest_T *all_termrequests[] = { |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
156 &crv_status, |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
157 &u7_status, |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
158 &xcc_status, |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
159 # ifdef FEAT_TERMINAL |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
160 &rfg_status, |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
161 # endif |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
162 &rbg_status, |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
163 &rbm_status, |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
164 &rcs_status, |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
165 &winpos_status, |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
166 NULL |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
167 }; |
7 | 168 # endif |
169 | |
170 /* | |
171 * Don't declare these variables if termcap.h contains them. | |
172 * Autoconf checks if these variables should be declared extern (not all | |
173 * systems have them). | |
174 * Some versions define ospeed to be speed_t, but that is incompatible with | |
175 * BSD, where ospeed is short and speed_t is long. | |
176 */ | |
177 # ifndef HAVE_OSPEED | |
178 # ifdef OSPEED_EXTERN | |
179 extern short ospeed; | |
180 # else | |
181 short ospeed; | |
182 # endif | |
183 # endif | |
184 # ifndef HAVE_UP_BC_PC | |
185 # ifdef UP_BC_PC_EXTERN | |
186 extern char *UP, *BC, PC; | |
187 # else | |
188 char *UP, *BC, PC; | |
189 # endif | |
190 # endif | |
191 | |
192 # define TGETSTR(s, p) vim_tgetstr((s), (p)) | |
193 # define TGETENT(b, t) tgetent((char *)(b), (char *)(t)) | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
194 static char_u *vim_tgetstr(char *s, char_u **pp); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
195 #endif // HAVE_TGETENT |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
196 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
197 static int detected_8bit = FALSE; // detected 8-bit terminal |
7 | 198 |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
199 #if (defined(UNIX) || defined(VMS)) |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
200 static int focus_mode = FALSE; // xterm's "focus reporting" availability |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
201 static int focus_state = FALSE; // TRUE if the terminal window gains focus |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
202 #endif |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
203 |
12184
76fbd85c3cea
patch 8.0.0972: compiler warnings for unused variables
Christian Brabandt <cb@256bit.org>
parents:
12174
diff
changeset
|
204 #ifdef FEAT_TERMRESPONSE |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
205 // When the cursor shape was detected these values are used: |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
206 // 1: block, 2: underline, 3: vertical bar |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
207 static int initial_cursor_shape = 0; |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
208 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
209 // The blink flag from the style response may be inverted from the actual |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
210 // blinking state, xterm XORs the flags. |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
211 static int initial_cursor_shape_blink = FALSE; |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
212 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
213 // The blink flag from the blinking-cursor mode response |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
214 static int initial_cursor_blink = FALSE; |
12184
76fbd85c3cea
patch 8.0.0972: compiler warnings for unused variables
Christian Brabandt <cb@256bit.org>
parents:
12174
diff
changeset
|
215 #endif |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
216 |
298 | 217 static struct builtin_term builtin_termcaps[] = |
7 | 218 { |
219 | |
220 #if defined(FEAT_GUI) | |
221 /* | |
222 * GUI pseudo term-cap. | |
223 */ | |
224 {(int)KS_NAME, "gui"}, | |
225 {(int)KS_CE, IF_EB("\033|$", ESC_STR "|$")}, | |
226 {(int)KS_AL, IF_EB("\033|i", ESC_STR "|i")}, | |
227 # ifdef TERMINFO | |
228 {(int)KS_CAL, IF_EB("\033|%p1%dI", ESC_STR "|%p1%dI")}, | |
229 # else | |
230 {(int)KS_CAL, IF_EB("\033|%dI", ESC_STR "|%dI")}, | |
231 # endif | |
232 {(int)KS_DL, IF_EB("\033|d", ESC_STR "|d")}, | |
233 # ifdef TERMINFO | |
234 {(int)KS_CDL, IF_EB("\033|%p1%dD", ESC_STR "|%p1%dD")}, | |
235 {(int)KS_CS, IF_EB("\033|%p1%d;%p2%dR", ESC_STR "|%p1%d;%p2%dR")}, | |
236 {(int)KS_CSV, IF_EB("\033|%p1%d;%p2%dV", ESC_STR "|%p1%d;%p2%dV")}, | |
237 # else | |
238 {(int)KS_CDL, IF_EB("\033|%dD", ESC_STR "|%dD")}, | |
239 {(int)KS_CS, IF_EB("\033|%d;%dR", ESC_STR "|%d;%dR")}, | |
240 {(int)KS_CSV, IF_EB("\033|%d;%dV", ESC_STR "|%d;%dV")}, | |
241 # endif | |
242 {(int)KS_CL, IF_EB("\033|C", ESC_STR "|C")}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
243 // attributes switched on with 'h', off with * 'H' |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
244 {(int)KS_ME, IF_EB("\033|31H", ESC_STR "|31H")}, // HL_ALL |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
245 {(int)KS_MR, IF_EB("\033|1h", ESC_STR "|1h")}, // HL_INVERSE |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
246 {(int)KS_MD, IF_EB("\033|2h", ESC_STR "|2h")}, // HL_BOLD |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
247 {(int)KS_SE, IF_EB("\033|16H", ESC_STR "|16H")}, // HL_STANDOUT |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
248 {(int)KS_SO, IF_EB("\033|16h", ESC_STR "|16h")}, // HL_STANDOUT |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
249 {(int)KS_UE, IF_EB("\033|8H", ESC_STR "|8H")}, // HL_UNDERLINE |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
250 {(int)KS_US, IF_EB("\033|8h", ESC_STR "|8h")}, // HL_UNDERLINE |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
251 {(int)KS_UCE, IF_EB("\033|8C", ESC_STR "|8C")}, // HL_UNDERCURL |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
252 {(int)KS_UCS, IF_EB("\033|8c", ESC_STR "|8c")}, // HL_UNDERCURL |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
253 {(int)KS_STE, IF_EB("\033|4C", ESC_STR "|4C")}, // HL_STRIKETHROUGH |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
254 {(int)KS_STS, IF_EB("\033|4c", ESC_STR "|4c")}, // HL_STRIKETHROUGH |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
255 {(int)KS_CZR, IF_EB("\033|4H", ESC_STR "|4H")}, // HL_ITALIC |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
256 {(int)KS_CZH, IF_EB("\033|4h", ESC_STR "|4h")}, // HL_ITALIC |
7 | 257 {(int)KS_VB, IF_EB("\033|f", ESC_STR "|f")}, |
258 {(int)KS_MS, "y"}, | |
259 {(int)KS_UT, "y"}, | |
6602 | 260 {(int)KS_XN, "y"}, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
261 {(int)KS_LE, "\b"}, // cursor-left = BS |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
262 {(int)KS_ND, "\014"}, // cursor-right = CTRL-L |
7 | 263 # ifdef TERMINFO |
264 {(int)KS_CM, IF_EB("\033|%p1%d;%p2%dM", ESC_STR "|%p1%d;%p2%dM")}, | |
265 # else | |
266 {(int)KS_CM, IF_EB("\033|%d;%dM", ESC_STR "|%d;%dM")}, | |
267 # endif | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
268 // there are no key sequences here, the GUI sequences are recognized |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
269 // in check_termcode() |
7 | 270 #endif |
271 | |
272 #ifndef NO_BUILTIN_TCAPS | |
273 | |
274 # if defined(AMIGA) || defined(ALL_BUILTIN_TCAPS) | |
275 /* | |
276 * Amiga console window, default for Amiga | |
277 */ | |
278 {(int)KS_NAME, "amiga"}, | |
279 {(int)KS_CE, "\033[K"}, | |
280 {(int)KS_CD, "\033[J"}, | |
281 {(int)KS_AL, "\033[L"}, | |
282 # ifdef TERMINFO | |
283 {(int)KS_CAL, "\033[%p1%dL"}, | |
284 # else | |
285 {(int)KS_CAL, "\033[%dL"}, | |
286 # endif | |
287 {(int)KS_DL, "\033[M"}, | |
288 # ifdef TERMINFO | |
289 {(int)KS_CDL, "\033[%p1%dM"}, | |
290 # else | |
291 {(int)KS_CDL, "\033[%dM"}, | |
292 # endif | |
293 {(int)KS_CL, "\014"}, | |
294 {(int)KS_VI, "\033[0 p"}, | |
295 {(int)KS_VE, "\033[1 p"}, | |
296 {(int)KS_ME, "\033[0m"}, | |
297 {(int)KS_MR, "\033[7m"}, | |
298 {(int)KS_MD, "\033[1m"}, | |
299 {(int)KS_SE, "\033[0m"}, | |
300 {(int)KS_SO, "\033[33m"}, | |
301 {(int)KS_US, "\033[4m"}, | |
302 {(int)KS_UE, "\033[0m"}, | |
303 {(int)KS_CZH, "\033[3m"}, | |
304 {(int)KS_CZR, "\033[0m"}, | |
22956
9c8af140b2da
patch 8.2.2025: Amiga: Not all colors are used on OS4
Bram Moolenaar <Bram@vim.org>
parents:
22764
diff
changeset
|
305 #if defined(__amigaos4__) || defined(__MORPHOS__) || defined(__AROS__) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
306 {(int)KS_CCO, "8"}, // allow 8 colors |
7 | 307 # ifdef TERMINFO |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
308 {(int)KS_CAB, "\033[4%p1%dm"},// set background color |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
309 {(int)KS_CAF, "\033[3%p1%dm"},// set foreground color |
7 | 310 # else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
311 {(int)KS_CAB, "\033[4%dm"}, // set background color |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
312 {(int)KS_CAF, "\033[3%dm"}, // set foreground color |
7 | 313 # endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
314 {(int)KS_OP, "\033[m"}, // reset colors |
7 | 315 #endif |
316 {(int)KS_MS, "y"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
317 {(int)KS_UT, "y"}, // guessed |
7 | 318 {(int)KS_LE, "\b"}, |
319 # ifdef TERMINFO | |
320 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
321 # else | |
322 {(int)KS_CM, "\033[%i%d;%dH"}, | |
323 # endif | |
324 #if defined(__MORPHOS__) | |
325 {(int)KS_SR, "\033M"}, | |
326 #endif | |
327 # ifdef TERMINFO | |
328 {(int)KS_CRI, "\033[%p1%dC"}, | |
329 # else | |
330 {(int)KS_CRI, "\033[%dC"}, | |
331 # endif | |
332 {K_UP, "\233A"}, | |
333 {K_DOWN, "\233B"}, | |
334 {K_LEFT, "\233D"}, | |
335 {K_RIGHT, "\233C"}, | |
336 {K_S_UP, "\233T"}, | |
337 {K_S_DOWN, "\233S"}, | |
338 {K_S_LEFT, "\233 A"}, | |
339 {K_S_RIGHT, "\233 @"}, | |
340 {K_S_TAB, "\233Z"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
341 {K_F1, "\233\060~"},// some compilers don't dig "\2330" |
7 | 342 {K_F2, "\233\061~"}, |
343 {K_F3, "\233\062~"}, | |
344 {K_F4, "\233\063~"}, | |
345 {K_F5, "\233\064~"}, | |
346 {K_F6, "\233\065~"}, | |
347 {K_F7, "\233\066~"}, | |
348 {K_F8, "\233\067~"}, | |
349 {K_F9, "\233\070~"}, | |
350 {K_F10, "\233\071~"}, | |
351 {K_S_F1, "\233\061\060~"}, | |
352 {K_S_F2, "\233\061\061~"}, | |
353 {K_S_F3, "\233\061\062~"}, | |
354 {K_S_F4, "\233\061\063~"}, | |
355 {K_S_F5, "\233\061\064~"}, | |
356 {K_S_F6, "\233\061\065~"}, | |
357 {K_S_F7, "\233\061\066~"}, | |
358 {K_S_F8, "\233\061\067~"}, | |
359 {K_S_F9, "\233\061\070~"}, | |
360 {K_S_F10, "\233\061\071~"}, | |
361 {K_HELP, "\233?~"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
362 {K_INS, "\233\064\060~"}, // 101 key keyboard |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
363 {K_PAGEUP, "\233\064\061~"}, // 101 key keyboard |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
364 {K_PAGEDOWN, "\233\064\062~"}, // 101 key keyboard |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
365 {K_HOME, "\233\064\064~"}, // 101 key keyboard |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
366 {K_END, "\233\064\065~"}, // 101 key keyboard |
7 | 367 |
368 {BT_EXTRA_KEYS, ""}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
369 {TERMCAP2KEY('#', '2'), "\233\065\064~"}, // shifted home key |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
370 {TERMCAP2KEY('#', '3'), "\233\065\060~"}, // shifted insert key |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
371 {TERMCAP2KEY('*', '7'), "\233\065\065~"}, // shifted end key |
7 | 372 # endif |
373 | |
20591
4411c2b96af9
patch 8.2.0849: BeOS code is not maintained and probably unused
Bram Moolenaar <Bram@vim.org>
parents:
20589
diff
changeset
|
374 # ifdef ALL_BUILTIN_TCAPS |
7 | 375 /* |
20591
4411c2b96af9
patch 8.2.0849: BeOS code is not maintained and probably unused
Bram Moolenaar <Bram@vim.org>
parents:
20589
diff
changeset
|
376 * almost standard ANSI terminal |
7 | 377 */ |
378 {(int)KS_CE, "\033[K"}, | |
379 {(int)KS_CD, "\033[J"}, | |
380 {(int)KS_AL, "\033[L"}, | |
381 # ifdef TERMINFO | |
382 {(int)KS_CAL, "\033[%p1%dL"}, | |
383 # else | |
384 {(int)KS_CAL, "\033[%dL"}, | |
385 # endif | |
386 {(int)KS_DL, "\033[M"}, | |
387 # ifdef TERMINFO | |
388 {(int)KS_CDL, "\033[%p1%dM"}, | |
389 # else | |
390 {(int)KS_CDL, "\033[%dM"}, | |
391 # endif | |
392 {(int)KS_CL, "\033[H\033[2J"}, | |
393 #ifdef notyet | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
394 {(int)KS_VI, "[VI]"}, // cursor invisible, VT320: CSI ? 25 l |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
395 {(int)KS_VE, "[VE]"}, // cursor visible, VT320: CSI ? 25 h |
7 | 396 #endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
397 {(int)KS_ME, "\033[m"}, // normal mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
398 {(int)KS_MR, "\033[7m"}, // reverse |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
399 {(int)KS_MD, "\033[1m"}, // bold |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
400 {(int)KS_SO, "\033[31m"}, // standout mode: red |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
401 {(int)KS_SE, "\033[m"}, // standout end |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
402 {(int)KS_CZH, "\033[35m"}, // italic: purple |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
403 {(int)KS_CZR, "\033[m"}, // italic end |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
404 {(int)KS_US, "\033[4m"}, // underscore mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
405 {(int)KS_UE, "\033[m"}, // underscore end |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
406 {(int)KS_CCO, "8"}, // allow 8 colors |
7 | 407 # ifdef TERMINFO |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
408 {(int)KS_CAB, "\033[4%p1%dm"},// set background color |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
409 {(int)KS_CAF, "\033[3%p1%dm"},// set foreground color |
7 | 410 # else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
411 {(int)KS_CAB, "\033[4%dm"}, // set background color |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
412 {(int)KS_CAF, "\033[3%dm"}, // set foreground color |
7 | 413 # endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
414 {(int)KS_OP, "\033[m"}, // reset colors |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
415 {(int)KS_MS, "y"}, // safe to move cur in reverse mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
416 {(int)KS_UT, "y"}, // guessed |
7 | 417 {(int)KS_LE, "\b"}, |
418 # ifdef TERMINFO | |
419 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
420 # else | |
421 {(int)KS_CM, "\033[%i%d;%dH"}, | |
422 # endif | |
423 {(int)KS_SR, "\033M"}, | |
424 # ifdef TERMINFO | |
425 {(int)KS_CRI, "\033[%p1%dC"}, | |
426 # else | |
427 {(int)KS_CRI, "\033[%dC"}, | |
428 # endif | |
429 | |
430 {K_UP, "\033[A"}, | |
431 {K_DOWN, "\033[B"}, | |
432 {K_LEFT, "\033[D"}, | |
433 {K_RIGHT, "\033[C"}, | |
434 # endif | |
435 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
436 # if defined(UNIX) || defined(ALL_BUILTIN_TCAPS) || defined(SOME_BUILTIN_TCAPS) |
7 | 437 /* |
438 * standard ANSI terminal, default for unix | |
439 */ | |
440 {(int)KS_NAME, "ansi"}, | |
441 {(int)KS_CE, IF_EB("\033[K", ESC_STR "[K")}, | |
442 {(int)KS_AL, IF_EB("\033[L", ESC_STR "[L")}, | |
443 # ifdef TERMINFO | |
444 {(int)KS_CAL, IF_EB("\033[%p1%dL", ESC_STR "[%p1%dL")}, | |
445 # else | |
446 {(int)KS_CAL, IF_EB("\033[%dL", ESC_STR "[%dL")}, | |
447 # endif | |
448 {(int)KS_DL, IF_EB("\033[M", ESC_STR "[M")}, | |
449 # ifdef TERMINFO | |
450 {(int)KS_CDL, IF_EB("\033[%p1%dM", ESC_STR "[%p1%dM")}, | |
451 # else | |
452 {(int)KS_CDL, IF_EB("\033[%dM", ESC_STR "[%dM")}, | |
453 # endif | |
454 {(int)KS_CL, IF_EB("\033[H\033[2J", ESC_STR "[H" ESC_STR_nc "[2J")}, | |
455 {(int)KS_ME, IF_EB("\033[0m", ESC_STR "[0m")}, | |
456 {(int)KS_MR, IF_EB("\033[7m", ESC_STR "[7m")}, | |
457 {(int)KS_MS, "y"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
458 {(int)KS_UT, "y"}, // guessed |
7 | 459 {(int)KS_LE, "\b"}, |
460 # ifdef TERMINFO | |
461 {(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", ESC_STR "[%i%p1%d;%p2%dH")}, | |
462 # else | |
463 {(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")}, | |
464 # endif | |
465 # ifdef TERMINFO | |
466 {(int)KS_CRI, IF_EB("\033[%p1%dC", ESC_STR "[%p1%dC")}, | |
467 # else | |
468 {(int)KS_CRI, IF_EB("\033[%dC", ESC_STR "[%dC")}, | |
469 # endif | |
470 # endif | |
471 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
472 # if defined(ALL_BUILTIN_TCAPS) |
7 | 473 /* |
474 * These codes are valid when nansi.sys or equivalent has been installed. | |
475 * Function keys on a PC are preceded with a NUL. These are converted into | |
476 * K_NUL '\316' in mch_inchar(), because we cannot handle NULs in key codes. | |
477 * CTRL-arrow is used instead of SHIFT-arrow. | |
478 */ | |
479 {(int)KS_NAME, "pcansi"}, | |
480 {(int)KS_DL, "\033[M"}, | |
481 {(int)KS_AL, "\033[L"}, | |
482 {(int)KS_CE, "\033[K"}, | |
483 {(int)KS_CL, "\033[2J"}, | |
484 {(int)KS_ME, "\033[0m"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
485 {(int)KS_MR, "\033[5m"}, // reverse: black on lightgrey |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
486 {(int)KS_MD, "\033[1m"}, // bold: white text |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
487 {(int)KS_SE, "\033[0m"}, // standout end |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
488 {(int)KS_SO, "\033[31m"}, // standout: white on blue |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
489 {(int)KS_CZH, "\033[34;43m"}, // italic mode: blue text on yellow |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
490 {(int)KS_CZR, "\033[0m"}, // italic mode end |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
491 {(int)KS_US, "\033[36;41m"}, // underscore mode: cyan text on red |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
492 {(int)KS_UE, "\033[0m"}, // underscore mode end |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
493 {(int)KS_CCO, "8"}, // allow 8 colors |
7 | 494 # ifdef TERMINFO |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
495 {(int)KS_CAB, "\033[4%p1%dm"},// set background color |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
496 {(int)KS_CAF, "\033[3%p1%dm"},// set foreground color |
7 | 497 # else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
498 {(int)KS_CAB, "\033[4%dm"}, // set background color |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
499 {(int)KS_CAF, "\033[3%dm"}, // set foreground color |
7 | 500 # endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
501 {(int)KS_OP, "\033[0m"}, // reset colors |
7 | 502 {(int)KS_MS, "y"}, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
503 {(int)KS_UT, "y"}, // guessed |
7 | 504 {(int)KS_LE, "\b"}, |
505 # ifdef TERMINFO | |
506 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
507 # else | |
508 {(int)KS_CM, "\033[%i%d;%dH"}, | |
509 # endif | |
510 # ifdef TERMINFO | |
511 {(int)KS_CRI, "\033[%p1%dC"}, | |
512 # else | |
513 {(int)KS_CRI, "\033[%dC"}, | |
514 # endif | |
515 {K_UP, "\316H"}, | |
516 {K_DOWN, "\316P"}, | |
517 {K_LEFT, "\316K"}, | |
518 {K_RIGHT, "\316M"}, | |
519 {K_S_LEFT, "\316s"}, | |
520 {K_S_RIGHT, "\316t"}, | |
521 {K_F1, "\316;"}, | |
522 {K_F2, "\316<"}, | |
523 {K_F3, "\316="}, | |
524 {K_F4, "\316>"}, | |
525 {K_F5, "\316?"}, | |
526 {K_F6, "\316@"}, | |
527 {K_F7, "\316A"}, | |
528 {K_F8, "\316B"}, | |
529 {K_F9, "\316C"}, | |
530 {K_F10, "\316D"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
531 {K_F11, "\316\205"}, // guessed |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
532 {K_F12, "\316\206"}, // guessed |
7 | 533 {K_S_F1, "\316T"}, |
534 {K_S_F2, "\316U"}, | |
535 {K_S_F3, "\316V"}, | |
536 {K_S_F4, "\316W"}, | |
537 {K_S_F5, "\316X"}, | |
538 {K_S_F6, "\316Y"}, | |
539 {K_S_F7, "\316Z"}, | |
540 {K_S_F8, "\316["}, | |
541 {K_S_F9, "\316\\"}, | |
542 {K_S_F10, "\316]"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
543 {K_S_F11, "\316\207"}, // guessed |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
544 {K_S_F12, "\316\210"}, // guessed |
7 | 545 {K_INS, "\316R"}, |
546 {K_DEL, "\316S"}, | |
547 {K_HOME, "\316G"}, | |
548 {K_END, "\316O"}, | |
549 {K_PAGEDOWN, "\316Q"}, | |
550 {K_PAGEUP, "\316I"}, | |
551 # endif | |
552 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15852
diff
changeset
|
553 # if defined(MSWIN) || defined(ALL_BUILTIN_TCAPS) |
7 | 554 /* |
555 * These codes are valid for the Win32 Console . The entries that start with | |
556 * ESC | are translated into console calls in os_win32.c. The function keys | |
557 * are also translated in os_win32.c. | |
558 */ | |
559 {(int)KS_NAME, "win32"}, | |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
560 {(int)KS_CE, "\033|K"}, // clear to end of line |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
561 {(int)KS_AL, "\033|L"}, // add new blank line |
7 | 562 # ifdef TERMINFO |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
563 {(int)KS_CAL, "\033|%p1%dL"}, // add number of new blank lines |
7 | 564 # else |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
565 {(int)KS_CAL, "\033|%dL"}, // add number of new blank lines |
7 | 566 # endif |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
567 {(int)KS_DL, "\033|M"}, // delete line |
7 | 568 # ifdef TERMINFO |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
569 {(int)KS_CDL, "\033|%p1%dM"}, // delete number of lines |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
570 {(int)KS_CSV, "\033|%p1%d;%p2%dV"}, |
7 | 571 # else |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
572 {(int)KS_CDL, "\033|%dM"}, // delete number of lines |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
573 {(int)KS_CSV, "\033|%d;%dV"}, |
7 | 574 # endif |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
575 {(int)KS_CL, "\033|J"}, // clear screen |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
576 {(int)KS_CD, "\033|j"}, // clear to end of display |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
577 {(int)KS_VI, "\033|v"}, // cursor invisible |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
578 {(int)KS_VE, "\033|V"}, // cursor visible |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
579 |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
580 {(int)KS_ME, "\033|0m"}, // normal |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
581 {(int)KS_MR, "\033|112m"}, // reverse: black on lightgray |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
582 {(int)KS_MD, "\033|15m"}, // bold: white on black |
7 | 583 #if 1 |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
584 {(int)KS_SO, "\033|31m"}, // standout: white on blue |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
585 {(int)KS_SE, "\033|0m"}, // standout end |
7 | 586 #else |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
587 {(int)KS_SO, "\033|F"}, // standout: high intensity |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
588 {(int)KS_SE, "\033|f"}, // standout end |
7 | 589 #endif |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
590 {(int)KS_CZH, "\033|225m"}, // italic: blue text on yellow |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
591 {(int)KS_CZR, "\033|0m"}, // italic end |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
592 {(int)KS_US, "\033|67m"}, // underscore: cyan text on red |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
593 {(int)KS_UE, "\033|0m"}, // underscore end |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
594 {(int)KS_CCO, "16"}, // allow 16 colors |
7 | 595 # ifdef TERMINFO |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
596 {(int)KS_CAB, "\033|%p1%db"}, // set background color |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
597 {(int)KS_CAF, "\033|%p1%df"}, // set foreground color |
7 | 598 # else |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
599 {(int)KS_CAB, "\033|%db"}, // set background color |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
600 {(int)KS_CAF, "\033|%df"}, // set foreground color |
7 | 601 # endif |
602 | |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
603 {(int)KS_MS, "y"}, // save to move cur in reverse mode |
7 | 604 {(int)KS_UT, "y"}, |
6602 | 605 {(int)KS_XN, "y"}, |
7 | 606 {(int)KS_LE, "\b"}, |
607 # ifdef TERMINFO | |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
608 {(int)KS_CM, "\033|%i%p1%d;%p2%dH"}, // cursor motion |
7 | 609 # else |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
610 {(int)KS_CM, "\033|%i%d;%dH"}, // cursor motion |
7 | 611 # endif |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
612 {(int)KS_VB, "\033|B"}, // visual bell |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
613 {(int)KS_TI, "\033|S"}, // put terminal in termcap mode |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
614 {(int)KS_TE, "\033|E"}, // out of termcap mode |
7 | 615 # ifdef TERMINFO |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
616 {(int)KS_CS, "\033|%i%p1%d;%p2%dr"}, // scroll region |
7 | 617 # else |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
618 {(int)KS_CS, "\033|%i%d;%dr"}, // scroll region |
7 | 619 # endif |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
620 # ifdef FEAT_TERMGUICOLORS |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
621 {(int)KS_8F, "\033|38;2;%lu;%lu;%lum"}, |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
622 {(int)KS_8B, "\033|48;2;%lu;%lu;%lum"}, |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
623 # endif |
7 | 624 |
625 {K_UP, "\316H"}, | |
626 {K_DOWN, "\316P"}, | |
627 {K_LEFT, "\316K"}, | |
628 {K_RIGHT, "\316M"}, | |
629 {K_S_UP, "\316\304"}, | |
630 {K_S_DOWN, "\316\317"}, | |
631 {K_S_LEFT, "\316\311"}, | |
632 {K_C_LEFT, "\316s"}, | |
633 {K_S_RIGHT, "\316\313"}, | |
634 {K_C_RIGHT, "\316t"}, | |
635 {K_S_TAB, "\316\017"}, | |
636 {K_F1, "\316;"}, | |
637 {K_F2, "\316<"}, | |
638 {K_F3, "\316="}, | |
639 {K_F4, "\316>"}, | |
640 {K_F5, "\316?"}, | |
641 {K_F6, "\316@"}, | |
642 {K_F7, "\316A"}, | |
643 {K_F8, "\316B"}, | |
644 {K_F9, "\316C"}, | |
645 {K_F10, "\316D"}, | |
646 {K_F11, "\316\205"}, | |
647 {K_F12, "\316\206"}, | |
648 {K_S_F1, "\316T"}, | |
649 {K_S_F2, "\316U"}, | |
650 {K_S_F3, "\316V"}, | |
651 {K_S_F4, "\316W"}, | |
652 {K_S_F5, "\316X"}, | |
653 {K_S_F6, "\316Y"}, | |
654 {K_S_F7, "\316Z"}, | |
655 {K_S_F8, "\316["}, | |
656 {K_S_F9, "\316\\"}, | |
657 {K_S_F10, "\316]"}, | |
658 {K_S_F11, "\316\207"}, | |
659 {K_S_F12, "\316\210"}, | |
660 {K_INS, "\316R"}, | |
661 {K_DEL, "\316S"}, | |
662 {K_HOME, "\316G"}, | |
663 {K_S_HOME, "\316\302"}, | |
664 {K_C_HOME, "\316w"}, | |
665 {K_END, "\316O"}, | |
666 {K_S_END, "\316\315"}, | |
667 {K_C_END, "\316u"}, | |
668 {K_PAGEDOWN, "\316Q"}, | |
669 {K_PAGEUP, "\316I"}, | |
670 {K_KPLUS, "\316N"}, | |
671 {K_KMINUS, "\316J"}, | |
672 {K_KMULTIPLY, "\316\067"}, | |
673 {K_K0, "\316\332"}, | |
674 {K_K1, "\316\336"}, | |
675 {K_K2, "\316\342"}, | |
676 {K_K3, "\316\346"}, | |
677 {K_K4, "\316\352"}, | |
678 {K_K5, "\316\356"}, | |
679 {K_K6, "\316\362"}, | |
680 {K_K7, "\316\366"}, | |
681 {K_K8, "\316\372"}, | |
682 {K_K9, "\316\376"}, | |
16182
bed0d7200635
patch 8.1.1096: MS-Windows: cannot distinguish BS and CTRL-H
Bram Moolenaar <Bram@vim.org>
parents:
16058
diff
changeset
|
683 {K_BS, "\316x"}, |
7 | 684 # endif |
685 | |
686 # if defined(VMS) || defined(ALL_BUILTIN_TCAPS) | |
687 /* | |
688 * VT320 is working as an ANSI terminal compatible DEC terminal. | |
689 * (it covers VT1x0, VT2x0 and VT3x0 up to VT320 on VMS as well) | |
690 * TODO:- rewrite ESC[ codes to CSI | |
691 * - keyboard languages (CSI ? 26 n) | |
692 */ | |
693 {(int)KS_NAME, "vt320"}, | |
694 {(int)KS_CE, IF_EB("\033[K", ESC_STR "[K")}, | |
695 {(int)KS_AL, IF_EB("\033[L", ESC_STR "[L")}, | |
696 # ifdef TERMINFO | |
697 {(int)KS_CAL, IF_EB("\033[%p1%dL", ESC_STR "[%p1%dL")}, | |
698 # else | |
699 {(int)KS_CAL, IF_EB("\033[%dL", ESC_STR "[%dL")}, | |
700 # endif | |
701 {(int)KS_DL, IF_EB("\033[M", ESC_STR "[M")}, | |
702 # ifdef TERMINFO | |
703 {(int)KS_CDL, IF_EB("\033[%p1%dM", ESC_STR "[%p1%dM")}, | |
704 # else | |
705 {(int)KS_CDL, IF_EB("\033[%dM", ESC_STR "[%dM")}, | |
706 # endif | |
707 {(int)KS_CL, IF_EB("\033[H\033[2J", ESC_STR "[H" ESC_STR_nc "[2J")}, | |
22 | 708 {(int)KS_CD, IF_EB("\033[J", ESC_STR "[J")}, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
709 {(int)KS_CCO, "8"}, // allow 8 colors |
7 | 710 {(int)KS_ME, IF_EB("\033[0m", ESC_STR "[0m")}, |
711 {(int)KS_MR, IF_EB("\033[7m", ESC_STR "[7m")}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
712 {(int)KS_MD, IF_EB("\033[1m", ESC_STR "[1m")}, // bold mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
713 {(int)KS_SE, IF_EB("\033[22m", ESC_STR "[22m")},// normal mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
714 {(int)KS_UE, IF_EB("\033[24m", ESC_STR "[24m")},// exit underscore mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
715 {(int)KS_US, IF_EB("\033[4m", ESC_STR "[4m")}, // underscore mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
716 {(int)KS_CZH, IF_EB("\033[34;43m", ESC_STR "[34;43m")}, // italic mode: blue text on yellow |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
717 {(int)KS_CZR, IF_EB("\033[0m", ESC_STR "[0m")}, // italic mode end |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
718 {(int)KS_CAB, IF_EB("\033[4%dm", ESC_STR "[4%dm")}, // set background color (ANSI) |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
719 {(int)KS_CAF, IF_EB("\033[3%dm", ESC_STR "[3%dm")}, // set foreground color (ANSI) |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
720 {(int)KS_CSB, IF_EB("\033[102;%dm", ESC_STR "[102;%dm")}, // set screen background color |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
721 {(int)KS_CSF, IF_EB("\033[101;%dm", ESC_STR "[101;%dm")}, // set screen foreground color |
7 | 722 {(int)KS_MS, "y"}, |
723 {(int)KS_UT, "y"}, | |
6602 | 724 {(int)KS_XN, "y"}, |
7 | 725 {(int)KS_LE, "\b"}, |
726 # ifdef TERMINFO | |
727 {(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", | |
728 ESC_STR "[%i%p1%d;%p2%dH")}, | |
729 # else | |
730 {(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")}, | |
731 # endif | |
732 # ifdef TERMINFO | |
733 {(int)KS_CRI, IF_EB("\033[%p1%dC", ESC_STR "[%p1%dC")}, | |
734 # else | |
735 {(int)KS_CRI, IF_EB("\033[%dC", ESC_STR "[%dC")}, | |
736 # endif | |
737 {K_UP, IF_EB("\033[A", ESC_STR "[A")}, | |
738 {K_DOWN, IF_EB("\033[B", ESC_STR "[B")}, | |
739 {K_RIGHT, IF_EB("\033[C", ESC_STR "[C")}, | |
740 {K_LEFT, IF_EB("\033[D", ESC_STR "[D")}, | |
14252
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
741 // Note: cursor key sequences for application cursor mode are omitted, |
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
742 // because they interfere with typed commands: <Esc>OA. |
344 | 743 {K_F1, IF_EB("\033[11~", ESC_STR "[11~")}, |
744 {K_F2, IF_EB("\033[12~", ESC_STR "[12~")}, | |
745 {K_F3, IF_EB("\033[13~", ESC_STR "[13~")}, | |
746 {K_F4, IF_EB("\033[14~", ESC_STR "[14~")}, | |
747 {K_F5, IF_EB("\033[15~", ESC_STR "[15~")}, | |
7 | 748 {K_F6, IF_EB("\033[17~", ESC_STR "[17~")}, |
749 {K_F7, IF_EB("\033[18~", ESC_STR "[18~")}, | |
750 {K_F8, IF_EB("\033[19~", ESC_STR "[19~")}, | |
751 {K_F9, IF_EB("\033[20~", ESC_STR "[20~")}, | |
752 {K_F10, IF_EB("\033[21~", ESC_STR "[21~")}, | |
344 | 753 {K_F11, IF_EB("\033[23~", ESC_STR "[23~")}, |
7 | 754 {K_F12, IF_EB("\033[24~", ESC_STR "[24~")}, |
755 {K_F13, IF_EB("\033[25~", ESC_STR "[25~")}, | |
756 {K_F14, IF_EB("\033[26~", ESC_STR "[26~")}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
757 {K_F15, IF_EB("\033[28~", ESC_STR "[28~")}, // Help |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
758 {K_F16, IF_EB("\033[29~", ESC_STR "[29~")}, // Select |
7 | 759 {K_F17, IF_EB("\033[31~", ESC_STR "[31~")}, |
760 {K_F18, IF_EB("\033[32~", ESC_STR "[32~")}, | |
761 {K_F19, IF_EB("\033[33~", ESC_STR "[33~")}, | |
762 {K_F20, IF_EB("\033[34~", ESC_STR "[34~")}, | |
763 {K_INS, IF_EB("\033[2~", ESC_STR "[2~")}, | |
764 {K_DEL, IF_EB("\033[3~", ESC_STR "[3~")}, | |
765 {K_HOME, IF_EB("\033[1~", ESC_STR "[1~")}, | |
766 {K_END, IF_EB("\033[4~", ESC_STR "[4~")}, | |
767 {K_PAGEUP, IF_EB("\033[5~", ESC_STR "[5~")}, | |
768 {K_PAGEDOWN, IF_EB("\033[6~", ESC_STR "[6~")}, | |
14252
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
769 // These sequences starting with <Esc> O may interfere with what the user |
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
770 // is typing. Remove these if that bothers you. |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
771 {K_KPLUS, IF_EB("\033Ok", ESC_STR "Ok")}, // keypad plus |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
772 {K_KMINUS, IF_EB("\033Om", ESC_STR "Om")}, // keypad minus |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
773 {K_KDIVIDE, IF_EB("\033Oo", ESC_STR "Oo")}, // keypad / |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
774 {K_KMULTIPLY, IF_EB("\033Oj", ESC_STR "Oj")}, // keypad * |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
775 {K_KENTER, IF_EB("\033OM", ESC_STR "OM")}, // keypad Enter |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
776 {K_K0, IF_EB("\033Op", ESC_STR "Op")}, // keypad 0 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
777 {K_K1, IF_EB("\033Oq", ESC_STR "Oq")}, // keypad 1 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
778 {K_K2, IF_EB("\033Or", ESC_STR "Or")}, // keypad 2 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
779 {K_K3, IF_EB("\033Os", ESC_STR "Os")}, // keypad 3 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
780 {K_K4, IF_EB("\033Ot", ESC_STR "Ot")}, // keypad 4 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
781 {K_K5, IF_EB("\033Ou", ESC_STR "Ou")}, // keypad 5 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
782 {K_K6, IF_EB("\033Ov", ESC_STR "Ov")}, // keypad 6 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
783 {K_K7, IF_EB("\033Ow", ESC_STR "Ow")}, // keypad 7 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
784 {K_K8, IF_EB("\033Ox", ESC_STR "Ox")}, // keypad 8 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
785 {K_K9, IF_EB("\033Oy", ESC_STR "Oy")}, // keypad 9 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
786 {K_BS, "\x7f"}, // for some reason 0177 doesn't work |
7 | 787 # endif |
788 | |
21329
bb3f60b0aca0
patch 8.2.1215: Atari MiNT support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
21226
diff
changeset
|
789 # if defined(ALL_BUILTIN_TCAPS) |
7 | 790 /* |
791 * Ordinary vt52 | |
792 */ | |
793 {(int)KS_NAME, "vt52"}, | |
794 {(int)KS_CE, IF_EB("\033K", ESC_STR "K")}, | |
795 {(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
|
796 # ifdef TERMINFO |
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
797 {(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
|
798 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
|
799 # else |
7 | 800 {(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
|
801 # endif |
7 | 802 {(int)KS_LE, "\b"}, |
7264
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
803 {(int)KS_SR, IF_EB("\033I", ESC_STR "I")}, |
7 | 804 {(int)KS_AL, IF_EB("\033L", ESC_STR "L")}, |
805 {(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
|
806 {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
|
807 {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
|
808 {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
|
809 {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
|
810 {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
|
811 {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
|
812 {K_F3, IF_EB("\033R", ESC_STR "R")}, |
7 | 813 {(int)KS_CL, IF_EB("\033H\033J", ESC_STR "H" ESC_STR_nc "J")}, |
814 {(int)KS_MS, "y"}, | |
815 # endif | |
816 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
817 # 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
|
818 {(int)KS_NAME, "xterm"}, |
7 | 819 {(int)KS_CE, IF_EB("\033[K", ESC_STR "[K")}, |
820 {(int)KS_AL, IF_EB("\033[L", ESC_STR "[L")}, | |
821 # ifdef TERMINFO | |
822 {(int)KS_CAL, IF_EB("\033[%p1%dL", ESC_STR "[%p1%dL")}, | |
823 # else | |
824 {(int)KS_CAL, IF_EB("\033[%dL", ESC_STR "[%dL")}, | |
825 # endif | |
826 {(int)KS_DL, IF_EB("\033[M", ESC_STR "[M")}, | |
827 # ifdef TERMINFO | |
828 {(int)KS_CDL, IF_EB("\033[%p1%dM", ESC_STR "[%p1%dM")}, | |
829 # else | |
830 {(int)KS_CDL, IF_EB("\033[%dM", ESC_STR "[%dM")}, | |
831 # endif | |
832 # ifdef TERMINFO | |
833 {(int)KS_CS, IF_EB("\033[%i%p1%d;%p2%dr", | |
834 ESC_STR "[%i%p1%d;%p2%dr")}, | |
835 # else | |
836 {(int)KS_CS, IF_EB("\033[%i%d;%dr", ESC_STR "[%i%d;%dr")}, | |
837 # endif | |
838 {(int)KS_CL, IF_EB("\033[H\033[2J", ESC_STR "[H" ESC_STR_nc "[2J")}, | |
839 {(int)KS_CD, IF_EB("\033[J", ESC_STR "[J")}, | |
840 {(int)KS_ME, IF_EB("\033[m", ESC_STR "[m")}, | |
841 {(int)KS_MR, IF_EB("\033[7m", ESC_STR "[7m")}, | |
842 {(int)KS_MD, IF_EB("\033[1m", ESC_STR "[1m")}, | |
843 {(int)KS_UE, IF_EB("\033[m", ESC_STR "[m")}, | |
844 {(int)KS_US, IF_EB("\033[4m", ESC_STR "[4m")}, | |
12317
2a8890b80923
patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents:
12307
diff
changeset
|
845 {(int)KS_STE, IF_EB("\033[29m", ESC_STR "[29m")}, |
2a8890b80923
patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents:
12307
diff
changeset
|
846 {(int)KS_STS, IF_EB("\033[9m", ESC_STR "[9m")}, |
7 | 847 {(int)KS_MS, "y"}, |
848 {(int)KS_UT, "y"}, | |
849 {(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
|
850 {(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
|
851 {(int)KS_VE, IF_EB("\033[?25h", ESC_STR "[?25h")}, |
12174
c314cd883fcc
patch 8.0.0967: using a terminal may cause the cursor to blink
Christian Brabandt <cb@256bit.org>
parents:
12172
diff
changeset
|
852 {(int)KS_VS, IF_EB("\033[?12h", ESC_STR "[?12h")}, |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
853 {(int)KS_CVS, IF_EB("\033[?12l", ESC_STR "[?12l")}, |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
854 # ifdef TERMINFO |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
855 {(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
|
856 # else |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
857 {(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
|
858 # endif |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
859 {(int)KS_CRC, IF_EB("\033[?12$p", ESC_STR "[?12$p")}, |
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
|
860 {(int)KS_CRS, IF_EB("\033P$q q\033\\", ESC_STR "P$q q" ESC_STR "\\")}, |
7 | 861 # ifdef TERMINFO |
862 {(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", | |
863 ESC_STR "[%i%p1%d;%p2%dH")}, | |
864 # else | |
865 {(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")}, | |
866 # endif | |
867 {(int)KS_SR, IF_EB("\033M", ESC_STR "M")}, | |
868 # ifdef TERMINFO | |
869 {(int)KS_CRI, IF_EB("\033[%p1%dC", ESC_STR "[%p1%dC")}, | |
870 # else | |
871 {(int)KS_CRI, IF_EB("\033[%dC", ESC_STR "[%dC")}, | |
872 # endif | |
873 {(int)KS_KS, IF_EB("\033[?1h\033=", ESC_STR "[?1h" ESC_STR_nc "=")}, | |
874 {(int)KS_KE, IF_EB("\033[?1l\033>", ESC_STR "[?1l" ESC_STR_nc ">")}, | |
875 # ifdef FEAT_XTERM_SAVE | |
876 {(int)KS_TI, IF_EB("\0337\033[?47h", ESC_STR "7" ESC_STR_nc "[?47h")}, | |
19346
0dd8d1291439
patch 8.2.0231: silent system command may clear the screen
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
877 {(int)KS_TE, IF_EB("\033[?47l\0338", |
0dd8d1291439
patch 8.2.0231: silent system command may clear the screen
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
878 ESC_STR_nc "[?47l" ESC_STR_nc "8")}, |
7 | 879 # endif |
18400
f66fee58e7e2
patch 8.1.2194: modifyOtherKeys is not enabled by default
Bram Moolenaar <Bram@vim.org>
parents:
18360
diff
changeset
|
880 {(int)KS_CTI, IF_EB("\033[>4;2m", ESC_STR_nc "[>4;2m")}, |
f66fee58e7e2
patch 8.1.2194: modifyOtherKeys is not enabled by default
Bram Moolenaar <Bram@vim.org>
parents:
18360
diff
changeset
|
881 {(int)KS_CTE, IF_EB("\033[>4;m", ESC_STR_nc "[>4;m")}, |
7 | 882 {(int)KS_CIS, IF_EB("\033]1;", ESC_STR "]1;")}, |
883 {(int)KS_CIE, "\007"}, | |
884 {(int)KS_TS, IF_EB("\033]2;", ESC_STR "]2;")}, | |
885 {(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
|
886 {(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
|
887 {(int)KS_CEC, "\007"}, |
7 | 888 # ifdef TERMINFO |
889 {(int)KS_CWS, IF_EB("\033[8;%p1%d;%p2%dt", | |
890 ESC_STR "[8;%p1%d;%p2%dt")}, | |
891 {(int)KS_CWP, IF_EB("\033[3;%p1%d;%p2%dt", | |
892 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
|
893 {(int)KS_CGP, IF_EB("\033[13t", ESC_STR "[13t")}, |
7 | 894 # else |
895 {(int)KS_CWS, IF_EB("\033[8;%d;%dt", ESC_STR "[8;%d;%dt")}, | |
896 {(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
|
897 {(int)KS_CGP, IF_EB("\033[13t", ESC_STR "[13t")}, |
7 | 898 # endif |
899 {(int)KS_CRV, IF_EB("\033[>c", ESC_STR "[>c")}, | |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
900 {(int)KS_RFG, IF_EB("\033]10;?\007", ESC_STR "]10;?\007")}, |
6874 | 901 {(int)KS_RBG, IF_EB("\033]11;?\007", ESC_STR "]11;?\007")}, |
4215 | 902 {(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
|
903 # ifdef FEAT_TERMGUICOLORS |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
904 // These are printf strings, not terminal codes. |
8985
42eb58c9da92
commit https://github.com/vim/vim/commit/b2fa54a84078e2b8dc3c7c7bfbccf6b75c0788d0
Christian Brabandt <cb@256bit.org>
parents:
8981
diff
changeset
|
905 {(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
|
906 {(int)KS_8B, IF_EB("\033[48;2;%lu;%lu;%lum", ESC_STR "[48;2;%lu;%lu;%lum")}, |
20619
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
907 {(int)KS_8U, IF_EB("\033[58;2;%lu;%lu;%lum", ESC_STR "[58;2;%lu;%lu;%lum")}, |
8985
42eb58c9da92
commit https://github.com/vim/vim/commit/b2fa54a84078e2b8dc3c7c7bfbccf6b75c0788d0
Christian Brabandt <cb@256bit.org>
parents:
8981
diff
changeset
|
908 # endif |
20619
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
909 {(int)KS_CAU, IF_EB("\033[58;5;%dm", ESC_STR "[58;5;%dm")}, |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
910 {(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
|
911 {(int)KS_CBD, IF_EB("\033[?2004l", ESC_STR "[?2004l")}, |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
912 {(int)KS_CST, IF_EB("\033[22;2t", ESC_STR "[22;2t")}, |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
913 {(int)KS_CRT, IF_EB("\033[23;2t", ESC_STR "[23;2t")}, |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
914 {(int)KS_SSI, IF_EB("\033[22;1t", ESC_STR "[22;1t")}, |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
915 {(int)KS_SRI, IF_EB("\033[23;1t", ESC_STR "[23;1t")}, |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
916 # if (defined(UNIX) || defined(VMS)) |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
917 {(int)KS_FD, IF_EB("\033[?1004l", ESC_STR "[?1004l")}, |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
918 {(int)KS_FE, IF_EB("\033[?1004h", ESC_STR "[?1004h")}, |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
919 # endif |
180 | 920 |
921 {K_UP, IF_EB("\033O*A", ESC_STR "O*A")}, | |
922 {K_DOWN, IF_EB("\033O*B", ESC_STR "O*B")}, | |
923 {K_RIGHT, IF_EB("\033O*C", ESC_STR "O*C")}, | |
924 {K_LEFT, IF_EB("\033O*D", ESC_STR "O*D")}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
925 // An extra set of cursor keys for vt100 mode |
23406
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
926 {K_XUP, IF_EB("\033[@;*A", ESC_STR "[@;*A")}, |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
927 {K_XDOWN, IF_EB("\033[@;*B", ESC_STR "[@;*B")}, |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
928 {K_XRIGHT, IF_EB("\033[@;*C", ESC_STR "[@;*C")}, |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
929 {K_XLEFT, IF_EB("\033[@;*D", ESC_STR "[@;*D")}, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
930 // An extra set of function keys for vt100 mode |
180 | 931 {K_XF1, IF_EB("\033O*P", ESC_STR "O*P")}, |
932 {K_XF2, IF_EB("\033O*Q", ESC_STR "O*Q")}, | |
933 {K_XF3, IF_EB("\033O*R", ESC_STR "O*R")}, | |
934 {K_XF4, IF_EB("\033O*S", ESC_STR "O*S")}, | |
179 | 935 {K_F1, IF_EB("\033[11;*~", ESC_STR "[11;*~")}, |
936 {K_F2, IF_EB("\033[12;*~", ESC_STR "[12;*~")}, | |
937 {K_F3, IF_EB("\033[13;*~", ESC_STR "[13;*~")}, | |
938 {K_F4, IF_EB("\033[14;*~", ESC_STR "[14;*~")}, | |
939 {K_F5, IF_EB("\033[15;*~", ESC_STR "[15;*~")}, | |
940 {K_F6, IF_EB("\033[17;*~", ESC_STR "[17;*~")}, | |
941 {K_F7, IF_EB("\033[18;*~", ESC_STR "[18;*~")}, | |
942 {K_F8, IF_EB("\033[19;*~", ESC_STR "[19;*~")}, | |
943 {K_F9, IF_EB("\033[20;*~", ESC_STR "[20;*~")}, | |
944 {K_F10, IF_EB("\033[21;*~", ESC_STR "[21;*~")}, | |
945 {K_F11, IF_EB("\033[23;*~", ESC_STR "[23;*~")}, | |
946 {K_F12, IF_EB("\033[24;*~", ESC_STR "[24;*~")}, | |
7 | 947 {K_S_TAB, IF_EB("\033[Z", ESC_STR "[Z")}, |
179 | 948 {K_HELP, IF_EB("\033[28;*~", ESC_STR "[28;*~")}, |
949 {K_UNDO, IF_EB("\033[26;*~", ESC_STR "[26;*~")}, | |
950 {K_INS, IF_EB("\033[2;*~", ESC_STR "[2;*~")}, | |
951 {K_HOME, IF_EB("\033[1;*H", ESC_STR "[1;*H")}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
952 // {K_S_HOME, IF_EB("\033O2H", ESC_STR "O2H")}, |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
953 // {K_C_HOME, IF_EB("\033O5H", ESC_STR "O5H")}, |
230 | 954 {K_KHOME, IF_EB("\033[1;*~", ESC_STR "[1;*~")}, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
955 {K_XHOME, IF_EB("\033O*H", ESC_STR "O*H")}, // other Home |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
956 {K_ZHOME, IF_EB("\033[7;*~", ESC_STR "[7;*~")}, // other Home |
179 | 957 {K_END, IF_EB("\033[1;*F", ESC_STR "[1;*F")}, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
958 // {K_S_END, IF_EB("\033O2F", ESC_STR "O2F")}, |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
959 // {K_C_END, IF_EB("\033O5F", ESC_STR "O5F")}, |
179 | 960 {K_KEND, IF_EB("\033[4;*~", ESC_STR "[4;*~")}, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
961 {K_XEND, IF_EB("\033O*F", ESC_STR "O*F")}, // other End |
230 | 962 {K_ZEND, IF_EB("\033[8;*~", ESC_STR "[8;*~")}, |
179 | 963 {K_PAGEUP, IF_EB("\033[5;*~", ESC_STR "[5;*~")}, |
964 {K_PAGEDOWN, IF_EB("\033[6;*~", ESC_STR "[6;*~")}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
965 {K_KPLUS, IF_EB("\033O*k", ESC_STR "O*k")}, // keypad plus |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
966 {K_KMINUS, IF_EB("\033O*m", ESC_STR "O*m")}, // keypad minus |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
967 {K_KDIVIDE, IF_EB("\033O*o", ESC_STR "O*o")}, // keypad / |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
968 {K_KMULTIPLY, IF_EB("\033O*j", ESC_STR "O*j")}, // keypad * |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
969 {K_KENTER, IF_EB("\033O*M", ESC_STR "O*M")}, // keypad Enter |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
970 {K_KPOINT, IF_EB("\033O*n", ESC_STR "O*n")}, // keypad . |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
971 {K_K0, IF_EB("\033O*p", ESC_STR "O*p")}, // keypad 0 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
972 {K_K1, IF_EB("\033O*q", ESC_STR "O*q")}, // keypad 1 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
973 {K_K2, IF_EB("\033O*r", ESC_STR "O*r")}, // keypad 2 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
974 {K_K3, IF_EB("\033O*s", ESC_STR "O*s")}, // keypad 3 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
975 {K_K4, IF_EB("\033O*t", ESC_STR "O*t")}, // keypad 4 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
976 {K_K5, IF_EB("\033O*u", ESC_STR "O*u")}, // keypad 5 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
977 {K_K6, IF_EB("\033O*v", ESC_STR "O*v")}, // keypad 6 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
978 {K_K7, IF_EB("\033O*w", ESC_STR "O*w")}, // keypad 7 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
979 {K_K8, IF_EB("\033O*x", ESC_STR "O*x")}, // keypad 8 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
980 {K_K9, IF_EB("\033O*y", ESC_STR "O*y")}, // keypad 9 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
981 {K_KDEL, IF_EB("\033[3;*~", ESC_STR "[3;*~")}, // keypad Del |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
982 {K_PS, IF_EB("\033[200~", ESC_STR "[200~")}, // paste start |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
983 {K_PE, IF_EB("\033[201~", ESC_STR "[201~")}, // paste end |
7 | 984 |
985 {BT_EXTRA_KEYS, ""}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
986 {TERMCAP2KEY('k', '0'), IF_EB("\033[10;*~", ESC_STR "[10;*~")}, // F0 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
987 {TERMCAP2KEY('F', '3'), IF_EB("\033[25;*~", ESC_STR "[25;*~")}, // F13 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
988 // F14 and F15 are missing, because they send the same codes as the undo |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
989 // and help key, although they don't work on all keyboards. |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
990 {TERMCAP2KEY('F', '6'), IF_EB("\033[29;*~", ESC_STR "[29;*~")}, // F16 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
991 {TERMCAP2KEY('F', '7'), IF_EB("\033[31;*~", ESC_STR "[31;*~")}, // F17 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
992 {TERMCAP2KEY('F', '8'), IF_EB("\033[32;*~", ESC_STR "[32;*~")}, // F18 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
993 {TERMCAP2KEY('F', '9'), IF_EB("\033[33;*~", ESC_STR "[33;*~")}, // F19 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
994 {TERMCAP2KEY('F', 'A'), IF_EB("\033[34;*~", ESC_STR "[34;*~")}, // F20 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
995 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
996 {TERMCAP2KEY('F', 'B'), IF_EB("\033[42;*~", ESC_STR "[42;*~")}, // F21 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
997 {TERMCAP2KEY('F', 'C'), IF_EB("\033[43;*~", ESC_STR "[43;*~")}, // F22 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
998 {TERMCAP2KEY('F', 'D'), IF_EB("\033[44;*~", ESC_STR "[44;*~")}, // F23 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
999 {TERMCAP2KEY('F', 'E'), IF_EB("\033[45;*~", ESC_STR "[45;*~")}, // F24 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1000 {TERMCAP2KEY('F', 'F'), IF_EB("\033[46;*~", ESC_STR "[46;*~")}, // F25 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1001 {TERMCAP2KEY('F', 'G'), IF_EB("\033[47;*~", ESC_STR "[47;*~")}, // F26 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1002 {TERMCAP2KEY('F', 'H'), IF_EB("\033[48;*~", ESC_STR "[48;*~")}, // F27 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1003 {TERMCAP2KEY('F', 'I'), IF_EB("\033[49;*~", ESC_STR "[49;*~")}, // F28 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1004 {TERMCAP2KEY('F', 'J'), IF_EB("\033[50;*~", ESC_STR "[50;*~")}, // F29 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1005 {TERMCAP2KEY('F', 'K'), IF_EB("\033[51;*~", ESC_STR "[51;*~")}, // F30 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1006 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1007 {TERMCAP2KEY('F', 'L'), IF_EB("\033[52;*~", ESC_STR "[52;*~")}, // F31 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1008 {TERMCAP2KEY('F', 'M'), IF_EB("\033[53;*~", ESC_STR "[53;*~")}, // F32 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1009 {TERMCAP2KEY('F', 'N'), IF_EB("\033[54;*~", ESC_STR "[54;*~")}, // F33 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1010 {TERMCAP2KEY('F', 'O'), IF_EB("\033[55;*~", ESC_STR "[55;*~")}, // F34 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1011 {TERMCAP2KEY('F', 'P'), IF_EB("\033[56;*~", ESC_STR "[56;*~")}, // F35 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1012 {TERMCAP2KEY('F', 'Q'), IF_EB("\033[57;*~", ESC_STR "[57;*~")}, // F36 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1013 {TERMCAP2KEY('F', 'R'), IF_EB("\033[58;*~", ESC_STR "[58;*~")}, // F37 |
7 | 1014 # endif |
1015 | |
1016 # if defined(UNIX) || defined(ALL_BUILTIN_TCAPS) | |
1017 /* | |
1018 * iris-ansi for Silicon Graphics machines. | |
1019 */ | |
1020 {(int)KS_NAME, "iris-ansi"}, | |
1021 {(int)KS_CE, "\033[K"}, | |
1022 {(int)KS_CD, "\033[J"}, | |
1023 {(int)KS_AL, "\033[L"}, | |
1024 # ifdef TERMINFO | |
1025 {(int)KS_CAL, "\033[%p1%dL"}, | |
1026 # else | |
1027 {(int)KS_CAL, "\033[%dL"}, | |
1028 # endif | |
1029 {(int)KS_DL, "\033[M"}, | |
1030 # ifdef TERMINFO | |
1031 {(int)KS_CDL, "\033[%p1%dM"}, | |
1032 # else | |
1033 {(int)KS_CDL, "\033[%dM"}, | |
1034 # endif | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1035 #if 0 // The scroll region is not working as Vim expects. |
7 | 1036 # ifdef TERMINFO |
1037 {(int)KS_CS, "\033[%i%p1%d;%p2%dr"}, | |
1038 # else | |
1039 {(int)KS_CS, "\033[%i%d;%dr"}, | |
1040 # endif | |
1041 #endif | |
1042 {(int)KS_CL, "\033[H\033[2J"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1043 {(int)KS_VE, "\033[9/y\033[12/y"}, // These aren't documented |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1044 {(int)KS_VS, "\033[10/y\033[=1h\033[=2l"}, // These aren't documented |
7 | 1045 {(int)KS_TI, "\033[=6h"}, |
1046 {(int)KS_TE, "\033[=6l"}, | |
1047 {(int)KS_SE, "\033[21;27m"}, | |
1048 {(int)KS_SO, "\033[1;7m"}, | |
1049 {(int)KS_ME, "\033[m"}, | |
1050 {(int)KS_MR, "\033[7m"}, | |
1051 {(int)KS_MD, "\033[1m"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1052 {(int)KS_CCO, "8"}, // allow 8 colors |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1053 {(int)KS_CZH, "\033[3m"}, // italic mode on |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1054 {(int)KS_CZR, "\033[23m"}, // italic mode off |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1055 {(int)KS_US, "\033[4m"}, // underline on |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1056 {(int)KS_UE, "\033[24m"}, // underline off |
7 | 1057 # ifdef TERMINFO |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1058 {(int)KS_CAB, "\033[4%p1%dm"}, // set background color (ANSI) |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1059 {(int)KS_CAF, "\033[3%p1%dm"}, // set foreground color (ANSI) |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1060 {(int)KS_CSB, "\033[102;%p1%dm"}, // set screen background color |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1061 {(int)KS_CSF, "\033[101;%p1%dm"}, // set screen foreground color |
7 | 1062 # else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1063 {(int)KS_CAB, "\033[4%dm"}, // set background color (ANSI) |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1064 {(int)KS_CAF, "\033[3%dm"}, // set foreground color (ANSI) |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1065 {(int)KS_CSB, "\033[102;%dm"}, // set screen background color |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1066 {(int)KS_CSF, "\033[101;%dm"}, // set screen foreground color |
7 | 1067 # endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1068 {(int)KS_MS, "y"}, // guessed |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1069 {(int)KS_UT, "y"}, // guessed |
7 | 1070 {(int)KS_LE, "\b"}, |
1071 # ifdef TERMINFO | |
1072 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
1073 # else | |
1074 {(int)KS_CM, "\033[%i%d;%dH"}, | |
1075 # endif | |
1076 {(int)KS_SR, "\033M"}, | |
1077 # ifdef TERMINFO | |
1078 {(int)KS_CRI, "\033[%p1%dC"}, | |
1079 # else | |
1080 {(int)KS_CRI, "\033[%dC"}, | |
1081 # endif | |
1082 {(int)KS_CIS, "\033P3.y"}, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1083 {(int)KS_CIE, "\234"}, // ST "String Terminator" |
7 | 1084 {(int)KS_TS, "\033P1.y"}, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1085 {(int)KS_FS, "\234"}, // ST "String Terminator" |
7 | 1086 # ifdef TERMINFO |
1087 {(int)KS_CWS, "\033[203;%p1%d;%p2%d/y"}, | |
1088 {(int)KS_CWP, "\033[205;%p1%d;%p2%d/y"}, | |
1089 # else | |
1090 {(int)KS_CWS, "\033[203;%d;%d/y"}, | |
1091 {(int)KS_CWP, "\033[205;%d;%d/y"}, | |
1092 # endif | |
1093 {K_UP, "\033[A"}, | |
1094 {K_DOWN, "\033[B"}, | |
1095 {K_LEFT, "\033[D"}, | |
1096 {K_RIGHT, "\033[C"}, | |
1097 {K_S_UP, "\033[161q"}, | |
1098 {K_S_DOWN, "\033[164q"}, | |
1099 {K_S_LEFT, "\033[158q"}, | |
1100 {K_S_RIGHT, "\033[167q"}, | |
1101 {K_F1, "\033[001q"}, | |
1102 {K_F2, "\033[002q"}, | |
1103 {K_F3, "\033[003q"}, | |
1104 {K_F4, "\033[004q"}, | |
1105 {K_F5, "\033[005q"}, | |
1106 {K_F6, "\033[006q"}, | |
1107 {K_F7, "\033[007q"}, | |
1108 {K_F8, "\033[008q"}, | |
1109 {K_F9, "\033[009q"}, | |
1110 {K_F10, "\033[010q"}, | |
1111 {K_F11, "\033[011q"}, | |
1112 {K_F12, "\033[012q"}, | |
1113 {K_S_F1, "\033[013q"}, | |
1114 {K_S_F2, "\033[014q"}, | |
1115 {K_S_F3, "\033[015q"}, | |
1116 {K_S_F4, "\033[016q"}, | |
1117 {K_S_F5, "\033[017q"}, | |
1118 {K_S_F6, "\033[018q"}, | |
1119 {K_S_F7, "\033[019q"}, | |
1120 {K_S_F8, "\033[020q"}, | |
1121 {K_S_F9, "\033[021q"}, | |
1122 {K_S_F10, "\033[022q"}, | |
1123 {K_S_F11, "\033[023q"}, | |
1124 {K_S_F12, "\033[024q"}, | |
1125 {K_INS, "\033[139q"}, | |
1126 {K_HOME, "\033[H"}, | |
1127 {K_END, "\033[146q"}, | |
1128 {K_PAGEUP, "\033[150q"}, | |
1129 {K_PAGEDOWN, "\033[154q"}, | |
1130 # endif | |
1131 | |
1132 # if defined(DEBUG) || defined(ALL_BUILTIN_TCAPS) | |
1133 /* | |
1134 * for debugging | |
1135 */ | |
1136 {(int)KS_NAME, "debug"}, | |
1137 {(int)KS_CE, "[CE]"}, | |
1138 {(int)KS_CD, "[CD]"}, | |
1139 {(int)KS_AL, "[AL]"}, | |
1140 # ifdef TERMINFO | |
1141 {(int)KS_CAL, "[CAL%p1%d]"}, | |
1142 # else | |
1143 {(int)KS_CAL, "[CAL%d]"}, | |
1144 # endif | |
1145 {(int)KS_DL, "[DL]"}, | |
1146 # ifdef TERMINFO | |
1147 {(int)KS_CDL, "[CDL%p1%d]"}, | |
1148 # else | |
1149 {(int)KS_CDL, "[CDL%d]"}, | |
1150 # endif | |
1151 # ifdef TERMINFO | |
1152 {(int)KS_CS, "[%p1%dCS%p2%d]"}, | |
1153 # else | |
1154 {(int)KS_CS, "[%dCS%d]"}, | |
1155 # endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12429
diff
changeset
|
1156 # ifdef TERMINFO |
7 | 1157 {(int)KS_CSV, "[%p1%dCSV%p2%d]"}, |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12429
diff
changeset
|
1158 # else |
7 | 1159 {(int)KS_CSV, "[%dCSV%d]"}, |
1160 # endif | |
1161 # ifdef TERMINFO | |
1162 {(int)KS_CAB, "[CAB%p1%d]"}, | |
1163 {(int)KS_CAF, "[CAF%p1%d]"}, | |
1164 {(int)KS_CSB, "[CSB%p1%d]"}, | |
1165 {(int)KS_CSF, "[CSF%p1%d]"}, | |
1166 # else | |
1167 {(int)KS_CAB, "[CAB%d]"}, | |
1168 {(int)KS_CAF, "[CAF%d]"}, | |
1169 {(int)KS_CSB, "[CSB%d]"}, | |
1170 {(int)KS_CSF, "[CSF%d]"}, | |
1171 # endif | |
20619
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
1172 {(int)KS_CAU, "[CAU%d]"}, |
7 | 1173 {(int)KS_OP, "[OP]"}, |
1174 {(int)KS_LE, "[LE]"}, | |
1175 {(int)KS_CL, "[CL]"}, | |
1176 {(int)KS_VI, "[VI]"}, | |
1177 {(int)KS_VE, "[VE]"}, | |
1178 {(int)KS_VS, "[VS]"}, | |
1179 {(int)KS_ME, "[ME]"}, | |
1180 {(int)KS_MR, "[MR]"}, | |
1181 {(int)KS_MB, "[MB]"}, | |
1182 {(int)KS_MD, "[MD]"}, | |
1183 {(int)KS_SE, "[SE]"}, | |
1184 {(int)KS_SO, "[SO]"}, | |
1185 {(int)KS_UE, "[UE]"}, | |
1186 {(int)KS_US, "[US]"}, | |
205 | 1187 {(int)KS_UCE, "[UCE]"}, |
1188 {(int)KS_UCS, "[UCS]"}, | |
12317
2a8890b80923
patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents:
12307
diff
changeset
|
1189 {(int)KS_STE, "[STE]"}, |
2a8890b80923
patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents:
12307
diff
changeset
|
1190 {(int)KS_STS, "[STS]"}, |
7 | 1191 {(int)KS_MS, "[MS]"}, |
1192 {(int)KS_UT, "[UT]"}, | |
6602 | 1193 {(int)KS_XN, "[XN]"}, |
7 | 1194 # ifdef TERMINFO |
1195 {(int)KS_CM, "[%p1%dCM%p2%d]"}, | |
1196 # else | |
1197 {(int)KS_CM, "[%dCM%d]"}, | |
1198 # endif | |
1199 {(int)KS_SR, "[SR]"}, | |
1200 # ifdef TERMINFO | |
1201 {(int)KS_CRI, "[CRI%p1%d]"}, | |
1202 # else | |
1203 {(int)KS_CRI, "[CRI%d]"}, | |
1204 # endif | |
1205 {(int)KS_VB, "[VB]"}, | |
1206 {(int)KS_KS, "[KS]"}, | |
1207 {(int)KS_KE, "[KE]"}, | |
1208 {(int)KS_TI, "[TI]"}, | |
1209 {(int)KS_TE, "[TE]"}, | |
1210 {(int)KS_CIS, "[CIS]"}, | |
1211 {(int)KS_CIE, "[CIE]"}, | |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
1212 {(int)KS_CSC, "[CSC]"}, |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
1213 {(int)KS_CEC, "[CEC]"}, |
7 | 1214 {(int)KS_TS, "[TS]"}, |
1215 {(int)KS_FS, "[FS]"}, | |
1216 # ifdef TERMINFO | |
1217 {(int)KS_CWS, "[%p1%dCWS%p2%d]"}, | |
1218 {(int)KS_CWP, "[%p1%dCWP%p2%d]"}, | |
1219 # else | |
1220 {(int)KS_CWS, "[%dCWS%d]"}, | |
1221 {(int)KS_CWP, "[%dCWP%d]"}, | |
1222 # endif | |
1223 {(int)KS_CRV, "[CRV]"}, | |
4215 | 1224 {(int)KS_U7, "[U7]"}, |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
1225 {(int)KS_RFG, "[RFG]"}, |
6874 | 1226 {(int)KS_RBG, "[RBG]"}, |
7 | 1227 {K_UP, "[KU]"}, |
1228 {K_DOWN, "[KD]"}, | |
1229 {K_LEFT, "[KL]"}, | |
1230 {K_RIGHT, "[KR]"}, | |
180 | 1231 {K_XUP, "[xKU]"}, |
1232 {K_XDOWN, "[xKD]"}, | |
1233 {K_XLEFT, "[xKL]"}, | |
1234 {K_XRIGHT, "[xKR]"}, | |
7 | 1235 {K_S_UP, "[S-KU]"}, |
1236 {K_S_DOWN, "[S-KD]"}, | |
1237 {K_S_LEFT, "[S-KL]"}, | |
1238 {K_C_LEFT, "[C-KL]"}, | |
1239 {K_S_RIGHT, "[S-KR]"}, | |
1240 {K_C_RIGHT, "[C-KR]"}, | |
1241 {K_F1, "[F1]"}, | |
1242 {K_XF1, "[xF1]"}, | |
1243 {K_F2, "[F2]"}, | |
1244 {K_XF2, "[xF2]"}, | |
1245 {K_F3, "[F3]"}, | |
1246 {K_XF3, "[xF3]"}, | |
1247 {K_F4, "[F4]"}, | |
1248 {K_XF4, "[xF4]"}, | |
1249 {K_F5, "[F5]"}, | |
1250 {K_F6, "[F6]"}, | |
1251 {K_F7, "[F7]"}, | |
1252 {K_F8, "[F8]"}, | |
1253 {K_F9, "[F9]"}, | |
1254 {K_F10, "[F10]"}, | |
1255 {K_F11, "[F11]"}, | |
1256 {K_F12, "[F12]"}, | |
1257 {K_S_F1, "[S-F1]"}, | |
1258 {K_S_XF1, "[S-xF1]"}, | |
1259 {K_S_F2, "[S-F2]"}, | |
1260 {K_S_XF2, "[S-xF2]"}, | |
1261 {K_S_F3, "[S-F3]"}, | |
1262 {K_S_XF3, "[S-xF3]"}, | |
1263 {K_S_F4, "[S-F4]"}, | |
1264 {K_S_XF4, "[S-xF4]"}, | |
1265 {K_S_F5, "[S-F5]"}, | |
1266 {K_S_F6, "[S-F6]"}, | |
1267 {K_S_F7, "[S-F7]"}, | |
1268 {K_S_F8, "[S-F8]"}, | |
1269 {K_S_F9, "[S-F9]"}, | |
1270 {K_S_F10, "[S-F10]"}, | |
1271 {K_S_F11, "[S-F11]"}, | |
1272 {K_S_F12, "[S-F12]"}, | |
1273 {K_HELP, "[HELP]"}, | |
1274 {K_UNDO, "[UNDO]"}, | |
1275 {K_BS, "[BS]"}, | |
1276 {K_INS, "[INS]"}, | |
1277 {K_KINS, "[KINS]"}, | |
1278 {K_DEL, "[DEL]"}, | |
1279 {K_KDEL, "[KDEL]"}, | |
1280 {K_HOME, "[HOME]"}, | |
1281 {K_S_HOME, "[C-HOME]"}, | |
1282 {K_C_HOME, "[C-HOME]"}, | |
1283 {K_KHOME, "[KHOME]"}, | |
1284 {K_XHOME, "[XHOME]"}, | |
230 | 1285 {K_ZHOME, "[ZHOME]"}, |
7 | 1286 {K_END, "[END]"}, |
1287 {K_S_END, "[C-END]"}, | |
1288 {K_C_END, "[C-END]"}, | |
1289 {K_KEND, "[KEND]"}, | |
1290 {K_XEND, "[XEND]"}, | |
230 | 1291 {K_ZEND, "[ZEND]"}, |
7 | 1292 {K_PAGEUP, "[PAGEUP]"}, |
1293 {K_PAGEDOWN, "[PAGEDOWN]"}, | |
1294 {K_KPAGEUP, "[KPAGEUP]"}, | |
1295 {K_KPAGEDOWN, "[KPAGEDOWN]"}, | |
1296 {K_MOUSE, "[MOUSE]"}, | |
1297 {K_KPLUS, "[KPLUS]"}, | |
1298 {K_KMINUS, "[KMINUS]"}, | |
1299 {K_KDIVIDE, "[KDIVIDE]"}, | |
1300 {K_KMULTIPLY, "[KMULTIPLY]"}, | |
1301 {K_KENTER, "[KENTER]"}, | |
1302 {K_KPOINT, "[KPOINT]"}, | |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
1303 {K_PS, "[PASTE-START]"}, |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
1304 {K_PE, "[PASTE-END]"}, |
7 | 1305 {K_K0, "[K0]"}, |
1306 {K_K1, "[K1]"}, | |
1307 {K_K2, "[K2]"}, | |
1308 {K_K3, "[K3]"}, | |
1309 {K_K4, "[K4]"}, | |
1310 {K_K5, "[K5]"}, | |
1311 {K_K6, "[K6]"}, | |
1312 {K_K7, "[K7]"}, | |
1313 {K_K8, "[K8]"}, | |
1314 {K_K9, "[K9]"}, | |
1315 # endif | |
1316 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1317 #endif // NO_BUILTIN_TCAPS |
7 | 1318 |
1319 /* | |
1320 * The most minimal terminal: only clear screen and cursor positioning | |
1321 * Always included. | |
1322 */ | |
1323 {(int)KS_NAME, "dumb"}, | |
1324 {(int)KS_CL, "\014"}, | |
1325 #ifdef TERMINFO | |
1326 {(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", | |
1327 ESC_STR "[%i%p1%d;%p2%dH")}, | |
1328 #else | |
1329 {(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")}, | |
1330 #endif | |
1331 | |
1332 /* | |
1333 * end marker | |
1334 */ | |
1335 {(int)KS_NAME, NULL} | |
1336 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1337 }; // end of builtin_termcaps |
7 | 1338 |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1339 #if defined(FEAT_TERMGUICOLORS) || defined(PROTO) |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
1340 static guicolor_T |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1341 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
|
1342 { |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
1343 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
|
1344 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1345 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1346 guicolor_T |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1347 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
|
1348 { |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1349 guicolor_T t; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1350 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1351 if (*name == NUL) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1352 return INVALCOLOR; |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1353 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
|
1354 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1355 if (t == INVALCOLOR) |
20524
bed30e6b5a09
patch 8.2.0816: terminal test fails when compiled with Athena
Bram Moolenaar <Bram@vim.org>
parents:
20500
diff
changeset
|
1356 semsg(_(e_alloc_color), name); |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1357 return t; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1358 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1359 |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
1360 guicolor_T |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1361 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
|
1362 { |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
1363 return color; |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1364 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1365 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1366 |
7 | 1367 /* |
1368 * DEFAULT_TERM is used, when no terminal is specified with -T option or $TERM. | |
1369 */ | |
1370 #ifdef AMIGA | |
1371 # define DEFAULT_TERM (char_u *)"amiga" | |
1372 #endif | |
1373 | |
1374 #ifdef MSWIN | |
1375 # define DEFAULT_TERM (char_u *)"win32" | |
1376 #endif | |
1377 | |
21329
bb3f60b0aca0
patch 8.2.1215: Atari MiNT support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
21226
diff
changeset
|
1378 #if defined(UNIX) |
7 | 1379 # define DEFAULT_TERM (char_u *)"ansi" |
1380 #endif | |
1381 | |
1382 #ifdef VMS | |
1383 # define DEFAULT_TERM (char_u *)"vt320" | |
1384 #endif | |
1385 | |
19526
22f0dda71638
patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
19489
diff
changeset
|
1386 #ifdef __HAIKU__ |
22f0dda71638
patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
19489
diff
changeset
|
1387 # undef DEFAULT_TERM |
22f0dda71638
patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
19489
diff
changeset
|
1388 # define DEFAULT_TERM (char_u *)"xterm" |
22f0dda71638
patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
19489
diff
changeset
|
1389 #endif |
22f0dda71638
patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
19489
diff
changeset
|
1390 |
7 | 1391 #ifndef DEFAULT_TERM |
1392 # define DEFAULT_TERM (char_u *)"dumb" | |
1393 #endif | |
1394 | |
1395 /* | |
1396 * Term_strings contains currently used terminal output strings. | |
1397 * It is initialized with the default values by parse_builtin_tcap(). | |
1398 * The values can be changed by setting the option with the same name. | |
1399 */ | |
1400 char_u *(term_strings[(int)KS_LAST + 1]); | |
1401 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1402 static int need_gather = FALSE; // need to fill termleader[] |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1403 static char_u termleader[256 + 1]; // for check_termcode() |
7 | 1404 #ifdef FEAT_TERMRESPONSE |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1405 static int check_for_codes = FALSE; // check for key code response |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1406 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1407 /* |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1408 * Structure and table to store terminal features that can be detected by |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1409 * querying the terminal. Either by inspecting the termresponse or a more |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1410 * specific request. Besides this there are: |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1411 * t_colors - number of colors supported |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1412 */ |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1413 typedef struct { |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1414 char *tpr_name; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1415 int tpr_set_by_termresponse; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1416 int tpr_status; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1417 } termprop_T; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1418 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1419 // Values for tpr_status. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1420 #define TPR_UNKNOWN 'u' |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1421 #define TPR_YES 'y' |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1422 #define TPR_NO 'n' |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1423 #define TPR_MOUSE_XTERM 'x' // use "xterm" for 'ttymouse' |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1424 #define TPR_MOUSE_XTERM2 '2' // use "xterm2" for 'ttymouse' |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1425 #define TPR_MOUSE_SGR 's' // use "sgr" for 'ttymouse' |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1426 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1427 // can request the cursor style without messing up the display |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1428 #define TPR_CURSOR_STYLE 0 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1429 // can request the cursor blink mode without messing up the display |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1430 #define TPR_CURSOR_BLINK 1 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1431 // can set the underline color with t_8u without resetting other colors |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1432 #define TPR_UNDERLINE_RGB 2 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1433 // mouse support - TPR_MOUSE_XTERM, TPR_MOUSE_XTERM2 or TPR_MOUSE_SGR |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1434 #define TPR_MOUSE 3 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1435 // table size |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1436 #define TPR_COUNT 4 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1437 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1438 static termprop_T term_props[TPR_COUNT]; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1439 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1440 /* |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1441 * Initialize the term_props table. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1442 * When "all" is FALSE only set those that are detected from the version |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1443 * response. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1444 */ |
20836
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1445 void |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1446 init_term_props(int all) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1447 { |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1448 int i; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1449 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1450 term_props[TPR_CURSOR_STYLE].tpr_name = "cursor_style"; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1451 term_props[TPR_CURSOR_STYLE].tpr_set_by_termresponse = FALSE; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1452 term_props[TPR_CURSOR_BLINK].tpr_name = "cursor_blink_mode"; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1453 term_props[TPR_CURSOR_BLINK].tpr_set_by_termresponse = FALSE; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1454 term_props[TPR_UNDERLINE_RGB].tpr_name = "underline_rgb"; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1455 term_props[TPR_UNDERLINE_RGB].tpr_set_by_termresponse = TRUE; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1456 term_props[TPR_MOUSE].tpr_name = "mouse"; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1457 term_props[TPR_MOUSE].tpr_set_by_termresponse = TRUE; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1458 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1459 for (i = 0; i < TPR_COUNT; ++i) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1460 if (all || term_props[i].tpr_set_by_termresponse) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1461 term_props[i].tpr_status = TPR_UNKNOWN; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
1462 } |
7 | 1463 #endif |
1464 | |
20836
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1465 #if defined(FEAT_EVAL) || defined(PROTO) |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1466 void |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1467 f_terminalprops(typval_T *argvars UNUSED, typval_T *rettv) |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1468 { |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1469 # ifdef FEAT_TERMRESPONSE |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1470 int i; |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1471 # endif |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1472 |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1473 if (rettv_dict_alloc(rettv) != OK) |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1474 return; |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1475 # ifdef FEAT_TERMRESPONSE |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1476 for (i = 0; i < TPR_COUNT; ++i) |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1477 { |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1478 char_u value[2]; |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1479 |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1480 value[0] = term_props[i].tpr_status; |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1481 value[1] = NUL; |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1482 dict_add_string(rettv->vval.v_dict, term_props[i].tpr_name, value); |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1483 } |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1484 # endif |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1485 } |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1486 #endif |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1487 |
7 | 1488 static struct builtin_term * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1489 find_builtin_term(char_u *term) |
7 | 1490 { |
1491 struct builtin_term *p; | |
1492 | |
1493 p = builtin_termcaps; | |
1494 while (p->bt_string != NULL) | |
1495 { | |
1496 if (p->bt_entry == (int)KS_NAME) | |
1497 { | |
1498 #ifdef UNIX | |
1499 if (STRCMP(p->bt_string, "iris-ansi") == 0 && vim_is_iris(term)) | |
1500 return p; | |
1501 else if (STRCMP(p->bt_string, "xterm") == 0 && vim_is_xterm(term)) | |
1502 return p; | |
1503 else | |
1504 #endif | |
1505 #ifdef VMS | |
1506 if (STRCMP(p->bt_string, "vt320") == 0 && vim_is_vt300(term)) | |
1507 return p; | |
1508 else | |
1509 #endif | |
1510 if (STRCMP(term, p->bt_string) == 0) | |
1511 return p; | |
1512 } | |
1513 ++p; | |
1514 } | |
1515 return p; | |
1516 } | |
1517 | |
1518 /* | |
1519 * Parsing of the builtin termcap entries. | |
1520 * Caller should check if 'name' is a valid builtin term. | |
1521 * The terminal's name is not set, as this is already done in termcapinit(). | |
1522 */ | |
1523 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1524 parse_builtin_tcap(char_u *term) |
7 | 1525 { |
1526 struct builtin_term *p; | |
1527 char_u name[2]; | |
1528 int term_8bit; | |
1529 | |
1530 p = find_builtin_term(term); | |
1531 term_8bit = term_is_8bit(term); | |
1532 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1533 // Do not parse if builtin term not found |
7 | 1534 if (p->bt_string == NULL) |
1535 return; | |
1536 | |
1537 for (++p; p->bt_entry != (int)KS_NAME && p->bt_entry != BT_EXTRA_KEYS; ++p) | |
1538 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1539 if ((int)p->bt_entry >= 0) // KS_xx entry |
7 | 1540 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1541 // Only set the value if it wasn't set yet. |
7 | 1542 if (term_strings[p->bt_entry] == NULL |
1543 || term_strings[p->bt_entry] == empty_option) | |
1544 { | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1545 #ifdef FEAT_EVAL |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1546 int opt_idx = -1; |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1547 #endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1548 // 8bit terminal: use CSI instead of <Esc>[ |
7 | 1549 if (term_8bit && term_7to8bit((char_u *)p->bt_string) != 0) |
1550 { | |
1551 char_u *s, *t; | |
1552 | |
1553 s = vim_strsave((char_u *)p->bt_string); | |
1554 if (s != NULL) | |
1555 { | |
1556 for (t = s; *t; ++t) | |
1557 if (term_7to8bit(t)) | |
1558 { | |
1559 *t = term_7to8bit(t); | |
14321
6bcac243b9de
patch 8.1.0176: overlapping string argument for strcpy()
Christian Brabandt <cb@256bit.org>
parents:
14282
diff
changeset
|
1560 STRMOVE(t + 1, t + 2); |
7 | 1561 } |
1562 term_strings[p->bt_entry] = s; | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1563 #ifdef FEAT_EVAL |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1564 opt_idx = |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1565 #endif |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1566 set_term_option_alloced( |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1567 &term_strings[p->bt_entry]); |
7 | 1568 } |
1569 } | |
1570 else | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1571 { |
7 | 1572 term_strings[p->bt_entry] = (char_u *)p->bt_string; |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1573 #ifdef FEAT_EVAL |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1574 opt_idx = get_term_opt_idx(&term_strings[p->bt_entry]); |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1575 #endif |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1576 } |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1577 #ifdef FEAT_EVAL |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1578 set_term_option_sctx_idx(NULL, opt_idx); |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1579 #endif |
7 | 1580 } |
1581 } | |
1582 else | |
1583 { | |
1584 name[0] = KEY2TERMCAP0((int)p->bt_entry); | |
1585 name[1] = KEY2TERMCAP1((int)p->bt_entry); | |
1586 if (find_termcode(name) == NULL) | |
1587 add_termcode(name, (char_u *)p->bt_string, term_8bit); | |
1588 } | |
1589 } | |
1590 } | |
11739
5c69c6d9e2eb
patch 8.0.0752: build fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11731
diff
changeset
|
1591 |
7 | 1592 /* |
1593 * Set number of colors. | |
1594 * Store it as a number in t_colors. | |
1595 * Store it as a string in T_CCO (using nr_colors[]). | |
1596 */ | |
19997
3d1de9093c01
patch 8.2.0554: the GUI doesn't set t_Co
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
1597 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1598 set_color_count(int nr) |
7 | 1599 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1600 char_u nr_colors[20]; // string for number of colors |
7 | 1601 |
1602 t_colors = nr; | |
1603 if (t_colors > 1) | |
1604 sprintf((char *)nr_colors, "%d", t_colors); | |
1605 else | |
1606 *nr_colors = NUL; | |
694 | 1607 set_string_option_direct((char_u *)"t_Co", -1, nr_colors, OPT_FREE, 0); |
7 | 1608 } |
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
|
1609 |
11739
5c69c6d9e2eb
patch 8.0.0752: build fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11731
diff
changeset
|
1610 #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
|
1611 /* |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1612 * 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
|
1613 */ |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1614 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
|
1615 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
|
1616 { |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1617 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
|
1618 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1619 // Nr of colors changed, initialize highlighting and |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1620 // redraw everything. This causes a redraw, which usually |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1621 // clears the message. Try keeping the message if it |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1622 // might work. |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1623 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
|
1624 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
|
1625 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
|
1626 # 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
|
1627 { |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
1628 int r = redraw_asap(CLEAR); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
1629 |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
1630 log_tr("Received t_Co, redraw_asap(): %d", r); |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1631 } |
20524
bed30e6b5a09
patch 8.2.0816: terminal test fails when compiled with Athena
Bram Moolenaar <Bram@vim.org>
parents:
20500
diff
changeset
|
1632 # else |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1633 redraw_asap(CLEAR); |
20524
bed30e6b5a09
patch 8.2.0816: terminal test fails when compiled with Athena
Bram Moolenaar <Bram@vim.org>
parents:
20500
diff
changeset
|
1634 # endif |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1635 } |
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
|
1636 } |
7 | 1637 #endif |
1638 | |
1639 #ifdef HAVE_TGETENT | |
1640 static char *(key_names[]) = | |
1641 { | |
20524
bed30e6b5a09
patch 8.2.0816: terminal test fails when compiled with Athena
Bram Moolenaar <Bram@vim.org>
parents:
20500
diff
changeset
|
1642 # ifdef FEAT_TERMRESPONSE |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1643 // Do this one first, it may cause a screen redraw. |
7 | 1644 "Co", |
20524
bed30e6b5a09
patch 8.2.0816: terminal test fails when compiled with Athena
Bram Moolenaar <Bram@vim.org>
parents:
20500
diff
changeset
|
1645 # endif |
7 | 1646 "ku", "kd", "kr", "kl", |
1647 "#2", "#4", "%i", "*7", | |
1648 "k1", "k2", "k3", "k4", "k5", "k6", | |
1649 "k7", "k8", "k9", "k;", "F1", "F2", | |
1650 "%1", "&8", "kb", "kI", "kD", "kh", | |
1651 "@7", "kP", "kN", "K1", "K3", "K4", "K5", "kB", | |
1652 NULL | |
1653 }; | |
1654 #endif | |
1655 | |
13874
fc2f175e8169
patch 8.0.1808: can't build without TGETENT
Christian Brabandt <cb@256bit.org>
parents:
13872
diff
changeset
|
1656 #ifdef HAVE_TGETENT |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1657 static void |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1658 get_term_entries(int *height, int *width) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1659 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1660 static struct { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1661 enum SpecialKey dest; // index in term_strings[] |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1662 char *name; // termcap name for string |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1663 } string_names[] = |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1664 { {KS_CE, "ce"}, {KS_AL, "al"}, {KS_CAL,"AL"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1665 {KS_DL, "dl"}, {KS_CDL,"DL"}, {KS_CS, "cs"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1666 {KS_CL, "cl"}, {KS_CD, "cd"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1667 {KS_VI, "vi"}, {KS_VE, "ve"}, {KS_MB, "mb"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1668 {KS_ME, "me"}, {KS_MR, "mr"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1669 {KS_MD, "md"}, {KS_SE, "se"}, {KS_SO, "so"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1670 {KS_CZH,"ZH"}, {KS_CZR,"ZR"}, {KS_UE, "ue"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1671 {KS_US, "us"}, {KS_UCE, "Ce"}, {KS_UCS, "Cs"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1672 {KS_STE,"Te"}, {KS_STS,"Ts"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1673 {KS_CM, "cm"}, {KS_SR, "sr"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1674 {KS_CRI,"RI"}, {KS_VB, "vb"}, {KS_KS, "ks"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1675 {KS_KE, "ke"}, {KS_TI, "ti"}, {KS_TE, "te"}, |
18299
a9cf41bcb5d6
patch 8.1.2144: side effects when using t_ti to enable modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18295
diff
changeset
|
1676 {KS_CTI, "TI"}, {KS_CTE, "TE"}, |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1677 {KS_BC, "bc"}, {KS_CSB,"Sb"}, {KS_CSF,"Sf"}, |
20619
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
1678 {KS_CAB,"AB"}, {KS_CAF,"AF"}, {KS_CAU,"AU"}, |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
1679 {KS_LE, "le"}, |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1680 {KS_ND, "nd"}, {KS_OP, "op"}, {KS_CRV, "RV"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1681 {KS_VS, "vs"}, {KS_CVS, "VS"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1682 {KS_CIS, "IS"}, {KS_CIE, "IE"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1683 {KS_CSC, "SC"}, {KS_CEC, "EC"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1684 {KS_TS, "ts"}, {KS_FS, "fs"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1685 {KS_CWP, "WP"}, {KS_CWS, "WS"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1686 {KS_CSI, "SI"}, {KS_CEI, "EI"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1687 {KS_U7, "u7"}, {KS_RFG, "RF"}, {KS_RBG, "RB"}, |
20619
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
1688 {KS_8F, "8f"}, {KS_8B, "8b"}, {KS_8U, "8u"}, |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1689 {KS_CBE, "BE"}, {KS_CBD, "BD"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1690 {KS_CPS, "PS"}, {KS_CPE, "PE"}, |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
1691 {KS_CST, "ST"}, {KS_CRT, "RT"}, |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
1692 {KS_SSI, "Si"}, {KS_SRI, "Ri"}, |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1693 {(enum SpecialKey)0, NULL} |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1694 }; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1695 int i; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1696 char_u *p; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1697 static char_u tstrbuf[TBUFSZ]; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1698 char_u *tp = tstrbuf; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1699 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1700 /* |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1701 * get output strings |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1702 */ |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1703 for (i = 0; string_names[i].name != NULL; ++i) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1704 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1705 if (TERM_STR(string_names[i].dest) == NULL |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1706 || TERM_STR(string_names[i].dest) == empty_option) |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1707 { |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1708 TERM_STR(string_names[i].dest) = TGETSTR(string_names[i].name, &tp); |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1709 #ifdef FEAT_EVAL |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1710 set_term_option_sctx_idx(string_names[i].name, -1); |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1711 #endif |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1712 } |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1713 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1714 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1715 // tgetflag() returns 1 if the flag is present, 0 if not and |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1716 // possibly -1 if the flag doesn't exist. |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1717 if ((T_MS == NULL || T_MS == empty_option) && tgetflag("ms") > 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1718 T_MS = (char_u *)"y"; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1719 if ((T_XS == NULL || T_XS == empty_option) && tgetflag("xs") > 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1720 T_XS = (char_u *)"y"; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1721 if ((T_XN == NULL || T_XN == empty_option) && tgetflag("xn") > 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1722 T_XN = (char_u *)"y"; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1723 if ((T_DB == NULL || T_DB == empty_option) && tgetflag("db") > 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1724 T_DB = (char_u *)"y"; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1725 if ((T_DA == NULL || T_DA == empty_option) && tgetflag("da") > 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1726 T_DA = (char_u *)"y"; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1727 if ((T_UT == NULL || T_UT == empty_option) && tgetflag("ut") > 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1728 T_UT = (char_u *)"y"; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1729 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1730 /* |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1731 * get key codes |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1732 */ |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1733 for (i = 0; key_names[i] != NULL; ++i) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1734 if (find_termcode((char_u *)key_names[i]) == NULL) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1735 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1736 p = TGETSTR(key_names[i], &tp); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1737 // if cursor-left == backspace, ignore it (televideo 925) |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1738 if (p != NULL |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1739 && (*p != Ctrl_H |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1740 || key_names[i][0] != 'k' |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1741 || key_names[i][1] != 'l')) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1742 add_termcode((char_u *)key_names[i], p, FALSE); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1743 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1744 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1745 if (*height == 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1746 *height = tgetnum("li"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1747 if (*width == 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1748 *width = tgetnum("co"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1749 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1750 /* |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1751 * Get number of colors (if not done already). |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1752 */ |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1753 if (TERM_STR(KS_CCO) == NULL || TERM_STR(KS_CCO) == empty_option) |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1754 { |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1755 set_color_count(tgetnum("Co")); |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1756 #ifdef FEAT_EVAL |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1757 set_term_option_sctx_idx("Co", -1); |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1758 #endif |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1759 } |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1760 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1761 # ifndef hpux |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1762 BC = (char *)TGETSTR("bc", &tp); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1763 UP = (char *)TGETSTR("up", &tp); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1764 p = TGETSTR("pc", &tp); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1765 if (p) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1766 PC = *p; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1767 # endif |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1768 } |
13874
fc2f175e8169
patch 8.0.1808: can't build without TGETENT
Christian Brabandt <cb@256bit.org>
parents:
13872
diff
changeset
|
1769 #endif |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1770 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1771 static void |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
1772 report_term_error(char *error_msg, char_u *term) |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1773 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1774 struct builtin_term *termp; |
21624
1d75baa22d9a
patch 8.2.1362: last entry of ":set term=xxx" overwritten by error message
Bram Moolenaar <Bram@vim.org>
parents:
21329
diff
changeset
|
1775 int i; |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1776 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1777 mch_errmsg("\r\n"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1778 if (error_msg != NULL) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1779 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
1780 mch_errmsg(error_msg); |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1781 mch_errmsg("\r\n"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1782 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1783 mch_errmsg("'"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1784 mch_errmsg((char *)term); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1785 mch_errmsg(_("' not known. Available builtin terminals are:")); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1786 mch_errmsg("\r\n"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1787 for (termp = &(builtin_termcaps[0]); termp->bt_string != NULL; ++termp) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1788 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1789 if (termp->bt_entry == (int)KS_NAME) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1790 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1791 #ifdef HAVE_TGETENT |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1792 mch_errmsg(" builtin_"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1793 #else |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1794 mch_errmsg(" "); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1795 #endif |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1796 mch_errmsg(termp->bt_string); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1797 mch_errmsg("\r\n"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1798 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1799 } |
21624
1d75baa22d9a
patch 8.2.1362: last entry of ":set term=xxx" overwritten by error message
Bram Moolenaar <Bram@vim.org>
parents:
21329
diff
changeset
|
1800 // Output extra 'cmdheight' line breaks to avoid that the following error |
1d75baa22d9a
patch 8.2.1362: last entry of ":set term=xxx" overwritten by error message
Bram Moolenaar <Bram@vim.org>
parents:
21329
diff
changeset
|
1801 // message overwrites the last terminal name. |
1d75baa22d9a
patch 8.2.1362: last entry of ":set term=xxx" overwritten by error message
Bram Moolenaar <Bram@vim.org>
parents:
21329
diff
changeset
|
1802 for (i = 1; i < p_ch; ++i) |
1d75baa22d9a
patch 8.2.1362: last entry of ":set term=xxx" overwritten by error message
Bram Moolenaar <Bram@vim.org>
parents:
21329
diff
changeset
|
1803 mch_errmsg("\r\n"); |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1804 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1805 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1806 static void |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1807 report_default_term(char_u *term) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1808 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1809 mch_errmsg(_("defaulting to '")); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1810 mch_errmsg((char *)term); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1811 mch_errmsg("'\r\n"); |
22742
f7f2d73ff85e
patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Bram Moolenaar <Bram@vim.org>
parents:
22522
diff
changeset
|
1812 if (emsg_silent == 0 && !in_assert_fails) |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1813 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1814 screen_start(); // don't know where cursor is now |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1815 out_flush(); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1816 if (!is_not_a_term()) |
18642
bbea1f108187
patch 8.1.2313: debugging where a delay comes from is not easy
Bram Moolenaar <Bram@vim.org>
parents:
18430
diff
changeset
|
1817 ui_delay(2007L, TRUE); |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1818 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1819 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1820 |
7 | 1821 /* |
1822 * Set terminal options for terminal "term". | |
1823 * Return OK if terminal 'term' was found in a termcap, FAIL otherwise. | |
1824 * | |
1825 * While doing this, until ttest(), some options may be NULL, be careful. | |
1826 */ | |
1827 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1828 set_termname(char_u *term) |
7 | 1829 { |
1830 struct builtin_term *termp; | |
1831 #ifdef HAVE_TGETENT | |
1832 int builtin_first = p_tbi; | |
1833 int try; | |
1834 int termcap_cleared = FALSE; | |
1835 #endif | |
1836 int width = 0, height = 0; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
1837 char *error_msg = NULL; |
7 | 1838 char_u *bs_p, *del_p; |
1839 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1840 // In silect mode (ex -s) we don't use the 'term' option. |
168 | 1841 if (silent_mode) |
1842 return OK; | |
1843 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1844 detected_8bit = FALSE; // reset 8-bit detection |
7 | 1845 |
1846 if (term_is_builtin(term)) | |
1847 { | |
1848 term += 8; | |
1849 #ifdef HAVE_TGETENT | |
1850 builtin_first = 1; | |
1851 #endif | |
1852 } | |
1853 | |
1854 /* | |
1855 * If HAVE_TGETENT is not defined, only the builtin termcap is used, otherwise: | |
1856 * If builtin_first is TRUE: | |
1857 * 0. try builtin termcap | |
1858 * 1. try external termcap | |
1859 * 2. if both fail default to a builtin terminal | |
1860 * If builtin_first is FALSE: | |
1861 * 1. try external termcap | |
1862 * 2. try builtin termcap, if both fail default to a builtin terminal | |
1863 */ | |
1864 #ifdef HAVE_TGETENT | |
1865 for (try = builtin_first ? 0 : 1; try < 3; ++try) | |
1866 { | |
1867 /* | |
1868 * Use external termcap | |
1869 */ | |
1870 if (try == 1) | |
1871 { | |
1872 char_u tbuf[TBUFSZ]; | |
1873 | |
1874 /* | |
1875 * If the external termcap does not have a matching entry, try the | |
1876 * builtin ones. | |
1877 */ | |
1878 if ((error_msg = tgetent_error(tbuf, term)) == NULL) | |
1879 { | |
1880 if (!termcap_cleared) | |
1881 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1882 clear_termoptions(); // clear old options |
7 | 1883 termcap_cleared = TRUE; |
1884 } | |
1885 | |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1886 get_term_entries(&height, &width); |
7 | 1887 } |
1888 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1889 else // try == 0 || try == 2 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1890 #endif // HAVE_TGETENT |
7 | 1891 /* |
1892 * Use builtin termcap | |
1893 */ | |
1894 { | |
1895 #ifdef HAVE_TGETENT | |
1896 /* | |
1897 * If builtin termcap was already used, there is no need to search | |
1898 * for the builtin termcap again, quit now. | |
1899 */ | |
1900 if (try == 2 && builtin_first && termcap_cleared) | |
1901 break; | |
1902 #endif | |
1903 /* | |
1904 * search for 'term' in builtin_termcaps[] | |
1905 */ | |
1906 termp = find_builtin_term(term); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1907 if (termp->bt_string == NULL) // did not find it |
7 | 1908 { |
1909 #ifdef HAVE_TGETENT | |
1910 /* | |
1911 * If try == 0, first try the external termcap. If that is not | |
1912 * found we'll get back here with try == 2. | |
1913 * If termcap_cleared is set we used the external termcap, | |
1914 * don't complain about not finding the term in the builtin | |
1915 * termcap. | |
1916 */ | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1917 if (try == 0) // try external one |
7 | 1918 continue; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1919 if (termcap_cleared) // found in external termcap |
7 | 1920 break; |
1921 #endif | |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1922 report_term_error(error_msg, term); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1923 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1924 // when user typed :set term=xxx, quit here |
7 | 1925 if (starting != NO_SCREEN) |
1926 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1927 screen_start(); // don't know where cursor is now |
7 | 1928 wait_return(TRUE); |
1929 return FAIL; | |
1930 } | |
1931 term = DEFAULT_TERM; | |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1932 report_default_term(term); |
694 | 1933 set_string_option_direct((char_u *)"term", -1, term, |
1934 OPT_FREE, 0); | |
7 | 1935 display_errors(); |
1936 } | |
1937 out_flush(); | |
1938 #ifdef HAVE_TGETENT | |
1939 if (!termcap_cleared) | |
1940 { | |
1941 #endif | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1942 clear_termoptions(); // clear old options |
7 | 1943 #ifdef HAVE_TGETENT |
1944 termcap_cleared = TRUE; | |
1945 } | |
1946 #endif | |
1947 parse_builtin_tcap(term); | |
1948 #ifdef FEAT_GUI | |
1949 if (term_is_gui(term)) | |
1950 { | |
1951 out_flush(); | |
1952 gui_init(); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1953 // If starting the GUI failed, don't do any of the other |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1954 // things for this terminal |
7 | 1955 if (!gui.in_use) |
1956 return FAIL; | |
1957 #ifdef HAVE_TGETENT | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1958 break; // don't try using external termcap |
7 | 1959 #endif |
1960 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1961 #endif // FEAT_GUI |
7 | 1962 } |
1963 #ifdef HAVE_TGETENT | |
1964 } | |
1965 #endif | |
1966 | |
1967 /* | |
1968 * special: There is no info in the termcap about whether the cursor | |
1969 * positioning is relative to the start of the screen or to the start of the | |
1970 * scrolling region. We just guess here. Only msdos pcterm is known to do it | |
1971 * relative. | |
1972 */ | |
1973 if (STRCMP(term, "pcterm") == 0) | |
1974 T_CCS = (char_u *)"yes"; | |
1975 else | |
1976 T_CCS = empty_option; | |
1977 | |
1978 #ifdef UNIX | |
1979 /* | |
1980 * Any "stty" settings override the default for t_kb from the termcap. | |
1981 * This is in os_unix.c, because it depends a lot on the version of unix that | |
1982 * is being used. | |
1983 * Don't do this when the GUI is active, it uses "t_kb" and "t_kD" directly. | |
1984 */ | |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
1985 # ifdef FEAT_GUI |
7 | 1986 if (!gui.in_use) |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
1987 # endif |
7 | 1988 get_stty(); |
1989 #endif | |
1990 | |
1991 /* | |
1992 * If the termcap has no entry for 'bs' and/or 'del' and the ioctl() also | |
1993 * didn't work, use the default CTRL-H | |
1994 * The default for t_kD is DEL, unless t_kb is DEL. | |
1995 * The vim_strsave'd strings are probably lost forever, well it's only two | |
1996 * bytes. Don't do this when the GUI is active, it uses "t_kb" and "t_kD" | |
1997 * directly. | |
1998 */ | |
1999 #ifdef FEAT_GUI | |
2000 if (!gui.in_use) | |
2001 #endif | |
2002 { | |
2003 bs_p = find_termcode((char_u *)"kb"); | |
2004 del_p = find_termcode((char_u *)"kD"); | |
2005 if (bs_p == NULL || *bs_p == NUL) | |
2006 add_termcode((char_u *)"kb", (bs_p = (char_u *)CTRL_H_STR), FALSE); | |
2007 if ((del_p == NULL || *del_p == NUL) && | |
2008 (bs_p == NULL || *bs_p != DEL)) | |
2009 add_termcode((char_u *)"kD", (char_u *)DEL_STR, FALSE); | |
2010 } | |
2011 | |
2012 #if defined(UNIX) || defined(VMS) | |
2013 term_is_xterm = vim_is_xterm(term); | |
2014 #endif | |
18352
94e1a49b879e
patch 8.1.2170: cannot build without the +termresponse feature
Bram Moolenaar <Bram@vim.org>
parents:
18350
diff
changeset
|
2015 #ifdef FEAT_TERMRESPONSE |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
2016 // Reset terminal properties that are set based on the termresponse, which |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
2017 // will be sent out soon. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
2018 init_term_props(FALSE); |
18352
94e1a49b879e
patch 8.1.2170: cannot build without the +termresponse feature
Bram Moolenaar <Bram@vim.org>
parents:
18350
diff
changeset
|
2019 #endif |
7 | 2020 |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
2021 #if defined(UNIX) || defined(VMS) |
7 | 2022 /* |
2023 * For Unix, set the 'ttymouse' option to the type of mouse to be used. | |
2024 * The termcode for the mouse is added as a side effect in option.c. | |
2025 */ | |
2026 { | |
11563
2547bbe6716e
patch 8.0.0664: mouse does not work in tmux
Christian Brabandt <cb@256bit.org>
parents:
11557
diff
changeset
|
2027 char_u *p = (char_u *)""; |
2547bbe6716e
patch 8.0.0664: mouse does not work in tmux
Christian Brabandt <cb@256bit.org>
parents:
11557
diff
changeset
|
2028 |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
2029 # ifdef FEAT_MOUSE_XTERM |
1623 | 2030 if (use_xterm_like_mouse(term)) |
7 | 2031 { |
2032 if (use_xterm_mouse()) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2033 p = NULL; // keep existing value, might be "xterm2" |
7 | 2034 else |
2035 p = (char_u *)"xterm"; | |
2036 } | |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
2037 # endif |
7 | 2038 if (p != NULL) |
3980 | 2039 { |
7 | 2040 set_option_value((char_u *)"ttym", 0L, p, 0); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2041 // Reset the WAS_SET flag, 'ttymouse' can be set to "sgr" or |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2042 // "xterm2" in check_termcode(). |
3980 | 2043 reset_option_was_set((char_u *)"ttym"); |
2044 } | |
7 | 2045 if (p == NULL |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
2046 # ifdef FEAT_GUI |
7 | 2047 || gui.in_use |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
2048 # endif |
7 | 2049 ) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2050 check_mouse_termcode(); // set mouse termcode anyway |
7 | 2051 } |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
2052 #else |
7 | 2053 set_mouse_termcode(KS_MOUSE, (char_u *)"\233M"); |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
2054 #endif |
7 | 2055 |
23632
8da1d91d751c
patch 8.2.2358: wrong #ifdef for use_xterm_like_mouse()
Bram Moolenaar <Bram@vim.org>
parents:
23620
diff
changeset
|
2056 #ifdef FEAT_MOUSE_XTERM |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2057 // focus reporting is supported by xterm compatible terminals and tmux. |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2058 if (use_xterm_like_mouse(term)) |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2059 { |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2060 char_u name[3]; |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2061 |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2062 // handle focus in event |
23632
8da1d91d751c
patch 8.2.2358: wrong #ifdef for use_xterm_like_mouse()
Bram Moolenaar <Bram@vim.org>
parents:
23620
diff
changeset
|
2063 name[0] = KS_EXTRA; |
8da1d91d751c
patch 8.2.2358: wrong #ifdef for use_xterm_like_mouse()
Bram Moolenaar <Bram@vim.org>
parents:
23620
diff
changeset
|
2064 name[1] = KE_FOCUSGAINED; |
8da1d91d751c
patch 8.2.2358: wrong #ifdef for use_xterm_like_mouse()
Bram Moolenaar <Bram@vim.org>
parents:
23620
diff
changeset
|
2065 name[2] = NUL; |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2066 add_termcode(name, (char_u *)"\033[I", FALSE); |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2067 |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2068 // handle focus out event |
23632
8da1d91d751c
patch 8.2.2358: wrong #ifdef for use_xterm_like_mouse()
Bram Moolenaar <Bram@vim.org>
parents:
23620
diff
changeset
|
2069 name[1] = KE_FOCUSLOST; |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2070 add_termcode(name, (char_u *)"\033[O", FALSE); |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2071 |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2072 focus_mode = TRUE; |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2073 focus_state = TRUE; |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2074 } |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2075 #endif |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2076 |
7 | 2077 #ifdef USE_TERM_CONSOLE |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2078 // DEFAULT_TERM indicates that it is the machine console. |
7 | 2079 if (STRCMP(term, DEFAULT_TERM) != 0) |
2080 term_console = FALSE; | |
2081 else | |
2082 { | |
2083 term_console = TRUE; | |
2084 # ifdef AMIGA | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2085 win_resize_on(); // enable window resizing reports |
7 | 2086 # endif |
2087 } | |
2088 #endif | |
2089 | |
2090 #if defined(UNIX) || defined(VMS) | |
2091 /* | |
2092 * 'ttyfast' is default on for xterm, iris-ansi and a few others. | |
2093 */ | |
2094 if (vim_is_fastterm(term)) | |
2095 p_tf = TRUE; | |
2096 #endif | |
2097 #ifdef USE_TERM_CONSOLE | |
2098 /* | |
2099 * 'ttyfast' is default on consoles | |
2100 */ | |
2101 if (term_console) | |
2102 p_tf = TRUE; | |
2103 #endif | |
2104 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2105 ttest(TRUE); // make sure we have a valid set of terminal codes |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2106 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2107 full_screen = TRUE; // we can use termcap codes from now on |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2108 set_term_defaults(); // use current values as defaults |
7 | 2109 #ifdef FEAT_TERMRESPONSE |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
2110 LOG_TR(("setting crv_status to STATUS_GET")); |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2111 crv_status.tr_progress = STATUS_GET; // Get terminal version later |
7 | 2112 #endif |
2113 | |
2114 /* | |
2115 * Initialize the terminal with the appropriate termcap codes. | |
2116 * Set the mouse and window title if possible. | |
2117 * Don't do this when starting, need to parse the .vimrc first, because it | |
2118 * may redefine t_TI etc. | |
2119 */ | |
2120 if (starting != NO_SCREEN) | |
2121 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2122 starttermcap(); // may change terminal mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2123 setmouse(); // may start using the mouse |
7 | 2124 #ifdef FEAT_TITLE |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2125 maketitle(); // may display window title |
7 | 2126 #endif |
2127 } | |
2128 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2129 // display initial screen after ttest() checking. jw. |
7 | 2130 if (width <= 0 || height <= 0) |
2131 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2132 // termcap failed to report size |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2133 // set defaults, in case ui_get_shellsize() also fails |
7 | 2134 width = 80; |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15852
diff
changeset
|
2135 #if defined(MSWIN) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2136 height = 25; // console is often 25 lines |
7 | 2137 #else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2138 height = 24; // most terminals are 24 lines |
7 | 2139 #endif |
2140 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2141 set_shellsize(width, height, FALSE); // may change Rows |
7 | 2142 if (starting != NO_SCREEN) |
2143 { | |
2144 if (scroll_region) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2145 scroll_region_reset(); // In case Rows changed |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2146 check_map_keycodes(); // check mappings for terminal codes used |
7 | 2147 |
2148 { | |
19489
31ac050a29a7
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
2149 buf_T *buf; |
31ac050a29a7
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
2150 aco_save_T aco; |
7 | 2151 |
2152 /* | |
2153 * Execute the TermChanged autocommands for each buffer that is | |
2154 * loaded. | |
2155 */ | |
19489
31ac050a29a7
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
2156 FOR_ALL_BUFFERS(buf) |
7 | 2157 { |
2158 if (curbuf->b_ml.ml_mfp != NULL) | |
19489
31ac050a29a7
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
2159 { |
31ac050a29a7
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
2160 aucmd_prepbuf(&aco, buf); |
7 | 2161 apply_autocmds(EVENT_TERMCHANGED, NULL, NULL, FALSE, |
2162 curbuf); | |
19489
31ac050a29a7
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
2163 // restore curwin/curbuf and a few other things |
31ac050a29a7
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
2164 aucmd_restbuf(&aco); |
31ac050a29a7
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
2165 } |
7 | 2166 } |
2167 } | |
2168 } | |
2169 | |
2170 #ifdef FEAT_TERMRESPONSE | |
2171 may_req_termresponse(); | |
2172 #endif | |
2173 | |
2174 return OK; | |
2175 } | |
2176 | |
2177 #ifdef HAVE_TGETENT | |
2178 /* | |
2179 * Call tgetent() | |
2180 * Return error message if it fails, NULL if it's OK. | |
2181 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
2182 static char * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2183 tgetent_error(char_u *tbuf, char_u *term) |
7 | 2184 { |
2185 int i; | |
2186 | |
18838
8dabdfc7c799
patch 8.1.2406: leaking memory in test_paste and test_registers
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
2187 // Note: Valgrind may report a leak here, because the library keeps one |
8dabdfc7c799
patch 8.1.2406: leaking memory in test_paste and test_registers
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
2188 // buffer around that we can't ever free. |
7 | 2189 i = TGETENT(tbuf, term); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2190 if (i < 0 // -1 is always an error |
7 | 2191 # ifdef TGETENT_ZERO_ERR |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2192 || i == 0 // sometimes zero is also an error |
7 | 2193 # endif |
2194 ) | |
2195 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2196 // On FreeBSD tputs() gets a SEGV after a tgetent() which fails. Call |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2197 // tgetent() with the always existing "dumb" entry to avoid a crash or |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2198 // hang. |
7 | 2199 (void)TGETENT(tbuf, "dumb"); |
2200 | |
2201 if (i < 0) | |
2202 # ifdef TGETENT_ZERO_ERR | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
2203 return _("E557: Cannot open termcap file"); |
7 | 2204 if (i == 0) |
2205 # endif | |
2206 #ifdef TERMINFO | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
2207 return _("E558: Terminal entry not found in terminfo"); |
7 | 2208 #else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
2209 return _("E559: Terminal entry not found in termcap"); |
7 | 2210 #endif |
2211 } | |
2212 return NULL; | |
2213 } | |
2214 | |
2215 /* | |
2216 * Some versions of tgetstr() have been reported to return -1 instead of NULL. | |
2217 * Fix that here. | |
2218 */ | |
2219 static char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2220 vim_tgetstr(char *s, char_u **pp) |
7 | 2221 { |
2222 char *p; | |
2223 | |
2224 p = tgetstr(s, (char **)pp); | |
2225 if (p == (char *)-1) | |
2226 p = NULL; | |
2227 return (char_u *)p; | |
2228 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2229 #endif // HAVE_TGETENT |
7 | 2230 |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
2231 #if defined(HAVE_TGETENT) && (defined(UNIX) || defined(VMS) || defined(MACOS_X)) |
7 | 2232 /* |
2233 * Get Columns and Rows from the termcap. Used after a window signal if the | |
2234 * ioctl() fails. It doesn't make sense to call tgetent each time if the "co" | |
2235 * and "li" entries never change. But on some systems this works. | |
2236 * Errors while getting the entries are ignored. | |
2237 */ | |
2238 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2239 getlinecol( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2240 long *cp, // pointer to columns |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2241 long *rp) // pointer to rows |
7 | 2242 { |
2243 char_u tbuf[TBUFSZ]; | |
2244 | |
2245 if (T_NAME != NULL && *T_NAME != NUL && tgetent_error(tbuf, T_NAME) == NULL) | |
2246 { | |
2247 if (*cp == 0) | |
2248 *cp = tgetnum("co"); | |
2249 if (*rp == 0) | |
2250 *rp = tgetnum("li"); | |
2251 } | |
2252 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2253 #endif // defined(HAVE_TGETENT) && defined(UNIX) |
7 | 2254 |
2255 /* | |
2256 * Get a string entry from the termcap and add it to the list of termcodes. | |
2257 * Used for <t_xx> special keys. | |
2258 * Give an error message for failure when not sourcing. | |
2259 * If force given, replace an existing entry. | |
2260 * Return FAIL if the entry was not found, OK if the entry was added. | |
2261 */ | |
2262 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2263 add_termcap_entry(char_u *name, int force) |
7 | 2264 { |
2265 char_u *term; | |
2266 int key; | |
2267 struct builtin_term *termp; | |
2268 #ifdef HAVE_TGETENT | |
2269 char_u *string; | |
2270 int i; | |
2271 int builtin_first; | |
2272 char_u tbuf[TBUFSZ]; | |
2273 char_u tstrbuf[TBUFSZ]; | |
2274 char_u *tp = tstrbuf; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
2275 char *error_msg = NULL; |
7 | 2276 #endif |
2277 | |
2278 /* | |
2279 * If the GUI is running or will start in a moment, we only support the keys | |
2280 * that the GUI can produce. | |
2281 */ | |
2282 #ifdef FEAT_GUI | |
2283 if (gui.in_use || gui.starting) | |
2284 return gui_mch_haskey(name); | |
2285 #endif | |
2286 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2287 if (!force && find_termcode(name) != NULL) // it's already there |
7 | 2288 return OK; |
2289 | |
2290 term = T_NAME; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2291 if (term == NULL || *term == NUL) // 'term' not defined yet |
7 | 2292 return FAIL; |
2293 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2294 if (term_is_builtin(term)) // name starts with "builtin_" |
7 | 2295 { |
2296 term += 8; | |
2297 #ifdef HAVE_TGETENT | |
2298 builtin_first = TRUE; | |
2299 #endif | |
2300 } | |
2301 #ifdef HAVE_TGETENT | |
2302 else | |
2303 builtin_first = p_tbi; | |
2304 #endif | |
2305 | |
2306 #ifdef HAVE_TGETENT | |
2307 /* | |
2308 * We can get the entry from the builtin termcap and from the external one. | |
2309 * If 'ttybuiltin' is on or the terminal name starts with "builtin_", try | |
2310 * builtin termcap first. | |
2311 * If 'ttybuiltin' is off, try external termcap first. | |
2312 */ | |
2313 for (i = 0; i < 2; ++i) | |
2314 { | |
7210
08b50e436093
commit https://github.com/vim/vim/commit/98b30a473a58ae98c280e0383c8b1e08c0ebced5
Christian Brabandt <cb@256bit.org>
parents:
6901
diff
changeset
|
2315 if ((!builtin_first) == i) |
7 | 2316 #endif |
2317 /* | |
2318 * Search in builtin termcap | |
2319 */ | |
2320 { | |
2321 termp = find_builtin_term(term); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2322 if (termp->bt_string != NULL) // found it |
7 | 2323 { |
2324 key = TERMCAP2KEY(name[0], name[1]); | |
13406
4e30f3f4cb78
patch 8.0.1577: virtual replace test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13398
diff
changeset
|
2325 ++termp; |
7 | 2326 while (termp->bt_entry != (int)KS_NAME) |
2327 { | |
2328 if ((int)termp->bt_entry == key) | |
2329 { | |
2330 add_termcode(name, (char_u *)termp->bt_string, | |
2331 term_is_8bit(term)); | |
2332 return OK; | |
2333 } | |
2334 ++termp; | |
2335 } | |
2336 } | |
2337 } | |
2338 #ifdef HAVE_TGETENT | |
2339 else | |
2340 /* | |
2341 * Search in external termcap | |
2342 */ | |
2343 { | |
2344 error_msg = tgetent_error(tbuf, term); | |
2345 if (error_msg == NULL) | |
2346 { | |
2347 string = TGETSTR((char *)name, &tp); | |
2348 if (string != NULL && *string != NUL) | |
2349 { | |
2350 add_termcode(name, string, FALSE); | |
2351 return OK; | |
2352 } | |
2353 } | |
2354 } | |
2355 } | |
2356 #endif | |
2357 | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18838
diff
changeset
|
2358 if (SOURCING_NAME == NULL) |
7 | 2359 { |
2360 #ifdef HAVE_TGETENT | |
2361 if (error_msg != NULL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
2362 emsg(error_msg); |
7 | 2363 else |
2364 #endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
2365 semsg(_("E436: No \"%s\" entry in termcap"), name); |
7 | 2366 } |
2367 return FAIL; | |
2368 } | |
2369 | |
2370 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2371 term_is_builtin(char_u *name) |
7 | 2372 { |
2373 return (STRNCMP(name, "builtin_", (size_t)8) == 0); | |
2374 } | |
2375 | |
2376 /* | |
2377 * Return TRUE if terminal "name" uses CSI instead of <Esc>[. | |
2378 * Assume that the terminal is using 8-bit controls when the name contains | |
2379 * "8bit", like in "xterm-8bit". | |
2380 */ | |
2381 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2382 term_is_8bit(char_u *name) |
7 | 2383 { |
2384 return (detected_8bit || strstr((char *)name, "8bit") != NULL); | |
2385 } | |
2386 | |
2387 /* | |
2388 * 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
|
2389 * <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
|
2390 * <Esc>] -> OSC <M-C-]> |
7 | 2391 * <Esc>O -> <M-C-O> |
2392 */ | |
2393 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2394 term_7to8bit(char_u *p) |
7 | 2395 { |
2396 if (*p == ESC) | |
2397 { | |
2398 if (p[1] == '[') | |
2399 return CSI; | |
2400 if (p[1] == ']') | |
6901 | 2401 return OSC; |
7 | 2402 if (p[1] == 'O') |
2403 return 0x8f; | |
2404 } | |
2405 return 0; | |
2406 } | |
2407 | |
13762
9de2b25932eb
patch 8.0.1753: various warnings from a static analyser
Christian Brabandt <cb@256bit.org>
parents:
13573
diff
changeset
|
2408 #if defined(FEAT_GUI) || defined(PROTO) |
7 | 2409 int |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2410 term_is_gui(char_u *name) |
7 | 2411 { |
2412 return (STRCMP(name, "builtin_gui") == 0 || STRCMP(name, "gui") == 0); | |
2413 } | |
2414 #endif | |
2415 | |
2416 #if !defined(HAVE_TGETENT) || defined(AMIGA) || defined(PROTO) | |
2417 | |
2418 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2419 tltoa(unsigned long i) |
7 | 2420 { |
2421 static char_u buf[16]; | |
2422 char_u *p; | |
2423 | |
2424 p = buf + 15; | |
2425 *p = '\0'; | |
2426 do | |
2427 { | |
2428 --p; | |
2429 *p = (char_u) (i % 10 + '0'); | |
2430 i /= 10; | |
2431 } | |
2432 while (i > 0 && p > buf); | |
2433 return p; | |
2434 } | |
2435 #endif | |
2436 | |
2437 #ifndef HAVE_TGETENT | |
2438 | |
2439 /* | |
2440 * minimal tgoto() implementation. | |
2441 * no padding and we only parse for %i %d and %+char | |
2442 */ | |
298 | 2443 static char * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2444 tgoto(char *cm, int x, int y) |
7 | 2445 { |
2446 static char buf[30]; | |
2447 char *p, *s, *e; | |
2448 | |
2449 if (!cm) | |
2450 return "OOPS"; | |
2451 e = buf + 29; | |
2452 for (s = buf; s < e && *cm; cm++) | |
2453 { | |
2454 if (*cm != '%') | |
2455 { | |
2456 *s++ = *cm; | |
2457 continue; | |
2458 } | |
2459 switch (*++cm) | |
2460 { | |
2461 case 'd': | |
2462 p = (char *)tltoa((unsigned long)y); | |
2463 y = x; | |
2464 while (*p) | |
2465 *s++ = *p++; | |
2466 break; | |
2467 case 'i': | |
2468 x++; | |
2469 y++; | |
2470 break; | |
2471 case '+': | |
2472 *s++ = (char)(*++cm + y); | |
2473 y = x; | |
2474 break; | |
2475 case '%': | |
2476 *s++ = *cm; | |
2477 break; | |
2478 default: | |
2479 return "OOPS"; | |
2480 } | |
2481 } | |
2482 *s = '\0'; | |
2483 return buf; | |
2484 } | |
2485 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2486 #endif // HAVE_TGETENT |
7 | 2487 |
2488 /* | |
2489 * Set the terminal name and initialize the terminal options. | |
2490 * If "name" is NULL or empty, get the terminal name from the environment. | |
2491 * If that fails, use the default terminal name. | |
2492 */ | |
2493 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2494 termcapinit(char_u *name) |
7 | 2495 { |
2496 char_u *term; | |
2497 | |
2498 if (name != NULL && *name == NUL) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2499 name = NULL; // empty name is equal to no name |
7 | 2500 term = name; |
2501 | |
2502 #ifndef MSWIN | |
2503 if (term == NULL) | |
2504 term = mch_getenv((char_u *)"TERM"); | |
2505 #endif | |
2506 if (term == NULL || *term == NUL) | |
2507 term = DEFAULT_TERM; | |
694 | 2508 set_string_option_direct((char_u *)"term", -1, term, OPT_FREE, 0); |
7 | 2509 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2510 // Set the default terminal name. |
7 | 2511 set_string_default("term", term); |
2512 set_string_default("ttytype", term); | |
2513 | |
2514 /* | |
2515 * Avoid using "term" here, because the next mch_getenv() may overwrite it. | |
2516 */ | |
2517 set_termname(T_NAME != NULL ? T_NAME : term); | |
2518 } | |
2519 | |
2520 /* | |
16200
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2521 * The number of calls to ui_write is reduced by using "out_buf". |
7 | 2522 */ |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
2523 #define OUT_SIZE 2047 |
16200
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2524 |
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2525 // add one to allow mch_write() in os_win32.c to append a NUL |
7 | 2526 static char_u out_buf[OUT_SIZE + 1]; |
16200
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2527 |
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2528 static int out_pos = 0; // number of chars in out_buf |
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2529 |
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2530 // Since the maximum number of SGR parameters shown as a normal value range is |
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2531 // 16, the escape sequence length can be 4 * 16 + lead + tail. |
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2532 #define MAX_ESC_SEQ_LEN 80 |
7 | 2533 |
2534 /* | |
2535 * out_flush(): flush the output buffer | |
2536 */ | |
2537 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2538 out_flush(void) |
7 | 2539 { |
2540 int len; | |
2541 | |
2542 if (out_pos != 0) | |
2543 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2544 // set out_pos to 0 before ui_write, to avoid recursiveness |
7 | 2545 len = out_pos; |
2546 out_pos = 0; | |
2547 ui_write(out_buf, len); | |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2548 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2549 if (ch_log_output) |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2550 { |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2551 out_buf[len] = NUL; |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2552 ch_log(NULL, "raw %s output: \"%s\"", |
23610
07f9e4a54178
patch 8.2.2347: build failure without GUI
Bram Moolenaar <Bram@vim.org>
parents:
23606
diff
changeset
|
2553 # ifdef FEAT_GUI |
07f9e4a54178
patch 8.2.2347: build failure without GUI
Bram Moolenaar <Bram@vim.org>
parents:
23606
diff
changeset
|
2554 (gui.in_use && !gui.dying && !gui.starting) ? "GUI" : |
07f9e4a54178
patch 8.2.2347: build failure without GUI
Bram Moolenaar <Bram@vim.org>
parents:
23606
diff
changeset
|
2555 # endif |
07f9e4a54178
patch 8.2.2347: build failure without GUI
Bram Moolenaar <Bram@vim.org>
parents:
23606
diff
changeset
|
2556 "terminal", |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
2557 out_buf); |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2558 ch_log_output = FALSE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2559 } |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2560 #endif |
7 | 2561 } |
2562 } | |
2563 | |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2564 /* |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
2565 * out_flush_cursor(): flush the output buffer and redraw the cursor. |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
2566 * Does not flush recursively in the GUI to avoid slow drawing. |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2567 */ |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2568 void |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2569 out_flush_cursor( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2570 int force UNUSED, // when TRUE, update cursor even when not moved |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2571 int clear_selection UNUSED) // clear selection under cursor |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2572 { |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2573 mch_disable_flush(); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2574 out_flush(); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2575 mch_enable_flush(); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2576 #ifdef FEAT_GUI |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2577 if (gui.in_use) |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2578 { |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2579 gui_update_cursor(force, clear_selection); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2580 gui_may_flush(); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2581 } |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2582 #endif |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2583 } |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2584 |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2585 |
7 | 2586 /* |
2587 * Sometimes a byte out of a multi-byte character is written with out_char(). | |
2588 * To avoid flushing half of the character, call this function first. | |
2589 */ | |
2590 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2591 out_flush_check(void) |
7 | 2592 { |
2593 if (enc_dbcs != 0 && out_pos >= OUT_SIZE - MB_MAXBYTES) | |
2594 out_flush(); | |
2595 } | |
2596 | |
2597 #ifdef FEAT_GUI | |
2598 /* | |
2599 * out_trash(): Throw away the contents of the output buffer | |
2600 */ | |
2601 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2602 out_trash(void) |
7 | 2603 { |
2604 out_pos = 0; | |
2605 } | |
2606 #endif | |
2607 | |
2608 /* | |
2609 * out_char(c): put a byte into the output buffer. | |
2610 * Flush it if it becomes full. | |
2611 * This should not be used for outputting text on the screen (use functions | |
2612 * like msg_puts() and screen_putchar() for that). | |
2613 */ | |
2614 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2615 out_char(unsigned c) |
7 | 2616 { |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12640
diff
changeset
|
2617 #if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(MACOS_X) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2618 if (c == '\n') // turn LF into CR-LF (CRMOD doesn't seem to do this) |
7 | 2619 out_char('\r'); |
2620 #endif | |
2621 | |
2622 out_buf[out_pos++] = c; | |
2623 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2624 // For testing we flush each time. |
7 | 2625 if (out_pos >= OUT_SIZE || p_wd) |
2626 out_flush(); | |
2627 } | |
2628 | |
2629 /* | |
18430
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
2630 * Output "c" like out_char(), but don't flush when p_wd is set. |
7 | 2631 */ |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2632 static int |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2633 out_char_nf(int c) |
7 | 2634 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2635 out_buf[out_pos++] = (unsigned)c; |
7 | 2636 |
2637 if (out_pos >= OUT_SIZE) | |
2638 out_flush(); | |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
2639 return (unsigned)c; |
7 | 2640 } |
2641 | |
2642 /* | |
18430
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
2643 * A never-padding out_str(). |
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
2644 * Use this whenever you don't want to run the string through tputs(). |
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
2645 * tputs() above is harmless, but tputs() from the termcap library |
7 | 2646 * is likely to strip off leading digits, that it mistakes for padding |
2647 * information, and "%i", "%d", etc. | |
2648 * This should only be used for writing terminal codes, not for outputting | |
2649 * normal text (use functions like msg_puts() and screen_putchar() for that). | |
2650 */ | |
2651 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2652 out_str_nf(char_u *s) |
7 | 2653 { |
16200
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2654 // avoid terminal strings being split up |
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2655 if (out_pos > OUT_SIZE - MAX_ESC_SEQ_LEN) |
7 | 2656 out_flush(); |
16200
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2657 |
7 | 2658 while (*s) |
2659 out_char_nf(*s++); | |
2660 | |
16200
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2661 // For testing we write one string at a time. |
7 | 2662 if (p_wd) |
2663 out_flush(); | |
2664 } | |
2665 | |
2666 /* | |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2667 * 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
|
2668 * 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
|
2669 * it at the wrong time. |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2670 * Note: Only for terminal strings. |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2671 */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2672 void |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2673 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
|
2674 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2675 if (s != NULL && *s) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2676 { |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2677 #ifdef HAVE_TGETENT |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2678 char_u *p; |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2679 #endif |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2680 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2681 #ifdef FEAT_GUI |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2682 // Don't use tputs() when GUI is used, ncurses crashes. |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2683 if (gui.in_use) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2684 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2685 out_str_nf(s); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2686 return; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2687 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2688 #endif |
16200
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2689 if (out_pos > OUT_SIZE - MAX_ESC_SEQ_LEN) |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2690 out_flush(); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2691 #ifdef HAVE_TGETENT |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2692 for (p = s; *s; ++s) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2693 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2694 // flush just before delay command |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2695 if (*s == '$' && *(s + 1) == '<') |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2696 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2697 char_u save_c = *s; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2698 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
|
2699 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2700 *s = NUL; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2701 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
|
2702 *s = save_c; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2703 out_flush(); |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2704 # ifdef ELAPSED_FUNC |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2705 // Only sleep here if we can limit this happening in |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2706 // vim_beep(). |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2707 p = vim_strchr(s, '>'); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2708 if (p == NULL || duration <= 0) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2709 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2710 // can't parse the time, don't sleep here |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2711 p = s; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2712 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2713 else |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2714 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2715 ++p; |
23648
b7d3c79075c5
patch 8.2.2366: when using ":sleep" the cursor is always displayed
Bram Moolenaar <Bram@vim.org>
parents:
23632
diff
changeset
|
2716 do_sleep(duration, FALSE); |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2717 } |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2718 # else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2719 // Rely on the terminal library to sleep. |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2720 p = s; |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2721 # endif |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2722 break; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2723 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2724 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2725 tputs((char *)p, 1, TPUTSFUNCAST out_char_nf); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2726 #else |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2727 while (*s) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2728 out_char_nf(*s++); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2729 #endif |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2730 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2731 // For testing we write one string at a time. |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2732 if (p_wd) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2733 out_flush(); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2734 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2735 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2736 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2737 /* |
7 | 2738 * out_str(s): Put a character string a byte at a time into the output buffer. |
18430
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
2739 * If HAVE_TGETENT is defined use tputs(), the termcap parser. (jw) |
7 | 2740 * This should only be used for writing terminal codes, not for outputting |
2741 * normal text (use functions like msg_puts() and screen_putchar() for that). | |
2742 */ | |
2743 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2744 out_str(char_u *s) |
7 | 2745 { |
2746 if (s != NULL && *s) | |
2747 { | |
2748 #ifdef FEAT_GUI | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2749 // Don't use tputs() when GUI is used, ncurses crashes. |
7 | 2750 if (gui.in_use) |
2751 { | |
2752 out_str_nf(s); | |
2753 return; | |
2754 } | |
2755 #endif | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2756 // avoid terminal strings being split up |
16200
ce6de8dab779
patch 8.1.1105: long escape sequences may be split up
Bram Moolenaar <Bram@vim.org>
parents:
16182
diff
changeset
|
2757 if (out_pos > OUT_SIZE - MAX_ESC_SEQ_LEN) |
7 | 2758 out_flush(); |
2759 #ifdef HAVE_TGETENT | |
2760 tputs((char *)s, 1, TPUTSFUNCAST out_char_nf); | |
2761 #else | |
2762 while (*s) | |
2763 out_char_nf(*s++); | |
2764 #endif | |
2765 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2766 // For testing we write one string at a time. |
7 | 2767 if (p_wd) |
2768 out_flush(); | |
2769 } | |
2770 } | |
2771 | |
2772 /* | |
2773 * cursor positioning using termcap parser. (jw) | |
2774 */ | |
2775 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2776 term_windgoto(int row, int col) |
7 | 2777 { |
2778 OUT_STR(tgoto((char *)T_CM, col, row)); | |
2779 } | |
2780 | |
2781 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2782 term_cursor_right(int i) |
7 | 2783 { |
2784 OUT_STR(tgoto((char *)T_CRI, 0, i)); | |
2785 } | |
2786 | |
2787 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2788 term_append_lines(int line_count) |
7 | 2789 { |
2790 OUT_STR(tgoto((char *)T_CAL, 0, line_count)); | |
2791 } | |
2792 | |
2793 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2794 term_delete_lines(int line_count) |
7 | 2795 { |
2796 OUT_STR(tgoto((char *)T_CDL, 0, line_count)); | |
2797 } | |
2798 | |
2799 #if defined(HAVE_TGETENT) || defined(PROTO) | |
2800 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2801 term_set_winpos(int x, int y) |
7 | 2802 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2803 // Can't handle a negative value here |
7 | 2804 if (x < 0) |
2805 x = 0; | |
2806 if (y < 0) | |
2807 y = 0; | |
2808 OUT_STR(tgoto((char *)T_CWP, y, x)); | |
2809 } | |
2810 | |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2811 # 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
|
2812 /* |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2813 * 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
|
2814 */ |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2815 static int |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2816 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
|
2817 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2818 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
|
2819 && termcap_active |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2820 # ifdef UNIX |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2821 && (is_not_a_term() || (isatty(1) && isatty(read_cmd_fd))) |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2822 # endif |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2823 && p_ek; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2824 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2825 |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2826 /* |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2827 * Set "status" to STATUS_SENT. |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2828 */ |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2829 static void |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2830 termrequest_sent(termrequest_T *status) |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2831 { |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2832 status->tr_progress = STATUS_SENT; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2833 status->tr_start = time(NULL); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2834 } |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2835 |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2836 /* |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2837 * Return TRUE if any of the requests are in STATUS_SENT. |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2838 */ |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2839 static int |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2840 termrequest_any_pending() |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2841 { |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2842 int i; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2843 time_t now = time(NULL); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2844 |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2845 for (i = 0; all_termrequests[i] != NULL; ++i) |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2846 { |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2847 if (all_termrequests[i]->tr_progress == STATUS_SENT) |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2848 { |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2849 if (all_termrequests[i]->tr_start > 0 && now > 0 |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2850 && all_termrequests[i]->tr_start + 2 < now) |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2851 // Sent the request more than 2 seconds ago and didn't get a |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2852 // response, assume it failed. |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2853 all_termrequests[i]->tr_progress = STATUS_FAIL; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2854 else |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2855 return TRUE; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2856 } |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2857 } |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2858 return FALSE; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2859 } |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2860 |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2861 static int winpos_x = -1; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2862 static int winpos_y = -1; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2863 static int did_request_winpos = 0; |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2864 |
16245
e0a6298bd70f
patch 8.1.1127: getwinpos() doesn't work in terminal on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents:
16200
diff
changeset
|
2865 # if defined(FEAT_EVAL) || defined(FEAT_TERMINAL) || defined(PROTO) |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2866 /* |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2867 * 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
|
2868 * 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
|
2869 */ |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2870 int |
13379
0f9dd1b43244
patch 8.0.1563: timeout of getwinposx() can be too short
Christian Brabandt <cb@256bit.org>
parents:
13365
diff
changeset
|
2871 term_get_winpos(int *x, int *y, varnumber_T timeout) |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2872 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2873 int count = 0; |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2874 int prev_winpos_x = winpos_x; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2875 int prev_winpos_y = winpos_y; |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2876 |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2877 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
|
2878 return FAIL; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2879 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
|
2880 winpos_y = -1; |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2881 ++did_request_winpos; |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
2882 termrequest_sent(&winpos_status); |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2883 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
|
2884 out_flush(); |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2885 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2886 // Try reading the result for "timeout" msec. |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2887 while (count++ <= timeout / 10 && !got_int) |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2888 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2889 (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
|
2890 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
|
2891 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2892 *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
|
2893 *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
|
2894 return OK; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2895 } |
18642
bbea1f108187
patch 8.1.2313: debugging where a delay comes from is not easy
Bram Moolenaar <Bram@vim.org>
parents:
18430
diff
changeset
|
2896 ui_delay(10L, FALSE); |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2897 } |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2898 // Do not reset "did_request_winpos", if we timed out the response might |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2899 // still come later and we must consume it. |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2900 |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2901 winpos_x = prev_winpos_x; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2902 winpos_y = prev_winpos_y; |
13762
9de2b25932eb
patch 8.0.1753: various warnings from a static analyser
Christian Brabandt <cb@256bit.org>
parents:
13573
diff
changeset
|
2903 if (timeout < 10 && prev_winpos_y >= 0 && prev_winpos_x >= 0) |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2904 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2905 // Polling: return previous values if we have them. |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2906 *x = winpos_x; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2907 *y = winpos_y; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2908 return OK; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2909 } |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2910 |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2911 return FALSE; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2912 } |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2913 # endif |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2914 # endif |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2915 |
7 | 2916 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
|
2917 term_set_winsize(int height, int width) |
7 | 2918 { |
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
|
2919 OUT_STR(tgoto((char *)T_CWS, width, height)); |
7 | 2920 } |
2921 #endif | |
2922 | |
2923 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2924 term_color(char_u *s, int n) |
7 | 2925 { |
2926 char buf[20]; | |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2927 int i = *s == CSI ? 1 : 2; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2928 // index in s[] just after <Esc>[ or CSI |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2929 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2930 // Special handling of 16 colors, because termcap can't handle it |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2931 // Also accept "\e[3%dm" for TERMINFO, it is sometimes used |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2932 // Also accept CSI instead of <Esc>[ |
7 | 2933 if (n >= 8 && t_colors >= 16 |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
2934 && ((s[0] == ESC && s[1] == '[') |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
2935 #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
2936 || (s[0] == ESC && s[1] == '|') |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
2937 #endif |
20437
3bb4dea4a164
patch 8.2.0773: switching to raw mode every time ":" is used
Bram Moolenaar <Bram@vim.org>
parents:
20425
diff
changeset
|
2938 || (s[0] == CSI && (i = 1) == 1)) |
7 | 2939 && s[i] != NUL |
2940 && (STRCMP(s + i + 1, "%p1%dm") == 0 | |
2941 || STRCMP(s + i + 1, "%dm") == 0) | |
2942 && (s[i] == '3' || s[i] == '4')) | |
2943 { | |
2944 #ifdef TERMINFO | |
9068
0a3bc9fdea20
commit https://github.com/vim/vim/commit/827b165b2aebad2cfe98cc6d5804c6c0fe8afd89
Christian Brabandt <cb@256bit.org>
parents:
9027
diff
changeset
|
2945 char *format = "%s%s%%p1%%dm"; |
7 | 2946 #else |
9068
0a3bc9fdea20
commit https://github.com/vim/vim/commit/827b165b2aebad2cfe98cc6d5804c6c0fe8afd89
Christian Brabandt <cb@256bit.org>
parents:
9027
diff
changeset
|
2947 char *format = "%s%s%%dm"; |
7 | 2948 #endif |
14007
5d6e8dedfc73
patch 8.1.0021: clang warns for undefined behavior
Christian Brabandt <cb@256bit.org>
parents:
13874
diff
changeset
|
2949 char *lead = i == 2 ? ( |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
2950 #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS) |
14007
5d6e8dedfc73
patch 8.1.0021: clang warns for undefined behavior
Christian Brabandt <cb@256bit.org>
parents:
13874
diff
changeset
|
2951 s[1] == '|' ? IF_EB("\033|", ESC_STR "|") : |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
2952 #endif |
14007
5d6e8dedfc73
patch 8.1.0021: clang warns for undefined behavior
Christian Brabandt <cb@256bit.org>
parents:
13874
diff
changeset
|
2953 IF_EB("\033[", ESC_STR "[")) : "\233"; |
5d6e8dedfc73
patch 8.1.0021: clang warns for undefined behavior
Christian Brabandt <cb@256bit.org>
parents:
13874
diff
changeset
|
2954 char *tail = s[i] == '3' ? (n >= 16 ? "38;5;" : "9") |
5d6e8dedfc73
patch 8.1.0021: clang warns for undefined behavior
Christian Brabandt <cb@256bit.org>
parents:
13874
diff
changeset
|
2955 : (n >= 16 ? "48;5;" : "10"); |
5d6e8dedfc73
patch 8.1.0021: clang warns for undefined behavior
Christian Brabandt <cb@256bit.org>
parents:
13874
diff
changeset
|
2956 |
5d6e8dedfc73
patch 8.1.0021: clang warns for undefined behavior
Christian Brabandt <cb@256bit.org>
parents:
13874
diff
changeset
|
2957 sprintf(buf, format, lead, tail); |
7 | 2958 OUT_STR(tgoto(buf, 0, n >= 16 ? n : n - 8)); |
2959 } | |
2960 else | |
2961 OUT_STR(tgoto((char *)s, 0, n)); | |
2962 } | |
2963 | |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2964 void |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2965 term_fg_color(int n) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2966 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2967 // Use "AF" termcap entry if present, "Sf" entry otherwise |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2968 if (*T_CAF) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2969 term_color(T_CAF, n); |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2970 else if (*T_CSF) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2971 term_color(T_CSF, n); |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2972 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2973 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2974 void |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2975 term_bg_color(int n) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2976 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2977 // Use "AB" termcap entry if present, "Sb" entry otherwise |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2978 if (*T_CAB) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2979 term_color(T_CAB, n); |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2980 else if (*T_CSB) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2981 term_color(T_CSB, n); |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2982 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2983 |
20619
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
2984 void |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
2985 term_ul_color(int n) |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
2986 { |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
2987 if (*T_CAU) |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
2988 term_color(T_CAU, n); |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
2989 } |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
2990 |
18679
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
2991 /* |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
2992 * Return "dark" or "light" depending on the kind of terminal. |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
2993 * This is just guessing! Recognized are: |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
2994 * "linux" Linux console |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
2995 * "screen.linux" Linux console with screen |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
2996 * "cygwin.*" Cygwin shell |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
2997 * "putty.*" Putty program |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
2998 * We also check the COLORFGBG environment variable, which is set by |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
2999 * rxvt and derivatives. This variable contains either two or three |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3000 * values separated by semicolons; we want the last value in either |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3001 * case. If this value is 0-6 or 8, our background is dark. |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3002 */ |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3003 char_u * |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3004 term_bg_default(void) |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3005 { |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3006 #if defined(MSWIN) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3007 // DOS console is nearly always black |
18679
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3008 return (char_u *)"dark"; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3009 #else |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3010 char_u *p; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3011 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3012 if (STRCMP(T_NAME, "linux") == 0 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3013 || STRCMP(T_NAME, "screen.linux") == 0 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3014 || STRNCMP(T_NAME, "cygwin", 6) == 0 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3015 || STRNCMP(T_NAME, "putty", 5) == 0 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3016 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3017 && (p = vim_strrchr(p, ';')) != NULL |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3018 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8') |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3019 && p[2] == NUL)) |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3020 return (char_u *)"dark"; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3021 return (char_u *)"light"; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3022 #endif |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3023 } |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3024 |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
3025 #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
|
3026 |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3027 #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
|
3028 #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
|
3029 #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
|
3030 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3031 static void |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3032 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
|
3033 { |
8975
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
3034 #define MAX_COLOR_STR_LEN 100 |
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
3035 char buf[MAX_COLOR_STR_LEN]; |
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
3036 |
8981
3b51b0aeb9a3
commit https://github.com/vim/vim/commit/a1c487eef71d1673e57511453009de9cb4c9af51
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
3037 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
|
3038 (char *)s, RED(rgb), GREEN(rgb), BLUE(rgb)); |
20589
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3039 #ifdef FEAT_VTP |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3040 if (use_wt()) |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3041 { |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3042 out_flush(); |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3043 buf[1] = '['; |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3044 vtp_printf(buf); |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3045 } |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3046 else |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3047 #endif |
ecaceb5c5644
patch 8.2.0848: MS-Windows: the Windows terminal code has some flaws
Bram Moolenaar <Bram@vim.org>
parents:
20524
diff
changeset
|
3048 OUT_STR(buf); |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3049 } |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3050 |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3051 void |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3052 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
|
3053 { |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3054 term_rgb_color(T_8F, rgb); |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3055 } |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3056 |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3057 void |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3058 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
|
3059 { |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3060 term_rgb_color(T_8B, rgb); |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
3061 } |
20619
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3062 |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3063 void |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3064 term_ul_rgb_color(guicolor_T rgb) |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3065 { |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3066 term_rgb_color(T_8U, rgb); |
68c206d3a251
patch 8.2.0863: cannot set a separate color for underline/undercurl
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
3067 } |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3068 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3069 |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7307
diff
changeset
|
3070 #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
|
3071 || defined(MACOS_X))) || defined(PROTO) |
7 | 3072 /* |
3073 * Generic function to set window title, using t_ts and t_fs. | |
3074 */ | |
3075 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3076 term_settitle(char_u *title) |
7 | 3077 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3078 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3079 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3080 #endif |
18430
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
3081 // t_ts takes one argument: column in status line |
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
3082 OUT_STR(tgoto((char *)T_TS, 0, 0)); // set title start |
7 | 3083 out_str_nf(title); |
18430
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
3084 out_str(T_FS); // set title end |
7 | 3085 out_flush(); |
3086 } | |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3087 |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3088 /* |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3089 * Tell the terminal to push (save) the title and/or icon, so that it can be |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3090 * popped (restored) later. |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3091 */ |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3092 void |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3093 term_push_title(int which) |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3094 { |
16586
5ebb2c87d1f5
patch 8.1.1296: crash when using invalid command line argument
Bram Moolenaar <Bram@vim.org>
parents:
16523
diff
changeset
|
3095 if ((which & SAVE_RESTORE_TITLE) && T_CST != NULL && *T_CST != NUL) |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3096 { |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3097 OUT_STR(T_CST); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3098 out_flush(); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3099 } |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3100 |
16586
5ebb2c87d1f5
patch 8.1.1296: crash when using invalid command line argument
Bram Moolenaar <Bram@vim.org>
parents:
16523
diff
changeset
|
3101 if ((which & SAVE_RESTORE_ICON) && T_SSI != NULL && *T_SSI != NUL) |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3102 { |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3103 OUT_STR(T_SSI); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3104 out_flush(); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3105 } |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3106 } |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3107 |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3108 /* |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3109 * Tell the terminal to pop the title and/or icon. |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3110 */ |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3111 void |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3112 term_pop_title(int which) |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3113 { |
16586
5ebb2c87d1f5
patch 8.1.1296: crash when using invalid command line argument
Bram Moolenaar <Bram@vim.org>
parents:
16523
diff
changeset
|
3114 if ((which & SAVE_RESTORE_TITLE) && T_CRT != NULL && *T_CRT != NUL) |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3115 { |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3116 OUT_STR(T_CRT); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3117 out_flush(); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3118 } |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3119 |
16586
5ebb2c87d1f5
patch 8.1.1296: crash when using invalid command line argument
Bram Moolenaar <Bram@vim.org>
parents:
16523
diff
changeset
|
3120 if ((which & SAVE_RESTORE_ICON) && T_SRI != NULL && *T_SRI != NUL) |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3121 { |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3122 OUT_STR(T_SRI); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3123 out_flush(); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3124 } |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3125 } |
7 | 3126 #endif |
3127 | |
3128 /* | |
3129 * Make sure we have a valid set or terminal options. | |
3130 * Replace all entries that are NULL by empty_option | |
3131 */ | |
3132 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3133 ttest(int pairs) |
7 | 3134 { |
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
|
3135 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
|
3136 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3137 check_options(); // make sure no options are NULL |
7 | 3138 |
3139 /* | |
3140 * MUST have "cm": cursor motion. | |
3141 */ | |
3142 if (*T_CM == NUL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
3143 emsg(_("E437: terminal capability \"cm\" required")); |
7 | 3144 |
3145 /* | |
3146 * if "cs" defined, use a scroll region, it's faster. | |
3147 */ | |
3148 if (*T_CS != NUL) | |
3149 scroll_region = TRUE; | |
3150 else | |
3151 scroll_region = FALSE; | |
3152 | |
3153 if (pairs) | |
3154 { | |
3155 /* | |
3156 * optional pairs | |
3157 */ | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3158 // TP goes to normal mode for TI (invert) and TB (bold) |
7 | 3159 if (*T_ME == NUL) |
3160 T_ME = T_MR = T_MD = T_MB = empty_option; | |
3161 if (*T_SO == NUL || *T_SE == NUL) | |
3162 T_SO = T_SE = empty_option; | |
3163 if (*T_US == NUL || *T_UE == NUL) | |
3164 T_US = T_UE = empty_option; | |
3165 if (*T_CZH == NUL || *T_CZR == NUL) | |
3166 T_CZH = T_CZR = empty_option; | |
3167 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3168 // T_VE is needed even though T_VI is not defined |
7 | 3169 if (*T_VE == NUL) |
3170 T_VI = empty_option; | |
3171 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3172 // if 'mr' or 'me' is not defined use 'so' and 'se' |
7 | 3173 if (*T_ME == NUL) |
3174 { | |
3175 T_ME = T_SE; | |
3176 T_MR = T_SO; | |
3177 T_MD = T_SO; | |
3178 } | |
3179 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3180 // if 'so' or 'se' is not defined use 'mr' and 'me' |
7 | 3181 if (*T_SO == NUL) |
3182 { | |
3183 T_SE = T_ME; | |
3184 if (*T_MR == NUL) | |
3185 T_SO = T_MD; | |
3186 else | |
3187 T_SO = T_MR; | |
3188 } | |
3189 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3190 // if 'ZH' or 'ZR' is not defined use 'mr' and 'me' |
7 | 3191 if (*T_CZH == NUL) |
3192 { | |
3193 T_CZR = T_ME; | |
3194 if (*T_MR == NUL) | |
3195 T_CZH = T_MD; | |
3196 else | |
3197 T_CZH = T_MR; | |
3198 } | |
3199 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3200 // "Sb" and "Sf" come in pairs |
7 | 3201 if (*T_CSB == NUL || *T_CSF == NUL) |
3202 { | |
3203 T_CSB = empty_option; | |
3204 T_CSF = empty_option; | |
3205 } | |
3206 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3207 // "AB" and "AF" come in pairs |
7 | 3208 if (*T_CAB == NUL || *T_CAF == NUL) |
3209 { | |
3210 T_CAB = empty_option; | |
3211 T_CAF = empty_option; | |
3212 } | |
3213 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3214 // if 'Sb' and 'AB' are not defined, reset "Co" |
7 | 3215 if (*T_CSB == NUL && *T_CAB == NUL) |
1941 | 3216 free_one_termoption(T_CCO); |
7 | 3217 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3218 // Set 'weirdinvert' according to value of 't_xs' |
7 | 3219 p_wiv = (*T_XS != NUL); |
3220 } | |
3221 need_gather = TRUE; | |
3222 | |
20181
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3223 // Set t_colors to the value of $COLORS or t_Co. Ignore $COLORS in the |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3224 // GUI. |
7 | 3225 t_colors = atoi((char *)T_CCO); |
20181
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3226 #ifdef FEAT_GUI |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3227 if (!gui.in_use) |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3228 #endif |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
3229 { |
20181
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3230 env_colors = mch_getenv((char_u *)"COLORS"); |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3231 if (env_colors != NULL && isdigit(*env_colors)) |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3232 { |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3233 int colors = atoi((char *)env_colors); |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3234 |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3235 if (colors != t_colors) |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3236 set_color_count(colors); |
0ab9d7469ce7
patch 8.2.0646: t_Co uses the value of $COLORS in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20065
diff
changeset
|
3237 } |
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
|
3238 } |
7 | 3239 } |
3240 | |
3241 #if (defined(FEAT_GUI) && (defined(FEAT_MENU) || !defined(USE_ON_FLY_SCROLL))) \ | |
3242 || defined(PROTO) | |
3243 /* | |
3244 * Represent the given long_u as individual bytes, with the most significant | |
3245 * byte first, and store them in dst. | |
3246 */ | |
3247 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3248 add_long_to_buf(long_u val, char_u *dst) |
7 | 3249 { |
3250 int i; | |
3251 int shift; | |
3252 | |
1883 | 3253 for (i = 1; i <= (int)sizeof(long_u); i++) |
7 | 3254 { |
3255 shift = 8 * (sizeof(long_u) - i); | |
3256 dst[i - 1] = (char_u) ((val >> shift) & 0xff); | |
3257 } | |
3258 } | |
3259 | |
3260 /* | |
3261 * Interpret the next string of bytes in buf as a long integer, with the most | |
3262 * significant byte first. Note that it is assumed that buf has been through | |
3263 * inchar(), so that NUL and K_SPECIAL will be represented as three bytes each. | |
3264 * Puts result in val, and returns the number of bytes read from buf | |
3265 * (between sizeof(long_u) and 2 * sizeof(long_u)), or -1 if not enough bytes | |
3266 * were present. | |
3267 */ | |
3268 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3269 get_long_from_buf(char_u *buf, long_u *val) |
7 | 3270 { |
3271 int len; | |
3272 char_u bytes[sizeof(long_u)]; | |
3273 int i; | |
3274 int shift; | |
3275 | |
3276 *val = 0; | |
3277 len = get_bytes_from_buf(buf, bytes, (int)sizeof(long_u)); | |
3278 if (len != -1) | |
3279 { | |
1883 | 3280 for (i = 0; i < (int)sizeof(long_u); i++) |
7 | 3281 { |
3282 shift = 8 * (sizeof(long_u) - 1 - i); | |
3283 *val += (long_u)bytes[i] << shift; | |
3284 } | |
3285 } | |
3286 return len; | |
3287 } | |
3288 #endif | |
3289 | |
3290 /* | |
3291 * Read the next num_bytes bytes from buf, and store them in bytes. Assume | |
3292 * that buf has been through inchar(). Returns the actual number of bytes used | |
3293 * from buf (between num_bytes and num_bytes*2), or -1 if not enough bytes were | |
3294 * available. | |
3295 */ | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
3296 int |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3297 get_bytes_from_buf(char_u *buf, char_u *bytes, int num_bytes) |
7 | 3298 { |
3299 int len = 0; | |
3300 int i; | |
3301 char_u c; | |
3302 | |
3303 for (i = 0; i < num_bytes; i++) | |
3304 { | |
3305 if ((c = buf[len++]) == NUL) | |
3306 return -1; | |
3307 if (c == K_SPECIAL) | |
3308 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3309 if (buf[len] == NUL || buf[len + 1] == NUL) // cannot happen? |
7 | 3310 return -1; |
3311 if (buf[len++] == (int)KS_ZERO) | |
3312 c = NUL; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3313 // else it should be KS_SPECIAL; when followed by KE_FILLER c is |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3314 // K_SPECIAL, or followed by KE_CSI and c must be CSI. |
5076
19ed30f7cef7
updated for version 7.3.1281
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
3315 if (buf[len++] == (int)KE_CSI) |
19ed30f7cef7
updated for version 7.3.1281
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
3316 c = CSI; |
7 | 3317 } |
1160 | 3318 else if (c == CSI && buf[len] == KS_EXTRA |
3319 && buf[len + 1] == (int)KE_CSI) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3320 // CSI is stored as CSI KS_SPECIAL KE_CSI to avoid confusion with |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3321 // the start of a special key, see add_to_input_buf_csi(). |
667 | 3322 len += 2; |
7 | 3323 bytes[i] = c; |
3324 } | |
3325 return len; | |
3326 } | |
3327 | |
3328 /* | |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3329 * 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
|
3330 * too big. |
7 | 3331 */ |
3332 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3333 check_shellsize(void) |
7 | 3334 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3335 if (Rows < min_rows()) // need room for one window and command line |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3336 Rows = min_rows(); |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3337 limit_screen_size(); |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3338 } |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3339 |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3340 /* |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3341 * 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
|
3342 */ |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3343 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3344 limit_screen_size(void) |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3345 { |
7 | 3346 if (Columns < MIN_COLUMNS) |
3347 Columns = MIN_COLUMNS; | |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3348 else if (Columns > 10000) |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3349 Columns = 10000; |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3350 if (Rows > 1000) |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3351 Rows = 1000; |
7 | 3352 } |
3353 | |
41 | 3354 /* |
3355 * Invoked just before the screen structures are going to be (re)allocated. | |
3356 */ | |
7 | 3357 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3358 win_new_shellsize(void) |
7 | 3359 { |
3360 static int old_Rows = 0; | |
3361 static int old_Columns = 0; | |
3362 | |
3363 if (old_Rows != Rows || old_Columns != Columns) | |
3364 ui_new_shellsize(); | |
3365 if (old_Rows != Rows) | |
3366 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3367 // if 'window' uses the whole screen, keep it using that |
179 | 3368 if (p_window == old_Rows - 1 || old_Rows == 0) |
164 | 3369 p_window = Rows - 1; |
7 | 3370 old_Rows = Rows; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3371 shell_new_rows(); // update window sizes |
7 | 3372 } |
3373 if (old_Columns != Columns) | |
3374 { | |
3375 old_Columns = Columns; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3376 shell_new_columns(); // update window sizes |
7 | 3377 } |
3378 } | |
3379 | |
3380 /* | |
3381 * Call this function when the Vim shell has been resized in any way. | |
3382 * Will obtain the current size and redraw (also when size didn't change). | |
3383 */ | |
3384 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3385 shell_resized(void) |
7 | 3386 { |
3387 set_shellsize(0, 0, FALSE); | |
3388 } | |
3389 | |
3390 /* | |
3391 * Check if the shell size changed. Handle a resize. | |
3392 * When the size didn't change, nothing happens. | |
3393 */ | |
3394 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3395 shell_resized_check(void) |
7 | 3396 { |
3397 int old_Rows = Rows; | |
3398 int old_Columns = Columns; | |
3399 | |
3770 | 3400 if (!exiting |
3401 #ifdef FEAT_GUI | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3402 // Do not get the size when executing a shell command during |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3403 // startup. |
3770 | 3404 && !gui.starting |
3405 #endif | |
3406 ) | |
2673 | 3407 { |
3408 (void)ui_get_shellsize(); | |
3409 check_shellsize(); | |
3410 if (old_Rows != Rows || old_Columns != Columns) | |
3411 shell_resized(); | |
3412 } | |
7 | 3413 } |
3414 | |
3415 /* | |
3416 * Set size of the Vim shell. | |
3417 * If 'mustset' is TRUE, we must set Rows and Columns, do not get the real | |
3418 * window size (this is used for the :win command). | |
3419 * If 'mustset' is FALSE, we may try to get the real window size and if | |
3420 * it fails use 'width' and 'height'. | |
3421 */ | |
3422 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3423 set_shellsize(int width, int height, int mustset) |
7 | 3424 { |
3425 static int busy = FALSE; | |
3426 | |
3427 /* | |
3428 * Avoid recursiveness, can happen when setting the window size causes | |
3429 * another window-changed signal. | |
3430 */ | |
3431 if (busy) | |
3432 return; | |
3433 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3434 if (width < 0 || height < 0) // just checking... |
7 | 3435 return; |
3436 | |
3068 | 3437 if (State == HITRETURN || State == SETWSIZE) |
7 | 3438 { |
17330
b2918bd457cb
patch 8.1.1664: GUI resize may cause changing Rows at a bad time
Bram Moolenaar <Bram@vim.org>
parents:
16961
diff
changeset
|
3439 // postpone the resizing |
7 | 3440 State = SETWSIZE; |
3441 return; | |
3442 } | |
3443 | |
17330
b2918bd457cb
patch 8.1.1664: GUI resize may cause changing Rows at a bad time
Bram Moolenaar <Bram@vim.org>
parents:
16961
diff
changeset
|
3444 if (updating_screen) |
b2918bd457cb
patch 8.1.1664: GUI resize may cause changing Rows at a bad time
Bram Moolenaar <Bram@vim.org>
parents:
16961
diff
changeset
|
3445 // resizing while in update_screen() may cause a crash |
b2918bd457cb
patch 8.1.1664: GUI resize may cause changing Rows at a bad time
Bram Moolenaar <Bram@vim.org>
parents:
16961
diff
changeset
|
3446 return; |
b2918bd457cb
patch 8.1.1664: GUI resize may cause changing Rows at a bad time
Bram Moolenaar <Bram@vim.org>
parents:
16961
diff
changeset
|
3447 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3448 // curwin->w_buffer can be NULL when we are closing a window and the |
23410
ae3421daa981
patch 8.2.2248: ASAN error on exit with GUI
Bram Moolenaar <Bram@vim.org>
parents:
23408
diff
changeset
|
3449 // buffer (or window) has already been closed and removing a scrollbar |
ae3421daa981
patch 8.2.2248: ASAN error on exit with GUI
Bram Moolenaar <Bram@vim.org>
parents:
23408
diff
changeset
|
3450 // causes a resize event. Don't resize then, it will happen after entering |
ae3421daa981
patch 8.2.2248: ASAN error on exit with GUI
Bram Moolenaar <Bram@vim.org>
parents:
23408
diff
changeset
|
3451 // another buffer. |
ae3421daa981
patch 8.2.2248: ASAN error on exit with GUI
Bram Moolenaar <Bram@vim.org>
parents:
23408
diff
changeset
|
3452 if (curwin->w_buffer == NULL || curwin->w_lines == NULL) |
3068 | 3453 return; |
3454 | |
7 | 3455 ++busy; |
3456 | |
3457 #ifdef AMIGA | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3458 out_flush(); // must do this before mch_get_shellsize() for |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3459 // some obscure reason |
7 | 3460 #endif |
3461 | |
3462 if (mustset || (ui_get_shellsize() == FAIL && height != 0)) | |
3463 { | |
3464 Rows = height; | |
3465 Columns = width; | |
3466 check_shellsize(); | |
3467 ui_set_shellsize(mustset); | |
3468 } | |
3469 else | |
3470 check_shellsize(); | |
3471 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3472 // The window layout used to be adjusted here, but it now happens in |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3473 // screenalloc() (also invoked from screenclear()). That is because the |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3474 // "busy" check above may skip this, but not screenalloc(). |
7 | 3475 |
3476 if (State != ASKMORE && State != EXTERNCMD && State != CONFIRM) | |
3477 screenclear(); | |
3478 else | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3479 screen_start(); // don't know where cursor is now |
7 | 3480 |
3481 if (starting != NO_SCREEN) | |
3482 { | |
3483 #ifdef FEAT_TITLE | |
3484 maketitle(); | |
3485 #endif | |
3486 changed_line_abv_curs(); | |
3487 invalidate_botline(); | |
3488 | |
3489 /* | |
3490 * We only redraw when it's needed: | |
3491 * - While at the more prompt or executing an external command, don't | |
3492 * redraw, but position the cursor. | |
3493 * - While editing the command line, only redraw that. | |
3494 * - in Ex mode, don't redraw anything. | |
3495 * - Otherwise, redraw right now, and position the cursor. | |
3496 * Always need to call update_screen() or screenalloc(), to make | |
3497 * sure Rows/Columns and the size of ScreenLines[] is correct! | |
3498 */ | |
3499 if (State == ASKMORE || State == EXTERNCMD || State == CONFIRM | |
3500 || exmode_active) | |
3501 { | |
3502 screenalloc(FALSE); | |
3503 repeat_message(); | |
3504 } | |
3505 else | |
3506 { | |
1024 | 3507 if (curwin->w_p_scb) |
3508 do_check_scrollbind(TRUE); | |
3509 if (State & CMDLINE) | |
648 | 3510 { |
1024 | 3511 update_screen(NOT_VALID); |
3512 redrawcmdline(); | |
648 | 3513 } |
3514 else | |
1024 | 3515 { |
3516 update_topline(); | |
3517 if (pum_visible()) | |
3518 { | |
3519 redraw_later(NOT_VALID); | |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12513
diff
changeset
|
3520 ins_compl_show_pum(); |
1024 | 3521 } |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12513
diff
changeset
|
3522 update_screen(NOT_VALID); |
1024 | 3523 if (redrawing()) |
3524 setcursor(); | |
3525 } | |
7 | 3526 } |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3527 cursor_on(); // redrawing may have switched it off |
7 | 3528 } |
3529 out_flush(); | |
3530 --busy; | |
3531 } | |
3532 | |
3533 /* | |
3534 * Set the terminal to TMODE_RAW (for Normal mode) or TMODE_COOK (for external | |
3535 * commands and Ex mode). | |
3536 */ | |
3537 void | |
20450
d5d89c24eec7
patch 8.2.0779: tmode_T not used everywhere
Bram Moolenaar <Bram@vim.org>
parents:
20439
diff
changeset
|
3538 settmode(tmode_T tmode) |
7 | 3539 { |
3540 #ifdef FEAT_GUI | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3541 // don't set the term where gvim was started to any mode |
7 | 3542 if (gui.in_use) |
3543 return; | |
3544 #endif | |
3545 | |
3546 if (full_screen) | |
3547 { | |
3548 /* | |
20437
3bb4dea4a164
patch 8.2.0773: switching to raw mode every time ":" is used
Bram Moolenaar <Bram@vim.org>
parents:
20425
diff
changeset
|
3549 * When returning after calling a shell cur_tmode is TMODE_UNKNOWN, |
3bb4dea4a164
patch 8.2.0773: switching to raw mode every time ":" is used
Bram Moolenaar <Bram@vim.org>
parents:
20425
diff
changeset
|
3550 * set the terminal to raw mode, even though we think it already is, |
3bb4dea4a164
patch 8.2.0773: switching to raw mode every time ":" is used
Bram Moolenaar <Bram@vim.org>
parents:
20425
diff
changeset
|
3551 * because the shell program may have reset the terminal mode. |
7 | 3552 * When we think the terminal is normal, don't try to set it to |
3553 * normal again, because that causes problems (logout!) on some | |
3554 * machines. | |
3555 */ | |
20437
3bb4dea4a164
patch 8.2.0773: switching to raw mode every time ":" is used
Bram Moolenaar <Bram@vim.org>
parents:
20425
diff
changeset
|
3556 if (tmode != cur_tmode) |
7 | 3557 { |
3558 #ifdef FEAT_TERMRESPONSE | |
1691 | 3559 # ifdef FEAT_GUI |
3560 if (!gui.in_use && !gui.starting) | |
3561 # endif | |
3562 { | |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3563 // May need to check for T_CRV response and termcodes, it |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3564 // doesn't work in Cooked mode, an external program may get |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3565 // them. |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3566 if (tmode != TMODE_RAW && termrequest_any_pending()) |
1691 | 3567 (void)vpeekc_nomap(); |
3568 check_for_codes_from_term(); | |
3569 } | |
7 | 3570 #endif |
3571 if (tmode != TMODE_RAW) | |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3572 mch_setmouse(FALSE); // switch mouse off |
20439
d4b2a8675b78
patch 8.2.0774: t_TI and t_TE are output when using 'visualbell'
Bram Moolenaar <Bram@vim.org>
parents:
20437
diff
changeset
|
3573 |
d4b2a8675b78
patch 8.2.0774: t_TI and t_TE are output when using 'visualbell'
Bram Moolenaar <Bram@vim.org>
parents:
20437
diff
changeset
|
3574 // Disable bracketed paste and modifyOtherKeys in cooked mode. |
d4b2a8675b78
patch 8.2.0774: t_TI and t_TE are output when using 'visualbell'
Bram Moolenaar <Bram@vim.org>
parents:
20437
diff
changeset
|
3575 // Avoid doing this too often, on some terminals the codes are not |
d4b2a8675b78
patch 8.2.0774: t_TI and t_TE are output when using 'visualbell'
Bram Moolenaar <Bram@vim.org>
parents:
20437
diff
changeset
|
3576 // handled properly. |
d4b2a8675b78
patch 8.2.0774: t_TI and t_TE are output when using 'visualbell'
Bram Moolenaar <Bram@vim.org>
parents:
20437
diff
changeset
|
3577 if (termcap_active && tmode != TMODE_SLEEP |
d4b2a8675b78
patch 8.2.0774: t_TI and t_TE are output when using 'visualbell'
Bram Moolenaar <Bram@vim.org>
parents:
20437
diff
changeset
|
3578 && cur_tmode != TMODE_SLEEP) |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3579 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3580 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3581 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3582 #endif |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3583 if (tmode != TMODE_RAW) |
20425
426ef48be465
patch 8.2.0767: modifyOtherKeys active when using a shell command in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
20181
diff
changeset
|
3584 { |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3585 out_str(T_BD); // disable bracketed paste mode |
20425
426ef48be465
patch 8.2.0767: modifyOtherKeys active when using a shell command in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
20181
diff
changeset
|
3586 out_str(T_CTE); // possibly disables modifyOtherKeys |
426ef48be465
patch 8.2.0767: modifyOtherKeys active when using a shell command in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
20181
diff
changeset
|
3587 } |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3588 else |
20425
426ef48be465
patch 8.2.0767: modifyOtherKeys active when using a shell command in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
20181
diff
changeset
|
3589 { |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3590 out_str(T_BE); // enable bracketed paste mode (should |
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3591 // be before mch_settmode(). |
20425
426ef48be465
patch 8.2.0767: modifyOtherKeys active when using a shell command in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
20181
diff
changeset
|
3592 out_str(T_CTI); // possibly enables modifyOtherKeys |
426ef48be465
patch 8.2.0767: modifyOtherKeys active when using a shell command in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
20181
diff
changeset
|
3593 } |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3594 } |
7 | 3595 out_flush(); |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3596 mch_settmode(tmode); // machine specific function |
7 | 3597 cur_tmode = tmode; |
3598 if (tmode == TMODE_RAW) | |
16387
12d57853ddb2
patch 8.1.1198: bracketed paste may remain active after Vim exists
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3599 setmouse(); // may switch mouse on |
7 | 3600 out_flush(); |
3601 } | |
3602 #ifdef FEAT_TERMRESPONSE | |
3603 may_req_termresponse(); | |
3604 #endif | |
3605 } | |
3606 } | |
3607 | |
3608 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3609 starttermcap(void) |
7 | 3610 { |
3611 if (full_screen && !termcap_active) | |
3612 { | |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3613 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3614 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3615 #endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3616 out_str(T_TI); // start termcap mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3617 out_str(T_CTI); // start "raw" mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3618 out_str(T_KS); // start "keypad transmit" mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3619 out_str(T_BE); // enable bracketed paste mode |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3620 |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3621 #if (defined(UNIX) || defined(VMS)) |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3622 // enable xterm's focus reporting mode |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3623 if (focus_mode && *T_FE != NUL) |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3624 out_str(T_FE); |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3625 #endif |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3626 |
7 | 3627 out_flush(); |
3628 termcap_active = TRUE; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3629 screen_start(); // don't know where cursor is now |
7 | 3630 #ifdef FEAT_TERMRESPONSE |
1691 | 3631 # ifdef FEAT_GUI |
3632 if (!gui.in_use && !gui.starting) | |
3633 # endif | |
3634 { | |
3635 may_req_termresponse(); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3636 // Immediately check for a response. If t_Co changes, we don't |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3637 // want to redraw with wrong colors first. |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3638 if (crv_status.tr_progress == STATUS_SENT) |
1691 | 3639 check_for_codes_from_term(); |
3640 } | |
7 | 3641 #endif |
3642 } | |
3643 } | |
3644 | |
3645 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3646 stoptermcap(void) |
7 | 3647 { |
3648 screen_stop_highlight(); | |
3649 reset_cterm_colors(); | |
3650 if (termcap_active) | |
3651 { | |
3652 #ifdef FEAT_TERMRESPONSE | |
1691 | 3653 # ifdef FEAT_GUI |
3654 if (!gui.in_use && !gui.starting) | |
3655 # endif | |
3656 { | |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3657 // May need to discard T_CRV, T_U7 or T_RBG response. |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3658 if (termrequest_any_pending()) |
4391 | 3659 { |
3660 # ifdef UNIX | |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3661 // Give the terminal a chance to respond. |
21927
88070e222e82
patch 8.2.1513: cannot interrupt shell used for filename expansion
Bram Moolenaar <Bram@vim.org>
parents:
21624
diff
changeset
|
3662 mch_delay(100L, 0); |
4391 | 3663 # endif |
3664 # ifdef TCIFLUSH | |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3665 // Discard data received but not read. |
4391 | 3666 if (exiting) |
3667 tcflush(fileno(stdin), TCIFLUSH); | |
3668 # endif | |
3669 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3670 // Check for termcodes first, otherwise an external program may |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3671 // get them. |
1691 | 3672 check_for_codes_from_term(); |
3673 } | |
7 | 3674 #endif |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3675 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3676 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3677 #endif |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3678 |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3679 #if (defined(UNIX) || defined(VMS)) |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3680 // disable xterm's focus reporting mode |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3681 if (focus_mode && *T_FD != NUL) |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3682 out_str(T_FD); |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3683 #endif |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
3684 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3685 out_str(T_BD); // disable bracketed paste mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3686 out_str(T_KE); // stop "keypad transmit" mode |
7 | 3687 out_flush(); |
3688 termcap_active = FALSE; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3689 cursor_on(); // just in case it is still off |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3690 out_str(T_CTE); // stop "raw" mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3691 out_str(T_TE); // stop termcap mode |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3692 screen_start(); // don't know where cursor is now |
7 | 3693 out_flush(); |
3694 } | |
3695 } | |
3696 | |
5932 | 3697 #if defined(FEAT_TERMRESPONSE) || defined(PROTO) |
7 | 3698 /* |
3699 * Request version string (for xterm) when needed. | |
3700 * Only do this after switching to raw mode, otherwise the result will be | |
3701 * echoed. | |
626 | 3702 * Only do this after startup has finished, to avoid that the response comes |
1221 | 3703 * while executing "-c !cmd" or even after "-c quit". |
7 | 3704 * Only do this after termcap mode has been started, otherwise the codes for |
3705 * the cursor keys may be wrong. | |
620 | 3706 * Only do this when 'esckeys' is on, otherwise the response causes trouble in |
3707 * Insert mode. | |
164 | 3708 * On Unix only do it when both output and input are a tty (avoid writing |
3709 * request to terminal while reading from a file). | |
7 | 3710 * The result is caught in check_termcode(). |
3711 */ | |
626 | 3712 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3713 may_req_termresponse(void) |
7 | 3714 { |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3715 if (crv_status.tr_progress == STATUS_GET |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
3716 && can_get_termresponse() |
626 | 3717 && starting == 0 |
7 | 3718 && *T_CRV != NUL) |
3719 { | |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3720 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3721 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3722 #endif |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3723 LOG_TR(("Sending CRV request")); |
7 | 3724 out_str(T_CRV); |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3725 termrequest_sent(&crv_status); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3726 // check for the characters now, otherwise they might be eaten by |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3727 // get_keystroke() |
7 | 3728 out_flush(); |
3729 (void)vpeekc_nomap(); | |
3730 } | |
3731 } | |
4215 | 3732 |
3733 /* | |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3734 * Send sequences to the terminal and check with t_u7 how the cursor moves, to |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3735 * find out properties of the terminal. |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
3736 * Note that this goes out before T_CRV, so that the result can be used when |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
3737 * the termresponse arrives. |
4215 | 3738 */ |
3739 void | |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3740 check_terminal_behavior(void) |
4215 | 3741 { |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3742 int did_send = FALSE; |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3743 |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3744 if (!can_get_termresponse() || starting != 0 || *T_U7 == NUL) |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3745 return; |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3746 |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3747 if (u7_status.tr_progress == STATUS_GET |
4215 | 3748 && !option_was_set((char_u *)"ambiwidth")) |
3749 { | |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3750 char_u buf[16]; |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3751 |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3752 // Ambiguous width check. |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3753 // Check how the terminal treats ambiguous character width (UAX #11). |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3754 // First, we move the cursor to (1, 0) and print a test ambiguous |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3755 // character \u25bd (WHITE DOWN-POINTING TRIANGLE) and then query |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3756 // the current cursor position. If the terminal treats \u25bd as |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3757 // single width, the position is (1, 1), or if it is treated as double |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3758 // width, that will be (1, 2). This function has the side effect that |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3759 // changes cursor position, so it must be called immediately after |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3760 // entering termcap mode. |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3761 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3762 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3763 #endif |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3764 LOG_TR(("Sending request for ambiwidth check")); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3765 // Do this in the second row. In the first row the returned sequence |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3766 // may be CSI 1;2R, which is the same as <S-F3>. |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3767 term_windgoto(1, 0); |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3768 buf[mb_char2bytes(0x25bd, buf)] = NUL; |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3769 out_str(buf); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3770 out_str(T_U7); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3771 termrequest_sent(&u7_status); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3772 out_flush(); |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3773 did_send = TRUE; |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3774 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3775 // This overwrites a few characters on the screen, a redraw is needed |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3776 // after this. Clear them out for now. |
17482
6cf077f59152
patch 8.1.1739: deleted match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents:
17330
diff
changeset
|
3777 screen_stop_highlight(); |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3778 term_windgoto(1, 0); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3779 out_str((char_u *)" "); |
21226
421c4ed6b949
patch 8.2.1164: text cleared by checking terminal properties not redrawn
Bram Moolenaar <Bram@vim.org>
parents:
20935
diff
changeset
|
3780 line_was_clobbered(1); |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3781 } |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3782 |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3783 if (xcc_status.tr_progress == STATUS_GET) |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3784 { |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3785 // 2. Check compatibility with xterm. |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3786 // We move the cursor to (2, 0), print a test sequence and then query |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3787 // the current cursor position. If the terminal properly handles |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3788 // unknown DCS string and CSI sequence with intermediate byte, the test |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3789 // sequence is ignored and the cursor does not move. If the terminal |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3790 // handles test sequence incorrectly, a garbage string is displayed and |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3791 // the cursor does move. |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3792 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3793 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3794 #endif |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3795 LOG_TR(("Sending xterm compatibility test sequence.")); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3796 // Do this in the third row. Second row is used by ambiguous |
23229
b545334ae654
patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents:
22956
diff
changeset
|
3797 // character width check. |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3798 term_windgoto(2, 0); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3799 // send the test DCS string. |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3800 out_str((char_u *)"\033Pzz\033\\"); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3801 // send the test CSI sequence with intermediate byte. |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3802 out_str((char_u *)"\033[0%m"); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3803 out_str(T_U7); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3804 termrequest_sent(&xcc_status); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3805 out_flush(); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3806 did_send = TRUE; |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3807 |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3808 // If the terminal handles test sequence incorrectly, garbage text is |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3809 // displayed. Clear them out for now. |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3810 screen_stop_highlight(); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3811 term_windgoto(2, 0); |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3812 out_str((char_u *)" "); |
21226
421c4ed6b949
patch 8.2.1164: text cleared by checking terminal properties not redrawn
Bram Moolenaar <Bram@vim.org>
parents:
20935
diff
changeset
|
3813 line_was_clobbered(2); |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3814 } |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3815 |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3816 if (did_send) |
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
3817 { |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3818 term_windgoto(0, 0); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3819 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3820 // Need to reset the known cursor position. |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3821 screen_start(); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3822 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3823 // check for the characters now, otherwise they might be eaten by |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3824 // get_keystroke() |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3825 out_flush(); |
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3826 (void)vpeekc_nomap(); |
4215 | 3827 } |
3828 } | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3829 |
6874 | 3830 /* |
6885 | 3831 * Similar to requesting the version string: Request the terminal background |
3832 * color when it is the right moment. | |
6874 | 3833 */ |
3834 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3835 may_req_bg_color(void) |
6874 | 3836 { |
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
|
3837 if (can_get_termresponse() && starting == 0) |
6874 | 3838 { |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3839 int didit = FALSE; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3840 |
12640
a715f0b44532
patch 8.0.1198: older compilers don't know uint8_t
Christian Brabandt <cb@256bit.org>
parents:
12634
diff
changeset
|
3841 # ifdef FEAT_TERMINAL |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3842 // Only request foreground if t_RF is set. |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3843 if (rfg_status.tr_progress == STATUS_GET && *T_RFG != NUL) |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3844 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3845 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3846 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3847 #endif |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3848 LOG_TR(("Sending FG request")); |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3849 out_str(T_RFG); |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3850 termrequest_sent(&rfg_status); |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3851 didit = TRUE; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3852 } |
12640
a715f0b44532
patch 8.0.1198: older compilers don't know uint8_t
Christian Brabandt <cb@256bit.org>
parents:
12634
diff
changeset
|
3853 # endif |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3854 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3855 // Only request background if t_RB is set. |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3856 if (rbg_status.tr_progress == STATUS_GET && *T_RBG != NUL) |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3857 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3858 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3859 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3860 #endif |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3861 LOG_TR(("Sending BG request")); |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3862 out_str(T_RBG); |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
3863 termrequest_sent(&rbg_status); |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3864 didit = TRUE; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3865 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3866 |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3867 if (didit) |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3868 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3869 // check for the characters now, otherwise they might be eaten by |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3870 // get_keystroke() |
12232
1553d1a4bf7c
patch 8.0.0996: Mac: t_RS is echoed on the screne in Terminal.app
Christian Brabandt <cb@256bit.org>
parents:
12226
diff
changeset
|
3871 out_flush(); |
1553d1a4bf7c
patch 8.0.0996: Mac: t_RS is echoed on the screne in Terminal.app
Christian Brabandt <cb@256bit.org>
parents:
12226
diff
changeset
|
3872 (void)vpeekc_nomap(); |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3873 } |
6874 | 3874 } |
3875 } | |
3876 | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3877 # ifdef DEBUG_TERMRESPONSE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3878 static void |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3879 log_tr(const char *fmt, ...) |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3880 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3881 static FILE *fd_tr = NULL; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3882 static proftime_T start; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3883 proftime_T now; |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3884 va_list ap; |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3885 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3886 if (fd_tr == NULL) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3887 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3888 fd_tr = fopen("termresponse.log", "w"); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3889 profile_start(&start); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3890 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3891 now = start; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3892 profile_end(&now); |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3893 fprintf(fd_tr, "%s: %s ", profile_msg(&now), |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3894 must_redraw == NOT_VALID ? "NV" |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3895 : must_redraw == CLEAR ? "CL" : " "); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3896 va_start(ap, fmt); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3897 vfprintf(fd_tr, fmt, ap); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3898 va_end(ap); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3899 fputc('\n', fd_tr); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3900 fflush(fd_tr); |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3901 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3902 # endif |
7 | 3903 #endif |
3904 | |
3905 /* | |
3906 * Return TRUE when saving and restoring the screen. | |
3907 */ | |
3908 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3909 swapping_screen(void) |
7 | 3910 { |
3911 return (full_screen && *T_TI != NUL); | |
3912 } | |
3913 | |
3914 /* | |
3915 * By outputting the 'cursor very visible' termcap code, for some windowed | |
3916 * terminals this makes the screen scrolled to the correct position. | |
3917 * Used when starting Vim or returning from a shell. | |
3918 */ | |
3919 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3920 scroll_start(void) |
7 | 3921 { |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3922 if (*T_VS != NUL && *T_CVS != NUL) |
7 | 3923 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3924 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3925 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
3926 #endif |
7 | 3927 out_str(T_VS); |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3928 out_str(T_CVS); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3929 screen_start(); // don't know where cursor is now |
7 | 3930 } |
3931 } | |
3932 | |
3933 static int cursor_is_off = FALSE; | |
3934 | |
3935 /* | |
14581
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3936 * Enable the cursor without checking if it's already enabled. |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3937 */ |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3938 void |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3939 cursor_on_force(void) |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3940 { |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3941 out_str(T_VE); |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3942 cursor_is_off = FALSE; |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3943 } |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3944 |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3945 /* |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3946 * Enable the cursor if it's currently off. |
7 | 3947 */ |
3948 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3949 cursor_on(void) |
7 | 3950 { |
3951 if (cursor_is_off) | |
14581
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3952 cursor_on_force(); |
7 | 3953 } |
3954 | |
3955 /* | |
3956 * Disable the cursor. | |
3957 */ | |
3958 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3959 cursor_off(void) |
7 | 3960 { |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3961 if (full_screen && !cursor_is_off) |
7 | 3962 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3963 out_str(T_VI); // disable cursor |
7 | 3964 cursor_is_off = TRUE; |
3965 } | |
3966 } | |
3967 | |
39 | 3968 #if defined(CURSOR_SHAPE) || defined(PROTO) |
7 | 3969 /* |
6727 | 3970 * Set cursor shape to match Insert or Replace mode. |
36 | 3971 */ |
3972 void | |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3973 term_cursor_mode(int forced) |
36 | 3974 { |
12078
d21b8f31b296
patch 8.0.0919: cursor color isn't set on startup
Christian Brabandt <cb@256bit.org>
parents:
12076
diff
changeset
|
3975 static int showing_mode = -1; |
6727 | 3976 char_u *p; |
3977 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3978 // Only do something when redrawing the screen and we can restore the |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3979 // mode. |
6727 | 3980 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
|
3981 { |
12184
76fbd85c3cea
patch 8.0.0972: compiler warnings for unused variables
Christian Brabandt <cb@256bit.org>
parents:
12174
diff
changeset
|
3982 # 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
|
3983 if (forced && initial_cursor_shape > 0) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3984 // Restore to initial values. |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3985 term_cursor_shape(initial_cursor_shape, initial_cursor_blink); |
12184
76fbd85c3cea
patch 8.0.0972: compiler warnings for unused variables
Christian Brabandt <cb@256bit.org>
parents:
12174
diff
changeset
|
3986 # endif |
36 | 3987 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
|
3988 } |
36 | 3989 |
6727 | 3990 if ((State & REPLACE) == REPLACE) |
36 | 3991 { |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3992 if (forced || showing_mode != REPLACE) |
6727 | 3993 { |
3994 if (*T_CSR != NUL) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3995 p = T_CSR; // Replace mode cursor |
6727 | 3996 else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3997 p = T_CSI; // fall back to Insert mode cursor |
6727 | 3998 if (*p != NUL) |
3999 { | |
4000 out_str(p); | |
4001 showing_mode = REPLACE; | |
4002 } | |
4003 } | |
36 | 4004 } |
6727 | 4005 else if (State & INSERT) |
36 | 4006 { |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4007 if ((forced || showing_mode != INSERT) && *T_CSI != NUL) |
6727 | 4008 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4009 out_str(T_CSI); // Insert mode cursor |
6727 | 4010 showing_mode = INSERT; |
4011 } | |
4012 } | |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4013 else if (forced || showing_mode != NORMAL) |
6727 | 4014 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4015 out_str(T_CEI); // non-Insert mode cursor |
6727 | 4016 showing_mode = NORMAL; |
36 | 4017 } |
4018 } | |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4019 |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4020 # 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
|
4021 void |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4022 term_cursor_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
|
4023 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4024 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
|
4025 { |
18430
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
4026 out_str(T_CSC); // set cursor color start |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4027 out_str_nf(color); |
18430
0388e1991ec5
patch 8.1.2209: LF in escape codes may be expanded to CR-LF
Bram Moolenaar <Bram@vim.org>
parents:
18400
diff
changeset
|
4028 out_str(T_CEC); // set cursor color end |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4029 out_flush(); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4030 } |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4031 } |
12172
444793fce117
patch 8.0.0966: build failure without terminal feature
Christian Brabandt <cb@256bit.org>
parents:
12170
diff
changeset
|
4032 # endif |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4033 |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4034 int |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4035 blink_state_is_inverted() |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4036 { |
12261
875d7cc9b127
patch 8.0.1010: build failure without termresponse feature
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
4037 #ifdef FEAT_TERMRESPONSE |
16936
73e6ed2f69a2
patch 8.1.1469: no test for checking the cursor style response
Bram Moolenaar <Bram@vim.org>
parents:
16926
diff
changeset
|
4038 return rbm_status.tr_progress == STATUS_GOT |
73e6ed2f69a2
patch 8.1.1469: no test for checking the cursor style response
Bram Moolenaar <Bram@vim.org>
parents:
16926
diff
changeset
|
4039 && rcs_status.tr_progress == STATUS_GOT |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4040 && initial_cursor_blink != initial_cursor_shape_blink; |
12261
875d7cc9b127
patch 8.0.1010: build failure without termresponse feature
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
4041 #else |
875d7cc9b127
patch 8.0.1010: build failure without termresponse feature
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
4042 return FALSE; |
875d7cc9b127
patch 8.0.1010: build failure without termresponse feature
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
4043 #endif |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4044 } |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4045 |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4046 /* |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
4047 * "shape": 1 = block, 2 = underline, 3 = vertical bar |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4048 */ |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4049 void |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4050 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
|
4051 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4052 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
|
4053 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4054 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
|
4055 out_flush(); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4056 } |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4057 else |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
4058 { |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4059 int do_blink = blink; |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4060 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4061 // t_SH is empty: try setting just the blink state. |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4062 // The blink flags are XORed together, if the initial blinking from |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4063 // style and shape differs, we need to invert the flag here. |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4064 if (blink_state_is_inverted()) |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4065 do_blink = !blink; |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4066 |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4067 if (do_blink && *T_VS != NUL) |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4068 { |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4069 out_str(T_VS); |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4070 out_flush(); |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4071 } |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4072 else if (!do_blink && *T_CVS != NUL) |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4073 { |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4074 out_str(T_CVS); |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4075 out_flush(); |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4076 } |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
4077 } |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
4078 } |
39 | 4079 #endif |
36 | 4080 |
4081 /* | |
7 | 4082 * Set scrolling region for window 'wp'. |
4083 * The region starts 'off' lines from the start of the window. | |
4084 * Also set the vertical scroll region for a vertically split window. Always | |
4085 * the full width of the window, excluding the vertical separator. | |
4086 */ | |
4087 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4088 scroll_region_set(win_T *wp, int off) |
7 | 4089 { |
4090 OUT_STR(tgoto((char *)T_CS, W_WINROW(wp) + wp->w_height - 1, | |
4091 W_WINROW(wp) + off)); | |
4092 if (*T_CSV != NUL && wp->w_width != Columns) | |
12513
3ca08bf99396
patch 8.0.1135: W_WINCOL() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12497
diff
changeset
|
4093 OUT_STR(tgoto((char *)T_CSV, wp->w_wincol + wp->w_width - 1, |
3ca08bf99396
patch 8.0.1135: W_WINCOL() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12497
diff
changeset
|
4094 wp->w_wincol)); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4095 screen_start(); // don't know where cursor is now |
7 | 4096 } |
4097 | |
4098 /* | |
4099 * Reset scrolling region to the whole screen. | |
4100 */ | |
4101 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4102 scroll_region_reset(void) |
7 | 4103 { |
4104 OUT_STR(tgoto((char *)T_CS, (int)Rows - 1, 0)); | |
4105 if (*T_CSV != NUL) | |
4106 OUT_STR(tgoto((char *)T_CSV, (int)Columns - 1, 0)); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4107 screen_start(); // don't know where cursor is now |
7 | 4108 } |
4109 | |
4110 | |
4111 /* | |
4112 * List of terminal codes that are currently recognized. | |
4113 */ | |
4114 | |
298 | 4115 static struct termcode |
7 | 4116 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4117 char_u name[2]; // termcap name of entry |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4118 char_u *code; // terminal code (in allocated memory) |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4119 int len; // STRLEN(code) |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4120 int modlen; // length of part before ";*~". |
7 | 4121 } *termcodes = NULL; |
4122 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4123 static int tc_max_len = 0; // number of entries that termcodes[] can hold |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4124 static int tc_len = 0; // current number of entries in termcodes[] |
7 | 4125 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
4126 static int termcode_star(char_u *code, int len); |
180 | 4127 |
7 | 4128 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4129 clear_termcodes(void) |
7 | 4130 { |
4131 while (tc_len > 0) | |
4132 vim_free(termcodes[--tc_len].code); | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
4133 VIM_CLEAR(termcodes); |
7 | 4134 tc_max_len = 0; |
4135 | |
4136 #ifdef HAVE_TGETENT | |
4137 BC = (char *)empty_option; | |
4138 UP = (char *)empty_option; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4139 PC = NUL; // set pad character to NUL |
7 | 4140 ospeed = 0; |
4141 #endif | |
4142 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4143 need_gather = TRUE; // need to fill termleader[] |
7 | 4144 } |
4145 | |
180 | 4146 #define ATC_FROM_TERM 55 |
4147 | |
7 | 4148 /* |
4149 * Add a new entry to the list of terminal codes. | |
4150 * The list is kept alphabetical for ":set termcap" | |
180 | 4151 * "flags" is TRUE when replacing 7-bit by 8-bit controls is desired. |
4152 * "flags" can also be ATC_FROM_TERM for got_code_from_term(). | |
7 | 4153 */ |
4154 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4155 add_termcode(char_u *name, char_u *string, int flags) |
7 | 4156 { |
4157 struct termcode *new_tc; | |
4158 int i, j; | |
4159 char_u *s; | |
179 | 4160 int len; |
7 | 4161 |
4162 if (string == NULL || *string == NUL) | |
4163 { | |
4164 del_termcode(name); | |
4165 return; | |
4166 } | |
4167 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15852
diff
changeset
|
4168 #if defined(MSWIN) && !defined(FEAT_GUI) |
20830
9064044fd4f6
patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents:
20778
diff
changeset
|
4169 s = vim_strnsave(string, STRLEN(string) + 1); |
6047 | 4170 #else |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4171 # ifdef VIMDLL |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4172 if (!gui.in_use) |
20830
9064044fd4f6
patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents:
20778
diff
changeset
|
4173 s = vim_strnsave(string, STRLEN(string) + 1); |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4174 else |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4175 # endif |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4176 s = vim_strsave(string); |
6047 | 4177 #endif |
7 | 4178 if (s == NULL) |
4179 return; | |
4180 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4181 // Change leading <Esc>[ to CSI, change <Esc>O to <M-O>. |
180 | 4182 if (flags != 0 && flags != ATC_FROM_TERM && term_7to8bit(string) != 0) |
7 | 4183 { |
1623 | 4184 STRMOVE(s, s + 1); |
7 | 4185 s[0] = term_7to8bit(string); |
4186 } | |
6047 | 4187 |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4188 #if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL)) |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4189 # ifdef VIMDLL |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4190 if (!gui.in_use) |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4191 # endif |
6047 | 4192 { |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4193 if (s[0] == K_NUL) |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4194 { |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4195 STRMOVE(s + 1, s); |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4196 s[1] = 3; |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
4197 } |
6047 | 4198 } |
4199 #endif | |
4200 | |
179 | 4201 len = (int)STRLEN(s); |
7 | 4202 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4203 need_gather = TRUE; // need to fill termleader[] |
7 | 4204 |
4205 /* | |
4206 * need to make space for more entries | |
4207 */ | |
4208 if (tc_len == tc_max_len) | |
4209 { | |
4210 tc_max_len += 20; | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
4211 new_tc = ALLOC_MULT(struct termcode, tc_max_len); |
7 | 4212 if (new_tc == NULL) |
4213 { | |
4214 tc_max_len -= 20; | |
4215 return; | |
4216 } | |
4217 for (i = 0; i < tc_len; ++i) | |
4218 new_tc[i] = termcodes[i]; | |
4219 vim_free(termcodes); | |
4220 termcodes = new_tc; | |
4221 } | |
4222 | |
4223 /* | |
4224 * Look for existing entry with the same name, it is replaced. | |
4225 * Look for an existing entry that is alphabetical higher, the new entry | |
4226 * is inserted in front of it. | |
4227 */ | |
4228 for (i = 0; i < tc_len; ++i) | |
4229 { | |
4230 if (termcodes[i].name[0] < name[0]) | |
4231 continue; | |
4232 if (termcodes[i].name[0] == name[0]) | |
4233 { | |
4234 if (termcodes[i].name[1] < name[1]) | |
4235 continue; | |
4236 /* | |
180 | 4237 * Exact match: May replace old code. |
7 | 4238 */ |
4239 if (termcodes[i].name[1] == name[1]) | |
4240 { | |
180 | 4241 if (flags == ATC_FROM_TERM && (j = termcode_star( |
4242 termcodes[i].code, termcodes[i].len)) > 0) | |
179 | 4243 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4244 // Don't replace ESC[123;*X or ESC O*X with another when |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4245 // invoked from got_code_from_term(). |
180 | 4246 if (len == termcodes[i].len - j |
179 | 4247 && STRNCMP(s, termcodes[i].code, len - 1) == 0 |
180 | 4248 && s[len - 1] |
4249 == termcodes[i].code[termcodes[i].len - 1]) | |
179 | 4250 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4251 // They are equal but for the ";*": don't add it. |
179 | 4252 vim_free(s); |
4253 return; | |
4254 } | |
4255 } | |
4256 else | |
4257 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4258 // Replace old code. |
179 | 4259 vim_free(termcodes[i].code); |
4260 --tc_len; | |
4261 break; | |
4262 } | |
7 | 4263 } |
4264 } | |
4265 /* | |
4266 * Found alphabetical larger entry, move rest to insert new entry | |
4267 */ | |
4268 for (j = tc_len; j > i; --j) | |
4269 termcodes[j] = termcodes[j - 1]; | |
4270 break; | |
4271 } | |
4272 | |
4273 termcodes[i].name[0] = name[0]; | |
4274 termcodes[i].name[1] = name[1]; | |
4275 termcodes[i].code = s; | |
179 | 4276 termcodes[i].len = len; |
180 | 4277 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4278 // For xterm we recognize special codes like "ESC[42;*X" and "ESC O*X" that |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4279 // accept modifiers. |
180 | 4280 termcodes[i].modlen = 0; |
4281 j = termcode_star(s, len); | |
4282 if (j > 0) | |
23406
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
4283 { |
180 | 4284 termcodes[i].modlen = len - 1 - j; |
23406
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
4285 // For "CSI[@;X" the "@" is not included in "modlen". |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
4286 if (termcodes[i].code[termcodes[i].modlen - 1] == '@') |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
4287 --termcodes[i].modlen; |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
4288 } |
7 | 4289 ++tc_len; |
4290 } | |
4291 | |
180 | 4292 /* |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
4293 * Check termcode "code[len]" for ending in ;*X or *X. |
180 | 4294 * 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
|
4295 * Return 0 if not found, 2 for ;*X and 1 for *X. |
180 | 4296 */ |
4297 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4298 termcode_star(char_u *code, int len) |
180 | 4299 { |
23406
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
4300 // Shortest is <M-O>*X. With ; shortest is <CSI>@;*X |
180 | 4301 if (len >= 3 && code[len - 2] == '*') |
4302 { | |
4303 if (len >= 5 && code[len - 3] == ';') | |
4304 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
|
4305 else |
180 | 4306 return 1; |
4307 } | |
4308 return 0; | |
4309 } | |
4310 | |
7 | 4311 char_u * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4312 find_termcode(char_u *name) |
7 | 4313 { |
4314 int i; | |
4315 | |
4316 for (i = 0; i < tc_len; ++i) | |
4317 if (termcodes[i].name[0] == name[0] && termcodes[i].name[1] == name[1]) | |
4318 return termcodes[i].code; | |
4319 return NULL; | |
4320 } | |
4321 | |
4322 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4323 get_termcode(int i) |
7 | 4324 { |
4325 if (i >= tc_len) | |
4326 return NULL; | |
4327 return &termcodes[i].name[0]; | |
4328 } | |
4329 | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4330 /* |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4331 * Returns the length of the terminal code at index 'idx'. |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4332 */ |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4333 int |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4334 get_termcode_len(int idx) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4335 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4336 return termcodes[idx].len; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4337 } |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4338 |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4339 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4340 del_termcode(char_u *name) |
7 | 4341 { |
4342 int i; | |
4343 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4344 if (termcodes == NULL) // nothing there yet |
7 | 4345 return; |
4346 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4347 need_gather = TRUE; // need to fill termleader[] |
7 | 4348 |
4349 for (i = 0; i < tc_len; ++i) | |
4350 if (termcodes[i].name[0] == name[0] && termcodes[i].name[1] == name[1]) | |
4351 { | |
4352 del_termcode_idx(i); | |
4353 return; | |
4354 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4355 // not found. Give error message? |
7 | 4356 } |
4357 | |
4358 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4359 del_termcode_idx(int idx) |
7 | 4360 { |
4361 int i; | |
4362 | |
4363 vim_free(termcodes[idx].code); | |
4364 --tc_len; | |
4365 for (i = idx; i < tc_len; ++i) | |
4366 termcodes[i] = termcodes[i + 1]; | |
4367 } | |
4368 | |
4369 #ifdef FEAT_TERMRESPONSE | |
4370 /* | |
4371 * Called when detected that the terminal sends 8-bit codes. | |
4372 * Convert all 7-bit codes to their 8-bit equivalent. | |
4373 */ | |
4374 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4375 switch_to_8bit(void) |
7 | 4376 { |
4377 int i; | |
4378 int c; | |
4379 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4380 // Only need to do something when not already using 8-bit codes. |
7 | 4381 if (!term_is_8bit(T_NAME)) |
4382 { | |
4383 for (i = 0; i < tc_len; ++i) | |
4384 { | |
4385 c = term_7to8bit(termcodes[i].code); | |
4386 if (c != 0) | |
4387 { | |
1623 | 4388 STRMOVE(termcodes[i].code + 1, termcodes[i].code + 2); |
7 | 4389 termcodes[i].code[0] = c; |
4390 } | |
4391 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4392 need_gather = TRUE; // need to fill termleader[] |
7 | 4393 } |
4394 detected_8bit = TRUE; | |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
4395 LOG_TR(("Switching to 8 bit")); |
7 | 4396 } |
4397 #endif | |
4398 | |
4399 #ifdef CHECK_DOUBLE_CLICK | |
4400 static linenr_T orig_topline = 0; | |
4401 # ifdef FEAT_DIFF | |
4402 static int orig_topfill = 0; | |
4403 # endif | |
4404 #endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12429
diff
changeset
|
4405 #if defined(CHECK_DOUBLE_CLICK) || defined(PROTO) |
7 | 4406 /* |
4407 * Checking for double clicks ourselves. | |
4408 * "orig_topline" is used to avoid detecting a double-click when the window | |
4409 * contents scrolled (e.g., when 'scrolloff' is non-zero). | |
4410 */ | |
4411 /* | |
4412 * Set orig_topline. Used when jumping to another window, so that a double | |
4413 * click still works. | |
4414 */ | |
4415 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4416 set_mouse_topline(win_T *wp) |
7 | 4417 { |
4418 orig_topline = wp->w_topline; | |
4419 # ifdef FEAT_DIFF | |
4420 orig_topfill = wp->w_topfill; | |
4421 # endif | |
4422 } | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4423 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4424 /* |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4425 * Returns TRUE if the top line and top fill of window 'wp' matches the saved |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4426 * topline and topfill. |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4427 */ |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4428 int |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4429 is_mouse_topline(win_T *wp) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4430 { |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4431 return orig_topline == wp->w_topline |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4432 #ifdef FEAT_DIFF |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4433 && orig_topfill == wp->w_topfill |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4434 #endif |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4435 ; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4436 } |
7 | 4437 #endif |
4438 | |
4439 /* | |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4440 * Put "string[new_slen]" in typebuf, or in "buf[bufsize]" if "buf" is not NULL. |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4441 * Remove "slen" bytes. |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4442 * Returns FAIL for error. |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4443 */ |
20727
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20705
diff
changeset
|
4444 int |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4445 put_string_in_typebuf( |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4446 int offset, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4447 int slen, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4448 char_u *string, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4449 int new_slen, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4450 char_u *buf, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4451 int bufsize, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4452 int *buflen) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4453 { |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4454 int extra = new_slen - slen; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4455 |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4456 string[new_slen] = NUL; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4457 if (buf == NULL) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4458 { |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4459 if (extra < 0) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4460 // remove matched chars, taking care of noremap |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4461 del_typebuf(-extra, offset); |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4462 else if (extra > 0) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4463 // insert the extra space we need |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4464 ins_typebuf(string + slen, REMAP_YES, offset, FALSE, FALSE); |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4465 |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4466 // Careful: del_typebuf() and ins_typebuf() may have reallocated |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4467 // typebuf.tb_buf[]! |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4468 mch_memmove(typebuf.tb_buf + typebuf.tb_off + offset, string, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4469 (size_t)new_slen); |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4470 } |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4471 else |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4472 { |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4473 if (extra < 0) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4474 // remove matched characters |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4475 mch_memmove(buf + offset, buf + offset - extra, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4476 (size_t)(*buflen + offset + extra)); |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4477 else if (extra > 0) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4478 { |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4479 // Insert the extra space we need. If there is insufficient |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4480 // space return -1. |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4481 if (*buflen + extra + new_slen >= bufsize) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4482 return FAIL; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4483 mch_memmove(buf + offset + extra, buf + offset, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4484 (size_t)(*buflen - offset)); |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4485 } |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4486 mch_memmove(buf + offset, string, (size_t)new_slen); |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4487 *buflen = *buflen + extra + new_slen; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4488 } |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4489 return OK; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4490 } |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4491 |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4492 /* |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4493 * Decode a modifier number as xterm provides it into MOD_MASK bits. |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4494 */ |
18717
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4495 int |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4496 decode_modifiers(int n) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4497 { |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4498 int code = n - 1; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4499 int modifiers = 0; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4500 |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4501 if (code & 1) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4502 modifiers |= MOD_MASK_SHIFT; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4503 if (code & 2) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4504 modifiers |= MOD_MASK_ALT; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4505 if (code & 4) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4506 modifiers |= MOD_MASK_CTRL; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4507 if (code & 8) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4508 modifiers |= MOD_MASK_META; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4509 return modifiers; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4510 } |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4511 |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4512 static int |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4513 modifiers2keycode(int modifiers, int *key, char_u *string) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4514 { |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4515 int new_slen = 0; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4516 |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4517 if (modifiers != 0) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4518 { |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4519 // Some keys have the modifier included. Need to handle that here to |
22764
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4520 // make mappings work. This may result in a special key, such as |
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4521 // K_S_TAB. |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4522 *key = simplify_key(*key, &modifiers); |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4523 if (modifiers != 0) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4524 { |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4525 string[new_slen++] = K_SPECIAL; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4526 string[new_slen++] = (int)KS_MODIFIER; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4527 string[new_slen++] = modifiers; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4528 } |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4529 } |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4530 return new_slen; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4531 } |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
4532 |
20776
7728e309e013
patch 8.2.0940: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
20774
diff
changeset
|
4533 #ifdef FEAT_TERMRESPONSE |
7728e309e013
patch 8.2.0940: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
20774
diff
changeset
|
4534 /* |
7728e309e013
patch 8.2.0940: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
20774
diff
changeset
|
4535 * Handle a cursor position report. |
7728e309e013
patch 8.2.0940: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
20774
diff
changeset
|
4536 */ |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4537 static void |
20776
7728e309e013
patch 8.2.0940: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
20774
diff
changeset
|
4538 handle_u7_response(int *arg, char_u *tp UNUSED, int csi_len UNUSED) |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4539 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4540 if (arg[0] == 2 && arg[1] >= 2) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4541 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4542 char *aw = NULL; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4543 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4544 LOG_TR(("Received U7 status: %s", tp)); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4545 u7_status.tr_progress = STATUS_GOT; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4546 did_cursorhold = TRUE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4547 if (arg[1] == 2) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4548 aw = "single"; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4549 else if (arg[1] == 3) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4550 aw = "double"; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4551 if (aw != NULL && STRCMP(aw, p_ambw) != 0) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4552 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4553 // Setting the option causes a screen redraw. Do |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4554 // that right away if possible, keeping any |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4555 // messages. |
20776
7728e309e013
patch 8.2.0940: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
20774
diff
changeset
|
4556 set_option_value((char_u *)"ambw", 0L, (char_u *)aw, 0); |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4557 # ifdef DEBUG_TERMRESPONSE |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4558 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4559 int r = redraw_asap(CLEAR); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4560 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4561 log_tr("set 'ambiwidth', redraw_asap(): %d", r); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4562 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4563 # else |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4564 redraw_asap(CLEAR); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4565 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4566 # ifdef FEAT_EVAL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4567 set_vim_var_string(VV_TERMU7RESP, tp, csi_len); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4568 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4569 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4570 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4571 else if (arg[0] == 3) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4572 { |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4573 int value; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4574 |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4575 LOG_TR(("Received compatibility test result: %s", tp)); |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4576 xcc_status.tr_progress = STATUS_GOT; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4577 |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4578 // Third row: xterm compatibility test. |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4579 // If the cursor is on the first column then the terminal can handle |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4580 // the request for cursor style and blinking. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4581 value = arg[1] == 1 ? TPR_YES : TPR_NO; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4582 term_props[TPR_CURSOR_STYLE].tpr_status = value; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4583 term_props[TPR_CURSOR_BLINK].tpr_status = value; |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4584 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4585 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4586 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4587 /* |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4588 * Handle a response to T_CRV: {lead}{first}{x};{vers};{y}c |
23229
b545334ae654
patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents:
22956
diff
changeset
|
4589 * Xterm and alike use '>' for {first}. |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4590 * Rxvt sends "{lead}?1;2c". |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4591 */ |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4592 static void |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4593 handle_version_response(int first, int *arg, int argc, char_u *tp) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4594 { |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4595 // The xterm version. It is set to zero when it can't be an actual xterm |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4596 // version. |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4597 int version = arg[1]; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4598 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4599 LOG_TR(("Received CRV response: %s", tp)); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4600 crv_status.tr_progress = STATUS_GOT; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4601 did_cursorhold = TRUE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4602 |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4603 // Reset terminal properties that are set based on the termresponse. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4604 // Mainly useful for tests that send the termresponse multiple times. |
20836
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
4605 // For testing all props can be reset. |
20838
020aec2e8de9
patch 8.2.0971: build with tiny features fails
Bram Moolenaar <Bram@vim.org>
parents:
20836
diff
changeset
|
4606 init_term_props( |
020aec2e8de9
patch 8.2.0971: build with tiny features fails
Bram Moolenaar <Bram@vim.org>
parents:
20836
diff
changeset
|
4607 #ifdef FEAT_EVAL |
020aec2e8de9
patch 8.2.0971: build with tiny features fails
Bram Moolenaar <Bram@vim.org>
parents:
20836
diff
changeset
|
4608 reset_term_props_on_termresponse |
020aec2e8de9
patch 8.2.0971: build with tiny features fails
Bram Moolenaar <Bram@vim.org>
parents:
20836
diff
changeset
|
4609 #else |
020aec2e8de9
patch 8.2.0971: build with tiny features fails
Bram Moolenaar <Bram@vim.org>
parents:
20836
diff
changeset
|
4610 FALSE |
020aec2e8de9
patch 8.2.0971: build with tiny features fails
Bram Moolenaar <Bram@vim.org>
parents:
20836
diff
changeset
|
4611 #endif |
020aec2e8de9
patch 8.2.0971: build with tiny features fails
Bram Moolenaar <Bram@vim.org>
parents:
20836
diff
changeset
|
4612 ); |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4613 |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4614 // If this code starts with CSI, you can bet that the |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4615 // terminal uses 8-bit codes. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4616 if (tp[0] == CSI) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4617 switch_to_8bit(); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4618 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4619 // Screen sends 40500. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4620 // rxvt sends its version number: "20703" is 2.7.3. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4621 // Ignore it for when the user has set 'term' to xterm, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4622 // even though it's an rxvt. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4623 if (version > 20000) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4624 version = 0; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4625 |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4626 // Figure out more if the reeponse is CSI > 99 ; 99 ; 99 c |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4627 if (first == '>' && argc == 3) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4628 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4629 int need_flush = FALSE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4630 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4631 // mintty 2.9.5 sends 77;20905;0c. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4632 // (77 is ASCII 'M' for mintty.) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4633 if (arg[0] == 77) |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4634 { |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4635 // mintty can do SGR mouse reporting |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4636 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4637 } |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4638 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4639 // If xterm version >= 141 try to get termcap codes. For other |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4640 // terminals the request should be ignored. |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4641 if (version >= 141) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4642 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4643 LOG_TR(("Enable checking for XT codes")); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4644 check_for_codes = TRUE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4645 need_gather = TRUE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4646 req_codes_from_term(); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4647 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4648 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4649 // libvterm sends 0;100;0 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4650 if (version == 100 && arg[0] == 0 && arg[2] == 0) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4651 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4652 // If run from Vim $COLORS is set to the number of |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4653 // colors the terminal supports. Otherwise assume |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4654 // 256, libvterm supports even more. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4655 if (mch_getenv((char_u *)"COLORS") == NULL) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4656 may_adjust_color_count(256); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4657 // Libvterm can handle SGR mouse reporting. |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4658 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4659 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4660 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4661 if (version == 95) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4662 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4663 // Mac Terminal.app sends 1;95;0 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4664 if (arg[0] == 1 && arg[2] == 0) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4665 { |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4666 term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4667 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4668 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4669 // iTerm2 sends 0;95;0 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4670 else if (arg[0] == 0 && arg[2] == 0) |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4671 { |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4672 // iTerm2 can do SGR mouse reporting |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4673 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4674 } |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4675 // old iTerm2 sends 0;95; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4676 else if (arg[0] == 0 && arg[2] == -1) |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4677 term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES; |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4678 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4679 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4680 // screen sends 83;40500;0 83 is 'S' in ASCII. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4681 if (arg[0] == 83) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4682 { |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4683 // screen supports SGR mouse codes since 4.7.0 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4684 if (arg[1] >= 40700) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4685 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4686 else |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4687 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_XTERM; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4688 } |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4689 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4690 // If no recognized terminal has set mouse behavior, assume xterm. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4691 if (term_props[TPR_MOUSE].tpr_status == TPR_UNKNOWN) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4692 { |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4693 // Xterm version 277 supports SGR. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4694 // Xterm version >= 95 supports mouse dragging. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4695 if (version >= 277) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4696 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4697 else if (version >= 95) |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4698 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_XTERM2; |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4699 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4700 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4701 // Detect terminals that set $TERM to something like |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4702 // "xterm-256color" but are not fully xterm compatible. |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4703 // |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4704 // Gnome terminal sends 1;3801;0, 1;4402;0 or 1;2501;0. |
20850
bf7453768034
patch 8.2.0977: t_8u is made empty for the wrong terminals
Bram Moolenaar <Bram@vim.org>
parents:
20838
diff
changeset
|
4705 // Newer Gnome-terminal sends 65;6001;1. |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4706 // xfce4-terminal sends 1;2802;0. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4707 // screen sends 83;40500;0 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4708 // Assuming any version number over 2500 is not an |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4709 // xterm (without the limit for rxvt and screen). |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4710 if (arg[1] >= 2500) |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4711 term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4712 |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4713 else if (version == 136 && arg[2] == 0) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4714 { |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4715 term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4716 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4717 // PuTTY sends 0;136;0 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4718 if (arg[0] == 0) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4719 { |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4720 // supports sgr-like mouse reporting. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4721 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4722 } |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4723 // vandyke SecureCRT sends 1;136;0 |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4724 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4725 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4726 // Konsole sends 0;115;0 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4727 else if (version == 115 && arg[0] == 0 && arg[2] == 0) |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4728 term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES; |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4729 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4730 // GNU screen sends 83;30600;0, 83;40500;0, etc. |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4731 // 30600/40500 is a version number of GNU screen. DA2 support is added |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4732 // on 3.6. DCS string has a special meaning to GNU screen, but xterm |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4733 // compatibility checking does not detect GNU screen. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4734 if (arg[0] == 83 && arg[1] >= 30600) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4735 { |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4736 term_props[TPR_CURSOR_STYLE].tpr_status = TPR_NO; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4737 term_props[TPR_CURSOR_BLINK].tpr_status = TPR_NO; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4738 } |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4739 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4740 // Xterm first responded to this request at patch level |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4741 // 95, so assume anything below 95 is not xterm and hopefully supports |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4742 // the underline RGB color sequence. |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4743 if (version < 95) |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4744 term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4745 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4746 // Getting the cursor style is only supported properly by xterm since |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4747 // version 279 (otherwise it returns 0x18). |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4748 if (version < 279) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4749 term_props[TPR_CURSOR_STYLE].tpr_status = TPR_NO; |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4750 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4751 /* |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4752 * Take action on the detected properties. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4753 */ |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4754 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4755 // Unless the underline RGB color is expected to work, disable "t_8u". |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4756 // It does not work for the real Xterm, it resets the background color. |
20850
bf7453768034
patch 8.2.0977: t_8u is made empty for the wrong terminals
Bram Moolenaar <Bram@vim.org>
parents:
20838
diff
changeset
|
4757 if (term_props[TPR_UNDERLINE_RGB].tpr_status != TPR_YES && *T_8U != NUL) |
20854
bd56f4045f37
patch 8.2.0979: a couple of screendump tests fail
Bram Moolenaar <Bram@vim.org>
parents:
20852
diff
changeset
|
4758 set_string_option_direct((char_u *)"t_8u", -1, (char_u *)"", |
bd56f4045f37
patch 8.2.0979: a couple of screendump tests fail
Bram Moolenaar <Bram@vim.org>
parents:
20852
diff
changeset
|
4759 OPT_FREE, 0); |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4760 |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4761 // Only set 'ttymouse' automatically if it was not set |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4762 // by the user already. |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4763 if (!option_was_set((char_u *)"ttym") |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4764 && (term_props[TPR_MOUSE].tpr_status == TPR_MOUSE_XTERM2 |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4765 || term_props[TPR_MOUSE].tpr_status == TPR_MOUSE_SGR)) |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4766 { |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4767 set_option_value((char_u *)"ttym", 0L, |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4768 term_props[TPR_MOUSE].tpr_status == TPR_MOUSE_SGR |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4769 ? (char_u *)"sgr" : (char_u *)"xterm2", 0); |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4770 } |
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4771 |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4772 // Only request the cursor style if t_SH and t_RS are |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4773 // set. Only supported properly by xterm since version |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4774 // 279 (otherwise it returns 0x18). |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4775 // Only when getting the cursor style was detected to work. |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4776 // Not for Terminal.app, it can't handle t_RS, it |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4777 // echoes the characters to the screen. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4778 if (rcs_status.tr_progress == STATUS_GET |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4779 && term_props[TPR_CURSOR_STYLE].tpr_status == TPR_YES |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4780 && *T_CSH != NUL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4781 && *T_CRS != NUL) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4782 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
4783 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
4784 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
4785 #endif |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4786 LOG_TR(("Sending cursor style request")); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4787 out_str(T_CRS); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4788 termrequest_sent(&rcs_status); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4789 need_flush = TRUE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4790 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4791 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4792 // Only request the cursor blink mode if t_RC set. Not |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4793 // for Gnome terminal, it can't handle t_RC, it |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4794 // echoes the characters to the screen. |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4795 // Only when getting the cursor style was detected to work. |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4796 if (rbm_status.tr_progress == STATUS_GET |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4797 && term_props[TPR_CURSOR_BLINK].tpr_status == TPR_YES |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4798 && *T_CRC != NUL) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4799 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
4800 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
4801 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
4802 #endif |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4803 LOG_TR(("Sending cursor blink mode request")); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4804 out_str(T_CRC); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4805 termrequest_sent(&rbm_status); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4806 need_flush = TRUE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4807 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4808 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4809 if (need_flush) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4810 out_flush(); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4811 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4812 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4813 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4814 /* |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4815 * Handle a sequence with key and modifier, one of: |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4816 * {lead}27;{modifier};{key}~ |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4817 * {lead}{key};{modifier}u |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4818 * Returns the difference in length. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4819 */ |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4820 static int |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4821 handle_key_with_modifier( |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4822 int *arg, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4823 int trail, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4824 int csi_len, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4825 int offset, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4826 char_u *buf, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4827 int bufsize, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4828 int *buflen) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4829 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4830 int key; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4831 int modifiers; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4832 int new_slen; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4833 char_u string[MAX_KEY_CODE_LEN + 1]; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4834 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4835 seenModifyOtherKeys = TRUE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4836 if (trail == 'u') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4837 key = arg[0]; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4838 else |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4839 key = arg[2]; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4840 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4841 modifiers = decode_modifiers(arg[1]); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4842 |
22522
6c7e4db139a3
patch 8.2.1809: mapping some keys with Ctrl does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
22091
diff
changeset
|
4843 // Some keys need adjustment when the Ctrl modifier is used. |
6c7e4db139a3
patch 8.2.1809: mapping some keys with Ctrl does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
22091
diff
changeset
|
4844 key = may_adjust_key_for_ctrl(modifiers, key); |
6c7e4db139a3
patch 8.2.1809: mapping some keys with Ctrl does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
22091
diff
changeset
|
4845 |
20935
d64520bfafa0
patch 8.2.1019: mapping <M-S-a> does not work in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20927
diff
changeset
|
4846 // May remove the shift modifier if it's already included in the key. |
d64520bfafa0
patch 8.2.1019: mapping <M-S-a> does not work in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20927
diff
changeset
|
4847 modifiers = may_remove_shift_modifier(modifiers, key); |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4848 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4849 // insert modifiers with KS_MODIFIER |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4850 new_slen = modifiers2keycode(modifiers, &key, string); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4851 |
22764
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4852 if (IS_SPECIAL(key)) |
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4853 { |
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4854 string[new_slen++] = K_SPECIAL; |
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4855 string[new_slen++] = KEY2TERMCAP0(key); |
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4856 string[new_slen++] = KEY2TERMCAP1(key); |
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4857 } |
d03221aa54f3
patch 8.2.1930: wrong input if removing shift results in special key code
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
4858 else if (has_mbyte) |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4859 new_slen += (*mb_char2bytes)(key, string + new_slen); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4860 else |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4861 string[new_slen++] = key; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4862 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4863 if (put_string_in_typebuf(offset, csi_len, string, new_slen, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4864 buf, bufsize, buflen) == FAIL) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4865 return -1; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4866 return new_slen - csi_len + offset; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4867 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4868 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4869 /* |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4870 * Handle a CSI escape sequence. |
20778
6d5e233bac9c
patch 8.2.0941: detecting terminal properties is unstructured
Bram Moolenaar <Bram@vim.org>
parents:
20776
diff
changeset
|
4871 * - Xterm version string. |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4872 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4873 * - Cursor position report: {lead}{row};{col}R |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4874 * The final byte must be 'R'. It is used for checking the |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4875 * ambiguous-width character state. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4876 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4877 * - window position reply: {lead}3;{x};{y}t |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4878 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4879 * - key with modifiers when modifyOtherKeys is enabled: |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4880 * {lead}27;{modifier};{key}~ |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4881 * {lead}{key};{modifier}u |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4882 * Return 0 for no match, -1 for partial match, > 0 for full match. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4883 */ |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4884 static int |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4885 handle_csi( |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4886 char_u *tp, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4887 int len, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4888 char_u *argp, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4889 int offset, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4890 char_u *buf, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4891 int bufsize, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4892 int *buflen, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4893 char_u *key_name, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4894 int *slen) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4895 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4896 int first = -1; // optional char right after {lead} |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4897 int trail; // char that ends CSI sequence |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4898 int arg[3] = {-1, -1, -1}; // argument numbers |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4899 int argc; // number of arguments |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4900 char_u *ap = argp; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4901 int csi_len; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4902 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4903 // Check for non-digit after CSI. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4904 if (!VIM_ISDIGIT(*ap)) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4905 first = *ap++; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4906 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4907 // Find up to three argument numbers. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4908 for (argc = 0; argc < 3; ) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4909 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4910 if (ap >= tp + len) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4911 return -1; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4912 if (*ap == ';') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4913 arg[argc++] = -1; // omitted number |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4914 else if (VIM_ISDIGIT(*ap)) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4915 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4916 arg[argc] = 0; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4917 for (;;) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4918 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4919 if (ap >= tp + len) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4920 return -1; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4921 if (!VIM_ISDIGIT(*ap)) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4922 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4923 arg[argc] = arg[argc] * 10 + (*ap - '0'); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4924 ++ap; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4925 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4926 ++argc; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4927 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4928 if (*ap == ';') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4929 ++ap; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4930 else |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4931 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4932 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4933 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4934 // mrxvt has been reported to have "+" in the version. Assume |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4935 // the escape sequence ends with a letter or one of "{|}~". |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4936 while (ap < tp + len |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4937 && !(*ap >= '{' && *ap <= '~') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4938 && !ASCII_ISALPHA(*ap)) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4939 ++ap; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4940 if (ap >= tp + len) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4941 return -1; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4942 trail = *ap; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4943 csi_len = (int)(ap - tp) + 1; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4944 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4945 // Cursor position report: Eat it when there are 2 arguments |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4946 // and it ends in 'R'. Also when u7_status is not "sent", it |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4947 // may be from a previous Vim that just exited. But not for |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4948 // <S-F3>, it sends something similar, check for row and column |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4949 // to make sense. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4950 if (first == -1 && argc == 2 && trail == 'R') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4951 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4952 handle_u7_response(arg, tp, csi_len); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4953 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4954 key_name[0] = (int)KS_EXTRA; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4955 key_name[1] = (int)KE_IGNORE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4956 *slen = csi_len; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4957 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4958 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4959 // Version string: Eat it when there is at least one digit and |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4960 // it ends in 'c' |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4961 else if (*T_CRV != NUL && ap > argp + 1 && trail == 'c') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4962 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4963 handle_version_response(first, arg, argc, tp); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4964 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4965 *slen = csi_len; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4966 # ifdef FEAT_EVAL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4967 set_vim_var_string(VV_TERMRESPONSE, tp, *slen); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4968 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4969 apply_autocmds(EVENT_TERMRESPONSE, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4970 NULL, NULL, FALSE, curbuf); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4971 key_name[0] = (int)KS_EXTRA; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4972 key_name[1] = (int)KE_IGNORE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4973 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4974 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4975 // Check blinking cursor from xterm: |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4976 // {lead}?12;1$y set |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4977 // {lead}?12;2$y not set |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4978 // |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4979 // {lead} can be <Esc>[ or CSI |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4980 else if (rbm_status.tr_progress == STATUS_SENT |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4981 && first == '?' |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4982 && ap == argp + 6 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4983 && arg[0] == 12 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4984 && ap[-1] == '$' |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4985 && trail == 'y') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4986 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4987 initial_cursor_blink = (arg[1] == '1'); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4988 rbm_status.tr_progress = STATUS_GOT; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4989 LOG_TR(("Received cursor blinking mode response: %s", tp)); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4990 key_name[0] = (int)KS_EXTRA; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4991 key_name[1] = (int)KE_IGNORE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4992 *slen = csi_len; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4993 # ifdef FEAT_EVAL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4994 set_vim_var_string(VV_TERMBLINKRESP, tp, *slen); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4995 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4996 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4997 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4998 // Check for a window position response from the terminal: |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
4999 // {lead}3;{x};{y}t |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5000 else if (did_request_winpos && argc == 3 && arg[0] == 3 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5001 && trail == 't') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5002 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5003 winpos_x = arg[1]; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5004 winpos_y = arg[2]; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5005 // got finished code: consume it |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5006 key_name[0] = (int)KS_EXTRA; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5007 key_name[1] = (int)KE_IGNORE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5008 *slen = csi_len; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5009 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5010 if (--did_request_winpos <= 0) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5011 winpos_status.tr_progress = STATUS_GOT; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5012 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5013 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5014 // Key with modifier: |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5015 // {lead}27;{modifier};{key}~ |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5016 // {lead}{key};{modifier}u |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5017 else if ((arg[0] == 27 && argc == 3 && trail == '~') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5018 || (argc == 2 && trail == 'u')) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5019 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5020 return len + handle_key_with_modifier(arg, trail, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5021 csi_len, offset, buf, bufsize, buflen); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5022 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5023 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5024 // else: Unknown CSI sequence. We could drop it, but then the |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5025 // user can't create a map for it. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5026 return 0; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5027 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5028 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5029 /* |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5030 * Handle an OSC sequence, fore/background color response from the terminal: |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5031 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5032 * {lead}{code};rgb:{rrrr}/{gggg}/{bbbb}{tail} |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5033 * or {lead}{code};rgb:{rr}/{gg}/{bb}{tail} |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5034 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5035 * {code} is 10 for foreground, 11 for background |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5036 * {lead} can be <Esc>] or OSC |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5037 * {tail} can be '\007', <Esc>\ or STERM. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5038 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5039 * Consume any code that starts with "{lead}11;", it's also |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5040 * possible that "rgba" is following. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5041 */ |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5042 static int |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5043 handle_osc(char_u *tp, char_u *argp, int len, char_u *key_name, int *slen) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5044 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5045 int i, j; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5046 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5047 j = 1 + (tp[0] == ESC); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5048 if (len >= j + 3 && (argp[0] != '1' |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5049 || (argp[1] != '1' && argp[1] != '0') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5050 || argp[2] != ';')) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5051 i = 0; // no match |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5052 else |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5053 for (i = j; i < len; ++i) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5054 if (tp[i] == '\007' || (tp[0] == OSC ? tp[i] == STERM |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5055 : (tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\'))) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5056 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5057 int is_bg = argp[1] == '1'; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5058 int is_4digit = i - j >= 21 && tp[j + 11] == '/' |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5059 && tp[j + 16] == '/'; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5060 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5061 if (i - j >= 15 && STRNCMP(tp + j + 3, "rgb:", 4) == 0 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5062 && (is_4digit |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5063 || (tp[j + 9] == '/' && tp[i + 12 == '/']))) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5064 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5065 char_u *tp_r = tp + j + 7; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5066 char_u *tp_g = tp + j + (is_4digit ? 12 : 10); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5067 char_u *tp_b = tp + j + (is_4digit ? 17 : 13); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5068 # ifdef FEAT_TERMINAL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5069 int rval, gval, bval; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5070 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5071 rval = hexhex2nr(tp_r); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5072 gval = hexhex2nr(tp_b); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5073 bval = hexhex2nr(tp_g); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5074 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5075 if (is_bg) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5076 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5077 char *new_bg_val = (3 * '6' < *tp_r + *tp_g + |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5078 *tp_b) ? "light" : "dark"; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5079 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5080 LOG_TR(("Received RBG response: %s", tp)); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5081 rbg_status.tr_progress = STATUS_GOT; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5082 # ifdef FEAT_TERMINAL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5083 bg_r = rval; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5084 bg_g = gval; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5085 bg_b = bval; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5086 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5087 if (!option_was_set((char_u *)"bg") |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5088 && STRCMP(p_bg, new_bg_val) != 0) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5089 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5090 // value differs, apply it |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5091 set_option_value((char_u *)"bg", 0L, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5092 (char_u *)new_bg_val, 0); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5093 reset_option_was_set((char_u *)"bg"); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5094 redraw_asap(CLEAR); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5095 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5096 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5097 # ifdef FEAT_TERMINAL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5098 else |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5099 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5100 LOG_TR(("Received RFG response: %s", tp)); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5101 rfg_status.tr_progress = STATUS_GOT; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5102 fg_r = rval; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5103 fg_g = gval; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5104 fg_b = bval; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5105 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5106 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5107 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5108 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5109 // got finished code: consume it |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5110 key_name[0] = (int)KS_EXTRA; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5111 key_name[1] = (int)KE_IGNORE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5112 *slen = i + 1 + (tp[i] == ESC); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5113 # ifdef FEAT_EVAL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5114 set_vim_var_string(is_bg ? VV_TERMRBGRESP |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5115 : VV_TERMRFGRESP, tp, *slen); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5116 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5117 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5118 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5119 if (i == len) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5120 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5121 LOG_TR(("not enough characters for RB")); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5122 return FAIL; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5123 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5124 return OK; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5125 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5126 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5127 /* |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5128 * Check for key code response from xterm: |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5129 * {lead}{flag}+r<hex bytes><{tail} |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5130 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5131 * {lead} can be <Esc>P or DCS |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5132 * {flag} can be '0' or '1' |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5133 * {tail} can be Esc>\ or STERM |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5134 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5135 * Check for cursor shape response from xterm: |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5136 * {lead}1$r<digit> q{tail} |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5137 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5138 * {lead} can be <Esc>P or DCS |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5139 * {tail} can be <Esc>\ or STERM |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5140 * |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5141 * Consume any code that starts with "{lead}.+r" or "{lead}.$r". |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5142 */ |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5143 static int |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5144 handle_dcs(char_u *tp, char_u *argp, int len, char_u *key_name, int *slen) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5145 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5146 int i, j; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5147 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5148 j = 1 + (tp[0] == ESC); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5149 if (len < j + 3) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5150 i = len; // need more chars |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5151 else if ((argp[1] != '+' && argp[1] != '$') || argp[2] != 'r') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5152 i = 0; // no match |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5153 else if (argp[1] == '+') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5154 // key code response |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5155 for (i = j; i < len; ++i) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5156 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5157 if ((tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5158 || tp[i] == STERM) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5159 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5160 if (i - j >= 3) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5161 got_code_from_term(tp + j, i); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5162 key_name[0] = (int)KS_EXTRA; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5163 key_name[1] = (int)KE_IGNORE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5164 *slen = i + 1 + (tp[i] == ESC); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5165 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5166 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5167 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5168 else |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5169 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5170 // Probably the cursor shape response. Make sure that "i" |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5171 // is equal to "len" when there are not sufficient |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5172 // characters. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5173 for (i = j + 3; i < len; ++i) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5174 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5175 if (i - j == 3 && !isdigit(tp[i])) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5176 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5177 if (i - j == 4 && tp[i] != ' ') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5178 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5179 if (i - j == 5 && tp[i] != 'q') |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5180 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5181 if (i - j == 6 && tp[i] != ESC && tp[i] != STERM) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5182 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5183 if ((i - j == 6 && tp[i] == STERM) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5184 || (i - j == 7 && tp[i] == '\\')) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5185 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5186 int number = argp[3] - '0'; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5187 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5188 // 0, 1 = block blink, 2 = block |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5189 // 3 = underline blink, 4 = underline |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5190 // 5 = vertical bar blink, 6 = vertical bar |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5191 number = number == 0 ? 1 : number; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5192 initial_cursor_shape = (number + 1) / 2; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5193 // The blink flag is actually inverted, compared to |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5194 // the value set with T_SH. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5195 initial_cursor_shape_blink = |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5196 (number & 1) ? FALSE : TRUE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5197 rcs_status.tr_progress = STATUS_GOT; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5198 LOG_TR(("Received cursor shape response: %s", tp)); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5199 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5200 key_name[0] = (int)KS_EXTRA; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5201 key_name[1] = (int)KE_IGNORE; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5202 *slen = i + 1; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5203 # ifdef FEAT_EVAL |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5204 set_vim_var_string(VV_TERMSTYLERESP, tp, *slen); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5205 # endif |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5206 break; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5207 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5208 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5209 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5210 |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5211 if (i == len) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5212 { |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5213 // These codes arrive many together, each code can be |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5214 // truncated at any point. |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5215 LOG_TR(("not enough characters for XT")); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5216 return FAIL; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5217 } |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5218 return OK; |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5219 } |
20776
7728e309e013
patch 8.2.0940: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
20774
diff
changeset
|
5220 #endif // FEAT_TERMRESPONSE |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5221 |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5222 /* |
7 | 5223 * Check if typebuf.tb_buf[] contains a terminal key code. |
5224 * Check from typebuf.tb_buf[typebuf.tb_off] to typebuf.tb_buf[typebuf.tb_off | |
20727
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20705
diff
changeset
|
5225 * + "max_offset"]. |
7 | 5226 * Return 0 for no match, -1 for partial match, > 0 for full match. |
2672 | 5227 * Return KEYLEN_REMOVED when a key code was deleted. |
7 | 5228 * With a match, the match is removed, the replacement code is inserted in |
5229 * typebuf.tb_buf[] and the number of characters in typebuf.tb_buf[] is | |
5230 * returned. | |
3328 | 5231 * When "buf" is not NULL, buf[bufsize] is used instead of typebuf.tb_buf[]. |
5232 * "buflen" is then the length of the string in buf[] and is updated for | |
5233 * inserts and deletes. | |
7 | 5234 */ |
5235 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5236 check_termcode( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5237 int max_offset, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5238 char_u *buf, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5239 int bufsize, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5240 int *buflen) |
7 | 5241 { |
5242 char_u *tp; | |
5243 char_u *p; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5244 int slen = 0; // init for GCC |
180 | 5245 int modslen; |
7 | 5246 int len; |
2672 | 5247 int retval = 0; |
7 | 5248 int offset; |
5249 char_u key_name[2]; | |
180 | 5250 int modifiers; |
11565
91519a14ec1f
patch 8.0.0665: warning for uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
11563
diff
changeset
|
5251 char_u *modifiers_start = NULL; |
180 | 5252 int key; |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5253 int new_slen; // Length of what will replace the termcode |
7 | 5254 char_u string[MAX_KEY_CODE_LEN + 1]; |
5255 int i, j; | |
5256 int idx = 0; | |
5257 int cpo_koffset; | |
5258 | |
5259 cpo_koffset = (vim_strchr(p_cpo, CPO_KOFFSET) != NULL); | |
5260 | |
5261 /* | |
5262 * Speed up the checks for terminal codes by gathering all first bytes | |
5263 * used in termleader[]. Often this is just a single <Esc>. | |
5264 */ | |
5265 if (need_gather) | |
5266 gather_termleader(); | |
5267 | |
5268 /* | |
5269 * Check at several positions in typebuf.tb_buf[], to catch something like | |
5270 * "x<Up>" that can be mapped. Stop at max_offset, because characters | |
5271 * after that cannot be used for mapping, and with @r commands | |
4223 | 5272 * typebuf.tb_buf[] can become very long. |
7 | 5273 * This is used often, KEEP IT FAST! |
5274 */ | |
5275 for (offset = 0; offset < max_offset; ++offset) | |
5276 { | |
5277 if (buf == NULL) | |
5278 { | |
5279 if (offset >= typebuf.tb_len) | |
5280 break; | |
5281 tp = typebuf.tb_buf + typebuf.tb_off + offset; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5282 len = typebuf.tb_len - offset; // length of the input |
7 | 5283 } |
5284 else | |
5285 { | |
3328 | 5286 if (offset >= *buflen) |
7 | 5287 break; |
5288 tp = buf + offset; | |
3328 | 5289 len = *buflen - offset; |
7 | 5290 } |
5291 | |
5292 /* | |
5293 * Don't check characters after K_SPECIAL, those are already | |
5294 * translated terminal chars (avoid translating ~@^Hx). | |
5295 */ | |
5296 if (*tp == K_SPECIAL) | |
5297 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5298 offset += 2; // there are always 2 extra characters |
7 | 5299 continue; |
5300 } | |
5301 | |
5302 /* | |
5303 * Skip this position if the character does not appear as the first | |
5304 * character in term_strings. This speeds up a lot, since most | |
5305 * termcodes start with the same character (ESC or CSI). | |
5306 */ | |
5307 i = *tp; | |
5308 for (p = termleader; *p && *p != i; ++p) | |
5309 ; | |
5310 if (*p == NUL) | |
5311 continue; | |
5312 | |
5313 /* | |
5314 * Skip this position if p_ek is not set and tp[0] is an ESC and we | |
5315 * are in Insert mode. | |
5316 */ | |
5317 if (*tp == ESC && !p_ek && (State & INSERT)) | |
5318 continue; | |
5319 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5320 key_name[0] = NUL; // no key name found yet |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5321 key_name[1] = NUL; // no key name found yet |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5322 modifiers = 0; // no modifiers yet |
7 | 5323 |
5324 #ifdef FEAT_GUI | |
5325 if (gui.in_use) | |
5326 { | |
5327 /* | |
5328 * GUI special key codes are all of the form [CSI xx]. | |
5329 */ | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5330 if (*tp == CSI) // Special key from GUI |
7 | 5331 { |
5332 if (len < 3) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5333 return -1; // Shouldn't happen |
7 | 5334 slen = 3; |
5335 key_name[0] = tp[1]; | |
5336 key_name[1] = tp[2]; | |
5337 } | |
5338 } | |
5339 else | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5340 #endif // FEAT_GUI |
7 | 5341 { |
23774
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5342 int mouse_index_found = -1; |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5343 |
7 | 5344 for (idx = 0; idx < tc_len; ++idx) |
5345 { | |
5346 /* | |
5347 * Ignore the entry if we are not at the start of | |
5348 * typebuf.tb_buf[] | |
5349 * and there are not enough characters to make a match. | |
5350 * But only when the 'K' flag is in 'cpoptions'. | |
5351 */ | |
5352 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
|
5353 modifiers_start = NULL; |
7 | 5354 if (cpo_koffset && offset && len < slen) |
5355 continue; | |
5356 if (STRNCMP(termcodes[idx].code, tp, | |
5357 (size_t)(slen > len ? len : slen)) == 0) | |
5358 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5359 if (len < slen) // got a partial sequence |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5360 return -1; // need to get more chars |
7 | 5361 |
5362 /* | |
5363 * When found a keypad key, check if there is another key | |
5364 * that matches and use that one. This makes <Home> to be | |
5365 * found instead of <kHome> when they produce the same | |
5366 * key code. | |
5367 */ | |
5368 if (termcodes[idx].name[0] == 'K' | |
5369 && VIM_ISDIGIT(termcodes[idx].name[1])) | |
5370 { | |
5371 for (j = idx + 1; j < tc_len; ++j) | |
5372 if (termcodes[j].len == slen && | |
5373 STRNCMP(termcodes[idx].code, | |
5374 termcodes[j].code, slen) == 0) | |
5375 { | |
5376 idx = j; | |
5377 break; | |
5378 } | |
5379 } | |
5380 | |
23774
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5381 // The mouse termcode "ESC [" is also the prefix of |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5382 // "ESC [ I" (focus gained). Only use it when there is |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5383 // no other match. Do use it when a digit is following to |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5384 // avoid waiting for more bytes. |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5385 if (slen == 2 && len > 2 |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5386 && termcodes[idx].code[0] == ESC |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5387 && termcodes[idx].code[1] == '[' |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5388 && !isdigit(tp[2])) |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5389 { |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5390 if (mouse_index_found < 0) |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5391 mouse_index_found = idx; |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5392 } |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5393 else |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5394 { |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5395 key_name[0] = termcodes[idx].name[0]; |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5396 key_name[1] = termcodes[idx].name[1]; |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5397 break; |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5398 } |
7 | 5399 } |
179 | 5400 |
5401 /* | |
5402 * Check for code with modifier, like xterm uses: | |
180 | 5403 * <Esc>[123;*X (modslen == slen - 3) |
23406
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5404 * <Esc>[@;*X (matches <Esc>[X and <Esc>[1;9X ) |
180 | 5405 * Also <Esc>O*X and <M-O>*X (modslen == slen - 2). |
5406 * When there is a modifier the * matches a number. | |
5407 * When there is no modifier the ;* or * is omitted. | |
179 | 5408 */ |
23774
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5409 if (termcodes[idx].modlen > 0 && mouse_index_found < 0) |
179 | 5410 { |
23406
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5411 int at_code; |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5412 |
180 | 5413 modslen = termcodes[idx].modlen; |
5414 if (cpo_koffset && offset && len < modslen) | |
179 | 5415 continue; |
23406
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5416 at_code = termcodes[idx].code[modslen] == '@'; |
179 | 5417 if (STRNCMP(termcodes[idx].code, tp, |
180 | 5418 (size_t)(modslen > len ? len : modslen)) == 0) |
179 | 5419 { |
5420 int n; | |
180 | 5421 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5422 if (len <= modslen) // got a partial sequence |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5423 return -1; // need to get more chars |
179 | 5424 |
180 | 5425 if (tp[modslen] == termcodes[idx].code[slen - 1]) |
23406
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5426 // no modifiers |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5427 slen = modslen + 1; |
180 | 5428 else if (tp[modslen] != ';' && modslen == slen - 3) |
23406
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5429 // no match for "code;*X" with "code;" |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5430 continue; |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5431 else if (at_code && tp[modslen] != '1') |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5432 // no match for "<Esc>[@" with "<Esc>[1" |
24ce202a7d68
patch 8.2.2246: cursor keys not recognized at the hit-Enter prompt
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
5433 continue; |
179 | 5434 else |
5435 { | |
16485
b870146e09e1
patch 8.1.1246: cannot handle negative mouse coordinate from urxvt
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
5436 // Skip over the digits, the final char must |
b870146e09e1
patch 8.1.1246: cannot handle negative mouse coordinate from urxvt
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
5437 // follow. URXVT can use a negative value, thus |
b870146e09e1
patch 8.1.1246: cannot handle negative mouse coordinate from urxvt
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
5438 // also accept '-'. |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
5439 for (j = slen - 2; j < len && (isdigit(tp[j]) |
16485
b870146e09e1
patch 8.1.1246: cannot handle negative mouse coordinate from urxvt
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
5440 || tp[j] == '-' || tp[j] == ';'); ++j) |
179 | 5441 ; |
5442 ++j; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5443 if (len < j) // got a partial sequence |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5444 return -1; // need to get more chars |
180 | 5445 if (tp[j - 1] != termcodes[idx].code[slen - 1]) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5446 continue; // no match |
179 | 5447 |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
5448 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
|
5449 |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5450 // Match! Convert modifier bits. |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5451 n = atoi((char *)modifiers_start); |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5452 modifiers |= decode_modifiers(n); |
179 | 5453 |
5454 slen = j; | |
5455 } | |
5456 key_name[0] = termcodes[idx].name[0]; | |
5457 key_name[1] = termcodes[idx].name[1]; | |
5458 break; | |
5459 } | |
5460 } | |
7 | 5461 } |
23774
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5462 if (idx == tc_len && mouse_index_found >= 0) |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5463 { |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5464 key_name[0] = termcodes[mouse_index_found].name[0]; |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5465 key_name[1] = termcodes[mouse_index_found].name[1]; |
646ca2893d85
patch 8.2.2428: FocusGained does not work when 'ttymouse' is empty
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5466 } |
7 | 5467 } |
5468 | |
5469 #ifdef FEAT_TERMRESPONSE | |
3166 | 5470 if (key_name[0] == NUL |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5471 // Mouse codes of DEC and pterm start with <ESC>[. When |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5472 // detecting the start of these mouse codes they might as well be |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5473 // another key code or terminal response. |
6102 | 5474 # ifdef FEAT_MOUSE_DEC |
5475 || key_name[0] == KS_DEC_MOUSE | |
5476 # endif | |
5477 # ifdef FEAT_MOUSE_PTERM | |
5478 || key_name[0] == KS_PTERM_MOUSE | |
4223 | 5479 # endif |
6102 | 5480 ) |
7 | 5481 { |
18257
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5482 char_u *argp = tp[0] == ESC ? tp + 2 : tp + 1; |
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5483 |
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5484 /* |
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5485 * Check for responses from the terminal starting with {lead}: |
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5486 * "<Esc>[" or CSI followed by [0-9>?] |
4215 | 5487 * |
18257
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5488 * - Xterm version string: {lead}>{x};{vers};{y}c |
4215 | 5489 * Also eat other possible responses to t_RV, rxvt returns |
18257
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5490 * "{lead}?1;2c". |
4215 | 5491 * |
18257
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5492 * - Cursor position report: {lead}{row};{col}R |
6102 | 5493 * The final byte must be 'R'. It is used for checking the |
4215 | 5494 * 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
|
5495 * |
18257
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5496 * - window position reply: {lead}3;{x};{y}t |
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5497 * |
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5498 * - key with modifiers when modifyOtherKeys is enabled: |
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5499 * {lead}27;{modifier};{key}~ |
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5500 * {lead}{key};{modifier}u |
4215 | 5501 */ |
18257
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5502 if (((tp[0] == ESC && len >= 3 && tp[1] == '[') |
4395 | 5503 || (tp[0] == CSI && len >= 2)) |
18257
f5a6c8261f64
patch 8.1.2123: parsing CSI sequence is messy
Bram Moolenaar <Bram@vim.org>
parents:
18150
diff
changeset
|
5504 && (VIM_ISDIGIT(*argp) || *argp == '>' || *argp == '?')) |
7 | 5505 { |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5506 int resp = handle_csi(tp, len, argp, offset, buf, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5507 bufsize, buflen, key_name, &slen); |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5508 if (resp != 0) |
7 | 5509 { |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5510 # ifdef DEBUG_TERMRESPONSE |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5511 if (resp == -1) |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5512 LOG_TR(("Not enough characters for CSI sequence")); |
7 | 5513 # endif |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5514 return resp; |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
5515 } |
6901 | 5516 } |
5517 | |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5518 // Check for fore/background color response from the terminal, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5519 // starting} with <Esc>] or OSC |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5520 else if ((*T_RBG != NUL || *T_RFG != NUL) |
6901 | 5521 && ((tp[0] == ESC && len >= 2 && tp[1] == ']') |
5522 || tp[0] == OSC)) | |
5523 { | |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5524 if (handle_osc(tp, argp, len, key_name, &slen) == FAIL) |
6901 | 5525 return -1; |
7 | 5526 } |
5527 | |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5528 // Check for key code response from xterm, |
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5529 // starting with <Esc>P or DCS |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
5530 else if ((check_for_codes || rcs_status.tr_progress == STATUS_SENT) |
6901 | 5531 && ((tp[0] == ESC && len >= 2 && tp[1] == 'P') |
7 | 5532 || tp[0] == DCS)) |
5533 { | |
20774
10535993e913
patch 8.2.0939: checking for term escape sequences is long and confusing
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
5534 if (handle_dcs(tp, argp, len, key_name, &slen) == FAIL) |
6901 | 5535 return -1; |
7 | 5536 } |
5537 } | |
5538 #endif | |
5539 | |
5540 if (key_name[0] == NUL) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5541 continue; // No match at this position, try next one |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5542 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5543 // We only get here when we have a complete termcode match |
7 | 5544 |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5545 #ifdef FEAT_GUI |
7 | 5546 /* |
5547 * Only in the GUI: Fetch the pointer coordinates of the scroll event | |
5548 * so that we know which window to scroll later. | |
5549 */ | |
5550 if (gui.in_use | |
5551 && key_name[0] == (int)KS_EXTRA | |
5552 && (key_name[1] == (int)KE_X1MOUSE | |
5553 || 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
|
5554 || key_name[1] == (int)KE_MOUSELEFT |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2347
diff
changeset
|
5555 || key_name[1] == (int)KE_MOUSERIGHT |
7 | 5556 || key_name[1] == (int)KE_MOUSEDOWN |
5557 || key_name[1] == (int)KE_MOUSEUP)) | |
5558 { | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5559 char_u bytes[6]; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5560 int num_bytes = get_bytes_from_buf(tp + slen, bytes, 4); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5561 |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5562 if (num_bytes == -1) // not enough coordinates |
7 | 5563 return -1; |
5564 mouse_col = 128 * (bytes[0] - ' ' - 1) + bytes[1] - ' ' - 1; | |
5565 mouse_row = 128 * (bytes[2] - ' ' - 1) + bytes[3] - ' ' - 1; | |
5566 slen += num_bytes; | |
5567 } | |
5568 else | |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5569 #endif |
7 | 5570 /* |
5571 * If it is a mouse click, get the coordinates. | |
5572 */ | |
3746 | 5573 if (key_name[0] == KS_MOUSE |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5574 #ifdef FEAT_MOUSE_GPM |
16523
a72ad8a8b249
patch 8.1.1265: when GPM mouse support is enabled double clicks do not work
Bram Moolenaar <Bram@vim.org>
parents:
16501
diff
changeset
|
5575 || key_name[0] == KS_GPM_MOUSE |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5576 #endif |
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5577 #ifdef FEAT_MOUSE_JSB |
3746 | 5578 || key_name[0] == KS_JSBTERM_MOUSE |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5579 #endif |
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5580 #ifdef FEAT_MOUSE_NET |
3746 | 5581 || key_name[0] == KS_NETTERM_MOUSE |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5582 #endif |
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5583 #ifdef FEAT_MOUSE_DEC |
3746 | 5584 || key_name[0] == KS_DEC_MOUSE |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5585 #endif |
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5586 #ifdef FEAT_MOUSE_PTERM |
3746 | 5587 || key_name[0] == KS_PTERM_MOUSE |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5588 #endif |
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5589 #ifdef FEAT_MOUSE_URXVT |
3746 | 5590 || key_name[0] == KS_URXVT_MOUSE |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18352
diff
changeset
|
5591 #endif |
3746 | 5592 || key_name[0] == KS_SGR_MOUSE |
16058
012f03e583e2
patch 8.1.1034: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
5593 || key_name[0] == KS_SGR_MOUSE_RELEASE) |
7 | 5594 { |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5595 if (check_termcode_mouse(tp, &slen, key_name, modifiers_start, idx, |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5596 &modifiers) == -1) |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5597 return -1; |
7 | 5598 } |
5599 | |
5600 #ifdef FEAT_GUI | |
5601 /* | |
5602 * If using the GUI, then we get menu and scrollbar events. | |
5603 * | |
5604 * A menu event is encoded as K_SPECIAL, KS_MENU, KE_FILLER followed by | |
5605 * four bytes which are to be taken as a pointer to the vimmenu_T | |
5606 * structure. | |
5607 * | |
1221 | 5608 * A tab line event is encoded as K_SPECIAL KS_TABLINE nr, where "nr" |
685 | 5609 * is one byte with the tab index. |
5610 * | |
7 | 5611 * A scrollbar event is K_SPECIAL, KS_VER_SCROLLBAR, KE_FILLER followed |
5612 * by one byte representing the scrollbar number, and then four bytes | |
5613 * representing a long_u which is the new value of the scrollbar. | |
5614 * | |
5615 * A horizontal scrollbar event is K_SPECIAL, KS_HOR_SCROLLBAR, | |
5616 * KE_FILLER followed by four bytes representing a long_u which is the | |
5617 * new value of the scrollbar. | |
5618 */ | |
5619 # ifdef FEAT_MENU | |
5620 else if (key_name[0] == (int)KS_MENU) | |
5621 { | |
5622 long_u val; | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5623 int num_bytes = get_long_from_buf(tp + slen, &val); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5624 |
7 | 5625 if (num_bytes == -1) |
5626 return -1; | |
5627 current_menu = (vimmenu_T *)val; | |
5628 slen += num_bytes; | |
936 | 5629 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5630 // The menu may have been deleted right after it was used, check |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5631 // for that. |
936 | 5632 if (check_menu_pointer(root_menu, current_menu) == FAIL) |
5633 { | |
5634 key_name[0] = KS_EXTRA; | |
5635 key_name[1] = (int)KE_IGNORE; | |
5636 } | |
7 | 5637 } |
5638 # endif | |
685 | 5639 # ifdef FEAT_GUI_TABLINE |
5640 else if (key_name[0] == (int)KS_TABLINE) | |
5641 { | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5642 // Selecting tabline tab or using its menu. |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5643 char_u bytes[6]; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5644 int num_bytes = get_bytes_from_buf(tp + slen, bytes, 1); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5645 |
685 | 5646 if (num_bytes == -1) |
5647 return -1; | |
5648 current_tab = (int)bytes[0]; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5649 if (current_tab == 255) // -1 in a byte gives 255 |
1394 | 5650 current_tab = -1; |
685 | 5651 slen += num_bytes; |
5652 } | |
688 | 5653 else if (key_name[0] == (int)KS_TABMENU) |
5654 { | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5655 // Selecting tabline tab or using its menu. |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5656 char_u bytes[6]; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5657 int num_bytes = get_bytes_from_buf(tp + slen, bytes, 2); |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5658 |
688 | 5659 if (num_bytes == -1) |
5660 return -1; | |
5661 current_tab = (int)bytes[0]; | |
5662 current_tabmenu = (int)bytes[1]; | |
5663 slen += num_bytes; | |
5664 } | |
685 | 5665 # endif |
7 | 5666 # ifndef USE_ON_FLY_SCROLL |
5667 else if (key_name[0] == (int)KS_VER_SCROLLBAR) | |
5668 { | |
5669 long_u val; | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5670 char_u bytes[6]; |
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5671 int num_bytes; |
7 | 5672 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5673 // Get the last scrollbar event in the queue of the same type |
7 | 5674 j = 0; |
5675 for (i = 0; tp[j] == CSI && tp[j + 1] == KS_VER_SCROLLBAR | |
5676 && tp[j + 2] != NUL; ++i) | |
5677 { | |
5678 j += 3; | |
5679 num_bytes = get_bytes_from_buf(tp + j, bytes, 1); | |
5680 if (num_bytes == -1) | |
5681 break; | |
5682 if (i == 0) | |
5683 current_scrollbar = (int)bytes[0]; | |
5684 else if (current_scrollbar != (int)bytes[0]) | |
5685 break; | |
5686 j += num_bytes; | |
5687 num_bytes = get_long_from_buf(tp + j, &val); | |
5688 if (num_bytes == -1) | |
5689 break; | |
5690 scrollbar_value = val; | |
5691 j += num_bytes; | |
5692 slen = j; | |
5693 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5694 if (i == 0) // not enough characters to make one |
7 | 5695 return -1; |
5696 } | |
5697 else if (key_name[0] == (int)KS_HOR_SCROLLBAR) | |
5698 { | |
5699 long_u val; | |
18150
0ec6521e9d80
patch 8.1.2070: mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
5700 int num_bytes; |
7 | 5701 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5702 // Get the last horiz. scrollbar event in the queue |
7 | 5703 j = 0; |
5704 for (i = 0; tp[j] == CSI && tp[j + 1] == KS_HOR_SCROLLBAR | |
5705 && tp[j + 2] != NUL; ++i) | |
5706 { | |
5707 j += 3; | |
5708 num_bytes = get_long_from_buf(tp + j, &val); | |
5709 if (num_bytes == -1) | |
5710 break; | |
5711 scrollbar_value = val; | |
5712 j += num_bytes; | |
5713 slen = j; | |
5714 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5715 if (i == 0) // not enough characters to make one |
7 | 5716 return -1; |
5717 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5718 # endif // !USE_ON_FLY_SCROLL |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5719 #endif // FEAT_GUI |
7 | 5720 |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5721 #if (defined(UNIX) || defined(VMS)) |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5722 /* |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5723 * Handle FocusIn/FocusOut event sequences reported by XTerm. |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5724 * (CSI I/CSI O) |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5725 */ |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5726 if (focus_mode |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5727 # ifdef FEAT_GUI |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5728 && !gui.in_use |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5729 # endif |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5730 && key_name[0] == KS_EXTRA |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5731 ) |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5732 { |
23620
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5733 if (key_name[1] == KE_FOCUSGAINED) |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5734 { |
23620
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5735 if (!focus_state) |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5736 { |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5737 ui_focus_change(TRUE); |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5738 did_cursorhold = TRUE; |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5739 focus_state = TRUE; |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5740 } |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5741 key_name[1] = (int)KE_IGNORE; |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5742 } |
23620
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5743 else if (key_name[1] == KE_FOCUSLOST) |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5744 { |
23620
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5745 if (focus_state) |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5746 { |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5747 ui_focus_change(FALSE); |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5748 did_cursorhold = TRUE; |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5749 focus_state = FALSE; |
24beca855c59
patch 8.2.2352: if focus lost/gained is received twice code is not ignored
Bram Moolenaar <Bram@vim.org>
parents:
23612
diff
changeset
|
5750 } |
23606
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5751 key_name[1] = (int)KE_IGNORE; |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5752 } |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5753 } |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5754 #endif |
f98939164e91
patch 8.2.2345: no focus events in a terminal
Bram Moolenaar <Bram@vim.org>
parents:
23410
diff
changeset
|
5755 |
180 | 5756 /* |
5757 * Change <xHome> to <Home>, <xUp> to <Up>, etc. | |
5758 */ | |
5759 key = handle_x_keys(TERMCAP2KEY(key_name[0], key_name[1])); | |
5760 | |
5761 /* | |
5762 * Add any modifier codes to our string. | |
5763 */ | |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5764 new_slen = modifiers2keycode(modifiers, &key, string); |
180 | 5765 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5766 // Finally, add the special key code to our string |
180 | 5767 key_name[0] = KEY2TERMCAP0(key); |
5768 key_name[1] = KEY2TERMCAP1(key); | |
7 | 5769 if (key_name[0] == KS_KEY) |
1787 | 5770 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5771 // from ":set <M-b>=xx" |
1787 | 5772 if (has_mbyte) |
5773 new_slen += (*mb_char2bytes)(key_name[1], string + new_slen); | |
5774 else | |
5775 string[new_slen++] = key_name[1]; | |
5776 } | |
2672 | 5777 else if (new_slen == 0 && key_name[0] == KS_EXTRA |
5778 && key_name[1] == KE_IGNORE) | |
5779 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5780 // Do not put K_IGNORE into the buffer, do return KEYLEN_REMOVED |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5781 // to indicate what happened. |
2672 | 5782 retval = KEYLEN_REMOVED; |
5783 } | |
7 | 5784 else |
5785 { | |
5786 string[new_slen++] = K_SPECIAL; | |
5787 string[new_slen++] = key_name[0]; | |
5788 string[new_slen++] = key_name[1]; | |
5789 } | |
18279
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5790 if (put_string_in_typebuf(offset, slen, string, new_slen, |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5791 buf, bufsize, buflen) == FAIL) |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5792 return -1; |
e8d1f3209dcd
patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
18257
diff
changeset
|
5793 return retval == 0 ? (len + new_slen - slen + offset) : retval; |
7 | 5794 } |
5795 | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5796 #ifdef FEAT_TERMRESPONSE |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
5797 LOG_TR(("normal character")); |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5798 #endif |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5799 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5800 return 0; // no match found |
7 | 5801 } |
5802 | |
12634
94566ecb55f0
patch 8.0.1195: can't build on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12632
diff
changeset
|
5803 #if (defined(FEAT_TERMINAL) && defined(FEAT_TERMRESPONSE)) || defined(PROTO) |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5804 /* |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5805 * Get the text foreground color, if known. |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5806 */ |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5807 void |
12640
a715f0b44532
patch 8.0.1198: older compilers don't know uint8_t
Christian Brabandt <cb@256bit.org>
parents:
12634
diff
changeset
|
5808 term_get_fg_color(char_u *r, char_u *g, char_u *b) |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5809 { |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
5810 if (rfg_status.tr_progress == STATUS_GOT) |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5811 { |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5812 *r = fg_r; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5813 *g = fg_g; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5814 *b = fg_b; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5815 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5816 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5817 |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5818 /* |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5819 * Get the text background color, if known. |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5820 */ |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5821 void |
12640
a715f0b44532
patch 8.0.1198: older compilers don't know uint8_t
Christian Brabandt <cb@256bit.org>
parents:
12634
diff
changeset
|
5822 term_get_bg_color(char_u *r, char_u *g, char_u *b) |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5823 { |
16625
d4e74f9f7ae9
patch 8.1.1315: there is always a delay if a termrequest is never answered
Bram Moolenaar <Bram@vim.org>
parents:
16586
diff
changeset
|
5824 if (rbg_status.tr_progress == STATUS_GOT) |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5825 { |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5826 *r = bg_r; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5827 *g = bg_g; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5828 *b = bg_b; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5829 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5830 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5831 #endif |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5832 |
7 | 5833 /* |
5834 * Replace any terminal code strings in from[] with the equivalent internal | |
5835 * vim representation. This is used for the "from" and "to" part of a | |
5836 * mapping, and the "to" part of a menu command. | |
5837 * Any strings like "<C-UP>" are also replaced, unless 'cpoptions' contains | |
5838 * '<'. | |
5839 * K_SPECIAL by itself is replaced by K_SPECIAL KS_SPECIAL KE_FILLER. | |
5840 * | |
5841 * The replacement is done in result[] and finally copied into allocated | |
5842 * memory. If this all works well *bufp is set to the allocated memory and a | |
5843 * pointer to it is returned. If something fails *bufp is set to NULL and from | |
5844 * is returned. | |
5845 * | |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5846 * CTRL-V characters are removed. When "flags" has REPTERM_FROM_PART, a |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5847 * trailing CTRL-V is included, otherwise it is removed (for ":map xx ^V", maps |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5848 * xx to nothing). When 'cpoptions' does not contain 'B', a backslash can be |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5849 * used instead of a CTRL-V. |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5850 * |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5851 * Flags: |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5852 * REPTERM_FROM_PART see above |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5853 * REPTERM_DO_LT also translate <lt> |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5854 * REPTERM_SPECIAL always accept <key> notation |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5855 * REPTERM_NO_SIMPLIFY do not simplify <C-H> to 0x08 and set 8th bit for <A-x> |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5856 * |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5857 * "did_simplify" is set when some <C-H> or <A-x> code was simplified, unless |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5858 * it is NULL. |
7 | 5859 */ |
859 | 5860 char_u * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5861 replace_termcodes( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5862 char_u *from, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5863 char_u **bufp, |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5864 int flags, |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5865 int *did_simplify) |
7 | 5866 { |
5867 int i; | |
5868 int slen; | |
5869 int key; | |
5870 int dlen = 0; | |
5871 char_u *src; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5872 int do_backslash; // backslash is a special character |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5873 int do_special; // recognize <> key codes |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5874 int do_key_code; // recognize raw key codes |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5875 char_u *result; // buffer for resulting string |
7 | 5876 |
5877 do_backslash = (vim_strchr(p_cpo, CPO_BSLASH) == NULL); | |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5878 do_special = (vim_strchr(p_cpo, CPO_SPECI) == NULL) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5879 || (flags & REPTERM_SPECIAL); |
7 | 5880 do_key_code = (vim_strchr(p_cpo, CPO_KEYCODE) == NULL); |
5881 | |
5882 /* | |
5883 * Allocate space for the translation. Worst case a single character is | |
5884 * replaced by 6 bytes (shifted special key), plus a NUL at the end. | |
5885 */ | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16642
diff
changeset
|
5886 result = alloc(STRLEN(from) * 6 + 1); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5887 if (result == NULL) // out of memory |
7 | 5888 { |
5889 *bufp = NULL; | |
5890 return from; | |
5891 } | |
5892 | |
5893 src = from; | |
5894 | |
5895 /* | |
5896 * Check for #n at start only: function key n | |
5897 */ | |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5898 if ((flags & REPTERM_FROM_PART) && src[0] == '#' && VIM_ISDIGIT(src[1])) |
7 | 5899 { |
5900 result[dlen++] = K_SPECIAL; | |
5901 result[dlen++] = 'k'; | |
5902 if (src[1] == '0') | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5903 result[dlen++] = ';'; // #0 is F10 is "k;" |
7 | 5904 else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5905 result[dlen++] = src[1]; // #3 is F3 is "k3" |
7 | 5906 src += 2; |
5907 } | |
5908 | |
5909 /* | |
5910 * Copy each byte from *from to result[dlen] | |
5911 */ | |
5912 while (*src != NUL) | |
5913 { | |
5914 /* | |
5915 * 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
|
5916 * like "<C-S-LeftMouse>" |
7 | 5917 */ |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5918 if (do_special && ((flags & REPTERM_DO_LT) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
5919 || STRNCMP(src, "<lt>", 4) != 0)) |
7 | 5920 { |
5921 #ifdef FEAT_EVAL | |
5922 /* | |
5923 * Replace <SID> by K_SNR <script-nr> _. | |
5924 * (room: 5 * 6 = 30 bytes; needed: 3 + <nr> + 1 <= 14) | |
5925 */ | |
5926 if (STRNICMP(src, "<SID>", 5) == 0) | |
5927 { | |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14581
diff
changeset
|
5928 if (current_sctx.sc_sid <= 0) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
5929 emsg(_(e_usingsid)); |
7 | 5930 else |
5931 { | |
5932 src += 5; | |
5933 result[dlen++] = K_SPECIAL; | |
5934 result[dlen++] = (int)KS_EXTRA; | |
5935 result[dlen++] = (int)KE_SNR; | |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14581
diff
changeset
|
5936 sprintf((char *)result + dlen, "%ld", |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14581
diff
changeset
|
5937 (long)current_sctx.sc_sid); |
7 | 5938 dlen += (int)STRLEN(result + dlen); |
5939 result[dlen++] = '_'; | |
5940 continue; | |
5941 } | |
5942 } | |
5943 #endif | |
5944 | |
20603
c2570baa2e4c
patch 8.2.0855: GUI tests fail because the test doesn't use a modifier
Bram Moolenaar <Bram@vim.org>
parents:
20591
diff
changeset
|
5945 slen = trans_special(&src, result + dlen, FSK_KEYCODE |
c2570baa2e4c
patch 8.2.0855: GUI tests fail because the test doesn't use a modifier
Bram Moolenaar <Bram@vim.org>
parents:
20591
diff
changeset
|
5946 | ((flags & REPTERM_NO_SIMPLIFY) ? 0 : FSK_SIMPLIFY), |
c2570baa2e4c
patch 8.2.0855: GUI tests fail because the test doesn't use a modifier
Bram Moolenaar <Bram@vim.org>
parents:
20591
diff
changeset
|
5947 did_simplify); |
7 | 5948 if (slen) |
5949 { | |
5950 dlen += slen; | |
5951 continue; | |
5952 } | |
5953 } | |
5954 | |
5955 /* | |
5956 * If 'cpoptions' does not contain 'k', see if it's an actual key-code. | |
5957 * Note that this is also checked after replacing the <> form. | |
5958 * Single character codes are NOT replaced (e.g. ^H or DEL), because | |
5959 * it could be a character in the file. | |
5960 */ | |
5961 if (do_key_code) | |
5962 { | |
5963 i = find_term_bykeys(src); | |
5964 if (i >= 0) | |
5965 { | |
5966 result[dlen++] = K_SPECIAL; | |
5967 result[dlen++] = termcodes[i].name[0]; | |
5968 result[dlen++] = termcodes[i].name[1]; | |
5969 src += termcodes[i].len; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
5970 // If terminal code matched, continue after it. |
7 | 5971 continue; |
5972 } | |
5973 } | |
5974 | |
5975 #ifdef FEAT_EVAL | |
5976 if (do_special) | |
5977 { | |
5978 char_u *p, *s, len; | |
5979 | |
5980 /* | |
5981 * Replace <Leader> by the value of "mapleader". | |
5982 * Replace <LocalLeader> by the value of "maplocalleader". | |
5983 * If "mapleader" or "maplocalleader" isn't set use a backslash. | |
5984 */ | |
5985 if (STRNICMP(src, "<Leader>", 8) == 0) | |
5986 { | |
5987 len = 8; | |
5988 p = get_var_value((char_u *)"g:mapleader"); | |
5989 } | |
5990 else if (STRNICMP(src, "<LocalLeader>", 13) == 0) | |
5991 { | |
5992 len = 13; | |
5993 p = get_var_value((char_u *)"g:maplocalleader"); | |
5994 } | |
5995 else | |
5996 { | |
5997 len = 0; | |
5998 p = NULL; | |
5999 } | |
6000 if (len != 0) | |
6001 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6002 // Allow up to 8 * 6 characters for "mapleader". |
7 | 6003 if (p == NULL || *p == NUL || STRLEN(p) > 8 * 6) |
6004 s = (char_u *)"\\"; | |
6005 else | |
6006 s = p; | |
6007 while (*s != NUL) | |
6008 result[dlen++] = *s++; | |
6009 src += len; | |
6010 continue; | |
6011 } | |
6012 } | |
6013 #endif | |
6014 | |
6015 /* | |
6016 * Remove CTRL-V and ignore the next character. | |
6017 * For "from" side the CTRL-V at the end is included, for the "to" | |
6018 * part it is removed. | |
6019 * If 'cpoptions' does not contain 'B', also accept a backslash. | |
6020 */ | |
6021 key = *src; | |
6022 if (key == Ctrl_V || (do_backslash && key == '\\')) | |
6023 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6024 ++src; // skip CTRL-V or backslash |
7 | 6025 if (*src == NUL) |
6026 { | |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18299
diff
changeset
|
6027 if (flags & REPTERM_FROM_PART) |
7 | 6028 result[dlen++] = key; |
6029 break; | |
6030 } | |
6031 } | |
6032 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6033 // skip multibyte char correctly |
474 | 6034 for (i = (*mb_ptr2len)(src); i > 0; --i) |
7 | 6035 { |
6036 /* | |
6037 * If the character is K_SPECIAL, replace it with K_SPECIAL | |
6038 * KS_SPECIAL KE_FILLER. | |
6039 * If compiled with the GUI replace CSI with K_CSI. | |
6040 */ | |
6041 if (*src == K_SPECIAL) | |
6042 { | |
6043 result[dlen++] = K_SPECIAL; | |
6044 result[dlen++] = KS_SPECIAL; | |
6045 result[dlen++] = KE_FILLER; | |
6046 } | |
6047 # ifdef FEAT_GUI | |
6048 else if (*src == CSI) | |
6049 { | |
6050 result[dlen++] = K_SPECIAL; | |
6051 result[dlen++] = KS_EXTRA; | |
6052 result[dlen++] = (int)KE_CSI; | |
6053 } | |
6054 # endif | |
6055 else | |
6056 result[dlen++] = *src; | |
6057 ++src; | |
6058 } | |
6059 } | |
6060 result[dlen] = NUL; | |
6061 | |
6062 /* | |
6063 * Copy the new string to allocated memory. | |
6064 * If this fails, just return from. | |
6065 */ | |
6066 if ((*bufp = vim_strsave(result)) != NULL) | |
6067 from = *bufp; | |
6068 vim_free(result); | |
6069 return from; | |
6070 } | |
6071 | |
6072 /* | |
6073 * Find a termcode with keys 'src' (must be NUL terminated). | |
6074 * Return the index in termcodes[], or -1 if not found. | |
6075 */ | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
6076 static int |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6077 find_term_bykeys(char_u *src) |
7 | 6078 { |
6079 int i; | |
3290 | 6080 int slen = (int)STRLEN(src); |
7 | 6081 |
6082 for (i = 0; i < tc_len; ++i) | |
6083 { | |
3273 | 6084 if (slen == termcodes[i].len |
6085 && STRNCMP(termcodes[i].code, src, (size_t)slen) == 0) | |
7 | 6086 return i; |
6087 } | |
6088 return -1; | |
6089 } | |
6090 | |
6091 /* | |
6092 * Gather the first characters in the terminal key codes into a string. | |
6093 * Used to speed up check_termcode(). | |
6094 */ | |
6095 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6096 gather_termleader(void) |
7 | 6097 { |
6098 int i; | |
6099 int len = 0; | |
6100 | |
6101 #ifdef FEAT_GUI | |
6102 if (gui.in_use) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6103 termleader[len++] = CSI; // the GUI codes are not in termcodes[] |
7 | 6104 #endif |
6105 #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
|
6106 if (check_for_codes || *T_CRS != NUL) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6107 termleader[len++] = DCS; // the termcode response starts with DCS |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6108 // in 8-bit mode |
7 | 6109 #endif |
6110 termleader[len] = NUL; | |
6111 | |
6112 for (i = 0; i < tc_len; ++i) | |
6113 if (vim_strchr(termleader, termcodes[i].code[0]) == NULL) | |
6114 { | |
6115 termleader[len++] = termcodes[i].code[0]; | |
6116 termleader[len] = NUL; | |
6117 } | |
6118 | |
6119 need_gather = FALSE; | |
6120 } | |
6121 | |
6122 /* | |
6123 * Show all termcodes (for ":set termcap") | |
6124 * This code looks a lot like showoptions(), but is different. | |
6125 */ | |
6126 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6127 show_termcodes(void) |
7 | 6128 { |
6129 int col; | |
6130 int *items; | |
6131 int item_count; | |
6132 int run; | |
6133 int row, rows; | |
6134 int cols; | |
6135 int i; | |
6136 int len; | |
6137 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6138 #define INC3 27 // try to make three columns |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6139 #define INC2 40 // try to make two columns |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6140 #define GAP 2 // spaces between columns |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6141 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6142 if (tc_len == 0) // no terminal codes (must be GUI) |
7 | 6143 return; |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
6144 items = ALLOC_MULT(int, tc_len); |
7 | 6145 if (items == NULL) |
6146 return; | |
6147 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6148 // Highlight title |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6149 msg_puts_title(_("\n--- Terminal keys ---")); |
7 | 6150 |
6151 /* | |
6152 * do the loop two times: | |
6153 * 1. display the short items (non-strings and short strings) | |
180 | 6154 * 2. display the medium items (medium length strings) |
6155 * 3. display the long items (remaining strings) | |
7 | 6156 */ |
180 | 6157 for (run = 1; run <= 3 && !got_int; ++run) |
7 | 6158 { |
6159 /* | |
6160 * collect the items in items[] | |
6161 */ | |
6162 item_count = 0; | |
6163 for (i = 0; i < tc_len; i++) | |
6164 { | |
6165 len = show_one_termcode(termcodes[i].name, | |
6166 termcodes[i].code, FALSE); | |
180 | 6167 if (len <= INC3 - GAP ? run == 1 |
6168 : len <= INC2 - GAP ? run == 2 | |
6169 : run == 3) | |
7 | 6170 items[item_count++] = i; |
6171 } | |
6172 | |
6173 /* | |
6174 * display the items | |
6175 */ | |
180 | 6176 if (run <= 2) |
7 | 6177 { |
180 | 6178 cols = (Columns + GAP) / (run == 1 ? INC3 : INC2); |
7 | 6179 if (cols == 0) |
6180 cols = 1; | |
6181 rows = (item_count + cols - 1) / cols; | |
6182 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6183 else // run == 3 |
7 | 6184 rows = item_count; |
6185 for (row = 0; row < rows && !got_int; ++row) | |
6186 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6187 msg_putchar('\n'); // go to next line |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6188 if (got_int) // 'q' typed in more |
7 | 6189 break; |
6190 col = 0; | |
6191 for (i = row; i < item_count; i += rows) | |
6192 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6193 msg_col = col; // make columns |
7 | 6194 show_one_termcode(termcodes[items[i]].name, |
6195 termcodes[items[i]].code, TRUE); | |
180 | 6196 if (run == 2) |
6197 col += INC2; | |
6198 else | |
6199 col += INC3; | |
7 | 6200 } |
6201 out_flush(); | |
6202 ui_breakcheck(); | |
6203 } | |
6204 } | |
6205 vim_free(items); | |
6206 } | |
6207 | |
6208 /* | |
6209 * Show one termcode entry. | |
6210 * Output goes into IObuff[] | |
6211 */ | |
6212 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6213 show_one_termcode(char_u *name, char_u *code, int printit) |
7 | 6214 { |
6215 char_u *p; | |
6216 int len; | |
6217 | |
6218 if (name[0] > '~') | |
6219 { | |
6220 IObuff[0] = ' '; | |
6221 IObuff[1] = ' '; | |
6222 IObuff[2] = ' '; | |
6223 IObuff[3] = ' '; | |
6224 } | |
6225 else | |
6226 { | |
6227 IObuff[0] = 't'; | |
6228 IObuff[1] = '_'; | |
6229 IObuff[2] = name[0]; | |
6230 IObuff[3] = name[1]; | |
6231 } | |
6232 IObuff[4] = ' '; | |
6233 | |
6234 p = get_special_key_name(TERMCAP2KEY(name[0], name[1]), 0); | |
6235 if (p[1] != 't') | |
6236 STRCPY(IObuff + 5, p); | |
6237 else | |
6238 IObuff[5] = NUL; | |
6239 len = (int)STRLEN(IObuff); | |
6240 do | |
6241 IObuff[len++] = ' '; | |
6242 while (len < 17); | |
6243 IObuff[len] = NUL; | |
6244 if (code == NULL) | |
6245 len += 4; | |
6246 else | |
6247 len += vim_strsize(code); | |
6248 | |
6249 if (printit) | |
6250 { | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6251 msg_puts((char *)IObuff); |
7 | 6252 if (code == NULL) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6253 msg_puts("NULL"); |
7 | 6254 else |
6255 msg_outtrans(code); | |
6256 } | |
6257 return len; | |
6258 } | |
6259 | |
6260 #if defined(FEAT_TERMRESPONSE) || defined(PROTO) | |
6261 /* | |
6262 * For Xterm >= 140 compiled with OPT_TCAP_QUERY: Obtain the actually used | |
6263 * termcap codes from the terminal itself. | |
6264 * We get them one by one to avoid a very long response string. | |
6265 */ | |
6102 | 6266 static int xt_index_in = 0; |
6267 static int xt_index_out = 0; | |
6268 | |
7 | 6269 static void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6270 req_codes_from_term(void) |
7 | 6271 { |
6272 xt_index_out = 0; | |
6273 xt_index_in = 0; | |
6274 req_more_codes_from_term(); | |
6275 } | |
6276 | |
6277 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6278 req_more_codes_from_term(void) |
7 | 6279 { |
6280 char buf[11]; | |
6281 int old_idx = xt_index_out; | |
6282 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6283 // Don't do anything when going to exit. |
7 | 6284 if (exiting) |
6285 return; | |
6286 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6287 // Send up to 10 more requests out than we received. Avoid sending too |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6288 // many, there can be a buffer overflow somewhere. |
7 | 6289 while (xt_index_out < xt_index_in + 10 && key_names[xt_index_out] != NULL) |
6290 { | |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6291 char *key_name = key_names[xt_index_out]; |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6292 |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
6293 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
6294 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
6295 #endif |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6296 LOG_TR(("Requesting XT %d: %s", xt_index_out, key_name)); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6297 sprintf(buf, "\033P+q%02x%02x\033\\", key_name[0], key_name[1]); |
7 | 6298 out_str_nf((char_u *)buf); |
6299 ++xt_index_out; | |
6300 } | |
6301 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6302 // Send the codes out right away. |
7 | 6303 if (xt_index_out != old_idx) |
6304 out_flush(); | |
6305 } | |
6306 | |
6307 /* | |
6308 * Decode key code response from xterm: '<Esc>P1+r<name>=<string><Esc>\'. | |
6309 * A "0" instead of the "1" indicates a code that isn't supported. | |
6310 * Both <name> and <string> are encoded in hex. | |
6311 * "code" points to the "0" or "1". | |
6312 */ | |
6313 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6314 got_code_from_term(char_u *code, int len) |
7 | 6315 { |
6316 #define XT_LEN 100 | |
6317 char_u name[3]; | |
6318 char_u str[XT_LEN]; | |
6319 int i; | |
6320 int j = 0; | |
6321 int c; | |
6322 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6323 // A '1' means the code is supported, a '0' means it isn't. |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6324 // When half the length is > XT_LEN we can't use it. |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6325 // Our names are currently all 2 characters. |
7 | 6326 if (code[0] == '1' && code[7] == '=' && len / 2 < XT_LEN) |
6327 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6328 // Get the name from the response and find it in the table. |
7 | 6329 name[0] = hexhex2nr(code + 3); |
6330 name[1] = hexhex2nr(code + 5); | |
6331 name[2] = NUL; | |
6332 for (i = 0; key_names[i] != NULL; ++i) | |
6333 { | |
6334 if (STRCMP(key_names[i], name) == 0) | |
6335 { | |
6336 xt_index_in = i; | |
6337 break; | |
6338 } | |
6339 } | |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6340 |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6341 LOG_TR(("Received XT %d: %s", xt_index_in, (char *)name)); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6342 |
7 | 6343 if (key_names[i] != NULL) |
6344 { | |
6345 for (i = 8; (c = hexhex2nr(code + i)) >= 0; i += 2) | |
6346 str[j++] = c; | |
6347 str[j] = NUL; | |
6348 if (name[0] == 'C' && name[1] == 'o') | |
6349 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6350 // Color count is not a key code. |
7 | 6351 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
|
6352 may_adjust_color_count(i); |
7 | 6353 } |
6354 else | |
6355 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6356 // First delete any existing entry with the same code. |
7 | 6357 i = find_term_bykeys(str); |
6358 if (i >= 0) | |
6359 del_termcode_idx(i); | |
180 | 6360 add_termcode(name, str, ATC_FROM_TERM); |
7 | 6361 } |
6362 } | |
6363 } | |
6364 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6365 // May request more codes now that we received one. |
7 | 6366 ++xt_index_in; |
6367 req_more_codes_from_term(); | |
6368 } | |
6369 | |
6370 /* | |
6371 * Check if there are any unanswered requests and deal with them. | |
6372 * This is called before starting an external program or getting direct | |
6373 * keyboard input. We don't want responses to be send to that program or | |
6374 * handled as typed text. | |
6375 */ | |
6376 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6377 check_for_codes_from_term(void) |
7 | 6378 { |
6379 int c; | |
6380 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6381 // If no codes requested or all are answered, no need to wait. |
7 | 6382 if (xt_index_out == 0 || xt_index_out == xt_index_in) |
6383 return; | |
6384 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6385 // Vgetc() will check for and handle any response. |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6386 // Keep calling vpeekc() until we don't get any responses. |
7 | 6387 ++no_mapping; |
6388 ++allow_keys; | |
6389 for (;;) | |
6390 { | |
6391 c = vpeekc(); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6392 if (c == NUL) // nothing available |
7 | 6393 break; |
6394 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6395 // If a response is recognized it's replaced with K_IGNORE, must read |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6396 // it from the input stream. If there is no K_IGNORE we can't do |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6397 // anything, break here (there might be some responses further on, but |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6398 // we don't want to throw away any typed chars). |
7 | 6399 if (c != K_SPECIAL && c != K_IGNORE) |
6400 break; | |
6401 c = vgetc(); | |
6402 if (c != K_IGNORE) | |
6403 { | |
6404 vungetc(c); | |
6405 break; | |
6406 } | |
6407 } | |
6408 --no_mapping; | |
6409 --allow_keys; | |
6410 } | |
6411 #endif | |
6412 | |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
6413 #if (defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL))) || defined(PROTO) |
7 | 6414 static char ksme_str[20]; |
6415 static char ksmr_str[20]; | |
6416 static char ksmd_str[20]; | |
6417 | |
6418 /* | |
6419 * For Win32 console: update termcap codes for existing console attributes. | |
6420 */ | |
6421 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6422 update_tcap(int attr) |
7 | 6423 { |
6424 struct builtin_term *p; | |
6425 | |
6426 p = find_builtin_term(DEFAULT_TERM); | |
6427 sprintf(ksme_str, IF_EB("\033|%dm", ESC_STR "|%dm"), attr); | |
6428 sprintf(ksmd_str, IF_EB("\033|%dm", ESC_STR "|%dm"), | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6429 attr | 0x08); // FOREGROUND_INTENSITY |
7 | 6430 sprintf(ksmr_str, IF_EB("\033|%dm", ESC_STR "|%dm"), |
6431 ((attr & 0x0F) << 4) | ((attr & 0xF0) >> 4)); | |
6432 | |
6433 while (p->bt_string != NULL) | |
6434 { | |
6435 if (p->bt_entry == (int)KS_ME) | |
6436 p->bt_string = &ksme_str[0]; | |
6437 else if (p->bt_entry == (int)KS_MR) | |
6438 p->bt_string = &ksmr_str[0]; | |
6439 else if (p->bt_entry == (int)KS_MD) | |
6440 p->bt_string = &ksmd_str[0]; | |
6441 ++p; | |
6442 } | |
6443 } | |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6444 |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6445 # ifdef FEAT_TERMGUICOLORS |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6446 # define KSSIZE 20 |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6447 struct ks_tbl_s |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6448 { |
14806
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6449 int code; // value of KS_ |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6450 char *vtp; // code in vtp mode |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6451 char *vtp2; // code in vtp2 mode |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6452 char buf[KSSIZE]; // save buffer in non-vtp mode |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6453 char vbuf[KSSIZE]; // save buffer in vtp mode |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6454 char v2buf[KSSIZE]; // save buffer in vtp2 mode |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6455 char arr[KSSIZE]; // real buffer |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6456 }; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6457 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6458 static struct ks_tbl_s ks_tbl[] = |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6459 { |
14806
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6460 {(int)KS_ME, "\033|0m", "\033|0m"}, // normal |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6461 {(int)KS_MR, "\033|7m", "\033|7m"}, // reverse |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6462 {(int)KS_MD, "\033|1m", "\033|1m"}, // bold |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6463 {(int)KS_SO, "\033|91m", "\033|91m"}, // standout: bright red text |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6464 {(int)KS_SE, "\033|39m", "\033|39m"}, // standout end: default color |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6465 {(int)KS_CZH, "\033|95m", "\033|95m"}, // italic: bright magenta text |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6466 {(int)KS_CZR, "\033|0m", "\033|0m"}, // italic end |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6467 {(int)KS_US, "\033|4m", "\033|4m"}, // underscore |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6468 {(int)KS_UE, "\033|24m", "\033|24m"}, // underscore end |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6469 # ifdef TERMINFO |
14806
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6470 {(int)KS_CAB, "\033|%p1%db", "\033|%p14%dm"}, // set background color |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6471 {(int)KS_CAF, "\033|%p1%df", "\033|%p13%dm"}, // set foreground color |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
6472 {(int)KS_CS, "\033|%p1%d;%p2%dR", "\033|%p1%d;%p2%dR"}, |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
6473 {(int)KS_CSV, "\033|%p1%d;%p2%dV", "\033|%p1%d;%p2%dV"}, |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6474 # else |
14806
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6475 {(int)KS_CAB, "\033|%db", "\033|4%dm"}, // set background color |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6476 {(int)KS_CAF, "\033|%df", "\033|3%dm"}, // set foreground color |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
6477 {(int)KS_CS, "\033|%d;%dR", "\033|%d;%dR"}, |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
6478 {(int)KS_CSV, "\033|%d;%dV", "\033|%d;%dV"}, |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6479 # endif |
14806
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6480 {(int)KS_CCO, "256", "256"}, // colors |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6481 {(int)KS_NAME} // terminator |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6482 }; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6483 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6484 static struct builtin_term * |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6485 find_first_tcap( |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6486 char_u *name, |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6487 int code) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6488 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6489 struct builtin_term *p; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6490 |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6491 for (p = find_builtin_term(name); p->bt_string != NULL; ++p) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6492 if (p->bt_entry == code) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6493 return p; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6494 return NULL; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6495 } |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6496 # endif |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6497 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6498 /* |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6499 * For Win32 console: replace the sequence immediately after termguicolors. |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6500 */ |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6501 void |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6502 swap_tcap(void) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6503 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6504 # ifdef FEAT_TERMGUICOLORS |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6505 static int init_done = FALSE; |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6506 static int curr_mode; |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6507 struct ks_tbl_s *ks; |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6508 struct builtin_term *bt; |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6509 int mode; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6510 enum |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6511 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6512 CMODEINDEX, |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6513 CMODE24, |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6514 CMODE256 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6515 }; |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6516 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6517 // buffer initialization |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6518 if (!init_done) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6519 { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6520 for (ks = ks_tbl; ks->code != (int)KS_NAME; ks++) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6521 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6522 bt = find_first_tcap(DEFAULT_TERM, ks->code); |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6523 if (bt != NULL) |
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6524 { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6525 STRNCPY(ks->buf, bt->bt_string, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6526 STRNCPY(ks->vbuf, ks->vtp, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6527 STRNCPY(ks->v2buf, ks->vtp2, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6528 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6529 STRNCPY(ks->arr, bt->bt_string, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6530 bt->bt_string = &ks->arr[0]; |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6531 } |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6532 } |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6533 init_done = TRUE; |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6534 curr_mode = CMODEINDEX; |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6535 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6536 |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6537 if (p_tgc) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6538 mode = CMODE24; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6539 else if (t_colors >= 256) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6540 mode = CMODE256; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6541 else |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6542 mode = CMODEINDEX; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6543 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6544 for (ks = ks_tbl; ks->code != (int)KS_NAME; ks++) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6545 { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6546 bt = find_first_tcap(DEFAULT_TERM, ks->code); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6547 if (bt != NULL) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6548 { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6549 switch (curr_mode) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6550 { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6551 case CMODEINDEX: |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6552 STRNCPY(&ks->buf[0], bt->bt_string, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6553 break; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6554 case CMODE24: |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6555 STRNCPY(&ks->vbuf[0], bt->bt_string, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6556 break; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6557 default: |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6558 STRNCPY(&ks->v2buf[0], bt->bt_string, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6559 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6560 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6561 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6562 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6563 if (mode != curr_mode) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6564 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6565 for (ks = ks_tbl; ks->code != (int)KS_NAME; ks++) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6566 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6567 bt = find_first_tcap(DEFAULT_TERM, ks->code); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6568 if (bt != NULL) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6569 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6570 switch (mode) |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6571 { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6572 case CMODEINDEX: |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6573 STRNCPY(bt->bt_string, &ks->buf[0], KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6574 break; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6575 case CMODE24: |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6576 STRNCPY(bt->bt_string, &ks->vbuf[0], KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6577 break; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6578 default: |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6579 STRNCPY(bt->bt_string, &ks->v2buf[0], KSSIZE); |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6580 } |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6581 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6582 } |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6583 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6584 curr_mode = mode; |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6585 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6586 # endif |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6587 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6588 |
7 | 6589 #endif |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6590 |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
6591 #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
|
6592 static int |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6593 hex_digit(int c) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6594 { |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6595 if (isdigit(c)) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6596 return c - '0'; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6597 c = TOLOWER_ASC(c); |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6598 if (c >= 'a' && c <= 'f') |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6599 return c - 'a' + 10; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6600 return 0x1ffffff; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6601 } |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6602 |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
6603 # ifdef VIMDLL |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
6604 static guicolor_T |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
6605 gui_adjust_rgb(guicolor_T c) |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
6606 { |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
6607 if (gui.in_use) |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
6608 return c; |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
6609 else |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
6610 return ((c & 0xff) << 16) | (c & 0x00ff00) | ((c >> 16) & 0xff); |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
6611 } |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
6612 # else |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
6613 # define gui_adjust_rgb(c) (c) |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
6614 # endif |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
6615 |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6616 guicolor_T |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6617 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
|
6618 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6619 // On MS-Windows an RGB macro is available and it produces 0x00bbggrr color |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6620 // values as used by the MS-Windows GDI api. It should be used only for |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6621 // MS-Windows GDI builds. |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15852
diff
changeset
|
6622 # if defined(RGB) && defined(MSWIN) && !defined(FEAT_GUI) |
10512
675dfe47ab69
commit https://github.com/vim/vim/commit/287266527abc163e191a06dd70518bbbdab4468f
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
6623 # undef RGB |
675dfe47ab69
commit https://github.com/vim/vim/commit/287266527abc163e191a06dd70518bbbdab4468f
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
6624 # endif |
9021
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6625 # ifndef RGB |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6626 # 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
|
6627 # endif |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6628 # define LINE_LEN 100 |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6629 FILE *fd; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6630 char line[LINE_LEN]; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6631 char_u *fname; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6632 int r, g, b, i; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6633 guicolor_T color; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6634 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6635 struct rgbcolor_table_S { |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6636 char_u *color_name; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6637 guicolor_T color; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6638 }; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6639 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6640 // Only non X11 colors (not present in rgb.txt) and colors in |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6641 // 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
|
6642 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
|
6643 {(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
|
6644 {(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
|
6645 {(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
|
6646 {(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
|
6647 {(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
|
6648 {(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
|
6649 {(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
|
6650 {(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
|
6651 {(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
|
6652 {(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
|
6653 {(char_u *)"darkred", RGB(0x8B, 0x00, 0x00)}, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6654 {(char_u *)"darkyellow", RGB(0x8B, 0x8B, 0x00)}, // No X11 |
9021
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6655 {(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
|
6656 {(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
|
6657 {(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
|
6658 {(char_u *)"grey40", RGB(0x66, 0x66, 0x66)}, |
13489
24e8f9044bed
patch 8.0.1618: color Grey50 is missing in the compiled-in table
Christian Brabandt <cb@256bit.org>
parents:
13406
diff
changeset
|
6659 {(char_u *)"grey50", RGB(0x7F, 0x7F, 0x7F)}, |
9601
9cc49b86f613
commit https://github.com/vim/vim/commit/ca8942c6e331a69ddd533dd78931f399f7dcaa79
Christian Brabandt <cb@256bit.org>
parents:
9591
diff
changeset
|
6660 {(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
|
6661 {(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
|
6662 {(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
|
6663 {(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
|
6664 {(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
|
6665 {(char_u *)"lightgrey", RGB(0xD3, 0xD3, 0xD3)}, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6666 {(char_u *)"lightmagenta", RGB(0xFF, 0x8B, 0xFF)}, // No X11 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6667 {(char_u *)"lightred", RGB(0xFF, 0x8B, 0x8B)}, // No X11 |
9021
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6668 {(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
|
6669 {(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
|
6670 {(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
|
6671 {(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
|
6672 {(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
|
6673 {(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
|
6674 }; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6675 |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6676 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
|
6677 static int size = 0; |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6678 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6679 if (name[0] == '#' && STRLEN(name) == 7) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6680 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6681 // Name is in "#rrggbb" format |
9021
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6682 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
|
6683 ((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
|
6684 ((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
|
6685 if (color > 0xffffff) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6686 return INVALCOLOR; |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
6687 return gui_adjust_rgb(color); |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6688 } |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6689 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6690 // Check if the name is one of the colors we know |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6691 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
|
6692 if (STRICMP(name, rgb_table[i].color_name) == 0) |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
6693 return gui_adjust_rgb(rgb_table[i].color); |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6694 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6695 /* |
15782
5de143c7cd76
patch 8.1.0898: a messed up rgb.txt can crash Vim
Bram Moolenaar <Bram@vim.org>
parents:
15605
diff
changeset
|
6696 * Last attempt. Look in the file "$VIMRUNTIME/rgb.txt". |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6697 */ |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6698 if (size == 0) |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6699 { |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6700 int counting; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6701 |
15782
5de143c7cd76
patch 8.1.0898: a messed up rgb.txt can crash Vim
Bram Moolenaar <Bram@vim.org>
parents:
15605
diff
changeset
|
6702 // colornames_table not yet initialized |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6703 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
|
6704 if (fname == NULL) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6705 return INVALCOLOR; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6706 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6707 fd = fopen((char *)fname, "rt"); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6708 vim_free(fname); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6709 if (fd == NULL) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6710 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6711 if (p_verbose > 1) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6712 verb_msg(_("Cannot open $VIMRUNTIME/rgb.txt")); |
15782
5de143c7cd76
patch 8.1.0898: a messed up rgb.txt can crash Vim
Bram Moolenaar <Bram@vim.org>
parents:
15605
diff
changeset
|
6713 size = -1; // don't try again |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6714 return INVALCOLOR; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6715 } |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6716 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6717 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
|
6718 { |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6719 if (!counting) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6720 { |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
6721 colornames_table = ALLOC_MULT(struct rgbcolor_table_S, size); |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6722 if (colornames_table == NULL) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6723 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6724 fclose(fd); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6725 return INVALCOLOR; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6726 } |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6727 rewind(fd); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6728 } |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6729 size = 0; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6730 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6731 while (!feof(fd)) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6732 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6733 size_t len; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6734 int pos; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6735 |
14730
193471015e1a
patch 8.1.0377: xdiff doesn't use the Vim memory allocation functions
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
6736 vim_ignoredp = fgets(line, LINE_LEN, fd); |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6737 len = strlen(line); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6738 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6739 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
|
6740 continue; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6741 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6742 line[len - 1] = '\0'; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6743 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6744 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
|
6745 if (i != 3) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6746 continue; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6747 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6748 if (!counting) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6749 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6750 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
|
6751 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6752 if (s == NULL) |
9628
fefd0551aa9d
commit https://github.com/vim/vim/commit/2e45d21c819272051f7ef4436f483e4b2ecfb369
Christian Brabandt <cb@256bit.org>
parents:
9601
diff
changeset
|
6753 { |
fefd0551aa9d
commit https://github.com/vim/vim/commit/2e45d21c819272051f7ef4436f483e4b2ecfb369
Christian Brabandt <cb@256bit.org>
parents:
9601
diff
changeset
|
6754 fclose(fd); |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6755 return INVALCOLOR; |
9628
fefd0551aa9d
commit https://github.com/vim/vim/commit/2e45d21c819272051f7ef4436f483e4b2ecfb369
Christian Brabandt <cb@256bit.org>
parents:
9601
diff
changeset
|
6756 } |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6757 colornames_table[size].color_name = s; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6758 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
|
6759 } |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6760 size++; |
15782
5de143c7cd76
patch 8.1.0898: a messed up rgb.txt can crash Vim
Bram Moolenaar <Bram@vim.org>
parents:
15605
diff
changeset
|
6761 |
5de143c7cd76
patch 8.1.0898: a messed up rgb.txt can crash Vim
Bram Moolenaar <Bram@vim.org>
parents:
15605
diff
changeset
|
6762 // The distributed rgb.txt has less than 1000 entries. Limit to |
5de143c7cd76
patch 8.1.0898: a messed up rgb.txt can crash Vim
Bram Moolenaar <Bram@vim.org>
parents:
15605
diff
changeset
|
6763 // 10000, just in case the file was messed up. |
5de143c7cd76
patch 8.1.0898: a messed up rgb.txt can crash Vim
Bram Moolenaar <Bram@vim.org>
parents:
15605
diff
changeset
|
6764 if (size == 10000) |
5de143c7cd76
patch 8.1.0898: a messed up rgb.txt can crash Vim
Bram Moolenaar <Bram@vim.org>
parents:
15605
diff
changeset
|
6765 break; |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6766 } |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6767 } |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6768 fclose(fd); |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6769 } |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6770 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6771 for (i = 0; i < size; i++) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6772 if (STRICMP(name, colornames_table[i].color_name) == 0) |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
6773 return gui_adjust_rgb(colornames_table[i].color); |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6774 |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6775 return INVALCOLOR; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6776 } |
11745
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11739
diff
changeset
|
6777 |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11739
diff
changeset
|
6778 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
|
6779 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
|
6780 { |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11739
diff
changeset
|
6781 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
|
6782 |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11739
diff
changeset
|
6783 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
|
6784 return INVALCOLOR; |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
6785 return gui_adjust_rgb(color); |
11745
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11739
diff
changeset
|
6786 } |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6787 #endif |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6788 |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16387
diff
changeset
|
6789 #if (defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))) || defined(FEAT_TERMINAL) \ |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6790 || defined(PROTO) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6791 static int cube_value[] = { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6792 0x00, 0x5F, 0x87, 0xAF, 0xD7, 0xFF |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6793 }; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6794 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6795 static int grey_ramp[] = { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6796 0x08, 0x12, 0x1C, 0x26, 0x30, 0x3A, 0x44, 0x4E, 0x58, 0x62, 0x6C, 0x76, |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6797 0x80, 0x8A, 0x94, 0x9E, 0xA8, 0xB2, 0xBC, 0xC6, 0xD0, 0xDA, 0xE4, 0xEE |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6798 }; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6799 |
13839
ca8953d36264
patch 8.0.1791: using uint8_t does not work everywhere
Christian Brabandt <cb@256bit.org>
parents:
13827
diff
changeset
|
6800 static char_u ansi_table[16][4] = { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6801 // R G B idx |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6802 { 0, 0, 0, 1}, // black |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6803 {224, 0, 0, 2}, // dark red |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6804 { 0, 224, 0, 3}, // dark green |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6805 {224, 224, 0, 4}, // dark yellow / brown |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6806 { 0, 0, 224, 5}, // dark blue |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6807 {224, 0, 224, 6}, // dark magenta |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6808 { 0, 224, 224, 7}, // dark cyan |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6809 {224, 224, 224, 8}, // light grey |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6810 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6811 {128, 128, 128, 9}, // dark grey |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6812 {255, 64, 64, 10}, // light red |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6813 { 64, 255, 64, 11}, // light green |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6814 {255, 255, 64, 12}, // yellow |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6815 { 64, 64, 255, 13}, // light blue |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6816 {255, 64, 255, 14}, // light magenta |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6817 { 64, 255, 255, 15}, // light cyan |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6818 {255, 255, 255, 16}, // white |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6819 }; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6820 |
20500
03826c672315
patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20450
diff
changeset
|
6821 #define ANSI_INDEX_NONE 0 |
03826c672315
patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20450
diff
changeset
|
6822 |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6823 void |
13839
ca8953d36264
patch 8.0.1791: using uint8_t does not work everywhere
Christian Brabandt <cb@256bit.org>
parents:
13827
diff
changeset
|
6824 cterm_color2rgb(int nr, char_u *r, char_u *g, char_u *b, char_u *ansi_idx) |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6825 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6826 int idx; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6827 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6828 if (nr < 16) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6829 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6830 *r = ansi_table[nr][0]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6831 *g = ansi_table[nr][1]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6832 *b = ansi_table[nr][2]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6833 *ansi_idx = ansi_table[nr][3]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6834 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6835 else if (nr < 232) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6836 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6837 // 216 color cube |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6838 idx = nr - 16; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6839 *r = cube_value[idx / 36 % 6]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6840 *g = cube_value[idx / 6 % 6]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6841 *b = cube_value[idx % 6]; |
20500
03826c672315
patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20450
diff
changeset
|
6842 *ansi_idx = ANSI_INDEX_NONE; |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6843 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6844 else if (nr < 256) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6845 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
6846 // 24 grey scale ramp |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6847 idx = nr - 232; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6848 *r = grey_ramp[idx]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6849 *g = grey_ramp[idx]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6850 *b = grey_ramp[idx]; |
20500
03826c672315
patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20450
diff
changeset
|
6851 *ansi_idx = ANSI_INDEX_NONE; |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6852 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6853 else |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6854 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6855 *r = 0; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6856 *g = 0; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6857 *b = 0; |
20500
03826c672315
patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents:
20450
diff
changeset
|
6858 *ansi_idx = ANSI_INDEX_NONE; |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6859 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6860 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6861 #endif |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15852
diff
changeset
|
6862 |
19405
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6863 /* |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6864 * Replace K_BS by <BS> and K_DEL by <DEL> |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6865 */ |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6866 void |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6867 term_replace_bs_del_keycode(char_u *ta_buf, int ta_len, int len) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6868 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6869 int i; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6870 int c; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6871 |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6872 for (i = ta_len; i < ta_len + len; ++i) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6873 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6874 if (ta_buf[i] == CSI && len - i > 2) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6875 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6876 c = TERMCAP2KEY(ta_buf[i + 1], ta_buf[i + 2]); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6877 if (c == K_DEL || c == K_KDEL || c == K_BS) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6878 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6879 mch_memmove(ta_buf + i + 1, ta_buf + i + 3, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6880 (size_t)(len - i - 2)); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6881 if (c == K_DEL || c == K_KDEL) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6882 ta_buf[i] = DEL; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6883 else |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6884 ta_buf[i] = Ctrl_H; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6885 len -= 2; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6886 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6887 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6888 else if (ta_buf[i] == '\r') |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6889 ta_buf[i] = '\n'; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6890 if (has_mbyte) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6891 i += (*mb_ptr2len_len)(ta_buf + i, ta_len + len - i) - 1; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6892 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19346
diff
changeset
|
6893 } |