Mercurial > vim
annotate src/term.c @ 12295:270256b6d0b8 v8.0.1027
patch 8.0.1027: more terminals can't handle requesting cursor mode
commit https://github.com/vim/vim/commit/2db0ec4b2ec405aca4e642e0420ce703f94914a8
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Aug 31 20:17:59 2017 +0200
patch 8.0.1027: more terminals can't handle requesting cursor mode
Problem: More terminals can't handle requesting cursor mode.
Solution: Recognize Putty. (Hirohito Higashi) Also include Xfce in the
version check. (Dominique Pelle) Recognize Konsole.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 31 Aug 2017 20:30:04 +0200 |
parents | decfedf9138d |
children | 50b0b3aaa545 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9939
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 /* | |
10 * | |
11 * term.c: functions for controlling the terminal | |
12 * | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
13 * primitive termcap support for Amiga and Win32 included |
7 | 14 * |
15 * NOTE: padding and variable substitution is not performed, | |
16 * when compiling without HAVE_TGETENT, we use tputs() and tgoto() dummies. | |
17 */ | |
18 | |
19 /* | |
20 * Some systems have a prototype for tgetstr() with (char *) instead of | |
21 * (char **). This define removes that prototype. We include our own prototype | |
22 * below. | |
23 */ | |
24 | |
25 #define tgetstr tgetstr_defined_wrong | |
26 #include "vim.h" | |
27 | |
28 #ifdef HAVE_TGETENT | |
29 # ifdef HAVE_TERMIOS_H | |
30 # include <termios.h> /* seems to be required for some Linux */ | |
31 # endif | |
32 # ifdef HAVE_TERMCAP_H | |
33 # include <termcap.h> | |
34 # endif | |
35 | |
36 /* | |
37 * A few linux systems define outfuntype in termcap.h to be used as the third | |
38 * argument for tputs(). | |
39 */ | |
40 # ifdef VMS | |
41 # define TPUTSFUNCAST | |
42 # else | |
43 # ifdef HAVE_OUTFUNTYPE | |
44 # define TPUTSFUNCAST (outfuntype) | |
45 # else | |
46 # define TPUTSFUNCAST (int (*)()) | |
47 # endif | |
48 # endif | |
49 #endif | |
50 | |
51 #undef tgetstr | |
52 | |
53 /* | |
54 * Here are the builtin termcap entries. They are not stored as complete | |
2823 | 55 * structures with all entries, as such a structure is too big. |
7 | 56 * |
57 * The entries are compact, therefore they normally are included even when | |
58 * HAVE_TGETENT is defined. When HAVE_TGETENT is defined, the builtin entries | |
59 * can be accessed with "builtin_amiga", "builtin_ansi", "builtin_debug", etc. | |
60 * | |
61 * Each termcap is a list of builtin_term structures. It always starts with | |
62 * KS_NAME, which separates the entries. See parse_builtin_tcap() for all | |
63 * details. | |
64 * bt_entry is either a KS_xxx code (>= 0), or a K_xxx code. | |
65 * | |
66 * Entries marked with "guessed" may be wrong. | |
67 */ | |
68 struct builtin_term | |
69 { | |
70 int bt_entry; | |
71 char *bt_string; | |
72 }; | |
73 | |
74 /* start of keys that are not directly used by Vim but can be mapped */ | |
75 #define BT_EXTRA_KEYS 0x101 | |
76 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
77 static struct builtin_term *find_builtin_term(char_u *name); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
78 static void parse_builtin_tcap(char_u *s); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
79 static void term_color(char_u *s, int n); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
80 static void gather_termleader(void); |
7 | 81 #ifdef FEAT_TERMRESPONSE |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
82 static void req_codes_from_term(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
83 static void req_more_codes_from_term(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
84 static void got_code_from_term(char_u *code, int len); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
85 static void check_for_codes_from_term(void); |
7 | 86 #endif |
87 #if defined(FEAT_GUI) \ | |
1623 | 88 || (defined(FEAT_MOUSE) && (!defined(UNIX) || defined(FEAT_MOUSE_XTERM) \ |
89 || defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE))) | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
90 static int get_bytes_from_buf(char_u *, char_u *, int); |
7 | 91 #endif |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
92 static void del_termcode_idx(int idx); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
93 static int term_is_builtin(char_u *name); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
94 static int term_7to8bit(char_u *p); |
7 | 95 #ifdef FEAT_TERMRESPONSE |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
96 static void switch_to_8bit(void); |
7 | 97 #endif |
98 | |
99 #ifdef HAVE_TGETENT | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
100 static char_u *tgetent_error(char_u *, char_u *); |
7 | 101 |
102 /* | |
103 * Here is our own prototype for tgetstr(), any prototypes from the include | |
104 * files have been disabled by the define at the start of this file. | |
105 */ | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
106 char *tgetstr(char *, char **); |
7 | 107 |
108 # ifdef FEAT_TERMRESPONSE | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
109 /* Change this to "if 1" to debug what happens with termresponse. */ |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
110 # if 0 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
111 # define DEBUG_TERMRESPONSE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
112 static void log_tr(char *msg); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
113 # define LOG_TR(msg) log_tr(msg) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
114 # else |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
115 # define LOG_TR(msg) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
116 # endif |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
117 |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
118 # define STATUS_GET 1 /* send request when switching to RAW mode */ |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
119 # define STATUS_SENT 2 /* did send request, waiting for response */ |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
120 # define STATUS_GOT 3 /* received response */ |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
121 |
7 | 122 /* Request Terminal Version status: */ |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
123 static int crv_status = STATUS_GET; |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
124 |
4215 | 125 /* Request Cursor position report: */ |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
126 static int u7_status = STATUS_GET; |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
127 |
6874 | 128 /* Request background color report: */ |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
129 static int rbg_status = STATUS_GET; |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
130 |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
131 /* Request cursor blinking mode report: */ |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
132 static int rbm_status = STATUS_GET; |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
133 |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
134 /* Request cursor style report: */ |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
135 static int rcs_status = STATUS_GET; |
7 | 136 # endif |
137 | |
138 /* | |
139 * Don't declare these variables if termcap.h contains them. | |
140 * Autoconf checks if these variables should be declared extern (not all | |
141 * systems have them). | |
142 * Some versions define ospeed to be speed_t, but that is incompatible with | |
143 * BSD, where ospeed is short and speed_t is long. | |
144 */ | |
145 # ifndef HAVE_OSPEED | |
146 # ifdef OSPEED_EXTERN | |
147 extern short ospeed; | |
148 # else | |
149 short ospeed; | |
150 # endif | |
151 # endif | |
152 # ifndef HAVE_UP_BC_PC | |
153 # ifdef UP_BC_PC_EXTERN | |
154 extern char *UP, *BC, PC; | |
155 # else | |
156 char *UP, *BC, PC; | |
157 # endif | |
158 # endif | |
159 | |
160 # define TGETSTR(s, p) vim_tgetstr((s), (p)) | |
161 # 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
|
162 static char_u *vim_tgetstr(char *s, char_u **pp); |
7 | 163 #endif /* HAVE_TGETENT */ |
164 | |
165 static int detected_8bit = FALSE; /* detected 8-bit terminal */ | |
166 | |
12184
76fbd85c3cea
patch 8.0.0972: compiler warnings for unused variables
Christian Brabandt <cb@256bit.org>
parents:
12174
diff
changeset
|
167 #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
|
168 /* When the cursor shape was detected these values are used: |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
169 * 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
|
170 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
|
171 |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
172 /* The blink flag from the style response may be inverted from the actual |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
173 * blinking state, xterm XORs the flags. */ |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
174 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
|
175 |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
176 /* 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
|
177 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
|
178 #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
|
179 |
298 | 180 static struct builtin_term builtin_termcaps[] = |
7 | 181 { |
182 | |
183 #if defined(FEAT_GUI) | |
184 /* | |
185 * GUI pseudo term-cap. | |
186 */ | |
187 {(int)KS_NAME, "gui"}, | |
188 {(int)KS_CE, IF_EB("\033|$", ESC_STR "|$")}, | |
189 {(int)KS_AL, IF_EB("\033|i", ESC_STR "|i")}, | |
190 # ifdef TERMINFO | |
191 {(int)KS_CAL, IF_EB("\033|%p1%dI", ESC_STR "|%p1%dI")}, | |
192 # else | |
193 {(int)KS_CAL, IF_EB("\033|%dI", ESC_STR "|%dI")}, | |
194 # endif | |
195 {(int)KS_DL, IF_EB("\033|d", ESC_STR "|d")}, | |
196 # ifdef TERMINFO | |
197 {(int)KS_CDL, IF_EB("\033|%p1%dD", ESC_STR "|%p1%dD")}, | |
198 {(int)KS_CS, IF_EB("\033|%p1%d;%p2%dR", ESC_STR "|%p1%d;%p2%dR")}, | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
199 # ifdef FEAT_WINDOWS |
7 | 200 {(int)KS_CSV, IF_EB("\033|%p1%d;%p2%dV", ESC_STR "|%p1%d;%p2%dV")}, |
201 # endif | |
202 # else | |
203 {(int)KS_CDL, IF_EB("\033|%dD", ESC_STR "|%dD")}, | |
204 {(int)KS_CS, IF_EB("\033|%d;%dR", ESC_STR "|%d;%dR")}, | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
205 # ifdef FEAT_WINDOWS |
7 | 206 {(int)KS_CSV, IF_EB("\033|%d;%dV", ESC_STR "|%d;%dV")}, |
207 # endif | |
208 # endif | |
209 {(int)KS_CL, IF_EB("\033|C", ESC_STR "|C")}, | |
210 /* attributes switched on with 'h', off with * 'H' */ | |
211 {(int)KS_ME, IF_EB("\033|31H", ESC_STR "|31H")}, /* HL_ALL */ | |
212 {(int)KS_MR, IF_EB("\033|1h", ESC_STR "|1h")}, /* HL_INVERSE */ | |
213 {(int)KS_MD, IF_EB("\033|2h", ESC_STR "|2h")}, /* HL_BOLD */ | |
214 {(int)KS_SE, IF_EB("\033|16H", ESC_STR "|16H")}, /* HL_STANDOUT */ | |
215 {(int)KS_SO, IF_EB("\033|16h", ESC_STR "|16h")}, /* HL_STANDOUT */ | |
216 {(int)KS_UE, IF_EB("\033|8H", ESC_STR "|8H")}, /* HL_UNDERLINE */ | |
217 {(int)KS_US, IF_EB("\033|8h", ESC_STR "|8h")}, /* HL_UNDERLINE */ | |
205 | 218 {(int)KS_UCE, IF_EB("\033|8C", ESC_STR "|8C")}, /* HL_UNDERCURL */ |
219 {(int)KS_UCS, IF_EB("\033|8c", ESC_STR "|8c")}, /* HL_UNDERCURL */ | |
7 | 220 {(int)KS_CZR, IF_EB("\033|4H", ESC_STR "|4H")}, /* HL_ITALIC */ |
221 {(int)KS_CZH, IF_EB("\033|4h", ESC_STR "|4h")}, /* HL_ITALIC */ | |
222 {(int)KS_VB, IF_EB("\033|f", ESC_STR "|f")}, | |
223 {(int)KS_MS, "y"}, | |
224 {(int)KS_UT, "y"}, | |
6602 | 225 {(int)KS_XN, "y"}, |
7 | 226 {(int)KS_LE, "\b"}, /* cursor-left = BS */ |
227 {(int)KS_ND, "\014"}, /* cursor-right = CTRL-L */ | |
228 # ifdef TERMINFO | |
229 {(int)KS_CM, IF_EB("\033|%p1%d;%p2%dM", ESC_STR "|%p1%d;%p2%dM")}, | |
230 # else | |
231 {(int)KS_CM, IF_EB("\033|%d;%dM", ESC_STR "|%d;%dM")}, | |
232 # endif | |
233 /* there are no key sequences here, the GUI sequences are recognized | |
205 | 234 * in check_termcode() */ |
7 | 235 #endif |
236 | |
237 #ifndef NO_BUILTIN_TCAPS | |
238 | |
239 # if defined(AMIGA) || defined(ALL_BUILTIN_TCAPS) | |
240 /* | |
241 * Amiga console window, default for Amiga | |
242 */ | |
243 {(int)KS_NAME, "amiga"}, | |
244 {(int)KS_CE, "\033[K"}, | |
245 {(int)KS_CD, "\033[J"}, | |
246 {(int)KS_AL, "\033[L"}, | |
247 # ifdef TERMINFO | |
248 {(int)KS_CAL, "\033[%p1%dL"}, | |
249 # else | |
250 {(int)KS_CAL, "\033[%dL"}, | |
251 # endif | |
252 {(int)KS_DL, "\033[M"}, | |
253 # ifdef TERMINFO | |
254 {(int)KS_CDL, "\033[%p1%dM"}, | |
255 # else | |
256 {(int)KS_CDL, "\033[%dM"}, | |
257 # endif | |
258 {(int)KS_CL, "\014"}, | |
259 {(int)KS_VI, "\033[0 p"}, | |
260 {(int)KS_VE, "\033[1 p"}, | |
261 {(int)KS_ME, "\033[0m"}, | |
262 {(int)KS_MR, "\033[7m"}, | |
263 {(int)KS_MD, "\033[1m"}, | |
264 {(int)KS_SE, "\033[0m"}, | |
265 {(int)KS_SO, "\033[33m"}, | |
266 {(int)KS_US, "\033[4m"}, | |
267 {(int)KS_UE, "\033[0m"}, | |
268 {(int)KS_CZH, "\033[3m"}, | |
269 {(int)KS_CZR, "\033[0m"}, | |
270 #if defined(__MORPHOS__) || defined(__AROS__) | |
271 {(int)KS_CCO, "8"}, /* allow 8 colors */ | |
272 # ifdef TERMINFO | |
273 {(int)KS_CAB, "\033[4%p1%dm"},/* set background color */ | |
274 {(int)KS_CAF, "\033[3%p1%dm"},/* set foreground color */ | |
275 # else | |
276 {(int)KS_CAB, "\033[4%dm"}, /* set background color */ | |
277 {(int)KS_CAF, "\033[3%dm"}, /* set foreground color */ | |
278 # endif | |
279 {(int)KS_OP, "\033[m"}, /* reset colors */ | |
280 #endif | |
281 {(int)KS_MS, "y"}, | |
282 {(int)KS_UT, "y"}, /* guessed */ | |
283 {(int)KS_LE, "\b"}, | |
284 # ifdef TERMINFO | |
285 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
286 # else | |
287 {(int)KS_CM, "\033[%i%d;%dH"}, | |
288 # endif | |
289 #if defined(__MORPHOS__) | |
290 {(int)KS_SR, "\033M"}, | |
291 #endif | |
292 # ifdef TERMINFO | |
293 {(int)KS_CRI, "\033[%p1%dC"}, | |
294 # else | |
295 {(int)KS_CRI, "\033[%dC"}, | |
296 # endif | |
297 {K_UP, "\233A"}, | |
298 {K_DOWN, "\233B"}, | |
299 {K_LEFT, "\233D"}, | |
300 {K_RIGHT, "\233C"}, | |
301 {K_S_UP, "\233T"}, | |
302 {K_S_DOWN, "\233S"}, | |
303 {K_S_LEFT, "\233 A"}, | |
304 {K_S_RIGHT, "\233 @"}, | |
305 {K_S_TAB, "\233Z"}, | |
306 {K_F1, "\233\060~"},/* some compilers don't dig "\2330" */ | |
307 {K_F2, "\233\061~"}, | |
308 {K_F3, "\233\062~"}, | |
309 {K_F4, "\233\063~"}, | |
310 {K_F5, "\233\064~"}, | |
311 {K_F6, "\233\065~"}, | |
312 {K_F7, "\233\066~"}, | |
313 {K_F8, "\233\067~"}, | |
314 {K_F9, "\233\070~"}, | |
315 {K_F10, "\233\071~"}, | |
316 {K_S_F1, "\233\061\060~"}, | |
317 {K_S_F2, "\233\061\061~"}, | |
318 {K_S_F3, "\233\061\062~"}, | |
319 {K_S_F4, "\233\061\063~"}, | |
320 {K_S_F5, "\233\061\064~"}, | |
321 {K_S_F6, "\233\061\065~"}, | |
322 {K_S_F7, "\233\061\066~"}, | |
323 {K_S_F8, "\233\061\067~"}, | |
324 {K_S_F9, "\233\061\070~"}, | |
325 {K_S_F10, "\233\061\071~"}, | |
326 {K_HELP, "\233?~"}, | |
327 {K_INS, "\233\064\060~"}, /* 101 key keyboard */ | |
328 {K_PAGEUP, "\233\064\061~"}, /* 101 key keyboard */ | |
329 {K_PAGEDOWN, "\233\064\062~"}, /* 101 key keyboard */ | |
330 {K_HOME, "\233\064\064~"}, /* 101 key keyboard */ | |
331 {K_END, "\233\064\065~"}, /* 101 key keyboard */ | |
332 | |
333 {BT_EXTRA_KEYS, ""}, | |
334 {TERMCAP2KEY('#', '2'), "\233\065\064~"}, /* shifted home key */ | |
335 {TERMCAP2KEY('#', '3'), "\233\065\060~"}, /* shifted insert key */ | |
336 {TERMCAP2KEY('*', '7'), "\233\065\065~"}, /* shifted end key */ | |
337 # endif | |
338 | |
339 # if defined(__BEOS__) || defined(ALL_BUILTIN_TCAPS) | |
340 /* | |
341 * almost standard ANSI terminal, default for bebox | |
342 */ | |
343 {(int)KS_NAME, "beos-ansi"}, | |
344 {(int)KS_CE, "\033[K"}, | |
345 {(int)KS_CD, "\033[J"}, | |
346 {(int)KS_AL, "\033[L"}, | |
347 # ifdef TERMINFO | |
348 {(int)KS_CAL, "\033[%p1%dL"}, | |
349 # else | |
350 {(int)KS_CAL, "\033[%dL"}, | |
351 # endif | |
352 {(int)KS_DL, "\033[M"}, | |
353 # ifdef TERMINFO | |
354 {(int)KS_CDL, "\033[%p1%dM"}, | |
355 # else | |
356 {(int)KS_CDL, "\033[%dM"}, | |
357 # endif | |
358 #ifdef BEOS_PR_OR_BETTER | |
359 # ifdef TERMINFO | |
360 {(int)KS_CS, "\033[%i%p1%d;%p2%dr"}, | |
361 # else | |
362 {(int)KS_CS, "\033[%i%d;%dr"}, /* scroll region */ | |
363 # endif | |
364 #endif | |
365 {(int)KS_CL, "\033[H\033[2J"}, | |
366 #ifdef notyet | |
367 {(int)KS_VI, "[VI]"}, /* cursor invisible, VT320: CSI ? 25 l */ | |
368 {(int)KS_VE, "[VE]"}, /* cursor visible, VT320: CSI ? 25 h */ | |
369 #endif | |
370 {(int)KS_ME, "\033[m"}, /* normal mode */ | |
371 {(int)KS_MR, "\033[7m"}, /* reverse */ | |
372 {(int)KS_MD, "\033[1m"}, /* bold */ | |
373 {(int)KS_SO, "\033[31m"}, /* standout mode: red */ | |
374 {(int)KS_SE, "\033[m"}, /* standout end */ | |
375 {(int)KS_CZH, "\033[35m"}, /* italic: purple */ | |
376 {(int)KS_CZR, "\033[m"}, /* italic end */ | |
377 {(int)KS_US, "\033[4m"}, /* underscore mode */ | |
378 {(int)KS_UE, "\033[m"}, /* underscore end */ | |
379 {(int)KS_CCO, "8"}, /* allow 8 colors */ | |
380 # ifdef TERMINFO | |
381 {(int)KS_CAB, "\033[4%p1%dm"},/* set background color */ | |
382 {(int)KS_CAF, "\033[3%p1%dm"},/* set foreground color */ | |
383 # else | |
384 {(int)KS_CAB, "\033[4%dm"}, /* set background color */ | |
385 {(int)KS_CAF, "\033[3%dm"}, /* set foreground color */ | |
386 # endif | |
387 {(int)KS_OP, "\033[m"}, /* reset colors */ | |
388 {(int)KS_MS, "y"}, /* safe to move cur in reverse mode */ | |
389 {(int)KS_UT, "y"}, /* guessed */ | |
390 {(int)KS_LE, "\b"}, | |
391 # ifdef TERMINFO | |
392 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
393 # else | |
394 {(int)KS_CM, "\033[%i%d;%dH"}, | |
395 # endif | |
396 {(int)KS_SR, "\033M"}, | |
397 # ifdef TERMINFO | |
398 {(int)KS_CRI, "\033[%p1%dC"}, | |
399 # else | |
400 {(int)KS_CRI, "\033[%dC"}, | |
401 # endif | |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
402 # if defined(BEOS_DR8) |
7 | 403 {(int)KS_DB, ""}, /* hack! see screen.c */ |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
404 # endif |
7 | 405 |
406 {K_UP, "\033[A"}, | |
407 {K_DOWN, "\033[B"}, | |
408 {K_LEFT, "\033[D"}, | |
409 {K_RIGHT, "\033[C"}, | |
410 # endif | |
411 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
412 # if defined(UNIX) || defined(ALL_BUILTIN_TCAPS) || defined(SOME_BUILTIN_TCAPS) |
7 | 413 /* |
414 * standard ANSI terminal, default for unix | |
415 */ | |
416 {(int)KS_NAME, "ansi"}, | |
417 {(int)KS_CE, IF_EB("\033[K", ESC_STR "[K")}, | |
418 {(int)KS_AL, IF_EB("\033[L", ESC_STR "[L")}, | |
419 # ifdef TERMINFO | |
420 {(int)KS_CAL, IF_EB("\033[%p1%dL", ESC_STR "[%p1%dL")}, | |
421 # else | |
422 {(int)KS_CAL, IF_EB("\033[%dL", ESC_STR "[%dL")}, | |
423 # endif | |
424 {(int)KS_DL, IF_EB("\033[M", ESC_STR "[M")}, | |
425 # ifdef TERMINFO | |
426 {(int)KS_CDL, IF_EB("\033[%p1%dM", ESC_STR "[%p1%dM")}, | |
427 # else | |
428 {(int)KS_CDL, IF_EB("\033[%dM", ESC_STR "[%dM")}, | |
429 # endif | |
430 {(int)KS_CL, IF_EB("\033[H\033[2J", ESC_STR "[H" ESC_STR_nc "[2J")}, | |
431 {(int)KS_ME, IF_EB("\033[0m", ESC_STR "[0m")}, | |
432 {(int)KS_MR, IF_EB("\033[7m", ESC_STR "[7m")}, | |
433 {(int)KS_MS, "y"}, | |
434 {(int)KS_UT, "y"}, /* guessed */ | |
435 {(int)KS_LE, "\b"}, | |
436 # ifdef TERMINFO | |
437 {(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", ESC_STR "[%i%p1%d;%p2%dH")}, | |
438 # else | |
439 {(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")}, | |
440 # endif | |
441 # ifdef TERMINFO | |
442 {(int)KS_CRI, IF_EB("\033[%p1%dC", ESC_STR "[%p1%dC")}, | |
443 # else | |
444 {(int)KS_CRI, IF_EB("\033[%dC", ESC_STR "[%dC")}, | |
445 # endif | |
446 # endif | |
447 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
448 # if defined(ALL_BUILTIN_TCAPS) |
7 | 449 /* |
450 * These codes are valid when nansi.sys or equivalent has been installed. | |
451 * Function keys on a PC are preceded with a NUL. These are converted into | |
452 * K_NUL '\316' in mch_inchar(), because we cannot handle NULs in key codes. | |
453 * CTRL-arrow is used instead of SHIFT-arrow. | |
454 */ | |
455 {(int)KS_NAME, "pcansi"}, | |
456 {(int)KS_DL, "\033[M"}, | |
457 {(int)KS_AL, "\033[L"}, | |
458 {(int)KS_CE, "\033[K"}, | |
459 {(int)KS_CL, "\033[2J"}, | |
460 {(int)KS_ME, "\033[0m"}, | |
461 {(int)KS_MR, "\033[5m"}, /* reverse: black on lightgrey */ | |
462 {(int)KS_MD, "\033[1m"}, /* bold: white text */ | |
463 {(int)KS_SE, "\033[0m"}, /* standout end */ | |
464 {(int)KS_SO, "\033[31m"}, /* standout: white on blue */ | |
465 {(int)KS_CZH, "\033[34;43m"}, /* italic mode: blue text on yellow */ | |
466 {(int)KS_CZR, "\033[0m"}, /* italic mode end */ | |
467 {(int)KS_US, "\033[36;41m"}, /* underscore mode: cyan text on red */ | |
468 {(int)KS_UE, "\033[0m"}, /* underscore mode end */ | |
469 {(int)KS_CCO, "8"}, /* allow 8 colors */ | |
470 # ifdef TERMINFO | |
471 {(int)KS_CAB, "\033[4%p1%dm"},/* set background color */ | |
472 {(int)KS_CAF, "\033[3%p1%dm"},/* set foreground color */ | |
473 # else | |
474 {(int)KS_CAB, "\033[4%dm"}, /* set background color */ | |
475 {(int)KS_CAF, "\033[3%dm"}, /* set foreground color */ | |
476 # endif | |
477 {(int)KS_OP, "\033[0m"}, /* reset colors */ | |
478 {(int)KS_MS, "y"}, | |
479 {(int)KS_UT, "y"}, /* guessed */ | |
480 {(int)KS_LE, "\b"}, | |
481 # ifdef TERMINFO | |
482 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
483 # else | |
484 {(int)KS_CM, "\033[%i%d;%dH"}, | |
485 # endif | |
486 # ifdef TERMINFO | |
487 {(int)KS_CRI, "\033[%p1%dC"}, | |
488 # else | |
489 {(int)KS_CRI, "\033[%dC"}, | |
490 # endif | |
491 {K_UP, "\316H"}, | |
492 {K_DOWN, "\316P"}, | |
493 {K_LEFT, "\316K"}, | |
494 {K_RIGHT, "\316M"}, | |
495 {K_S_LEFT, "\316s"}, | |
496 {K_S_RIGHT, "\316t"}, | |
497 {K_F1, "\316;"}, | |
498 {K_F2, "\316<"}, | |
499 {K_F3, "\316="}, | |
500 {K_F4, "\316>"}, | |
501 {K_F5, "\316?"}, | |
502 {K_F6, "\316@"}, | |
503 {K_F7, "\316A"}, | |
504 {K_F8, "\316B"}, | |
505 {K_F9, "\316C"}, | |
506 {K_F10, "\316D"}, | |
507 {K_F11, "\316\205"}, /* guessed */ | |
508 {K_F12, "\316\206"}, /* guessed */ | |
509 {K_S_F1, "\316T"}, | |
510 {K_S_F2, "\316U"}, | |
511 {K_S_F3, "\316V"}, | |
512 {K_S_F4, "\316W"}, | |
513 {K_S_F5, "\316X"}, | |
514 {K_S_F6, "\316Y"}, | |
515 {K_S_F7, "\316Z"}, | |
516 {K_S_F8, "\316["}, | |
517 {K_S_F9, "\316\\"}, | |
518 {K_S_F10, "\316]"}, | |
519 {K_S_F11, "\316\207"}, /* guessed */ | |
520 {K_S_F12, "\316\210"}, /* guessed */ | |
521 {K_INS, "\316R"}, | |
522 {K_DEL, "\316S"}, | |
523 {K_HOME, "\316G"}, | |
524 {K_END, "\316O"}, | |
525 {K_PAGEDOWN, "\316Q"}, | |
526 {K_PAGEUP, "\316I"}, | |
527 # endif | |
528 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
529 # if defined(WIN3264) || defined(ALL_BUILTIN_TCAPS) |
7 | 530 /* |
531 * These codes are valid for the Win32 Console . The entries that start with | |
532 * ESC | are translated into console calls in os_win32.c. The function keys | |
533 * are also translated in os_win32.c. | |
534 */ | |
535 {(int)KS_NAME, "win32"}, | |
536 {(int)KS_CE, "\033|K"}, /* clear to end of line */ | |
537 {(int)KS_AL, "\033|L"}, /* add new blank line */ | |
538 # ifdef TERMINFO | |
539 {(int)KS_CAL, "\033|%p1%dL"}, /* add number of new blank lines */ | |
540 # else | |
541 {(int)KS_CAL, "\033|%dL"}, /* add number of new blank lines */ | |
542 # endif | |
543 {(int)KS_DL, "\033|M"}, /* delete line */ | |
544 # ifdef TERMINFO | |
545 {(int)KS_CDL, "\033|%p1%dM"}, /* delete number of lines */ | |
546 # else | |
547 {(int)KS_CDL, "\033|%dM"}, /* delete number of lines */ | |
548 # endif | |
549 {(int)KS_CL, "\033|J"}, /* clear screen */ | |
550 {(int)KS_CD, "\033|j"}, /* clear to end of display */ | |
551 {(int)KS_VI, "\033|v"}, /* cursor invisible */ | |
552 {(int)KS_VE, "\033|V"}, /* cursor visible */ | |
553 | |
554 {(int)KS_ME, "\033|0m"}, /* normal */ | |
555 {(int)KS_MR, "\033|112m"}, /* reverse: black on lightgray */ | |
556 {(int)KS_MD, "\033|15m"}, /* bold: white on black */ | |
557 #if 1 | |
558 {(int)KS_SO, "\033|31m"}, /* standout: white on blue */ | |
559 {(int)KS_SE, "\033|0m"}, /* standout end */ | |
560 #else | |
561 {(int)KS_SO, "\033|F"}, /* standout: high intensity */ | |
562 {(int)KS_SE, "\033|f"}, /* standout end */ | |
563 #endif | |
564 {(int)KS_CZH, "\033|225m"}, /* italic: blue text on yellow */ | |
565 {(int)KS_CZR, "\033|0m"}, /* italic end */ | |
566 {(int)KS_US, "\033|67m"}, /* underscore: cyan text on red */ | |
567 {(int)KS_UE, "\033|0m"}, /* underscore end */ | |
568 {(int)KS_CCO, "16"}, /* allow 16 colors */ | |
569 # ifdef TERMINFO | |
570 {(int)KS_CAB, "\033|%p1%db"}, /* set background color */ | |
571 {(int)KS_CAF, "\033|%p1%df"}, /* set foreground color */ | |
572 # else | |
573 {(int)KS_CAB, "\033|%db"}, /* set background color */ | |
574 {(int)KS_CAF, "\033|%df"}, /* set foreground color */ | |
575 # endif | |
576 | |
577 {(int)KS_MS, "y"}, /* save to move cur in reverse mode */ | |
578 {(int)KS_UT, "y"}, | |
6602 | 579 {(int)KS_XN, "y"}, |
7 | 580 {(int)KS_LE, "\b"}, |
581 # ifdef TERMINFO | |
582 {(int)KS_CM, "\033|%i%p1%d;%p2%dH"},/* cursor motion */ | |
583 # else | |
584 {(int)KS_CM, "\033|%i%d;%dH"},/* cursor motion */ | |
585 # endif | |
586 {(int)KS_VB, "\033|B"}, /* visual bell */ | |
587 {(int)KS_TI, "\033|S"}, /* put terminal in termcap mode */ | |
588 {(int)KS_TE, "\033|E"}, /* out of termcap mode */ | |
589 # ifdef TERMINFO | |
590 {(int)KS_CS, "\033|%i%p1%d;%p2%dr"},/* scroll region */ | |
591 # else | |
592 {(int)KS_CS, "\033|%i%d;%dr"},/* scroll region */ | |
593 # endif | |
594 | |
595 {K_UP, "\316H"}, | |
596 {K_DOWN, "\316P"}, | |
597 {K_LEFT, "\316K"}, | |
598 {K_RIGHT, "\316M"}, | |
599 {K_S_UP, "\316\304"}, | |
600 {K_S_DOWN, "\316\317"}, | |
601 {K_S_LEFT, "\316\311"}, | |
602 {K_C_LEFT, "\316s"}, | |
603 {K_S_RIGHT, "\316\313"}, | |
604 {K_C_RIGHT, "\316t"}, | |
605 {K_S_TAB, "\316\017"}, | |
606 {K_F1, "\316;"}, | |
607 {K_F2, "\316<"}, | |
608 {K_F3, "\316="}, | |
609 {K_F4, "\316>"}, | |
610 {K_F5, "\316?"}, | |
611 {K_F6, "\316@"}, | |
612 {K_F7, "\316A"}, | |
613 {K_F8, "\316B"}, | |
614 {K_F9, "\316C"}, | |
615 {K_F10, "\316D"}, | |
616 {K_F11, "\316\205"}, | |
617 {K_F12, "\316\206"}, | |
618 {K_S_F1, "\316T"}, | |
619 {K_S_F2, "\316U"}, | |
620 {K_S_F3, "\316V"}, | |
621 {K_S_F4, "\316W"}, | |
622 {K_S_F5, "\316X"}, | |
623 {K_S_F6, "\316Y"}, | |
624 {K_S_F7, "\316Z"}, | |
625 {K_S_F8, "\316["}, | |
626 {K_S_F9, "\316\\"}, | |
627 {K_S_F10, "\316]"}, | |
628 {K_S_F11, "\316\207"}, | |
629 {K_S_F12, "\316\210"}, | |
630 {K_INS, "\316R"}, | |
631 {K_DEL, "\316S"}, | |
632 {K_HOME, "\316G"}, | |
633 {K_S_HOME, "\316\302"}, | |
634 {K_C_HOME, "\316w"}, | |
635 {K_END, "\316O"}, | |
636 {K_S_END, "\316\315"}, | |
637 {K_C_END, "\316u"}, | |
638 {K_PAGEDOWN, "\316Q"}, | |
639 {K_PAGEUP, "\316I"}, | |
640 {K_KPLUS, "\316N"}, | |
641 {K_KMINUS, "\316J"}, | |
642 {K_KMULTIPLY, "\316\067"}, | |
643 {K_K0, "\316\332"}, | |
644 {K_K1, "\316\336"}, | |
645 {K_K2, "\316\342"}, | |
646 {K_K3, "\316\346"}, | |
647 {K_K4, "\316\352"}, | |
648 {K_K5, "\316\356"}, | |
649 {K_K6, "\316\362"}, | |
650 {K_K7, "\316\366"}, | |
651 {K_K8, "\316\372"}, | |
652 {K_K9, "\316\376"}, | |
653 # endif | |
654 | |
655 # if defined(VMS) || defined(ALL_BUILTIN_TCAPS) | |
656 /* | |
657 * VT320 is working as an ANSI terminal compatible DEC terminal. | |
658 * (it covers VT1x0, VT2x0 and VT3x0 up to VT320 on VMS as well) | |
659 * Note: K_F1...K_F5 are for internal use, should not be defined. | |
660 * TODO:- rewrite ESC[ codes to CSI | |
661 * - keyboard languages (CSI ? 26 n) | |
662 */ | |
663 {(int)KS_NAME, "vt320"}, | |
664 {(int)KS_CE, IF_EB("\033[K", ESC_STR "[K")}, | |
665 {(int)KS_AL, IF_EB("\033[L", ESC_STR "[L")}, | |
666 # ifdef TERMINFO | |
667 {(int)KS_CAL, IF_EB("\033[%p1%dL", ESC_STR "[%p1%dL")}, | |
668 # else | |
669 {(int)KS_CAL, IF_EB("\033[%dL", ESC_STR "[%dL")}, | |
670 # endif | |
671 {(int)KS_DL, IF_EB("\033[M", ESC_STR "[M")}, | |
672 # ifdef TERMINFO | |
673 {(int)KS_CDL, IF_EB("\033[%p1%dM", ESC_STR "[%p1%dM")}, | |
674 # else | |
675 {(int)KS_CDL, IF_EB("\033[%dM", ESC_STR "[%dM")}, | |
676 # endif | |
677 {(int)KS_CL, IF_EB("\033[H\033[2J", ESC_STR "[H" ESC_STR_nc "[2J")}, | |
22 | 678 {(int)KS_CD, IF_EB("\033[J", ESC_STR "[J")}, |
679 {(int)KS_CCO, "8"}, /* allow 8 colors */ | |
7 | 680 {(int)KS_ME, IF_EB("\033[0m", ESC_STR "[0m")}, |
681 {(int)KS_MR, IF_EB("\033[7m", ESC_STR "[7m")}, | |
344 | 682 {(int)KS_MD, IF_EB("\033[1m", ESC_STR "[1m")}, /* bold mode */ |
683 {(int)KS_SE, IF_EB("\033[22m", ESC_STR "[22m")},/* normal mode */ | |
684 {(int)KS_UE, IF_EB("\033[24m", ESC_STR "[24m")},/* exit underscore mode */ | |
685 {(int)KS_US, IF_EB("\033[4m", ESC_STR "[4m")}, /* underscore mode */ | |
686 {(int)KS_CZH, IF_EB("\033[34;43m", ESC_STR "[34;43m")}, /* italic mode: blue text on yellow */ | |
687 {(int)KS_CZR, IF_EB("\033[0m", ESC_STR "[0m")}, /* italic mode end */ | |
688 {(int)KS_CAB, IF_EB("\033[4%dm", ESC_STR "[4%dm")}, /* set background color (ANSI) */ | |
689 {(int)KS_CAF, IF_EB("\033[3%dm", ESC_STR "[3%dm")}, /* set foreground color (ANSI) */ | |
690 {(int)KS_CSB, IF_EB("\033[102;%dm", ESC_STR "[102;%dm")}, /* set screen background color */ | |
691 {(int)KS_CSF, IF_EB("\033[101;%dm", ESC_STR "[101;%dm")}, /* set screen foreground color */ | |
7 | 692 {(int)KS_MS, "y"}, |
693 {(int)KS_UT, "y"}, | |
6602 | 694 {(int)KS_XN, "y"}, |
7 | 695 {(int)KS_LE, "\b"}, |
696 # ifdef TERMINFO | |
697 {(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", | |
698 ESC_STR "[%i%p1%d;%p2%dH")}, | |
699 # else | |
700 {(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")}, | |
701 # endif | |
702 # ifdef TERMINFO | |
703 {(int)KS_CRI, IF_EB("\033[%p1%dC", ESC_STR "[%p1%dC")}, | |
704 # else | |
705 {(int)KS_CRI, IF_EB("\033[%dC", ESC_STR "[%dC")}, | |
706 # endif | |
707 {K_UP, IF_EB("\033[A", ESC_STR "[A")}, | |
708 {K_DOWN, IF_EB("\033[B", ESC_STR "[B")}, | |
709 {K_RIGHT, IF_EB("\033[C", ESC_STR "[C")}, | |
710 {K_LEFT, IF_EB("\033[D", ESC_STR "[D")}, | |
344 | 711 {K_F1, IF_EB("\033[11~", ESC_STR "[11~")}, |
712 {K_F2, IF_EB("\033[12~", ESC_STR "[12~")}, | |
713 {K_F3, IF_EB("\033[13~", ESC_STR "[13~")}, | |
714 {K_F4, IF_EB("\033[14~", ESC_STR "[14~")}, | |
715 {K_F5, IF_EB("\033[15~", ESC_STR "[15~")}, | |
7 | 716 {K_F6, IF_EB("\033[17~", ESC_STR "[17~")}, |
717 {K_F7, IF_EB("\033[18~", ESC_STR "[18~")}, | |
718 {K_F8, IF_EB("\033[19~", ESC_STR "[19~")}, | |
719 {K_F9, IF_EB("\033[20~", ESC_STR "[20~")}, | |
720 {K_F10, IF_EB("\033[21~", ESC_STR "[21~")}, | |
344 | 721 {K_F11, IF_EB("\033[23~", ESC_STR "[23~")}, |
7 | 722 {K_F12, IF_EB("\033[24~", ESC_STR "[24~")}, |
723 {K_F13, IF_EB("\033[25~", ESC_STR "[25~")}, | |
724 {K_F14, IF_EB("\033[26~", ESC_STR "[26~")}, | |
725 {K_F15, IF_EB("\033[28~", ESC_STR "[28~")}, /* Help */ | |
726 {K_F16, IF_EB("\033[29~", ESC_STR "[29~")}, /* Select */ | |
727 {K_F17, IF_EB("\033[31~", ESC_STR "[31~")}, | |
728 {K_F18, IF_EB("\033[32~", ESC_STR "[32~")}, | |
729 {K_F19, IF_EB("\033[33~", ESC_STR "[33~")}, | |
730 {K_F20, IF_EB("\033[34~", ESC_STR "[34~")}, | |
731 {K_INS, IF_EB("\033[2~", ESC_STR "[2~")}, | |
732 {K_DEL, IF_EB("\033[3~", ESC_STR "[3~")}, | |
733 {K_HOME, IF_EB("\033[1~", ESC_STR "[1~")}, | |
734 {K_END, IF_EB("\033[4~", ESC_STR "[4~")}, | |
735 {K_PAGEUP, IF_EB("\033[5~", ESC_STR "[5~")}, | |
736 {K_PAGEDOWN, IF_EB("\033[6~", ESC_STR "[6~")}, | |
737 {K_KPLUS, IF_EB("\033Ok", ESC_STR "Ok")}, /* keypad plus */ | |
738 {K_KMINUS, IF_EB("\033Om", ESC_STR "Om")}, /* keypad minus */ | |
739 {K_KDIVIDE, IF_EB("\033Oo", ESC_STR "Oo")}, /* keypad / */ | |
740 {K_KMULTIPLY, IF_EB("\033Oj", ESC_STR "Oj")}, /* keypad * */ | |
741 {K_KENTER, IF_EB("\033OM", ESC_STR "OM")}, /* keypad Enter */ | |
742 {K_BS, "\x7f"}, /* for some reason 0177 doesn't work */ | |
743 # endif | |
744 | |
745 # if defined(ALL_BUILTIN_TCAPS) || defined(__MINT__) | |
746 /* | |
747 * Ordinary vt52 | |
748 */ | |
749 {(int)KS_NAME, "vt52"}, | |
750 {(int)KS_CE, IF_EB("\033K", ESC_STR "K")}, | |
751 {(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
|
752 # ifdef TERMINFO |
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
753 {(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
|
754 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
|
755 # else |
7 | 756 {(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
|
757 # endif |
7 | 758 {(int)KS_LE, "\b"}, |
7264
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
759 {(int)KS_SR, IF_EB("\033I", ESC_STR "I")}, |
7 | 760 {(int)KS_AL, IF_EB("\033L", ESC_STR "L")}, |
761 {(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
|
762 {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
|
763 {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
|
764 {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
|
765 {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
|
766 {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
|
767 {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
|
768 {K_F3, IF_EB("\033R", ESC_STR "R")}, |
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
769 # ifdef __MINT__ |
7 | 770 {(int)KS_CL, IF_EB("\033E", ESC_STR "E")}, |
771 {(int)KS_VE, IF_EB("\033e", ESC_STR "e")}, | |
772 {(int)KS_VI, IF_EB("\033f", ESC_STR "f")}, | |
773 {(int)KS_SO, IF_EB("\033p", ESC_STR "p")}, | |
774 {(int)KS_SE, IF_EB("\033q", ESC_STR "q")}, | |
775 {K_S_UP, IF_EB("\033a", ESC_STR "a")}, | |
776 {K_S_DOWN, IF_EB("\033b", ESC_STR "b")}, | |
777 {K_S_LEFT, IF_EB("\033d", ESC_STR "d")}, | |
778 {K_S_RIGHT, IF_EB("\033c", ESC_STR "c")}, | |
779 {K_F4, IF_EB("\033S", ESC_STR "S")}, | |
780 {K_F5, IF_EB("\033T", ESC_STR "T")}, | |
781 {K_F6, IF_EB("\033U", ESC_STR "U")}, | |
782 {K_F7, IF_EB("\033V", ESC_STR "V")}, | |
783 {K_F8, IF_EB("\033W", ESC_STR "W")}, | |
784 {K_F9, IF_EB("\033X", ESC_STR "X")}, | |
785 {K_F10, IF_EB("\033Y", ESC_STR "Y")}, | |
786 {K_S_F1, IF_EB("\033p", ESC_STR "p")}, | |
787 {K_S_F2, IF_EB("\033q", ESC_STR "q")}, | |
788 {K_S_F3, IF_EB("\033r", ESC_STR "r")}, | |
789 {K_S_F4, IF_EB("\033s", ESC_STR "s")}, | |
790 {K_S_F5, IF_EB("\033t", ESC_STR "t")}, | |
791 {K_S_F6, IF_EB("\033u", ESC_STR "u")}, | |
792 {K_S_F7, IF_EB("\033v", ESC_STR "v")}, | |
793 {K_S_F8, IF_EB("\033w", ESC_STR "w")}, | |
794 {K_S_F9, IF_EB("\033x", ESC_STR "x")}, | |
795 {K_S_F10, IF_EB("\033y", ESC_STR "y")}, | |
796 {K_INS, IF_EB("\033I", ESC_STR "I")}, | |
797 {K_HOME, IF_EB("\033E", ESC_STR "E")}, | |
798 {K_PAGEDOWN, IF_EB("\033b", ESC_STR "b")}, | |
799 {K_PAGEUP, IF_EB("\033a", ESC_STR "a")}, | |
800 # else | |
801 {(int)KS_CL, IF_EB("\033H\033J", ESC_STR "H" ESC_STR_nc "J")}, | |
802 {(int)KS_MS, "y"}, | |
803 # endif | |
804 # endif | |
805 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
806 # 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
|
807 {(int)KS_NAME, "xterm"}, |
7 | 808 {(int)KS_CE, IF_EB("\033[K", ESC_STR "[K")}, |
809 {(int)KS_AL, IF_EB("\033[L", ESC_STR "[L")}, | |
810 # ifdef TERMINFO | |
811 {(int)KS_CAL, IF_EB("\033[%p1%dL", ESC_STR "[%p1%dL")}, | |
812 # else | |
813 {(int)KS_CAL, IF_EB("\033[%dL", ESC_STR "[%dL")}, | |
814 # endif | |
815 {(int)KS_DL, IF_EB("\033[M", ESC_STR "[M")}, | |
816 # ifdef TERMINFO | |
817 {(int)KS_CDL, IF_EB("\033[%p1%dM", ESC_STR "[%p1%dM")}, | |
818 # else | |
819 {(int)KS_CDL, IF_EB("\033[%dM", ESC_STR "[%dM")}, | |
820 # endif | |
821 # ifdef TERMINFO | |
822 {(int)KS_CS, IF_EB("\033[%i%p1%d;%p2%dr", | |
823 ESC_STR "[%i%p1%d;%p2%dr")}, | |
824 # else | |
825 {(int)KS_CS, IF_EB("\033[%i%d;%dr", ESC_STR "[%i%d;%dr")}, | |
826 # endif | |
827 {(int)KS_CL, IF_EB("\033[H\033[2J", ESC_STR "[H" ESC_STR_nc "[2J")}, | |
828 {(int)KS_CD, IF_EB("\033[J", ESC_STR "[J")}, | |
829 {(int)KS_ME, IF_EB("\033[m", ESC_STR "[m")}, | |
830 {(int)KS_MR, IF_EB("\033[7m", ESC_STR "[7m")}, | |
831 {(int)KS_MD, IF_EB("\033[1m", ESC_STR "[1m")}, | |
832 {(int)KS_UE, IF_EB("\033[m", ESC_STR "[m")}, | |
833 {(int)KS_US, IF_EB("\033[4m", ESC_STR "[4m")}, | |
834 {(int)KS_MS, "y"}, | |
835 {(int)KS_UT, "y"}, | |
836 {(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
|
837 {(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
|
838 {(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
|
839 {(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
|
840 {(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
|
841 # ifdef TERMINFO |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
842 {(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
|
843 # else |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
844 {(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
|
845 # endif |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
846 {(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
|
847 {(int)KS_CRS, IF_EB("\033P$q q\033\\", ESC_STR "P$q q" ESC_STR "\\")}, |
7 | 848 # ifdef TERMINFO |
849 {(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", | |
850 ESC_STR "[%i%p1%d;%p2%dH")}, | |
851 # else | |
852 {(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")}, | |
853 # endif | |
854 {(int)KS_SR, IF_EB("\033M", ESC_STR "M")}, | |
855 # ifdef TERMINFO | |
856 {(int)KS_CRI, IF_EB("\033[%p1%dC", ESC_STR "[%p1%dC")}, | |
857 # else | |
858 {(int)KS_CRI, IF_EB("\033[%dC", ESC_STR "[%dC")}, | |
859 # endif | |
860 {(int)KS_KS, IF_EB("\033[?1h\033=", ESC_STR "[?1h" ESC_STR_nc "=")}, | |
861 {(int)KS_KE, IF_EB("\033[?1l\033>", ESC_STR "[?1l" ESC_STR_nc ">")}, | |
862 # ifdef FEAT_XTERM_SAVE | |
863 {(int)KS_TI, IF_EB("\0337\033[?47h", ESC_STR "7" ESC_STR_nc "[?47h")}, | |
864 {(int)KS_TE, IF_EB("\033[2J\033[?47l\0338", | |
865 ESC_STR "[2J" ESC_STR_nc "[?47l" ESC_STR_nc "8")}, | |
866 # endif | |
867 {(int)KS_CIS, IF_EB("\033]1;", ESC_STR "]1;")}, | |
868 {(int)KS_CIE, "\007"}, | |
869 {(int)KS_TS, IF_EB("\033]2;", ESC_STR "]2;")}, | |
870 {(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
|
871 {(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
|
872 {(int)KS_CEC, "\007"}, |
7 | 873 # ifdef TERMINFO |
874 {(int)KS_CWS, IF_EB("\033[8;%p1%d;%p2%dt", | |
875 ESC_STR "[8;%p1%d;%p2%dt")}, | |
876 {(int)KS_CWP, IF_EB("\033[3;%p1%d;%p2%dt", | |
877 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
|
878 {(int)KS_CGP, IF_EB("\033[13t", ESC_STR "[13t")}, |
7 | 879 # else |
880 {(int)KS_CWS, IF_EB("\033[8;%d;%dt", ESC_STR "[8;%d;%dt")}, | |
881 {(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
|
882 {(int)KS_CGP, IF_EB("\033[13t", ESC_STR "[13t")}, |
7 | 883 # endif |
884 {(int)KS_CRV, IF_EB("\033[>c", ESC_STR "[>c")}, | |
6874 | 885 {(int)KS_RBG, IF_EB("\033]11;?\007", ESC_STR "]11;?\007")}, |
4215 | 886 {(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
|
887 # ifdef FEAT_TERMGUICOLORS |
8985
42eb58c9da92
commit https://github.com/vim/vim/commit/b2fa54a84078e2b8dc3c7c7bfbccf6b75c0788d0
Christian Brabandt <cb@256bit.org>
parents:
8981
diff
changeset
|
888 /* These are printf strings, not terminal codes. */ |
42eb58c9da92
commit https://github.com/vim/vim/commit/b2fa54a84078e2b8dc3c7c7bfbccf6b75c0788d0
Christian Brabandt <cb@256bit.org>
parents:
8981
diff
changeset
|
889 {(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
|
890 {(int)KS_8B, IF_EB("\033[48;2;%lu;%lu;%lum", ESC_STR "[48;2;%lu;%lu;%lum")}, |
42eb58c9da92
commit https://github.com/vim/vim/commit/b2fa54a84078e2b8dc3c7c7bfbccf6b75c0788d0
Christian Brabandt <cb@256bit.org>
parents:
8981
diff
changeset
|
891 # endif |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
892 {(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
|
893 {(int)KS_CBD, IF_EB("\033[?2004l", ESC_STR "[?2004l")}, |
180 | 894 |
895 {K_UP, IF_EB("\033O*A", ESC_STR "O*A")}, | |
896 {K_DOWN, IF_EB("\033O*B", ESC_STR "O*B")}, | |
897 {K_RIGHT, IF_EB("\033O*C", ESC_STR "O*C")}, | |
898 {K_LEFT, IF_EB("\033O*D", ESC_STR "O*D")}, | |
899 /* An extra set of cursor keys for vt100 mode */ | |
900 {K_XUP, IF_EB("\033[1;*A", ESC_STR "[1;*A")}, | |
901 {K_XDOWN, IF_EB("\033[1;*B", ESC_STR "[1;*B")}, | |
902 {K_XRIGHT, IF_EB("\033[1;*C", ESC_STR "[1;*C")}, | |
903 {K_XLEFT, IF_EB("\033[1;*D", ESC_STR "[1;*D")}, | |
7 | 904 /* An extra set of function keys for vt100 mode */ |
180 | 905 {K_XF1, IF_EB("\033O*P", ESC_STR "O*P")}, |
906 {K_XF2, IF_EB("\033O*Q", ESC_STR "O*Q")}, | |
907 {K_XF3, IF_EB("\033O*R", ESC_STR "O*R")}, | |
908 {K_XF4, IF_EB("\033O*S", ESC_STR "O*S")}, | |
179 | 909 {K_F1, IF_EB("\033[11;*~", ESC_STR "[11;*~")}, |
910 {K_F2, IF_EB("\033[12;*~", ESC_STR "[12;*~")}, | |
911 {K_F3, IF_EB("\033[13;*~", ESC_STR "[13;*~")}, | |
912 {K_F4, IF_EB("\033[14;*~", ESC_STR "[14;*~")}, | |
913 {K_F5, IF_EB("\033[15;*~", ESC_STR "[15;*~")}, | |
914 {K_F6, IF_EB("\033[17;*~", ESC_STR "[17;*~")}, | |
915 {K_F7, IF_EB("\033[18;*~", ESC_STR "[18;*~")}, | |
916 {K_F8, IF_EB("\033[19;*~", ESC_STR "[19;*~")}, | |
917 {K_F9, IF_EB("\033[20;*~", ESC_STR "[20;*~")}, | |
918 {K_F10, IF_EB("\033[21;*~", ESC_STR "[21;*~")}, | |
919 {K_F11, IF_EB("\033[23;*~", ESC_STR "[23;*~")}, | |
920 {K_F12, IF_EB("\033[24;*~", ESC_STR "[24;*~")}, | |
7 | 921 {K_S_TAB, IF_EB("\033[Z", ESC_STR "[Z")}, |
179 | 922 {K_HELP, IF_EB("\033[28;*~", ESC_STR "[28;*~")}, |
923 {K_UNDO, IF_EB("\033[26;*~", ESC_STR "[26;*~")}, | |
924 {K_INS, IF_EB("\033[2;*~", ESC_STR "[2;*~")}, | |
925 {K_HOME, IF_EB("\033[1;*H", ESC_STR "[1;*H")}, | |
180 | 926 /* {K_S_HOME, IF_EB("\033O2H", ESC_STR "O2H")}, */ |
927 /* {K_C_HOME, IF_EB("\033O5H", ESC_STR "O5H")}, */ | |
230 | 928 {K_KHOME, IF_EB("\033[1;*~", ESC_STR "[1;*~")}, |
180 | 929 {K_XHOME, IF_EB("\033O*H", ESC_STR "O*H")}, /* other Home */ |
230 | 930 {K_ZHOME, IF_EB("\033[7;*~", ESC_STR "[7;*~")}, /* other Home */ |
179 | 931 {K_END, IF_EB("\033[1;*F", ESC_STR "[1;*F")}, |
180 | 932 /* {K_S_END, IF_EB("\033O2F", ESC_STR "O2F")}, */ |
933 /* {K_C_END, IF_EB("\033O5F", ESC_STR "O5F")}, */ | |
179 | 934 {K_KEND, IF_EB("\033[4;*~", ESC_STR "[4;*~")}, |
180 | 935 {K_XEND, IF_EB("\033O*F", ESC_STR "O*F")}, /* other End */ |
230 | 936 {K_ZEND, IF_EB("\033[8;*~", ESC_STR "[8;*~")}, |
179 | 937 {K_PAGEUP, IF_EB("\033[5;*~", ESC_STR "[5;*~")}, |
938 {K_PAGEDOWN, IF_EB("\033[6;*~", ESC_STR "[6;*~")}, | |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
939 {K_KPLUS, IF_EB("\033O*k", ESC_STR "O*k")}, /* keypad plus */ |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
940 {K_KMINUS, IF_EB("\033O*m", ESC_STR "O*m")}, /* keypad minus */ |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
941 {K_KDIVIDE, IF_EB("\033O*o", ESC_STR "O*o")}, /* keypad / */ |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
942 {K_KMULTIPLY, IF_EB("\033O*j", ESC_STR "O*j")}, /* keypad * */ |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
943 {K_KENTER, IF_EB("\033O*M", ESC_STR "O*M")}, /* keypad Enter */ |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
944 {K_KPOINT, IF_EB("\033O*n", ESC_STR "O*n")}, /* keypad . */ |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
945 {K_KDEL, IF_EB("\033[3;*~", ESC_STR "[3;*~")}, /* keypad Del */ |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
946 {K_PS, IF_EB("\033[200~", ESC_STR "[200~")}, /* paste start */ |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
947 {K_PE, IF_EB("\033[201~", ESC_STR "[201~")}, /* paste end */ |
7 | 948 |
949 {BT_EXTRA_KEYS, ""}, | |
179 | 950 {TERMCAP2KEY('k', '0'), IF_EB("\033[10;*~", ESC_STR "[10;*~")}, /* F0 */ |
951 {TERMCAP2KEY('F', '3'), IF_EB("\033[25;*~", ESC_STR "[25;*~")}, /* F13 */ | |
952 /* F14 and F15 are missing, because they send the same codes as the undo | |
953 * and help key, although they don't work on all keyboards. */ | |
954 {TERMCAP2KEY('F', '6'), IF_EB("\033[29;*~", ESC_STR "[29;*~")}, /* F16 */ | |
955 {TERMCAP2KEY('F', '7'), IF_EB("\033[31;*~", ESC_STR "[31;*~")}, /* F17 */ | |
956 {TERMCAP2KEY('F', '8'), IF_EB("\033[32;*~", ESC_STR "[32;*~")}, /* F18 */ | |
957 {TERMCAP2KEY('F', '9'), IF_EB("\033[33;*~", ESC_STR "[33;*~")}, /* F19 */ | |
958 {TERMCAP2KEY('F', 'A'), IF_EB("\033[34;*~", ESC_STR "[34;*~")}, /* F20 */ | |
959 | |
960 {TERMCAP2KEY('F', 'B'), IF_EB("\033[42;*~", ESC_STR "[42;*~")}, /* F21 */ | |
961 {TERMCAP2KEY('F', 'C'), IF_EB("\033[43;*~", ESC_STR "[43;*~")}, /* F22 */ | |
962 {TERMCAP2KEY('F', 'D'), IF_EB("\033[44;*~", ESC_STR "[44;*~")}, /* F23 */ | |
963 {TERMCAP2KEY('F', 'E'), IF_EB("\033[45;*~", ESC_STR "[45;*~")}, /* F24 */ | |
964 {TERMCAP2KEY('F', 'F'), IF_EB("\033[46;*~", ESC_STR "[46;*~")}, /* F25 */ | |
965 {TERMCAP2KEY('F', 'G'), IF_EB("\033[47;*~", ESC_STR "[47;*~")}, /* F26 */ | |
966 {TERMCAP2KEY('F', 'H'), IF_EB("\033[48;*~", ESC_STR "[48;*~")}, /* F27 */ | |
967 {TERMCAP2KEY('F', 'I'), IF_EB("\033[49;*~", ESC_STR "[49;*~")}, /* F28 */ | |
968 {TERMCAP2KEY('F', 'J'), IF_EB("\033[50;*~", ESC_STR "[50;*~")}, /* F29 */ | |
969 {TERMCAP2KEY('F', 'K'), IF_EB("\033[51;*~", ESC_STR "[51;*~")}, /* F30 */ | |
970 | |
971 {TERMCAP2KEY('F', 'L'), IF_EB("\033[52;*~", ESC_STR "[52;*~")}, /* F31 */ | |
972 {TERMCAP2KEY('F', 'M'), IF_EB("\033[53;*~", ESC_STR "[53;*~")}, /* F32 */ | |
973 {TERMCAP2KEY('F', 'N'), IF_EB("\033[54;*~", ESC_STR "[54;*~")}, /* F33 */ | |
974 {TERMCAP2KEY('F', 'O'), IF_EB("\033[55;*~", ESC_STR "[55;*~")}, /* F34 */ | |
975 {TERMCAP2KEY('F', 'P'), IF_EB("\033[56;*~", ESC_STR "[56;*~")}, /* F35 */ | |
976 {TERMCAP2KEY('F', 'Q'), IF_EB("\033[57;*~", ESC_STR "[57;*~")}, /* F36 */ | |
977 {TERMCAP2KEY('F', 'R'), IF_EB("\033[58;*~", ESC_STR "[58;*~")}, /* F37 */ | |
7 | 978 # endif |
979 | |
980 # if defined(UNIX) || defined(ALL_BUILTIN_TCAPS) | |
981 /* | |
982 * iris-ansi for Silicon Graphics machines. | |
983 */ | |
984 {(int)KS_NAME, "iris-ansi"}, | |
985 {(int)KS_CE, "\033[K"}, | |
986 {(int)KS_CD, "\033[J"}, | |
987 {(int)KS_AL, "\033[L"}, | |
988 # ifdef TERMINFO | |
989 {(int)KS_CAL, "\033[%p1%dL"}, | |
990 # else | |
991 {(int)KS_CAL, "\033[%dL"}, | |
992 # endif | |
993 {(int)KS_DL, "\033[M"}, | |
994 # ifdef TERMINFO | |
995 {(int)KS_CDL, "\033[%p1%dM"}, | |
996 # else | |
997 {(int)KS_CDL, "\033[%dM"}, | |
998 # endif | |
999 #if 0 /* The scroll region is not working as Vim expects. */ | |
1000 # ifdef TERMINFO | |
1001 {(int)KS_CS, "\033[%i%p1%d;%p2%dr"}, | |
1002 # else | |
1003 {(int)KS_CS, "\033[%i%d;%dr"}, | |
1004 # endif | |
1005 #endif | |
1006 {(int)KS_CL, "\033[H\033[2J"}, | |
1007 {(int)KS_VE, "\033[9/y\033[12/y"}, /* These aren't documented */ | |
1008 {(int)KS_VS, "\033[10/y\033[=1h\033[=2l"}, /* These aren't documented */ | |
1009 {(int)KS_TI, "\033[=6h"}, | |
1010 {(int)KS_TE, "\033[=6l"}, | |
1011 {(int)KS_SE, "\033[21;27m"}, | |
1012 {(int)KS_SO, "\033[1;7m"}, | |
1013 {(int)KS_ME, "\033[m"}, | |
1014 {(int)KS_MR, "\033[7m"}, | |
1015 {(int)KS_MD, "\033[1m"}, | |
1016 {(int)KS_CCO, "8"}, /* allow 8 colors */ | |
1017 {(int)KS_CZH, "\033[3m"}, /* italic mode on */ | |
1018 {(int)KS_CZR, "\033[23m"}, /* italic mode off */ | |
1019 {(int)KS_US, "\033[4m"}, /* underline on */ | |
1020 {(int)KS_UE, "\033[24m"}, /* underline off */ | |
1021 # ifdef TERMINFO | |
1022 {(int)KS_CAB, "\033[4%p1%dm"}, /* set background color (ANSI) */ | |
1023 {(int)KS_CAF, "\033[3%p1%dm"}, /* set foreground color (ANSI) */ | |
1024 {(int)KS_CSB, "\033[102;%p1%dm"}, /* set screen background color */ | |
1025 {(int)KS_CSF, "\033[101;%p1%dm"}, /* set screen foreground color */ | |
1026 # else | |
1027 {(int)KS_CAB, "\033[4%dm"}, /* set background color (ANSI) */ | |
1028 {(int)KS_CAF, "\033[3%dm"}, /* set foreground color (ANSI) */ | |
1029 {(int)KS_CSB, "\033[102;%dm"}, /* set screen background color */ | |
1030 {(int)KS_CSF, "\033[101;%dm"}, /* set screen foreground color */ | |
1031 # endif | |
1032 {(int)KS_MS, "y"}, /* guessed */ | |
1033 {(int)KS_UT, "y"}, /* guessed */ | |
1034 {(int)KS_LE, "\b"}, | |
1035 # ifdef TERMINFO | |
1036 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
1037 # else | |
1038 {(int)KS_CM, "\033[%i%d;%dH"}, | |
1039 # endif | |
1040 {(int)KS_SR, "\033M"}, | |
1041 # ifdef TERMINFO | |
1042 {(int)KS_CRI, "\033[%p1%dC"}, | |
1043 # else | |
1044 {(int)KS_CRI, "\033[%dC"}, | |
1045 # endif | |
1046 {(int)KS_CIS, "\033P3.y"}, | |
1047 {(int)KS_CIE, "\234"}, /* ST "String Terminator" */ | |
1048 {(int)KS_TS, "\033P1.y"}, | |
1049 {(int)KS_FS, "\234"}, /* ST "String Terminator" */ | |
1050 # ifdef TERMINFO | |
1051 {(int)KS_CWS, "\033[203;%p1%d;%p2%d/y"}, | |
1052 {(int)KS_CWP, "\033[205;%p1%d;%p2%d/y"}, | |
1053 # else | |
1054 {(int)KS_CWS, "\033[203;%d;%d/y"}, | |
1055 {(int)KS_CWP, "\033[205;%d;%d/y"}, | |
1056 # endif | |
1057 {K_UP, "\033[A"}, | |
1058 {K_DOWN, "\033[B"}, | |
1059 {K_LEFT, "\033[D"}, | |
1060 {K_RIGHT, "\033[C"}, | |
1061 {K_S_UP, "\033[161q"}, | |
1062 {K_S_DOWN, "\033[164q"}, | |
1063 {K_S_LEFT, "\033[158q"}, | |
1064 {K_S_RIGHT, "\033[167q"}, | |
1065 {K_F1, "\033[001q"}, | |
1066 {K_F2, "\033[002q"}, | |
1067 {K_F3, "\033[003q"}, | |
1068 {K_F4, "\033[004q"}, | |
1069 {K_F5, "\033[005q"}, | |
1070 {K_F6, "\033[006q"}, | |
1071 {K_F7, "\033[007q"}, | |
1072 {K_F8, "\033[008q"}, | |
1073 {K_F9, "\033[009q"}, | |
1074 {K_F10, "\033[010q"}, | |
1075 {K_F11, "\033[011q"}, | |
1076 {K_F12, "\033[012q"}, | |
1077 {K_S_F1, "\033[013q"}, | |
1078 {K_S_F2, "\033[014q"}, | |
1079 {K_S_F3, "\033[015q"}, | |
1080 {K_S_F4, "\033[016q"}, | |
1081 {K_S_F5, "\033[017q"}, | |
1082 {K_S_F6, "\033[018q"}, | |
1083 {K_S_F7, "\033[019q"}, | |
1084 {K_S_F8, "\033[020q"}, | |
1085 {K_S_F9, "\033[021q"}, | |
1086 {K_S_F10, "\033[022q"}, | |
1087 {K_S_F11, "\033[023q"}, | |
1088 {K_S_F12, "\033[024q"}, | |
1089 {K_INS, "\033[139q"}, | |
1090 {K_HOME, "\033[H"}, | |
1091 {K_END, "\033[146q"}, | |
1092 {K_PAGEUP, "\033[150q"}, | |
1093 {K_PAGEDOWN, "\033[154q"}, | |
1094 # endif | |
1095 | |
1096 # if defined(DEBUG) || defined(ALL_BUILTIN_TCAPS) | |
1097 /* | |
1098 * for debugging | |
1099 */ | |
1100 {(int)KS_NAME, "debug"}, | |
1101 {(int)KS_CE, "[CE]"}, | |
1102 {(int)KS_CD, "[CD]"}, | |
1103 {(int)KS_AL, "[AL]"}, | |
1104 # ifdef TERMINFO | |
1105 {(int)KS_CAL, "[CAL%p1%d]"}, | |
1106 # else | |
1107 {(int)KS_CAL, "[CAL%d]"}, | |
1108 # endif | |
1109 {(int)KS_DL, "[DL]"}, | |
1110 # ifdef TERMINFO | |
1111 {(int)KS_CDL, "[CDL%p1%d]"}, | |
1112 # else | |
1113 {(int)KS_CDL, "[CDL%d]"}, | |
1114 # endif | |
1115 # ifdef TERMINFO | |
1116 {(int)KS_CS, "[%p1%dCS%p2%d]"}, | |
1117 # else | |
1118 {(int)KS_CS, "[%dCS%d]"}, | |
1119 # endif | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
1120 # ifdef FEAT_WINDOWS |
7 | 1121 # ifdef TERMINFO |
1122 {(int)KS_CSV, "[%p1%dCSV%p2%d]"}, | |
1123 # else | |
1124 {(int)KS_CSV, "[%dCSV%d]"}, | |
1125 # endif | |
1126 # endif | |
1127 # ifdef TERMINFO | |
1128 {(int)KS_CAB, "[CAB%p1%d]"}, | |
1129 {(int)KS_CAF, "[CAF%p1%d]"}, | |
1130 {(int)KS_CSB, "[CSB%p1%d]"}, | |
1131 {(int)KS_CSF, "[CSF%p1%d]"}, | |
1132 # else | |
1133 {(int)KS_CAB, "[CAB%d]"}, | |
1134 {(int)KS_CAF, "[CAF%d]"}, | |
1135 {(int)KS_CSB, "[CSB%d]"}, | |
1136 {(int)KS_CSF, "[CSF%d]"}, | |
1137 # endif | |
1138 {(int)KS_OP, "[OP]"}, | |
1139 {(int)KS_LE, "[LE]"}, | |
1140 {(int)KS_CL, "[CL]"}, | |
1141 {(int)KS_VI, "[VI]"}, | |
1142 {(int)KS_VE, "[VE]"}, | |
1143 {(int)KS_VS, "[VS]"}, | |
1144 {(int)KS_ME, "[ME]"}, | |
1145 {(int)KS_MR, "[MR]"}, | |
1146 {(int)KS_MB, "[MB]"}, | |
1147 {(int)KS_MD, "[MD]"}, | |
1148 {(int)KS_SE, "[SE]"}, | |
1149 {(int)KS_SO, "[SO]"}, | |
1150 {(int)KS_UE, "[UE]"}, | |
1151 {(int)KS_US, "[US]"}, | |
205 | 1152 {(int)KS_UCE, "[UCE]"}, |
1153 {(int)KS_UCS, "[UCS]"}, | |
7 | 1154 {(int)KS_MS, "[MS]"}, |
1155 {(int)KS_UT, "[UT]"}, | |
6602 | 1156 {(int)KS_XN, "[XN]"}, |
7 | 1157 # ifdef TERMINFO |
1158 {(int)KS_CM, "[%p1%dCM%p2%d]"}, | |
1159 # else | |
1160 {(int)KS_CM, "[%dCM%d]"}, | |
1161 # endif | |
1162 {(int)KS_SR, "[SR]"}, | |
1163 # ifdef TERMINFO | |
1164 {(int)KS_CRI, "[CRI%p1%d]"}, | |
1165 # else | |
1166 {(int)KS_CRI, "[CRI%d]"}, | |
1167 # endif | |
1168 {(int)KS_VB, "[VB]"}, | |
1169 {(int)KS_KS, "[KS]"}, | |
1170 {(int)KS_KE, "[KE]"}, | |
1171 {(int)KS_TI, "[TI]"}, | |
1172 {(int)KS_TE, "[TE]"}, | |
1173 {(int)KS_CIS, "[CIS]"}, | |
1174 {(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
|
1175 {(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
|
1176 {(int)KS_CEC, "[CEC]"}, |
7 | 1177 {(int)KS_TS, "[TS]"}, |
1178 {(int)KS_FS, "[FS]"}, | |
1179 # ifdef TERMINFO | |
1180 {(int)KS_CWS, "[%p1%dCWS%p2%d]"}, | |
1181 {(int)KS_CWP, "[%p1%dCWP%p2%d]"}, | |
1182 # else | |
1183 {(int)KS_CWS, "[%dCWS%d]"}, | |
1184 {(int)KS_CWP, "[%dCWP%d]"}, | |
1185 # endif | |
1186 {(int)KS_CRV, "[CRV]"}, | |
4215 | 1187 {(int)KS_U7, "[U7]"}, |
6874 | 1188 {(int)KS_RBG, "[RBG]"}, |
7 | 1189 {K_UP, "[KU]"}, |
1190 {K_DOWN, "[KD]"}, | |
1191 {K_LEFT, "[KL]"}, | |
1192 {K_RIGHT, "[KR]"}, | |
180 | 1193 {K_XUP, "[xKU]"}, |
1194 {K_XDOWN, "[xKD]"}, | |
1195 {K_XLEFT, "[xKL]"}, | |
1196 {K_XRIGHT, "[xKR]"}, | |
7 | 1197 {K_S_UP, "[S-KU]"}, |
1198 {K_S_DOWN, "[S-KD]"}, | |
1199 {K_S_LEFT, "[S-KL]"}, | |
1200 {K_C_LEFT, "[C-KL]"}, | |
1201 {K_S_RIGHT, "[S-KR]"}, | |
1202 {K_C_RIGHT, "[C-KR]"}, | |
1203 {K_F1, "[F1]"}, | |
1204 {K_XF1, "[xF1]"}, | |
1205 {K_F2, "[F2]"}, | |
1206 {K_XF2, "[xF2]"}, | |
1207 {K_F3, "[F3]"}, | |
1208 {K_XF3, "[xF3]"}, | |
1209 {K_F4, "[F4]"}, | |
1210 {K_XF4, "[xF4]"}, | |
1211 {K_F5, "[F5]"}, | |
1212 {K_F6, "[F6]"}, | |
1213 {K_F7, "[F7]"}, | |
1214 {K_F8, "[F8]"}, | |
1215 {K_F9, "[F9]"}, | |
1216 {K_F10, "[F10]"}, | |
1217 {K_F11, "[F11]"}, | |
1218 {K_F12, "[F12]"}, | |
1219 {K_S_F1, "[S-F1]"}, | |
1220 {K_S_XF1, "[S-xF1]"}, | |
1221 {K_S_F2, "[S-F2]"}, | |
1222 {K_S_XF2, "[S-xF2]"}, | |
1223 {K_S_F3, "[S-F3]"}, | |
1224 {K_S_XF3, "[S-xF3]"}, | |
1225 {K_S_F4, "[S-F4]"}, | |
1226 {K_S_XF4, "[S-xF4]"}, | |
1227 {K_S_F5, "[S-F5]"}, | |
1228 {K_S_F6, "[S-F6]"}, | |
1229 {K_S_F7, "[S-F7]"}, | |
1230 {K_S_F8, "[S-F8]"}, | |
1231 {K_S_F9, "[S-F9]"}, | |
1232 {K_S_F10, "[S-F10]"}, | |
1233 {K_S_F11, "[S-F11]"}, | |
1234 {K_S_F12, "[S-F12]"}, | |
1235 {K_HELP, "[HELP]"}, | |
1236 {K_UNDO, "[UNDO]"}, | |
1237 {K_BS, "[BS]"}, | |
1238 {K_INS, "[INS]"}, | |
1239 {K_KINS, "[KINS]"}, | |
1240 {K_DEL, "[DEL]"}, | |
1241 {K_KDEL, "[KDEL]"}, | |
1242 {K_HOME, "[HOME]"}, | |
1243 {K_S_HOME, "[C-HOME]"}, | |
1244 {K_C_HOME, "[C-HOME]"}, | |
1245 {K_KHOME, "[KHOME]"}, | |
1246 {K_XHOME, "[XHOME]"}, | |
230 | 1247 {K_ZHOME, "[ZHOME]"}, |
7 | 1248 {K_END, "[END]"}, |
1249 {K_S_END, "[C-END]"}, | |
1250 {K_C_END, "[C-END]"}, | |
1251 {K_KEND, "[KEND]"}, | |
1252 {K_XEND, "[XEND]"}, | |
230 | 1253 {K_ZEND, "[ZEND]"}, |
7 | 1254 {K_PAGEUP, "[PAGEUP]"}, |
1255 {K_PAGEDOWN, "[PAGEDOWN]"}, | |
1256 {K_KPAGEUP, "[KPAGEUP]"}, | |
1257 {K_KPAGEDOWN, "[KPAGEDOWN]"}, | |
1258 {K_MOUSE, "[MOUSE]"}, | |
1259 {K_KPLUS, "[KPLUS]"}, | |
1260 {K_KMINUS, "[KMINUS]"}, | |
1261 {K_KDIVIDE, "[KDIVIDE]"}, | |
1262 {K_KMULTIPLY, "[KMULTIPLY]"}, | |
1263 {K_KENTER, "[KENTER]"}, | |
1264 {K_KPOINT, "[KPOINT]"}, | |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
1265 {K_PS, "[PASTE-START]"}, |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
1266 {K_PE, "[PASTE-END]"}, |
7 | 1267 {K_K0, "[K0]"}, |
1268 {K_K1, "[K1]"}, | |
1269 {K_K2, "[K2]"}, | |
1270 {K_K3, "[K3]"}, | |
1271 {K_K4, "[K4]"}, | |
1272 {K_K5, "[K5]"}, | |
1273 {K_K6, "[K6]"}, | |
1274 {K_K7, "[K7]"}, | |
1275 {K_K8, "[K8]"}, | |
1276 {K_K9, "[K9]"}, | |
1277 # endif | |
1278 | |
1279 #endif /* NO_BUILTIN_TCAPS */ | |
1280 | |
1281 /* | |
1282 * The most minimal terminal: only clear screen and cursor positioning | |
1283 * Always included. | |
1284 */ | |
1285 {(int)KS_NAME, "dumb"}, | |
1286 {(int)KS_CL, "\014"}, | |
1287 #ifdef TERMINFO | |
1288 {(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", | |
1289 ESC_STR "[%i%p1%d;%p2%dH")}, | |
1290 #else | |
1291 {(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")}, | |
1292 #endif | |
1293 | |
1294 /* | |
1295 * end marker | |
1296 */ | |
1297 {(int)KS_NAME, NULL} | |
1298 | |
1299 }; /* end of builtin_termcaps */ | |
1300 | |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1301 #if defined(FEAT_TERMGUICOLORS) || defined(PROTO) |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1302 guicolor_T |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1303 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
|
1304 { |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
1305 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
|
1306 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1307 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1308 guicolor_T |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1309 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
|
1310 { |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1311 guicolor_T t; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1312 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1313 if (*name == NUL) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1314 return INVALCOLOR; |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1315 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
|
1316 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1317 if (t == INVALCOLOR) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1318 EMSG2(_("E254: Cannot allocate color %s"), name); |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1319 return t; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1320 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1321 |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
1322 guicolor_T |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1323 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
|
1324 { |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
1325 return color; |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1326 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1327 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1328 |
7 | 1329 /* |
1330 * DEFAULT_TERM is used, when no terminal is specified with -T option or $TERM. | |
1331 */ | |
1332 #ifdef AMIGA | |
1333 # define DEFAULT_TERM (char_u *)"amiga" | |
1334 #endif | |
1335 | |
1336 #ifdef MSWIN | |
1337 # define DEFAULT_TERM (char_u *)"win32" | |
1338 #endif | |
1339 | |
1340 #if defined(UNIX) && !defined(__MINT__) | |
1341 # define DEFAULT_TERM (char_u *)"ansi" | |
1342 #endif | |
1343 | |
1344 #ifdef __MINT__ | |
1345 # define DEFAULT_TERM (char_u *)"vt52" | |
1346 #endif | |
1347 | |
1348 #ifdef VMS | |
1349 # define DEFAULT_TERM (char_u *)"vt320" | |
1350 #endif | |
1351 | |
1352 #ifdef __BEOS__ | |
1353 # undef DEFAULT_TERM | |
1354 # define DEFAULT_TERM (char_u *)"beos-ansi" | |
1355 #endif | |
1356 | |
1357 #ifndef DEFAULT_TERM | |
1358 # define DEFAULT_TERM (char_u *)"dumb" | |
1359 #endif | |
1360 | |
1361 /* | |
1362 * Term_strings contains currently used terminal output strings. | |
1363 * It is initialized with the default values by parse_builtin_tcap(). | |
1364 * The values can be changed by setting the option with the same name. | |
1365 */ | |
1366 char_u *(term_strings[(int)KS_LAST + 1]); | |
1367 | |
1221 | 1368 static int need_gather = FALSE; /* need to fill termleader[] */ |
1369 static char_u termleader[256 + 1]; /* for check_termcode() */ | |
7 | 1370 #ifdef FEAT_TERMRESPONSE |
1221 | 1371 static int check_for_codes = FALSE; /* check for key code response */ |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
1372 static int is_not_xterm = FALSE; /* recognized not-really-xterm */ |
7 | 1373 #endif |
1374 | |
1375 static struct builtin_term * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1376 find_builtin_term(char_u *term) |
7 | 1377 { |
1378 struct builtin_term *p; | |
1379 | |
1380 p = builtin_termcaps; | |
1381 while (p->bt_string != NULL) | |
1382 { | |
1383 if (p->bt_entry == (int)KS_NAME) | |
1384 { | |
1385 #ifdef UNIX | |
1386 if (STRCMP(p->bt_string, "iris-ansi") == 0 && vim_is_iris(term)) | |
1387 return p; | |
1388 else if (STRCMP(p->bt_string, "xterm") == 0 && vim_is_xterm(term)) | |
1389 return p; | |
1390 else | |
1391 #endif | |
1392 #ifdef VMS | |
1393 if (STRCMP(p->bt_string, "vt320") == 0 && vim_is_vt300(term)) | |
1394 return p; | |
1395 else | |
1396 #endif | |
1397 if (STRCMP(term, p->bt_string) == 0) | |
1398 return p; | |
1399 } | |
1400 ++p; | |
1401 } | |
1402 return p; | |
1403 } | |
1404 | |
1405 /* | |
1406 * Parsing of the builtin termcap entries. | |
1407 * Caller should check if 'name' is a valid builtin term. | |
1408 * The terminal's name is not set, as this is already done in termcapinit(). | |
1409 */ | |
1410 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1411 parse_builtin_tcap(char_u *term) |
7 | 1412 { |
1413 struct builtin_term *p; | |
1414 char_u name[2]; | |
1415 int term_8bit; | |
1416 | |
1417 p = find_builtin_term(term); | |
1418 term_8bit = term_is_8bit(term); | |
1419 | |
1420 /* Do not parse if builtin term not found */ | |
1421 if (p->bt_string == NULL) | |
1422 return; | |
1423 | |
1424 for (++p; p->bt_entry != (int)KS_NAME && p->bt_entry != BT_EXTRA_KEYS; ++p) | |
1425 { | |
1426 if ((int)p->bt_entry >= 0) /* KS_xx entry */ | |
1427 { | |
1428 /* Only set the value if it wasn't set yet. */ | |
1429 if (term_strings[p->bt_entry] == NULL | |
1430 || term_strings[p->bt_entry] == empty_option) | |
1431 { | |
1432 /* 8bit terminal: use CSI instead of <Esc>[ */ | |
1433 if (term_8bit && term_7to8bit((char_u *)p->bt_string) != 0) | |
1434 { | |
1435 char_u *s, *t; | |
1436 | |
1437 s = vim_strsave((char_u *)p->bt_string); | |
1438 if (s != NULL) | |
1439 { | |
1440 for (t = s; *t; ++t) | |
1441 if (term_7to8bit(t)) | |
1442 { | |
1443 *t = term_7to8bit(t); | |
1444 STRCPY(t + 1, t + 2); | |
1445 } | |
1446 term_strings[p->bt_entry] = s; | |
1447 set_term_option_alloced(&term_strings[p->bt_entry]); | |
1448 } | |
1449 } | |
1450 else | |
1451 term_strings[p->bt_entry] = (char_u *)p->bt_string; | |
1452 } | |
1453 } | |
1454 else | |
1455 { | |
1456 name[0] = KEY2TERMCAP0((int)p->bt_entry); | |
1457 name[1] = KEY2TERMCAP1((int)p->bt_entry); | |
1458 if (find_termcode(name) == NULL) | |
1459 add_termcode(name, (char_u *)p->bt_string, term_8bit); | |
1460 } | |
1461 } | |
1462 } | |
11739
5c69c6d9e2eb
patch 8.0.0752: build fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11731
diff
changeset
|
1463 |
7 | 1464 /* |
1465 * Set number of colors. | |
1466 * Store it as a number in t_colors. | |
1467 * Store it as a string in T_CCO (using nr_colors[]). | |
1468 */ | |
1469 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1470 set_color_count(int nr) |
7 | 1471 { |
1472 char_u nr_colors[20]; /* string for number of colors */ | |
1473 | |
1474 t_colors = nr; | |
1475 if (t_colors > 1) | |
1476 sprintf((char *)nr_colors, "%d", t_colors); | |
1477 else | |
1478 *nr_colors = NUL; | |
694 | 1479 set_string_option_direct((char_u *)"t_Co", -1, nr_colors, OPT_FREE, 0); |
7 | 1480 } |
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
|
1481 |
11739
5c69c6d9e2eb
patch 8.0.0752: build fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11731
diff
changeset
|
1482 #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
|
1483 /* |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1484 * 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
|
1485 */ |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1486 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
|
1487 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
|
1488 { |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1489 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
|
1490 { |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1491 /* Nr of colors changed, initialize highlighting and |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1492 * redraw everything. This causes a redraw, which usually |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1493 * clears the message. Try keeping the message if it |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1494 * might work. */ |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1495 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
|
1496 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
|
1497 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
|
1498 # 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
|
1499 { |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1500 char buf[100]; |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1501 int r = redraw_asap(CLEAR); |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1502 |
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
|
1503 sprintf(buf, "Received t_Co, redraw_asap(): %d", r); |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1504 log_tr(buf); |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1505 } |
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
|
1506 # else |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1507 redraw_asap(CLEAR); |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1508 # endif |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1509 } |
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
|
1510 } |
7 | 1511 #endif |
1512 | |
1513 #ifdef HAVE_TGETENT | |
1514 static char *(key_names[]) = | |
1515 { | |
1516 #ifdef FEAT_TERMRESPONSE | |
1517 /* Do this one first, it may cause a screen redraw. */ | |
1518 "Co", | |
1519 #endif | |
1520 "ku", "kd", "kr", "kl", | |
1521 "#2", "#4", "%i", "*7", | |
1522 "k1", "k2", "k3", "k4", "k5", "k6", | |
1523 "k7", "k8", "k9", "k;", "F1", "F2", | |
1524 "%1", "&8", "kb", "kI", "kD", "kh", | |
1525 "@7", "kP", "kN", "K1", "K3", "K4", "K5", "kB", | |
1526 NULL | |
1527 }; | |
1528 #endif | |
1529 | |
1530 /* | |
1531 * Set terminal options for terminal "term". | |
1532 * Return OK if terminal 'term' was found in a termcap, FAIL otherwise. | |
1533 * | |
1534 * While doing this, until ttest(), some options may be NULL, be careful. | |
1535 */ | |
1536 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1537 set_termname(char_u *term) |
7 | 1538 { |
1539 struct builtin_term *termp; | |
1540 #ifdef HAVE_TGETENT | |
1541 int builtin_first = p_tbi; | |
1542 int try; | |
1543 int termcap_cleared = FALSE; | |
1544 #endif | |
1545 int width = 0, height = 0; | |
1546 char_u *error_msg = NULL; | |
1547 char_u *bs_p, *del_p; | |
1548 | |
168 | 1549 /* In silect mode (ex -s) we don't use the 'term' option. */ |
1550 if (silent_mode) | |
1551 return OK; | |
1552 | |
7 | 1553 detected_8bit = FALSE; /* reset 8-bit detection */ |
1554 | |
1555 if (term_is_builtin(term)) | |
1556 { | |
1557 term += 8; | |
1558 #ifdef HAVE_TGETENT | |
1559 builtin_first = 1; | |
1560 #endif | |
1561 } | |
1562 | |
1563 /* | |
1564 * If HAVE_TGETENT is not defined, only the builtin termcap is used, otherwise: | |
1565 * If builtin_first is TRUE: | |
1566 * 0. try builtin termcap | |
1567 * 1. try external termcap | |
1568 * 2. if both fail default to a builtin terminal | |
1569 * If builtin_first is FALSE: | |
1570 * 1. try external termcap | |
1571 * 2. try builtin termcap, if both fail default to a builtin terminal | |
1572 */ | |
1573 #ifdef HAVE_TGETENT | |
1574 for (try = builtin_first ? 0 : 1; try < 3; ++try) | |
1575 { | |
1576 /* | |
1577 * Use external termcap | |
1578 */ | |
1579 if (try == 1) | |
1580 { | |
1581 char_u *p; | |
1582 static char_u tstrbuf[TBUFSZ]; | |
1583 int i; | |
1584 char_u tbuf[TBUFSZ]; | |
1585 char_u *tp; | |
1586 static struct { | |
1587 enum SpecialKey dest; /* index in term_strings[] */ | |
1588 char *name; /* termcap name for string */ | |
1589 } string_names[] = | |
1590 { {KS_CE, "ce"}, {KS_AL, "al"}, {KS_CAL,"AL"}, | |
1591 {KS_DL, "dl"}, {KS_CDL,"DL"}, {KS_CS, "cs"}, | |
1592 {KS_CL, "cl"}, {KS_CD, "cd"}, | |
1593 {KS_VI, "vi"}, {KS_VE, "ve"}, {KS_MB, "mb"}, | |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
1594 {KS_ME, "me"}, {KS_MR, "mr"}, |
7 | 1595 {KS_MD, "md"}, {KS_SE, "se"}, {KS_SO, "so"}, |
1596 {KS_CZH,"ZH"}, {KS_CZR,"ZR"}, {KS_UE, "ue"}, | |
205 | 1597 {KS_US, "us"}, {KS_UCE, "Ce"}, {KS_UCS, "Cs"}, |
1598 {KS_CM, "cm"}, {KS_SR, "sr"}, | |
7 | 1599 {KS_CRI,"RI"}, {KS_VB, "vb"}, {KS_KS, "ks"}, |
1600 {KS_KE, "ke"}, {KS_TI, "ti"}, {KS_TE, "te"}, | |
1601 {KS_BC, "bc"}, {KS_CSB,"Sb"}, {KS_CSF,"Sf"}, | |
1602 {KS_CAB,"AB"}, {KS_CAF,"AF"}, {KS_LE, "le"}, | |
1603 {KS_ND, "nd"}, {KS_OP, "op"}, {KS_CRV, "RV"}, | |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
1604 {KS_VS, "vs"}, {KS_CVS, "VS"}, |
7 | 1605 {KS_CIS, "IS"}, {KS_CIE, "IE"}, |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
1606 {KS_CSC, "SC"}, {KS_CEC, "EC"}, |
7 | 1607 {KS_TS, "ts"}, {KS_FS, "fs"}, |
1608 {KS_CWP, "WP"}, {KS_CWS, "WS"}, | |
36 | 1609 {KS_CSI, "SI"}, {KS_CEI, "EI"}, |
6882 | 1610 {KS_U7, "u7"}, {KS_RBG, "RB"}, |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1611 {KS_8F, "8f"}, {KS_8B, "8b"}, |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
1612 {KS_CBE, "BE"}, {KS_CBD, "BD"}, |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
1613 {KS_CPS, "PS"}, {KS_CPE, "PE"}, |
7 | 1614 {(enum SpecialKey)0, NULL} |
1615 }; | |
1616 | |
1617 /* | |
1618 * If the external termcap does not have a matching entry, try the | |
1619 * builtin ones. | |
1620 */ | |
1621 if ((error_msg = tgetent_error(tbuf, term)) == NULL) | |
1622 { | |
1623 tp = tstrbuf; | |
1624 if (!termcap_cleared) | |
1625 { | |
1626 clear_termoptions(); /* clear old options */ | |
1627 termcap_cleared = TRUE; | |
1628 } | |
1629 | |
1630 /* get output strings */ | |
1631 for (i = 0; string_names[i].name != NULL; ++i) | |
1632 { | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
10676
diff
changeset
|
1633 if (TERM_STR(string_names[i].dest) == NULL |
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
10676
diff
changeset
|
1634 || TERM_STR(string_names[i].dest) == empty_option) |
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
10676
diff
changeset
|
1635 TERM_STR(string_names[i].dest) = |
7 | 1636 TGETSTR(string_names[i].name, &tp); |
1637 } | |
1638 | |
1639 /* tgetflag() returns 1 if the flag is present, 0 if not and | |
1640 * possibly -1 if the flag doesn't exist. */ | |
1641 if ((T_MS == NULL || T_MS == empty_option) | |
1642 && tgetflag("ms") > 0) | |
1643 T_MS = (char_u *)"y"; | |
1644 if ((T_XS == NULL || T_XS == empty_option) | |
1645 && tgetflag("xs") > 0) | |
1646 T_XS = (char_u *)"y"; | |
6602 | 1647 if ((T_XN == NULL || T_XN == empty_option) |
1648 && tgetflag("xn") > 0) | |
1649 T_XN = (char_u *)"y"; | |
7 | 1650 if ((T_DB == NULL || T_DB == empty_option) |
1651 && tgetflag("db") > 0) | |
1652 T_DB = (char_u *)"y"; | |
1653 if ((T_DA == NULL || T_DA == empty_option) | |
1654 && tgetflag("da") > 0) | |
1655 T_DA = (char_u *)"y"; | |
1656 if ((T_UT == NULL || T_UT == empty_option) | |
1657 && tgetflag("ut") > 0) | |
1658 T_UT = (char_u *)"y"; | |
1659 | |
1660 | |
1661 /* | |
1662 * get key codes | |
1663 */ | |
1664 for (i = 0; key_names[i] != NULL; ++i) | |
1665 { | |
1666 if (find_termcode((char_u *)key_names[i]) == NULL) | |
1667 { | |
1668 p = TGETSTR(key_names[i], &tp); | |
1669 /* if cursor-left == backspace, ignore it (televideo | |
1670 * 925) */ | |
1671 if (p != NULL | |
1672 && (*p != Ctrl_H | |
1673 || key_names[i][0] != 'k' | |
1674 || key_names[i][1] != 'l')) | |
1675 add_termcode((char_u *)key_names[i], p, FALSE); | |
1676 } | |
1677 } | |
1678 | |
1679 if (height == 0) | |
1680 height = tgetnum("li"); | |
1681 if (width == 0) | |
1682 width = tgetnum("co"); | |
1683 | |
1684 /* | |
1685 * Get number of colors (if not done already). | |
1686 */ | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
10676
diff
changeset
|
1687 if (TERM_STR(KS_CCO) == NULL |
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
10676
diff
changeset
|
1688 || TERM_STR(KS_CCO) == empty_option) |
7 | 1689 set_color_count(tgetnum("Co")); |
1690 | |
1691 # ifndef hpux | |
1692 BC = (char *)TGETSTR("bc", &tp); | |
1693 UP = (char *)TGETSTR("up", &tp); | |
1694 p = TGETSTR("pc", &tp); | |
1695 if (p) | |
1696 PC = *p; | |
1697 # endif /* hpux */ | |
1698 } | |
1699 } | |
1700 else /* try == 0 || try == 2 */ | |
1701 #endif /* HAVE_TGETENT */ | |
1702 /* | |
1703 * Use builtin termcap | |
1704 */ | |
1705 { | |
1706 #ifdef HAVE_TGETENT | |
1707 /* | |
1708 * If builtin termcap was already used, there is no need to search | |
1709 * for the builtin termcap again, quit now. | |
1710 */ | |
1711 if (try == 2 && builtin_first && termcap_cleared) | |
1712 break; | |
1713 #endif | |
1714 /* | |
1715 * search for 'term' in builtin_termcaps[] | |
1716 */ | |
1717 termp = find_builtin_term(term); | |
1718 if (termp->bt_string == NULL) /* did not find it */ | |
1719 { | |
1720 #ifdef HAVE_TGETENT | |
1721 /* | |
1722 * If try == 0, first try the external termcap. If that is not | |
1723 * found we'll get back here with try == 2. | |
1724 * If termcap_cleared is set we used the external termcap, | |
1725 * don't complain about not finding the term in the builtin | |
1726 * termcap. | |
1727 */ | |
1728 if (try == 0) /* try external one */ | |
1729 continue; | |
1730 if (termcap_cleared) /* found in external termcap */ | |
1731 break; | |
1732 #endif | |
1733 | |
1734 mch_errmsg("\r\n"); | |
1735 if (error_msg != NULL) | |
1736 { | |
1737 mch_errmsg((char *)error_msg); | |
1738 mch_errmsg("\r\n"); | |
1739 } | |
1740 mch_errmsg("'"); | |
1741 mch_errmsg((char *)term); | |
1742 mch_errmsg(_("' not known. Available builtin terminals are:")); | |
1743 mch_errmsg("\r\n"); | |
1744 for (termp = &(builtin_termcaps[0]); termp->bt_string != NULL; | |
1745 ++termp) | |
1746 { | |
1747 if (termp->bt_entry == (int)KS_NAME) | |
1748 { | |
1749 #ifdef HAVE_TGETENT | |
1750 mch_errmsg(" builtin_"); | |
1751 #else | |
1752 mch_errmsg(" "); | |
1753 #endif | |
1754 mch_errmsg(termp->bt_string); | |
1755 mch_errmsg("\r\n"); | |
1756 } | |
1757 } | |
1758 /* when user typed :set term=xxx, quit here */ | |
1759 if (starting != NO_SCREEN) | |
1760 { | |
1761 screen_start(); /* don't know where cursor is now */ | |
1762 wait_return(TRUE); | |
1763 return FAIL; | |
1764 } | |
1765 term = DEFAULT_TERM; | |
1766 mch_errmsg(_("defaulting to '")); | |
1767 mch_errmsg((char *)term); | |
1768 mch_errmsg("'\r\n"); | |
1769 if (emsg_silent == 0) | |
1770 { | |
1771 screen_start(); /* don't know where cursor is now */ | |
1772 out_flush(); | |
11307
6e1c19d3de03
patch 8.0.0539: startup test fails on Mac
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1773 if (!is_not_a_term()) |
6e1c19d3de03
patch 8.0.0539: startup test fails on Mac
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1774 ui_delay(2000L, TRUE); |
7 | 1775 } |
694 | 1776 set_string_option_direct((char_u *)"term", -1, term, |
1777 OPT_FREE, 0); | |
7 | 1778 display_errors(); |
1779 } | |
1780 out_flush(); | |
1781 #ifdef HAVE_TGETENT | |
1782 if (!termcap_cleared) | |
1783 { | |
1784 #endif | |
1785 clear_termoptions(); /* clear old options */ | |
1786 #ifdef HAVE_TGETENT | |
1787 termcap_cleared = TRUE; | |
1788 } | |
1789 #endif | |
1790 parse_builtin_tcap(term); | |
1791 #ifdef FEAT_GUI | |
1792 if (term_is_gui(term)) | |
1793 { | |
1794 out_flush(); | |
1795 gui_init(); | |
1796 /* If starting the GUI failed, don't do any of the other | |
1797 * things for this terminal */ | |
1798 if (!gui.in_use) | |
1799 return FAIL; | |
1800 #ifdef HAVE_TGETENT | |
1801 break; /* don't try using external termcap */ | |
1802 #endif | |
1803 } | |
1804 #endif /* FEAT_GUI */ | |
1805 } | |
1806 #ifdef HAVE_TGETENT | |
1807 } | |
1808 #endif | |
1809 | |
1810 /* | |
1811 * special: There is no info in the termcap about whether the cursor | |
1812 * positioning is relative to the start of the screen or to the start of the | |
1813 * scrolling region. We just guess here. Only msdos pcterm is known to do it | |
1814 * relative. | |
1815 */ | |
1816 if (STRCMP(term, "pcterm") == 0) | |
1817 T_CCS = (char_u *)"yes"; | |
1818 else | |
1819 T_CCS = empty_option; | |
1820 | |
1821 #ifdef UNIX | |
1822 /* | |
1823 * Any "stty" settings override the default for t_kb from the termcap. | |
1824 * This is in os_unix.c, because it depends a lot on the version of unix that | |
1825 * is being used. | |
1826 * Don't do this when the GUI is active, it uses "t_kb" and "t_kD" directly. | |
1827 */ | |
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
|
1828 # ifdef FEAT_GUI |
7 | 1829 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
|
1830 # endif |
7 | 1831 get_stty(); |
1832 #endif | |
1833 | |
1834 /* | |
1835 * If the termcap has no entry for 'bs' and/or 'del' and the ioctl() also | |
1836 * didn't work, use the default CTRL-H | |
1837 * The default for t_kD is DEL, unless t_kb is DEL. | |
1838 * The vim_strsave'd strings are probably lost forever, well it's only two | |
1839 * bytes. Don't do this when the GUI is active, it uses "t_kb" and "t_kD" | |
1840 * directly. | |
1841 */ | |
1842 #ifdef FEAT_GUI | |
1843 if (!gui.in_use) | |
1844 #endif | |
1845 { | |
1846 bs_p = find_termcode((char_u *)"kb"); | |
1847 del_p = find_termcode((char_u *)"kD"); | |
1848 if (bs_p == NULL || *bs_p == NUL) | |
1849 add_termcode((char_u *)"kb", (bs_p = (char_u *)CTRL_H_STR), FALSE); | |
1850 if ((del_p == NULL || *del_p == NUL) && | |
1851 (bs_p == NULL || *bs_p != DEL)) | |
1852 add_termcode((char_u *)"kD", (char_u *)DEL_STR, FALSE); | |
1853 } | |
1854 | |
1855 #if defined(UNIX) || defined(VMS) | |
1856 term_is_xterm = vim_is_xterm(term); | |
1857 #endif | |
1858 | |
1859 #ifdef FEAT_MOUSE | |
1860 # if defined(UNIX) || defined(VMS) | |
1861 # ifdef FEAT_MOUSE_TTY | |
1862 /* | |
1863 * For Unix, set the 'ttymouse' option to the type of mouse to be used. | |
1864 * The termcode for the mouse is added as a side effect in option.c. | |
1865 */ | |
1866 { | |
11563
2547bbe6716e
patch 8.0.0664: mouse does not work in tmux
Christian Brabandt <cb@256bit.org>
parents:
11557
diff
changeset
|
1867 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
|
1868 |
7 | 1869 # ifdef FEAT_MOUSE_XTERM |
1623 | 1870 if (use_xterm_like_mouse(term)) |
7 | 1871 { |
1872 if (use_xterm_mouse()) | |
1873 p = NULL; /* keep existing value, might be "xterm2" */ | |
1874 else | |
1875 p = (char_u *)"xterm"; | |
1876 } | |
1877 # endif | |
1878 if (p != NULL) | |
3980 | 1879 { |
7 | 1880 set_option_value((char_u *)"ttym", 0L, p, 0); |
3980 | 1881 /* Reset the WAS_SET flag, 'ttymouse' can be set to "sgr" or |
1882 * "xterm2" in check_termcode(). */ | |
1883 reset_option_was_set((char_u *)"ttym"); | |
1884 } | |
7 | 1885 if (p == NULL |
1886 # ifdef FEAT_GUI | |
1887 || gui.in_use | |
1888 # endif | |
1889 ) | |
1890 check_mouse_termcode(); /* set mouse termcode anyway */ | |
1891 } | |
1892 # endif | |
1893 # else | |
1894 set_mouse_termcode(KS_MOUSE, (char_u *)"\233M"); | |
1895 # endif | |
1896 #endif /* FEAT_MOUSE */ | |
1897 | |
1898 #ifdef USE_TERM_CONSOLE | |
1899 /* DEFAULT_TERM indicates that it is the machine console. */ | |
1900 if (STRCMP(term, DEFAULT_TERM) != 0) | |
1901 term_console = FALSE; | |
1902 else | |
1903 { | |
1904 term_console = TRUE; | |
1905 # ifdef AMIGA | |
1906 win_resize_on(); /* enable window resizing reports */ | |
1907 # endif | |
1908 } | |
1909 #endif | |
1910 | |
1911 #if defined(UNIX) || defined(VMS) | |
1912 /* | |
1913 * 'ttyfast' is default on for xterm, iris-ansi and a few others. | |
1914 */ | |
1915 if (vim_is_fastterm(term)) | |
1916 p_tf = TRUE; | |
1917 #endif | |
1918 #ifdef USE_TERM_CONSOLE | |
1919 /* | |
1920 * 'ttyfast' is default on consoles | |
1921 */ | |
1922 if (term_console) | |
1923 p_tf = TRUE; | |
1924 #endif | |
1925 | |
1926 ttest(TRUE); /* make sure we have a valid set of terminal codes */ | |
1927 | |
1928 full_screen = TRUE; /* we can use termcap codes from now on */ | |
1929 set_term_defaults(); /* use current values as defaults */ | |
1930 #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
|
1931 LOG_TR("setting crv_status to STATUS_GET"); |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
1932 crv_status = STATUS_GET; /* Get terminal version later */ |
7 | 1933 #endif |
1934 | |
1935 /* | |
1936 * Initialize the terminal with the appropriate termcap codes. | |
1937 * Set the mouse and window title if possible. | |
1938 * Don't do this when starting, need to parse the .vimrc first, because it | |
1939 * may redefine t_TI etc. | |
1940 */ | |
1941 if (starting != NO_SCREEN) | |
1942 { | |
1943 starttermcap(); /* may change terminal mode */ | |
1944 #ifdef FEAT_MOUSE | |
1945 setmouse(); /* may start using the mouse */ | |
1946 #endif | |
1947 #ifdef FEAT_TITLE | |
1948 maketitle(); /* may display window title */ | |
1949 #endif | |
1950 } | |
1951 | |
1952 /* display initial screen after ttest() checking. jw. */ | |
1953 if (width <= 0 || height <= 0) | |
1954 { | |
1955 /* termcap failed to report size */ | |
1956 /* set defaults, in case ui_get_shellsize() also fails */ | |
1957 width = 80; | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
1958 #if defined(WIN3264) |
7 | 1959 height = 25; /* console is often 25 lines */ |
1960 #else | |
1961 height = 24; /* most terminals are 24 lines */ | |
1962 #endif | |
1963 } | |
1964 set_shellsize(width, height, FALSE); /* may change Rows */ | |
1965 if (starting != NO_SCREEN) | |
1966 { | |
1967 if (scroll_region) | |
1968 scroll_region_reset(); /* In case Rows changed */ | |
1969 check_map_keycodes(); /* check mappings for terminal codes used */ | |
1970 | |
1971 #ifdef FEAT_AUTOCMD | |
1972 { | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9125
diff
changeset
|
1973 bufref_T old_curbuf; |
7 | 1974 |
1975 /* | |
1976 * Execute the TermChanged autocommands for each buffer that is | |
1977 * loaded. | |
1978 */ | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9125
diff
changeset
|
1979 set_bufref(&old_curbuf, curbuf); |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9628
diff
changeset
|
1980 FOR_ALL_BUFFERS(curbuf) |
7 | 1981 { |
1982 if (curbuf->b_ml.ml_mfp != NULL) | |
1983 apply_autocmds(EVENT_TERMCHANGED, NULL, NULL, FALSE, | |
1984 curbuf); | |
1985 } | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9125
diff
changeset
|
1986 if (bufref_valid(&old_curbuf)) |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9125
diff
changeset
|
1987 curbuf = old_curbuf.br_buf; |
7 | 1988 } |
1989 #endif | |
1990 } | |
1991 | |
1992 #ifdef FEAT_TERMRESPONSE | |
1993 may_req_termresponse(); | |
1994 #endif | |
1995 | |
1996 return OK; | |
1997 } | |
1998 | |
1999 #if defined(FEAT_MOUSE) || defined(PROTO) | |
2000 | |
2001 # ifdef FEAT_MOUSE_TTY | |
2002 # define HMT_NORMAL 1 | |
2003 # define HMT_NETTERM 2 | |
2004 # define HMT_DEC 4 | |
2005 # define HMT_JSBTERM 8 | |
2006 # define HMT_PTERM 16 | |
3176 | 2007 # define HMT_URXVT 32 |
3746 | 2008 # define HMT_SGR 64 |
11563
2547bbe6716e
patch 8.0.0664: mouse does not work in tmux
Christian Brabandt <cb@256bit.org>
parents:
11557
diff
changeset
|
2009 # define HMT_SGR_REL 128 |
7 | 2010 static int has_mouse_termcode = 0; |
2011 # endif | |
2012 | |
1623 | 2013 # if (!defined(UNIX) || defined(FEAT_MOUSE_TTY)) || defined(PROTO) |
7 | 2014 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2015 set_mouse_termcode( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2016 int n, /* KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2017 char_u *s) |
7 | 2018 { |
2019 char_u name[2]; | |
2020 | |
2021 name[0] = n; | |
2022 name[1] = KE_FILLER; | |
2023 add_termcode(name, s, FALSE); | |
2024 # ifdef FEAT_MOUSE_TTY | |
2025 # ifdef FEAT_MOUSE_JSB | |
2026 if (n == KS_JSBTERM_MOUSE) | |
2027 has_mouse_termcode |= HMT_JSBTERM; | |
2028 else | |
2029 # endif | |
2030 # ifdef FEAT_MOUSE_NET | |
2031 if (n == KS_NETTERM_MOUSE) | |
2032 has_mouse_termcode |= HMT_NETTERM; | |
2033 else | |
2034 # endif | |
2035 # ifdef FEAT_MOUSE_DEC | |
2036 if (n == KS_DEC_MOUSE) | |
2037 has_mouse_termcode |= HMT_DEC; | |
2038 else | |
2039 # endif | |
2040 # ifdef FEAT_MOUSE_PTERM | |
2041 if (n == KS_PTERM_MOUSE) | |
2042 has_mouse_termcode |= HMT_PTERM; | |
2043 else | |
2044 # endif | |
3176 | 2045 # ifdef FEAT_MOUSE_URXVT |
2046 if (n == KS_URXVT_MOUSE) | |
2047 has_mouse_termcode |= HMT_URXVT; | |
2048 else | |
2049 # endif | |
3746 | 2050 # ifdef FEAT_MOUSE_SGR |
2051 if (n == KS_SGR_MOUSE) | |
2052 has_mouse_termcode |= HMT_SGR; | |
11563
2547bbe6716e
patch 8.0.0664: mouse does not work in tmux
Christian Brabandt <cb@256bit.org>
parents:
11557
diff
changeset
|
2053 else if (n == KS_SGR_MOUSE_RELEASE) |
2547bbe6716e
patch 8.0.0664: mouse does not work in tmux
Christian Brabandt <cb@256bit.org>
parents:
11557
diff
changeset
|
2054 has_mouse_termcode |= HMT_SGR_REL; |
3746 | 2055 else |
2056 # endif | |
7 | 2057 has_mouse_termcode |= HMT_NORMAL; |
2058 # endif | |
2059 } | |
2060 # endif | |
2061 | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7307
diff
changeset
|
2062 # if ((defined(UNIX) || defined(VMS)) \ |
1623 | 2063 && defined(FEAT_MOUSE_TTY)) || defined(PROTO) |
7 | 2064 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2065 del_mouse_termcode( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2066 int n) /* KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE */ |
7 | 2067 { |
2068 char_u name[2]; | |
2069 | |
2070 name[0] = n; | |
2071 name[1] = KE_FILLER; | |
2072 del_termcode(name); | |
2073 # ifdef FEAT_MOUSE_TTY | |
2074 # ifdef FEAT_MOUSE_JSB | |
2075 if (n == KS_JSBTERM_MOUSE) | |
2076 has_mouse_termcode &= ~HMT_JSBTERM; | |
2077 else | |
2078 # endif | |
2079 # ifdef FEAT_MOUSE_NET | |
2080 if (n == KS_NETTERM_MOUSE) | |
2081 has_mouse_termcode &= ~HMT_NETTERM; | |
2082 else | |
2083 # endif | |
2084 # ifdef FEAT_MOUSE_DEC | |
2085 if (n == KS_DEC_MOUSE) | |
2086 has_mouse_termcode &= ~HMT_DEC; | |
2087 else | |
2088 # endif | |
2089 # ifdef FEAT_MOUSE_PTERM | |
2090 if (n == KS_PTERM_MOUSE) | |
2091 has_mouse_termcode &= ~HMT_PTERM; | |
2092 else | |
2093 # endif | |
3176 | 2094 # ifdef FEAT_MOUSE_URXVT |
2095 if (n == KS_URXVT_MOUSE) | |
2096 has_mouse_termcode &= ~HMT_URXVT; | |
2097 else | |
2098 # endif | |
3746 | 2099 # ifdef FEAT_MOUSE_SGR |
2100 if (n == KS_SGR_MOUSE) | |
2101 has_mouse_termcode &= ~HMT_SGR; | |
11563
2547bbe6716e
patch 8.0.0664: mouse does not work in tmux
Christian Brabandt <cb@256bit.org>
parents:
11557
diff
changeset
|
2102 else if (n == KS_SGR_MOUSE_RELEASE) |
2547bbe6716e
patch 8.0.0664: mouse does not work in tmux
Christian Brabandt <cb@256bit.org>
parents:
11557
diff
changeset
|
2103 has_mouse_termcode &= ~HMT_SGR_REL; |
3746 | 2104 else |
2105 # endif | |
7 | 2106 has_mouse_termcode &= ~HMT_NORMAL; |
2107 # endif | |
2108 } | |
2109 # endif | |
2110 #endif | |
2111 | |
2112 #ifdef HAVE_TGETENT | |
2113 /* | |
2114 * Call tgetent() | |
2115 * Return error message if it fails, NULL if it's OK. | |
2116 */ | |
2117 static char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2118 tgetent_error(char_u *tbuf, char_u *term) |
7 | 2119 { |
2120 int i; | |
2121 | |
2122 i = TGETENT(tbuf, term); | |
2123 if (i < 0 /* -1 is always an error */ | |
2124 # ifdef TGETENT_ZERO_ERR | |
2125 || i == 0 /* sometimes zero is also an error */ | |
2126 # endif | |
2127 ) | |
2128 { | |
2129 /* On FreeBSD tputs() gets a SEGV after a tgetent() which fails. Call | |
2130 * tgetent() with the always existing "dumb" entry to avoid a crash or | |
2131 * hang. */ | |
2132 (void)TGETENT(tbuf, "dumb"); | |
2133 | |
2134 if (i < 0) | |
2135 # ifdef TGETENT_ZERO_ERR | |
2136 return (char_u *)_("E557: Cannot open termcap file"); | |
2137 if (i == 0) | |
2138 # endif | |
2139 #ifdef TERMINFO | |
2140 return (char_u *)_("E558: Terminal entry not found in terminfo"); | |
2141 #else | |
2142 return (char_u *)_("E559: Terminal entry not found in termcap"); | |
2143 #endif | |
2144 } | |
2145 return NULL; | |
2146 } | |
2147 | |
2148 /* | |
2149 * Some versions of tgetstr() have been reported to return -1 instead of NULL. | |
2150 * Fix that here. | |
2151 */ | |
2152 static char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2153 vim_tgetstr(char *s, char_u **pp) |
7 | 2154 { |
2155 char *p; | |
2156 | |
2157 p = tgetstr(s, (char **)pp); | |
2158 if (p == (char *)-1) | |
2159 p = NULL; | |
2160 return (char_u *)p; | |
2161 } | |
2162 #endif /* HAVE_TGETENT */ | |
2163 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
2164 #if defined(HAVE_TGETENT) && (defined(UNIX) || defined(VMS) || defined(MACOS_X)) |
7 | 2165 /* |
2166 * Get Columns and Rows from the termcap. Used after a window signal if the | |
2167 * ioctl() fails. It doesn't make sense to call tgetent each time if the "co" | |
2168 * and "li" entries never change. But on some systems this works. | |
2169 * Errors while getting the entries are ignored. | |
2170 */ | |
2171 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2172 getlinecol( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2173 long *cp, /* pointer to columns */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2174 long *rp) /* pointer to rows */ |
7 | 2175 { |
2176 char_u tbuf[TBUFSZ]; | |
2177 | |
2178 if (T_NAME != NULL && *T_NAME != NUL && tgetent_error(tbuf, T_NAME) == NULL) | |
2179 { | |
2180 if (*cp == 0) | |
2181 *cp = tgetnum("co"); | |
2182 if (*rp == 0) | |
2183 *rp = tgetnum("li"); | |
2184 } | |
2185 } | |
2186 #endif /* defined(HAVE_TGETENT) && defined(UNIX) */ | |
2187 | |
2188 /* | |
2189 * Get a string entry from the termcap and add it to the list of termcodes. | |
2190 * Used for <t_xx> special keys. | |
2191 * Give an error message for failure when not sourcing. | |
2192 * If force given, replace an existing entry. | |
2193 * Return FAIL if the entry was not found, OK if the entry was added. | |
2194 */ | |
2195 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2196 add_termcap_entry(char_u *name, int force) |
7 | 2197 { |
2198 char_u *term; | |
2199 int key; | |
2200 struct builtin_term *termp; | |
2201 #ifdef HAVE_TGETENT | |
2202 char_u *string; | |
2203 int i; | |
2204 int builtin_first; | |
2205 char_u tbuf[TBUFSZ]; | |
2206 char_u tstrbuf[TBUFSZ]; | |
2207 char_u *tp = tstrbuf; | |
2208 char_u *error_msg = NULL; | |
2209 #endif | |
2210 | |
2211 /* | |
2212 * If the GUI is running or will start in a moment, we only support the keys | |
2213 * that the GUI can produce. | |
2214 */ | |
2215 #ifdef FEAT_GUI | |
2216 if (gui.in_use || gui.starting) | |
2217 return gui_mch_haskey(name); | |
2218 #endif | |
2219 | |
2220 if (!force && find_termcode(name) != NULL) /* it's already there */ | |
2221 return OK; | |
2222 | |
2223 term = T_NAME; | |
2224 if (term == NULL || *term == NUL) /* 'term' not defined yet */ | |
2225 return FAIL; | |
2226 | |
2227 if (term_is_builtin(term)) /* name starts with "builtin_" */ | |
2228 { | |
2229 term += 8; | |
2230 #ifdef HAVE_TGETENT | |
2231 builtin_first = TRUE; | |
2232 #endif | |
2233 } | |
2234 #ifdef HAVE_TGETENT | |
2235 else | |
2236 builtin_first = p_tbi; | |
2237 #endif | |
2238 | |
2239 #ifdef HAVE_TGETENT | |
2240 /* | |
2241 * We can get the entry from the builtin termcap and from the external one. | |
2242 * If 'ttybuiltin' is on or the terminal name starts with "builtin_", try | |
2243 * builtin termcap first. | |
2244 * If 'ttybuiltin' is off, try external termcap first. | |
2245 */ | |
2246 for (i = 0; i < 2; ++i) | |
2247 { | |
7210
08b50e436093
commit https://github.com/vim/vim/commit/98b30a473a58ae98c280e0383c8b1e08c0ebced5
Christian Brabandt <cb@256bit.org>
parents:
6901
diff
changeset
|
2248 if ((!builtin_first) == i) |
7 | 2249 #endif |
2250 /* | |
2251 * Search in builtin termcap | |
2252 */ | |
2253 { | |
2254 termp = find_builtin_term(term); | |
2255 if (termp->bt_string != NULL) /* found it */ | |
2256 { | |
2257 key = TERMCAP2KEY(name[0], name[1]); | |
2258 while (termp->bt_entry != (int)KS_NAME) | |
2259 { | |
2260 if ((int)termp->bt_entry == key) | |
2261 { | |
2262 add_termcode(name, (char_u *)termp->bt_string, | |
2263 term_is_8bit(term)); | |
2264 return OK; | |
2265 } | |
2266 ++termp; | |
2267 } | |
2268 } | |
2269 } | |
2270 #ifdef HAVE_TGETENT | |
2271 else | |
2272 /* | |
2273 * Search in external termcap | |
2274 */ | |
2275 { | |
2276 error_msg = tgetent_error(tbuf, term); | |
2277 if (error_msg == NULL) | |
2278 { | |
2279 string = TGETSTR((char *)name, &tp); | |
2280 if (string != NULL && *string != NUL) | |
2281 { | |
2282 add_termcode(name, string, FALSE); | |
2283 return OK; | |
2284 } | |
2285 } | |
2286 } | |
2287 } | |
2288 #endif | |
2289 | |
2290 if (sourcing_name == NULL) | |
2291 { | |
2292 #ifdef HAVE_TGETENT | |
2293 if (error_msg != NULL) | |
2294 EMSG(error_msg); | |
2295 else | |
2296 #endif | |
2297 EMSG2(_("E436: No \"%s\" entry in termcap"), name); | |
2298 } | |
2299 return FAIL; | |
2300 } | |
2301 | |
2302 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2303 term_is_builtin(char_u *name) |
7 | 2304 { |
2305 return (STRNCMP(name, "builtin_", (size_t)8) == 0); | |
2306 } | |
2307 | |
2308 /* | |
2309 * Return TRUE if terminal "name" uses CSI instead of <Esc>[. | |
2310 * Assume that the terminal is using 8-bit controls when the name contains | |
2311 * "8bit", like in "xterm-8bit". | |
2312 */ | |
2313 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2314 term_is_8bit(char_u *name) |
7 | 2315 { |
2316 return (detected_8bit || strstr((char *)name, "8bit") != NULL); | |
2317 } | |
2318 | |
2319 /* | |
2320 * 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
|
2321 * <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
|
2322 * <Esc>] -> OSC <M-C-]> |
7 | 2323 * <Esc>O -> <M-C-O> |
2324 */ | |
2325 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2326 term_7to8bit(char_u *p) |
7 | 2327 { |
2328 if (*p == ESC) | |
2329 { | |
2330 if (p[1] == '[') | |
2331 return CSI; | |
2332 if (p[1] == ']') | |
6901 | 2333 return OSC; |
7 | 2334 if (p[1] == 'O') |
2335 return 0x8f; | |
2336 } | |
2337 return 0; | |
2338 } | |
2339 | |
2340 #ifdef FEAT_GUI | |
2341 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2342 term_is_gui(char_u *name) |
7 | 2343 { |
2344 return (STRCMP(name, "builtin_gui") == 0 || STRCMP(name, "gui") == 0); | |
2345 } | |
2346 #endif | |
2347 | |
2348 #if !defined(HAVE_TGETENT) || defined(AMIGA) || defined(PROTO) | |
2349 | |
2350 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2351 tltoa(unsigned long i) |
7 | 2352 { |
2353 static char_u buf[16]; | |
2354 char_u *p; | |
2355 | |
2356 p = buf + 15; | |
2357 *p = '\0'; | |
2358 do | |
2359 { | |
2360 --p; | |
2361 *p = (char_u) (i % 10 + '0'); | |
2362 i /= 10; | |
2363 } | |
2364 while (i > 0 && p > buf); | |
2365 return p; | |
2366 } | |
2367 #endif | |
2368 | |
2369 #ifndef HAVE_TGETENT | |
2370 | |
2371 /* | |
2372 * minimal tgoto() implementation. | |
2373 * no padding and we only parse for %i %d and %+char | |
2374 */ | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
2375 static char *tgoto(char *, int, int); |
298 | 2376 |
2377 static char * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2378 tgoto(char *cm, int x, int y) |
7 | 2379 { |
2380 static char buf[30]; | |
2381 char *p, *s, *e; | |
2382 | |
2383 if (!cm) | |
2384 return "OOPS"; | |
2385 e = buf + 29; | |
2386 for (s = buf; s < e && *cm; cm++) | |
2387 { | |
2388 if (*cm != '%') | |
2389 { | |
2390 *s++ = *cm; | |
2391 continue; | |
2392 } | |
2393 switch (*++cm) | |
2394 { | |
2395 case 'd': | |
2396 p = (char *)tltoa((unsigned long)y); | |
2397 y = x; | |
2398 while (*p) | |
2399 *s++ = *p++; | |
2400 break; | |
2401 case 'i': | |
2402 x++; | |
2403 y++; | |
2404 break; | |
2405 case '+': | |
2406 *s++ = (char)(*++cm + y); | |
2407 y = x; | |
2408 break; | |
2409 case '%': | |
2410 *s++ = *cm; | |
2411 break; | |
2412 default: | |
2413 return "OOPS"; | |
2414 } | |
2415 } | |
2416 *s = '\0'; | |
2417 return buf; | |
2418 } | |
2419 | |
2420 #endif /* HAVE_TGETENT */ | |
2421 | |
2422 /* | |
2423 * Set the terminal name and initialize the terminal options. | |
2424 * If "name" is NULL or empty, get the terminal name from the environment. | |
2425 * If that fails, use the default terminal name. | |
2426 */ | |
2427 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2428 termcapinit(char_u *name) |
7 | 2429 { |
2430 char_u *term; | |
2431 | |
2432 if (name != NULL && *name == NUL) | |
2433 name = NULL; /* empty name is equal to no name */ | |
2434 term = name; | |
2435 | |
2436 #ifdef __BEOS__ | |
2437 /* | |
2438 * TERM environment variable is normally set to 'ansi' on the Bebox; | |
2439 * Since the BeBox doesn't quite support full ANSI yet, we use our | |
2440 * own custom 'ansi-beos' termcap instead, unless the -T option has | |
2441 * been given on the command line. | |
2442 */ | |
2443 if (term == NULL | |
2444 && strcmp((char *)mch_getenv((char_u *)"TERM"), "ansi") == 0) | |
2445 term = DEFAULT_TERM; | |
2446 #endif | |
2447 #ifndef MSWIN | |
2448 if (term == NULL) | |
2449 term = mch_getenv((char_u *)"TERM"); | |
2450 #endif | |
2451 if (term == NULL || *term == NUL) | |
2452 term = DEFAULT_TERM; | |
694 | 2453 set_string_option_direct((char_u *)"term", -1, term, OPT_FREE, 0); |
7 | 2454 |
2455 /* Set the default terminal name. */ | |
2456 set_string_default("term", term); | |
2457 set_string_default("ttytype", term); | |
2458 | |
2459 /* | |
2460 * Avoid using "term" here, because the next mch_getenv() may overwrite it. | |
2461 */ | |
2462 set_termname(T_NAME != NULL ? T_NAME : term); | |
2463 } | |
2464 | |
2465 /* | |
2466 * the number of calls to ui_write is reduced by using the buffer "out_buf" | |
2467 */ | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
2468 #define OUT_SIZE 2047 |
7 | 2469 /* Add one to allow mch_write() in os_win32.c to append a NUL */ |
2470 static char_u out_buf[OUT_SIZE + 1]; | |
2471 static int out_pos = 0; /* number of chars in out_buf */ | |
2472 | |
2473 /* | |
2474 * out_flush(): flush the output buffer | |
2475 */ | |
2476 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2477 out_flush(void) |
7 | 2478 { |
2479 int len; | |
2480 | |
2481 if (out_pos != 0) | |
2482 { | |
2483 /* set out_pos to 0 before ui_write, to avoid recursiveness */ | |
2484 len = out_pos; | |
2485 out_pos = 0; | |
2486 ui_write(out_buf, len); | |
2487 } | |
2488 } | |
2489 | |
2490 #if defined(FEAT_MBYTE) || defined(PROTO) | |
2491 /* | |
2492 * Sometimes a byte out of a multi-byte character is written with out_char(). | |
2493 * To avoid flushing half of the character, call this function first. | |
2494 */ | |
2495 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2496 out_flush_check(void) |
7 | 2497 { |
2498 if (enc_dbcs != 0 && out_pos >= OUT_SIZE - MB_MAXBYTES) | |
2499 out_flush(); | |
2500 } | |
2501 #endif | |
2502 | |
2503 #ifdef FEAT_GUI | |
2504 /* | |
2505 * out_trash(): Throw away the contents of the output buffer | |
2506 */ | |
2507 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2508 out_trash(void) |
7 | 2509 { |
2510 out_pos = 0; | |
2511 } | |
2512 #endif | |
2513 | |
2514 /* | |
2515 * out_char(c): put a byte into the output buffer. | |
2516 * Flush it if it becomes full. | |
2517 * This should not be used for outputting text on the screen (use functions | |
2518 * like msg_puts() and screen_putchar() for that). | |
2519 */ | |
2520 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2521 out_char(unsigned c) |
7 | 2522 { |
2523 #if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(MACOS_X_UNIX) | |
2524 if (c == '\n') /* turn LF into CR-LF (CRMOD doesn't seem to do this) */ | |
2525 out_char('\r'); | |
2526 #endif | |
2527 | |
2528 out_buf[out_pos++] = c; | |
2529 | |
2530 /* For testing we flush each time. */ | |
2531 if (out_pos >= OUT_SIZE || p_wd) | |
2532 out_flush(); | |
2533 } | |
2534 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
2535 static void out_char_nf(unsigned); |
7 | 2536 |
2537 /* | |
2538 * out_char_nf(c): like out_char(), but don't flush when p_wd is set | |
2539 */ | |
2540 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2541 out_char_nf(unsigned c) |
7 | 2542 { |
2543 #if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(MACOS_X_UNIX) | |
2544 if (c == '\n') /* turn LF into CR-LF (CRMOD doesn't seem to do this) */ | |
2545 out_char_nf('\r'); | |
2546 #endif | |
2547 | |
2548 out_buf[out_pos++] = c; | |
2549 | |
2550 if (out_pos >= OUT_SIZE) | |
2551 out_flush(); | |
2552 } | |
2553 | |
2237
770485470e59
Add a few #ifdefs to exclude functions that are not used. (Domnique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
1941
diff
changeset
|
2554 #if defined(FEAT_TITLE) || defined(FEAT_MOUSE_TTY) || defined(FEAT_GUI) \ |
770485470e59
Add a few #ifdefs to exclude functions that are not used. (Domnique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
1941
diff
changeset
|
2555 || defined(FEAT_TERMRESPONSE) || defined(PROTO) |
7 | 2556 /* |
2557 * A never-padding out_str. | |
2558 * use this whenever you don't want to run the string through tputs. | |
2559 * tputs above is harmless, but tputs from the termcap library | |
2560 * is likely to strip off leading digits, that it mistakes for padding | |
2561 * information, and "%i", "%d", etc. | |
2562 * This should only be used for writing terminal codes, not for outputting | |
2563 * normal text (use functions like msg_puts() and screen_putchar() for that). | |
2564 */ | |
2565 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2566 out_str_nf(char_u *s) |
7 | 2567 { |
2568 if (out_pos > OUT_SIZE - 20) /* avoid terminal strings being split up */ | |
2569 out_flush(); | |
2570 while (*s) | |
2571 out_char_nf(*s++); | |
2572 | |
2573 /* For testing we write one string at a time. */ | |
2574 if (p_wd) | |
2575 out_flush(); | |
2576 } | |
2237
770485470e59
Add a few #ifdefs to exclude functions that are not used. (Domnique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
1941
diff
changeset
|
2577 #endif |
7 | 2578 |
2579 /* | |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2580 * 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
|
2581 * 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
|
2582 * it at the wrong time. |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2583 * Note: Only for terminal strings. |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2584 */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2585 void |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2586 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
|
2587 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2588 if (s != NULL && *s) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2589 { |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2590 #ifdef HAVE_TGETENT |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2591 char_u *p; |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2592 #endif |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2593 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2594 #ifdef FEAT_GUI |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2595 /* Don't use tputs() when GUI is used, ncurses crashes. */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2596 if (gui.in_use) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2597 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2598 out_str_nf(s); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2599 return; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2600 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2601 #endif |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2602 if (out_pos > OUT_SIZE - 20) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2603 out_flush(); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2604 #ifdef HAVE_TGETENT |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2605 for (p = s; *s; ++s) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2606 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2607 /* flush just before delay command */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2608 if (*s == '$' && *(s + 1) == '<') |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2609 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2610 char_u save_c = *s; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2611 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
|
2612 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2613 *s = NUL; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2614 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
|
2615 *s = save_c; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2616 out_flush(); |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2617 # ifdef ELAPSED_FUNC |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2618 /* Only sleep here if we can limit this happening in |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2619 * vim_beep(). */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2620 p = vim_strchr(s, '>'); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2621 if (p == NULL || duration <= 0) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2622 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2623 /* can't parse the time, don't sleep here */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2624 p = s; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2625 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2626 else |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2627 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2628 ++p; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2629 do_sleep(duration); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2630 } |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2631 # else |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2632 /* Rely on the terminal library to sleep. */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2633 p = s; |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2634 # endif |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2635 break; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2636 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2637 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2638 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
|
2639 #else |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2640 while (*s) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2641 out_char_nf(*s++); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2642 #endif |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2643 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2644 /* For testing we write one string at a time. */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2645 if (p_wd) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2646 out_flush(); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2647 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2648 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2649 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2650 /* |
7 | 2651 * out_str(s): Put a character string a byte at a time into the output buffer. |
2652 * If HAVE_TGETENT is defined use the termcap parser. (jw) | |
2653 * This should only be used for writing terminal codes, not for outputting | |
2654 * normal text (use functions like msg_puts() and screen_putchar() for that). | |
2655 */ | |
2656 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2657 out_str(char_u *s) |
7 | 2658 { |
2659 if (s != NULL && *s) | |
2660 { | |
2661 #ifdef FEAT_GUI | |
2662 /* Don't use tputs() when GUI is used, ncurses crashes. */ | |
2663 if (gui.in_use) | |
2664 { | |
2665 out_str_nf(s); | |
2666 return; | |
2667 } | |
2668 #endif | |
2669 /* avoid terminal strings being split up */ | |
2670 if (out_pos > OUT_SIZE - 20) | |
2671 out_flush(); | |
2672 #ifdef HAVE_TGETENT | |
2673 tputs((char *)s, 1, TPUTSFUNCAST out_char_nf); | |
2674 #else | |
2675 while (*s) | |
2676 out_char_nf(*s++); | |
2677 #endif | |
2678 | |
2679 /* For testing we write one string at a time. */ | |
2680 if (p_wd) | |
2681 out_flush(); | |
2682 } | |
2683 } | |
2684 | |
2685 /* | |
2686 * cursor positioning using termcap parser. (jw) | |
2687 */ | |
2688 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2689 term_windgoto(int row, int col) |
7 | 2690 { |
2691 OUT_STR(tgoto((char *)T_CM, col, row)); | |
2692 } | |
2693 | |
2694 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2695 term_cursor_right(int i) |
7 | 2696 { |
2697 OUT_STR(tgoto((char *)T_CRI, 0, i)); | |
2698 } | |
2699 | |
2700 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2701 term_append_lines(int line_count) |
7 | 2702 { |
2703 OUT_STR(tgoto((char *)T_CAL, 0, line_count)); | |
2704 } | |
2705 | |
2706 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2707 term_delete_lines(int line_count) |
7 | 2708 { |
2709 OUT_STR(tgoto((char *)T_CDL, 0, line_count)); | |
2710 } | |
2711 | |
2712 #if defined(HAVE_TGETENT) || defined(PROTO) | |
2713 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2714 term_set_winpos(int x, int y) |
7 | 2715 { |
2716 /* Can't handle a negative value here */ | |
2717 if (x < 0) | |
2718 x = 0; | |
2719 if (y < 0) | |
2720 y = 0; | |
2721 OUT_STR(tgoto((char *)T_CWP, y, x)); | |
2722 } | |
2723 | |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2724 # 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
|
2725 /* |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2726 * 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
|
2727 */ |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2728 static int |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2729 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
|
2730 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2731 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
|
2732 && termcap_active |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2733 # ifdef UNIX |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2734 && (is_not_a_term() || (isatty(1) && isatty(read_cmd_fd))) |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2735 # endif |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2736 && p_ek; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2737 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2738 |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2739 static int winpos_x; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2740 static int winpos_y; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2741 static int waiting_for_winpos = FALSE; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2742 |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2743 /* |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2744 * 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
|
2745 * 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
|
2746 */ |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2747 int |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2748 term_get_winpos(int *x, int *y) |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2749 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2750 int count = 0; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2751 |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2752 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
|
2753 return FAIL; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2754 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
|
2755 winpos_y = -1; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2756 waiting_for_winpos = TRUE; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2757 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
|
2758 out_flush(); |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2759 |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2760 /* Try reading the result for 100 msec. */ |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2761 while (count++ < 10) |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2762 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2763 (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
|
2764 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
|
2765 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2766 *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
|
2767 *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
|
2768 waiting_for_winpos = FALSE; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2769 return OK; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2770 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2771 ui_delay(10, FALSE); |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2772 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2773 waiting_for_winpos = FALSE; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2774 return FALSE; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2775 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2776 # endif |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2777 |
7 | 2778 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
|
2779 term_set_winsize(int height, int width) |
7 | 2780 { |
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
|
2781 OUT_STR(tgoto((char *)T_CWS, width, height)); |
7 | 2782 } |
2783 #endif | |
2784 | |
2785 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2786 term_fg_color(int n) |
7 | 2787 { |
2788 /* Use "AF" termcap entry if present, "Sf" entry otherwise */ | |
2789 if (*T_CAF) | |
2790 term_color(T_CAF, n); | |
2791 else if (*T_CSF) | |
2792 term_color(T_CSF, n); | |
2793 } | |
2794 | |
2795 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2796 term_bg_color(int n) |
7 | 2797 { |
2798 /* Use "AB" termcap entry if present, "Sb" entry otherwise */ | |
2799 if (*T_CAB) | |
2800 term_color(T_CAB, n); | |
2801 else if (*T_CSB) | |
2802 term_color(T_CSB, n); | |
2803 } | |
2804 | |
2805 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2806 term_color(char_u *s, int n) |
7 | 2807 { |
2808 char buf[20]; | |
2809 int i = 2; /* index in s[] just after <Esc>[ or CSI */ | |
2810 | |
2811 /* Special handling of 16 colors, because termcap can't handle it */ | |
2812 /* Also accept "\e[3%dm" for TERMINFO, it is sometimes used */ | |
2813 /* Also accept CSI instead of <Esc>[ */ | |
2814 if (n >= 8 && t_colors >= 16 | |
2815 && ((s[0] == ESC && s[1] == '[') || (s[0] == CSI && (i = 1) == 1)) | |
2816 && s[i] != NUL | |
2817 && (STRCMP(s + i + 1, "%p1%dm") == 0 | |
2818 || STRCMP(s + i + 1, "%dm") == 0) | |
2819 && (s[i] == '3' || s[i] == '4')) | |
2820 { | |
2821 #ifdef TERMINFO | |
9068
0a3bc9fdea20
commit https://github.com/vim/vim/commit/827b165b2aebad2cfe98cc6d5804c6c0fe8afd89
Christian Brabandt <cb@256bit.org>
parents:
9027
diff
changeset
|
2822 char *format = "%s%s%%p1%%dm"; |
7 | 2823 #else |
9068
0a3bc9fdea20
commit https://github.com/vim/vim/commit/827b165b2aebad2cfe98cc6d5804c6c0fe8afd89
Christian Brabandt <cb@256bit.org>
parents:
9027
diff
changeset
|
2824 char *format = "%s%s%%dm"; |
7 | 2825 #endif |
9068
0a3bc9fdea20
commit https://github.com/vim/vim/commit/827b165b2aebad2cfe98cc6d5804c6c0fe8afd89
Christian Brabandt <cb@256bit.org>
parents:
9027
diff
changeset
|
2826 sprintf(buf, format, |
7 | 2827 i == 2 ? IF_EB("\033[", ESC_STR "[") : "\233", |
2828 s[i] == '3' ? (n >= 16 ? "38;5;" : "9") | |
2829 : (n >= 16 ? "48;5;" : "10")); | |
2830 OUT_STR(tgoto(buf, 0, n >= 16 ? n : n - 8)); | |
2831 } | |
2832 else | |
2833 OUT_STR(tgoto((char *)s, 0, n)); | |
2834 } | |
2835 | |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
2836 #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
|
2837 |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2838 #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
|
2839 #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
|
2840 #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
|
2841 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2842 static void |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2843 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
|
2844 { |
8975
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
2845 #define MAX_COLOR_STR_LEN 100 |
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
2846 char buf[MAX_COLOR_STR_LEN]; |
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
2847 |
8981
3b51b0aeb9a3
commit https://github.com/vim/vim/commit/a1c487eef71d1673e57511453009de9cb4c9af51
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
2848 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
|
2849 (char *)s, RED(rgb), GREEN(rgb), BLUE(rgb)); |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2850 OUT_STR(buf); |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2851 } |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2852 |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2853 void |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2854 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
|
2855 { |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2856 term_rgb_color(T_8F, rgb); |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2857 } |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2858 |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2859 void |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2860 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
|
2861 { |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2862 term_rgb_color(T_8B, rgb); |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2863 } |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2864 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2865 |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7307
diff
changeset
|
2866 #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
|
2867 || defined(MACOS_X))) || defined(PROTO) |
7 | 2868 /* |
2869 * Generic function to set window title, using t_ts and t_fs. | |
2870 */ | |
2871 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2872 term_settitle(char_u *title) |
7 | 2873 { |
2874 /* t_ts takes one argument: column in status line */ | |
2875 OUT_STR(tgoto((char *)T_TS, 0, 0)); /* set title start */ | |
2876 out_str_nf(title); | |
2877 out_str(T_FS); /* set title end */ | |
2878 out_flush(); | |
2879 } | |
2880 #endif | |
2881 | |
2882 /* | |
2883 * Make sure we have a valid set or terminal options. | |
2884 * Replace all entries that are NULL by empty_option | |
2885 */ | |
2886 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2887 ttest(int pairs) |
7 | 2888 { |
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
|
2889 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
|
2890 |
7 | 2891 check_options(); /* make sure no options are NULL */ |
2892 | |
2893 /* | |
2894 * MUST have "cm": cursor motion. | |
2895 */ | |
2896 if (*T_CM == NUL) | |
2897 EMSG(_("E437: terminal capability \"cm\" required")); | |
2898 | |
2899 /* | |
2900 * if "cs" defined, use a scroll region, it's faster. | |
2901 */ | |
2902 if (*T_CS != NUL) | |
2903 scroll_region = TRUE; | |
2904 else | |
2905 scroll_region = FALSE; | |
2906 | |
2907 if (pairs) | |
2908 { | |
2909 /* | |
2910 * optional pairs | |
2911 */ | |
2912 /* TP goes to normal mode for TI (invert) and TB (bold) */ | |
2913 if (*T_ME == NUL) | |
2914 T_ME = T_MR = T_MD = T_MB = empty_option; | |
2915 if (*T_SO == NUL || *T_SE == NUL) | |
2916 T_SO = T_SE = empty_option; | |
2917 if (*T_US == NUL || *T_UE == NUL) | |
2918 T_US = T_UE = empty_option; | |
2919 if (*T_CZH == NUL || *T_CZR == NUL) | |
2920 T_CZH = T_CZR = empty_option; | |
2921 | |
2922 /* T_VE is needed even though T_VI is not defined */ | |
2923 if (*T_VE == NUL) | |
2924 T_VI = empty_option; | |
2925 | |
2926 /* if 'mr' or 'me' is not defined use 'so' and 'se' */ | |
2927 if (*T_ME == NUL) | |
2928 { | |
2929 T_ME = T_SE; | |
2930 T_MR = T_SO; | |
2931 T_MD = T_SO; | |
2932 } | |
2933 | |
2934 /* if 'so' or 'se' is not defined use 'mr' and 'me' */ | |
2935 if (*T_SO == NUL) | |
2936 { | |
2937 T_SE = T_ME; | |
2938 if (*T_MR == NUL) | |
2939 T_SO = T_MD; | |
2940 else | |
2941 T_SO = T_MR; | |
2942 } | |
2943 | |
2944 /* if 'ZH' or 'ZR' is not defined use 'mr' and 'me' */ | |
2945 if (*T_CZH == NUL) | |
2946 { | |
2947 T_CZR = T_ME; | |
2948 if (*T_MR == NUL) | |
2949 T_CZH = T_MD; | |
2950 else | |
2951 T_CZH = T_MR; | |
2952 } | |
2953 | |
2954 /* "Sb" and "Sf" come in pairs */ | |
2955 if (*T_CSB == NUL || *T_CSF == NUL) | |
2956 { | |
2957 T_CSB = empty_option; | |
2958 T_CSF = empty_option; | |
2959 } | |
2960 | |
2961 /* "AB" and "AF" come in pairs */ | |
2962 if (*T_CAB == NUL || *T_CAF == NUL) | |
2963 { | |
2964 T_CAB = empty_option; | |
2965 T_CAF = empty_option; | |
2966 } | |
2967 | |
2968 /* if 'Sb' and 'AB' are not defined, reset "Co" */ | |
2969 if (*T_CSB == NUL && *T_CAB == NUL) | |
1941 | 2970 free_one_termoption(T_CCO); |
7 | 2971 |
2972 /* Set 'weirdinvert' according to value of 't_xs' */ | |
2973 p_wiv = (*T_XS != NUL); | |
2974 } | |
2975 need_gather = TRUE; | |
2976 | |
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
|
2977 /* Set t_colors to the value of $COLORS or t_Co. */ |
7 | 2978 t_colors = atoi((char *)T_CCO); |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
2979 env_colors = mch_getenv((char_u *)"COLORS"); |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
2980 if (env_colors != NULL && isdigit(*env_colors)) |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
2981 { |
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
|
2982 int colors = atoi((char *)env_colors); |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
2983 |
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
|
2984 if (colors != t_colors) |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
2985 set_color_count(colors); |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
2986 } |
7 | 2987 } |
2988 | |
2989 #if (defined(FEAT_GUI) && (defined(FEAT_MENU) || !defined(USE_ON_FLY_SCROLL))) \ | |
2990 || defined(PROTO) | |
2991 /* | |
2992 * Represent the given long_u as individual bytes, with the most significant | |
2993 * byte first, and store them in dst. | |
2994 */ | |
2995 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2996 add_long_to_buf(long_u val, char_u *dst) |
7 | 2997 { |
2998 int i; | |
2999 int shift; | |
3000 | |
1883 | 3001 for (i = 1; i <= (int)sizeof(long_u); i++) |
7 | 3002 { |
3003 shift = 8 * (sizeof(long_u) - i); | |
3004 dst[i - 1] = (char_u) ((val >> shift) & 0xff); | |
3005 } | |
3006 } | |
3007 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
3008 static int get_long_from_buf(char_u *buf, long_u *val); |
7 | 3009 |
3010 /* | |
3011 * Interpret the next string of bytes in buf as a long integer, with the most | |
3012 * significant byte first. Note that it is assumed that buf has been through | |
3013 * inchar(), so that NUL and K_SPECIAL will be represented as three bytes each. | |
3014 * Puts result in val, and returns the number of bytes read from buf | |
3015 * (between sizeof(long_u) and 2 * sizeof(long_u)), or -1 if not enough bytes | |
3016 * were present. | |
3017 */ | |
3018 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3019 get_long_from_buf(char_u *buf, long_u *val) |
7 | 3020 { |
3021 int len; | |
3022 char_u bytes[sizeof(long_u)]; | |
3023 int i; | |
3024 int shift; | |
3025 | |
3026 *val = 0; | |
3027 len = get_bytes_from_buf(buf, bytes, (int)sizeof(long_u)); | |
3028 if (len != -1) | |
3029 { | |
1883 | 3030 for (i = 0; i < (int)sizeof(long_u); i++) |
7 | 3031 { |
3032 shift = 8 * (sizeof(long_u) - 1 - i); | |
3033 *val += (long_u)bytes[i] << shift; | |
3034 } | |
3035 } | |
3036 return len; | |
3037 } | |
3038 #endif | |
3039 | |
3040 #if defined(FEAT_GUI) \ | |
1623 | 3041 || (defined(FEAT_MOUSE) && (!defined(UNIX) || defined(FEAT_MOUSE_XTERM) \ |
3042 || defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE))) | |
7 | 3043 /* |
3044 * Read the next num_bytes bytes from buf, and store them in bytes. Assume | |
3045 * that buf has been through inchar(). Returns the actual number of bytes used | |
3046 * from buf (between num_bytes and num_bytes*2), or -1 if not enough bytes were | |
3047 * available. | |
3048 */ | |
3049 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3050 get_bytes_from_buf(char_u *buf, char_u *bytes, int num_bytes) |
7 | 3051 { |
3052 int len = 0; | |
3053 int i; | |
3054 char_u c; | |
3055 | |
3056 for (i = 0; i < num_bytes; i++) | |
3057 { | |
3058 if ((c = buf[len++]) == NUL) | |
3059 return -1; | |
3060 if (c == K_SPECIAL) | |
3061 { | |
3062 if (buf[len] == NUL || buf[len + 1] == NUL) /* cannot happen? */ | |
3063 return -1; | |
3064 if (buf[len++] == (int)KS_ZERO) | |
3065 c = NUL; | |
5076
19ed30f7cef7
updated for version 7.3.1281
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
3066 /* else it should be KS_SPECIAL; when followed by KE_FILLER c is |
19ed30f7cef7
updated for version 7.3.1281
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
3067 * K_SPECIAL, or followed by KE_CSI and c must be CSI. */ |
19ed30f7cef7
updated for version 7.3.1281
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
3068 if (buf[len++] == (int)KE_CSI) |
19ed30f7cef7
updated for version 7.3.1281
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
3069 c = CSI; |
7 | 3070 } |
1160 | 3071 else if (c == CSI && buf[len] == KS_EXTRA |
3072 && buf[len + 1] == (int)KE_CSI) | |
667 | 3073 /* CSI is stored as CSI KS_SPECIAL KE_CSI to avoid confusion with |
3074 * the start of a special key, see add_to_input_buf_csi(). */ | |
3075 len += 2; | |
7 | 3076 bytes[i] = c; |
3077 } | |
3078 return len; | |
3079 } | |
3080 #endif | |
3081 | |
3082 /* | |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3083 * 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
|
3084 * too big. |
7 | 3085 */ |
3086 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3087 check_shellsize(void) |
7 | 3088 { |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3089 if (Rows < min_rows()) /* need room for one window and command line */ |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3090 Rows = min_rows(); |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3091 limit_screen_size(); |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3092 } |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3093 |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3094 /* |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3095 * 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
|
3096 */ |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3097 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3098 limit_screen_size(void) |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3099 { |
7 | 3100 if (Columns < MIN_COLUMNS) |
3101 Columns = MIN_COLUMNS; | |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3102 else if (Columns > 10000) |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3103 Columns = 10000; |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3104 if (Rows > 1000) |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3105 Rows = 1000; |
7 | 3106 } |
3107 | |
41 | 3108 /* |
3109 * Invoked just before the screen structures are going to be (re)allocated. | |
3110 */ | |
7 | 3111 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3112 win_new_shellsize(void) |
7 | 3113 { |
3114 static int old_Rows = 0; | |
3115 static int old_Columns = 0; | |
3116 | |
3117 if (old_Rows != Rows || old_Columns != Columns) | |
3118 ui_new_shellsize(); | |
3119 if (old_Rows != Rows) | |
3120 { | |
164 | 3121 /* if 'window' uses the whole screen, keep it using that */ |
179 | 3122 if (p_window == old_Rows - 1 || old_Rows == 0) |
164 | 3123 p_window = Rows - 1; |
7 | 3124 old_Rows = Rows; |
3125 shell_new_rows(); /* update window sizes */ | |
3126 } | |
3127 if (old_Columns != Columns) | |
3128 { | |
3129 old_Columns = Columns; | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
3130 #ifdef FEAT_WINDOWS |
7 | 3131 shell_new_columns(); /* update window sizes */ |
3132 #endif | |
3133 } | |
3134 } | |
3135 | |
3136 /* | |
3137 * Call this function when the Vim shell has been resized in any way. | |
3138 * Will obtain the current size and redraw (also when size didn't change). | |
3139 */ | |
3140 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3141 shell_resized(void) |
7 | 3142 { |
3143 set_shellsize(0, 0, FALSE); | |
3144 } | |
3145 | |
3146 /* | |
3147 * Check if the shell size changed. Handle a resize. | |
3148 * When the size didn't change, nothing happens. | |
3149 */ | |
3150 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3151 shell_resized_check(void) |
7 | 3152 { |
3153 int old_Rows = Rows; | |
3154 int old_Columns = Columns; | |
3155 | |
3770 | 3156 if (!exiting |
3157 #ifdef FEAT_GUI | |
3158 /* Do not get the size when executing a shell command during | |
3159 * startup. */ | |
3160 && !gui.starting | |
3161 #endif | |
3162 ) | |
2673 | 3163 { |
3164 (void)ui_get_shellsize(); | |
3165 check_shellsize(); | |
3166 if (old_Rows != Rows || old_Columns != Columns) | |
3167 shell_resized(); | |
3168 } | |
7 | 3169 } |
3170 | |
3171 /* | |
3172 * Set size of the Vim shell. | |
3173 * If 'mustset' is TRUE, we must set Rows and Columns, do not get the real | |
3174 * window size (this is used for the :win command). | |
3175 * If 'mustset' is FALSE, we may try to get the real window size and if | |
3176 * it fails use 'width' and 'height'. | |
3177 */ | |
3178 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3179 set_shellsize(int width, int height, int mustset) |
7 | 3180 { |
3181 static int busy = FALSE; | |
3182 | |
3183 /* | |
3184 * Avoid recursiveness, can happen when setting the window size causes | |
3185 * another window-changed signal. | |
3186 */ | |
3187 if (busy) | |
3188 return; | |
3189 | |
3190 if (width < 0 || height < 0) /* just checking... */ | |
3191 return; | |
3192 | |
3068 | 3193 if (State == HITRETURN || State == SETWSIZE) |
7 | 3194 { |
3068 | 3195 /* postpone the resizing */ |
7 | 3196 State = SETWSIZE; |
3197 return; | |
3198 } | |
3199 | |
3068 | 3200 /* curwin->w_buffer can be NULL when we are closing a window and the |
3201 * buffer has already been closed and removing a scrollbar causes a resize | |
3202 * event. Don't resize then, it will happen after entering another buffer. | |
3203 */ | |
3204 if (curwin->w_buffer == NULL) | |
3205 return; | |
3206 | |
7 | 3207 ++busy; |
3208 | |
3209 #ifdef AMIGA | |
3210 out_flush(); /* must do this before mch_get_shellsize() for | |
3211 some obscure reason */ | |
3212 #endif | |
3213 | |
3214 if (mustset || (ui_get_shellsize() == FAIL && height != 0)) | |
3215 { | |
3216 Rows = height; | |
3217 Columns = width; | |
3218 check_shellsize(); | |
3219 ui_set_shellsize(mustset); | |
3220 } | |
3221 else | |
3222 check_shellsize(); | |
3223 | |
3224 /* The window layout used to be adjusted here, but it now happens in | |
3225 * screenalloc() (also invoked from screenclear()). That is because the | |
3226 * "busy" check above may skip this, but not screenalloc(). */ | |
3227 | |
3228 if (State != ASKMORE && State != EXTERNCMD && State != CONFIRM) | |
3229 screenclear(); | |
3230 else | |
3231 screen_start(); /* don't know where cursor is now */ | |
3232 | |
3233 if (starting != NO_SCREEN) | |
3234 { | |
3235 #ifdef FEAT_TITLE | |
3236 maketitle(); | |
3237 #endif | |
3238 changed_line_abv_curs(); | |
3239 invalidate_botline(); | |
3240 | |
3241 /* | |
3242 * We only redraw when it's needed: | |
3243 * - While at the more prompt or executing an external command, don't | |
3244 * redraw, but position the cursor. | |
3245 * - While editing the command line, only redraw that. | |
3246 * - in Ex mode, don't redraw anything. | |
3247 * - Otherwise, redraw right now, and position the cursor. | |
3248 * Always need to call update_screen() or screenalloc(), to make | |
3249 * sure Rows/Columns and the size of ScreenLines[] is correct! | |
3250 */ | |
3251 if (State == ASKMORE || State == EXTERNCMD || State == CONFIRM | |
3252 || exmode_active) | |
3253 { | |
3254 screenalloc(FALSE); | |
3255 repeat_message(); | |
3256 } | |
3257 else | |
3258 { | |
1024 | 3259 #ifdef FEAT_SCROLLBIND |
3260 if (curwin->w_p_scb) | |
3261 do_check_scrollbind(TRUE); | |
3262 #endif | |
3263 if (State & CMDLINE) | |
648 | 3264 { |
1024 | 3265 update_screen(NOT_VALID); |
3266 redrawcmdline(); | |
648 | 3267 } |
3268 else | |
1024 | 3269 { |
3270 update_topline(); | |
3271 #if defined(FEAT_INS_EXPAND) | |
3272 if (pum_visible()) | |
3273 { | |
3274 redraw_later(NOT_VALID); | |
3275 ins_compl_show_pum(); /* This includes the redraw. */ | |
3276 } | |
3277 else | |
648 | 3278 #endif |
1024 | 3279 update_screen(NOT_VALID); |
3280 if (redrawing()) | |
3281 setcursor(); | |
3282 } | |
7 | 3283 } |
3284 cursor_on(); /* redrawing may have switched it off */ | |
3285 } | |
3286 out_flush(); | |
3287 --busy; | |
3288 } | |
3289 | |
3290 /* | |
3291 * Set the terminal to TMODE_RAW (for Normal mode) or TMODE_COOK (for external | |
3292 * commands and Ex mode). | |
3293 */ | |
3294 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3295 settmode(int tmode) |
7 | 3296 { |
3297 #ifdef FEAT_GUI | |
3298 /* don't set the term where gvim was started to any mode */ | |
3299 if (gui.in_use) | |
3300 return; | |
3301 #endif | |
3302 | |
3303 if (full_screen) | |
3304 { | |
3305 /* | |
3306 * When returning after calling a shell we want to really set the | |
3307 * terminal to raw mode, even though we think it already is, because | |
3308 * the shell program may have reset the terminal mode. | |
3309 * When we think the terminal is normal, don't try to set it to | |
3310 * normal again, because that causes problems (logout!) on some | |
3311 * machines. | |
3312 */ | |
3313 if (tmode != TMODE_COOK || cur_tmode != TMODE_COOK) | |
3314 { | |
3315 #ifdef FEAT_TERMRESPONSE | |
1691 | 3316 # ifdef FEAT_GUI |
3317 if (!gui.in_use && !gui.starting) | |
3318 # endif | |
3319 { | |
3320 /* May need to check for T_CRV response and termcodes, it | |
3321 * doesn't work in Cooked mode, an external program may get | |
3322 * them. */ | |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3323 if (tmode != TMODE_RAW && (crv_status == STATUS_SENT |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3324 || u7_status == STATUS_SENT |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3325 || rbg_status == STATUS_SENT |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3326 || rbm_status == STATUS_SENT |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3327 || rcs_status == STATUS_SENT)) |
1691 | 3328 (void)vpeekc_nomap(); |
3329 check_for_codes_from_term(); | |
3330 } | |
7 | 3331 #endif |
3332 #ifdef FEAT_MOUSE_TTY | |
3333 if (tmode != TMODE_RAW) | |
11368
253e66dd1428
patch 8.0.0569: bracketed paste is still enabled in a shell command
Christian Brabandt <cb@256bit.org>
parents:
11315
diff
changeset
|
3334 mch_setmouse(FALSE); /* switch mouse off */ |
7 | 3335 #endif |
11368
253e66dd1428
patch 8.0.0569: bracketed paste is still enabled in a shell command
Christian Brabandt <cb@256bit.org>
parents:
11315
diff
changeset
|
3336 if (tmode != TMODE_RAW) |
253e66dd1428
patch 8.0.0569: bracketed paste is still enabled in a shell command
Christian Brabandt <cb@256bit.org>
parents:
11315
diff
changeset
|
3337 out_str(T_BD); /* disable bracketed paste mode */ |
7 | 3338 out_flush(); |
11368
253e66dd1428
patch 8.0.0569: bracketed paste is still enabled in a shell command
Christian Brabandt <cb@256bit.org>
parents:
11315
diff
changeset
|
3339 mch_settmode(tmode); /* machine specific function */ |
7 | 3340 cur_tmode = tmode; |
3341 #ifdef FEAT_MOUSE | |
3342 if (tmode == TMODE_RAW) | |
11368
253e66dd1428
patch 8.0.0569: bracketed paste is still enabled in a shell command
Christian Brabandt <cb@256bit.org>
parents:
11315
diff
changeset
|
3343 setmouse(); /* may switch mouse on */ |
7 | 3344 #endif |
11368
253e66dd1428
patch 8.0.0569: bracketed paste is still enabled in a shell command
Christian Brabandt <cb@256bit.org>
parents:
11315
diff
changeset
|
3345 if (tmode == TMODE_RAW) |
253e66dd1428
patch 8.0.0569: bracketed paste is still enabled in a shell command
Christian Brabandt <cb@256bit.org>
parents:
11315
diff
changeset
|
3346 out_str(T_BE); /* enable bracketed paste mode */ |
7 | 3347 out_flush(); |
3348 } | |
3349 #ifdef FEAT_TERMRESPONSE | |
3350 may_req_termresponse(); | |
3351 #endif | |
3352 } | |
3353 } | |
3354 | |
3355 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3356 starttermcap(void) |
7 | 3357 { |
3358 if (full_screen && !termcap_active) | |
3359 { | |
3360 out_str(T_TI); /* start termcap mode */ | |
3361 out_str(T_KS); /* start "keypad transmit" mode */ | |
10676
b8c04c007d39
patch 8.0.0228: pasting in xterm on the command line has PasteStart
Christian Brabandt <cb@256bit.org>
parents:
10640
diff
changeset
|
3362 out_str(T_BE); /* enable bracketed paste mode */ |
7 | 3363 out_flush(); |
3364 termcap_active = TRUE; | |
3365 screen_start(); /* don't know where cursor is now */ | |
3366 #ifdef FEAT_TERMRESPONSE | |
1691 | 3367 # ifdef FEAT_GUI |
3368 if (!gui.in_use && !gui.starting) | |
3369 # endif | |
3370 { | |
3371 may_req_termresponse(); | |
3372 /* Immediately check for a response. If t_Co changes, we don't | |
3373 * want to redraw with wrong colors first. */ | |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3374 if (crv_status == STATUS_SENT) |
1691 | 3375 check_for_codes_from_term(); |
3376 } | |
7 | 3377 #endif |
3378 } | |
3379 } | |
3380 | |
3381 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3382 stoptermcap(void) |
7 | 3383 { |
3384 screen_stop_highlight(); | |
3385 reset_cterm_colors(); | |
3386 if (termcap_active) | |
3387 { | |
3388 #ifdef FEAT_TERMRESPONSE | |
1691 | 3389 # ifdef FEAT_GUI |
3390 if (!gui.in_use && !gui.starting) | |
3391 # endif | |
3392 { | |
6874 | 3393 /* May need to discard T_CRV, T_U7 or T_RBG response. */ |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3394 if (crv_status == STATUS_SENT |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3395 || u7_status == STATUS_SENT |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3396 || rbg_status == STATUS_SENT |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3397 || rbm_status == STATUS_SENT |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3398 || rcs_status == STATUS_SENT) |
4391 | 3399 { |
3400 # ifdef UNIX | |
3401 /* Give the terminal a chance to respond. */ | |
3402 mch_delay(100L, FALSE); | |
3403 # endif | |
3404 # ifdef TCIFLUSH | |
3405 /* Discard data received but not read. */ | |
3406 if (exiting) | |
3407 tcflush(fileno(stdin), TCIFLUSH); | |
3408 # endif | |
3409 } | |
1691 | 3410 /* Check for termcodes first, otherwise an external program may |
3411 * get them. */ | |
3412 check_for_codes_from_term(); | |
3413 } | |
7 | 3414 #endif |
10676
b8c04c007d39
patch 8.0.0228: pasting in xterm on the command line has PasteStart
Christian Brabandt <cb@256bit.org>
parents:
10640
diff
changeset
|
3415 out_str(T_BD); /* disable bracketed paste mode */ |
7 | 3416 out_str(T_KE); /* stop "keypad transmit" mode */ |
3417 out_flush(); | |
3418 termcap_active = FALSE; | |
3419 cursor_on(); /* just in case it is still off */ | |
3420 out_str(T_TE); /* stop termcap mode */ | |
3421 screen_start(); /* don't know where cursor is now */ | |
3422 out_flush(); | |
3423 } | |
3424 } | |
3425 | |
5932 | 3426 #if defined(FEAT_TERMRESPONSE) || defined(PROTO) |
7 | 3427 /* |
3428 * Request version string (for xterm) when needed. | |
3429 * Only do this after switching to raw mode, otherwise the result will be | |
3430 * echoed. | |
626 | 3431 * Only do this after startup has finished, to avoid that the response comes |
1221 | 3432 * while executing "-c !cmd" or even after "-c quit". |
7 | 3433 * Only do this after termcap mode has been started, otherwise the codes for |
3434 * the cursor keys may be wrong. | |
620 | 3435 * Only do this when 'esckeys' is on, otherwise the response causes trouble in |
3436 * Insert mode. | |
164 | 3437 * On Unix only do it when both output and input are a tty (avoid writing |
3438 * request to terminal while reading from a file). | |
7 | 3439 * The result is caught in check_termcode(). |
3440 */ | |
626 | 3441 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3442 may_req_termresponse(void) |
7 | 3443 { |
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
|
3444 if (crv_status == STATUS_GET |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
3445 && can_get_termresponse() |
626 | 3446 && starting == 0 |
7 | 3447 && *T_CRV != NUL) |
3448 { | |
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
|
3449 LOG_TR("Sending CRV request"); |
7 | 3450 out_str(T_CRV); |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3451 crv_status = STATUS_SENT; |
7 | 3452 /* check for the characters now, otherwise they might be eaten by |
3453 * get_keystroke() */ | |
3454 out_flush(); | |
3455 (void)vpeekc_nomap(); | |
3456 } | |
3457 } | |
4215 | 3458 |
3459 # if defined(FEAT_MBYTE) || defined(PROTO) | |
3460 /* | |
3461 * Check how the terminal treats ambiguous character width (UAX #11). | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3462 * First, we move the cursor to (1, 0) and print a test ambiguous character |
4215 | 3463 * \u25bd (WHITE DOWN-POINTING TRIANGLE) and query current cursor position. |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3464 * If the terminal treats \u25bd as single width, the position is (1, 1), |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3465 * or if it is treated as double width, that will be (1, 2). |
4215 | 3466 * This function has the side effect that changes cursor position, so |
3467 * it must be called immediately after entering termcap mode. | |
3468 */ | |
3469 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3470 may_req_ambiguous_char_width(void) |
4215 | 3471 { |
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
|
3472 if (u7_status == STATUS_GET |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
3473 && 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
|
3474 && starting == 0 |
4215 | 3475 && *T_U7 != NUL |
3476 && !option_was_set((char_u *)"ambiwidth")) | |
3477 { | |
3478 char_u buf[16]; | |
3479 | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3480 LOG_TR("Sending U7 request"); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3481 /* Do this in the second row. In the first row the returned sequence |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3482 * may be CSI 1;2R, which is the same as <S-F3>. */ |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3483 term_windgoto(1, 0); |
4215 | 3484 buf[mb_char2bytes(0x25bd, buf)] = 0; |
3485 out_str(buf); | |
3486 out_str(T_U7); | |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3487 u7_status = STATUS_SENT; |
5724 | 3488 out_flush(); |
11455
08e60ce4cbf3
patch 8.0.0611: the screen is not redrawn after sending t_u7
Christian Brabandt <cb@256bit.org>
parents:
11453
diff
changeset
|
3489 |
08e60ce4cbf3
patch 8.0.0611: the screen is not redrawn after sending t_u7
Christian Brabandt <cb@256bit.org>
parents:
11453
diff
changeset
|
3490 /* This overwrites a few characters on the screen, a redraw is needed |
08e60ce4cbf3
patch 8.0.0611: the screen is not redrawn after sending t_u7
Christian Brabandt <cb@256bit.org>
parents:
11453
diff
changeset
|
3491 * after this. Clear them out for now. */ |
5724 | 3492 term_windgoto(1, 0); |
4215 | 3493 out_str((char_u *)" "); |
3494 term_windgoto(0, 0); | |
11455
08e60ce4cbf3
patch 8.0.0611: the screen is not redrawn after sending t_u7
Christian Brabandt <cb@256bit.org>
parents:
11453
diff
changeset
|
3495 |
4215 | 3496 /* check for the characters now, otherwise they might be eaten by |
3497 * get_keystroke() */ | |
3498 out_flush(); | |
3499 (void)vpeekc_nomap(); | |
3500 } | |
3501 } | |
3502 # endif | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3503 |
6874 | 3504 /* |
6885 | 3505 * Similar to requesting the version string: Request the terminal background |
3506 * color when it is the right moment. | |
6874 | 3507 */ |
3508 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3509 may_req_bg_color(void) |
6874 | 3510 { |
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
|
3511 if (can_get_termresponse() && starting == 0) |
6874 | 3512 { |
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
|
3513 /* Only request background if t_RB is set and 'background' wasn't |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3514 * changed. */ |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3515 if (rbg_status == STATUS_GET |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3516 && *T_RBG != NUL |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3517 && !option_was_set((char_u *)"bg")) |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3518 { |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3519 LOG_TR("Sending BG request"); |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3520 out_str(T_RBG); |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3521 rbg_status = STATUS_SENT; |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
3522 |
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
|
3523 /* check for the characters now, otherwise they might be eaten by |
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
|
3524 * get_keystroke() */ |
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
|
3525 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
|
3526 (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
|
3527 } |
6874 | 3528 } |
3529 } | |
3530 | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3531 # ifdef DEBUG_TERMRESPONSE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3532 static void |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3533 log_tr(char *msg) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3534 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3535 static FILE *fd_tr = NULL; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3536 static proftime_T start; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3537 proftime_T now; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3538 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3539 if (fd_tr == NULL) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3540 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3541 fd_tr = fopen("termresponse.log", "w"); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3542 profile_start(&start); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3543 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3544 now = start; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3545 profile_end(&now); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3546 fprintf(fd_tr, "%s: %s %s\n", |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3547 profile_msg(&now), |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3548 must_redraw == NOT_VALID ? "NV" |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3549 : must_redraw == CLEAR ? "CL" : " ", |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3550 msg); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3551 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3552 # endif |
7 | 3553 #endif |
3554 | |
3555 /* | |
3556 * Return TRUE when saving and restoring the screen. | |
3557 */ | |
3558 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3559 swapping_screen(void) |
7 | 3560 { |
3561 return (full_screen && *T_TI != NUL); | |
3562 } | |
3563 | |
3564 #ifdef FEAT_MOUSE | |
3565 /* | |
3566 * setmouse() - switch mouse on/off depending on current mode and 'mouse' | |
3567 */ | |
3568 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3569 setmouse(void) |
7 | 3570 { |
3571 # ifdef FEAT_MOUSE_TTY | |
3572 int checkfor; | |
3573 # endif | |
3574 | |
3575 # ifdef FEAT_MOUSESHAPE | |
3576 update_mouseshape(-1); | |
3577 # endif | |
3578 | |
3579 # ifdef FEAT_MOUSE_TTY /* Should be outside proc, but may break MOUSESHAPE */ | |
3580 # ifdef FEAT_GUI | |
3581 /* In the GUI the mouse is always enabled. */ | |
3582 if (gui.in_use) | |
3583 return; | |
3584 # endif | |
3585 /* be quick when mouse is off */ | |
3586 if (*p_mouse == NUL || has_mouse_termcode == 0) | |
3587 return; | |
3588 | |
3589 /* don't switch mouse on when not in raw mode (Ex mode) */ | |
3590 if (cur_tmode != TMODE_RAW) | |
3591 { | |
3592 mch_setmouse(FALSE); | |
3593 return; | |
3594 } | |
3595 | |
3596 if (VIsual_active) | |
3597 checkfor = MOUSE_VISUAL; | |
5735 | 3598 else if (State == HITRETURN || State == ASKMORE || State == SETWSIZE) |
7 | 3599 checkfor = MOUSE_RETURN; |
3600 else if (State & INSERT) | |
3601 checkfor = MOUSE_INSERT; | |
3602 else if (State & CMDLINE) | |
3603 checkfor = MOUSE_COMMAND; | |
3604 else if (State == CONFIRM || State == EXTERNCMD) | |
3605 checkfor = ' '; /* don't use mouse for ":confirm" or ":!cmd" */ | |
3606 else | |
3607 checkfor = MOUSE_NORMAL; /* assume normal mode */ | |
3608 | |
3609 if (mouse_has(checkfor)) | |
3610 mch_setmouse(TRUE); | |
3611 else | |
3612 mch_setmouse(FALSE); | |
3613 # endif | |
3614 } | |
3615 | |
3616 /* | |
3617 * Return TRUE if | |
3618 * - "c" is in 'mouse', or | |
3619 * - 'a' is in 'mouse' and "c" is in MOUSE_A, or | |
3620 * - the current buffer is a help file and 'h' is in 'mouse' and we are in a | |
3621 * normal editing mode (not at hit-return message). | |
3622 */ | |
3623 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3624 mouse_has(int c) |
7 | 3625 { |
3626 char_u *p; | |
3627 | |
3628 for (p = p_mouse; *p; ++p) | |
3629 switch (*p) | |
3630 { | |
3631 case 'a': if (vim_strchr((char_u *)MOUSE_A, c) != NULL) | |
3632 return TRUE; | |
3633 break; | |
3634 case MOUSE_HELP: if (c != MOUSE_RETURN && curbuf->b_help) | |
3635 return TRUE; | |
3636 break; | |
3637 default: if (c == *p) return TRUE; break; | |
3638 } | |
3639 return FALSE; | |
3640 } | |
3641 | |
3642 /* | |
3643 * Return TRUE when 'mousemodel' is set to "popup" or "popup_setpos". | |
3644 */ | |
3645 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3646 mouse_model_popup(void) |
7 | 3647 { |
3648 return (p_mousem[0] == 'p'); | |
3649 } | |
3650 #endif | |
3651 | |
3652 /* | |
3653 * By outputting the 'cursor very visible' termcap code, for some windowed | |
3654 * terminals this makes the screen scrolled to the correct position. | |
3655 * Used when starting Vim or returning from a shell. | |
3656 */ | |
3657 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3658 scroll_start(void) |
7 | 3659 { |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3660 if (*T_VS != NUL && *T_CVS != NUL) |
7 | 3661 { |
3662 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
|
3663 out_str(T_CVS); |
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3664 screen_start(); /* don't know where cursor is now */ |
7 | 3665 } |
3666 } | |
3667 | |
3668 static int cursor_is_off = FALSE; | |
3669 | |
3670 /* | |
3671 * Enable the cursor. | |
3672 */ | |
3673 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3674 cursor_on(void) |
7 | 3675 { |
3676 if (cursor_is_off) | |
3677 { | |
3678 out_str(T_VE); | |
3679 cursor_is_off = FALSE; | |
3680 } | |
3681 } | |
3682 | |
3683 /* | |
3684 * Disable the cursor. | |
3685 */ | |
3686 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3687 cursor_off(void) |
7 | 3688 { |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3689 if (full_screen && !cursor_is_off) |
7 | 3690 { |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3691 out_str(T_VI); /* disable cursor */ |
7 | 3692 cursor_is_off = TRUE; |
3693 } | |
3694 } | |
3695 | |
39 | 3696 #if defined(CURSOR_SHAPE) || defined(PROTO) |
7 | 3697 /* |
6727 | 3698 * Set cursor shape to match Insert or Replace mode. |
36 | 3699 */ |
3700 void | |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3701 term_cursor_mode(int forced) |
36 | 3702 { |
12078
d21b8f31b296
patch 8.0.0919: cursor color isn't set on startup
Christian Brabandt <cb@256bit.org>
parents:
12076
diff
changeset
|
3703 static int showing_mode = -1; |
6727 | 3704 char_u *p; |
3705 | |
3706 /* Only do something when redrawing the screen and we can restore the | |
3707 * mode. */ | |
3708 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
|
3709 { |
12184
76fbd85c3cea
patch 8.0.0972: compiler warnings for unused variables
Christian Brabandt <cb@256bit.org>
parents:
12174
diff
changeset
|
3710 # 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
|
3711 if (forced && initial_cursor_shape > 0) |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3712 /* Restore to initial values. */ |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3713 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
|
3714 # endif |
36 | 3715 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
|
3716 } |
36 | 3717 |
6727 | 3718 if ((State & REPLACE) == REPLACE) |
36 | 3719 { |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3720 if (forced || showing_mode != REPLACE) |
6727 | 3721 { |
3722 if (*T_CSR != NUL) | |
3723 p = T_CSR; /* Replace mode cursor */ | |
3724 else | |
3725 p = T_CSI; /* fall back to Insert mode cursor */ | |
3726 if (*p != NUL) | |
3727 { | |
3728 out_str(p); | |
3729 showing_mode = REPLACE; | |
3730 } | |
3731 } | |
36 | 3732 } |
6727 | 3733 else if (State & INSERT) |
36 | 3734 { |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3735 if ((forced || showing_mode != INSERT) && *T_CSI != NUL) |
6727 | 3736 { |
3737 out_str(T_CSI); /* Insert mode cursor */ | |
3738 showing_mode = INSERT; | |
3739 } | |
3740 } | |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3741 else if (forced || showing_mode != NORMAL) |
6727 | 3742 { |
3743 out_str(T_CEI); /* non-Insert mode cursor */ | |
3744 showing_mode = NORMAL; | |
36 | 3745 } |
3746 } | |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3747 |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3748 # 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
|
3749 void |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3750 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
|
3751 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3752 if (*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
|
3753 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3754 out_str(T_CSC); /* set cursor color start */ |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3755 out_str_nf(color); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3756 out_str(T_CEC); /* set cursor color end */ |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3757 out_flush(); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3758 } |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3759 } |
12172
444793fce117
patch 8.0.0966: build failure without terminal feature
Christian Brabandt <cb@256bit.org>
parents:
12170
diff
changeset
|
3760 # endif |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3761 |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3762 int |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3763 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
|
3764 { |
12261
875d7cc9b127
patch 8.0.1010: build failure without termresponse feature
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3765 #ifdef FEAT_TERMRESPONSE |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3766 return rbm_status == STATUS_GOT && rcs_status == STATUS_GOT |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3767 && 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
|
3768 #else |
875d7cc9b127
patch 8.0.1010: build failure without termresponse feature
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3769 return FALSE; |
875d7cc9b127
patch 8.0.1010: build failure without termresponse feature
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3770 #endif |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3771 } |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3772 |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3773 /* |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3774 * "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
|
3775 */ |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3776 void |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3777 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
|
3778 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3779 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
|
3780 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3781 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
|
3782 out_flush(); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3783 } |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3784 else |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3785 { |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3786 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
|
3787 |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3788 /* t_SH is empty: try setting just the blink state. |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3789 * The blink flags are XORed together, if the initial blinking from |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3790 * style and shape differs, we need to invert the flag here. */ |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3791 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
|
3792 do_blink = !blink; |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3793 |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3794 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
|
3795 { |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3796 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
|
3797 out_flush(); |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3798 } |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3799 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
|
3800 { |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3801 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
|
3802 out_flush(); |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3803 } |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3804 } |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3805 } |
39 | 3806 #endif |
36 | 3807 |
3808 /* | |
7 | 3809 * Set scrolling region for window 'wp'. |
3810 * The region starts 'off' lines from the start of the window. | |
3811 * Also set the vertical scroll region for a vertically split window. Always | |
3812 * the full width of the window, excluding the vertical separator. | |
3813 */ | |
3814 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3815 scroll_region_set(win_T *wp, int off) |
7 | 3816 { |
3817 OUT_STR(tgoto((char *)T_CS, W_WINROW(wp) + wp->w_height - 1, | |
3818 W_WINROW(wp) + off)); | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
3819 #ifdef FEAT_WINDOWS |
7 | 3820 if (*T_CSV != NUL && wp->w_width != Columns) |
3821 OUT_STR(tgoto((char *)T_CSV, W_WINCOL(wp) + wp->w_width - 1, | |
3822 W_WINCOL(wp))); | |
3823 #endif | |
3824 screen_start(); /* don't know where cursor is now */ | |
3825 } | |
3826 | |
3827 /* | |
3828 * Reset scrolling region to the whole screen. | |
3829 */ | |
3830 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3831 scroll_region_reset(void) |
7 | 3832 { |
3833 OUT_STR(tgoto((char *)T_CS, (int)Rows - 1, 0)); | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
3834 #ifdef FEAT_WINDOWS |
7 | 3835 if (*T_CSV != NUL) |
3836 OUT_STR(tgoto((char *)T_CSV, (int)Columns - 1, 0)); | |
3837 #endif | |
3838 screen_start(); /* don't know where cursor is now */ | |
3839 } | |
3840 | |
3841 | |
3842 /* | |
3843 * List of terminal codes that are currently recognized. | |
3844 */ | |
3845 | |
298 | 3846 static struct termcode |
7 | 3847 { |
3848 char_u name[2]; /* termcap name of entry */ | |
3849 char_u *code; /* terminal code (in allocated memory) */ | |
3850 int len; /* STRLEN(code) */ | |
179 | 3851 int modlen; /* length of part before ";*~". */ |
7 | 3852 } *termcodes = NULL; |
3853 | |
3854 static int tc_max_len = 0; /* number of entries that termcodes[] can hold */ | |
3855 static int tc_len = 0; /* current number of entries in termcodes[] */ | |
3856 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
3857 static int termcode_star(char_u *code, int len); |
180 | 3858 |
7 | 3859 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3860 clear_termcodes(void) |
7 | 3861 { |
3862 while (tc_len > 0) | |
3863 vim_free(termcodes[--tc_len].code); | |
3864 vim_free(termcodes); | |
3865 termcodes = NULL; | |
3866 tc_max_len = 0; | |
3867 | |
3868 #ifdef HAVE_TGETENT | |
3869 BC = (char *)empty_option; | |
3870 UP = (char *)empty_option; | |
3871 PC = NUL; /* set pad character to NUL */ | |
3872 ospeed = 0; | |
3873 #endif | |
3874 | |
3875 need_gather = TRUE; /* need to fill termleader[] */ | |
3876 } | |
3877 | |
180 | 3878 #define ATC_FROM_TERM 55 |
3879 | |
7 | 3880 /* |
3881 * Add a new entry to the list of terminal codes. | |
3882 * The list is kept alphabetical for ":set termcap" | |
180 | 3883 * "flags" is TRUE when replacing 7-bit by 8-bit controls is desired. |
3884 * "flags" can also be ATC_FROM_TERM for got_code_from_term(). | |
7 | 3885 */ |
3886 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3887 add_termcode(char_u *name, char_u *string, int flags) |
7 | 3888 { |
3889 struct termcode *new_tc; | |
3890 int i, j; | |
3891 char_u *s; | |
179 | 3892 int len; |
7 | 3893 |
3894 if (string == NULL || *string == NUL) | |
3895 { | |
3896 del_termcode(name); | |
3897 return; | |
3898 } | |
3899 | |
6047 | 3900 #if defined(WIN3264) && !defined(FEAT_GUI) |
3901 s = vim_strnsave(string, (int)STRLEN(string) + 1); | |
3902 #else | |
7 | 3903 s = vim_strsave(string); |
6047 | 3904 #endif |
7 | 3905 if (s == NULL) |
3906 return; | |
3907 | |
3908 /* Change leading <Esc>[ to CSI, change <Esc>O to <M-O>. */ | |
180 | 3909 if (flags != 0 && flags != ATC_FROM_TERM && term_7to8bit(string) != 0) |
7 | 3910 { |
1623 | 3911 STRMOVE(s, s + 1); |
7 | 3912 s[0] = term_7to8bit(string); |
3913 } | |
6047 | 3914 |
3915 #if defined(WIN3264) && !defined(FEAT_GUI) | |
3916 if (s[0] == K_NUL) | |
3917 { | |
6102 | 3918 STRMOVE(s + 1, s); |
3919 s[1] = 3; | |
6047 | 3920 } |
3921 #endif | |
3922 | |
179 | 3923 len = (int)STRLEN(s); |
7 | 3924 |
3925 need_gather = TRUE; /* need to fill termleader[] */ | |
3926 | |
3927 /* | |
3928 * need to make space for more entries | |
3929 */ | |
3930 if (tc_len == tc_max_len) | |
3931 { | |
3932 tc_max_len += 20; | |
3933 new_tc = (struct termcode *)alloc( | |
3934 (unsigned)(tc_max_len * sizeof(struct termcode))); | |
3935 if (new_tc == NULL) | |
3936 { | |
3937 tc_max_len -= 20; | |
3938 return; | |
3939 } | |
3940 for (i = 0; i < tc_len; ++i) | |
3941 new_tc[i] = termcodes[i]; | |
3942 vim_free(termcodes); | |
3943 termcodes = new_tc; | |
3944 } | |
3945 | |
3946 /* | |
3947 * Look for existing entry with the same name, it is replaced. | |
3948 * Look for an existing entry that is alphabetical higher, the new entry | |
3949 * is inserted in front of it. | |
3950 */ | |
3951 for (i = 0; i < tc_len; ++i) | |
3952 { | |
3953 if (termcodes[i].name[0] < name[0]) | |
3954 continue; | |
3955 if (termcodes[i].name[0] == name[0]) | |
3956 { | |
3957 if (termcodes[i].name[1] < name[1]) | |
3958 continue; | |
3959 /* | |
180 | 3960 * Exact match: May replace old code. |
7 | 3961 */ |
3962 if (termcodes[i].name[1] == name[1]) | |
3963 { | |
180 | 3964 if (flags == ATC_FROM_TERM && (j = termcode_star( |
3965 termcodes[i].code, termcodes[i].len)) > 0) | |
179 | 3966 { |
180 | 3967 /* Don't replace ESC[123;*X or ESC O*X with another when |
3968 * invoked from got_code_from_term(). */ | |
3969 if (len == termcodes[i].len - j | |
179 | 3970 && STRNCMP(s, termcodes[i].code, len - 1) == 0 |
180 | 3971 && s[len - 1] |
3972 == termcodes[i].code[termcodes[i].len - 1]) | |
179 | 3973 { |
180 | 3974 /* They are equal but for the ";*": don't add it. */ |
179 | 3975 vim_free(s); |
3976 return; | |
3977 } | |
3978 } | |
3979 else | |
3980 { | |
180 | 3981 /* Replace old code. */ |
179 | 3982 vim_free(termcodes[i].code); |
3983 --tc_len; | |
3984 break; | |
3985 } | |
7 | 3986 } |
3987 } | |
3988 /* | |
3989 * Found alphabetical larger entry, move rest to insert new entry | |
3990 */ | |
3991 for (j = tc_len; j > i; --j) | |
3992 termcodes[j] = termcodes[j - 1]; | |
3993 break; | |
3994 } | |
3995 | |
3996 termcodes[i].name[0] = name[0]; | |
3997 termcodes[i].name[1] = name[1]; | |
3998 termcodes[i].code = s; | |
179 | 3999 termcodes[i].len = len; |
180 | 4000 |
4001 /* For xterm we recognize special codes like "ESC[42;*X" and "ESC O*X" that | |
4002 * accept modifiers. */ | |
4003 termcodes[i].modlen = 0; | |
4004 j = termcode_star(s, len); | |
4005 if (j > 0) | |
4006 termcodes[i].modlen = len - 1 - j; | |
7 | 4007 ++tc_len; |
4008 } | |
4009 | |
180 | 4010 /* |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
4011 * Check termcode "code[len]" for ending in ;*X or *X. |
180 | 4012 * 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
|
4013 * Return 0 if not found, 2 for ;*X and 1 for *X. |
180 | 4014 */ |
4015 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4016 termcode_star(char_u *code, int len) |
180 | 4017 { |
4018 /* Shortest is <M-O>*X. With ; shortest is <CSI>1;*X */ | |
4019 if (len >= 3 && code[len - 2] == '*') | |
4020 { | |
4021 if (len >= 5 && code[len - 3] == ';') | |
4022 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
|
4023 else |
180 | 4024 return 1; |
4025 } | |
4026 return 0; | |
4027 } | |
4028 | |
7 | 4029 char_u * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4030 find_termcode(char_u *name) |
7 | 4031 { |
4032 int i; | |
4033 | |
4034 for (i = 0; i < tc_len; ++i) | |
4035 if (termcodes[i].name[0] == name[0] && termcodes[i].name[1] == name[1]) | |
4036 return termcodes[i].code; | |
4037 return NULL; | |
4038 } | |
4039 | |
4040 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) | |
4041 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4042 get_termcode(int i) |
7 | 4043 { |
4044 if (i >= tc_len) | |
4045 return NULL; | |
4046 return &termcodes[i].name[0]; | |
4047 } | |
4048 #endif | |
4049 | |
4050 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4051 del_termcode(char_u *name) |
7 | 4052 { |
4053 int i; | |
4054 | |
4055 if (termcodes == NULL) /* nothing there yet */ | |
4056 return; | |
4057 | |
4058 need_gather = TRUE; /* need to fill termleader[] */ | |
4059 | |
4060 for (i = 0; i < tc_len; ++i) | |
4061 if (termcodes[i].name[0] == name[0] && termcodes[i].name[1] == name[1]) | |
4062 { | |
4063 del_termcode_idx(i); | |
4064 return; | |
4065 } | |
4066 /* not found. Give error message? */ | |
4067 } | |
4068 | |
4069 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4070 del_termcode_idx(int idx) |
7 | 4071 { |
4072 int i; | |
4073 | |
4074 vim_free(termcodes[idx].code); | |
4075 --tc_len; | |
4076 for (i = idx; i < tc_len; ++i) | |
4077 termcodes[i] = termcodes[i + 1]; | |
4078 } | |
4079 | |
4080 #ifdef FEAT_TERMRESPONSE | |
4081 /* | |
4082 * Called when detected that the terminal sends 8-bit codes. | |
4083 * Convert all 7-bit codes to their 8-bit equivalent. | |
4084 */ | |
4085 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4086 switch_to_8bit(void) |
7 | 4087 { |
4088 int i; | |
4089 int c; | |
4090 | |
4091 /* Only need to do something when not already using 8-bit codes. */ | |
4092 if (!term_is_8bit(T_NAME)) | |
4093 { | |
4094 for (i = 0; i < tc_len; ++i) | |
4095 { | |
4096 c = term_7to8bit(termcodes[i].code); | |
4097 if (c != 0) | |
4098 { | |
1623 | 4099 STRMOVE(termcodes[i].code + 1, termcodes[i].code + 2); |
7 | 4100 termcodes[i].code[0] = c; |
4101 } | |
4102 } | |
4103 need_gather = TRUE; /* need to fill termleader[] */ | |
4104 } | |
4105 detected_8bit = TRUE; | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4106 LOG_TR("Switching to 8 bit"); |
7 | 4107 } |
4108 #endif | |
4109 | |
4110 #ifdef CHECK_DOUBLE_CLICK | |
4111 static linenr_T orig_topline = 0; | |
4112 # ifdef FEAT_DIFF | |
4113 static int orig_topfill = 0; | |
4114 # endif | |
4115 #endif | |
4116 #if (defined(FEAT_WINDOWS) && defined(CHECK_DOUBLE_CLICK)) || defined(PROTO) | |
4117 /* | |
4118 * Checking for double clicks ourselves. | |
4119 * "orig_topline" is used to avoid detecting a double-click when the window | |
4120 * contents scrolled (e.g., when 'scrolloff' is non-zero). | |
4121 */ | |
4122 /* | |
4123 * Set orig_topline. Used when jumping to another window, so that a double | |
4124 * click still works. | |
4125 */ | |
4126 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4127 set_mouse_topline(win_T *wp) |
7 | 4128 { |
4129 orig_topline = wp->w_topline; | |
4130 # ifdef FEAT_DIFF | |
4131 orig_topfill = wp->w_topfill; | |
4132 # endif | |
4133 } | |
4134 #endif | |
4135 | |
4136 /* | |
4137 * Check if typebuf.tb_buf[] contains a terminal key code. | |
4138 * Check from typebuf.tb_buf[typebuf.tb_off] to typebuf.tb_buf[typebuf.tb_off | |
4139 * + max_offset]. | |
4140 * Return 0 for no match, -1 for partial match, > 0 for full match. | |
2672 | 4141 * Return KEYLEN_REMOVED when a key code was deleted. |
7 | 4142 * With a match, the match is removed, the replacement code is inserted in |
4143 * typebuf.tb_buf[] and the number of characters in typebuf.tb_buf[] is | |
4144 * returned. | |
3328 | 4145 * When "buf" is not NULL, buf[bufsize] is used instead of typebuf.tb_buf[]. |
4146 * "buflen" is then the length of the string in buf[] and is updated for | |
4147 * inserts and deletes. | |
7 | 4148 */ |
4149 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4150 check_termcode( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4151 int max_offset, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4152 char_u *buf, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4153 int bufsize, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4154 int *buflen) |
7 | 4155 { |
4156 char_u *tp; | |
4157 char_u *p; | |
4158 int slen = 0; /* init for GCC */ | |
180 | 4159 int modslen; |
7 | 4160 int len; |
2672 | 4161 int retval = 0; |
7 | 4162 int offset; |
4163 char_u key_name[2]; | |
180 | 4164 int modifiers; |
11565
91519a14ec1f
patch 8.0.0665: warning for uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
11563
diff
changeset
|
4165 char_u *modifiers_start = NULL; |
180 | 4166 int key; |
7 | 4167 int new_slen; |
4168 int extra; | |
4169 char_u string[MAX_KEY_CODE_LEN + 1]; | |
4170 int i, j; | |
4171 int idx = 0; | |
4172 #ifdef FEAT_MOUSE | |
1623 | 4173 # if !defined(UNIX) || defined(FEAT_MOUSE_XTERM) || defined(FEAT_GUI) \ |
4174 || defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE) | |
7 | 4175 char_u bytes[6]; |
4176 int num_bytes; | |
4177 # endif | |
4178 int mouse_code = 0; /* init for GCC */ | |
4179 int is_click, is_drag; | |
4180 int wheel_code = 0; | |
4181 int current_button; | |
4182 static int held_button = MOUSE_RELEASE; | |
4183 static int orig_num_clicks = 1; | |
4184 static int orig_mouse_code = 0x0; | |
4185 # ifdef CHECK_DOUBLE_CLICK | |
4186 static int orig_mouse_col = 0; | |
4187 static int orig_mouse_row = 0; | |
4188 static struct timeval orig_mouse_time = {0, 0}; | |
4189 /* time of previous mouse click */ | |
4190 struct timeval mouse_time; /* time of current mouse click */ | |
4191 long timediff; /* elapsed time in msec */ | |
4192 # endif | |
4193 #endif | |
4194 int cpo_koffset; | |
4195 #ifdef FEAT_MOUSE_GPM | |
4196 extern int gpm_flag; /* gpm library variable */ | |
4197 #endif | |
4198 | |
4199 cpo_koffset = (vim_strchr(p_cpo, CPO_KOFFSET) != NULL); | |
4200 | |
4201 /* | |
4202 * Speed up the checks for terminal codes by gathering all first bytes | |
4203 * used in termleader[]. Often this is just a single <Esc>. | |
4204 */ | |
4205 if (need_gather) | |
4206 gather_termleader(); | |
4207 | |
4208 /* | |
4209 * Check at several positions in typebuf.tb_buf[], to catch something like | |
4210 * "x<Up>" that can be mapped. Stop at max_offset, because characters | |
4211 * after that cannot be used for mapping, and with @r commands | |
4223 | 4212 * typebuf.tb_buf[] can become very long. |
7 | 4213 * This is used often, KEEP IT FAST! |
4214 */ | |
4215 for (offset = 0; offset < max_offset; ++offset) | |
4216 { | |
4217 if (buf == NULL) | |
4218 { | |
4219 if (offset >= typebuf.tb_len) | |
4220 break; | |
4221 tp = typebuf.tb_buf + typebuf.tb_off + offset; | |
4222 len = typebuf.tb_len - offset; /* length of the input */ | |
4223 } | |
4224 else | |
4225 { | |
3328 | 4226 if (offset >= *buflen) |
7 | 4227 break; |
4228 tp = buf + offset; | |
3328 | 4229 len = *buflen - offset; |
7 | 4230 } |
4231 | |
4232 /* | |
4233 * Don't check characters after K_SPECIAL, those are already | |
4234 * translated terminal chars (avoid translating ~@^Hx). | |
4235 */ | |
4236 if (*tp == K_SPECIAL) | |
4237 { | |
4238 offset += 2; /* there are always 2 extra characters */ | |
4239 continue; | |
4240 } | |
4241 | |
4242 /* | |
4243 * Skip this position if the character does not appear as the first | |
4244 * character in term_strings. This speeds up a lot, since most | |
4245 * termcodes start with the same character (ESC or CSI). | |
4246 */ | |
4247 i = *tp; | |
4248 for (p = termleader; *p && *p != i; ++p) | |
4249 ; | |
4250 if (*p == NUL) | |
4251 continue; | |
4252 | |
4253 /* | |
4254 * Skip this position if p_ek is not set and tp[0] is an ESC and we | |
4255 * are in Insert mode. | |
4256 */ | |
4257 if (*tp == ESC && !p_ek && (State & INSERT)) | |
4258 continue; | |
4259 | |
4260 key_name[0] = NUL; /* no key name found yet */ | |
699 | 4261 key_name[1] = NUL; /* no key name found yet */ |
180 | 4262 modifiers = 0; /* no modifiers yet */ |
7 | 4263 |
4264 #ifdef FEAT_GUI | |
4265 if (gui.in_use) | |
4266 { | |
4267 /* | |
4268 * GUI special key codes are all of the form [CSI xx]. | |
4269 */ | |
4270 if (*tp == CSI) /* Special key from GUI */ | |
4271 { | |
4272 if (len < 3) | |
4273 return -1; /* Shouldn't happen */ | |
4274 slen = 3; | |
4275 key_name[0] = tp[1]; | |
4276 key_name[1] = tp[2]; | |
4277 } | |
4278 } | |
4279 else | |
4280 #endif /* FEAT_GUI */ | |
4281 { | |
4282 for (idx = 0; idx < tc_len; ++idx) | |
4283 { | |
4284 /* | |
4285 * Ignore the entry if we are not at the start of | |
4286 * typebuf.tb_buf[] | |
4287 * and there are not enough characters to make a match. | |
4288 * But only when the 'K' flag is in 'cpoptions'. | |
4289 */ | |
4290 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
|
4291 modifiers_start = NULL; |
7 | 4292 if (cpo_koffset && offset && len < slen) |
4293 continue; | |
4294 if (STRNCMP(termcodes[idx].code, tp, | |
4295 (size_t)(slen > len ? len : slen)) == 0) | |
4296 { | |
4297 if (len < slen) /* got a partial sequence */ | |
4298 return -1; /* need to get more chars */ | |
4299 | |
4300 /* | |
4301 * When found a keypad key, check if there is another key | |
4302 * that matches and use that one. This makes <Home> to be | |
4303 * found instead of <kHome> when they produce the same | |
4304 * key code. | |
4305 */ | |
4306 if (termcodes[idx].name[0] == 'K' | |
4307 && VIM_ISDIGIT(termcodes[idx].name[1])) | |
4308 { | |
4309 for (j = idx + 1; j < tc_len; ++j) | |
4310 if (termcodes[j].len == slen && | |
4311 STRNCMP(termcodes[idx].code, | |
4312 termcodes[j].code, slen) == 0) | |
4313 { | |
4314 idx = j; | |
4315 break; | |
4316 } | |
4317 } | |
4318 | |
4319 key_name[0] = termcodes[idx].name[0]; | |
4320 key_name[1] = termcodes[idx].name[1]; | |
4321 break; | |
4322 } | |
179 | 4323 |
4324 /* | |
4325 * Check for code with modifier, like xterm uses: | |
180 | 4326 * <Esc>[123;*X (modslen == slen - 3) |
4327 * Also <Esc>O*X and <M-O>*X (modslen == slen - 2). | |
4328 * When there is a modifier the * matches a number. | |
4329 * When there is no modifier the ;* or * is omitted. | |
179 | 4330 */ |
4331 if (termcodes[idx].modlen > 0) | |
4332 { | |
180 | 4333 modslen = termcodes[idx].modlen; |
4334 if (cpo_koffset && offset && len < modslen) | |
179 | 4335 continue; |
4336 if (STRNCMP(termcodes[idx].code, tp, | |
180 | 4337 (size_t)(modslen > len ? len : modslen)) == 0) |
179 | 4338 { |
4339 int n; | |
180 | 4340 |
4341 if (len <= modslen) /* got a partial sequence */ | |
179 | 4342 return -1; /* need to get more chars */ |
4343 | |
180 | 4344 if (tp[modslen] == termcodes[idx].code[slen - 1]) |
4345 slen = modslen + 1; /* no modifiers */ | |
4346 else if (tp[modslen] != ';' && modslen == slen - 3) | |
179 | 4347 continue; /* no match */ |
4348 else | |
4349 { | |
4350 /* Skip over the digits, the final char must | |
4351 * follow. */ | |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4352 for (j = slen - 2; j < len && (isdigit(tp[j]) |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4353 || tp[j] == ';'); ++j) |
179 | 4354 ; |
4355 ++j; | |
4356 if (len < j) /* got a partial sequence */ | |
4357 return -1; /* need to get more chars */ | |
180 | 4358 if (tp[j - 1] != termcodes[idx].code[slen - 1]) |
4359 continue; /* no match */ | |
179 | 4360 |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
4361 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
|
4362 |
179 | 4363 /* Match! Convert modifier bits. */ |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
4364 n = atoi((char *)modifiers_start) - 1; |
179 | 4365 if (n & 1) |
180 | 4366 modifiers |= MOD_MASK_SHIFT; |
179 | 4367 if (n & 2) |
180 | 4368 modifiers |= MOD_MASK_ALT; |
179 | 4369 if (n & 4) |
180 | 4370 modifiers |= MOD_MASK_CTRL; |
179 | 4371 if (n & 8) |
180 | 4372 modifiers |= MOD_MASK_META; |
179 | 4373 |
4374 slen = j; | |
4375 } | |
4376 key_name[0] = termcodes[idx].name[0]; | |
4377 key_name[1] = termcodes[idx].name[1]; | |
4378 break; | |
4379 } | |
4380 } | |
7 | 4381 } |
4382 } | |
4383 | |
4384 #ifdef FEAT_TERMRESPONSE | |
3166 | 4385 if (key_name[0] == NUL |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
4386 /* Mouse codes of DEC and pterm start with <ESC>[. When |
6102 | 4387 * detecting the start of these mouse codes they might as well be |
4388 * another key code or terminal response. */ | |
4389 # ifdef FEAT_MOUSE_DEC | |
4390 || key_name[0] == KS_DEC_MOUSE | |
4391 # endif | |
4392 # ifdef FEAT_MOUSE_PTERM | |
4393 || key_name[0] == KS_PTERM_MOUSE | |
4223 | 4394 # endif |
6102 | 4395 ) |
7 | 4396 { |
6102 | 4397 /* Check for some responses from the terminal starting with |
4398 * "<Esc>[" or CSI: | |
4215 | 4399 * |
6102 | 4400 * - Xterm version string: <Esc>[>{x};{vers};{y}c |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
4401 * Libvterm returns {x} == 0, {vers} == 100, {y} == 0. |
4215 | 4402 * Also eat other possible responses to t_RV, rxvt returns |
4403 * "<Esc>[?1;2c". Also accept CSI instead of <Esc>[. | |
4404 * mrxvt has been reported to have "+" in the version. Assume | |
4405 * the escape sequence ends with a letter or one of "{|}~". | |
4406 * | |
6102 | 4407 * - Cursor position report: <Esc>[{row};{col}R |
4408 * The final byte must be 'R'. It is used for checking the | |
4215 | 4409 * 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
|
4410 * |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4411 * - window position reply: <Esc>[3;{x};{y}t |
4215 | 4412 */ |
6901 | 4413 char_u *argp = tp[0] == ESC ? tp + 2 : tp + 1; |
4414 | |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4415 if ((*T_CRV != NUL || *T_U7 != NUL || waiting_for_winpos) |
6901 | 4416 && ((tp[0] == ESC && len >= 3 && tp[1] == '[') |
4395 | 4417 || (tp[0] == CSI && len >= 2)) |
6874 | 4418 && (VIM_ISDIGIT(*argp) || *argp == '>' || *argp == '?')) |
7 | 4419 { |
11784
80fa4b0eb0b0
patch 8.0.0774: build failure without the multi-byte feature
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
4420 int col = 0; |
80fa4b0eb0b0
patch 8.0.0774: build failure without the multi-byte feature
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
4421 int semicols = 0; |
5724 | 4422 #ifdef FEAT_MBYTE |
5743 | 4423 int row_char = NUL; |
5724 | 4424 #endif |
11784
80fa4b0eb0b0
patch 8.0.0774: build failure without the multi-byte feature
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
4425 |
7 | 4426 extra = 0; |
1552 | 4427 for (i = 2 + (tp[0] != CSI); i < len |
4428 && !(tp[i] >= '{' && tp[i] <= '~') | |
4429 && !ASCII_ISALPHA(tp[i]); ++i) | |
11784
80fa4b0eb0b0
patch 8.0.0774: build failure without the multi-byte feature
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
4430 if (tp[i] == ';' && ++semicols == 1) |
5724 | 4431 { |
4395 | 4432 extra = i + 1; |
5724 | 4433 #ifdef FEAT_MBYTE |
4434 row_char = tp[i - 1]; | |
4435 #endif | |
4436 } | |
7 | 4437 if (i == len) |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4438 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4439 LOG_TR("Not enough characters for CRV"); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4440 return -1; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4441 } |
5724 | 4442 if (extra > 0) |
4443 col = atoi((char *)tp + extra); | |
11784
80fa4b0eb0b0
patch 8.0.0774: build failure without the multi-byte feature
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
4444 |
80fa4b0eb0b0
patch 8.0.0774: build failure without the multi-byte feature
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
4445 #ifdef FEAT_MBYTE |
5724 | 4446 /* Eat it when it has 2 arguments and ends in 'R'. Also when |
4447 * u7_status is not "sent", it may be from a previous Vim that | |
4448 * just exited. But not for <S-F3>, it sends something | |
4449 * similar, check for row and column to make sense. */ | |
11784
80fa4b0eb0b0
patch 8.0.0774: build failure without the multi-byte feature
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
4450 if (semicols == 1 && tp[i] == 'R') |
4215 | 4451 { |
6102 | 4452 if (row_char == '2' && col >= 2) |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4453 { |
6102 | 4454 char *aw = NULL; |
4455 | |
4456 LOG_TR("Received U7 status"); | |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4457 u7_status = STATUS_GOT; |
6102 | 4458 # ifdef FEAT_AUTOCMD |
4459 did_cursorhold = TRUE; | |
4460 # endif | |
4461 if (col == 2) | |
4462 aw = "single"; | |
4463 else if (col == 3) | |
4464 aw = "double"; | |
4465 if (aw != NULL && STRCMP(aw, p_ambw) != 0) | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4466 { |
6102 | 4467 /* Setting the option causes a screen redraw. Do |
4468 * that right away if possible, keeping any | |
4469 * messages. */ | |
4470 set_option_value((char_u *)"ambw", 0L, | |
4471 (char_u *)aw, 0); | |
4472 # ifdef DEBUG_TERMRESPONSE | |
4473 { | |
4474 char buf[100]; | |
4475 int r = redraw_asap(CLEAR); | |
4476 | |
4477 sprintf(buf, | |
4478 "set 'ambiwidth', redraw_asap(): %d", | |
4479 r); | |
4480 log_tr(buf); | |
4481 } | |
4482 # else | |
4483 redraw_asap(CLEAR); | |
4484 # endif | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4485 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4486 } |
4215 | 4487 key_name[0] = (int)KS_EXTRA; |
4488 key_name[1] = (int)KE_IGNORE; | |
4489 slen = i + 1; | |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4490 # ifdef FEAT_EVAL |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4491 set_vim_var_string(VV_TERMU7RESP, tp, slen); |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4492 # endif |
4215 | 4493 } |
4494 else | |
4495 #endif | |
7 | 4496 /* eat it when at least one digit and ending in 'c' */ |
4215 | 4497 if (*T_CRV != NUL && i > 2 + (tp[0] != CSI) && tp[i] == 'c') |
7 | 4498 { |
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
|
4499 LOG_TR("Received CRV response"); |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4500 crv_status = STATUS_GOT; |
4262 | 4501 # ifdef FEAT_AUTOCMD |
4502 did_cursorhold = TRUE; | |
4503 # endif | |
7 | 4504 |
4505 /* If this code starts with CSI, you can bet that the | |
4506 * terminal uses 8-bit codes. */ | |
4507 if (tp[0] == CSI) | |
4508 switch_to_8bit(); | |
4509 | |
4510 /* rxvt sends its version number: "20703" is 2.7.3. | |
4511 * Ignore it for when the user has set 'term' to xterm, | |
4512 * even though it's an rxvt. */ | |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
4513 if (col > 20000) |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
4514 col = 0; |
7 | 4515 |
11784
80fa4b0eb0b0
patch 8.0.0774: build failure without the multi-byte feature
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
4516 if (tp[1 + (tp[0] != CSI)] == '>' && semicols == 2) |
7 | 4517 { |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4518 int need_flush = FALSE; |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4519 |
3885 | 4520 /* Only set 'ttymouse' automatically if it was not set |
4521 * by the user already. */ | |
4522 if (!option_was_set((char_u *)"ttym")) | |
4523 { | |
3746 | 4524 # ifdef TTYM_SGR |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
4525 if (col >= 277) |
3885 | 4526 set_option_value((char_u *)"ttym", 0L, |
3746 | 4527 (char_u *)"sgr", 0); |
3885 | 4528 else |
3746 | 4529 # endif |
3885 | 4530 /* if xterm version >= 95 use mouse dragging */ |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
4531 if (col >= 95) |
3885 | 4532 set_option_value((char_u *)"ttym", 0L, |
7 | 4533 (char_u *)"xterm2", 0); |
3885 | 4534 } |
4535 | |
7 | 4536 /* if xterm version >= 141 try to get termcap codes */ |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
4537 if (col >= 141) |
7 | 4538 { |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4539 LOG_TR("Enable checking for XT codes"); |
7 | 4540 check_for_codes = TRUE; |
4541 need_gather = TRUE; | |
4542 req_codes_from_term(); | |
4543 } | |
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
|
4544 |
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
|
4545 /* libvterm sends 0;100;0 */ |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
4546 if (col == 100 |
12234
2b333727279d
patch 8.0.0997 Problem: Libvterm and Terminal.app not regognized from termresponse. Solution: Adjust string compare.
Christian Brabandt <cb@256bit.org>
parents:
12232
diff
changeset
|
4547 && STRNCMP(tp + extra - 2, "0;100;0c", 8) == 0) |
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
|
4548 { |
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
|
4549 /* If run from Vim $COLORS is set to the number of |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
4550 * colors the terminal supports. Otherwise assume |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
4551 * 256, libvterm supports even more. */ |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
4552 if (mch_getenv((char_u *)"COLORS") == NULL) |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
4553 may_adjust_color_count(256); |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
4554 } |
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
|
4555 |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4556 /* Detect terminals that set $TERM to something like |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4557 * "xterm-256colors" but are not fully xterm |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4558 * compatible. */ |
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
|
4559 # ifdef MACOS |
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
|
4560 /* Mac Terminal.app sends 1;95;0 */ |
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
|
4561 if (col == 95 |
12234
2b333727279d
patch 8.0.0997 Problem: Libvterm and Terminal.app not regognized from termresponse. Solution: Adjust string compare.
Christian Brabandt <cb@256bit.org>
parents:
12232
diff
changeset
|
4562 && STRNCMP(tp + extra - 2, "1;95;0c", 7) == 0) |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4563 is_not_xterm = TRUE; |
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
|
4564 # endif |
12295
270256b6d0b8
patch 8.0.1027: more terminals can't handle requesting cursor mode
Christian Brabandt <cb@256bit.org>
parents:
12283
diff
changeset
|
4565 /* Gnome terminal sends 1;3801;0 or 1;4402;0. |
270256b6d0b8
patch 8.0.1027: more terminals can't handle requesting cursor mode
Christian Brabandt <cb@256bit.org>
parents:
12283
diff
changeset
|
4566 * xfce4-terminal sends 1;2802;0. |
270256b6d0b8
patch 8.0.1027: more terminals can't handle requesting cursor mode
Christian Brabandt <cb@256bit.org>
parents:
12283
diff
changeset
|
4567 * Assuming any version number over 2800 is not an |
12283
decfedf9138d
patch 8.0.1021: older Gnome terminal still echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12273
diff
changeset
|
4568 * xterm. */ |
12295
270256b6d0b8
patch 8.0.1027: more terminals can't handle requesting cursor mode
Christian Brabandt <cb@256bit.org>
parents:
12283
diff
changeset
|
4569 if (col >= 2800) |
270256b6d0b8
patch 8.0.1027: more terminals can't handle requesting cursor mode
Christian Brabandt <cb@256bit.org>
parents:
12283
diff
changeset
|
4570 is_not_xterm = TRUE; |
270256b6d0b8
patch 8.0.1027: more terminals can't handle requesting cursor mode
Christian Brabandt <cb@256bit.org>
parents:
12283
diff
changeset
|
4571 |
270256b6d0b8
patch 8.0.1027: more terminals can't handle requesting cursor mode
Christian Brabandt <cb@256bit.org>
parents:
12283
diff
changeset
|
4572 /* PuTTY sends 0;136;0 */ |
270256b6d0b8
patch 8.0.1027: more terminals can't handle requesting cursor mode
Christian Brabandt <cb@256bit.org>
parents:
12283
diff
changeset
|
4573 if (col == 136 |
270256b6d0b8
patch 8.0.1027: more terminals can't handle requesting cursor mode
Christian Brabandt <cb@256bit.org>
parents:
12283
diff
changeset
|
4574 && STRNCMP(tp + extra - 2, "0;136;0c", 8) == 0) |
270256b6d0b8
patch 8.0.1027: more terminals can't handle requesting cursor mode
Christian Brabandt <cb@256bit.org>
parents:
12283
diff
changeset
|
4575 is_not_xterm = TRUE; |
270256b6d0b8
patch 8.0.1027: more terminals can't handle requesting cursor mode
Christian Brabandt <cb@256bit.org>
parents:
12283
diff
changeset
|
4576 |
270256b6d0b8
patch 8.0.1027: more terminals can't handle requesting cursor mode
Christian Brabandt <cb@256bit.org>
parents:
12283
diff
changeset
|
4577 /* Konsole sends 0;115;0 */ |
270256b6d0b8
patch 8.0.1027: more terminals can't handle requesting cursor mode
Christian Brabandt <cb@256bit.org>
parents:
12283
diff
changeset
|
4578 if (col == 115 |
270256b6d0b8
patch 8.0.1027: more terminals can't handle requesting cursor mode
Christian Brabandt <cb@256bit.org>
parents:
12283
diff
changeset
|
4579 && STRNCMP(tp + extra - 2, "0;115;0c", 8) == 0) |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4580 is_not_xterm = TRUE; |
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
|
4581 |
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
|
4582 /* Only request the cursor style if t_SH and t_RS are |
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
|
4583 * set. Not for Terminal.app, it can't handle t_RS, it |
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
|
4584 * echoes the characters to the screen. */ |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4585 if (rcs_status == STATUS_GET |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4586 && !is_not_xterm |
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
|
4587 && *T_CSH != NUL |
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
|
4588 && *T_CRS != NUL) |
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
|
4589 { |
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
|
4590 LOG_TR("Sending cursor style request"); |
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
|
4591 out_str(T_CRS); |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4592 rcs_status = STATUS_SENT; |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4593 need_flush = TRUE; |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4594 } |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4595 |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4596 /* Only request the cursor blink mode if t_RC set. Not |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4597 * for Gnome terminal, it can't handle t_RC, it |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4598 * echoes the characters to the screen. */ |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4599 if (rbm_status == STATUS_GET |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4600 && !is_not_xterm |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4601 && *T_CRC != NUL) |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4602 { |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4603 LOG_TR("Sending cursor blink mode request"); |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4604 out_str(T_CRC); |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4605 rbm_status = STATUS_SENT; |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4606 need_flush = TRUE; |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4607 } |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4608 |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4609 if (need_flush) |
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
|
4610 out_flush(); |
7 | 4611 } |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4612 slen = i + 1; |
7 | 4613 # ifdef FEAT_EVAL |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4614 set_vim_var_string(VV_TERMRESPONSE, tp, slen); |
7 | 4615 # endif |
4616 # ifdef FEAT_AUTOCMD | |
4617 apply_autocmds(EVENT_TERMRESPONSE, | |
4618 NULL, NULL, FALSE, curbuf); | |
4619 # endif | |
4620 key_name[0] = (int)KS_EXTRA; | |
4621 key_name[1] = (int)KE_IGNORE; | |
4622 } | |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4623 |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4624 /* Check blinking cursor from xterm: |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4625 * {lead}?12;1$y set |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4626 * {lead}?12;2$y not set |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4627 * |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4628 * {lead} can be <Esc>[ or CSI |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4629 */ |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4630 else if (rbm_status == STATUS_SENT |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4631 && tp[(j = 1 + (tp[0] == ESC))] == '?' |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4632 && i == j + 6 |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4633 && tp[j + 1] == '1' |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4634 && tp[j + 2] == '2' |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4635 && tp[j + 3] == ';' |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4636 && tp[i - 1] == '$' |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4637 && tp[i] == 'y') |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4638 { |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4639 initial_cursor_blink = (tp[j + 4] == '1'); |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4640 rbm_status = STATUS_GOT; |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4641 LOG_TR("Received cursor blinking mode response"); |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4642 key_name[0] = (int)KS_EXTRA; |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4643 key_name[1] = (int)KE_IGNORE; |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4644 slen = i + 1; |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4645 # ifdef FEAT_EVAL |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4646 set_vim_var_string(VV_TERMBLINKRESP, tp, slen); |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4647 # endif |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4648 } |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4649 |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4650 /* |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4651 * Check for a window position response from the terminal: |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4652 * {lead}3;{x}:{y}t |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4653 */ |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4654 else if (waiting_for_winpos |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4655 && ((len >= 4 && tp[0] == ESC && tp[1] == '[') |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4656 || (len >= 3 && tp[0] == CSI)) |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4657 && tp[(j = 1 + (tp[0] == ESC))] == '3' |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4658 && tp[j + 1] == ';') |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4659 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4660 j += 2; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4661 for (i = j; i < len && vim_isdigit(tp[i]); ++i) |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4662 ; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4663 if (i < len && tp[i] == ';') |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4664 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4665 winpos_x = atoi((char *)tp + j); |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4666 j = i + 1; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4667 for (i = j; i < len && vim_isdigit(tp[i]); ++i) |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4668 ; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4669 if (i < len && tp[i] == 't') |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4670 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4671 winpos_y = atoi((char *)tp + j); |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4672 /* got finished code: consume it */ |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4673 key_name[0] = (int)KS_EXTRA; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4674 key_name[1] = (int)KE_IGNORE; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4675 slen = i + 1; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4676 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4677 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4678 if (i == len) |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4679 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4680 LOG_TR("not enough characters for winpos"); |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4681 return -1; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4682 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4683 } |
6901 | 4684 } |
4685 | |
4686 /* Check for background color response from the terminal: | |
4687 * | |
4688 * {lead}11;rgb:{rrrr}/{gggg}/{bbbb}{tail} | |
4689 * | |
4690 * {lead} can be <Esc>] or OSC | |
4691 * {tail} can be '\007', <Esc>\ or STERM. | |
4692 * | |
4693 * Consume any code that starts with "{lead}11;", it's also | |
4694 * possible that "rgba" is following. | |
4695 */ | |
4696 else if (*T_RBG != NUL | |
4697 && ((tp[0] == ESC && len >= 2 && tp[1] == ']') | |
4698 || tp[0] == OSC)) | |
4699 { | |
4700 j = 1 + (tp[0] == ESC); | |
4701 if (len >= j + 3 && (argp[0] != '1' | |
4702 || argp[1] != '1' || argp[2] != ';')) | |
4703 i = 0; /* no match */ | |
4704 else | |
4705 for (i = j; i < len; ++i) | |
4706 if (tp[i] == '\007' || (tp[0] == OSC ? tp[i] == STERM | |
4707 : (tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\'))) | |
4708 { | |
4709 if (i - j >= 21 && STRNCMP(tp + j + 3, "rgb:", 4) == 0 | |
4710 && tp[j + 11] == '/' && tp[j + 16] == '/' | |
4711 && !option_was_set((char_u *)"bg")) | |
11453
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4712 { |
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4713 char *newval = (3 * '6' < tp[j+7] + tp[j+12] |
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4714 + tp[j+17]) ? "light" : "dark"; |
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4715 |
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
|
4716 LOG_TR("Received RBG response"); |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4717 rbg_status = STATUS_GOT; |
11453
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4718 if (STRCMP(p_bg, newval) != 0) |
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4719 { |
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4720 /* value differs, apply it */ |
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4721 set_option_value((char_u *)"bg", 0L, |
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4722 (char_u *)newval, 0); |
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4723 reset_option_was_set((char_u *)"bg"); |
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4724 redraw_asap(CLEAR); |
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4725 } |
6901 | 4726 } |
4727 | |
4728 /* got finished code: consume it */ | |
4729 key_name[0] = (int)KS_EXTRA; | |
4730 key_name[1] = (int)KE_IGNORE; | |
4731 slen = i + 1 + (tp[i] == ESC); | |
12226
2b965b3dd20c
patch 8.0.0993: sometimes an xterm sends an extra CTRL-X
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
4732 if (tp[i] == 0x07 && i + 1 < len && tp[i + 1] == 0x18) |
2b965b3dd20c
patch 8.0.0993: sometimes an xterm sends an extra CTRL-X
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
4733 /* Sometimes the 0x07 is followed by 0x18, unclear |
2b965b3dd20c
patch 8.0.0993: sometimes an xterm sends an extra CTRL-X
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
4734 * when this happens. */ |
2b965b3dd20c
patch 8.0.0993: sometimes an xterm sends an extra CTRL-X
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
4735 ++slen; |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4736 # ifdef FEAT_EVAL |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4737 set_vim_var_string(VV_TERMRGBRESP, tp, slen); |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4738 # endif |
6901 | 4739 break; |
4740 } | |
4741 if (i == len) | |
6874 | 4742 { |
6901 | 4743 LOG_TR("not enough characters for RB"); |
4744 return -1; | |
6874 | 4745 } |
7 | 4746 } |
4747 | |
6901 | 4748 /* Check for key code response from xterm: |
4749 * {lead}{flag}+r<hex bytes><{tail} | |
4750 * | |
4751 * {lead} can be <Esc>P or DCS | |
4752 * {flag} can be '0' or '1' | |
4753 * {tail} can be Esc>\ or STERM | |
4754 * | |
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
|
4755 * Check for cursor shape response from xterm: |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4756 * {lead}1$r<number> q{tail} |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4757 * |
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
|
4758 * {lead} can be <Esc>P or DCS |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4759 * {tail} can be Esc>\ or STERM |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4760 * |
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
|
4761 * Consume any code that starts with "{lead}.+r" or "{lead}.$r". |
6901 | 4762 */ |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4763 else if ((check_for_codes || rcs_status == STATUS_SENT) |
6901 | 4764 && ((tp[0] == ESC && len >= 2 && tp[1] == 'P') |
7 | 4765 || tp[0] == DCS)) |
4766 { | |
6901 | 4767 j = 1 + (tp[0] == ESC); |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4768 if (len < j + 3) |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4769 i = len; /* need more chars */ |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4770 else if ((argp[1] != '+' && argp[1] != '$') || argp[2] != 'r') |
6901 | 4771 i = 0; /* no match */ |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4772 else if (argp[1] == '+') |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4773 /* key code response */ |
6901 | 4774 for (i = j; i < len; ++i) |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4775 { |
6901 | 4776 if ((tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\') |
7 | 4777 || tp[i] == STERM) |
4778 { | |
6901 | 4779 if (i - j >= 3) |
7 | 4780 got_code_from_term(tp + j, i); |
4781 key_name[0] = (int)KS_EXTRA; | |
4782 key_name[1] = (int)KE_IGNORE; | |
4783 slen = i + 1 + (tp[i] == ESC); | |
4784 break; | |
4785 } | |
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
|
4786 } |
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
|
4787 else if ((len >= j + 6 && isdigit(argp[3])) |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4788 && argp[4] == ' ' |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4789 && argp[5] == 'q') |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4790 { |
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
|
4791 /* cursor shape response */ |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4792 i = j + 6; |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4793 if ((tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\') |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4794 || tp[i] == STERM) |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4795 { |
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
|
4796 int number = argp[3] - '0'; |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4797 |
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
|
4798 /* 0, 1 = block blink, 2 = block |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4799 * 3 = underline blink, 4 = underline |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4800 * 5 = vertical bar blink, 6 = vertical bar */ |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4801 number = number == 0 ? 1 : number; |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4802 initial_cursor_shape = (number + 1) / 2; |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
4803 /* The blink flag is actually inverted, compared to |
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
4804 * the value set with T_SH. */ |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4805 initial_cursor_shape_blink = |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4806 (number & 1) ? FALSE : TRUE; |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4807 rcs_status = STATUS_GOT; |
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
|
4808 LOG_TR("Received cursor shape response"); |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4809 |
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
|
4810 key_name[0] = (int)KS_EXTRA; |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4811 key_name[1] = (int)KE_IGNORE; |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4812 slen = i + 1 + (tp[i] == ESC); |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4813 # ifdef FEAT_EVAL |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4814 set_vim_var_string(VV_TERMSTYLERESP, tp, slen); |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4815 # 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
|
4816 } |
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
|
4817 } |
7 | 4818 |
4819 if (i == len) | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4820 { |
6901 | 4821 /* These codes arrive many together, each code can be |
4822 * truncated at any point. */ | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4823 LOG_TR("not enough characters for XT"); |
6901 | 4824 return -1; |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4825 } |
7 | 4826 } |
4827 } | |
4828 #endif | |
4829 | |
4830 if (key_name[0] == NUL) | |
4831 continue; /* No match at this position, try next one */ | |
4832 | |
4833 /* We only get here when we have a complete termcode match */ | |
4834 | |
4835 #ifdef FEAT_MOUSE | |
4836 # ifdef FEAT_GUI | |
4837 /* | |
4838 * Only in the GUI: Fetch the pointer coordinates of the scroll event | |
4839 * so that we know which window to scroll later. | |
4840 */ | |
4841 if (gui.in_use | |
4842 && key_name[0] == (int)KS_EXTRA | |
4843 && (key_name[1] == (int)KE_X1MOUSE | |
4844 || 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
|
4845 || key_name[1] == (int)KE_MOUSELEFT |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2347
diff
changeset
|
4846 || key_name[1] == (int)KE_MOUSERIGHT |
7 | 4847 || key_name[1] == (int)KE_MOUSEDOWN |
4848 || key_name[1] == (int)KE_MOUSEUP)) | |
4849 { | |
4850 num_bytes = get_bytes_from_buf(tp + slen, bytes, 4); | |
4851 if (num_bytes == -1) /* not enough coordinates */ | |
4852 return -1; | |
4853 mouse_col = 128 * (bytes[0] - ' ' - 1) + bytes[1] - ' ' - 1; | |
4854 mouse_row = 128 * (bytes[2] - ' ' - 1) + bytes[3] - ' ' - 1; | |
4855 slen += num_bytes; | |
4856 } | |
4857 else | |
4858 # endif | |
4859 /* | |
4860 * If it is a mouse click, get the coordinates. | |
4861 */ | |
3746 | 4862 if (key_name[0] == KS_MOUSE |
7 | 4863 # ifdef FEAT_MOUSE_JSB |
3746 | 4864 || key_name[0] == KS_JSBTERM_MOUSE |
7 | 4865 # endif |
4866 # ifdef FEAT_MOUSE_NET | |
3746 | 4867 || key_name[0] == KS_NETTERM_MOUSE |
7 | 4868 # endif |
4869 # ifdef FEAT_MOUSE_DEC | |
3746 | 4870 || key_name[0] == KS_DEC_MOUSE |
7 | 4871 # endif |
4872 # ifdef FEAT_MOUSE_PTERM | |
3746 | 4873 || key_name[0] == KS_PTERM_MOUSE |
7 | 4874 # endif |
3166 | 4875 # ifdef FEAT_MOUSE_URXVT |
3746 | 4876 || key_name[0] == KS_URXVT_MOUSE |
4877 # endif | |
4878 # ifdef FEAT_MOUSE_SGR | |
4879 || key_name[0] == KS_SGR_MOUSE | |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
4880 || key_name[0] == KS_SGR_MOUSE_RELEASE |
3166 | 4881 # endif |
7 | 4882 ) |
4883 { | |
4884 is_click = is_drag = FALSE; | |
4885 | |
1623 | 4886 # if !defined(UNIX) || defined(FEAT_MOUSE_XTERM) || defined(FEAT_GUI) \ |
4887 || defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE) | |
7 | 4888 if (key_name[0] == (int)KS_MOUSE) |
4889 { | |
4890 /* | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
4891 * For xterm we get "<t_mouse>scr", where |
7 | 4892 * s == encoded button state: |
4893 * 0x20 = left button down | |
4894 * 0x21 = middle button down | |
4895 * 0x22 = right button down | |
4896 * 0x23 = any button release | |
4897 * 0x60 = button 4 down (scroll wheel down) | |
4898 * 0x61 = button 5 down (scroll wheel up) | |
4899 * add 0x04 for SHIFT | |
4900 * add 0x08 for ALT | |
4901 * add 0x10 for CTRL | |
4902 * add 0x20 for mouse drag (0x40 is drag with left button) | |
4903 * c == column + ' ' + 1 == column + 33 | |
4904 * r == row + ' ' + 1 == row + 33 | |
4905 * | |
4906 * The coordinates are passed on through global variables. | |
4907 * Ugly, but this avoids trouble with mouse clicks at an | |
4908 * unexpected moment and allows for mapping them. | |
4909 */ | |
4910 for (;;) | |
4911 { | |
4912 #ifdef FEAT_GUI | |
4913 if (gui.in_use) | |
4914 { | |
4915 /* GUI uses more bits for columns > 223 */ | |
4916 num_bytes = get_bytes_from_buf(tp + slen, bytes, 5); | |
4917 if (num_bytes == -1) /* not enough coordinates */ | |
4918 return -1; | |
4919 mouse_code = bytes[0]; | |
4920 mouse_col = 128 * (bytes[1] - ' ' - 1) | |
4921 + bytes[2] - ' ' - 1; | |
4922 mouse_row = 128 * (bytes[3] - ' ' - 1) | |
4923 + bytes[4] - ' ' - 1; | |
4924 } | |
4925 else | |
4926 #endif | |
4927 { | |
4928 num_bytes = get_bytes_from_buf(tp + slen, bytes, 3); | |
4929 if (num_bytes == -1) /* not enough coordinates */ | |
4930 return -1; | |
4931 mouse_code = bytes[0]; | |
4932 mouse_col = bytes[1] - ' ' - 1; | |
4933 mouse_row = bytes[2] - ' ' - 1; | |
4934 } | |
4935 slen += num_bytes; | |
4936 | |
4937 /* If the following bytes is also a mouse code and it has | |
4938 * the same code, dump this one and get the next. This | |
4939 * makes dragging a whole lot faster. */ | |
4940 #ifdef FEAT_GUI | |
4941 if (gui.in_use) | |
4942 j = 3; | |
4943 else | |
4944 #endif | |
4945 j = termcodes[idx].len; | |
4946 if (STRNCMP(tp, tp + slen, (size_t)j) == 0 | |
4947 && tp[slen + j] == mouse_code | |
4948 && tp[slen + j + 1] != NUL | |
4949 && tp[slen + j + 2] != NUL | |
4950 #ifdef FEAT_GUI | |
4951 && (!gui.in_use | |
4952 || (tp[slen + j + 3] != NUL | |
4953 && tp[slen + j + 4] != NUL)) | |
4954 #endif | |
4955 ) | |
4956 slen += j; | |
4957 else | |
4958 break; | |
4959 } | |
3166 | 4960 } |
4961 | |
3746 | 4962 # if defined(FEAT_MOUSE_URXVT) || defined(FEAT_MOUSE_SGR) |
4963 if (key_name[0] == KS_URXVT_MOUSE | |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
4964 || key_name[0] == KS_SGR_MOUSE |
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
4965 || key_name[0] == KS_SGR_MOUSE_RELEASE) |
3166 | 4966 { |
11567
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4967 /* URXVT 1015 mouse reporting mode: |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4968 * Almost identical to xterm mouse mode, except the values |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4969 * are decimal instead of bytes. |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4970 * |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4971 * \033[%d;%d;%dM |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4972 * ^-- row |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4973 * ^----- column |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4974 * ^-------- code |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4975 * |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4976 * SGR 1006 mouse reporting mode: |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4977 * Almost identical to xterm mouse mode, except the values |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4978 * are decimal instead of bytes. |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4979 * |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4980 * \033[<%d;%d;%dM |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4981 * ^-- row |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4982 * ^----- column |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4983 * ^-------- code |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4984 * |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4985 * \033[<%d;%d;%dm : mouse release event |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4986 * ^-- row |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4987 * ^----- column |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4988 * ^-------- code |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4989 */ |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4990 p = modifiers_start; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4991 if (p == NULL) |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4992 return -1; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4993 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4994 mouse_code = getdigits(&p); |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4995 if (*p++ != ';') |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4996 return -1; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4997 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4998 /* when mouse reporting is SGR, add 32 to mouse code */ |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4999 if (key_name[0] == KS_SGR_MOUSE |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5000 || key_name[0] == KS_SGR_MOUSE_RELEASE) |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5001 mouse_code += 32; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5002 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5003 if (key_name[0] == KS_SGR_MOUSE_RELEASE) |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5004 mouse_code |= MOUSE_RELEASE; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5005 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5006 mouse_col = getdigits(&p) - 1; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5007 if (*p++ != ';') |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5008 return -1; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5009 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5010 mouse_row = getdigits(&p) - 1; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5011 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5012 /* The modifiers were the mouse coordinates, not the |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5013 * modifier keys (alt/shift/ctrl/meta) state. */ |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5014 modifiers = 0; |
3166 | 5015 } |
5016 # endif | |
5017 | |
5018 if (key_name[0] == (int)KS_MOUSE | |
5019 #ifdef FEAT_MOUSE_URXVT | |
5020 || key_name[0] == (int)KS_URXVT_MOUSE | |
5021 #endif | |
3746 | 5022 #ifdef FEAT_MOUSE_SGR |
5023 || key_name[0] == KS_SGR_MOUSE | |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
5024 || key_name[0] == KS_SGR_MOUSE_RELEASE |
3746 | 5025 #endif |
3166 | 5026 ) |
5027 { | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
5028 # if !defined(MSWIN) |
7 | 5029 /* |
5030 * Handle mouse events. | |
5031 * Recognize the xterm mouse wheel, but not in the GUI, the | |
5032 * Linux console with GPM and the MS-DOS or Win32 console | |
5033 * (multi-clicks use >= 0x60). | |
5034 */ | |
5035 if (mouse_code >= MOUSEWHEEL_LOW | |
5036 # ifdef FEAT_GUI | |
5037 && !gui.in_use | |
5038 # endif | |
5039 # ifdef FEAT_MOUSE_GPM | |
5040 && gpm_flag == 0 | |
5041 # endif | |
5042 ) | |
5043 { | |
5044 /* Keep the mouse_code before it's changed, so that we | |
5045 * remember that it was a mouse wheel click. */ | |
5046 wheel_code = mouse_code; | |
5047 } | |
5048 # ifdef FEAT_MOUSE_XTERM | |
5049 else if (held_button == MOUSE_RELEASE | |
5050 # ifdef FEAT_GUI | |
5051 && !gui.in_use | |
5052 # endif | |
5053 && (mouse_code == 0x23 || mouse_code == 0x24)) | |
5054 { | |
5055 /* Apparently used by rxvt scroll wheel. */ | |
5056 wheel_code = mouse_code - 0x23 + MOUSEWHEEL_LOW; | |
5057 } | |
5058 # endif | |
5059 | |
5060 # if defined(UNIX) && defined(FEAT_MOUSE_TTY) | |
5061 else if (use_xterm_mouse() > 1) | |
5062 { | |
5063 if (mouse_code & MOUSE_DRAG_XTERM) | |
5064 mouse_code |= MOUSE_DRAG; | |
5065 } | |
5066 # endif | |
5067 # ifdef FEAT_XCLIPBOARD | |
5068 else if (!(mouse_code & MOUSE_DRAG & ~MOUSE_CLICK_MASK)) | |
5069 { | |
5070 if ((mouse_code & MOUSE_RELEASE) == MOUSE_RELEASE) | |
5071 stop_xterm_trace(); | |
5072 else | |
5073 start_xterm_trace(mouse_code); | |
5074 } | |
5075 # endif | |
5076 # endif | |
5077 } | |
5078 # endif /* !UNIX || FEAT_MOUSE_XTERM */ | |
5079 # ifdef FEAT_MOUSE_NET | |
5080 if (key_name[0] == (int)KS_NETTERM_MOUSE) | |
5081 { | |
5082 int mc, mr; | |
5083 | |
5084 /* expect a rather limited sequence like: balancing { | |
5085 * \033}6,45\r | |
5086 * '6' is the row, 45 is the column | |
5087 */ | |
5088 p = tp + slen; | |
5089 mr = getdigits(&p); | |
5090 if (*p++ != ',') | |
5091 return -1; | |
5092 mc = getdigits(&p); | |
5093 if (*p++ != '\r') | |
5094 return -1; | |
5095 | |
5096 mouse_col = mc - 1; | |
5097 mouse_row = mr - 1; | |
5098 mouse_code = MOUSE_LEFT; | |
5099 slen += (int)(p - (tp + slen)); | |
5100 } | |
5101 # endif /* FEAT_MOUSE_NET */ | |
5102 # ifdef FEAT_MOUSE_JSB | |
5103 if (key_name[0] == (int)KS_JSBTERM_MOUSE) | |
5104 { | |
5105 int mult, val, iter, button, status; | |
5106 | |
5107 /* JSBTERM Input Model | |
5108 * \033[0~zw uniq escape sequence | |
5109 * (L-x) Left button pressed - not pressed x not reporting | |
5110 * (M-x) Middle button pressed - not pressed x not reporting | |
5111 * (R-x) Right button pressed - not pressed x not reporting | |
5112 * (SDmdu) Single , Double click, m mouse move d button down | |
5113 * u button up | |
5114 * ### X cursor position padded to 3 digits | |
5115 * ### Y cursor position padded to 3 digits | |
5116 * (s-x) SHIFT key pressed - not pressed x not reporting | |
5117 * (c-x) CTRL key pressed - not pressed x not reporting | |
2237
770485470e59
Add a few #ifdefs to exclude functions that are not used. (Domnique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
1941
diff
changeset
|
5118 * \033\\ terminating sequence |
7 | 5119 */ |
5120 | |
5121 p = tp + slen; | |
5122 button = mouse_code = 0; | |
5123 switch (*p++) | |
5124 { | |
5125 case 'L': button = 1; break; | |
5126 case '-': break; | |
5127 case 'x': break; /* ignore sequence */ | |
5128 default: return -1; /* Unknown Result */ | |
5129 } | |
5130 switch (*p++) | |
5131 { | |
5132 case 'M': button |= 2; break; | |
5133 case '-': break; | |
5134 case 'x': break; /* ignore sequence */ | |
5135 default: return -1; /* Unknown Result */ | |
5136 } | |
5137 switch (*p++) | |
5138 { | |
5139 case 'R': button |= 4; break; | |
5140 case '-': break; | |
5141 case 'x': break; /* ignore sequence */ | |
5142 default: return -1; /* Unknown Result */ | |
5143 } | |
5144 status = *p++; | |
5145 for (val = 0, mult = 100, iter = 0; iter < 3; iter++, | |
5146 mult /= 10, p++) | |
5147 if (*p >= '0' && *p <= '9') | |
5148 val += (*p - '0') * mult; | |
5149 else | |
5150 return -1; | |
5151 mouse_col = val; | |
5152 for (val = 0, mult = 100, iter = 0; iter < 3; iter++, | |
5153 mult /= 10, p++) | |
5154 if (*p >= '0' && *p <= '9') | |
5155 val += (*p - '0') * mult; | |
5156 else | |
5157 return -1; | |
5158 mouse_row = val; | |
5159 switch (*p++) | |
5160 { | |
5161 case 's': button |= 8; break; /* SHIFT key Pressed */ | |
5162 case '-': break; /* Not Pressed */ | |
5163 case 'x': break; /* Not Reporting */ | |
5164 default: return -1; /* Unknown Result */ | |
5165 } | |
5166 switch (*p++) | |
5167 { | |
5168 case 'c': button |= 16; break; /* CTRL key Pressed */ | |
5169 case '-': break; /* Not Pressed */ | |
5170 case 'x': break; /* Not Reporting */ | |
5171 default: return -1; /* Unknown Result */ | |
5172 } | |
5173 if (*p++ != '\033') | |
5174 return -1; | |
5175 if (*p++ != '\\') | |
5176 return -1; | |
5177 switch (status) | |
5178 { | |
5179 case 'D': /* Double Click */ | |
5180 case 'S': /* Single Click */ | |
5181 if (button & 1) mouse_code |= MOUSE_LEFT; | |
5182 if (button & 2) mouse_code |= MOUSE_MIDDLE; | |
5183 if (button & 4) mouse_code |= MOUSE_RIGHT; | |
5184 if (button & 8) mouse_code |= MOUSE_SHIFT; | |
5185 if (button & 16) mouse_code |= MOUSE_CTRL; | |
5186 break; | |
5187 case 'm': /* Mouse move */ | |
5188 if (button & 1) mouse_code |= MOUSE_LEFT; | |
5189 if (button & 2) mouse_code |= MOUSE_MIDDLE; | |
5190 if (button & 4) mouse_code |= MOUSE_RIGHT; | |
5191 if (button & 8) mouse_code |= MOUSE_SHIFT; | |
5192 if (button & 16) mouse_code |= MOUSE_CTRL; | |
5193 if ((button & 7) != 0) | |
5194 { | |
5195 held_button = mouse_code; | |
5196 mouse_code |= MOUSE_DRAG; | |
5197 } | |
5198 is_drag = TRUE; | |
5199 showmode(); | |
5200 break; | |
5201 case 'd': /* Button Down */ | |
5202 if (button & 1) mouse_code |= MOUSE_LEFT; | |
5203 if (button & 2) mouse_code |= MOUSE_MIDDLE; | |
5204 if (button & 4) mouse_code |= MOUSE_RIGHT; | |
5205 if (button & 8) mouse_code |= MOUSE_SHIFT; | |
5206 if (button & 16) mouse_code |= MOUSE_CTRL; | |
5207 break; | |
5208 case 'u': /* Button Up */ | |
5209 if (button & 1) | |
5210 mouse_code |= MOUSE_LEFT | MOUSE_RELEASE; | |
5211 if (button & 2) | |
5212 mouse_code |= MOUSE_MIDDLE | MOUSE_RELEASE; | |
5213 if (button & 4) | |
5214 mouse_code |= MOUSE_RIGHT | MOUSE_RELEASE; | |
5215 if (button & 8) | |
5216 mouse_code |= MOUSE_SHIFT; | |
5217 if (button & 16) | |
5218 mouse_code |= MOUSE_CTRL; | |
5219 break; | |
5220 default: return -1; /* Unknown Result */ | |
5221 } | |
5222 | |
5223 slen += (p - (tp + slen)); | |
5224 } | |
5225 # endif /* FEAT_MOUSE_JSB */ | |
5226 # ifdef FEAT_MOUSE_DEC | |
5227 if (key_name[0] == (int)KS_DEC_MOUSE) | |
5228 { | |
5229 /* The DEC Locator Input Model | |
5230 * Netterm delivers the code sequence: | |
5231 * \033[2;4;24;80&w (left button down) | |
5232 * \033[3;0;24;80&w (left button up) | |
5233 * \033[6;1;24;80&w (right button down) | |
5234 * \033[7;0;24;80&w (right button up) | |
5235 * CSI Pe ; Pb ; Pr ; Pc ; Pp & w | |
5236 * Pe is the event code | |
5237 * Pb is the button code | |
5238 * Pr is the row coordinate | |
5239 * Pc is the column coordinate | |
5240 * Pp is the third coordinate (page number) | |
5241 * Pe, the event code indicates what event caused this report | |
5242 * The following event codes are defined: | |
5243 * 0 - request, the terminal received an explicit request | |
5244 * for a locator report, but the locator is unavailable | |
5245 * 1 - request, the terminal received an explicit request | |
5246 * for a locator report | |
5247 * 2 - left button down | |
5248 * 3 - left button up | |
5249 * 4 - middle button down | |
5250 * 5 - middle button up | |
5251 * 6 - right button down | |
5252 * 7 - right button up | |
5253 * 8 - fourth button down | |
5254 * 9 - fourth button up | |
5255 * 10 - locator outside filter rectangle | |
5256 * Pb, the button code, ASCII decimal 0-15 indicating which | |
5257 * buttons are down if any. The state of the four buttons | |
5258 * on the locator correspond to the low four bits of the | |
5259 * decimal value, | |
5260 * "1" means button depressed | |
5261 * 0 - no buttons down, | |
5262 * 1 - right, | |
5263 * 2 - middle, | |
5264 * 4 - left, | |
5265 * 8 - fourth | |
5266 * Pr is the row coordinate of the locator position in the page, | |
5267 * encoded as an ASCII decimal value. | |
5268 * If Pr is omitted, the locator position is undefined | |
5269 * (outside the terminal window for example). | |
5270 * Pc is the column coordinate of the locator position in the | |
5271 * page, encoded as an ASCII decimal value. | |
5272 * If Pc is omitted, the locator position is undefined | |
5273 * (outside the terminal window for example). | |
5274 * Pp is the page coordinate of the locator position | |
5275 * encoded as an ASCII decimal value. | |
5276 * The page coordinate may be omitted if the locator is on | |
5277 * page one (the default). We ignore it anyway. | |
5278 */ | |
5279 int Pe, Pb, Pr, Pc; | |
5280 | |
5281 p = tp + slen; | |
5282 | |
5283 /* get event status */ | |
5284 Pe = getdigits(&p); | |
5285 if (*p++ != ';') | |
5286 return -1; | |
5287 | |
5288 /* get button status */ | |
5289 Pb = getdigits(&p); | |
5290 if (*p++ != ';') | |
5291 return -1; | |
5292 | |
5293 /* get row status */ | |
5294 Pr = getdigits(&p); | |
5295 if (*p++ != ';') | |
5296 return -1; | |
5297 | |
5298 /* get column status */ | |
5299 Pc = getdigits(&p); | |
5300 | |
5301 /* the page parameter is optional */ | |
5302 if (*p == ';') | |
5303 { | |
5304 p++; | |
5305 (void)getdigits(&p); | |
5306 } | |
5307 if (*p++ != '&') | |
5308 return -1; | |
5309 if (*p++ != 'w') | |
5310 return -1; | |
5311 | |
5312 mouse_code = 0; | |
5313 switch (Pe) | |
5314 { | |
5315 case 0: return -1; /* position request while unavailable */ | |
5316 case 1: /* a response to a locator position request includes | |
5317 the status of all buttons */ | |
5318 Pb &= 7; /* mask off and ignore fourth button */ | |
5319 if (Pb & 4) | |
5320 mouse_code = MOUSE_LEFT; | |
5321 if (Pb & 2) | |
5322 mouse_code = MOUSE_MIDDLE; | |
5323 if (Pb & 1) | |
5324 mouse_code = MOUSE_RIGHT; | |
5325 if (Pb) | |
5326 { | |
5327 held_button = mouse_code; | |
5328 mouse_code |= MOUSE_DRAG; | |
227 | 5329 WantQueryMouse = TRUE; |
7 | 5330 } |
5331 is_drag = TRUE; | |
5332 showmode(); | |
5333 break; | |
5334 case 2: mouse_code = MOUSE_LEFT; | |
227 | 5335 WantQueryMouse = TRUE; |
7 | 5336 break; |
5337 case 3: mouse_code = MOUSE_RELEASE | MOUSE_LEFT; | |
5338 break; | |
5339 case 4: mouse_code = MOUSE_MIDDLE; | |
227 | 5340 WantQueryMouse = TRUE; |
7 | 5341 break; |
5342 case 5: mouse_code = MOUSE_RELEASE | MOUSE_MIDDLE; | |
5343 break; | |
5344 case 6: mouse_code = MOUSE_RIGHT; | |
227 | 5345 WantQueryMouse = TRUE; |
7 | 5346 break; |
5347 case 7: mouse_code = MOUSE_RELEASE | MOUSE_RIGHT; | |
5348 break; | |
5349 case 8: return -1; /* fourth button down */ | |
5350 case 9: return -1; /* fourth button up */ | |
5351 case 10: return -1; /* mouse outside of filter rectangle */ | |
5352 default: return -1; /* should never occur */ | |
5353 } | |
5354 | |
5355 mouse_col = Pc - 1; | |
5356 mouse_row = Pr - 1; | |
5357 | |
5358 slen += (int)(p - (tp + slen)); | |
5359 } | |
5360 # endif /* FEAT_MOUSE_DEC */ | |
5361 # ifdef FEAT_MOUSE_PTERM | |
5362 if (key_name[0] == (int)KS_PTERM_MOUSE) | |
5363 { | |
2237
770485470e59
Add a few #ifdefs to exclude functions that are not used. (Domnique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
1941
diff
changeset
|
5364 int button, num_clicks, action; |
7 | 5365 |
5366 p = tp + slen; | |
5367 | |
5368 action = getdigits(&p); | |
5369 if (*p++ != ';') | |
5370 return -1; | |
5371 | |
5372 mouse_row = getdigits(&p); | |
5373 if (*p++ != ';') | |
5374 return -1; | |
5375 mouse_col = getdigits(&p); | |
5376 if (*p++ != ';') | |
5377 return -1; | |
5378 | |
5379 button = getdigits(&p); | |
5380 mouse_code = 0; | |
5381 | |
9929
579abc260d85
commit https://github.com/vim/vim/commit/de7762a2c1498e2dc43586feb5f982d661799f85
Christian Brabandt <cb@256bit.org>
parents:
9869
diff
changeset
|
5382 switch (button) |
7 | 5383 { |
5384 case 4: mouse_code = MOUSE_LEFT; break; | |
5385 case 1: mouse_code = MOUSE_RIGHT; break; | |
5386 case 2: mouse_code = MOUSE_MIDDLE; break; | |
5387 default: return -1; | |
5388 } | |
5389 | |
9929
579abc260d85
commit https://github.com/vim/vim/commit/de7762a2c1498e2dc43586feb5f982d661799f85
Christian Brabandt <cb@256bit.org>
parents:
9869
diff
changeset
|
5390 switch (action) |
7 | 5391 { |
5392 case 31: /* Initial press */ | |
5393 if (*p++ != ';') | |
5394 return -1; | |
5395 | |
5396 num_clicks = getdigits(&p); /* Not used */ | |
5397 break; | |
5398 | |
5399 case 32: /* Release */ | |
5400 mouse_code |= MOUSE_RELEASE; | |
5401 break; | |
5402 | |
5403 case 33: /* Drag */ | |
5404 held_button = mouse_code; | |
5405 mouse_code |= MOUSE_DRAG; | |
5406 break; | |
5407 | |
5408 default: | |
5409 return -1; | |
5410 } | |
5411 | |
5412 if (*p++ != 't') | |
5413 return -1; | |
5414 | |
5415 slen += (p - (tp + slen)); | |
5416 } | |
5417 # endif /* FEAT_MOUSE_PTERM */ | |
5418 | |
5419 /* Interpret the mouse code */ | |
5420 current_button = (mouse_code & MOUSE_CLICK_MASK); | |
5421 if (current_button == MOUSE_RELEASE | |
5422 # ifdef FEAT_MOUSE_XTERM | |
5423 && wheel_code == 0 | |
5424 # endif | |
5425 ) | |
5426 { | |
5427 /* | |
5428 * If we get a mouse drag or release event when | |
5429 * there is no mouse button held down (held_button == | |
5430 * MOUSE_RELEASE), produce a K_IGNORE below. | |
5431 * (can happen when you hold down two buttons | |
5432 * and then let them go, or click in the menu bar, but not | |
5433 * on a menu, and drag into the text). | |
5434 */ | |
5435 if ((mouse_code & MOUSE_DRAG) == MOUSE_DRAG) | |
5436 is_drag = TRUE; | |
5437 current_button = held_button; | |
5438 } | |
5439 else if (wheel_code == 0) | |
5440 { | |
5441 # ifdef CHECK_DOUBLE_CLICK | |
5442 # ifdef FEAT_MOUSE_GPM | |
5443 # ifdef FEAT_GUI | |
5444 /* | |
5445 * Only for Unix, when GUI or gpm is not active, we handle | |
5446 * multi-clicks here. | |
5447 */ | |
5448 if (gpm_flag == 0 && !gui.in_use) | |
5449 # else | |
5450 if (gpm_flag == 0) | |
5451 # endif | |
5452 # else | |
5453 # ifdef FEAT_GUI | |
5454 if (!gui.in_use) | |
5455 # endif | |
5456 # endif | |
5457 { | |
5458 /* | |
5459 * Compute the time elapsed since the previous mouse click. | |
5460 */ | |
5461 gettimeofday(&mouse_time, NULL); | |
9125
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5462 if (orig_mouse_time.tv_sec == 0) |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5463 { |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5464 /* |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5465 * Avoid computing the difference between mouse_time |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5466 * and orig_mouse_time for the first click, as the |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5467 * difference would be huge and would cause multiplication |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5468 * overflow. |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5469 */ |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5470 timediff = p_mouset; |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5471 } |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5472 else |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5473 { |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5474 timediff = (mouse_time.tv_usec |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5475 - orig_mouse_time.tv_usec) / 1000; |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5476 if (timediff < 0) |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5477 --orig_mouse_time.tv_sec; |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5478 timediff += (mouse_time.tv_sec |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5479 - orig_mouse_time.tv_sec) * 1000; |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5480 } |
7 | 5481 orig_mouse_time = mouse_time; |
5482 if (mouse_code == orig_mouse_code | |
5483 && timediff < p_mouset | |
5484 && orig_num_clicks != 4 | |
5485 && orig_mouse_col == mouse_col | |
5486 && orig_mouse_row == mouse_row | |
683 | 5487 && ((orig_topline == curwin->w_topline |
7 | 5488 #ifdef FEAT_DIFF |
683 | 5489 && orig_topfill == curwin->w_topfill |
7 | 5490 #endif |
683 | 5491 ) |
5492 #ifdef FEAT_WINDOWS | |
5493 /* Double click in tab pages line also works | |
5494 * when window contents changes. */ | |
5495 || (mouse_row == 0 && firstwin->w_winrow > 0) | |
5496 #endif | |
5497 ) | |
5498 ) | |
7 | 5499 ++orig_num_clicks; |
5500 else | |
5501 orig_num_clicks = 1; | |
5502 orig_mouse_col = mouse_col; | |
5503 orig_mouse_row = mouse_row; | |
5504 orig_topline = curwin->w_topline; | |
5505 #ifdef FEAT_DIFF | |
5506 orig_topfill = curwin->w_topfill; | |
5507 #endif | |
5508 } | |
5509 # if defined(FEAT_GUI) || defined(FEAT_MOUSE_GPM) | |
5510 else | |
5511 orig_num_clicks = NUM_MOUSE_CLICKS(mouse_code); | |
5512 # endif | |
5513 # else | |
5514 orig_num_clicks = NUM_MOUSE_CLICKS(mouse_code); | |
5515 # endif | |
5516 is_click = TRUE; | |
5517 orig_mouse_code = mouse_code; | |
5518 } | |
5519 if (!is_drag) | |
5520 held_button = mouse_code & MOUSE_CLICK_MASK; | |
5521 | |
5522 /* | |
5523 * Translate the actual mouse event into a pseudo mouse event. | |
5524 * First work out what modifiers are to be used. | |
5525 */ | |
5526 if (orig_mouse_code & MOUSE_SHIFT) | |
5527 modifiers |= MOD_MASK_SHIFT; | |
5528 if (orig_mouse_code & MOUSE_CTRL) | |
5529 modifiers |= MOD_MASK_CTRL; | |
5530 if (orig_mouse_code & MOUSE_ALT) | |
5531 modifiers |= MOD_MASK_ALT; | |
5532 if (orig_num_clicks == 2) | |
5533 modifiers |= MOD_MASK_2CLICK; | |
5534 else if (orig_num_clicks == 3) | |
5535 modifiers |= MOD_MASK_3CLICK; | |
5536 else if (orig_num_clicks == 4) | |
5537 modifiers |= MOD_MASK_4CLICK; | |
5538 | |
9929
579abc260d85
commit https://github.com/vim/vim/commit/de7762a2c1498e2dc43586feb5f982d661799f85
Christian Brabandt <cb@256bit.org>
parents:
9869
diff
changeset
|
5539 /* Work out our pseudo mouse event. Note that MOUSE_RELEASE gets |
579abc260d85
commit https://github.com/vim/vim/commit/de7762a2c1498e2dc43586feb5f982d661799f85
Christian Brabandt <cb@256bit.org>
parents:
9869
diff
changeset
|
5540 * added, then it's not mouse up/down. */ |
7 | 5541 key_name[0] = (int)KS_EXTRA; |
9929
579abc260d85
commit https://github.com/vim/vim/commit/de7762a2c1498e2dc43586feb5f982d661799f85
Christian Brabandt <cb@256bit.org>
parents:
9869
diff
changeset
|
5542 if (wheel_code != 0 |
579abc260d85
commit https://github.com/vim/vim/commit/de7762a2c1498e2dc43586feb5f982d661799f85
Christian Brabandt <cb@256bit.org>
parents:
9869
diff
changeset
|
5543 && (wheel_code & MOUSE_RELEASE) != MOUSE_RELEASE) |
2336
1a4a66f0c871
Make CTRL modifier work for mouse wheel. (Benjamin Haskell)
Bram Moolenaar <bram@vim.org>
parents:
2279
diff
changeset
|
5544 { |
1a4a66f0c871
Make CTRL modifier work for mouse wheel. (Benjamin Haskell)
Bram Moolenaar <bram@vim.org>
parents:
2279
diff
changeset
|
5545 if (wheel_code & MOUSE_CTRL) |
1a4a66f0c871
Make CTRL modifier work for mouse wheel. (Benjamin Haskell)
Bram Moolenaar <bram@vim.org>
parents:
2279
diff
changeset
|
5546 modifiers |= MOD_MASK_CTRL; |
2347
9228765d3e13
Also make ALT modifier work for mouse wheel. (Benjamin Haskell)
Bram Moolenaar <bram@vim.org>
parents:
2336
diff
changeset
|
5547 if (wheel_code & MOUSE_ALT) |
9228765d3e13
Also make ALT modifier work for mouse wheel. (Benjamin Haskell)
Bram Moolenaar <bram@vim.org>
parents:
2336
diff
changeset
|
5548 modifiers |= MOD_MASK_ALT; |
7 | 5549 key_name[1] = (wheel_code & 1) |
5550 ? (int)KE_MOUSEUP : (int)KE_MOUSEDOWN; | |
2336
1a4a66f0c871
Make CTRL modifier work for mouse wheel. (Benjamin Haskell)
Bram Moolenaar <bram@vim.org>
parents:
2279
diff
changeset
|
5551 } |
7 | 5552 else |
5553 key_name[1] = get_pseudo_mouse_code(current_button, | |
5554 is_click, is_drag); | |
7256
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5555 |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5556 /* Make sure the mouse position is valid. Some terminals may |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5557 * return weird values. */ |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5558 if (mouse_col >= Columns) |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5559 mouse_col = Columns - 1; |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5560 if (mouse_row >= Rows) |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5561 mouse_row = Rows - 1; |
7 | 5562 } |
5563 #endif /* FEAT_MOUSE */ | |
5564 | |
5565 #ifdef FEAT_GUI | |
5566 /* | |
5567 * If using the GUI, then we get menu and scrollbar events. | |
5568 * | |
5569 * A menu event is encoded as K_SPECIAL, KS_MENU, KE_FILLER followed by | |
5570 * four bytes which are to be taken as a pointer to the vimmenu_T | |
5571 * structure. | |
5572 * | |
1221 | 5573 * A tab line event is encoded as K_SPECIAL KS_TABLINE nr, where "nr" |
685 | 5574 * is one byte with the tab index. |
5575 * | |
7 | 5576 * A scrollbar event is K_SPECIAL, KS_VER_SCROLLBAR, KE_FILLER followed |
5577 * by one byte representing the scrollbar number, and then four bytes | |
5578 * representing a long_u which is the new value of the scrollbar. | |
5579 * | |
5580 * A horizontal scrollbar event is K_SPECIAL, KS_HOR_SCROLLBAR, | |
5581 * KE_FILLER followed by four bytes representing a long_u which is the | |
5582 * new value of the scrollbar. | |
5583 */ | |
5584 # ifdef FEAT_MENU | |
5585 else if (key_name[0] == (int)KS_MENU) | |
5586 { | |
5587 long_u val; | |
5588 | |
5589 num_bytes = get_long_from_buf(tp + slen, &val); | |
5590 if (num_bytes == -1) | |
5591 return -1; | |
5592 current_menu = (vimmenu_T *)val; | |
5593 slen += num_bytes; | |
936 | 5594 |
5595 /* The menu may have been deleted right after it was used, check | |
5596 * for that. */ | |
5597 if (check_menu_pointer(root_menu, current_menu) == FAIL) | |
5598 { | |
5599 key_name[0] = KS_EXTRA; | |
5600 key_name[1] = (int)KE_IGNORE; | |
5601 } | |
7 | 5602 } |
5603 # endif | |
685 | 5604 # ifdef FEAT_GUI_TABLINE |
5605 else if (key_name[0] == (int)KS_TABLINE) | |
5606 { | |
688 | 5607 /* Selecting tabline tab or using its menu. */ |
685 | 5608 num_bytes = get_bytes_from_buf(tp + slen, bytes, 1); |
5609 if (num_bytes == -1) | |
5610 return -1; | |
5611 current_tab = (int)bytes[0]; | |
1394 | 5612 if (current_tab == 255) /* -1 in a byte gives 255 */ |
5613 current_tab = -1; | |
685 | 5614 slen += num_bytes; |
5615 } | |
688 | 5616 else if (key_name[0] == (int)KS_TABMENU) |
5617 { | |
5618 /* Selecting tabline tab or using its menu. */ | |
5619 num_bytes = get_bytes_from_buf(tp + slen, bytes, 2); | |
5620 if (num_bytes == -1) | |
5621 return -1; | |
5622 current_tab = (int)bytes[0]; | |
5623 current_tabmenu = (int)bytes[1]; | |
5624 slen += num_bytes; | |
5625 } | |
685 | 5626 # endif |
7 | 5627 # ifndef USE_ON_FLY_SCROLL |
5628 else if (key_name[0] == (int)KS_VER_SCROLLBAR) | |
5629 { | |
5630 long_u val; | |
5631 | |
5632 /* Get the last scrollbar event in the queue of the same type */ | |
5633 j = 0; | |
5634 for (i = 0; tp[j] == CSI && tp[j + 1] == KS_VER_SCROLLBAR | |
5635 && tp[j + 2] != NUL; ++i) | |
5636 { | |
5637 j += 3; | |
5638 num_bytes = get_bytes_from_buf(tp + j, bytes, 1); | |
5639 if (num_bytes == -1) | |
5640 break; | |
5641 if (i == 0) | |
5642 current_scrollbar = (int)bytes[0]; | |
5643 else if (current_scrollbar != (int)bytes[0]) | |
5644 break; | |
5645 j += num_bytes; | |
5646 num_bytes = get_long_from_buf(tp + j, &val); | |
5647 if (num_bytes == -1) | |
5648 break; | |
5649 scrollbar_value = val; | |
5650 j += num_bytes; | |
5651 slen = j; | |
5652 } | |
5653 if (i == 0) /* not enough characters to make one */ | |
5654 return -1; | |
5655 } | |
5656 else if (key_name[0] == (int)KS_HOR_SCROLLBAR) | |
5657 { | |
5658 long_u val; | |
5659 | |
5660 /* Get the last horiz. scrollbar event in the queue */ | |
5661 j = 0; | |
5662 for (i = 0; tp[j] == CSI && tp[j + 1] == KS_HOR_SCROLLBAR | |
5663 && tp[j + 2] != NUL; ++i) | |
5664 { | |
5665 j += 3; | |
5666 num_bytes = get_long_from_buf(tp + j, &val); | |
5667 if (num_bytes == -1) | |
5668 break; | |
5669 scrollbar_value = val; | |
5670 j += num_bytes; | |
5671 slen = j; | |
5672 } | |
5673 if (i == 0) /* not enough characters to make one */ | |
5674 return -1; | |
5675 } | |
5676 # endif /* !USE_ON_FLY_SCROLL */ | |
5677 #endif /* FEAT_GUI */ | |
5678 | |
180 | 5679 /* |
5680 * Change <xHome> to <Home>, <xUp> to <Up>, etc. | |
5681 */ | |
5682 key = handle_x_keys(TERMCAP2KEY(key_name[0], key_name[1])); | |
5683 | |
5684 /* | |
5685 * Add any modifier codes to our string. | |
5686 */ | |
5687 new_slen = 0; /* Length of what will replace the termcode */ | |
5688 if (modifiers != 0) | |
5689 { | |
5690 /* Some keys have the modifier included. Need to handle that here | |
5691 * to make mappings work. */ | |
5692 key = simplify_key(key, &modifiers); | |
5693 if (modifiers != 0) | |
5694 { | |
5695 string[new_slen++] = K_SPECIAL; | |
5696 string[new_slen++] = (int)KS_MODIFIER; | |
5697 string[new_slen++] = modifiers; | |
5698 } | |
5699 } | |
5700 | |
7 | 5701 /* Finally, add the special key code to our string */ |
180 | 5702 key_name[0] = KEY2TERMCAP0(key); |
5703 key_name[1] = KEY2TERMCAP1(key); | |
7 | 5704 if (key_name[0] == KS_KEY) |
1787 | 5705 { |
5706 /* from ":set <M-b>=xx" */ | |
5707 #ifdef FEAT_MBYTE | |
5708 if (has_mbyte) | |
5709 new_slen += (*mb_char2bytes)(key_name[1], string + new_slen); | |
5710 else | |
5711 #endif | |
5712 string[new_slen++] = key_name[1]; | |
5713 } | |
2672 | 5714 else if (new_slen == 0 && key_name[0] == KS_EXTRA |
5715 && key_name[1] == KE_IGNORE) | |
5716 { | |
5717 /* Do not put K_IGNORE into the buffer, do return KEYLEN_REMOVED | |
5718 * to indicate what happened. */ | |
5719 retval = KEYLEN_REMOVED; | |
5720 } | |
7 | 5721 else |
5722 { | |
5723 string[new_slen++] = K_SPECIAL; | |
5724 string[new_slen++] = key_name[0]; | |
5725 string[new_slen++] = key_name[1]; | |
5726 } | |
5727 string[new_slen] = NUL; | |
5728 extra = new_slen - slen; | |
5729 if (buf == NULL) | |
5730 { | |
5731 if (extra < 0) | |
5732 /* remove matched chars, taking care of noremap */ | |
5733 del_typebuf(-extra, offset); | |
5734 else if (extra > 0) | |
5735 /* insert the extra space we need */ | |
5736 ins_typebuf(string + slen, REMAP_YES, offset, FALSE, FALSE); | |
5737 | |
5738 /* | |
5739 * Careful: del_typebuf() and ins_typebuf() may have reallocated | |
5740 * typebuf.tb_buf[]! | |
5741 */ | |
5742 mch_memmove(typebuf.tb_buf + typebuf.tb_off + offset, string, | |
5743 (size_t)new_slen); | |
5744 } | |
5745 else | |
5746 { | |
5747 if (extra < 0) | |
5748 /* remove matched characters */ | |
5749 mch_memmove(buf + offset, buf + offset - extra, | |
3328 | 5750 (size_t)(*buflen + offset + extra)); |
7 | 5751 else if (extra > 0) |
3328 | 5752 { |
5753 /* Insert the extra space we need. If there is insufficient | |
5754 * space return -1. */ | |
5755 if (*buflen + extra + new_slen >= bufsize) | |
5756 return -1; | |
7 | 5757 mch_memmove(buf + offset + extra, buf + offset, |
3328 | 5758 (size_t)(*buflen - offset)); |
5759 } | |
7 | 5760 mch_memmove(buf + offset, string, (size_t)new_slen); |
3328 | 5761 *buflen = *buflen + extra + new_slen; |
7 | 5762 } |
2672 | 5763 return retval == 0 ? (len + extra + offset) : retval; |
7 | 5764 } |
5765 | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5766 #ifdef FEAT_TERMRESPONSE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5767 LOG_TR("normal character"); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5768 #endif |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5769 |
7 | 5770 return 0; /* no match found */ |
5771 } | |
5772 | |
5773 /* | |
5774 * Replace any terminal code strings in from[] with the equivalent internal | |
5775 * vim representation. This is used for the "from" and "to" part of a | |
5776 * mapping, and the "to" part of a menu command. | |
5777 * Any strings like "<C-UP>" are also replaced, unless 'cpoptions' contains | |
5778 * '<'. | |
5779 * K_SPECIAL by itself is replaced by K_SPECIAL KS_SPECIAL KE_FILLER. | |
5780 * | |
5781 * The replacement is done in result[] and finally copied into allocated | |
5782 * memory. If this all works well *bufp is set to the allocated memory and a | |
5783 * pointer to it is returned. If something fails *bufp is set to NULL and from | |
5784 * is returned. | |
5785 * | |
5786 * CTRL-V characters are removed. When "from_part" is TRUE, a trailing CTRL-V | |
5787 * is included, otherwise it is removed (for ":map xx ^V", maps xx to | |
5788 * nothing). When 'cpoptions' does not contain 'B', a backslash can be used | |
5789 * instead of a CTRL-V. | |
5790 */ | |
859 | 5791 char_u * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5792 replace_termcodes( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5793 char_u *from, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5794 char_u **bufp, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5795 int from_part, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5796 int do_lt, /* also translate <lt> */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5797 int special) /* always accept <key> notation */ |
7 | 5798 { |
5799 int i; | |
5800 int slen; | |
5801 int key; | |
5802 int dlen = 0; | |
5803 char_u *src; | |
5804 int do_backslash; /* backslash is a special character */ | |
5805 int do_special; /* recognize <> key codes */ | |
5806 int do_key_code; /* recognize raw key codes */ | |
5807 char_u *result; /* buffer for resulting string */ | |
5808 | |
5809 do_backslash = (vim_strchr(p_cpo, CPO_BSLASH) == NULL); | |
859 | 5810 do_special = (vim_strchr(p_cpo, CPO_SPECI) == NULL) || special; |
7 | 5811 do_key_code = (vim_strchr(p_cpo, CPO_KEYCODE) == NULL); |
5812 | |
5813 /* | |
5814 * Allocate space for the translation. Worst case a single character is | |
5815 * replaced by 6 bytes (shifted special key), plus a NUL at the end. | |
5816 */ | |
5817 result = alloc((unsigned)STRLEN(from) * 6 + 1); | |
5818 if (result == NULL) /* out of memory */ | |
5819 { | |
5820 *bufp = NULL; | |
5821 return from; | |
5822 } | |
5823 | |
5824 src = from; | |
5825 | |
5826 /* | |
5827 * Check for #n at start only: function key n | |
5828 */ | |
5829 if (from_part && src[0] == '#' && VIM_ISDIGIT(src[1])) /* function key */ | |
5830 { | |
5831 result[dlen++] = K_SPECIAL; | |
5832 result[dlen++] = 'k'; | |
5833 if (src[1] == '0') | |
5834 result[dlen++] = ';'; /* #0 is F10 is "k;" */ | |
5835 else | |
5836 result[dlen++] = src[1]; /* #3 is F3 is "k3" */ | |
5837 src += 2; | |
5838 } | |
5839 | |
5840 /* | |
5841 * Copy each byte from *from to result[dlen] | |
5842 */ | |
5843 while (*src != NUL) | |
5844 { | |
5845 /* | |
5846 * 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
|
5847 * like "<C-S-LeftMouse>" |
7 | 5848 */ |
5849 if (do_special && (do_lt || STRNCMP(src, "<lt>", 4) != 0)) | |
5850 { | |
5851 #ifdef FEAT_EVAL | |
5852 /* | |
5853 * Replace <SID> by K_SNR <script-nr> _. | |
5854 * (room: 5 * 6 = 30 bytes; needed: 3 + <nr> + 1 <= 14) | |
5855 */ | |
5856 if (STRNICMP(src, "<SID>", 5) == 0) | |
5857 { | |
5858 if (current_SID <= 0) | |
5859 EMSG(_(e_usingsid)); | |
5860 else | |
5861 { | |
5862 src += 5; | |
5863 result[dlen++] = K_SPECIAL; | |
5864 result[dlen++] = (int)KS_EXTRA; | |
5865 result[dlen++] = (int)KE_SNR; | |
5866 sprintf((char *)result + dlen, "%ld", (long)current_SID); | |
5867 dlen += (int)STRLEN(result + dlen); | |
5868 result[dlen++] = '_'; | |
5869 continue; | |
5870 } | |
5871 } | |
5872 #endif | |
5873 | |
9869
989d44d35a66
commit https://github.com/vim/vim/commit/35a4cfa200917dd171b1fff3cd5b6cee9add673d
Christian Brabandt <cb@256bit.org>
parents:
9814
diff
changeset
|
5874 slen = trans_special(&src, result + dlen, TRUE, FALSE); |
7 | 5875 if (slen) |
5876 { | |
5877 dlen += slen; | |
5878 continue; | |
5879 } | |
5880 } | |
5881 | |
5882 /* | |
5883 * If 'cpoptions' does not contain 'k', see if it's an actual key-code. | |
5884 * Note that this is also checked after replacing the <> form. | |
5885 * Single character codes are NOT replaced (e.g. ^H or DEL), because | |
5886 * it could be a character in the file. | |
5887 */ | |
5888 if (do_key_code) | |
5889 { | |
5890 i = find_term_bykeys(src); | |
5891 if (i >= 0) | |
5892 { | |
5893 result[dlen++] = K_SPECIAL; | |
5894 result[dlen++] = termcodes[i].name[0]; | |
5895 result[dlen++] = termcodes[i].name[1]; | |
5896 src += termcodes[i].len; | |
5897 /* If terminal code matched, continue after it. */ | |
5898 continue; | |
5899 } | |
5900 } | |
5901 | |
5902 #ifdef FEAT_EVAL | |
5903 if (do_special) | |
5904 { | |
5905 char_u *p, *s, len; | |
5906 | |
5907 /* | |
5908 * Replace <Leader> by the value of "mapleader". | |
5909 * Replace <LocalLeader> by the value of "maplocalleader". | |
5910 * If "mapleader" or "maplocalleader" isn't set use a backslash. | |
5911 */ | |
5912 if (STRNICMP(src, "<Leader>", 8) == 0) | |
5913 { | |
5914 len = 8; | |
5915 p = get_var_value((char_u *)"g:mapleader"); | |
5916 } | |
5917 else if (STRNICMP(src, "<LocalLeader>", 13) == 0) | |
5918 { | |
5919 len = 13; | |
5920 p = get_var_value((char_u *)"g:maplocalleader"); | |
5921 } | |
5922 else | |
5923 { | |
5924 len = 0; | |
5925 p = NULL; | |
5926 } | |
5927 if (len != 0) | |
5928 { | |
5929 /* Allow up to 8 * 6 characters for "mapleader". */ | |
5930 if (p == NULL || *p == NUL || STRLEN(p) > 8 * 6) | |
5931 s = (char_u *)"\\"; | |
5932 else | |
5933 s = p; | |
5934 while (*s != NUL) | |
5935 result[dlen++] = *s++; | |
5936 src += len; | |
5937 continue; | |
5938 } | |
5939 } | |
5940 #endif | |
5941 | |
5942 /* | |
5943 * Remove CTRL-V and ignore the next character. | |
5944 * For "from" side the CTRL-V at the end is included, for the "to" | |
5945 * part it is removed. | |
5946 * If 'cpoptions' does not contain 'B', also accept a backslash. | |
5947 */ | |
5948 key = *src; | |
5949 if (key == Ctrl_V || (do_backslash && key == '\\')) | |
5950 { | |
5951 ++src; /* skip CTRL-V or backslash */ | |
5952 if (*src == NUL) | |
5953 { | |
5954 if (from_part) | |
5955 result[dlen++] = key; | |
5956 break; | |
5957 } | |
5958 } | |
5959 | |
5960 #ifdef FEAT_MBYTE | |
5961 /* skip multibyte char correctly */ | |
474 | 5962 for (i = (*mb_ptr2len)(src); i > 0; --i) |
7 | 5963 #endif |
5964 { | |
5965 /* | |
5966 * If the character is K_SPECIAL, replace it with K_SPECIAL | |
5967 * KS_SPECIAL KE_FILLER. | |
5968 * If compiled with the GUI replace CSI with K_CSI. | |
5969 */ | |
5970 if (*src == K_SPECIAL) | |
5971 { | |
5972 result[dlen++] = K_SPECIAL; | |
5973 result[dlen++] = KS_SPECIAL; | |
5974 result[dlen++] = KE_FILLER; | |
5975 } | |
5976 # ifdef FEAT_GUI | |
5977 else if (*src == CSI) | |
5978 { | |
5979 result[dlen++] = K_SPECIAL; | |
5980 result[dlen++] = KS_EXTRA; | |
5981 result[dlen++] = (int)KE_CSI; | |
5982 } | |
5983 # endif | |
5984 else | |
5985 result[dlen++] = *src; | |
5986 ++src; | |
5987 } | |
5988 } | |
5989 result[dlen] = NUL; | |
5990 | |
5991 /* | |
5992 * Copy the new string to allocated memory. | |
5993 * If this fails, just return from. | |
5994 */ | |
5995 if ((*bufp = vim_strsave(result)) != NULL) | |
5996 from = *bufp; | |
5997 vim_free(result); | |
5998 return from; | |
5999 } | |
6000 | |
6001 /* | |
6002 * Find a termcode with keys 'src' (must be NUL terminated). | |
6003 * Return the index in termcodes[], or -1 if not found. | |
6004 */ | |
6005 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6006 find_term_bykeys(char_u *src) |
7 | 6007 { |
6008 int i; | |
3290 | 6009 int slen = (int)STRLEN(src); |
7 | 6010 |
6011 for (i = 0; i < tc_len; ++i) | |
6012 { | |
3273 | 6013 if (slen == termcodes[i].len |
6014 && STRNCMP(termcodes[i].code, src, (size_t)slen) == 0) | |
7 | 6015 return i; |
6016 } | |
6017 return -1; | |
6018 } | |
6019 | |
6020 /* | |
6021 * Gather the first characters in the terminal key codes into a string. | |
6022 * Used to speed up check_termcode(). | |
6023 */ | |
6024 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6025 gather_termleader(void) |
7 | 6026 { |
6027 int i; | |
6028 int len = 0; | |
6029 | |
6030 #ifdef FEAT_GUI | |
6031 if (gui.in_use) | |
6032 termleader[len++] = CSI; /* the GUI codes are not in termcodes[] */ | |
6033 #endif | |
6034 #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
|
6035 if (check_for_codes || *T_CRS != NUL) |
7 | 6036 termleader[len++] = DCS; /* the termcode response starts with DCS |
6037 in 8-bit mode */ | |
6038 #endif | |
6039 termleader[len] = NUL; | |
6040 | |
6041 for (i = 0; i < tc_len; ++i) | |
6042 if (vim_strchr(termleader, termcodes[i].code[0]) == NULL) | |
6043 { | |
6044 termleader[len++] = termcodes[i].code[0]; | |
6045 termleader[len] = NUL; | |
6046 } | |
6047 | |
6048 need_gather = FALSE; | |
6049 } | |
6050 | |
6051 /* | |
6052 * Show all termcodes (for ":set termcap") | |
6053 * This code looks a lot like showoptions(), but is different. | |
6054 */ | |
6055 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6056 show_termcodes(void) |
7 | 6057 { |
6058 int col; | |
6059 int *items; | |
6060 int item_count; | |
6061 int run; | |
6062 int row, rows; | |
6063 int cols; | |
6064 int i; | |
6065 int len; | |
6066 | |
180 | 6067 #define INC3 27 /* try to make three columns */ |
6068 #define INC2 40 /* try to make two columns */ | |
7 | 6069 #define GAP 2 /* spaces between columns */ |
6070 | |
6071 if (tc_len == 0) /* no terminal codes (must be GUI) */ | |
6072 return; | |
6073 items = (int *)alloc((unsigned)(sizeof(int) * tc_len)); | |
6074 if (items == NULL) | |
6075 return; | |
6076 | |
6077 /* Highlight title */ | |
6078 MSG_PUTS_TITLE(_("\n--- Terminal keys ---")); | |
6079 | |
6080 /* | |
6081 * do the loop two times: | |
6082 * 1. display the short items (non-strings and short strings) | |
180 | 6083 * 2. display the medium items (medium length strings) |
6084 * 3. display the long items (remaining strings) | |
7 | 6085 */ |
180 | 6086 for (run = 1; run <= 3 && !got_int; ++run) |
7 | 6087 { |
6088 /* | |
6089 * collect the items in items[] | |
6090 */ | |
6091 item_count = 0; | |
6092 for (i = 0; i < tc_len; i++) | |
6093 { | |
6094 len = show_one_termcode(termcodes[i].name, | |
6095 termcodes[i].code, FALSE); | |
180 | 6096 if (len <= INC3 - GAP ? run == 1 |
6097 : len <= INC2 - GAP ? run == 2 | |
6098 : run == 3) | |
7 | 6099 items[item_count++] = i; |
6100 } | |
6101 | |
6102 /* | |
6103 * display the items | |
6104 */ | |
180 | 6105 if (run <= 2) |
7 | 6106 { |
180 | 6107 cols = (Columns + GAP) / (run == 1 ? INC3 : INC2); |
7 | 6108 if (cols == 0) |
6109 cols = 1; | |
6110 rows = (item_count + cols - 1) / cols; | |
6111 } | |
180 | 6112 else /* run == 3 */ |
7 | 6113 rows = item_count; |
6114 for (row = 0; row < rows && !got_int; ++row) | |
6115 { | |
6116 msg_putchar('\n'); /* go to next line */ | |
6117 if (got_int) /* 'q' typed in more */ | |
6118 break; | |
6119 col = 0; | |
6120 for (i = row; i < item_count; i += rows) | |
6121 { | |
6122 msg_col = col; /* make columns */ | |
6123 show_one_termcode(termcodes[items[i]].name, | |
6124 termcodes[items[i]].code, TRUE); | |
180 | 6125 if (run == 2) |
6126 col += INC2; | |
6127 else | |
6128 col += INC3; | |
7 | 6129 } |
6130 out_flush(); | |
6131 ui_breakcheck(); | |
6132 } | |
6133 } | |
6134 vim_free(items); | |
6135 } | |
6136 | |
6137 /* | |
6138 * Show one termcode entry. | |
6139 * Output goes into IObuff[] | |
6140 */ | |
6141 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6142 show_one_termcode(char_u *name, char_u *code, int printit) |
7 | 6143 { |
6144 char_u *p; | |
6145 int len; | |
6146 | |
6147 if (name[0] > '~') | |
6148 { | |
6149 IObuff[0] = ' '; | |
6150 IObuff[1] = ' '; | |
6151 IObuff[2] = ' '; | |
6152 IObuff[3] = ' '; | |
6153 } | |
6154 else | |
6155 { | |
6156 IObuff[0] = 't'; | |
6157 IObuff[1] = '_'; | |
6158 IObuff[2] = name[0]; | |
6159 IObuff[3] = name[1]; | |
6160 } | |
6161 IObuff[4] = ' '; | |
6162 | |
6163 p = get_special_key_name(TERMCAP2KEY(name[0], name[1]), 0); | |
6164 if (p[1] != 't') | |
6165 STRCPY(IObuff + 5, p); | |
6166 else | |
6167 IObuff[5] = NUL; | |
6168 len = (int)STRLEN(IObuff); | |
6169 do | |
6170 IObuff[len++] = ' '; | |
6171 while (len < 17); | |
6172 IObuff[len] = NUL; | |
6173 if (code == NULL) | |
6174 len += 4; | |
6175 else | |
6176 len += vim_strsize(code); | |
6177 | |
6178 if (printit) | |
6179 { | |
6180 msg_puts(IObuff); | |
6181 if (code == NULL) | |
6182 msg_puts((char_u *)"NULL"); | |
6183 else | |
6184 msg_outtrans(code); | |
6185 } | |
6186 return len; | |
6187 } | |
6188 | |
6189 #if defined(FEAT_TERMRESPONSE) || defined(PROTO) | |
6190 /* | |
6191 * For Xterm >= 140 compiled with OPT_TCAP_QUERY: Obtain the actually used | |
6192 * termcap codes from the terminal itself. | |
6193 * We get them one by one to avoid a very long response string. | |
6194 */ | |
6102 | 6195 static int xt_index_in = 0; |
6196 static int xt_index_out = 0; | |
6197 | |
7 | 6198 static void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6199 req_codes_from_term(void) |
7 | 6200 { |
6201 xt_index_out = 0; | |
6202 xt_index_in = 0; | |
6203 req_more_codes_from_term(); | |
6204 } | |
6205 | |
6206 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6207 req_more_codes_from_term(void) |
7 | 6208 { |
6209 char buf[11]; | |
6210 int old_idx = xt_index_out; | |
6211 | |
6212 /* Don't do anything when going to exit. */ | |
6213 if (exiting) | |
6214 return; | |
6215 | |
6216 /* Send up to 10 more requests out than we received. Avoid sending too | |
6217 * many, there can be a buffer overflow somewhere. */ | |
6218 while (xt_index_out < xt_index_in + 10 && key_names[xt_index_out] != NULL) | |
6219 { | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6220 # ifdef DEBUG_TERMRESPONSE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6221 char dbuf[100]; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6222 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6223 sprintf(dbuf, "Requesting XT %d: %s", |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6224 xt_index_out, key_names[xt_index_out]); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6225 log_tr(dbuf); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6226 # endif |
7 | 6227 sprintf(buf, "\033P+q%02x%02x\033\\", |
6228 key_names[xt_index_out][0], key_names[xt_index_out][1]); | |
6229 out_str_nf((char_u *)buf); | |
6230 ++xt_index_out; | |
6231 } | |
6232 | |
6233 /* Send the codes out right away. */ | |
6234 if (xt_index_out != old_idx) | |
6235 out_flush(); | |
6236 } | |
6237 | |
6238 /* | |
6239 * Decode key code response from xterm: '<Esc>P1+r<name>=<string><Esc>\'. | |
6240 * A "0" instead of the "1" indicates a code that isn't supported. | |
6241 * Both <name> and <string> are encoded in hex. | |
6242 * "code" points to the "0" or "1". | |
6243 */ | |
6244 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6245 got_code_from_term(char_u *code, int len) |
7 | 6246 { |
6247 #define XT_LEN 100 | |
6248 char_u name[3]; | |
6249 char_u str[XT_LEN]; | |
6250 int i; | |
6251 int j = 0; | |
6252 int c; | |
6253 | |
6254 /* A '1' means the code is supported, a '0' means it isn't. | |
6255 * When half the length is > XT_LEN we can't use it. | |
6256 * Our names are currently all 2 characters. */ | |
6257 if (code[0] == '1' && code[7] == '=' && len / 2 < XT_LEN) | |
6258 { | |
6259 /* Get the name from the response and find it in the table. */ | |
6260 name[0] = hexhex2nr(code + 3); | |
6261 name[1] = hexhex2nr(code + 5); | |
6262 name[2] = NUL; | |
6263 for (i = 0; key_names[i] != NULL; ++i) | |
6264 { | |
6265 if (STRCMP(key_names[i], name) == 0) | |
6266 { | |
6267 xt_index_in = i; | |
6268 break; | |
6269 } | |
6270 } | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6271 # ifdef DEBUG_TERMRESPONSE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6272 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6273 char buf[100]; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6274 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6275 sprintf(buf, "Received XT %d: %s", xt_index_in, (char *)name); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6276 log_tr(buf); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6277 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6278 # endif |
7 | 6279 if (key_names[i] != NULL) |
6280 { | |
6281 for (i = 8; (c = hexhex2nr(code + i)) >= 0; i += 2) | |
6282 str[j++] = c; | |
6283 str[j] = NUL; | |
6284 if (name[0] == 'C' && name[1] == 'o') | |
6285 { | |
6286 /* Color count is not a key code. */ | |
6287 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
|
6288 may_adjust_color_count(i); |
7 | 6289 } |
6290 else | |
6291 { | |
6292 /* First delete any existing entry with the same code. */ | |
6293 i = find_term_bykeys(str); | |
6294 if (i >= 0) | |
6295 del_termcode_idx(i); | |
180 | 6296 add_termcode(name, str, ATC_FROM_TERM); |
7 | 6297 } |
6298 } | |
6299 } | |
6300 | |
6301 /* May request more codes now that we received one. */ | |
6302 ++xt_index_in; | |
6303 req_more_codes_from_term(); | |
6304 } | |
6305 | |
6306 /* | |
6307 * Check if there are any unanswered requests and deal with them. | |
6308 * This is called before starting an external program or getting direct | |
6309 * keyboard input. We don't want responses to be send to that program or | |
6310 * handled as typed text. | |
6311 */ | |
6312 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6313 check_for_codes_from_term(void) |
7 | 6314 { |
6315 int c; | |
6316 | |
6317 /* If no codes requested or all are answered, no need to wait. */ | |
6318 if (xt_index_out == 0 || xt_index_out == xt_index_in) | |
6319 return; | |
6320 | |
6321 /* Vgetc() will check for and handle any response. | |
6322 * Keep calling vpeekc() until we don't get any responses. */ | |
6323 ++no_mapping; | |
6324 ++allow_keys; | |
6325 for (;;) | |
6326 { | |
6327 c = vpeekc(); | |
6328 if (c == NUL) /* nothing available */ | |
6329 break; | |
6330 | |
6331 /* If a response is recognized it's replaced with K_IGNORE, must read | |
6332 * it from the input stream. If there is no K_IGNORE we can't do | |
6333 * anything, break here (there might be some responses further on, but | |
6334 * we don't want to throw away any typed chars). */ | |
6335 if (c != K_SPECIAL && c != K_IGNORE) | |
6336 break; | |
6337 c = vgetc(); | |
6338 if (c != K_IGNORE) | |
6339 { | |
6340 vungetc(c); | |
6341 break; | |
6342 } | |
6343 } | |
6344 --no_mapping; | |
6345 --allow_keys; | |
6346 } | |
6347 #endif | |
6348 | |
6349 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) | |
6350 /* | |
6351 * Translate an internal mapping/abbreviation representation into the | |
6352 * corresponding external one recognized by :map/:abbrev commands; | |
6353 * respects the current B/k/< settings of 'cpoption'. | |
6354 * | |
6355 * This function is called when expanding mappings/abbreviations on the | |
1902 | 6356 * command-line, and for building the "Ambiguous mapping..." error message. |
7 | 6357 * |
6358 * It uses a growarray to build the translation string since the | |
6359 * latter can be wider than the original description. The caller has to | |
6360 * free the string afterwards. | |
6361 * | |
6362 * Returns NULL when there is a problem. | |
6363 */ | |
6364 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6365 translate_mapping( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6366 char_u *str, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6367 int expmap) /* TRUE when expanding mappings on command-line */ |
7 | 6368 { |
6369 garray_T ga; | |
6370 int c; | |
6371 int modifiers; | |
6372 int cpo_bslash; | |
6373 int cpo_special; | |
6374 int cpo_keycode; | |
6375 | |
6376 ga_init(&ga); | |
6377 ga.ga_itemsize = 1; | |
6378 ga.ga_growsize = 40; | |
6379 | |
6380 cpo_bslash = (vim_strchr(p_cpo, CPO_BSLASH) != NULL); | |
6381 cpo_special = (vim_strchr(p_cpo, CPO_SPECI) != NULL); | |
6382 cpo_keycode = (vim_strchr(p_cpo, CPO_KEYCODE) == NULL); | |
6383 | |
6384 for (; *str; ++str) | |
6385 { | |
6386 c = *str; | |
6387 if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL) | |
6388 { | |
6389 modifiers = 0; | |
6390 if (str[1] == KS_MODIFIER) | |
6391 { | |
6392 str++; | |
6393 modifiers = *++str; | |
6394 c = *++str; | |
6395 } | |
6396 if (cpo_special && cpo_keycode && c == K_SPECIAL && !modifiers) | |
6397 { | |
6398 int i; | |
6399 | |
6400 /* try to find special key in termcodes */ | |
6401 for (i = 0; i < tc_len; ++i) | |
6402 if (termcodes[i].name[0] == str[1] | |
6403 && termcodes[i].name[1] == str[2]) | |
6404 break; | |
6405 if (i < tc_len) | |
6406 { | |
6407 ga_concat(&ga, termcodes[i].code); | |
6408 str += 2; | |
6409 continue; /* for (str) */ | |
6410 } | |
6411 } | |
6412 if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL) | |
6413 { | |
6414 if (expmap && cpo_special) | |
6415 { | |
6416 ga_clear(&ga); | |
6417 return NULL; | |
6418 } | |
6419 c = TO_SPECIAL(str[1], str[2]); | |
6420 if (c == K_ZERO) /* display <Nul> as ^@ */ | |
6421 c = NUL; | |
6422 str += 2; | |
6423 } | |
6424 if (IS_SPECIAL(c) || modifiers) /* special key */ | |
6425 { | |
6426 if (expmap && cpo_special) | |
6427 { | |
6428 ga_clear(&ga); | |
6429 return NULL; | |
6430 } | |
6431 ga_concat(&ga, get_special_key_name(c, modifiers)); | |
6432 continue; /* for (str) */ | |
6433 } | |
6434 } | |
6435 if (c == ' ' || c == '\t' || c == Ctrl_J || c == Ctrl_V | |
6436 || (c == '<' && !cpo_special) || (c == '\\' && !cpo_bslash)) | |
6437 ga_append(&ga, cpo_bslash ? Ctrl_V : '\\'); | |
6438 if (c) | |
6439 ga_append(&ga, c); | |
6440 } | |
6441 ga_append(&ga, NUL); | |
6442 return (char_u *)(ga.ga_data); | |
6443 } | |
6444 #endif | |
6445 | |
6446 #if (defined(WIN3264) && !defined(FEAT_GUI)) || defined(PROTO) | |
6447 static char ksme_str[20]; | |
6448 static char ksmr_str[20]; | |
6449 static char ksmd_str[20]; | |
6450 | |
6451 /* | |
6452 * For Win32 console: update termcap codes for existing console attributes. | |
6453 */ | |
6454 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6455 update_tcap(int attr) |
7 | 6456 { |
6457 struct builtin_term *p; | |
6458 | |
6459 p = find_builtin_term(DEFAULT_TERM); | |
6460 sprintf(ksme_str, IF_EB("\033|%dm", ESC_STR "|%dm"), attr); | |
6461 sprintf(ksmd_str, IF_EB("\033|%dm", ESC_STR "|%dm"), | |
6462 attr | 0x08); /* FOREGROUND_INTENSITY */ | |
6463 sprintf(ksmr_str, IF_EB("\033|%dm", ESC_STR "|%dm"), | |
6464 ((attr & 0x0F) << 4) | ((attr & 0xF0) >> 4)); | |
6465 | |
6466 while (p->bt_string != NULL) | |
6467 { | |
6468 if (p->bt_entry == (int)KS_ME) | |
6469 p->bt_string = &ksme_str[0]; | |
6470 else if (p->bt_entry == (int)KS_MR) | |
6471 p->bt_string = &ksmr_str[0]; | |
6472 else if (p->bt_entry == (int)KS_MD) | |
6473 p->bt_string = &ksmd_str[0]; | |
6474 ++p; | |
6475 } | |
6476 } | |
6477 #endif | |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6478 |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
6479 #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
|
6480 static int |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6481 hex_digit(int c) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6482 { |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6483 if (isdigit(c)) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6484 return c - '0'; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6485 c = TOLOWER_ASC(c); |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6486 if (c >= 'a' && c <= 'f') |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6487 return c - 'a' + 10; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6488 return 0x1ffffff; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6489 } |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6490 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6491 guicolor_T |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6492 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
|
6493 { |
10512
675dfe47ab69
commit https://github.com/vim/vim/commit/287266527abc163e191a06dd70518bbbdab4468f
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
6494 /* On MS-Windows an RGB macro is available and it produces 0x00bbggrr color |
675dfe47ab69
commit https://github.com/vim/vim/commit/287266527abc163e191a06dd70518bbbdab4468f
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
6495 * values as used by the MS-Windows GDI api. It should be used only for |
675dfe47ab69
commit https://github.com/vim/vim/commit/287266527abc163e191a06dd70518bbbdab4468f
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
6496 * MS-Windows GDI builds. */ |
675dfe47ab69
commit https://github.com/vim/vim/commit/287266527abc163e191a06dd70518bbbdab4468f
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
6497 # if defined(RGB) && defined(WIN32) && !defined(FEAT_GUI) |
675dfe47ab69
commit https://github.com/vim/vim/commit/287266527abc163e191a06dd70518bbbdab4468f
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
6498 # undef RGB |
675dfe47ab69
commit https://github.com/vim/vim/commit/287266527abc163e191a06dd70518bbbdab4468f
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
6499 # endif |
9021
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6500 # ifndef RGB |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6501 # 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
|
6502 # endif |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6503 # define LINE_LEN 100 |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6504 FILE *fd; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6505 char line[LINE_LEN]; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6506 char_u *fname; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6507 int r, g, b, i; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6508 guicolor_T color; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6509 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6510 struct rgbcolor_table_S { |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6511 char_u *color_name; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6512 guicolor_T color; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6513 }; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6514 |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6515 /* Only non X11 colors (not present in rgb.txt) and colors in |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6516 * 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
|
6517 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
|
6518 {(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
|
6519 {(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
|
6520 {(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
|
6521 {(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
|
6522 {(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
|
6523 {(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
|
6524 {(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
|
6525 {(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
|
6526 {(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
|
6527 {(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
|
6528 {(char_u *)"darkred", RGB(0x8B, 0x00, 0x00)}, |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6529 {(char_u *)"darkyellow", RGB(0x8B, 0x8B, 0x00)}, /* No X11 */ |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6530 {(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
|
6531 {(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
|
6532 {(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
|
6533 {(char_u *)"grey40", RGB(0x66, 0x66, 0x66)}, |
9601
9cc49b86f613
commit https://github.com/vim/vim/commit/ca8942c6e331a69ddd533dd78931f399f7dcaa79
Christian Brabandt <cb@256bit.org>
parents:
9591
diff
changeset
|
6534 {(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
|
6535 {(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
|
6536 {(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
|
6537 {(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
|
6538 {(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
|
6539 {(char_u *)"lightgrey", RGB(0xD3, 0xD3, 0xD3)}, |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6540 {(char_u *)"lightmagenta", RGB(0xFF, 0x8B, 0xFF)}, /* No X11 */ |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6541 {(char_u *)"lightred", RGB(0xFF, 0x8B, 0x8B)}, /* No X11 */ |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6542 {(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
|
6543 {(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
|
6544 {(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
|
6545 {(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
|
6546 {(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
|
6547 {(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
|
6548 }; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6549 |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6550 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
|
6551 static int size = 0; |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6552 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6553 if (name[0] == '#' && STRLEN(name) == 7) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6554 { |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6555 /* Name is in "#rrggbb" format */ |
9021
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6556 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
|
6557 ((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
|
6558 ((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
|
6559 if (color > 0xffffff) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6560 return INVALCOLOR; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6561 return color; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6562 } |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6563 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6564 /* Check if the name is one of the colors we know */ |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6565 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
|
6566 if (STRICMP(name, rgb_table[i].color_name) == 0) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6567 return rgb_table[i].color; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6568 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6569 /* |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6570 * Last attempt. Look in the file "$VIM/rgb.txt". |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6571 */ |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6572 if (size == 0) |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6573 { |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6574 int counting; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6575 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6576 /* colornames_table not yet initialized */ |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6577 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
|
6578 if (fname == NULL) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6579 return INVALCOLOR; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6580 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6581 fd = fopen((char *)fname, "rt"); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6582 vim_free(fname); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6583 if (fd == NULL) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6584 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6585 if (p_verbose > 1) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6586 verb_msg((char_u *)_("Cannot open $VIMRUNTIME/rgb.txt")); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6587 return INVALCOLOR; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6588 } |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6589 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6590 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
|
6591 { |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6592 if (!counting) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6593 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6594 colornames_table = (struct rgbcolor_table_S *)alloc( |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6595 (unsigned)(sizeof(struct rgbcolor_table_S) * size)); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6596 if (colornames_table == NULL) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6597 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6598 fclose(fd); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6599 return INVALCOLOR; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6600 } |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6601 rewind(fd); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6602 } |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6603 size = 0; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6604 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6605 while (!feof(fd)) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6606 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6607 size_t len; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6608 int pos; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6609 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6610 ignoredp = fgets(line, LINE_LEN, fd); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6611 len = strlen(line); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6612 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6613 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
|
6614 continue; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6615 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6616 line[len - 1] = '\0'; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6617 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6618 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
|
6619 if (i != 3) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6620 continue; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6621 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6622 if (!counting) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6623 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6624 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
|
6625 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6626 if (s == NULL) |
9628
fefd0551aa9d
commit https://github.com/vim/vim/commit/2e45d21c819272051f7ef4436f483e4b2ecfb369
Christian Brabandt <cb@256bit.org>
parents:
9601
diff
changeset
|
6627 { |
fefd0551aa9d
commit https://github.com/vim/vim/commit/2e45d21c819272051f7ef4436f483e4b2ecfb369
Christian Brabandt <cb@256bit.org>
parents:
9601
diff
changeset
|
6628 fclose(fd); |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6629 return INVALCOLOR; |
9628
fefd0551aa9d
commit https://github.com/vim/vim/commit/2e45d21c819272051f7ef4436f483e4b2ecfb369
Christian Brabandt <cb@256bit.org>
parents:
9601
diff
changeset
|
6630 } |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6631 colornames_table[size].color_name = s; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6632 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
|
6633 } |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6634 size++; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6635 } |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6636 } |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6637 fclose(fd); |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6638 } |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6639 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6640 for (i = 0; i < size; i++) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6641 if (STRICMP(name, colornames_table[i].color_name) == 0) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6642 return colornames_table[i].color; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6643 |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6644 return INVALCOLOR; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6645 } |
11745
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11739
diff
changeset
|
6646 |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11739
diff
changeset
|
6647 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
|
6648 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
|
6649 { |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11739
diff
changeset
|
6650 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
|
6651 |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11739
diff
changeset
|
6652 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
|
6653 return INVALCOLOR; |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11739
diff
changeset
|
6654 return color; |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11739
diff
changeset
|
6655 } |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6656 #endif |