Mercurial > vim
annotate src/term.c @ 12259:48eac9bc2f82 v8.0.1009
patch 8.0.1009: Xterm cursor blinking status may be inverted
commit https://github.com/vim/vim/commit/4db2554954056f21f2ba4cf4988c652745d7042a
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Aug 28 22:43:05 2017 +0200
patch 8.0.1009: Xterm cursor blinking status may be inverted
Problem: Xterm cursor blinking status may be inverted.
Solution: Use another request to get the blink status and compare with the
cursor style report
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 28 Aug 2017 22:45:04 +0200 |
parents | 2b333727279d |
children | 875d7cc9b127 |
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 */ |
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
|
1372 # 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
|
1373 static int is_terminal_app = FALSE; /* recognized Terminal.app */ |
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
|
1374 # endif |
7 | 1375 #endif |
1376 | |
1377 static struct builtin_term * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1378 find_builtin_term(char_u *term) |
7 | 1379 { |
1380 struct builtin_term *p; | |
1381 | |
1382 p = builtin_termcaps; | |
1383 while (p->bt_string != NULL) | |
1384 { | |
1385 if (p->bt_entry == (int)KS_NAME) | |
1386 { | |
1387 #ifdef UNIX | |
1388 if (STRCMP(p->bt_string, "iris-ansi") == 0 && vim_is_iris(term)) | |
1389 return p; | |
1390 else if (STRCMP(p->bt_string, "xterm") == 0 && vim_is_xterm(term)) | |
1391 return p; | |
1392 else | |
1393 #endif | |
1394 #ifdef VMS | |
1395 if (STRCMP(p->bt_string, "vt320") == 0 && vim_is_vt300(term)) | |
1396 return p; | |
1397 else | |
1398 #endif | |
1399 if (STRCMP(term, p->bt_string) == 0) | |
1400 return p; | |
1401 } | |
1402 ++p; | |
1403 } | |
1404 return p; | |
1405 } | |
1406 | |
1407 /* | |
1408 * Parsing of the builtin termcap entries. | |
1409 * Caller should check if 'name' is a valid builtin term. | |
1410 * The terminal's name is not set, as this is already done in termcapinit(). | |
1411 */ | |
1412 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1413 parse_builtin_tcap(char_u *term) |
7 | 1414 { |
1415 struct builtin_term *p; | |
1416 char_u name[2]; | |
1417 int term_8bit; | |
1418 | |
1419 p = find_builtin_term(term); | |
1420 term_8bit = term_is_8bit(term); | |
1421 | |
1422 /* Do not parse if builtin term not found */ | |
1423 if (p->bt_string == NULL) | |
1424 return; | |
1425 | |
1426 for (++p; p->bt_entry != (int)KS_NAME && p->bt_entry != BT_EXTRA_KEYS; ++p) | |
1427 { | |
1428 if ((int)p->bt_entry >= 0) /* KS_xx entry */ | |
1429 { | |
1430 /* Only set the value if it wasn't set yet. */ | |
1431 if (term_strings[p->bt_entry] == NULL | |
1432 || term_strings[p->bt_entry] == empty_option) | |
1433 { | |
1434 /* 8bit terminal: use CSI instead of <Esc>[ */ | |
1435 if (term_8bit && term_7to8bit((char_u *)p->bt_string) != 0) | |
1436 { | |
1437 char_u *s, *t; | |
1438 | |
1439 s = vim_strsave((char_u *)p->bt_string); | |
1440 if (s != NULL) | |
1441 { | |
1442 for (t = s; *t; ++t) | |
1443 if (term_7to8bit(t)) | |
1444 { | |
1445 *t = term_7to8bit(t); | |
1446 STRCPY(t + 1, t + 2); | |
1447 } | |
1448 term_strings[p->bt_entry] = s; | |
1449 set_term_option_alloced(&term_strings[p->bt_entry]); | |
1450 } | |
1451 } | |
1452 else | |
1453 term_strings[p->bt_entry] = (char_u *)p->bt_string; | |
1454 } | |
1455 } | |
1456 else | |
1457 { | |
1458 name[0] = KEY2TERMCAP0((int)p->bt_entry); | |
1459 name[1] = KEY2TERMCAP1((int)p->bt_entry); | |
1460 if (find_termcode(name) == NULL) | |
1461 add_termcode(name, (char_u *)p->bt_string, term_8bit); | |
1462 } | |
1463 } | |
1464 } | |
11739
5c69c6d9e2eb
patch 8.0.0752: build fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11731
diff
changeset
|
1465 |
7 | 1466 /* |
1467 * Set number of colors. | |
1468 * Store it as a number in t_colors. | |
1469 * Store it as a string in T_CCO (using nr_colors[]). | |
1470 */ | |
1471 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1472 set_color_count(int nr) |
7 | 1473 { |
1474 char_u nr_colors[20]; /* string for number of colors */ | |
1475 | |
1476 t_colors = nr; | |
1477 if (t_colors > 1) | |
1478 sprintf((char *)nr_colors, "%d", t_colors); | |
1479 else | |
1480 *nr_colors = NUL; | |
694 | 1481 set_string_option_direct((char_u *)"t_Co", -1, nr_colors, OPT_FREE, 0); |
7 | 1482 } |
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 |
11739
5c69c6d9e2eb
patch 8.0.0752: build fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11731
diff
changeset
|
1484 #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
|
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 * 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
|
1487 */ |
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 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
|
1489 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
|
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 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
|
1492 { |
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 /* 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
|
1494 * 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
|
1495 * 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
|
1496 * 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
|
1497 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
|
1498 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
|
1499 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
|
1500 # 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
|
1501 { |
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 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
|
1503 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
|
1504 |
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 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
|
1506 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
|
1507 } |
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 # 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
|
1509 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
|
1510 # 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
|
1511 } |
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
|
1512 } |
7 | 1513 #endif |
1514 | |
1515 #ifdef HAVE_TGETENT | |
1516 static char *(key_names[]) = | |
1517 { | |
1518 #ifdef FEAT_TERMRESPONSE | |
1519 /* Do this one first, it may cause a screen redraw. */ | |
1520 "Co", | |
1521 #endif | |
1522 "ku", "kd", "kr", "kl", | |
1523 "#2", "#4", "%i", "*7", | |
1524 "k1", "k2", "k3", "k4", "k5", "k6", | |
1525 "k7", "k8", "k9", "k;", "F1", "F2", | |
1526 "%1", "&8", "kb", "kI", "kD", "kh", | |
1527 "@7", "kP", "kN", "K1", "K3", "K4", "K5", "kB", | |
1528 NULL | |
1529 }; | |
1530 #endif | |
1531 | |
1532 /* | |
1533 * Set terminal options for terminal "term". | |
1534 * Return OK if terminal 'term' was found in a termcap, FAIL otherwise. | |
1535 * | |
1536 * While doing this, until ttest(), some options may be NULL, be careful. | |
1537 */ | |
1538 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1539 set_termname(char_u *term) |
7 | 1540 { |
1541 struct builtin_term *termp; | |
1542 #ifdef HAVE_TGETENT | |
1543 int builtin_first = p_tbi; | |
1544 int try; | |
1545 int termcap_cleared = FALSE; | |
1546 #endif | |
1547 int width = 0, height = 0; | |
1548 char_u *error_msg = NULL; | |
1549 char_u *bs_p, *del_p; | |
1550 | |
168 | 1551 /* In silect mode (ex -s) we don't use the 'term' option. */ |
1552 if (silent_mode) | |
1553 return OK; | |
1554 | |
7 | 1555 detected_8bit = FALSE; /* reset 8-bit detection */ |
1556 | |
1557 if (term_is_builtin(term)) | |
1558 { | |
1559 term += 8; | |
1560 #ifdef HAVE_TGETENT | |
1561 builtin_first = 1; | |
1562 #endif | |
1563 } | |
1564 | |
1565 /* | |
1566 * If HAVE_TGETENT is not defined, only the builtin termcap is used, otherwise: | |
1567 * If builtin_first is TRUE: | |
1568 * 0. try builtin termcap | |
1569 * 1. try external termcap | |
1570 * 2. if both fail default to a builtin terminal | |
1571 * If builtin_first is FALSE: | |
1572 * 1. try external termcap | |
1573 * 2. try builtin termcap, if both fail default to a builtin terminal | |
1574 */ | |
1575 #ifdef HAVE_TGETENT | |
1576 for (try = builtin_first ? 0 : 1; try < 3; ++try) | |
1577 { | |
1578 /* | |
1579 * Use external termcap | |
1580 */ | |
1581 if (try == 1) | |
1582 { | |
1583 char_u *p; | |
1584 static char_u tstrbuf[TBUFSZ]; | |
1585 int i; | |
1586 char_u tbuf[TBUFSZ]; | |
1587 char_u *tp; | |
1588 static struct { | |
1589 enum SpecialKey dest; /* index in term_strings[] */ | |
1590 char *name; /* termcap name for string */ | |
1591 } string_names[] = | |
1592 { {KS_CE, "ce"}, {KS_AL, "al"}, {KS_CAL,"AL"}, | |
1593 {KS_DL, "dl"}, {KS_CDL,"DL"}, {KS_CS, "cs"}, | |
1594 {KS_CL, "cl"}, {KS_CD, "cd"}, | |
1595 {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
|
1596 {KS_ME, "me"}, {KS_MR, "mr"}, |
7 | 1597 {KS_MD, "md"}, {KS_SE, "se"}, {KS_SO, "so"}, |
1598 {KS_CZH,"ZH"}, {KS_CZR,"ZR"}, {KS_UE, "ue"}, | |
205 | 1599 {KS_US, "us"}, {KS_UCE, "Ce"}, {KS_UCS, "Cs"}, |
1600 {KS_CM, "cm"}, {KS_SR, "sr"}, | |
7 | 1601 {KS_CRI,"RI"}, {KS_VB, "vb"}, {KS_KS, "ks"}, |
1602 {KS_KE, "ke"}, {KS_TI, "ti"}, {KS_TE, "te"}, | |
1603 {KS_BC, "bc"}, {KS_CSB,"Sb"}, {KS_CSF,"Sf"}, | |
1604 {KS_CAB,"AB"}, {KS_CAF,"AF"}, {KS_LE, "le"}, | |
1605 {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
|
1606 {KS_VS, "vs"}, {KS_CVS, "VS"}, |
7 | 1607 {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
|
1608 {KS_CSC, "SC"}, {KS_CEC, "EC"}, |
7 | 1609 {KS_TS, "ts"}, {KS_FS, "fs"}, |
1610 {KS_CWP, "WP"}, {KS_CWS, "WS"}, | |
36 | 1611 {KS_CSI, "SI"}, {KS_CEI, "EI"}, |
6882 | 1612 {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
|
1613 {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
|
1614 {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
|
1615 {KS_CPS, "PS"}, {KS_CPE, "PE"}, |
7 | 1616 {(enum SpecialKey)0, NULL} |
1617 }; | |
1618 | |
1619 /* | |
1620 * If the external termcap does not have a matching entry, try the | |
1621 * builtin ones. | |
1622 */ | |
1623 if ((error_msg = tgetent_error(tbuf, term)) == NULL) | |
1624 { | |
1625 tp = tstrbuf; | |
1626 if (!termcap_cleared) | |
1627 { | |
1628 clear_termoptions(); /* clear old options */ | |
1629 termcap_cleared = TRUE; | |
1630 } | |
1631 | |
1632 /* get output strings */ | |
1633 for (i = 0; string_names[i].name != NULL; ++i) | |
1634 { | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
10676
diff
changeset
|
1635 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
|
1636 || 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
|
1637 TERM_STR(string_names[i].dest) = |
7 | 1638 TGETSTR(string_names[i].name, &tp); |
1639 } | |
1640 | |
1641 /* tgetflag() returns 1 if the flag is present, 0 if not and | |
1642 * possibly -1 if the flag doesn't exist. */ | |
1643 if ((T_MS == NULL || T_MS == empty_option) | |
1644 && tgetflag("ms") > 0) | |
1645 T_MS = (char_u *)"y"; | |
1646 if ((T_XS == NULL || T_XS == empty_option) | |
1647 && tgetflag("xs") > 0) | |
1648 T_XS = (char_u *)"y"; | |
6602 | 1649 if ((T_XN == NULL || T_XN == empty_option) |
1650 && tgetflag("xn") > 0) | |
1651 T_XN = (char_u *)"y"; | |
7 | 1652 if ((T_DB == NULL || T_DB == empty_option) |
1653 && tgetflag("db") > 0) | |
1654 T_DB = (char_u *)"y"; | |
1655 if ((T_DA == NULL || T_DA == empty_option) | |
1656 && tgetflag("da") > 0) | |
1657 T_DA = (char_u *)"y"; | |
1658 if ((T_UT == NULL || T_UT == empty_option) | |
1659 && tgetflag("ut") > 0) | |
1660 T_UT = (char_u *)"y"; | |
1661 | |
1662 | |
1663 /* | |
1664 * get key codes | |
1665 */ | |
1666 for (i = 0; key_names[i] != NULL; ++i) | |
1667 { | |
1668 if (find_termcode((char_u *)key_names[i]) == NULL) | |
1669 { | |
1670 p = TGETSTR(key_names[i], &tp); | |
1671 /* if cursor-left == backspace, ignore it (televideo | |
1672 * 925) */ | |
1673 if (p != NULL | |
1674 && (*p != Ctrl_H | |
1675 || key_names[i][0] != 'k' | |
1676 || key_names[i][1] != 'l')) | |
1677 add_termcode((char_u *)key_names[i], p, FALSE); | |
1678 } | |
1679 } | |
1680 | |
1681 if (height == 0) | |
1682 height = tgetnum("li"); | |
1683 if (width == 0) | |
1684 width = tgetnum("co"); | |
1685 | |
1686 /* | |
1687 * Get number of colors (if not done already). | |
1688 */ | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
10676
diff
changeset
|
1689 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
|
1690 || TERM_STR(KS_CCO) == empty_option) |
7 | 1691 set_color_count(tgetnum("Co")); |
1692 | |
1693 # ifndef hpux | |
1694 BC = (char *)TGETSTR("bc", &tp); | |
1695 UP = (char *)TGETSTR("up", &tp); | |
1696 p = TGETSTR("pc", &tp); | |
1697 if (p) | |
1698 PC = *p; | |
1699 # endif /* hpux */ | |
1700 } | |
1701 } | |
1702 else /* try == 0 || try == 2 */ | |
1703 #endif /* HAVE_TGETENT */ | |
1704 /* | |
1705 * Use builtin termcap | |
1706 */ | |
1707 { | |
1708 #ifdef HAVE_TGETENT | |
1709 /* | |
1710 * If builtin termcap was already used, there is no need to search | |
1711 * for the builtin termcap again, quit now. | |
1712 */ | |
1713 if (try == 2 && builtin_first && termcap_cleared) | |
1714 break; | |
1715 #endif | |
1716 /* | |
1717 * search for 'term' in builtin_termcaps[] | |
1718 */ | |
1719 termp = find_builtin_term(term); | |
1720 if (termp->bt_string == NULL) /* did not find it */ | |
1721 { | |
1722 #ifdef HAVE_TGETENT | |
1723 /* | |
1724 * If try == 0, first try the external termcap. If that is not | |
1725 * found we'll get back here with try == 2. | |
1726 * If termcap_cleared is set we used the external termcap, | |
1727 * don't complain about not finding the term in the builtin | |
1728 * termcap. | |
1729 */ | |
1730 if (try == 0) /* try external one */ | |
1731 continue; | |
1732 if (termcap_cleared) /* found in external termcap */ | |
1733 break; | |
1734 #endif | |
1735 | |
1736 mch_errmsg("\r\n"); | |
1737 if (error_msg != NULL) | |
1738 { | |
1739 mch_errmsg((char *)error_msg); | |
1740 mch_errmsg("\r\n"); | |
1741 } | |
1742 mch_errmsg("'"); | |
1743 mch_errmsg((char *)term); | |
1744 mch_errmsg(_("' not known. Available builtin terminals are:")); | |
1745 mch_errmsg("\r\n"); | |
1746 for (termp = &(builtin_termcaps[0]); termp->bt_string != NULL; | |
1747 ++termp) | |
1748 { | |
1749 if (termp->bt_entry == (int)KS_NAME) | |
1750 { | |
1751 #ifdef HAVE_TGETENT | |
1752 mch_errmsg(" builtin_"); | |
1753 #else | |
1754 mch_errmsg(" "); | |
1755 #endif | |
1756 mch_errmsg(termp->bt_string); | |
1757 mch_errmsg("\r\n"); | |
1758 } | |
1759 } | |
1760 /* when user typed :set term=xxx, quit here */ | |
1761 if (starting != NO_SCREEN) | |
1762 { | |
1763 screen_start(); /* don't know where cursor is now */ | |
1764 wait_return(TRUE); | |
1765 return FAIL; | |
1766 } | |
1767 term = DEFAULT_TERM; | |
1768 mch_errmsg(_("defaulting to '")); | |
1769 mch_errmsg((char *)term); | |
1770 mch_errmsg("'\r\n"); | |
1771 if (emsg_silent == 0) | |
1772 { | |
1773 screen_start(); /* don't know where cursor is now */ | |
1774 out_flush(); | |
11307
6e1c19d3de03
patch 8.0.0539: startup test fails on Mac
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1775 if (!is_not_a_term()) |
6e1c19d3de03
patch 8.0.0539: startup test fails on Mac
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1776 ui_delay(2000L, TRUE); |
7 | 1777 } |
694 | 1778 set_string_option_direct((char_u *)"term", -1, term, |
1779 OPT_FREE, 0); | |
7 | 1780 display_errors(); |
1781 } | |
1782 out_flush(); | |
1783 #ifdef HAVE_TGETENT | |
1784 if (!termcap_cleared) | |
1785 { | |
1786 #endif | |
1787 clear_termoptions(); /* clear old options */ | |
1788 #ifdef HAVE_TGETENT | |
1789 termcap_cleared = TRUE; | |
1790 } | |
1791 #endif | |
1792 parse_builtin_tcap(term); | |
1793 #ifdef FEAT_GUI | |
1794 if (term_is_gui(term)) | |
1795 { | |
1796 out_flush(); | |
1797 gui_init(); | |
1798 /* If starting the GUI failed, don't do any of the other | |
1799 * things for this terminal */ | |
1800 if (!gui.in_use) | |
1801 return FAIL; | |
1802 #ifdef HAVE_TGETENT | |
1803 break; /* don't try using external termcap */ | |
1804 #endif | |
1805 } | |
1806 #endif /* FEAT_GUI */ | |
1807 } | |
1808 #ifdef HAVE_TGETENT | |
1809 } | |
1810 #endif | |
1811 | |
1812 /* | |
1813 * special: There is no info in the termcap about whether the cursor | |
1814 * positioning is relative to the start of the screen or to the start of the | |
1815 * scrolling region. We just guess here. Only msdos pcterm is known to do it | |
1816 * relative. | |
1817 */ | |
1818 if (STRCMP(term, "pcterm") == 0) | |
1819 T_CCS = (char_u *)"yes"; | |
1820 else | |
1821 T_CCS = empty_option; | |
1822 | |
1823 #ifdef UNIX | |
1824 /* | |
1825 * Any "stty" settings override the default for t_kb from the termcap. | |
1826 * This is in os_unix.c, because it depends a lot on the version of unix that | |
1827 * is being used. | |
1828 * Don't do this when the GUI is active, it uses "t_kb" and "t_kD" directly. | |
1829 */ | |
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 # ifdef FEAT_GUI |
7 | 1831 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
|
1832 # endif |
7 | 1833 get_stty(); |
1834 #endif | |
1835 | |
1836 /* | |
1837 * If the termcap has no entry for 'bs' and/or 'del' and the ioctl() also | |
1838 * didn't work, use the default CTRL-H | |
1839 * The default for t_kD is DEL, unless t_kb is DEL. | |
1840 * The vim_strsave'd strings are probably lost forever, well it's only two | |
1841 * bytes. Don't do this when the GUI is active, it uses "t_kb" and "t_kD" | |
1842 * directly. | |
1843 */ | |
1844 #ifdef FEAT_GUI | |
1845 if (!gui.in_use) | |
1846 #endif | |
1847 { | |
1848 bs_p = find_termcode((char_u *)"kb"); | |
1849 del_p = find_termcode((char_u *)"kD"); | |
1850 if (bs_p == NULL || *bs_p == NUL) | |
1851 add_termcode((char_u *)"kb", (bs_p = (char_u *)CTRL_H_STR), FALSE); | |
1852 if ((del_p == NULL || *del_p == NUL) && | |
1853 (bs_p == NULL || *bs_p != DEL)) | |
1854 add_termcode((char_u *)"kD", (char_u *)DEL_STR, FALSE); | |
1855 } | |
1856 | |
1857 #if defined(UNIX) || defined(VMS) | |
1858 term_is_xterm = vim_is_xterm(term); | |
1859 #endif | |
1860 | |
1861 #ifdef FEAT_MOUSE | |
1862 # if defined(UNIX) || defined(VMS) | |
1863 # ifdef FEAT_MOUSE_TTY | |
1864 /* | |
1865 * For Unix, set the 'ttymouse' option to the type of mouse to be used. | |
1866 * The termcode for the mouse is added as a side effect in option.c. | |
1867 */ | |
1868 { | |
11563
2547bbe6716e
patch 8.0.0664: mouse does not work in tmux
Christian Brabandt <cb@256bit.org>
parents:
11557
diff
changeset
|
1869 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
|
1870 |
7 | 1871 # ifdef FEAT_MOUSE_XTERM |
1623 | 1872 if (use_xterm_like_mouse(term)) |
7 | 1873 { |
1874 if (use_xterm_mouse()) | |
1875 p = NULL; /* keep existing value, might be "xterm2" */ | |
1876 else | |
1877 p = (char_u *)"xterm"; | |
1878 } | |
1879 # endif | |
1880 if (p != NULL) | |
3980 | 1881 { |
7 | 1882 set_option_value((char_u *)"ttym", 0L, p, 0); |
3980 | 1883 /* Reset the WAS_SET flag, 'ttymouse' can be set to "sgr" or |
1884 * "xterm2" in check_termcode(). */ | |
1885 reset_option_was_set((char_u *)"ttym"); | |
1886 } | |
7 | 1887 if (p == NULL |
1888 # ifdef FEAT_GUI | |
1889 || gui.in_use | |
1890 # endif | |
1891 ) | |
1892 check_mouse_termcode(); /* set mouse termcode anyway */ | |
1893 } | |
1894 # endif | |
1895 # else | |
1896 set_mouse_termcode(KS_MOUSE, (char_u *)"\233M"); | |
1897 # endif | |
1898 #endif /* FEAT_MOUSE */ | |
1899 | |
1900 #ifdef USE_TERM_CONSOLE | |
1901 /* DEFAULT_TERM indicates that it is the machine console. */ | |
1902 if (STRCMP(term, DEFAULT_TERM) != 0) | |
1903 term_console = FALSE; | |
1904 else | |
1905 { | |
1906 term_console = TRUE; | |
1907 # ifdef AMIGA | |
1908 win_resize_on(); /* enable window resizing reports */ | |
1909 # endif | |
1910 } | |
1911 #endif | |
1912 | |
1913 #if defined(UNIX) || defined(VMS) | |
1914 /* | |
1915 * 'ttyfast' is default on for xterm, iris-ansi and a few others. | |
1916 */ | |
1917 if (vim_is_fastterm(term)) | |
1918 p_tf = TRUE; | |
1919 #endif | |
1920 #ifdef USE_TERM_CONSOLE | |
1921 /* | |
1922 * 'ttyfast' is default on consoles | |
1923 */ | |
1924 if (term_console) | |
1925 p_tf = TRUE; | |
1926 #endif | |
1927 | |
1928 ttest(TRUE); /* make sure we have a valid set of terminal codes */ | |
1929 | |
1930 full_screen = TRUE; /* we can use termcap codes from now on */ | |
1931 set_term_defaults(); /* use current values as defaults */ | |
1932 #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
|
1933 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
|
1934 crv_status = STATUS_GET; /* Get terminal version later */ |
7 | 1935 #endif |
1936 | |
1937 /* | |
1938 * Initialize the terminal with the appropriate termcap codes. | |
1939 * Set the mouse and window title if possible. | |
1940 * Don't do this when starting, need to parse the .vimrc first, because it | |
1941 * may redefine t_TI etc. | |
1942 */ | |
1943 if (starting != NO_SCREEN) | |
1944 { | |
1945 starttermcap(); /* may change terminal mode */ | |
1946 #ifdef FEAT_MOUSE | |
1947 setmouse(); /* may start using the mouse */ | |
1948 #endif | |
1949 #ifdef FEAT_TITLE | |
1950 maketitle(); /* may display window title */ | |
1951 #endif | |
1952 } | |
1953 | |
1954 /* display initial screen after ttest() checking. jw. */ | |
1955 if (width <= 0 || height <= 0) | |
1956 { | |
1957 /* termcap failed to report size */ | |
1958 /* set defaults, in case ui_get_shellsize() also fails */ | |
1959 width = 80; | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
1960 #if defined(WIN3264) |
7 | 1961 height = 25; /* console is often 25 lines */ |
1962 #else | |
1963 height = 24; /* most terminals are 24 lines */ | |
1964 #endif | |
1965 } | |
1966 set_shellsize(width, height, FALSE); /* may change Rows */ | |
1967 if (starting != NO_SCREEN) | |
1968 { | |
1969 if (scroll_region) | |
1970 scroll_region_reset(); /* In case Rows changed */ | |
1971 check_map_keycodes(); /* check mappings for terminal codes used */ | |
1972 | |
1973 #ifdef FEAT_AUTOCMD | |
1974 { | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9125
diff
changeset
|
1975 bufref_T old_curbuf; |
7 | 1976 |
1977 /* | |
1978 * Execute the TermChanged autocommands for each buffer that is | |
1979 * loaded. | |
1980 */ | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9125
diff
changeset
|
1981 set_bufref(&old_curbuf, curbuf); |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9628
diff
changeset
|
1982 FOR_ALL_BUFFERS(curbuf) |
7 | 1983 { |
1984 if (curbuf->b_ml.ml_mfp != NULL) | |
1985 apply_autocmds(EVENT_TERMCHANGED, NULL, NULL, FALSE, | |
1986 curbuf); | |
1987 } | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9125
diff
changeset
|
1988 if (bufref_valid(&old_curbuf)) |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9125
diff
changeset
|
1989 curbuf = old_curbuf.br_buf; |
7 | 1990 } |
1991 #endif | |
1992 } | |
1993 | |
1994 #ifdef FEAT_TERMRESPONSE | |
1995 may_req_termresponse(); | |
1996 #endif | |
1997 | |
1998 return OK; | |
1999 } | |
2000 | |
2001 #if defined(FEAT_MOUSE) || defined(PROTO) | |
2002 | |
2003 # ifdef FEAT_MOUSE_TTY | |
2004 # define HMT_NORMAL 1 | |
2005 # define HMT_NETTERM 2 | |
2006 # define HMT_DEC 4 | |
2007 # define HMT_JSBTERM 8 | |
2008 # define HMT_PTERM 16 | |
3176 | 2009 # define HMT_URXVT 32 |
3746 | 2010 # 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
|
2011 # define HMT_SGR_REL 128 |
7 | 2012 static int has_mouse_termcode = 0; |
2013 # endif | |
2014 | |
1623 | 2015 # if (!defined(UNIX) || defined(FEAT_MOUSE_TTY)) || defined(PROTO) |
7 | 2016 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2017 set_mouse_termcode( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2018 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
|
2019 char_u *s) |
7 | 2020 { |
2021 char_u name[2]; | |
2022 | |
2023 name[0] = n; | |
2024 name[1] = KE_FILLER; | |
2025 add_termcode(name, s, FALSE); | |
2026 # ifdef FEAT_MOUSE_TTY | |
2027 # ifdef FEAT_MOUSE_JSB | |
2028 if (n == KS_JSBTERM_MOUSE) | |
2029 has_mouse_termcode |= HMT_JSBTERM; | |
2030 else | |
2031 # endif | |
2032 # ifdef FEAT_MOUSE_NET | |
2033 if (n == KS_NETTERM_MOUSE) | |
2034 has_mouse_termcode |= HMT_NETTERM; | |
2035 else | |
2036 # endif | |
2037 # ifdef FEAT_MOUSE_DEC | |
2038 if (n == KS_DEC_MOUSE) | |
2039 has_mouse_termcode |= HMT_DEC; | |
2040 else | |
2041 # endif | |
2042 # ifdef FEAT_MOUSE_PTERM | |
2043 if (n == KS_PTERM_MOUSE) | |
2044 has_mouse_termcode |= HMT_PTERM; | |
2045 else | |
2046 # endif | |
3176 | 2047 # ifdef FEAT_MOUSE_URXVT |
2048 if (n == KS_URXVT_MOUSE) | |
2049 has_mouse_termcode |= HMT_URXVT; | |
2050 else | |
2051 # endif | |
3746 | 2052 # ifdef FEAT_MOUSE_SGR |
2053 if (n == KS_SGR_MOUSE) | |
2054 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
|
2055 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
|
2056 has_mouse_termcode |= HMT_SGR_REL; |
3746 | 2057 else |
2058 # endif | |
7 | 2059 has_mouse_termcode |= HMT_NORMAL; |
2060 # endif | |
2061 } | |
2062 # endif | |
2063 | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7307
diff
changeset
|
2064 # if ((defined(UNIX) || defined(VMS)) \ |
1623 | 2065 && defined(FEAT_MOUSE_TTY)) || defined(PROTO) |
7 | 2066 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2067 del_mouse_termcode( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2068 int n) /* KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE */ |
7 | 2069 { |
2070 char_u name[2]; | |
2071 | |
2072 name[0] = n; | |
2073 name[1] = KE_FILLER; | |
2074 del_termcode(name); | |
2075 # ifdef FEAT_MOUSE_TTY | |
2076 # ifdef FEAT_MOUSE_JSB | |
2077 if (n == KS_JSBTERM_MOUSE) | |
2078 has_mouse_termcode &= ~HMT_JSBTERM; | |
2079 else | |
2080 # endif | |
2081 # ifdef FEAT_MOUSE_NET | |
2082 if (n == KS_NETTERM_MOUSE) | |
2083 has_mouse_termcode &= ~HMT_NETTERM; | |
2084 else | |
2085 # endif | |
2086 # ifdef FEAT_MOUSE_DEC | |
2087 if (n == KS_DEC_MOUSE) | |
2088 has_mouse_termcode &= ~HMT_DEC; | |
2089 else | |
2090 # endif | |
2091 # ifdef FEAT_MOUSE_PTERM | |
2092 if (n == KS_PTERM_MOUSE) | |
2093 has_mouse_termcode &= ~HMT_PTERM; | |
2094 else | |
2095 # endif | |
3176 | 2096 # ifdef FEAT_MOUSE_URXVT |
2097 if (n == KS_URXVT_MOUSE) | |
2098 has_mouse_termcode &= ~HMT_URXVT; | |
2099 else | |
2100 # endif | |
3746 | 2101 # ifdef FEAT_MOUSE_SGR |
2102 if (n == KS_SGR_MOUSE) | |
2103 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
|
2104 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
|
2105 has_mouse_termcode &= ~HMT_SGR_REL; |
3746 | 2106 else |
2107 # endif | |
7 | 2108 has_mouse_termcode &= ~HMT_NORMAL; |
2109 # endif | |
2110 } | |
2111 # endif | |
2112 #endif | |
2113 | |
2114 #ifdef HAVE_TGETENT | |
2115 /* | |
2116 * Call tgetent() | |
2117 * Return error message if it fails, NULL if it's OK. | |
2118 */ | |
2119 static char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2120 tgetent_error(char_u *tbuf, char_u *term) |
7 | 2121 { |
2122 int i; | |
2123 | |
2124 i = TGETENT(tbuf, term); | |
2125 if (i < 0 /* -1 is always an error */ | |
2126 # ifdef TGETENT_ZERO_ERR | |
2127 || i == 0 /* sometimes zero is also an error */ | |
2128 # endif | |
2129 ) | |
2130 { | |
2131 /* On FreeBSD tputs() gets a SEGV after a tgetent() which fails. Call | |
2132 * tgetent() with the always existing "dumb" entry to avoid a crash or | |
2133 * hang. */ | |
2134 (void)TGETENT(tbuf, "dumb"); | |
2135 | |
2136 if (i < 0) | |
2137 # ifdef TGETENT_ZERO_ERR | |
2138 return (char_u *)_("E557: Cannot open termcap file"); | |
2139 if (i == 0) | |
2140 # endif | |
2141 #ifdef TERMINFO | |
2142 return (char_u *)_("E558: Terminal entry not found in terminfo"); | |
2143 #else | |
2144 return (char_u *)_("E559: Terminal entry not found in termcap"); | |
2145 #endif | |
2146 } | |
2147 return NULL; | |
2148 } | |
2149 | |
2150 /* | |
2151 * Some versions of tgetstr() have been reported to return -1 instead of NULL. | |
2152 * Fix that here. | |
2153 */ | |
2154 static char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2155 vim_tgetstr(char *s, char_u **pp) |
7 | 2156 { |
2157 char *p; | |
2158 | |
2159 p = tgetstr(s, (char **)pp); | |
2160 if (p == (char *)-1) | |
2161 p = NULL; | |
2162 return (char_u *)p; | |
2163 } | |
2164 #endif /* HAVE_TGETENT */ | |
2165 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
2166 #if defined(HAVE_TGETENT) && (defined(UNIX) || defined(VMS) || defined(MACOS_X)) |
7 | 2167 /* |
2168 * Get Columns and Rows from the termcap. Used after a window signal if the | |
2169 * ioctl() fails. It doesn't make sense to call tgetent each time if the "co" | |
2170 * and "li" entries never change. But on some systems this works. | |
2171 * Errors while getting the entries are ignored. | |
2172 */ | |
2173 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2174 getlinecol( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2175 long *cp, /* pointer to columns */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2176 long *rp) /* pointer to rows */ |
7 | 2177 { |
2178 char_u tbuf[TBUFSZ]; | |
2179 | |
2180 if (T_NAME != NULL && *T_NAME != NUL && tgetent_error(tbuf, T_NAME) == NULL) | |
2181 { | |
2182 if (*cp == 0) | |
2183 *cp = tgetnum("co"); | |
2184 if (*rp == 0) | |
2185 *rp = tgetnum("li"); | |
2186 } | |
2187 } | |
2188 #endif /* defined(HAVE_TGETENT) && defined(UNIX) */ | |
2189 | |
2190 /* | |
2191 * Get a string entry from the termcap and add it to the list of termcodes. | |
2192 * Used for <t_xx> special keys. | |
2193 * Give an error message for failure when not sourcing. | |
2194 * If force given, replace an existing entry. | |
2195 * Return FAIL if the entry was not found, OK if the entry was added. | |
2196 */ | |
2197 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2198 add_termcap_entry(char_u *name, int force) |
7 | 2199 { |
2200 char_u *term; | |
2201 int key; | |
2202 struct builtin_term *termp; | |
2203 #ifdef HAVE_TGETENT | |
2204 char_u *string; | |
2205 int i; | |
2206 int builtin_first; | |
2207 char_u tbuf[TBUFSZ]; | |
2208 char_u tstrbuf[TBUFSZ]; | |
2209 char_u *tp = tstrbuf; | |
2210 char_u *error_msg = NULL; | |
2211 #endif | |
2212 | |
2213 /* | |
2214 * If the GUI is running or will start in a moment, we only support the keys | |
2215 * that the GUI can produce. | |
2216 */ | |
2217 #ifdef FEAT_GUI | |
2218 if (gui.in_use || gui.starting) | |
2219 return gui_mch_haskey(name); | |
2220 #endif | |
2221 | |
2222 if (!force && find_termcode(name) != NULL) /* it's already there */ | |
2223 return OK; | |
2224 | |
2225 term = T_NAME; | |
2226 if (term == NULL || *term == NUL) /* 'term' not defined yet */ | |
2227 return FAIL; | |
2228 | |
2229 if (term_is_builtin(term)) /* name starts with "builtin_" */ | |
2230 { | |
2231 term += 8; | |
2232 #ifdef HAVE_TGETENT | |
2233 builtin_first = TRUE; | |
2234 #endif | |
2235 } | |
2236 #ifdef HAVE_TGETENT | |
2237 else | |
2238 builtin_first = p_tbi; | |
2239 #endif | |
2240 | |
2241 #ifdef HAVE_TGETENT | |
2242 /* | |
2243 * We can get the entry from the builtin termcap and from the external one. | |
2244 * If 'ttybuiltin' is on or the terminal name starts with "builtin_", try | |
2245 * builtin termcap first. | |
2246 * If 'ttybuiltin' is off, try external termcap first. | |
2247 */ | |
2248 for (i = 0; i < 2; ++i) | |
2249 { | |
7210
08b50e436093
commit https://github.com/vim/vim/commit/98b30a473a58ae98c280e0383c8b1e08c0ebced5
Christian Brabandt <cb@256bit.org>
parents:
6901
diff
changeset
|
2250 if ((!builtin_first) == i) |
7 | 2251 #endif |
2252 /* | |
2253 * Search in builtin termcap | |
2254 */ | |
2255 { | |
2256 termp = find_builtin_term(term); | |
2257 if (termp->bt_string != NULL) /* found it */ | |
2258 { | |
2259 key = TERMCAP2KEY(name[0], name[1]); | |
2260 while (termp->bt_entry != (int)KS_NAME) | |
2261 { | |
2262 if ((int)termp->bt_entry == key) | |
2263 { | |
2264 add_termcode(name, (char_u *)termp->bt_string, | |
2265 term_is_8bit(term)); | |
2266 return OK; | |
2267 } | |
2268 ++termp; | |
2269 } | |
2270 } | |
2271 } | |
2272 #ifdef HAVE_TGETENT | |
2273 else | |
2274 /* | |
2275 * Search in external termcap | |
2276 */ | |
2277 { | |
2278 error_msg = tgetent_error(tbuf, term); | |
2279 if (error_msg == NULL) | |
2280 { | |
2281 string = TGETSTR((char *)name, &tp); | |
2282 if (string != NULL && *string != NUL) | |
2283 { | |
2284 add_termcode(name, string, FALSE); | |
2285 return OK; | |
2286 } | |
2287 } | |
2288 } | |
2289 } | |
2290 #endif | |
2291 | |
2292 if (sourcing_name == NULL) | |
2293 { | |
2294 #ifdef HAVE_TGETENT | |
2295 if (error_msg != NULL) | |
2296 EMSG(error_msg); | |
2297 else | |
2298 #endif | |
2299 EMSG2(_("E436: No \"%s\" entry in termcap"), name); | |
2300 } | |
2301 return FAIL; | |
2302 } | |
2303 | |
2304 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2305 term_is_builtin(char_u *name) |
7 | 2306 { |
2307 return (STRNCMP(name, "builtin_", (size_t)8) == 0); | |
2308 } | |
2309 | |
2310 /* | |
2311 * Return TRUE if terminal "name" uses CSI instead of <Esc>[. | |
2312 * Assume that the terminal is using 8-bit controls when the name contains | |
2313 * "8bit", like in "xterm-8bit". | |
2314 */ | |
2315 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2316 term_is_8bit(char_u *name) |
7 | 2317 { |
2318 return (detected_8bit || strstr((char *)name, "8bit") != NULL); | |
2319 } | |
2320 | |
2321 /* | |
2322 * 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
|
2323 * <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
|
2324 * <Esc>] -> OSC <M-C-]> |
7 | 2325 * <Esc>O -> <M-C-O> |
2326 */ | |
2327 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2328 term_7to8bit(char_u *p) |
7 | 2329 { |
2330 if (*p == ESC) | |
2331 { | |
2332 if (p[1] == '[') | |
2333 return CSI; | |
2334 if (p[1] == ']') | |
6901 | 2335 return OSC; |
7 | 2336 if (p[1] == 'O') |
2337 return 0x8f; | |
2338 } | |
2339 return 0; | |
2340 } | |
2341 | |
2342 #ifdef FEAT_GUI | |
2343 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2344 term_is_gui(char_u *name) |
7 | 2345 { |
2346 return (STRCMP(name, "builtin_gui") == 0 || STRCMP(name, "gui") == 0); | |
2347 } | |
2348 #endif | |
2349 | |
2350 #if !defined(HAVE_TGETENT) || defined(AMIGA) || defined(PROTO) | |
2351 | |
2352 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2353 tltoa(unsigned long i) |
7 | 2354 { |
2355 static char_u buf[16]; | |
2356 char_u *p; | |
2357 | |
2358 p = buf + 15; | |
2359 *p = '\0'; | |
2360 do | |
2361 { | |
2362 --p; | |
2363 *p = (char_u) (i % 10 + '0'); | |
2364 i /= 10; | |
2365 } | |
2366 while (i > 0 && p > buf); | |
2367 return p; | |
2368 } | |
2369 #endif | |
2370 | |
2371 #ifndef HAVE_TGETENT | |
2372 | |
2373 /* | |
2374 * minimal tgoto() implementation. | |
2375 * no padding and we only parse for %i %d and %+char | |
2376 */ | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
2377 static char *tgoto(char *, int, int); |
298 | 2378 |
2379 static char * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2380 tgoto(char *cm, int x, int y) |
7 | 2381 { |
2382 static char buf[30]; | |
2383 char *p, *s, *e; | |
2384 | |
2385 if (!cm) | |
2386 return "OOPS"; | |
2387 e = buf + 29; | |
2388 for (s = buf; s < e && *cm; cm++) | |
2389 { | |
2390 if (*cm != '%') | |
2391 { | |
2392 *s++ = *cm; | |
2393 continue; | |
2394 } | |
2395 switch (*++cm) | |
2396 { | |
2397 case 'd': | |
2398 p = (char *)tltoa((unsigned long)y); | |
2399 y = x; | |
2400 while (*p) | |
2401 *s++ = *p++; | |
2402 break; | |
2403 case 'i': | |
2404 x++; | |
2405 y++; | |
2406 break; | |
2407 case '+': | |
2408 *s++ = (char)(*++cm + y); | |
2409 y = x; | |
2410 break; | |
2411 case '%': | |
2412 *s++ = *cm; | |
2413 break; | |
2414 default: | |
2415 return "OOPS"; | |
2416 } | |
2417 } | |
2418 *s = '\0'; | |
2419 return buf; | |
2420 } | |
2421 | |
2422 #endif /* HAVE_TGETENT */ | |
2423 | |
2424 /* | |
2425 * Set the terminal name and initialize the terminal options. | |
2426 * If "name" is NULL or empty, get the terminal name from the environment. | |
2427 * If that fails, use the default terminal name. | |
2428 */ | |
2429 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2430 termcapinit(char_u *name) |
7 | 2431 { |
2432 char_u *term; | |
2433 | |
2434 if (name != NULL && *name == NUL) | |
2435 name = NULL; /* empty name is equal to no name */ | |
2436 term = name; | |
2437 | |
2438 #ifdef __BEOS__ | |
2439 /* | |
2440 * TERM environment variable is normally set to 'ansi' on the Bebox; | |
2441 * Since the BeBox doesn't quite support full ANSI yet, we use our | |
2442 * own custom 'ansi-beos' termcap instead, unless the -T option has | |
2443 * been given on the command line. | |
2444 */ | |
2445 if (term == NULL | |
2446 && strcmp((char *)mch_getenv((char_u *)"TERM"), "ansi") == 0) | |
2447 term = DEFAULT_TERM; | |
2448 #endif | |
2449 #ifndef MSWIN | |
2450 if (term == NULL) | |
2451 term = mch_getenv((char_u *)"TERM"); | |
2452 #endif | |
2453 if (term == NULL || *term == NUL) | |
2454 term = DEFAULT_TERM; | |
694 | 2455 set_string_option_direct((char_u *)"term", -1, term, OPT_FREE, 0); |
7 | 2456 |
2457 /* Set the default terminal name. */ | |
2458 set_string_default("term", term); | |
2459 set_string_default("ttytype", term); | |
2460 | |
2461 /* | |
2462 * Avoid using "term" here, because the next mch_getenv() may overwrite it. | |
2463 */ | |
2464 set_termname(T_NAME != NULL ? T_NAME : term); | |
2465 } | |
2466 | |
2467 /* | |
2468 * the number of calls to ui_write is reduced by using the buffer "out_buf" | |
2469 */ | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
2470 #define OUT_SIZE 2047 |
7 | 2471 /* Add one to allow mch_write() in os_win32.c to append a NUL */ |
2472 static char_u out_buf[OUT_SIZE + 1]; | |
2473 static int out_pos = 0; /* number of chars in out_buf */ | |
2474 | |
2475 /* | |
2476 * out_flush(): flush the output buffer | |
2477 */ | |
2478 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2479 out_flush(void) |
7 | 2480 { |
2481 int len; | |
2482 | |
2483 if (out_pos != 0) | |
2484 { | |
2485 /* set out_pos to 0 before ui_write, to avoid recursiveness */ | |
2486 len = out_pos; | |
2487 out_pos = 0; | |
2488 ui_write(out_buf, len); | |
2489 } | |
2490 } | |
2491 | |
2492 #if defined(FEAT_MBYTE) || defined(PROTO) | |
2493 /* | |
2494 * Sometimes a byte out of a multi-byte character is written with out_char(). | |
2495 * To avoid flushing half of the character, call this function first. | |
2496 */ | |
2497 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2498 out_flush_check(void) |
7 | 2499 { |
2500 if (enc_dbcs != 0 && out_pos >= OUT_SIZE - MB_MAXBYTES) | |
2501 out_flush(); | |
2502 } | |
2503 #endif | |
2504 | |
2505 #ifdef FEAT_GUI | |
2506 /* | |
2507 * out_trash(): Throw away the contents of the output buffer | |
2508 */ | |
2509 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2510 out_trash(void) |
7 | 2511 { |
2512 out_pos = 0; | |
2513 } | |
2514 #endif | |
2515 | |
2516 /* | |
2517 * out_char(c): put a byte into the output buffer. | |
2518 * Flush it if it becomes full. | |
2519 * This should not be used for outputting text on the screen (use functions | |
2520 * like msg_puts() and screen_putchar() for that). | |
2521 */ | |
2522 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2523 out_char(unsigned c) |
7 | 2524 { |
2525 #if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(MACOS_X_UNIX) | |
2526 if (c == '\n') /* turn LF into CR-LF (CRMOD doesn't seem to do this) */ | |
2527 out_char('\r'); | |
2528 #endif | |
2529 | |
2530 out_buf[out_pos++] = c; | |
2531 | |
2532 /* For testing we flush each time. */ | |
2533 if (out_pos >= OUT_SIZE || p_wd) | |
2534 out_flush(); | |
2535 } | |
2536 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
2537 static void out_char_nf(unsigned); |
7 | 2538 |
2539 /* | |
2540 * out_char_nf(c): like out_char(), but don't flush when p_wd is set | |
2541 */ | |
2542 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2543 out_char_nf(unsigned c) |
7 | 2544 { |
2545 #if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(MACOS_X_UNIX) | |
2546 if (c == '\n') /* turn LF into CR-LF (CRMOD doesn't seem to do this) */ | |
2547 out_char_nf('\r'); | |
2548 #endif | |
2549 | |
2550 out_buf[out_pos++] = c; | |
2551 | |
2552 if (out_pos >= OUT_SIZE) | |
2553 out_flush(); | |
2554 } | |
2555 | |
2237
770485470e59
Add a few #ifdefs to exclude functions that are not used. (Domnique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
1941
diff
changeset
|
2556 #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
|
2557 || defined(FEAT_TERMRESPONSE) || defined(PROTO) |
7 | 2558 /* |
2559 * A never-padding out_str. | |
2560 * use this whenever you don't want to run the string through tputs. | |
2561 * tputs above is harmless, but tputs from the termcap library | |
2562 * is likely to strip off leading digits, that it mistakes for padding | |
2563 * information, and "%i", "%d", etc. | |
2564 * This should only be used for writing terminal codes, not for outputting | |
2565 * normal text (use functions like msg_puts() and screen_putchar() for that). | |
2566 */ | |
2567 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2568 out_str_nf(char_u *s) |
7 | 2569 { |
2570 if (out_pos > OUT_SIZE - 20) /* avoid terminal strings being split up */ | |
2571 out_flush(); | |
2572 while (*s) | |
2573 out_char_nf(*s++); | |
2574 | |
2575 /* For testing we write one string at a time. */ | |
2576 if (p_wd) | |
2577 out_flush(); | |
2578 } | |
2237
770485470e59
Add a few #ifdefs to exclude functions that are not used. (Domnique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
1941
diff
changeset
|
2579 #endif |
7 | 2580 |
2581 /* | |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2582 * 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
|
2583 * 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
|
2584 * it at the wrong time. |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2585 * Note: Only for terminal strings. |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2586 */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2587 void |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2588 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
|
2589 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2590 if (s != NULL && *s) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2591 { |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2592 #ifdef HAVE_TGETENT |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2593 char_u *p; |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2594 #endif |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2595 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2596 #ifdef FEAT_GUI |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2597 /* 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
|
2598 if (gui.in_use) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2599 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2600 out_str_nf(s); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2601 return; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2602 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2603 #endif |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2604 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
|
2605 out_flush(); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2606 #ifdef HAVE_TGETENT |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2607 for (p = s; *s; ++s) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2608 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2609 /* flush just before delay command */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2610 if (*s == '$' && *(s + 1) == '<') |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2611 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2612 char_u save_c = *s; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2613 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
|
2614 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2615 *s = NUL; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2616 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
|
2617 *s = save_c; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2618 out_flush(); |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2619 # ifdef ELAPSED_FUNC |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2620 /* 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
|
2621 * vim_beep(). */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2622 p = vim_strchr(s, '>'); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2623 if (p == NULL || duration <= 0) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2624 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2625 /* 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
|
2626 p = s; |
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 else |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2629 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2630 ++p; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2631 do_sleep(duration); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2632 } |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2633 # else |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2634 /* 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
|
2635 p = s; |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2636 # endif |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2637 break; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2638 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2639 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2640 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
|
2641 #else |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2642 while (*s) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2643 out_char_nf(*s++); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2644 #endif |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2645 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2646 /* 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
|
2647 if (p_wd) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2648 out_flush(); |
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 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2651 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2652 /* |
7 | 2653 * out_str(s): Put a character string a byte at a time into the output buffer. |
2654 * If HAVE_TGETENT is defined use the termcap parser. (jw) | |
2655 * This should only be used for writing terminal codes, not for outputting | |
2656 * normal text (use functions like msg_puts() and screen_putchar() for that). | |
2657 */ | |
2658 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2659 out_str(char_u *s) |
7 | 2660 { |
2661 if (s != NULL && *s) | |
2662 { | |
2663 #ifdef FEAT_GUI | |
2664 /* Don't use tputs() when GUI is used, ncurses crashes. */ | |
2665 if (gui.in_use) | |
2666 { | |
2667 out_str_nf(s); | |
2668 return; | |
2669 } | |
2670 #endif | |
2671 /* avoid terminal strings being split up */ | |
2672 if (out_pos > OUT_SIZE - 20) | |
2673 out_flush(); | |
2674 #ifdef HAVE_TGETENT | |
2675 tputs((char *)s, 1, TPUTSFUNCAST out_char_nf); | |
2676 #else | |
2677 while (*s) | |
2678 out_char_nf(*s++); | |
2679 #endif | |
2680 | |
2681 /* For testing we write one string at a time. */ | |
2682 if (p_wd) | |
2683 out_flush(); | |
2684 } | |
2685 } | |
2686 | |
2687 /* | |
2688 * cursor positioning using termcap parser. (jw) | |
2689 */ | |
2690 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2691 term_windgoto(int row, int col) |
7 | 2692 { |
2693 OUT_STR(tgoto((char *)T_CM, col, row)); | |
2694 } | |
2695 | |
2696 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2697 term_cursor_right(int i) |
7 | 2698 { |
2699 OUT_STR(tgoto((char *)T_CRI, 0, i)); | |
2700 } | |
2701 | |
2702 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2703 term_append_lines(int line_count) |
7 | 2704 { |
2705 OUT_STR(tgoto((char *)T_CAL, 0, line_count)); | |
2706 } | |
2707 | |
2708 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2709 term_delete_lines(int line_count) |
7 | 2710 { |
2711 OUT_STR(tgoto((char *)T_CDL, 0, line_count)); | |
2712 } | |
2713 | |
2714 #if defined(HAVE_TGETENT) || defined(PROTO) | |
2715 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2716 term_set_winpos(int x, int y) |
7 | 2717 { |
2718 /* Can't handle a negative value here */ | |
2719 if (x < 0) | |
2720 x = 0; | |
2721 if (y < 0) | |
2722 y = 0; | |
2723 OUT_STR(tgoto((char *)T_CWP, y, x)); | |
2724 } | |
2725 | |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2726 # 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
|
2727 /* |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2728 * 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
|
2729 */ |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2730 static int |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2731 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
|
2732 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2733 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
|
2734 && termcap_active |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2735 # ifdef UNIX |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2736 && (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
|
2737 # endif |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2738 && p_ek; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2739 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2740 |
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 winpos_x; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2742 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
|
2743 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
|
2744 |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2745 /* |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2746 * 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
|
2747 * 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
|
2748 */ |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2749 int |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2750 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
|
2751 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2752 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
|
2753 |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2754 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
|
2755 return FAIL; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2756 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
|
2757 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
|
2758 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
|
2759 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
|
2760 out_flush(); |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2761 |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2762 /* 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
|
2763 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
|
2764 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2765 (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
|
2766 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
|
2767 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2768 *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
|
2769 *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
|
2770 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
|
2771 return OK; |
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 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
|
2774 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2775 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
|
2776 return FALSE; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2777 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2778 # endif |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2779 |
7 | 2780 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
|
2781 term_set_winsize(int height, int width) |
7 | 2782 { |
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
|
2783 OUT_STR(tgoto((char *)T_CWS, width, height)); |
7 | 2784 } |
2785 #endif | |
2786 | |
2787 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2788 term_fg_color(int n) |
7 | 2789 { |
2790 /* Use "AF" termcap entry if present, "Sf" entry otherwise */ | |
2791 if (*T_CAF) | |
2792 term_color(T_CAF, n); | |
2793 else if (*T_CSF) | |
2794 term_color(T_CSF, n); | |
2795 } | |
2796 | |
2797 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2798 term_bg_color(int n) |
7 | 2799 { |
2800 /* Use "AB" termcap entry if present, "Sb" entry otherwise */ | |
2801 if (*T_CAB) | |
2802 term_color(T_CAB, n); | |
2803 else if (*T_CSB) | |
2804 term_color(T_CSB, n); | |
2805 } | |
2806 | |
2807 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2808 term_color(char_u *s, int n) |
7 | 2809 { |
2810 char buf[20]; | |
2811 int i = 2; /* index in s[] just after <Esc>[ or CSI */ | |
2812 | |
2813 /* Special handling of 16 colors, because termcap can't handle it */ | |
2814 /* Also accept "\e[3%dm" for TERMINFO, it is sometimes used */ | |
2815 /* Also accept CSI instead of <Esc>[ */ | |
2816 if (n >= 8 && t_colors >= 16 | |
2817 && ((s[0] == ESC && s[1] == '[') || (s[0] == CSI && (i = 1) == 1)) | |
2818 && s[i] != NUL | |
2819 && (STRCMP(s + i + 1, "%p1%dm") == 0 | |
2820 || STRCMP(s + i + 1, "%dm") == 0) | |
2821 && (s[i] == '3' || s[i] == '4')) | |
2822 { | |
2823 #ifdef TERMINFO | |
9068
0a3bc9fdea20
commit https://github.com/vim/vim/commit/827b165b2aebad2cfe98cc6d5804c6c0fe8afd89
Christian Brabandt <cb@256bit.org>
parents:
9027
diff
changeset
|
2824 char *format = "%s%s%%p1%%dm"; |
7 | 2825 #else |
9068
0a3bc9fdea20
commit https://github.com/vim/vim/commit/827b165b2aebad2cfe98cc6d5804c6c0fe8afd89
Christian Brabandt <cb@256bit.org>
parents:
9027
diff
changeset
|
2826 char *format = "%s%s%%dm"; |
7 | 2827 #endif |
9068
0a3bc9fdea20
commit https://github.com/vim/vim/commit/827b165b2aebad2cfe98cc6d5804c6c0fe8afd89
Christian Brabandt <cb@256bit.org>
parents:
9027
diff
changeset
|
2828 sprintf(buf, format, |
7 | 2829 i == 2 ? IF_EB("\033[", ESC_STR "[") : "\233", |
2830 s[i] == '3' ? (n >= 16 ? "38;5;" : "9") | |
2831 : (n >= 16 ? "48;5;" : "10")); | |
2832 OUT_STR(tgoto(buf, 0, n >= 16 ? n : n - 8)); | |
2833 } | |
2834 else | |
2835 OUT_STR(tgoto((char *)s, 0, n)); | |
2836 } | |
2837 | |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
2838 #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
|
2839 |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2840 #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
|
2841 #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
|
2842 #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
|
2843 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2844 static void |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2845 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
|
2846 { |
8975
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
2847 #define MAX_COLOR_STR_LEN 100 |
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
2848 char buf[MAX_COLOR_STR_LEN]; |
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
2849 |
8981
3b51b0aeb9a3
commit https://github.com/vim/vim/commit/a1c487eef71d1673e57511453009de9cb4c9af51
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
2850 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
|
2851 (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
|
2852 OUT_STR(buf); |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2853 } |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2854 |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2855 void |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2856 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
|
2857 { |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2858 term_rgb_color(T_8F, rgb); |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2859 } |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2860 |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2861 void |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2862 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
|
2863 { |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2864 term_rgb_color(T_8B, rgb); |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2865 } |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2866 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2867 |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7307
diff
changeset
|
2868 #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
|
2869 || defined(MACOS_X))) || defined(PROTO) |
7 | 2870 /* |
2871 * Generic function to set window title, using t_ts and t_fs. | |
2872 */ | |
2873 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2874 term_settitle(char_u *title) |
7 | 2875 { |
2876 /* t_ts takes one argument: column in status line */ | |
2877 OUT_STR(tgoto((char *)T_TS, 0, 0)); /* set title start */ | |
2878 out_str_nf(title); | |
2879 out_str(T_FS); /* set title end */ | |
2880 out_flush(); | |
2881 } | |
2882 #endif | |
2883 | |
2884 /* | |
2885 * Make sure we have a valid set or terminal options. | |
2886 * Replace all entries that are NULL by empty_option | |
2887 */ | |
2888 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2889 ttest(int pairs) |
7 | 2890 { |
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
|
2891 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
|
2892 |
7 | 2893 check_options(); /* make sure no options are NULL */ |
2894 | |
2895 /* | |
2896 * MUST have "cm": cursor motion. | |
2897 */ | |
2898 if (*T_CM == NUL) | |
2899 EMSG(_("E437: terminal capability \"cm\" required")); | |
2900 | |
2901 /* | |
2902 * if "cs" defined, use a scroll region, it's faster. | |
2903 */ | |
2904 if (*T_CS != NUL) | |
2905 scroll_region = TRUE; | |
2906 else | |
2907 scroll_region = FALSE; | |
2908 | |
2909 if (pairs) | |
2910 { | |
2911 /* | |
2912 * optional pairs | |
2913 */ | |
2914 /* TP goes to normal mode for TI (invert) and TB (bold) */ | |
2915 if (*T_ME == NUL) | |
2916 T_ME = T_MR = T_MD = T_MB = empty_option; | |
2917 if (*T_SO == NUL || *T_SE == NUL) | |
2918 T_SO = T_SE = empty_option; | |
2919 if (*T_US == NUL || *T_UE == NUL) | |
2920 T_US = T_UE = empty_option; | |
2921 if (*T_CZH == NUL || *T_CZR == NUL) | |
2922 T_CZH = T_CZR = empty_option; | |
2923 | |
2924 /* T_VE is needed even though T_VI is not defined */ | |
2925 if (*T_VE == NUL) | |
2926 T_VI = empty_option; | |
2927 | |
2928 /* if 'mr' or 'me' is not defined use 'so' and 'se' */ | |
2929 if (*T_ME == NUL) | |
2930 { | |
2931 T_ME = T_SE; | |
2932 T_MR = T_SO; | |
2933 T_MD = T_SO; | |
2934 } | |
2935 | |
2936 /* if 'so' or 'se' is not defined use 'mr' and 'me' */ | |
2937 if (*T_SO == NUL) | |
2938 { | |
2939 T_SE = T_ME; | |
2940 if (*T_MR == NUL) | |
2941 T_SO = T_MD; | |
2942 else | |
2943 T_SO = T_MR; | |
2944 } | |
2945 | |
2946 /* if 'ZH' or 'ZR' is not defined use 'mr' and 'me' */ | |
2947 if (*T_CZH == NUL) | |
2948 { | |
2949 T_CZR = T_ME; | |
2950 if (*T_MR == NUL) | |
2951 T_CZH = T_MD; | |
2952 else | |
2953 T_CZH = T_MR; | |
2954 } | |
2955 | |
2956 /* "Sb" and "Sf" come in pairs */ | |
2957 if (*T_CSB == NUL || *T_CSF == NUL) | |
2958 { | |
2959 T_CSB = empty_option; | |
2960 T_CSF = empty_option; | |
2961 } | |
2962 | |
2963 /* "AB" and "AF" come in pairs */ | |
2964 if (*T_CAB == NUL || *T_CAF == NUL) | |
2965 { | |
2966 T_CAB = empty_option; | |
2967 T_CAF = empty_option; | |
2968 } | |
2969 | |
2970 /* if 'Sb' and 'AB' are not defined, reset "Co" */ | |
2971 if (*T_CSB == NUL && *T_CAB == NUL) | |
1941 | 2972 free_one_termoption(T_CCO); |
7 | 2973 |
2974 /* Set 'weirdinvert' according to value of 't_xs' */ | |
2975 p_wiv = (*T_XS != NUL); | |
2976 } | |
2977 need_gather = TRUE; | |
2978 | |
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 /* Set t_colors to the value of $COLORS or t_Co. */ |
7 | 2980 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
|
2981 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
|
2982 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
|
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 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
|
2985 |
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 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
|
2987 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
|
2988 } |
7 | 2989 } |
2990 | |
2991 #if (defined(FEAT_GUI) && (defined(FEAT_MENU) || !defined(USE_ON_FLY_SCROLL))) \ | |
2992 || defined(PROTO) | |
2993 /* | |
2994 * Represent the given long_u as individual bytes, with the most significant | |
2995 * byte first, and store them in dst. | |
2996 */ | |
2997 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2998 add_long_to_buf(long_u val, char_u *dst) |
7 | 2999 { |
3000 int i; | |
3001 int shift; | |
3002 | |
1883 | 3003 for (i = 1; i <= (int)sizeof(long_u); i++) |
7 | 3004 { |
3005 shift = 8 * (sizeof(long_u) - i); | |
3006 dst[i - 1] = (char_u) ((val >> shift) & 0xff); | |
3007 } | |
3008 } | |
3009 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
3010 static int get_long_from_buf(char_u *buf, long_u *val); |
7 | 3011 |
3012 /* | |
3013 * Interpret the next string of bytes in buf as a long integer, with the most | |
3014 * significant byte first. Note that it is assumed that buf has been through | |
3015 * inchar(), so that NUL and K_SPECIAL will be represented as three bytes each. | |
3016 * Puts result in val, and returns the number of bytes read from buf | |
3017 * (between sizeof(long_u) and 2 * sizeof(long_u)), or -1 if not enough bytes | |
3018 * were present. | |
3019 */ | |
3020 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3021 get_long_from_buf(char_u *buf, long_u *val) |
7 | 3022 { |
3023 int len; | |
3024 char_u bytes[sizeof(long_u)]; | |
3025 int i; | |
3026 int shift; | |
3027 | |
3028 *val = 0; | |
3029 len = get_bytes_from_buf(buf, bytes, (int)sizeof(long_u)); | |
3030 if (len != -1) | |
3031 { | |
1883 | 3032 for (i = 0; i < (int)sizeof(long_u); i++) |
7 | 3033 { |
3034 shift = 8 * (sizeof(long_u) - 1 - i); | |
3035 *val += (long_u)bytes[i] << shift; | |
3036 } | |
3037 } | |
3038 return len; | |
3039 } | |
3040 #endif | |
3041 | |
3042 #if defined(FEAT_GUI) \ | |
1623 | 3043 || (defined(FEAT_MOUSE) && (!defined(UNIX) || defined(FEAT_MOUSE_XTERM) \ |
3044 || defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE))) | |
7 | 3045 /* |
3046 * Read the next num_bytes bytes from buf, and store them in bytes. Assume | |
3047 * that buf has been through inchar(). Returns the actual number of bytes used | |
3048 * from buf (between num_bytes and num_bytes*2), or -1 if not enough bytes were | |
3049 * available. | |
3050 */ | |
3051 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3052 get_bytes_from_buf(char_u *buf, char_u *bytes, int num_bytes) |
7 | 3053 { |
3054 int len = 0; | |
3055 int i; | |
3056 char_u c; | |
3057 | |
3058 for (i = 0; i < num_bytes; i++) | |
3059 { | |
3060 if ((c = buf[len++]) == NUL) | |
3061 return -1; | |
3062 if (c == K_SPECIAL) | |
3063 { | |
3064 if (buf[len] == NUL || buf[len + 1] == NUL) /* cannot happen? */ | |
3065 return -1; | |
3066 if (buf[len++] == (int)KS_ZERO) | |
3067 c = NUL; | |
5076
19ed30f7cef7
updated for version 7.3.1281
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
3068 /* 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
|
3069 * 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
|
3070 if (buf[len++] == (int)KE_CSI) |
19ed30f7cef7
updated for version 7.3.1281
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
3071 c = CSI; |
7 | 3072 } |
1160 | 3073 else if (c == CSI && buf[len] == KS_EXTRA |
3074 && buf[len + 1] == (int)KE_CSI) | |
667 | 3075 /* CSI is stored as CSI KS_SPECIAL KE_CSI to avoid confusion with |
3076 * the start of a special key, see add_to_input_buf_csi(). */ | |
3077 len += 2; | |
7 | 3078 bytes[i] = c; |
3079 } | |
3080 return len; | |
3081 } | |
3082 #endif | |
3083 | |
3084 /* | |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3085 * 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
|
3086 * too big. |
7 | 3087 */ |
3088 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3089 check_shellsize(void) |
7 | 3090 { |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3091 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
|
3092 Rows = min_rows(); |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3093 limit_screen_size(); |
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 |
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 * 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
|
3098 */ |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3099 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3100 limit_screen_size(void) |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3101 { |
7 | 3102 if (Columns < MIN_COLUMNS) |
3103 Columns = MIN_COLUMNS; | |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3104 else if (Columns > 10000) |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3105 Columns = 10000; |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3106 if (Rows > 1000) |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3107 Rows = 1000; |
7 | 3108 } |
3109 | |
41 | 3110 /* |
3111 * Invoked just before the screen structures are going to be (re)allocated. | |
3112 */ | |
7 | 3113 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3114 win_new_shellsize(void) |
7 | 3115 { |
3116 static int old_Rows = 0; | |
3117 static int old_Columns = 0; | |
3118 | |
3119 if (old_Rows != Rows || old_Columns != Columns) | |
3120 ui_new_shellsize(); | |
3121 if (old_Rows != Rows) | |
3122 { | |
164 | 3123 /* if 'window' uses the whole screen, keep it using that */ |
179 | 3124 if (p_window == old_Rows - 1 || old_Rows == 0) |
164 | 3125 p_window = Rows - 1; |
7 | 3126 old_Rows = Rows; |
3127 shell_new_rows(); /* update window sizes */ | |
3128 } | |
3129 if (old_Columns != Columns) | |
3130 { | |
3131 old_Columns = Columns; | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
3132 #ifdef FEAT_WINDOWS |
7 | 3133 shell_new_columns(); /* update window sizes */ |
3134 #endif | |
3135 } | |
3136 } | |
3137 | |
3138 /* | |
3139 * Call this function when the Vim shell has been resized in any way. | |
3140 * Will obtain the current size and redraw (also when size didn't change). | |
3141 */ | |
3142 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3143 shell_resized(void) |
7 | 3144 { |
3145 set_shellsize(0, 0, FALSE); | |
3146 } | |
3147 | |
3148 /* | |
3149 * Check if the shell size changed. Handle a resize. | |
3150 * When the size didn't change, nothing happens. | |
3151 */ | |
3152 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3153 shell_resized_check(void) |
7 | 3154 { |
3155 int old_Rows = Rows; | |
3156 int old_Columns = Columns; | |
3157 | |
3770 | 3158 if (!exiting |
3159 #ifdef FEAT_GUI | |
3160 /* Do not get the size when executing a shell command during | |
3161 * startup. */ | |
3162 && !gui.starting | |
3163 #endif | |
3164 ) | |
2673 | 3165 { |
3166 (void)ui_get_shellsize(); | |
3167 check_shellsize(); | |
3168 if (old_Rows != Rows || old_Columns != Columns) | |
3169 shell_resized(); | |
3170 } | |
7 | 3171 } |
3172 | |
3173 /* | |
3174 * Set size of the Vim shell. | |
3175 * If 'mustset' is TRUE, we must set Rows and Columns, do not get the real | |
3176 * window size (this is used for the :win command). | |
3177 * If 'mustset' is FALSE, we may try to get the real window size and if | |
3178 * it fails use 'width' and 'height'. | |
3179 */ | |
3180 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3181 set_shellsize(int width, int height, int mustset) |
7 | 3182 { |
3183 static int busy = FALSE; | |
3184 | |
3185 /* | |
3186 * Avoid recursiveness, can happen when setting the window size causes | |
3187 * another window-changed signal. | |
3188 */ | |
3189 if (busy) | |
3190 return; | |
3191 | |
3192 if (width < 0 || height < 0) /* just checking... */ | |
3193 return; | |
3194 | |
3068 | 3195 if (State == HITRETURN || State == SETWSIZE) |
7 | 3196 { |
3068 | 3197 /* postpone the resizing */ |
7 | 3198 State = SETWSIZE; |
3199 return; | |
3200 } | |
3201 | |
3068 | 3202 /* curwin->w_buffer can be NULL when we are closing a window and the |
3203 * buffer has already been closed and removing a scrollbar causes a resize | |
3204 * event. Don't resize then, it will happen after entering another buffer. | |
3205 */ | |
3206 if (curwin->w_buffer == NULL) | |
3207 return; | |
3208 | |
7 | 3209 ++busy; |
3210 | |
3211 #ifdef AMIGA | |
3212 out_flush(); /* must do this before mch_get_shellsize() for | |
3213 some obscure reason */ | |
3214 #endif | |
3215 | |
3216 if (mustset || (ui_get_shellsize() == FAIL && height != 0)) | |
3217 { | |
3218 Rows = height; | |
3219 Columns = width; | |
3220 check_shellsize(); | |
3221 ui_set_shellsize(mustset); | |
3222 } | |
3223 else | |
3224 check_shellsize(); | |
3225 | |
3226 /* The window layout used to be adjusted here, but it now happens in | |
3227 * screenalloc() (also invoked from screenclear()). That is because the | |
3228 * "busy" check above may skip this, but not screenalloc(). */ | |
3229 | |
3230 if (State != ASKMORE && State != EXTERNCMD && State != CONFIRM) | |
3231 screenclear(); | |
3232 else | |
3233 screen_start(); /* don't know where cursor is now */ | |
3234 | |
3235 if (starting != NO_SCREEN) | |
3236 { | |
3237 #ifdef FEAT_TITLE | |
3238 maketitle(); | |
3239 #endif | |
3240 changed_line_abv_curs(); | |
3241 invalidate_botline(); | |
3242 | |
3243 /* | |
3244 * We only redraw when it's needed: | |
3245 * - While at the more prompt or executing an external command, don't | |
3246 * redraw, but position the cursor. | |
3247 * - While editing the command line, only redraw that. | |
3248 * - in Ex mode, don't redraw anything. | |
3249 * - Otherwise, redraw right now, and position the cursor. | |
3250 * Always need to call update_screen() or screenalloc(), to make | |
3251 * sure Rows/Columns and the size of ScreenLines[] is correct! | |
3252 */ | |
3253 if (State == ASKMORE || State == EXTERNCMD || State == CONFIRM | |
3254 || exmode_active) | |
3255 { | |
3256 screenalloc(FALSE); | |
3257 repeat_message(); | |
3258 } | |
3259 else | |
3260 { | |
1024 | 3261 #ifdef FEAT_SCROLLBIND |
3262 if (curwin->w_p_scb) | |
3263 do_check_scrollbind(TRUE); | |
3264 #endif | |
3265 if (State & CMDLINE) | |
648 | 3266 { |
1024 | 3267 update_screen(NOT_VALID); |
3268 redrawcmdline(); | |
648 | 3269 } |
3270 else | |
1024 | 3271 { |
3272 update_topline(); | |
3273 #if defined(FEAT_INS_EXPAND) | |
3274 if (pum_visible()) | |
3275 { | |
3276 redraw_later(NOT_VALID); | |
3277 ins_compl_show_pum(); /* This includes the redraw. */ | |
3278 } | |
3279 else | |
648 | 3280 #endif |
1024 | 3281 update_screen(NOT_VALID); |
3282 if (redrawing()) | |
3283 setcursor(); | |
3284 } | |
7 | 3285 } |
3286 cursor_on(); /* redrawing may have switched it off */ | |
3287 } | |
3288 out_flush(); | |
3289 --busy; | |
3290 } | |
3291 | |
3292 /* | |
3293 * Set the terminal to TMODE_RAW (for Normal mode) or TMODE_COOK (for external | |
3294 * commands and Ex mode). | |
3295 */ | |
3296 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3297 settmode(int tmode) |
7 | 3298 { |
3299 #ifdef FEAT_GUI | |
3300 /* don't set the term where gvim was started to any mode */ | |
3301 if (gui.in_use) | |
3302 return; | |
3303 #endif | |
3304 | |
3305 if (full_screen) | |
3306 { | |
3307 /* | |
3308 * When returning after calling a shell we want to really set the | |
3309 * terminal to raw mode, even though we think it already is, because | |
3310 * the shell program may have reset the terminal mode. | |
3311 * When we think the terminal is normal, don't try to set it to | |
3312 * normal again, because that causes problems (logout!) on some | |
3313 * machines. | |
3314 */ | |
3315 if (tmode != TMODE_COOK || cur_tmode != TMODE_COOK) | |
3316 { | |
3317 #ifdef FEAT_TERMRESPONSE | |
1691 | 3318 # ifdef FEAT_GUI |
3319 if (!gui.in_use && !gui.starting) | |
3320 # endif | |
3321 { | |
3322 /* May need to check for T_CRV response and termcodes, it | |
3323 * doesn't work in Cooked mode, an external program may get | |
3324 * 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
|
3325 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
|
3326 || 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
|
3327 || 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
|
3328 || 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
|
3329 || rcs_status == STATUS_SENT)) |
1691 | 3330 (void)vpeekc_nomap(); |
3331 check_for_codes_from_term(); | |
3332 } | |
7 | 3333 #endif |
3334 #ifdef FEAT_MOUSE_TTY | |
3335 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
|
3336 mch_setmouse(FALSE); /* switch mouse off */ |
7 | 3337 #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
|
3338 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
|
3339 out_str(T_BD); /* disable bracketed paste mode */ |
7 | 3340 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
|
3341 mch_settmode(tmode); /* machine specific function */ |
7 | 3342 cur_tmode = tmode; |
3343 #ifdef FEAT_MOUSE | |
3344 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
|
3345 setmouse(); /* may switch mouse on */ |
7 | 3346 #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
|
3347 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
|
3348 out_str(T_BE); /* enable bracketed paste mode */ |
7 | 3349 out_flush(); |
3350 } | |
3351 #ifdef FEAT_TERMRESPONSE | |
3352 may_req_termresponse(); | |
3353 #endif | |
3354 } | |
3355 } | |
3356 | |
3357 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3358 starttermcap(void) |
7 | 3359 { |
3360 if (full_screen && !termcap_active) | |
3361 { | |
3362 out_str(T_TI); /* start termcap mode */ | |
3363 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
|
3364 out_str(T_BE); /* enable bracketed paste mode */ |
7 | 3365 out_flush(); |
3366 termcap_active = TRUE; | |
3367 screen_start(); /* don't know where cursor is now */ | |
3368 #ifdef FEAT_TERMRESPONSE | |
1691 | 3369 # ifdef FEAT_GUI |
3370 if (!gui.in_use && !gui.starting) | |
3371 # endif | |
3372 { | |
3373 may_req_termresponse(); | |
3374 /* Immediately check for a response. If t_Co changes, we don't | |
3375 * 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
|
3376 if (crv_status == STATUS_SENT) |
1691 | 3377 check_for_codes_from_term(); |
3378 } | |
7 | 3379 #endif |
3380 } | |
3381 } | |
3382 | |
3383 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3384 stoptermcap(void) |
7 | 3385 { |
3386 screen_stop_highlight(); | |
3387 reset_cterm_colors(); | |
3388 if (termcap_active) | |
3389 { | |
3390 #ifdef FEAT_TERMRESPONSE | |
1691 | 3391 # ifdef FEAT_GUI |
3392 if (!gui.in_use && !gui.starting) | |
3393 # endif | |
3394 { | |
6874 | 3395 /* 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
|
3396 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
|
3397 || 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
|
3398 || 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
|
3399 || 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
|
3400 || rcs_status == STATUS_SENT) |
4391 | 3401 { |
3402 # ifdef UNIX | |
3403 /* Give the terminal a chance to respond. */ | |
3404 mch_delay(100L, FALSE); | |
3405 # endif | |
3406 # ifdef TCIFLUSH | |
3407 /* Discard data received but not read. */ | |
3408 if (exiting) | |
3409 tcflush(fileno(stdin), TCIFLUSH); | |
3410 # endif | |
3411 } | |
1691 | 3412 /* Check for termcodes first, otherwise an external program may |
3413 * get them. */ | |
3414 check_for_codes_from_term(); | |
3415 } | |
7 | 3416 #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
|
3417 out_str(T_BD); /* disable bracketed paste mode */ |
7 | 3418 out_str(T_KE); /* stop "keypad transmit" mode */ |
3419 out_flush(); | |
3420 termcap_active = FALSE; | |
3421 cursor_on(); /* just in case it is still off */ | |
3422 out_str(T_TE); /* stop termcap mode */ | |
3423 screen_start(); /* don't know where cursor is now */ | |
3424 out_flush(); | |
3425 } | |
3426 } | |
3427 | |
5932 | 3428 #if defined(FEAT_TERMRESPONSE) || defined(PROTO) |
7 | 3429 /* |
3430 * Request version string (for xterm) when needed. | |
3431 * Only do this after switching to raw mode, otherwise the result will be | |
3432 * echoed. | |
626 | 3433 * Only do this after startup has finished, to avoid that the response comes |
1221 | 3434 * while executing "-c !cmd" or even after "-c quit". |
7 | 3435 * Only do this after termcap mode has been started, otherwise the codes for |
3436 * the cursor keys may be wrong. | |
620 | 3437 * Only do this when 'esckeys' is on, otherwise the response causes trouble in |
3438 * Insert mode. | |
164 | 3439 * On Unix only do it when both output and input are a tty (avoid writing |
3440 * request to terminal while reading from a file). | |
7 | 3441 * The result is caught in check_termcode(). |
3442 */ | |
626 | 3443 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3444 may_req_termresponse(void) |
7 | 3445 { |
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
|
3446 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
|
3447 && can_get_termresponse() |
626 | 3448 && starting == 0 |
7 | 3449 && *T_CRV != NUL) |
3450 { | |
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 LOG_TR("Sending CRV request"); |
7 | 3452 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
|
3453 crv_status = STATUS_SENT; |
7 | 3454 /* check for the characters now, otherwise they might be eaten by |
3455 * get_keystroke() */ | |
3456 out_flush(); | |
3457 (void)vpeekc_nomap(); | |
3458 } | |
3459 } | |
4215 | 3460 |
3461 # if defined(FEAT_MBYTE) || defined(PROTO) | |
3462 /* | |
3463 * 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
|
3464 * First, we move the cursor to (1, 0) and print a test ambiguous character |
4215 | 3465 * \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
|
3466 * 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
|
3467 * or if it is treated as double width, that will be (1, 2). |
4215 | 3468 * This function has the side effect that changes cursor position, so |
3469 * it must be called immediately after entering termcap mode. | |
3470 */ | |
3471 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3472 may_req_ambiguous_char_width(void) |
4215 | 3473 { |
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
|
3474 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
|
3475 && 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
|
3476 && starting == 0 |
4215 | 3477 && *T_U7 != NUL |
3478 && !option_was_set((char_u *)"ambiwidth")) | |
3479 { | |
3480 char_u buf[16]; | |
3481 | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3482 LOG_TR("Sending U7 request"); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3483 /* 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
|
3484 * 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
|
3485 term_windgoto(1, 0); |
4215 | 3486 buf[mb_char2bytes(0x25bd, buf)] = 0; |
3487 out_str(buf); | |
3488 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
|
3489 u7_status = STATUS_SENT; |
5724 | 3490 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
|
3491 |
08e60ce4cbf3
patch 8.0.0611: the screen is not redrawn after sending t_u7
Christian Brabandt <cb@256bit.org>
parents:
11453
diff
changeset
|
3492 /* 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
|
3493 * after this. Clear them out for now. */ |
5724 | 3494 term_windgoto(1, 0); |
4215 | 3495 out_str((char_u *)" "); |
3496 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
|
3497 |
4215 | 3498 /* check for the characters now, otherwise they might be eaten by |
3499 * get_keystroke() */ | |
3500 out_flush(); | |
3501 (void)vpeekc_nomap(); | |
3502 } | |
3503 } | |
3504 # endif | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3505 |
6874 | 3506 /* |
6885 | 3507 * Similar to requesting the version string: Request the terminal background |
3508 * color when it is the right moment. | |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3509 * Also request the cursor shape, if possible. |
6874 | 3510 */ |
3511 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3512 may_req_bg_color(void) |
6874 | 3513 { |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3514 int did_one = FALSE; |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3515 |
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
|
3516 if (can_get_termresponse() && starting == 0) |
6874 | 3517 { |
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
|
3518 /* 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
|
3519 * 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
|
3520 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
|
3521 && *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
|
3522 && !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
|
3523 { |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3524 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
|
3525 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
|
3526 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
|
3527 did_one = TRUE; |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3528 } |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3529 |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3530 /* Only request cursor blinking mode if t_RC is set. */ |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3531 if (rbm_status == STATUS_GET && *T_CRC != NUL) |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3532 { |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3533 LOG_TR("Sending BC request"); |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3534 out_str(T_CRC); |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3535 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
|
3536 did_one = TRUE; |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3537 } |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3538 |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3539 if (did_one) |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3540 { |
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
|
3541 /* 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
|
3542 * 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
|
3543 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
|
3544 (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
|
3545 } |
6874 | 3546 } |
3547 } | |
3548 | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3549 # ifdef DEBUG_TERMRESPONSE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3550 static void |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3551 log_tr(char *msg) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3552 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3553 static FILE *fd_tr = NULL; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3554 static proftime_T start; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3555 proftime_T now; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3556 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3557 if (fd_tr == NULL) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3558 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3559 fd_tr = fopen("termresponse.log", "w"); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3560 profile_start(&start); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3561 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3562 now = start; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3563 profile_end(&now); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3564 fprintf(fd_tr, "%s: %s %s\n", |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3565 profile_msg(&now), |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3566 must_redraw == NOT_VALID ? "NV" |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3567 : must_redraw == CLEAR ? "CL" : " ", |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3568 msg); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3569 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3570 # endif |
7 | 3571 #endif |
3572 | |
3573 /* | |
3574 * Return TRUE when saving and restoring the screen. | |
3575 */ | |
3576 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3577 swapping_screen(void) |
7 | 3578 { |
3579 return (full_screen && *T_TI != NUL); | |
3580 } | |
3581 | |
3582 #ifdef FEAT_MOUSE | |
3583 /* | |
3584 * setmouse() - switch mouse on/off depending on current mode and 'mouse' | |
3585 */ | |
3586 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3587 setmouse(void) |
7 | 3588 { |
3589 # ifdef FEAT_MOUSE_TTY | |
3590 int checkfor; | |
3591 # endif | |
3592 | |
3593 # ifdef FEAT_MOUSESHAPE | |
3594 update_mouseshape(-1); | |
3595 # endif | |
3596 | |
3597 # ifdef FEAT_MOUSE_TTY /* Should be outside proc, but may break MOUSESHAPE */ | |
3598 # ifdef FEAT_GUI | |
3599 /* In the GUI the mouse is always enabled. */ | |
3600 if (gui.in_use) | |
3601 return; | |
3602 # endif | |
3603 /* be quick when mouse is off */ | |
3604 if (*p_mouse == NUL || has_mouse_termcode == 0) | |
3605 return; | |
3606 | |
3607 /* don't switch mouse on when not in raw mode (Ex mode) */ | |
3608 if (cur_tmode != TMODE_RAW) | |
3609 { | |
3610 mch_setmouse(FALSE); | |
3611 return; | |
3612 } | |
3613 | |
3614 if (VIsual_active) | |
3615 checkfor = MOUSE_VISUAL; | |
5735 | 3616 else if (State == HITRETURN || State == ASKMORE || State == SETWSIZE) |
7 | 3617 checkfor = MOUSE_RETURN; |
3618 else if (State & INSERT) | |
3619 checkfor = MOUSE_INSERT; | |
3620 else if (State & CMDLINE) | |
3621 checkfor = MOUSE_COMMAND; | |
3622 else if (State == CONFIRM || State == EXTERNCMD) | |
3623 checkfor = ' '; /* don't use mouse for ":confirm" or ":!cmd" */ | |
3624 else | |
3625 checkfor = MOUSE_NORMAL; /* assume normal mode */ | |
3626 | |
3627 if (mouse_has(checkfor)) | |
3628 mch_setmouse(TRUE); | |
3629 else | |
3630 mch_setmouse(FALSE); | |
3631 # endif | |
3632 } | |
3633 | |
3634 /* | |
3635 * Return TRUE if | |
3636 * - "c" is in 'mouse', or | |
3637 * - 'a' is in 'mouse' and "c" is in MOUSE_A, or | |
3638 * - the current buffer is a help file and 'h' is in 'mouse' and we are in a | |
3639 * normal editing mode (not at hit-return message). | |
3640 */ | |
3641 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3642 mouse_has(int c) |
7 | 3643 { |
3644 char_u *p; | |
3645 | |
3646 for (p = p_mouse; *p; ++p) | |
3647 switch (*p) | |
3648 { | |
3649 case 'a': if (vim_strchr((char_u *)MOUSE_A, c) != NULL) | |
3650 return TRUE; | |
3651 break; | |
3652 case MOUSE_HELP: if (c != MOUSE_RETURN && curbuf->b_help) | |
3653 return TRUE; | |
3654 break; | |
3655 default: if (c == *p) return TRUE; break; | |
3656 } | |
3657 return FALSE; | |
3658 } | |
3659 | |
3660 /* | |
3661 * Return TRUE when 'mousemodel' is set to "popup" or "popup_setpos". | |
3662 */ | |
3663 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3664 mouse_model_popup(void) |
7 | 3665 { |
3666 return (p_mousem[0] == 'p'); | |
3667 } | |
3668 #endif | |
3669 | |
3670 /* | |
3671 * By outputting the 'cursor very visible' termcap code, for some windowed | |
3672 * terminals this makes the screen scrolled to the correct position. | |
3673 * Used when starting Vim or returning from a shell. | |
3674 */ | |
3675 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3676 scroll_start(void) |
7 | 3677 { |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3678 if (*T_VS != NUL && *T_CVS != NUL) |
7 | 3679 { |
3680 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
|
3681 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
|
3682 screen_start(); /* don't know where cursor is now */ |
7 | 3683 } |
3684 } | |
3685 | |
3686 static int cursor_is_off = FALSE; | |
3687 | |
3688 /* | |
3689 * Enable the cursor. | |
3690 */ | |
3691 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3692 cursor_on(void) |
7 | 3693 { |
3694 if (cursor_is_off) | |
3695 { | |
3696 out_str(T_VE); | |
3697 cursor_is_off = FALSE; | |
3698 } | |
3699 } | |
3700 | |
3701 /* | |
3702 * Disable the cursor. | |
3703 */ | |
3704 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3705 cursor_off(void) |
7 | 3706 { |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3707 if (full_screen && !cursor_is_off) |
7 | 3708 { |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3709 out_str(T_VI); /* disable cursor */ |
7 | 3710 cursor_is_off = TRUE; |
3711 } | |
3712 } | |
3713 | |
39 | 3714 #if defined(CURSOR_SHAPE) || defined(PROTO) |
7 | 3715 /* |
6727 | 3716 * Set cursor shape to match Insert or Replace mode. |
36 | 3717 */ |
3718 void | |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3719 term_cursor_mode(int forced) |
36 | 3720 { |
12078
d21b8f31b296
patch 8.0.0919: cursor color isn't set on startup
Christian Brabandt <cb@256bit.org>
parents:
12076
diff
changeset
|
3721 static int showing_mode = -1; |
6727 | 3722 char_u *p; |
3723 | |
3724 /* Only do something when redrawing the screen and we can restore the | |
3725 * mode. */ | |
3726 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
|
3727 { |
12184
76fbd85c3cea
patch 8.0.0972: compiler warnings for unused variables
Christian Brabandt <cb@256bit.org>
parents:
12174
diff
changeset
|
3728 # 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
|
3729 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
|
3730 /* 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
|
3731 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
|
3732 # endif |
36 | 3733 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
|
3734 } |
36 | 3735 |
6727 | 3736 if ((State & REPLACE) == REPLACE) |
36 | 3737 { |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3738 if (forced || showing_mode != REPLACE) |
6727 | 3739 { |
3740 if (*T_CSR != NUL) | |
3741 p = T_CSR; /* Replace mode cursor */ | |
3742 else | |
3743 p = T_CSI; /* fall back to Insert mode cursor */ | |
3744 if (*p != NUL) | |
3745 { | |
3746 out_str(p); | |
3747 showing_mode = REPLACE; | |
3748 } | |
3749 } | |
36 | 3750 } |
6727 | 3751 else if (State & INSERT) |
36 | 3752 { |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3753 if ((forced || showing_mode != INSERT) && *T_CSI != NUL) |
6727 | 3754 { |
3755 out_str(T_CSI); /* Insert mode cursor */ | |
3756 showing_mode = INSERT; | |
3757 } | |
3758 } | |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3759 else if (forced || showing_mode != NORMAL) |
6727 | 3760 { |
3761 out_str(T_CEI); /* non-Insert mode cursor */ | |
3762 showing_mode = NORMAL; | |
36 | 3763 } |
3764 } | |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3765 |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3766 # 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
|
3767 void |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3768 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
|
3769 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3770 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
|
3771 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3772 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
|
3773 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
|
3774 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
|
3775 out_flush(); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3776 } |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3777 } |
12172
444793fce117
patch 8.0.0966: build failure without terminal feature
Christian Brabandt <cb@256bit.org>
parents:
12170
diff
changeset
|
3778 # endif |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3779 |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3780 int |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3781 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
|
3782 { |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3783 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
|
3784 && initial_cursor_blink != 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
|
3785 } |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3786 |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3787 /* |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3788 * "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
|
3789 */ |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3790 void |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3791 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
|
3792 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3793 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
|
3794 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3795 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
|
3796 out_flush(); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3797 } |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3798 else |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3799 { |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3800 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
|
3801 |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3802 /* 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
|
3803 * 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
|
3804 * 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
|
3805 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
|
3806 do_blink = !blink; |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3807 |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3808 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
|
3809 { |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3810 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
|
3811 out_flush(); |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3812 } |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3813 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
|
3814 { |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3815 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
|
3816 out_flush(); |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3817 } |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3818 } |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3819 } |
39 | 3820 #endif |
36 | 3821 |
3822 /* | |
7 | 3823 * Set scrolling region for window 'wp'. |
3824 * The region starts 'off' lines from the start of the window. | |
3825 * Also set the vertical scroll region for a vertically split window. Always | |
3826 * the full width of the window, excluding the vertical separator. | |
3827 */ | |
3828 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3829 scroll_region_set(win_T *wp, int off) |
7 | 3830 { |
3831 OUT_STR(tgoto((char *)T_CS, W_WINROW(wp) + wp->w_height - 1, | |
3832 W_WINROW(wp) + off)); | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
3833 #ifdef FEAT_WINDOWS |
7 | 3834 if (*T_CSV != NUL && wp->w_width != Columns) |
3835 OUT_STR(tgoto((char *)T_CSV, W_WINCOL(wp) + wp->w_width - 1, | |
3836 W_WINCOL(wp))); | |
3837 #endif | |
3838 screen_start(); /* don't know where cursor is now */ | |
3839 } | |
3840 | |
3841 /* | |
3842 * Reset scrolling region to the whole screen. | |
3843 */ | |
3844 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3845 scroll_region_reset(void) |
7 | 3846 { |
3847 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
|
3848 #ifdef FEAT_WINDOWS |
7 | 3849 if (*T_CSV != NUL) |
3850 OUT_STR(tgoto((char *)T_CSV, (int)Columns - 1, 0)); | |
3851 #endif | |
3852 screen_start(); /* don't know where cursor is now */ | |
3853 } | |
3854 | |
3855 | |
3856 /* | |
3857 * List of terminal codes that are currently recognized. | |
3858 */ | |
3859 | |
298 | 3860 static struct termcode |
7 | 3861 { |
3862 char_u name[2]; /* termcap name of entry */ | |
3863 char_u *code; /* terminal code (in allocated memory) */ | |
3864 int len; /* STRLEN(code) */ | |
179 | 3865 int modlen; /* length of part before ";*~". */ |
7 | 3866 } *termcodes = NULL; |
3867 | |
3868 static int tc_max_len = 0; /* number of entries that termcodes[] can hold */ | |
3869 static int tc_len = 0; /* current number of entries in termcodes[] */ | |
3870 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
3871 static int termcode_star(char_u *code, int len); |
180 | 3872 |
7 | 3873 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3874 clear_termcodes(void) |
7 | 3875 { |
3876 while (tc_len > 0) | |
3877 vim_free(termcodes[--tc_len].code); | |
3878 vim_free(termcodes); | |
3879 termcodes = NULL; | |
3880 tc_max_len = 0; | |
3881 | |
3882 #ifdef HAVE_TGETENT | |
3883 BC = (char *)empty_option; | |
3884 UP = (char *)empty_option; | |
3885 PC = NUL; /* set pad character to NUL */ | |
3886 ospeed = 0; | |
3887 #endif | |
3888 | |
3889 need_gather = TRUE; /* need to fill termleader[] */ | |
3890 } | |
3891 | |
180 | 3892 #define ATC_FROM_TERM 55 |
3893 | |
7 | 3894 /* |
3895 * Add a new entry to the list of terminal codes. | |
3896 * The list is kept alphabetical for ":set termcap" | |
180 | 3897 * "flags" is TRUE when replacing 7-bit by 8-bit controls is desired. |
3898 * "flags" can also be ATC_FROM_TERM for got_code_from_term(). | |
7 | 3899 */ |
3900 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3901 add_termcode(char_u *name, char_u *string, int flags) |
7 | 3902 { |
3903 struct termcode *new_tc; | |
3904 int i, j; | |
3905 char_u *s; | |
179 | 3906 int len; |
7 | 3907 |
3908 if (string == NULL || *string == NUL) | |
3909 { | |
3910 del_termcode(name); | |
3911 return; | |
3912 } | |
3913 | |
6047 | 3914 #if defined(WIN3264) && !defined(FEAT_GUI) |
3915 s = vim_strnsave(string, (int)STRLEN(string) + 1); | |
3916 #else | |
7 | 3917 s = vim_strsave(string); |
6047 | 3918 #endif |
7 | 3919 if (s == NULL) |
3920 return; | |
3921 | |
3922 /* Change leading <Esc>[ to CSI, change <Esc>O to <M-O>. */ | |
180 | 3923 if (flags != 0 && flags != ATC_FROM_TERM && term_7to8bit(string) != 0) |
7 | 3924 { |
1623 | 3925 STRMOVE(s, s + 1); |
7 | 3926 s[0] = term_7to8bit(string); |
3927 } | |
6047 | 3928 |
3929 #if defined(WIN3264) && !defined(FEAT_GUI) | |
3930 if (s[0] == K_NUL) | |
3931 { | |
6102 | 3932 STRMOVE(s + 1, s); |
3933 s[1] = 3; | |
6047 | 3934 } |
3935 #endif | |
3936 | |
179 | 3937 len = (int)STRLEN(s); |
7 | 3938 |
3939 need_gather = TRUE; /* need to fill termleader[] */ | |
3940 | |
3941 /* | |
3942 * need to make space for more entries | |
3943 */ | |
3944 if (tc_len == tc_max_len) | |
3945 { | |
3946 tc_max_len += 20; | |
3947 new_tc = (struct termcode *)alloc( | |
3948 (unsigned)(tc_max_len * sizeof(struct termcode))); | |
3949 if (new_tc == NULL) | |
3950 { | |
3951 tc_max_len -= 20; | |
3952 return; | |
3953 } | |
3954 for (i = 0; i < tc_len; ++i) | |
3955 new_tc[i] = termcodes[i]; | |
3956 vim_free(termcodes); | |
3957 termcodes = new_tc; | |
3958 } | |
3959 | |
3960 /* | |
3961 * Look for existing entry with the same name, it is replaced. | |
3962 * Look for an existing entry that is alphabetical higher, the new entry | |
3963 * is inserted in front of it. | |
3964 */ | |
3965 for (i = 0; i < tc_len; ++i) | |
3966 { | |
3967 if (termcodes[i].name[0] < name[0]) | |
3968 continue; | |
3969 if (termcodes[i].name[0] == name[0]) | |
3970 { | |
3971 if (termcodes[i].name[1] < name[1]) | |
3972 continue; | |
3973 /* | |
180 | 3974 * Exact match: May replace old code. |
7 | 3975 */ |
3976 if (termcodes[i].name[1] == name[1]) | |
3977 { | |
180 | 3978 if (flags == ATC_FROM_TERM && (j = termcode_star( |
3979 termcodes[i].code, termcodes[i].len)) > 0) | |
179 | 3980 { |
180 | 3981 /* Don't replace ESC[123;*X or ESC O*X with another when |
3982 * invoked from got_code_from_term(). */ | |
3983 if (len == termcodes[i].len - j | |
179 | 3984 && STRNCMP(s, termcodes[i].code, len - 1) == 0 |
180 | 3985 && s[len - 1] |
3986 == termcodes[i].code[termcodes[i].len - 1]) | |
179 | 3987 { |
180 | 3988 /* They are equal but for the ";*": don't add it. */ |
179 | 3989 vim_free(s); |
3990 return; | |
3991 } | |
3992 } | |
3993 else | |
3994 { | |
180 | 3995 /* Replace old code. */ |
179 | 3996 vim_free(termcodes[i].code); |
3997 --tc_len; | |
3998 break; | |
3999 } | |
7 | 4000 } |
4001 } | |
4002 /* | |
4003 * Found alphabetical larger entry, move rest to insert new entry | |
4004 */ | |
4005 for (j = tc_len; j > i; --j) | |
4006 termcodes[j] = termcodes[j - 1]; | |
4007 break; | |
4008 } | |
4009 | |
4010 termcodes[i].name[0] = name[0]; | |
4011 termcodes[i].name[1] = name[1]; | |
4012 termcodes[i].code = s; | |
179 | 4013 termcodes[i].len = len; |
180 | 4014 |
4015 /* For xterm we recognize special codes like "ESC[42;*X" and "ESC O*X" that | |
4016 * accept modifiers. */ | |
4017 termcodes[i].modlen = 0; | |
4018 j = termcode_star(s, len); | |
4019 if (j > 0) | |
4020 termcodes[i].modlen = len - 1 - j; | |
7 | 4021 ++tc_len; |
4022 } | |
4023 | |
180 | 4024 /* |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
4025 * Check termcode "code[len]" for ending in ;*X or *X. |
180 | 4026 * 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
|
4027 * Return 0 if not found, 2 for ;*X and 1 for *X. |
180 | 4028 */ |
4029 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4030 termcode_star(char_u *code, int len) |
180 | 4031 { |
4032 /* Shortest is <M-O>*X. With ; shortest is <CSI>1;*X */ | |
4033 if (len >= 3 && code[len - 2] == '*') | |
4034 { | |
4035 if (len >= 5 && code[len - 3] == ';') | |
4036 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
|
4037 else |
180 | 4038 return 1; |
4039 } | |
4040 return 0; | |
4041 } | |
4042 | |
7 | 4043 char_u * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4044 find_termcode(char_u *name) |
7 | 4045 { |
4046 int i; | |
4047 | |
4048 for (i = 0; i < tc_len; ++i) | |
4049 if (termcodes[i].name[0] == name[0] && termcodes[i].name[1] == name[1]) | |
4050 return termcodes[i].code; | |
4051 return NULL; | |
4052 } | |
4053 | |
4054 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) | |
4055 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4056 get_termcode(int i) |
7 | 4057 { |
4058 if (i >= tc_len) | |
4059 return NULL; | |
4060 return &termcodes[i].name[0]; | |
4061 } | |
4062 #endif | |
4063 | |
4064 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4065 del_termcode(char_u *name) |
7 | 4066 { |
4067 int i; | |
4068 | |
4069 if (termcodes == NULL) /* nothing there yet */ | |
4070 return; | |
4071 | |
4072 need_gather = TRUE; /* need to fill termleader[] */ | |
4073 | |
4074 for (i = 0; i < tc_len; ++i) | |
4075 if (termcodes[i].name[0] == name[0] && termcodes[i].name[1] == name[1]) | |
4076 { | |
4077 del_termcode_idx(i); | |
4078 return; | |
4079 } | |
4080 /* not found. Give error message? */ | |
4081 } | |
4082 | |
4083 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4084 del_termcode_idx(int idx) |
7 | 4085 { |
4086 int i; | |
4087 | |
4088 vim_free(termcodes[idx].code); | |
4089 --tc_len; | |
4090 for (i = idx; i < tc_len; ++i) | |
4091 termcodes[i] = termcodes[i + 1]; | |
4092 } | |
4093 | |
4094 #ifdef FEAT_TERMRESPONSE | |
4095 /* | |
4096 * Called when detected that the terminal sends 8-bit codes. | |
4097 * Convert all 7-bit codes to their 8-bit equivalent. | |
4098 */ | |
4099 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4100 switch_to_8bit(void) |
7 | 4101 { |
4102 int i; | |
4103 int c; | |
4104 | |
4105 /* Only need to do something when not already using 8-bit codes. */ | |
4106 if (!term_is_8bit(T_NAME)) | |
4107 { | |
4108 for (i = 0; i < tc_len; ++i) | |
4109 { | |
4110 c = term_7to8bit(termcodes[i].code); | |
4111 if (c != 0) | |
4112 { | |
1623 | 4113 STRMOVE(termcodes[i].code + 1, termcodes[i].code + 2); |
7 | 4114 termcodes[i].code[0] = c; |
4115 } | |
4116 } | |
4117 need_gather = TRUE; /* need to fill termleader[] */ | |
4118 } | |
4119 detected_8bit = TRUE; | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4120 LOG_TR("Switching to 8 bit"); |
7 | 4121 } |
4122 #endif | |
4123 | |
4124 #ifdef CHECK_DOUBLE_CLICK | |
4125 static linenr_T orig_topline = 0; | |
4126 # ifdef FEAT_DIFF | |
4127 static int orig_topfill = 0; | |
4128 # endif | |
4129 #endif | |
4130 #if (defined(FEAT_WINDOWS) && defined(CHECK_DOUBLE_CLICK)) || defined(PROTO) | |
4131 /* | |
4132 * Checking for double clicks ourselves. | |
4133 * "orig_topline" is used to avoid detecting a double-click when the window | |
4134 * contents scrolled (e.g., when 'scrolloff' is non-zero). | |
4135 */ | |
4136 /* | |
4137 * Set orig_topline. Used when jumping to another window, so that a double | |
4138 * click still works. | |
4139 */ | |
4140 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4141 set_mouse_topline(win_T *wp) |
7 | 4142 { |
4143 orig_topline = wp->w_topline; | |
4144 # ifdef FEAT_DIFF | |
4145 orig_topfill = wp->w_topfill; | |
4146 # endif | |
4147 } | |
4148 #endif | |
4149 | |
4150 /* | |
4151 * Check if typebuf.tb_buf[] contains a terminal key code. | |
4152 * Check from typebuf.tb_buf[typebuf.tb_off] to typebuf.tb_buf[typebuf.tb_off | |
4153 * + max_offset]. | |
4154 * Return 0 for no match, -1 for partial match, > 0 for full match. | |
2672 | 4155 * Return KEYLEN_REMOVED when a key code was deleted. |
7 | 4156 * With a match, the match is removed, the replacement code is inserted in |
4157 * typebuf.tb_buf[] and the number of characters in typebuf.tb_buf[] is | |
4158 * returned. | |
3328 | 4159 * When "buf" is not NULL, buf[bufsize] is used instead of typebuf.tb_buf[]. |
4160 * "buflen" is then the length of the string in buf[] and is updated for | |
4161 * inserts and deletes. | |
7 | 4162 */ |
4163 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4164 check_termcode( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4165 int max_offset, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4166 char_u *buf, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4167 int bufsize, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4168 int *buflen) |
7 | 4169 { |
4170 char_u *tp; | |
4171 char_u *p; | |
4172 int slen = 0; /* init for GCC */ | |
180 | 4173 int modslen; |
7 | 4174 int len; |
2672 | 4175 int retval = 0; |
7 | 4176 int offset; |
4177 char_u key_name[2]; | |
180 | 4178 int modifiers; |
11565
91519a14ec1f
patch 8.0.0665: warning for uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
11563
diff
changeset
|
4179 char_u *modifiers_start = NULL; |
180 | 4180 int key; |
7 | 4181 int new_slen; |
4182 int extra; | |
4183 char_u string[MAX_KEY_CODE_LEN + 1]; | |
4184 int i, j; | |
4185 int idx = 0; | |
4186 #ifdef FEAT_MOUSE | |
1623 | 4187 # if !defined(UNIX) || defined(FEAT_MOUSE_XTERM) || defined(FEAT_GUI) \ |
4188 || defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE) | |
7 | 4189 char_u bytes[6]; |
4190 int num_bytes; | |
4191 # endif | |
4192 int mouse_code = 0; /* init for GCC */ | |
4193 int is_click, is_drag; | |
4194 int wheel_code = 0; | |
4195 int current_button; | |
4196 static int held_button = MOUSE_RELEASE; | |
4197 static int orig_num_clicks = 1; | |
4198 static int orig_mouse_code = 0x0; | |
4199 # ifdef CHECK_DOUBLE_CLICK | |
4200 static int orig_mouse_col = 0; | |
4201 static int orig_mouse_row = 0; | |
4202 static struct timeval orig_mouse_time = {0, 0}; | |
4203 /* time of previous mouse click */ | |
4204 struct timeval mouse_time; /* time of current mouse click */ | |
4205 long timediff; /* elapsed time in msec */ | |
4206 # endif | |
4207 #endif | |
4208 int cpo_koffset; | |
4209 #ifdef FEAT_MOUSE_GPM | |
4210 extern int gpm_flag; /* gpm library variable */ | |
4211 #endif | |
4212 | |
4213 cpo_koffset = (vim_strchr(p_cpo, CPO_KOFFSET) != NULL); | |
4214 | |
4215 /* | |
4216 * Speed up the checks for terminal codes by gathering all first bytes | |
4217 * used in termleader[]. Often this is just a single <Esc>. | |
4218 */ | |
4219 if (need_gather) | |
4220 gather_termleader(); | |
4221 | |
4222 /* | |
4223 * Check at several positions in typebuf.tb_buf[], to catch something like | |
4224 * "x<Up>" that can be mapped. Stop at max_offset, because characters | |
4225 * after that cannot be used for mapping, and with @r commands | |
4223 | 4226 * typebuf.tb_buf[] can become very long. |
7 | 4227 * This is used often, KEEP IT FAST! |
4228 */ | |
4229 for (offset = 0; offset < max_offset; ++offset) | |
4230 { | |
4231 if (buf == NULL) | |
4232 { | |
4233 if (offset >= typebuf.tb_len) | |
4234 break; | |
4235 tp = typebuf.tb_buf + typebuf.tb_off + offset; | |
4236 len = typebuf.tb_len - offset; /* length of the input */ | |
4237 } | |
4238 else | |
4239 { | |
3328 | 4240 if (offset >= *buflen) |
7 | 4241 break; |
4242 tp = buf + offset; | |
3328 | 4243 len = *buflen - offset; |
7 | 4244 } |
4245 | |
4246 /* | |
4247 * Don't check characters after K_SPECIAL, those are already | |
4248 * translated terminal chars (avoid translating ~@^Hx). | |
4249 */ | |
4250 if (*tp == K_SPECIAL) | |
4251 { | |
4252 offset += 2; /* there are always 2 extra characters */ | |
4253 continue; | |
4254 } | |
4255 | |
4256 /* | |
4257 * Skip this position if the character does not appear as the first | |
4258 * character in term_strings. This speeds up a lot, since most | |
4259 * termcodes start with the same character (ESC or CSI). | |
4260 */ | |
4261 i = *tp; | |
4262 for (p = termleader; *p && *p != i; ++p) | |
4263 ; | |
4264 if (*p == NUL) | |
4265 continue; | |
4266 | |
4267 /* | |
4268 * Skip this position if p_ek is not set and tp[0] is an ESC and we | |
4269 * are in Insert mode. | |
4270 */ | |
4271 if (*tp == ESC && !p_ek && (State & INSERT)) | |
4272 continue; | |
4273 | |
4274 key_name[0] = NUL; /* no key name found yet */ | |
699 | 4275 key_name[1] = NUL; /* no key name found yet */ |
180 | 4276 modifiers = 0; /* no modifiers yet */ |
7 | 4277 |
4278 #ifdef FEAT_GUI | |
4279 if (gui.in_use) | |
4280 { | |
4281 /* | |
4282 * GUI special key codes are all of the form [CSI xx]. | |
4283 */ | |
4284 if (*tp == CSI) /* Special key from GUI */ | |
4285 { | |
4286 if (len < 3) | |
4287 return -1; /* Shouldn't happen */ | |
4288 slen = 3; | |
4289 key_name[0] = tp[1]; | |
4290 key_name[1] = tp[2]; | |
4291 } | |
4292 } | |
4293 else | |
4294 #endif /* FEAT_GUI */ | |
4295 { | |
4296 for (idx = 0; idx < tc_len; ++idx) | |
4297 { | |
4298 /* | |
4299 * Ignore the entry if we are not at the start of | |
4300 * typebuf.tb_buf[] | |
4301 * and there are not enough characters to make a match. | |
4302 * But only when the 'K' flag is in 'cpoptions'. | |
4303 */ | |
4304 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
|
4305 modifiers_start = NULL; |
7 | 4306 if (cpo_koffset && offset && len < slen) |
4307 continue; | |
4308 if (STRNCMP(termcodes[idx].code, tp, | |
4309 (size_t)(slen > len ? len : slen)) == 0) | |
4310 { | |
4311 if (len < slen) /* got a partial sequence */ | |
4312 return -1; /* need to get more chars */ | |
4313 | |
4314 /* | |
4315 * When found a keypad key, check if there is another key | |
4316 * that matches and use that one. This makes <Home> to be | |
4317 * found instead of <kHome> when they produce the same | |
4318 * key code. | |
4319 */ | |
4320 if (termcodes[idx].name[0] == 'K' | |
4321 && VIM_ISDIGIT(termcodes[idx].name[1])) | |
4322 { | |
4323 for (j = idx + 1; j < tc_len; ++j) | |
4324 if (termcodes[j].len == slen && | |
4325 STRNCMP(termcodes[idx].code, | |
4326 termcodes[j].code, slen) == 0) | |
4327 { | |
4328 idx = j; | |
4329 break; | |
4330 } | |
4331 } | |
4332 | |
4333 key_name[0] = termcodes[idx].name[0]; | |
4334 key_name[1] = termcodes[idx].name[1]; | |
4335 break; | |
4336 } | |
179 | 4337 |
4338 /* | |
4339 * Check for code with modifier, like xterm uses: | |
180 | 4340 * <Esc>[123;*X (modslen == slen - 3) |
4341 * Also <Esc>O*X and <M-O>*X (modslen == slen - 2). | |
4342 * When there is a modifier the * matches a number. | |
4343 * When there is no modifier the ;* or * is omitted. | |
179 | 4344 */ |
4345 if (termcodes[idx].modlen > 0) | |
4346 { | |
180 | 4347 modslen = termcodes[idx].modlen; |
4348 if (cpo_koffset && offset && len < modslen) | |
179 | 4349 continue; |
4350 if (STRNCMP(termcodes[idx].code, tp, | |
180 | 4351 (size_t)(modslen > len ? len : modslen)) == 0) |
179 | 4352 { |
4353 int n; | |
180 | 4354 |
4355 if (len <= modslen) /* got a partial sequence */ | |
179 | 4356 return -1; /* need to get more chars */ |
4357 | |
180 | 4358 if (tp[modslen] == termcodes[idx].code[slen - 1]) |
4359 slen = modslen + 1; /* no modifiers */ | |
4360 else if (tp[modslen] != ';' && modslen == slen - 3) | |
179 | 4361 continue; /* no match */ |
4362 else | |
4363 { | |
4364 /* Skip over the digits, the final char must | |
4365 * 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
|
4366 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
|
4367 || tp[j] == ';'); ++j) |
179 | 4368 ; |
4369 ++j; | |
4370 if (len < j) /* got a partial sequence */ | |
4371 return -1; /* need to get more chars */ | |
180 | 4372 if (tp[j - 1] != termcodes[idx].code[slen - 1]) |
4373 continue; /* no match */ | |
179 | 4374 |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
4375 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
|
4376 |
179 | 4377 /* 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
|
4378 n = atoi((char *)modifiers_start) - 1; |
179 | 4379 if (n & 1) |
180 | 4380 modifiers |= MOD_MASK_SHIFT; |
179 | 4381 if (n & 2) |
180 | 4382 modifiers |= MOD_MASK_ALT; |
179 | 4383 if (n & 4) |
180 | 4384 modifiers |= MOD_MASK_CTRL; |
179 | 4385 if (n & 8) |
180 | 4386 modifiers |= MOD_MASK_META; |
179 | 4387 |
4388 slen = j; | |
4389 } | |
4390 key_name[0] = termcodes[idx].name[0]; | |
4391 key_name[1] = termcodes[idx].name[1]; | |
4392 break; | |
4393 } | |
4394 } | |
7 | 4395 } |
4396 } | |
4397 | |
4398 #ifdef FEAT_TERMRESPONSE | |
3166 | 4399 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
|
4400 /* Mouse codes of DEC and pterm start with <ESC>[. When |
6102 | 4401 * detecting the start of these mouse codes they might as well be |
4402 * another key code or terminal response. */ | |
4403 # ifdef FEAT_MOUSE_DEC | |
4404 || key_name[0] == KS_DEC_MOUSE | |
4405 # endif | |
4406 # ifdef FEAT_MOUSE_PTERM | |
4407 || key_name[0] == KS_PTERM_MOUSE | |
4223 | 4408 # endif |
6102 | 4409 ) |
7 | 4410 { |
6102 | 4411 /* Check for some responses from the terminal starting with |
4412 * "<Esc>[" or CSI: | |
4215 | 4413 * |
6102 | 4414 * - 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
|
4415 * Libvterm returns {x} == 0, {vers} == 100, {y} == 0. |
4215 | 4416 * Also eat other possible responses to t_RV, rxvt returns |
4417 * "<Esc>[?1;2c". Also accept CSI instead of <Esc>[. | |
4418 * mrxvt has been reported to have "+" in the version. Assume | |
4419 * the escape sequence ends with a letter or one of "{|}~". | |
4420 * | |
6102 | 4421 * - Cursor position report: <Esc>[{row};{col}R |
4422 * The final byte must be 'R'. It is used for checking the | |
4215 | 4423 * 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
|
4424 * |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4425 * - window position reply: <Esc>[3;{x};{y}t |
4215 | 4426 */ |
6901 | 4427 char_u *argp = tp[0] == ESC ? tp + 2 : tp + 1; |
4428 | |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4429 if ((*T_CRV != NUL || *T_U7 != NUL || waiting_for_winpos) |
6901 | 4430 && ((tp[0] == ESC && len >= 3 && tp[1] == '[') |
4395 | 4431 || (tp[0] == CSI && len >= 2)) |
6874 | 4432 && (VIM_ISDIGIT(*argp) || *argp == '>' || *argp == '?')) |
7 | 4433 { |
11784
80fa4b0eb0b0
patch 8.0.0774: build failure without the multi-byte feature
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
4434 int col = 0; |
80fa4b0eb0b0
patch 8.0.0774: build failure without the multi-byte feature
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
4435 int semicols = 0; |
5724 | 4436 #ifdef FEAT_MBYTE |
5743 | 4437 int row_char = NUL; |
5724 | 4438 #endif |
11784
80fa4b0eb0b0
patch 8.0.0774: build failure without the multi-byte feature
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
4439 |
7 | 4440 extra = 0; |
1552 | 4441 for (i = 2 + (tp[0] != CSI); i < len |
4442 && !(tp[i] >= '{' && tp[i] <= '~') | |
4443 && !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
|
4444 if (tp[i] == ';' && ++semicols == 1) |
5724 | 4445 { |
4395 | 4446 extra = i + 1; |
5724 | 4447 #ifdef FEAT_MBYTE |
4448 row_char = tp[i - 1]; | |
4449 #endif | |
4450 } | |
7 | 4451 if (i == len) |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4452 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4453 LOG_TR("Not enough characters for CRV"); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4454 return -1; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4455 } |
5724 | 4456 if (extra > 0) |
4457 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
|
4458 |
80fa4b0eb0b0
patch 8.0.0774: build failure without the multi-byte feature
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
4459 #ifdef FEAT_MBYTE |
5724 | 4460 /* Eat it when it has 2 arguments and ends in 'R'. Also when |
4461 * u7_status is not "sent", it may be from a previous Vim that | |
4462 * just exited. But not for <S-F3>, it sends something | |
4463 * 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
|
4464 if (semicols == 1 && tp[i] == 'R') |
4215 | 4465 { |
6102 | 4466 if (row_char == '2' && col >= 2) |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4467 { |
6102 | 4468 char *aw = NULL; |
4469 | |
4470 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
|
4471 u7_status = STATUS_GOT; |
6102 | 4472 # ifdef FEAT_AUTOCMD |
4473 did_cursorhold = TRUE; | |
4474 # endif | |
4475 if (col == 2) | |
4476 aw = "single"; | |
4477 else if (col == 3) | |
4478 aw = "double"; | |
4479 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
|
4480 { |
6102 | 4481 /* Setting the option causes a screen redraw. Do |
4482 * that right away if possible, keeping any | |
4483 * messages. */ | |
4484 set_option_value((char_u *)"ambw", 0L, | |
4485 (char_u *)aw, 0); | |
4486 # ifdef DEBUG_TERMRESPONSE | |
4487 { | |
4488 char buf[100]; | |
4489 int r = redraw_asap(CLEAR); | |
4490 | |
4491 sprintf(buf, | |
4492 "set 'ambiwidth', redraw_asap(): %d", | |
4493 r); | |
4494 log_tr(buf); | |
4495 } | |
4496 # else | |
4497 redraw_asap(CLEAR); | |
4498 # endif | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4499 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4500 } |
4215 | 4501 key_name[0] = (int)KS_EXTRA; |
4502 key_name[1] = (int)KE_IGNORE; | |
4503 slen = i + 1; | |
4504 } | |
4505 else | |
4506 #endif | |
7 | 4507 /* eat it when at least one digit and ending in 'c' */ |
4215 | 4508 if (*T_CRV != NUL && i > 2 + (tp[0] != CSI) && tp[i] == 'c') |
7 | 4509 { |
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
|
4510 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
|
4511 crv_status = STATUS_GOT; |
4262 | 4512 # ifdef FEAT_AUTOCMD |
4513 did_cursorhold = TRUE; | |
4514 # endif | |
7 | 4515 |
4516 /* If this code starts with CSI, you can bet that the | |
4517 * terminal uses 8-bit codes. */ | |
4518 if (tp[0] == CSI) | |
4519 switch_to_8bit(); | |
4520 | |
4521 /* rxvt sends its version number: "20703" is 2.7.3. | |
4522 * Ignore it for when the user has set 'term' to xterm, | |
4523 * 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
|
4524 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
|
4525 col = 0; |
7 | 4526 |
11784
80fa4b0eb0b0
patch 8.0.0774: build failure without the multi-byte feature
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
4527 if (tp[1 + (tp[0] != CSI)] == '>' && semicols == 2) |
7 | 4528 { |
3885 | 4529 /* Only set 'ttymouse' automatically if it was not set |
4530 * by the user already. */ | |
4531 if (!option_was_set((char_u *)"ttym")) | |
4532 { | |
3746 | 4533 # 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
|
4534 if (col >= 277) |
3885 | 4535 set_option_value((char_u *)"ttym", 0L, |
3746 | 4536 (char_u *)"sgr", 0); |
3885 | 4537 else |
3746 | 4538 # endif |
3885 | 4539 /* 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
|
4540 if (col >= 95) |
3885 | 4541 set_option_value((char_u *)"ttym", 0L, |
7 | 4542 (char_u *)"xterm2", 0); |
3885 | 4543 } |
4544 | |
7 | 4545 /* 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
|
4546 if (col >= 141) |
7 | 4547 { |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4548 LOG_TR("Enable checking for XT codes"); |
7 | 4549 check_for_codes = TRUE; |
4550 need_gather = TRUE; | |
4551 req_codes_from_term(); | |
4552 } | |
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
|
4553 |
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 /* 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
|
4555 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
|
4556 && 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
|
4557 { |
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
|
4558 /* 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
|
4559 * 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
|
4560 * 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
|
4561 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
|
4562 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
|
4563 } |
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 |
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
|
4565 # 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
|
4566 /* 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
|
4567 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
|
4568 && STRNCMP(tp + extra - 2, "1;95;0c", 7) == 0) |
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
|
4569 { |
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
|
4570 /* Terminal.app sets $TERM to "xterm-256colors", |
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
|
4571 * but it's not fully xterm compatible. */ |
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
|
4572 is_terminal_app = TRUE; |
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
|
4573 } |
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
|
4574 # endif |
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
|
4575 |
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
|
4576 /* 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
|
4577 * 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
|
4578 * 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
|
4579 if (rcs_status == STATUS_GET |
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
|
4580 # 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
|
4581 && !is_terminal_app |
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 # endif |
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 && *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
|
4584 && *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
|
4585 { |
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
|
4586 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
|
4587 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
|
4588 rcs_status = STATUS_SENT; |
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
|
4589 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
|
4590 } |
7 | 4591 } |
4592 # ifdef FEAT_EVAL | |
4593 set_vim_var_string(VV_TERMRESPONSE, tp, i + 1); | |
4594 # endif | |
4595 # ifdef FEAT_AUTOCMD | |
4596 apply_autocmds(EVENT_TERMRESPONSE, | |
4597 NULL, NULL, FALSE, curbuf); | |
4598 # endif | |
4599 key_name[0] = (int)KS_EXTRA; | |
4600 key_name[1] = (int)KE_IGNORE; | |
4601 slen = i + 1; | |
4602 } | |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4603 |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4604 /* 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
|
4605 * {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
|
4606 * {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
|
4607 * |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4608 * {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
|
4609 */ |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4610 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
|
4611 && 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
|
4612 && i == j + 6 |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4613 && 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
|
4614 && 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
|
4615 && tp[j + 3] == ';' |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4616 && tp[i - 1] == '$' |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4617 && tp[i] == 'y') |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4618 { |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4619 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
|
4620 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
|
4621 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
|
4622 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
|
4623 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
|
4624 slen = i + 1; |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4625 } |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4626 |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4627 /* |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4628 * 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
|
4629 * {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
|
4630 */ |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4631 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
|
4632 && ((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
|
4633 || (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
|
4634 && 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
|
4635 && 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
|
4636 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4637 j += 2; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4638 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
|
4639 ; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4640 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
|
4641 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4642 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
|
4643 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
|
4644 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
|
4645 ; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4646 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
|
4647 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4648 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
|
4649 /* 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
|
4650 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
|
4651 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
|
4652 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
|
4653 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4654 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4655 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
|
4656 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4657 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
|
4658 return -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 } |
6901 | 4661 } |
4662 | |
4663 /* Check for background color response from the terminal: | |
4664 * | |
4665 * {lead}11;rgb:{rrrr}/{gggg}/{bbbb}{tail} | |
4666 * | |
4667 * {lead} can be <Esc>] or OSC | |
4668 * {tail} can be '\007', <Esc>\ or STERM. | |
4669 * | |
4670 * Consume any code that starts with "{lead}11;", it's also | |
4671 * possible that "rgba" is following. | |
4672 */ | |
4673 else if (*T_RBG != NUL | |
4674 && ((tp[0] == ESC && len >= 2 && tp[1] == ']') | |
4675 || tp[0] == OSC)) | |
4676 { | |
4677 j = 1 + (tp[0] == ESC); | |
4678 if (len >= j + 3 && (argp[0] != '1' | |
4679 || argp[1] != '1' || argp[2] != ';')) | |
4680 i = 0; /* no match */ | |
4681 else | |
4682 for (i = j; i < len; ++i) | |
4683 if (tp[i] == '\007' || (tp[0] == OSC ? tp[i] == STERM | |
4684 : (tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\'))) | |
4685 { | |
4686 if (i - j >= 21 && STRNCMP(tp + j + 3, "rgb:", 4) == 0 | |
4687 && tp[j + 11] == '/' && tp[j + 16] == '/' | |
4688 && !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
|
4689 { |
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4690 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
|
4691 + 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
|
4692 |
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
|
4693 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
|
4694 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
|
4695 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
|
4696 { |
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4697 /* 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
|
4698 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
|
4699 (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
|
4700 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
|
4701 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
|
4702 } |
6901 | 4703 } |
4704 | |
4705 /* got finished code: consume it */ | |
4706 key_name[0] = (int)KS_EXTRA; | |
4707 key_name[1] = (int)KE_IGNORE; | |
4708 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
|
4709 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
|
4710 /* 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
|
4711 * 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
|
4712 ++slen; |
6901 | 4713 break; |
4714 } | |
4715 if (i == len) | |
6874 | 4716 { |
6901 | 4717 LOG_TR("not enough characters for RB"); |
4718 return -1; | |
6874 | 4719 } |
7 | 4720 } |
4721 | |
6901 | 4722 /* Check for key code response from xterm: |
4723 * {lead}{flag}+r<hex bytes><{tail} | |
4724 * | |
4725 * {lead} can be <Esc>P or DCS | |
4726 * {flag} can be '0' or '1' | |
4727 * {tail} can be Esc>\ or STERM | |
4728 * | |
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
|
4729 * 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
|
4730 * {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
|
4731 * |
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
|
4732 * {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
|
4733 * {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
|
4734 * |
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
|
4735 * Consume any code that starts with "{lead}.+r" or "{lead}.$r". |
6901 | 4736 */ |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4737 else if ((check_for_codes || rcs_status == STATUS_SENT) |
6901 | 4738 && ((tp[0] == ESC && len >= 2 && tp[1] == 'P') |
7 | 4739 || tp[0] == DCS)) |
4740 { | |
6901 | 4741 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
|
4742 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
|
4743 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
|
4744 else if ((argp[1] != '+' && argp[1] != '$') || argp[2] != 'r') |
6901 | 4745 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
|
4746 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
|
4747 /* key code response */ |
6901 | 4748 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
|
4749 { |
6901 | 4750 if ((tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\') |
7 | 4751 || tp[i] == STERM) |
4752 { | |
6901 | 4753 if (i - j >= 3) |
7 | 4754 got_code_from_term(tp + j, i); |
4755 key_name[0] = (int)KS_EXTRA; | |
4756 key_name[1] = (int)KE_IGNORE; | |
4757 slen = i + 1 + (tp[i] == ESC); | |
4758 break; | |
4759 } | |
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
|
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 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
|
4762 && 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
|
4763 && 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
|
4764 { |
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
|
4765 /* 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
|
4766 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
|
4767 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
|
4768 || 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
|
4769 { |
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 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
|
4771 |
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 /* 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
|
4773 * 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
|
4774 * 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
|
4775 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
|
4776 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
|
4777 /* 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
|
4778 * 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
|
4779 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
|
4780 (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
|
4781 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
|
4782 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
|
4783 |
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
|
4784 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
|
4785 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
|
4786 slen = i + 1 + (tp[i] == ESC); |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4787 } |
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 } |
7 | 4789 |
4790 if (i == len) | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4791 { |
6901 | 4792 /* These codes arrive many together, each code can be |
4793 * truncated at any point. */ | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4794 LOG_TR("not enough characters for XT"); |
6901 | 4795 return -1; |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4796 } |
7 | 4797 } |
4798 } | |
4799 #endif | |
4800 | |
4801 if (key_name[0] == NUL) | |
4802 continue; /* No match at this position, try next one */ | |
4803 | |
4804 /* We only get here when we have a complete termcode match */ | |
4805 | |
4806 #ifdef FEAT_MOUSE | |
4807 # ifdef FEAT_GUI | |
4808 /* | |
4809 * Only in the GUI: Fetch the pointer coordinates of the scroll event | |
4810 * so that we know which window to scroll later. | |
4811 */ | |
4812 if (gui.in_use | |
4813 && key_name[0] == (int)KS_EXTRA | |
4814 && (key_name[1] == (int)KE_X1MOUSE | |
4815 || 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
|
4816 || key_name[1] == (int)KE_MOUSELEFT |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2347
diff
changeset
|
4817 || key_name[1] == (int)KE_MOUSERIGHT |
7 | 4818 || key_name[1] == (int)KE_MOUSEDOWN |
4819 || key_name[1] == (int)KE_MOUSEUP)) | |
4820 { | |
4821 num_bytes = get_bytes_from_buf(tp + slen, bytes, 4); | |
4822 if (num_bytes == -1) /* not enough coordinates */ | |
4823 return -1; | |
4824 mouse_col = 128 * (bytes[0] - ' ' - 1) + bytes[1] - ' ' - 1; | |
4825 mouse_row = 128 * (bytes[2] - ' ' - 1) + bytes[3] - ' ' - 1; | |
4826 slen += num_bytes; | |
4827 } | |
4828 else | |
4829 # endif | |
4830 /* | |
4831 * If it is a mouse click, get the coordinates. | |
4832 */ | |
3746 | 4833 if (key_name[0] == KS_MOUSE |
7 | 4834 # ifdef FEAT_MOUSE_JSB |
3746 | 4835 || key_name[0] == KS_JSBTERM_MOUSE |
7 | 4836 # endif |
4837 # ifdef FEAT_MOUSE_NET | |
3746 | 4838 || key_name[0] == KS_NETTERM_MOUSE |
7 | 4839 # endif |
4840 # ifdef FEAT_MOUSE_DEC | |
3746 | 4841 || key_name[0] == KS_DEC_MOUSE |
7 | 4842 # endif |
4843 # ifdef FEAT_MOUSE_PTERM | |
3746 | 4844 || key_name[0] == KS_PTERM_MOUSE |
7 | 4845 # endif |
3166 | 4846 # ifdef FEAT_MOUSE_URXVT |
3746 | 4847 || key_name[0] == KS_URXVT_MOUSE |
4848 # endif | |
4849 # ifdef FEAT_MOUSE_SGR | |
4850 || 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
|
4851 || key_name[0] == KS_SGR_MOUSE_RELEASE |
3166 | 4852 # endif |
7 | 4853 ) |
4854 { | |
4855 is_click = is_drag = FALSE; | |
4856 | |
1623 | 4857 # if !defined(UNIX) || defined(FEAT_MOUSE_XTERM) || defined(FEAT_GUI) \ |
4858 || defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE) | |
7 | 4859 if (key_name[0] == (int)KS_MOUSE) |
4860 { | |
4861 /* | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
4862 * For xterm we get "<t_mouse>scr", where |
7 | 4863 * s == encoded button state: |
4864 * 0x20 = left button down | |
4865 * 0x21 = middle button down | |
4866 * 0x22 = right button down | |
4867 * 0x23 = any button release | |
4868 * 0x60 = button 4 down (scroll wheel down) | |
4869 * 0x61 = button 5 down (scroll wheel up) | |
4870 * add 0x04 for SHIFT | |
4871 * add 0x08 for ALT | |
4872 * add 0x10 for CTRL | |
4873 * add 0x20 for mouse drag (0x40 is drag with left button) | |
4874 * c == column + ' ' + 1 == column + 33 | |
4875 * r == row + ' ' + 1 == row + 33 | |
4876 * | |
4877 * The coordinates are passed on through global variables. | |
4878 * Ugly, but this avoids trouble with mouse clicks at an | |
4879 * unexpected moment and allows for mapping them. | |
4880 */ | |
4881 for (;;) | |
4882 { | |
4883 #ifdef FEAT_GUI | |
4884 if (gui.in_use) | |
4885 { | |
4886 /* GUI uses more bits for columns > 223 */ | |
4887 num_bytes = get_bytes_from_buf(tp + slen, bytes, 5); | |
4888 if (num_bytes == -1) /* not enough coordinates */ | |
4889 return -1; | |
4890 mouse_code = bytes[0]; | |
4891 mouse_col = 128 * (bytes[1] - ' ' - 1) | |
4892 + bytes[2] - ' ' - 1; | |
4893 mouse_row = 128 * (bytes[3] - ' ' - 1) | |
4894 + bytes[4] - ' ' - 1; | |
4895 } | |
4896 else | |
4897 #endif | |
4898 { | |
4899 num_bytes = get_bytes_from_buf(tp + slen, bytes, 3); | |
4900 if (num_bytes == -1) /* not enough coordinates */ | |
4901 return -1; | |
4902 mouse_code = bytes[0]; | |
4903 mouse_col = bytes[1] - ' ' - 1; | |
4904 mouse_row = bytes[2] - ' ' - 1; | |
4905 } | |
4906 slen += num_bytes; | |
4907 | |
4908 /* If the following bytes is also a mouse code and it has | |
4909 * the same code, dump this one and get the next. This | |
4910 * makes dragging a whole lot faster. */ | |
4911 #ifdef FEAT_GUI | |
4912 if (gui.in_use) | |
4913 j = 3; | |
4914 else | |
4915 #endif | |
4916 j = termcodes[idx].len; | |
4917 if (STRNCMP(tp, tp + slen, (size_t)j) == 0 | |
4918 && tp[slen + j] == mouse_code | |
4919 && tp[slen + j + 1] != NUL | |
4920 && tp[slen + j + 2] != NUL | |
4921 #ifdef FEAT_GUI | |
4922 && (!gui.in_use | |
4923 || (tp[slen + j + 3] != NUL | |
4924 && tp[slen + j + 4] != NUL)) | |
4925 #endif | |
4926 ) | |
4927 slen += j; | |
4928 else | |
4929 break; | |
4930 } | |
3166 | 4931 } |
4932 | |
3746 | 4933 # if defined(FEAT_MOUSE_URXVT) || defined(FEAT_MOUSE_SGR) |
4934 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
|
4935 || 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
|
4936 || key_name[0] == KS_SGR_MOUSE_RELEASE) |
3166 | 4937 { |
11567
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4938 /* URXVT 1015 mouse reporting mode: |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4939 * 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
|
4940 * are decimal instead of bytes. |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4941 * |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4942 * \033[%d;%d;%dM |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4943 * ^-- row |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4944 * ^----- column |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4945 * ^-------- code |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4946 * |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4947 * SGR 1006 mouse reporting mode: |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4948 * 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
|
4949 * are decimal instead of bytes. |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4950 * |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4951 * \033[<%d;%d;%dM |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4952 * ^-- row |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4953 * ^----- column |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4954 * ^-------- code |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4955 * |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4956 * \033[<%d;%d;%dm : mouse release event |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4957 * ^-- row |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4958 * ^----- column |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4959 * ^-------- code |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4960 */ |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4961 p = modifiers_start; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4962 if (p == NULL) |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4963 return -1; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4964 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4965 mouse_code = getdigits(&p); |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4966 if (*p++ != ';') |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4967 return -1; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4968 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4969 /* 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
|
4970 if (key_name[0] == KS_SGR_MOUSE |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4971 || key_name[0] == KS_SGR_MOUSE_RELEASE) |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4972 mouse_code += 32; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4973 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4974 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
|
4975 mouse_code |= MOUSE_RELEASE; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4976 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4977 mouse_col = getdigits(&p) - 1; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4978 if (*p++ != ';') |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4979 return -1; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4980 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4981 mouse_row = getdigits(&p) - 1; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4982 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4983 /* 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
|
4984 * modifier keys (alt/shift/ctrl/meta) state. */ |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
4985 modifiers = 0; |
3166 | 4986 } |
4987 # endif | |
4988 | |
4989 if (key_name[0] == (int)KS_MOUSE | |
4990 #ifdef FEAT_MOUSE_URXVT | |
4991 || key_name[0] == (int)KS_URXVT_MOUSE | |
4992 #endif | |
3746 | 4993 #ifdef FEAT_MOUSE_SGR |
4994 || 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
|
4995 || key_name[0] == KS_SGR_MOUSE_RELEASE |
3746 | 4996 #endif |
3166 | 4997 ) |
4998 { | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
4999 # if !defined(MSWIN) |
7 | 5000 /* |
5001 * Handle mouse events. | |
5002 * Recognize the xterm mouse wheel, but not in the GUI, the | |
5003 * Linux console with GPM and the MS-DOS or Win32 console | |
5004 * (multi-clicks use >= 0x60). | |
5005 */ | |
5006 if (mouse_code >= MOUSEWHEEL_LOW | |
5007 # ifdef FEAT_GUI | |
5008 && !gui.in_use | |
5009 # endif | |
5010 # ifdef FEAT_MOUSE_GPM | |
5011 && gpm_flag == 0 | |
5012 # endif | |
5013 ) | |
5014 { | |
5015 /* Keep the mouse_code before it's changed, so that we | |
5016 * remember that it was a mouse wheel click. */ | |
5017 wheel_code = mouse_code; | |
5018 } | |
5019 # ifdef FEAT_MOUSE_XTERM | |
5020 else if (held_button == MOUSE_RELEASE | |
5021 # ifdef FEAT_GUI | |
5022 && !gui.in_use | |
5023 # endif | |
5024 && (mouse_code == 0x23 || mouse_code == 0x24)) | |
5025 { | |
5026 /* Apparently used by rxvt scroll wheel. */ | |
5027 wheel_code = mouse_code - 0x23 + MOUSEWHEEL_LOW; | |
5028 } | |
5029 # endif | |
5030 | |
5031 # if defined(UNIX) && defined(FEAT_MOUSE_TTY) | |
5032 else if (use_xterm_mouse() > 1) | |
5033 { | |
5034 if (mouse_code & MOUSE_DRAG_XTERM) | |
5035 mouse_code |= MOUSE_DRAG; | |
5036 } | |
5037 # endif | |
5038 # ifdef FEAT_XCLIPBOARD | |
5039 else if (!(mouse_code & MOUSE_DRAG & ~MOUSE_CLICK_MASK)) | |
5040 { | |
5041 if ((mouse_code & MOUSE_RELEASE) == MOUSE_RELEASE) | |
5042 stop_xterm_trace(); | |
5043 else | |
5044 start_xterm_trace(mouse_code); | |
5045 } | |
5046 # endif | |
5047 # endif | |
5048 } | |
5049 # endif /* !UNIX || FEAT_MOUSE_XTERM */ | |
5050 # ifdef FEAT_MOUSE_NET | |
5051 if (key_name[0] == (int)KS_NETTERM_MOUSE) | |
5052 { | |
5053 int mc, mr; | |
5054 | |
5055 /* expect a rather limited sequence like: balancing { | |
5056 * \033}6,45\r | |
5057 * '6' is the row, 45 is the column | |
5058 */ | |
5059 p = tp + slen; | |
5060 mr = getdigits(&p); | |
5061 if (*p++ != ',') | |
5062 return -1; | |
5063 mc = getdigits(&p); | |
5064 if (*p++ != '\r') | |
5065 return -1; | |
5066 | |
5067 mouse_col = mc - 1; | |
5068 mouse_row = mr - 1; | |
5069 mouse_code = MOUSE_LEFT; | |
5070 slen += (int)(p - (tp + slen)); | |
5071 } | |
5072 # endif /* FEAT_MOUSE_NET */ | |
5073 # ifdef FEAT_MOUSE_JSB | |
5074 if (key_name[0] == (int)KS_JSBTERM_MOUSE) | |
5075 { | |
5076 int mult, val, iter, button, status; | |
5077 | |
5078 /* JSBTERM Input Model | |
5079 * \033[0~zw uniq escape sequence | |
5080 * (L-x) Left button pressed - not pressed x not reporting | |
5081 * (M-x) Middle button pressed - not pressed x not reporting | |
5082 * (R-x) Right button pressed - not pressed x not reporting | |
5083 * (SDmdu) Single , Double click, m mouse move d button down | |
5084 * u button up | |
5085 * ### X cursor position padded to 3 digits | |
5086 * ### Y cursor position padded to 3 digits | |
5087 * (s-x) SHIFT key pressed - not pressed x not reporting | |
5088 * (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
|
5089 * \033\\ terminating sequence |
7 | 5090 */ |
5091 | |
5092 p = tp + slen; | |
5093 button = mouse_code = 0; | |
5094 switch (*p++) | |
5095 { | |
5096 case 'L': button = 1; break; | |
5097 case '-': break; | |
5098 case 'x': break; /* ignore sequence */ | |
5099 default: return -1; /* Unknown Result */ | |
5100 } | |
5101 switch (*p++) | |
5102 { | |
5103 case 'M': button |= 2; break; | |
5104 case '-': break; | |
5105 case 'x': break; /* ignore sequence */ | |
5106 default: return -1; /* Unknown Result */ | |
5107 } | |
5108 switch (*p++) | |
5109 { | |
5110 case 'R': button |= 4; break; | |
5111 case '-': break; | |
5112 case 'x': break; /* ignore sequence */ | |
5113 default: return -1; /* Unknown Result */ | |
5114 } | |
5115 status = *p++; | |
5116 for (val = 0, mult = 100, iter = 0; iter < 3; iter++, | |
5117 mult /= 10, p++) | |
5118 if (*p >= '0' && *p <= '9') | |
5119 val += (*p - '0') * mult; | |
5120 else | |
5121 return -1; | |
5122 mouse_col = val; | |
5123 for (val = 0, mult = 100, iter = 0; iter < 3; iter++, | |
5124 mult /= 10, p++) | |
5125 if (*p >= '0' && *p <= '9') | |
5126 val += (*p - '0') * mult; | |
5127 else | |
5128 return -1; | |
5129 mouse_row = val; | |
5130 switch (*p++) | |
5131 { | |
5132 case 's': button |= 8; break; /* SHIFT key Pressed */ | |
5133 case '-': break; /* Not Pressed */ | |
5134 case 'x': break; /* Not Reporting */ | |
5135 default: return -1; /* Unknown Result */ | |
5136 } | |
5137 switch (*p++) | |
5138 { | |
5139 case 'c': button |= 16; break; /* CTRL key Pressed */ | |
5140 case '-': break; /* Not Pressed */ | |
5141 case 'x': break; /* Not Reporting */ | |
5142 default: return -1; /* Unknown Result */ | |
5143 } | |
5144 if (*p++ != '\033') | |
5145 return -1; | |
5146 if (*p++ != '\\') | |
5147 return -1; | |
5148 switch (status) | |
5149 { | |
5150 case 'D': /* Double Click */ | |
5151 case 'S': /* Single Click */ | |
5152 if (button & 1) mouse_code |= MOUSE_LEFT; | |
5153 if (button & 2) mouse_code |= MOUSE_MIDDLE; | |
5154 if (button & 4) mouse_code |= MOUSE_RIGHT; | |
5155 if (button & 8) mouse_code |= MOUSE_SHIFT; | |
5156 if (button & 16) mouse_code |= MOUSE_CTRL; | |
5157 break; | |
5158 case 'm': /* Mouse move */ | |
5159 if (button & 1) mouse_code |= MOUSE_LEFT; | |
5160 if (button & 2) mouse_code |= MOUSE_MIDDLE; | |
5161 if (button & 4) mouse_code |= MOUSE_RIGHT; | |
5162 if (button & 8) mouse_code |= MOUSE_SHIFT; | |
5163 if (button & 16) mouse_code |= MOUSE_CTRL; | |
5164 if ((button & 7) != 0) | |
5165 { | |
5166 held_button = mouse_code; | |
5167 mouse_code |= MOUSE_DRAG; | |
5168 } | |
5169 is_drag = TRUE; | |
5170 showmode(); | |
5171 break; | |
5172 case 'd': /* Button Down */ | |
5173 if (button & 1) mouse_code |= MOUSE_LEFT; | |
5174 if (button & 2) mouse_code |= MOUSE_MIDDLE; | |
5175 if (button & 4) mouse_code |= MOUSE_RIGHT; | |
5176 if (button & 8) mouse_code |= MOUSE_SHIFT; | |
5177 if (button & 16) mouse_code |= MOUSE_CTRL; | |
5178 break; | |
5179 case 'u': /* Button Up */ | |
5180 if (button & 1) | |
5181 mouse_code |= MOUSE_LEFT | MOUSE_RELEASE; | |
5182 if (button & 2) | |
5183 mouse_code |= MOUSE_MIDDLE | MOUSE_RELEASE; | |
5184 if (button & 4) | |
5185 mouse_code |= MOUSE_RIGHT | MOUSE_RELEASE; | |
5186 if (button & 8) | |
5187 mouse_code |= MOUSE_SHIFT; | |
5188 if (button & 16) | |
5189 mouse_code |= MOUSE_CTRL; | |
5190 break; | |
5191 default: return -1; /* Unknown Result */ | |
5192 } | |
5193 | |
5194 slen += (p - (tp + slen)); | |
5195 } | |
5196 # endif /* FEAT_MOUSE_JSB */ | |
5197 # ifdef FEAT_MOUSE_DEC | |
5198 if (key_name[0] == (int)KS_DEC_MOUSE) | |
5199 { | |
5200 /* The DEC Locator Input Model | |
5201 * Netterm delivers the code sequence: | |
5202 * \033[2;4;24;80&w (left button down) | |
5203 * \033[3;0;24;80&w (left button up) | |
5204 * \033[6;1;24;80&w (right button down) | |
5205 * \033[7;0;24;80&w (right button up) | |
5206 * CSI Pe ; Pb ; Pr ; Pc ; Pp & w | |
5207 * Pe is the event code | |
5208 * Pb is the button code | |
5209 * Pr is the row coordinate | |
5210 * Pc is the column coordinate | |
5211 * Pp is the third coordinate (page number) | |
5212 * Pe, the event code indicates what event caused this report | |
5213 * The following event codes are defined: | |
5214 * 0 - request, the terminal received an explicit request | |
5215 * for a locator report, but the locator is unavailable | |
5216 * 1 - request, the terminal received an explicit request | |
5217 * for a locator report | |
5218 * 2 - left button down | |
5219 * 3 - left button up | |
5220 * 4 - middle button down | |
5221 * 5 - middle button up | |
5222 * 6 - right button down | |
5223 * 7 - right button up | |
5224 * 8 - fourth button down | |
5225 * 9 - fourth button up | |
5226 * 10 - locator outside filter rectangle | |
5227 * Pb, the button code, ASCII decimal 0-15 indicating which | |
5228 * buttons are down if any. The state of the four buttons | |
5229 * on the locator correspond to the low four bits of the | |
5230 * decimal value, | |
5231 * "1" means button depressed | |
5232 * 0 - no buttons down, | |
5233 * 1 - right, | |
5234 * 2 - middle, | |
5235 * 4 - left, | |
5236 * 8 - fourth | |
5237 * Pr is the row coordinate of the locator position in the page, | |
5238 * encoded as an ASCII decimal value. | |
5239 * If Pr is omitted, the locator position is undefined | |
5240 * (outside the terminal window for example). | |
5241 * Pc is the column coordinate of the locator position in the | |
5242 * page, encoded as an ASCII decimal value. | |
5243 * If Pc is omitted, the locator position is undefined | |
5244 * (outside the terminal window for example). | |
5245 * Pp is the page coordinate of the locator position | |
5246 * encoded as an ASCII decimal value. | |
5247 * The page coordinate may be omitted if the locator is on | |
5248 * page one (the default). We ignore it anyway. | |
5249 */ | |
5250 int Pe, Pb, Pr, Pc; | |
5251 | |
5252 p = tp + slen; | |
5253 | |
5254 /* get event status */ | |
5255 Pe = getdigits(&p); | |
5256 if (*p++ != ';') | |
5257 return -1; | |
5258 | |
5259 /* get button status */ | |
5260 Pb = getdigits(&p); | |
5261 if (*p++ != ';') | |
5262 return -1; | |
5263 | |
5264 /* get row status */ | |
5265 Pr = getdigits(&p); | |
5266 if (*p++ != ';') | |
5267 return -1; | |
5268 | |
5269 /* get column status */ | |
5270 Pc = getdigits(&p); | |
5271 | |
5272 /* the page parameter is optional */ | |
5273 if (*p == ';') | |
5274 { | |
5275 p++; | |
5276 (void)getdigits(&p); | |
5277 } | |
5278 if (*p++ != '&') | |
5279 return -1; | |
5280 if (*p++ != 'w') | |
5281 return -1; | |
5282 | |
5283 mouse_code = 0; | |
5284 switch (Pe) | |
5285 { | |
5286 case 0: return -1; /* position request while unavailable */ | |
5287 case 1: /* a response to a locator position request includes | |
5288 the status of all buttons */ | |
5289 Pb &= 7; /* mask off and ignore fourth button */ | |
5290 if (Pb & 4) | |
5291 mouse_code = MOUSE_LEFT; | |
5292 if (Pb & 2) | |
5293 mouse_code = MOUSE_MIDDLE; | |
5294 if (Pb & 1) | |
5295 mouse_code = MOUSE_RIGHT; | |
5296 if (Pb) | |
5297 { | |
5298 held_button = mouse_code; | |
5299 mouse_code |= MOUSE_DRAG; | |
227 | 5300 WantQueryMouse = TRUE; |
7 | 5301 } |
5302 is_drag = TRUE; | |
5303 showmode(); | |
5304 break; | |
5305 case 2: mouse_code = MOUSE_LEFT; | |
227 | 5306 WantQueryMouse = TRUE; |
7 | 5307 break; |
5308 case 3: mouse_code = MOUSE_RELEASE | MOUSE_LEFT; | |
5309 break; | |
5310 case 4: mouse_code = MOUSE_MIDDLE; | |
227 | 5311 WantQueryMouse = TRUE; |
7 | 5312 break; |
5313 case 5: mouse_code = MOUSE_RELEASE | MOUSE_MIDDLE; | |
5314 break; | |
5315 case 6: mouse_code = MOUSE_RIGHT; | |
227 | 5316 WantQueryMouse = TRUE; |
7 | 5317 break; |
5318 case 7: mouse_code = MOUSE_RELEASE | MOUSE_RIGHT; | |
5319 break; | |
5320 case 8: return -1; /* fourth button down */ | |
5321 case 9: return -1; /* fourth button up */ | |
5322 case 10: return -1; /* mouse outside of filter rectangle */ | |
5323 default: return -1; /* should never occur */ | |
5324 } | |
5325 | |
5326 mouse_col = Pc - 1; | |
5327 mouse_row = Pr - 1; | |
5328 | |
5329 slen += (int)(p - (tp + slen)); | |
5330 } | |
5331 # endif /* FEAT_MOUSE_DEC */ | |
5332 # ifdef FEAT_MOUSE_PTERM | |
5333 if (key_name[0] == (int)KS_PTERM_MOUSE) | |
5334 { | |
2237
770485470e59
Add a few #ifdefs to exclude functions that are not used. (Domnique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
1941
diff
changeset
|
5335 int button, num_clicks, action; |
7 | 5336 |
5337 p = tp + slen; | |
5338 | |
5339 action = getdigits(&p); | |
5340 if (*p++ != ';') | |
5341 return -1; | |
5342 | |
5343 mouse_row = getdigits(&p); | |
5344 if (*p++ != ';') | |
5345 return -1; | |
5346 mouse_col = getdigits(&p); | |
5347 if (*p++ != ';') | |
5348 return -1; | |
5349 | |
5350 button = getdigits(&p); | |
5351 mouse_code = 0; | |
5352 | |
9929
579abc260d85
commit https://github.com/vim/vim/commit/de7762a2c1498e2dc43586feb5f982d661799f85
Christian Brabandt <cb@256bit.org>
parents:
9869
diff
changeset
|
5353 switch (button) |
7 | 5354 { |
5355 case 4: mouse_code = MOUSE_LEFT; break; | |
5356 case 1: mouse_code = MOUSE_RIGHT; break; | |
5357 case 2: mouse_code = MOUSE_MIDDLE; break; | |
5358 default: return -1; | |
5359 } | |
5360 | |
9929
579abc260d85
commit https://github.com/vim/vim/commit/de7762a2c1498e2dc43586feb5f982d661799f85
Christian Brabandt <cb@256bit.org>
parents:
9869
diff
changeset
|
5361 switch (action) |
7 | 5362 { |
5363 case 31: /* Initial press */ | |
5364 if (*p++ != ';') | |
5365 return -1; | |
5366 | |
5367 num_clicks = getdigits(&p); /* Not used */ | |
5368 break; | |
5369 | |
5370 case 32: /* Release */ | |
5371 mouse_code |= MOUSE_RELEASE; | |
5372 break; | |
5373 | |
5374 case 33: /* Drag */ | |
5375 held_button = mouse_code; | |
5376 mouse_code |= MOUSE_DRAG; | |
5377 break; | |
5378 | |
5379 default: | |
5380 return -1; | |
5381 } | |
5382 | |
5383 if (*p++ != 't') | |
5384 return -1; | |
5385 | |
5386 slen += (p - (tp + slen)); | |
5387 } | |
5388 # endif /* FEAT_MOUSE_PTERM */ | |
5389 | |
5390 /* Interpret the mouse code */ | |
5391 current_button = (mouse_code & MOUSE_CLICK_MASK); | |
5392 if (current_button == MOUSE_RELEASE | |
5393 # ifdef FEAT_MOUSE_XTERM | |
5394 && wheel_code == 0 | |
5395 # endif | |
5396 ) | |
5397 { | |
5398 /* | |
5399 * If we get a mouse drag or release event when | |
5400 * there is no mouse button held down (held_button == | |
5401 * MOUSE_RELEASE), produce a K_IGNORE below. | |
5402 * (can happen when you hold down two buttons | |
5403 * and then let them go, or click in the menu bar, but not | |
5404 * on a menu, and drag into the text). | |
5405 */ | |
5406 if ((mouse_code & MOUSE_DRAG) == MOUSE_DRAG) | |
5407 is_drag = TRUE; | |
5408 current_button = held_button; | |
5409 } | |
5410 else if (wheel_code == 0) | |
5411 { | |
5412 # ifdef CHECK_DOUBLE_CLICK | |
5413 # ifdef FEAT_MOUSE_GPM | |
5414 # ifdef FEAT_GUI | |
5415 /* | |
5416 * Only for Unix, when GUI or gpm is not active, we handle | |
5417 * multi-clicks here. | |
5418 */ | |
5419 if (gpm_flag == 0 && !gui.in_use) | |
5420 # else | |
5421 if (gpm_flag == 0) | |
5422 # endif | |
5423 # else | |
5424 # ifdef FEAT_GUI | |
5425 if (!gui.in_use) | |
5426 # endif | |
5427 # endif | |
5428 { | |
5429 /* | |
5430 * Compute the time elapsed since the previous mouse click. | |
5431 */ | |
5432 gettimeofday(&mouse_time, NULL); | |
9125
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5433 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
|
5434 { |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5435 /* |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5436 * 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
|
5437 * 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
|
5438 * 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
|
5439 * overflow. |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5440 */ |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5441 timediff = p_mouset; |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5442 } |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5443 else |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5444 { |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5445 timediff = (mouse_time.tv_usec |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5446 - orig_mouse_time.tv_usec) / 1000; |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5447 if (timediff < 0) |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5448 --orig_mouse_time.tv_sec; |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5449 timediff += (mouse_time.tv_sec |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5450 - orig_mouse_time.tv_sec) * 1000; |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5451 } |
7 | 5452 orig_mouse_time = mouse_time; |
5453 if (mouse_code == orig_mouse_code | |
5454 && timediff < p_mouset | |
5455 && orig_num_clicks != 4 | |
5456 && orig_mouse_col == mouse_col | |
5457 && orig_mouse_row == mouse_row | |
683 | 5458 && ((orig_topline == curwin->w_topline |
7 | 5459 #ifdef FEAT_DIFF |
683 | 5460 && orig_topfill == curwin->w_topfill |
7 | 5461 #endif |
683 | 5462 ) |
5463 #ifdef FEAT_WINDOWS | |
5464 /* Double click in tab pages line also works | |
5465 * when window contents changes. */ | |
5466 || (mouse_row == 0 && firstwin->w_winrow > 0) | |
5467 #endif | |
5468 ) | |
5469 ) | |
7 | 5470 ++orig_num_clicks; |
5471 else | |
5472 orig_num_clicks = 1; | |
5473 orig_mouse_col = mouse_col; | |
5474 orig_mouse_row = mouse_row; | |
5475 orig_topline = curwin->w_topline; | |
5476 #ifdef FEAT_DIFF | |
5477 orig_topfill = curwin->w_topfill; | |
5478 #endif | |
5479 } | |
5480 # if defined(FEAT_GUI) || defined(FEAT_MOUSE_GPM) | |
5481 else | |
5482 orig_num_clicks = NUM_MOUSE_CLICKS(mouse_code); | |
5483 # endif | |
5484 # else | |
5485 orig_num_clicks = NUM_MOUSE_CLICKS(mouse_code); | |
5486 # endif | |
5487 is_click = TRUE; | |
5488 orig_mouse_code = mouse_code; | |
5489 } | |
5490 if (!is_drag) | |
5491 held_button = mouse_code & MOUSE_CLICK_MASK; | |
5492 | |
5493 /* | |
5494 * Translate the actual mouse event into a pseudo mouse event. | |
5495 * First work out what modifiers are to be used. | |
5496 */ | |
5497 if (orig_mouse_code & MOUSE_SHIFT) | |
5498 modifiers |= MOD_MASK_SHIFT; | |
5499 if (orig_mouse_code & MOUSE_CTRL) | |
5500 modifiers |= MOD_MASK_CTRL; | |
5501 if (orig_mouse_code & MOUSE_ALT) | |
5502 modifiers |= MOD_MASK_ALT; | |
5503 if (orig_num_clicks == 2) | |
5504 modifiers |= MOD_MASK_2CLICK; | |
5505 else if (orig_num_clicks == 3) | |
5506 modifiers |= MOD_MASK_3CLICK; | |
5507 else if (orig_num_clicks == 4) | |
5508 modifiers |= MOD_MASK_4CLICK; | |
5509 | |
9929
579abc260d85
commit https://github.com/vim/vim/commit/de7762a2c1498e2dc43586feb5f982d661799f85
Christian Brabandt <cb@256bit.org>
parents:
9869
diff
changeset
|
5510 /* 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
|
5511 * added, then it's not mouse up/down. */ |
7 | 5512 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
|
5513 if (wheel_code != 0 |
579abc260d85
commit https://github.com/vim/vim/commit/de7762a2c1498e2dc43586feb5f982d661799f85
Christian Brabandt <cb@256bit.org>
parents:
9869
diff
changeset
|
5514 && (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
|
5515 { |
1a4a66f0c871
Make CTRL modifier work for mouse wheel. (Benjamin Haskell)
Bram Moolenaar <bram@vim.org>
parents:
2279
diff
changeset
|
5516 if (wheel_code & MOUSE_CTRL) |
1a4a66f0c871
Make CTRL modifier work for mouse wheel. (Benjamin Haskell)
Bram Moolenaar <bram@vim.org>
parents:
2279
diff
changeset
|
5517 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
|
5518 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
|
5519 modifiers |= MOD_MASK_ALT; |
7 | 5520 key_name[1] = (wheel_code & 1) |
5521 ? (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
|
5522 } |
7 | 5523 else |
5524 key_name[1] = get_pseudo_mouse_code(current_button, | |
5525 is_click, is_drag); | |
7256
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5526 |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5527 /* 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
|
5528 * return weird values. */ |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5529 if (mouse_col >= Columns) |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5530 mouse_col = Columns - 1; |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5531 if (mouse_row >= Rows) |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5532 mouse_row = Rows - 1; |
7 | 5533 } |
5534 #endif /* FEAT_MOUSE */ | |
5535 | |
5536 #ifdef FEAT_GUI | |
5537 /* | |
5538 * If using the GUI, then we get menu and scrollbar events. | |
5539 * | |
5540 * A menu event is encoded as K_SPECIAL, KS_MENU, KE_FILLER followed by | |
5541 * four bytes which are to be taken as a pointer to the vimmenu_T | |
5542 * structure. | |
5543 * | |
1221 | 5544 * A tab line event is encoded as K_SPECIAL KS_TABLINE nr, where "nr" |
685 | 5545 * is one byte with the tab index. |
5546 * | |
7 | 5547 * A scrollbar event is K_SPECIAL, KS_VER_SCROLLBAR, KE_FILLER followed |
5548 * by one byte representing the scrollbar number, and then four bytes | |
5549 * representing a long_u which is the new value of the scrollbar. | |
5550 * | |
5551 * A horizontal scrollbar event is K_SPECIAL, KS_HOR_SCROLLBAR, | |
5552 * KE_FILLER followed by four bytes representing a long_u which is the | |
5553 * new value of the scrollbar. | |
5554 */ | |
5555 # ifdef FEAT_MENU | |
5556 else if (key_name[0] == (int)KS_MENU) | |
5557 { | |
5558 long_u val; | |
5559 | |
5560 num_bytes = get_long_from_buf(tp + slen, &val); | |
5561 if (num_bytes == -1) | |
5562 return -1; | |
5563 current_menu = (vimmenu_T *)val; | |
5564 slen += num_bytes; | |
936 | 5565 |
5566 /* The menu may have been deleted right after it was used, check | |
5567 * for that. */ | |
5568 if (check_menu_pointer(root_menu, current_menu) == FAIL) | |
5569 { | |
5570 key_name[0] = KS_EXTRA; | |
5571 key_name[1] = (int)KE_IGNORE; | |
5572 } | |
7 | 5573 } |
5574 # endif | |
685 | 5575 # ifdef FEAT_GUI_TABLINE |
5576 else if (key_name[0] == (int)KS_TABLINE) | |
5577 { | |
688 | 5578 /* Selecting tabline tab or using its menu. */ |
685 | 5579 num_bytes = get_bytes_from_buf(tp + slen, bytes, 1); |
5580 if (num_bytes == -1) | |
5581 return -1; | |
5582 current_tab = (int)bytes[0]; | |
1394 | 5583 if (current_tab == 255) /* -1 in a byte gives 255 */ |
5584 current_tab = -1; | |
685 | 5585 slen += num_bytes; |
5586 } | |
688 | 5587 else if (key_name[0] == (int)KS_TABMENU) |
5588 { | |
5589 /* Selecting tabline tab or using its menu. */ | |
5590 num_bytes = get_bytes_from_buf(tp + slen, bytes, 2); | |
5591 if (num_bytes == -1) | |
5592 return -1; | |
5593 current_tab = (int)bytes[0]; | |
5594 current_tabmenu = (int)bytes[1]; | |
5595 slen += num_bytes; | |
5596 } | |
685 | 5597 # endif |
7 | 5598 # ifndef USE_ON_FLY_SCROLL |
5599 else if (key_name[0] == (int)KS_VER_SCROLLBAR) | |
5600 { | |
5601 long_u val; | |
5602 | |
5603 /* Get the last scrollbar event in the queue of the same type */ | |
5604 j = 0; | |
5605 for (i = 0; tp[j] == CSI && tp[j + 1] == KS_VER_SCROLLBAR | |
5606 && tp[j + 2] != NUL; ++i) | |
5607 { | |
5608 j += 3; | |
5609 num_bytes = get_bytes_from_buf(tp + j, bytes, 1); | |
5610 if (num_bytes == -1) | |
5611 break; | |
5612 if (i == 0) | |
5613 current_scrollbar = (int)bytes[0]; | |
5614 else if (current_scrollbar != (int)bytes[0]) | |
5615 break; | |
5616 j += num_bytes; | |
5617 num_bytes = get_long_from_buf(tp + j, &val); | |
5618 if (num_bytes == -1) | |
5619 break; | |
5620 scrollbar_value = val; | |
5621 j += num_bytes; | |
5622 slen = j; | |
5623 } | |
5624 if (i == 0) /* not enough characters to make one */ | |
5625 return -1; | |
5626 } | |
5627 else if (key_name[0] == (int)KS_HOR_SCROLLBAR) | |
5628 { | |
5629 long_u val; | |
5630 | |
5631 /* Get the last horiz. scrollbar event in the queue */ | |
5632 j = 0; | |
5633 for (i = 0; tp[j] == CSI && tp[j + 1] == KS_HOR_SCROLLBAR | |
5634 && tp[j + 2] != NUL; ++i) | |
5635 { | |
5636 j += 3; | |
5637 num_bytes = get_long_from_buf(tp + j, &val); | |
5638 if (num_bytes == -1) | |
5639 break; | |
5640 scrollbar_value = val; | |
5641 j += num_bytes; | |
5642 slen = j; | |
5643 } | |
5644 if (i == 0) /* not enough characters to make one */ | |
5645 return -1; | |
5646 } | |
5647 # endif /* !USE_ON_FLY_SCROLL */ | |
5648 #endif /* FEAT_GUI */ | |
5649 | |
180 | 5650 /* |
5651 * Change <xHome> to <Home>, <xUp> to <Up>, etc. | |
5652 */ | |
5653 key = handle_x_keys(TERMCAP2KEY(key_name[0], key_name[1])); | |
5654 | |
5655 /* | |
5656 * Add any modifier codes to our string. | |
5657 */ | |
5658 new_slen = 0; /* Length of what will replace the termcode */ | |
5659 if (modifiers != 0) | |
5660 { | |
5661 /* Some keys have the modifier included. Need to handle that here | |
5662 * to make mappings work. */ | |
5663 key = simplify_key(key, &modifiers); | |
5664 if (modifiers != 0) | |
5665 { | |
5666 string[new_slen++] = K_SPECIAL; | |
5667 string[new_slen++] = (int)KS_MODIFIER; | |
5668 string[new_slen++] = modifiers; | |
5669 } | |
5670 } | |
5671 | |
7 | 5672 /* Finally, add the special key code to our string */ |
180 | 5673 key_name[0] = KEY2TERMCAP0(key); |
5674 key_name[1] = KEY2TERMCAP1(key); | |
7 | 5675 if (key_name[0] == KS_KEY) |
1787 | 5676 { |
5677 /* from ":set <M-b>=xx" */ | |
5678 #ifdef FEAT_MBYTE | |
5679 if (has_mbyte) | |
5680 new_slen += (*mb_char2bytes)(key_name[1], string + new_slen); | |
5681 else | |
5682 #endif | |
5683 string[new_slen++] = key_name[1]; | |
5684 } | |
2672 | 5685 else if (new_slen == 0 && key_name[0] == KS_EXTRA |
5686 && key_name[1] == KE_IGNORE) | |
5687 { | |
5688 /* Do not put K_IGNORE into the buffer, do return KEYLEN_REMOVED | |
5689 * to indicate what happened. */ | |
5690 retval = KEYLEN_REMOVED; | |
5691 } | |
7 | 5692 else |
5693 { | |
5694 string[new_slen++] = K_SPECIAL; | |
5695 string[new_slen++] = key_name[0]; | |
5696 string[new_slen++] = key_name[1]; | |
5697 } | |
5698 string[new_slen] = NUL; | |
5699 extra = new_slen - slen; | |
5700 if (buf == NULL) | |
5701 { | |
5702 if (extra < 0) | |
5703 /* remove matched chars, taking care of noremap */ | |
5704 del_typebuf(-extra, offset); | |
5705 else if (extra > 0) | |
5706 /* insert the extra space we need */ | |
5707 ins_typebuf(string + slen, REMAP_YES, offset, FALSE, FALSE); | |
5708 | |
5709 /* | |
5710 * Careful: del_typebuf() and ins_typebuf() may have reallocated | |
5711 * typebuf.tb_buf[]! | |
5712 */ | |
5713 mch_memmove(typebuf.tb_buf + typebuf.tb_off + offset, string, | |
5714 (size_t)new_slen); | |
5715 } | |
5716 else | |
5717 { | |
5718 if (extra < 0) | |
5719 /* remove matched characters */ | |
5720 mch_memmove(buf + offset, buf + offset - extra, | |
3328 | 5721 (size_t)(*buflen + offset + extra)); |
7 | 5722 else if (extra > 0) |
3328 | 5723 { |
5724 /* Insert the extra space we need. If there is insufficient | |
5725 * space return -1. */ | |
5726 if (*buflen + extra + new_slen >= bufsize) | |
5727 return -1; | |
7 | 5728 mch_memmove(buf + offset + extra, buf + offset, |
3328 | 5729 (size_t)(*buflen - offset)); |
5730 } | |
7 | 5731 mch_memmove(buf + offset, string, (size_t)new_slen); |
3328 | 5732 *buflen = *buflen + extra + new_slen; |
7 | 5733 } |
2672 | 5734 return retval == 0 ? (len + extra + offset) : retval; |
7 | 5735 } |
5736 | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5737 #ifdef FEAT_TERMRESPONSE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5738 LOG_TR("normal character"); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5739 #endif |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5740 |
7 | 5741 return 0; /* no match found */ |
5742 } | |
5743 | |
5744 /* | |
5745 * Replace any terminal code strings in from[] with the equivalent internal | |
5746 * vim representation. This is used for the "from" and "to" part of a | |
5747 * mapping, and the "to" part of a menu command. | |
5748 * Any strings like "<C-UP>" are also replaced, unless 'cpoptions' contains | |
5749 * '<'. | |
5750 * K_SPECIAL by itself is replaced by K_SPECIAL KS_SPECIAL KE_FILLER. | |
5751 * | |
5752 * The replacement is done in result[] and finally copied into allocated | |
5753 * memory. If this all works well *bufp is set to the allocated memory and a | |
5754 * pointer to it is returned. If something fails *bufp is set to NULL and from | |
5755 * is returned. | |
5756 * | |
5757 * CTRL-V characters are removed. When "from_part" is TRUE, a trailing CTRL-V | |
5758 * is included, otherwise it is removed (for ":map xx ^V", maps xx to | |
5759 * nothing). When 'cpoptions' does not contain 'B', a backslash can be used | |
5760 * instead of a CTRL-V. | |
5761 */ | |
859 | 5762 char_u * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5763 replace_termcodes( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5764 char_u *from, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5765 char_u **bufp, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5766 int from_part, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5767 int do_lt, /* also translate <lt> */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5768 int special) /* always accept <key> notation */ |
7 | 5769 { |
5770 int i; | |
5771 int slen; | |
5772 int key; | |
5773 int dlen = 0; | |
5774 char_u *src; | |
5775 int do_backslash; /* backslash is a special character */ | |
5776 int do_special; /* recognize <> key codes */ | |
5777 int do_key_code; /* recognize raw key codes */ | |
5778 char_u *result; /* buffer for resulting string */ | |
5779 | |
5780 do_backslash = (vim_strchr(p_cpo, CPO_BSLASH) == NULL); | |
859 | 5781 do_special = (vim_strchr(p_cpo, CPO_SPECI) == NULL) || special; |
7 | 5782 do_key_code = (vim_strchr(p_cpo, CPO_KEYCODE) == NULL); |
5783 | |
5784 /* | |
5785 * Allocate space for the translation. Worst case a single character is | |
5786 * replaced by 6 bytes (shifted special key), plus a NUL at the end. | |
5787 */ | |
5788 result = alloc((unsigned)STRLEN(from) * 6 + 1); | |
5789 if (result == NULL) /* out of memory */ | |
5790 { | |
5791 *bufp = NULL; | |
5792 return from; | |
5793 } | |
5794 | |
5795 src = from; | |
5796 | |
5797 /* | |
5798 * Check for #n at start only: function key n | |
5799 */ | |
5800 if (from_part && src[0] == '#' && VIM_ISDIGIT(src[1])) /* function key */ | |
5801 { | |
5802 result[dlen++] = K_SPECIAL; | |
5803 result[dlen++] = 'k'; | |
5804 if (src[1] == '0') | |
5805 result[dlen++] = ';'; /* #0 is F10 is "k;" */ | |
5806 else | |
5807 result[dlen++] = src[1]; /* #3 is F3 is "k3" */ | |
5808 src += 2; | |
5809 } | |
5810 | |
5811 /* | |
5812 * Copy each byte from *from to result[dlen] | |
5813 */ | |
5814 while (*src != NUL) | |
5815 { | |
5816 /* | |
5817 * 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
|
5818 * like "<C-S-LeftMouse>" |
7 | 5819 */ |
5820 if (do_special && (do_lt || STRNCMP(src, "<lt>", 4) != 0)) | |
5821 { | |
5822 #ifdef FEAT_EVAL | |
5823 /* | |
5824 * Replace <SID> by K_SNR <script-nr> _. | |
5825 * (room: 5 * 6 = 30 bytes; needed: 3 + <nr> + 1 <= 14) | |
5826 */ | |
5827 if (STRNICMP(src, "<SID>", 5) == 0) | |
5828 { | |
5829 if (current_SID <= 0) | |
5830 EMSG(_(e_usingsid)); | |
5831 else | |
5832 { | |
5833 src += 5; | |
5834 result[dlen++] = K_SPECIAL; | |
5835 result[dlen++] = (int)KS_EXTRA; | |
5836 result[dlen++] = (int)KE_SNR; | |
5837 sprintf((char *)result + dlen, "%ld", (long)current_SID); | |
5838 dlen += (int)STRLEN(result + dlen); | |
5839 result[dlen++] = '_'; | |
5840 continue; | |
5841 } | |
5842 } | |
5843 #endif | |
5844 | |
9869
989d44d35a66
commit https://github.com/vim/vim/commit/35a4cfa200917dd171b1fff3cd5b6cee9add673d
Christian Brabandt <cb@256bit.org>
parents:
9814
diff
changeset
|
5845 slen = trans_special(&src, result + dlen, TRUE, FALSE); |
7 | 5846 if (slen) |
5847 { | |
5848 dlen += slen; | |
5849 continue; | |
5850 } | |
5851 } | |
5852 | |
5853 /* | |
5854 * If 'cpoptions' does not contain 'k', see if it's an actual key-code. | |
5855 * Note that this is also checked after replacing the <> form. | |
5856 * Single character codes are NOT replaced (e.g. ^H or DEL), because | |
5857 * it could be a character in the file. | |
5858 */ | |
5859 if (do_key_code) | |
5860 { | |
5861 i = find_term_bykeys(src); | |
5862 if (i >= 0) | |
5863 { | |
5864 result[dlen++] = K_SPECIAL; | |
5865 result[dlen++] = termcodes[i].name[0]; | |
5866 result[dlen++] = termcodes[i].name[1]; | |
5867 src += termcodes[i].len; | |
5868 /* If terminal code matched, continue after it. */ | |
5869 continue; | |
5870 } | |
5871 } | |
5872 | |
5873 #ifdef FEAT_EVAL | |
5874 if (do_special) | |
5875 { | |
5876 char_u *p, *s, len; | |
5877 | |
5878 /* | |
5879 * Replace <Leader> by the value of "mapleader". | |
5880 * Replace <LocalLeader> by the value of "maplocalleader". | |
5881 * If "mapleader" or "maplocalleader" isn't set use a backslash. | |
5882 */ | |
5883 if (STRNICMP(src, "<Leader>", 8) == 0) | |
5884 { | |
5885 len = 8; | |
5886 p = get_var_value((char_u *)"g:mapleader"); | |
5887 } | |
5888 else if (STRNICMP(src, "<LocalLeader>", 13) == 0) | |
5889 { | |
5890 len = 13; | |
5891 p = get_var_value((char_u *)"g:maplocalleader"); | |
5892 } | |
5893 else | |
5894 { | |
5895 len = 0; | |
5896 p = NULL; | |
5897 } | |
5898 if (len != 0) | |
5899 { | |
5900 /* Allow up to 8 * 6 characters for "mapleader". */ | |
5901 if (p == NULL || *p == NUL || STRLEN(p) > 8 * 6) | |
5902 s = (char_u *)"\\"; | |
5903 else | |
5904 s = p; | |
5905 while (*s != NUL) | |
5906 result[dlen++] = *s++; | |
5907 src += len; | |
5908 continue; | |
5909 } | |
5910 } | |
5911 #endif | |
5912 | |
5913 /* | |
5914 * Remove CTRL-V and ignore the next character. | |
5915 * For "from" side the CTRL-V at the end is included, for the "to" | |
5916 * part it is removed. | |
5917 * If 'cpoptions' does not contain 'B', also accept a backslash. | |
5918 */ | |
5919 key = *src; | |
5920 if (key == Ctrl_V || (do_backslash && key == '\\')) | |
5921 { | |
5922 ++src; /* skip CTRL-V or backslash */ | |
5923 if (*src == NUL) | |
5924 { | |
5925 if (from_part) | |
5926 result[dlen++] = key; | |
5927 break; | |
5928 } | |
5929 } | |
5930 | |
5931 #ifdef FEAT_MBYTE | |
5932 /* skip multibyte char correctly */ | |
474 | 5933 for (i = (*mb_ptr2len)(src); i > 0; --i) |
7 | 5934 #endif |
5935 { | |
5936 /* | |
5937 * If the character is K_SPECIAL, replace it with K_SPECIAL | |
5938 * KS_SPECIAL KE_FILLER. | |
5939 * If compiled with the GUI replace CSI with K_CSI. | |
5940 */ | |
5941 if (*src == K_SPECIAL) | |
5942 { | |
5943 result[dlen++] = K_SPECIAL; | |
5944 result[dlen++] = KS_SPECIAL; | |
5945 result[dlen++] = KE_FILLER; | |
5946 } | |
5947 # ifdef FEAT_GUI | |
5948 else if (*src == CSI) | |
5949 { | |
5950 result[dlen++] = K_SPECIAL; | |
5951 result[dlen++] = KS_EXTRA; | |
5952 result[dlen++] = (int)KE_CSI; | |
5953 } | |
5954 # endif | |
5955 else | |
5956 result[dlen++] = *src; | |
5957 ++src; | |
5958 } | |
5959 } | |
5960 result[dlen] = NUL; | |
5961 | |
5962 /* | |
5963 * Copy the new string to allocated memory. | |
5964 * If this fails, just return from. | |
5965 */ | |
5966 if ((*bufp = vim_strsave(result)) != NULL) | |
5967 from = *bufp; | |
5968 vim_free(result); | |
5969 return from; | |
5970 } | |
5971 | |
5972 /* | |
5973 * Find a termcode with keys 'src' (must be NUL terminated). | |
5974 * Return the index in termcodes[], or -1 if not found. | |
5975 */ | |
5976 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5977 find_term_bykeys(char_u *src) |
7 | 5978 { |
5979 int i; | |
3290 | 5980 int slen = (int)STRLEN(src); |
7 | 5981 |
5982 for (i = 0; i < tc_len; ++i) | |
5983 { | |
3273 | 5984 if (slen == termcodes[i].len |
5985 && STRNCMP(termcodes[i].code, src, (size_t)slen) == 0) | |
7 | 5986 return i; |
5987 } | |
5988 return -1; | |
5989 } | |
5990 | |
5991 /* | |
5992 * Gather the first characters in the terminal key codes into a string. | |
5993 * Used to speed up check_termcode(). | |
5994 */ | |
5995 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5996 gather_termleader(void) |
7 | 5997 { |
5998 int i; | |
5999 int len = 0; | |
6000 | |
6001 #ifdef FEAT_GUI | |
6002 if (gui.in_use) | |
6003 termleader[len++] = CSI; /* the GUI codes are not in termcodes[] */ | |
6004 #endif | |
6005 #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
|
6006 if (check_for_codes || *T_CRS != NUL) |
7 | 6007 termleader[len++] = DCS; /* the termcode response starts with DCS |
6008 in 8-bit mode */ | |
6009 #endif | |
6010 termleader[len] = NUL; | |
6011 | |
6012 for (i = 0; i < tc_len; ++i) | |
6013 if (vim_strchr(termleader, termcodes[i].code[0]) == NULL) | |
6014 { | |
6015 termleader[len++] = termcodes[i].code[0]; | |
6016 termleader[len] = NUL; | |
6017 } | |
6018 | |
6019 need_gather = FALSE; | |
6020 } | |
6021 | |
6022 /* | |
6023 * Show all termcodes (for ":set termcap") | |
6024 * This code looks a lot like showoptions(), but is different. | |
6025 */ | |
6026 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6027 show_termcodes(void) |
7 | 6028 { |
6029 int col; | |
6030 int *items; | |
6031 int item_count; | |
6032 int run; | |
6033 int row, rows; | |
6034 int cols; | |
6035 int i; | |
6036 int len; | |
6037 | |
180 | 6038 #define INC3 27 /* try to make three columns */ |
6039 #define INC2 40 /* try to make two columns */ | |
7 | 6040 #define GAP 2 /* spaces between columns */ |
6041 | |
6042 if (tc_len == 0) /* no terminal codes (must be GUI) */ | |
6043 return; | |
6044 items = (int *)alloc((unsigned)(sizeof(int) * tc_len)); | |
6045 if (items == NULL) | |
6046 return; | |
6047 | |
6048 /* Highlight title */ | |
6049 MSG_PUTS_TITLE(_("\n--- Terminal keys ---")); | |
6050 | |
6051 /* | |
6052 * do the loop two times: | |
6053 * 1. display the short items (non-strings and short strings) | |
180 | 6054 * 2. display the medium items (medium length strings) |
6055 * 3. display the long items (remaining strings) | |
7 | 6056 */ |
180 | 6057 for (run = 1; run <= 3 && !got_int; ++run) |
7 | 6058 { |
6059 /* | |
6060 * collect the items in items[] | |
6061 */ | |
6062 item_count = 0; | |
6063 for (i = 0; i < tc_len; i++) | |
6064 { | |
6065 len = show_one_termcode(termcodes[i].name, | |
6066 termcodes[i].code, FALSE); | |
180 | 6067 if (len <= INC3 - GAP ? run == 1 |
6068 : len <= INC2 - GAP ? run == 2 | |
6069 : run == 3) | |
7 | 6070 items[item_count++] = i; |
6071 } | |
6072 | |
6073 /* | |
6074 * display the items | |
6075 */ | |
180 | 6076 if (run <= 2) |
7 | 6077 { |
180 | 6078 cols = (Columns + GAP) / (run == 1 ? INC3 : INC2); |
7 | 6079 if (cols == 0) |
6080 cols = 1; | |
6081 rows = (item_count + cols - 1) / cols; | |
6082 } | |
180 | 6083 else /* run == 3 */ |
7 | 6084 rows = item_count; |
6085 for (row = 0; row < rows && !got_int; ++row) | |
6086 { | |
6087 msg_putchar('\n'); /* go to next line */ | |
6088 if (got_int) /* 'q' typed in more */ | |
6089 break; | |
6090 col = 0; | |
6091 for (i = row; i < item_count; i += rows) | |
6092 { | |
6093 msg_col = col; /* make columns */ | |
6094 show_one_termcode(termcodes[items[i]].name, | |
6095 termcodes[items[i]].code, TRUE); | |
180 | 6096 if (run == 2) |
6097 col += INC2; | |
6098 else | |
6099 col += INC3; | |
7 | 6100 } |
6101 out_flush(); | |
6102 ui_breakcheck(); | |
6103 } | |
6104 } | |
6105 vim_free(items); | |
6106 } | |
6107 | |
6108 /* | |
6109 * Show one termcode entry. | |
6110 * Output goes into IObuff[] | |
6111 */ | |
6112 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6113 show_one_termcode(char_u *name, char_u *code, int printit) |
7 | 6114 { |
6115 char_u *p; | |
6116 int len; | |
6117 | |
6118 if (name[0] > '~') | |
6119 { | |
6120 IObuff[0] = ' '; | |
6121 IObuff[1] = ' '; | |
6122 IObuff[2] = ' '; | |
6123 IObuff[3] = ' '; | |
6124 } | |
6125 else | |
6126 { | |
6127 IObuff[0] = 't'; | |
6128 IObuff[1] = '_'; | |
6129 IObuff[2] = name[0]; | |
6130 IObuff[3] = name[1]; | |
6131 } | |
6132 IObuff[4] = ' '; | |
6133 | |
6134 p = get_special_key_name(TERMCAP2KEY(name[0], name[1]), 0); | |
6135 if (p[1] != 't') | |
6136 STRCPY(IObuff + 5, p); | |
6137 else | |
6138 IObuff[5] = NUL; | |
6139 len = (int)STRLEN(IObuff); | |
6140 do | |
6141 IObuff[len++] = ' '; | |
6142 while (len < 17); | |
6143 IObuff[len] = NUL; | |
6144 if (code == NULL) | |
6145 len += 4; | |
6146 else | |
6147 len += vim_strsize(code); | |
6148 | |
6149 if (printit) | |
6150 { | |
6151 msg_puts(IObuff); | |
6152 if (code == NULL) | |
6153 msg_puts((char_u *)"NULL"); | |
6154 else | |
6155 msg_outtrans(code); | |
6156 } | |
6157 return len; | |
6158 } | |
6159 | |
6160 #if defined(FEAT_TERMRESPONSE) || defined(PROTO) | |
6161 /* | |
6162 * For Xterm >= 140 compiled with OPT_TCAP_QUERY: Obtain the actually used | |
6163 * termcap codes from the terminal itself. | |
6164 * We get them one by one to avoid a very long response string. | |
6165 */ | |
6102 | 6166 static int xt_index_in = 0; |
6167 static int xt_index_out = 0; | |
6168 | |
7 | 6169 static void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6170 req_codes_from_term(void) |
7 | 6171 { |
6172 xt_index_out = 0; | |
6173 xt_index_in = 0; | |
6174 req_more_codes_from_term(); | |
6175 } | |
6176 | |
6177 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6178 req_more_codes_from_term(void) |
7 | 6179 { |
6180 char buf[11]; | |
6181 int old_idx = xt_index_out; | |
6182 | |
6183 /* Don't do anything when going to exit. */ | |
6184 if (exiting) | |
6185 return; | |
6186 | |
6187 /* Send up to 10 more requests out than we received. Avoid sending too | |
6188 * many, there can be a buffer overflow somewhere. */ | |
6189 while (xt_index_out < xt_index_in + 10 && key_names[xt_index_out] != NULL) | |
6190 { | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6191 # ifdef DEBUG_TERMRESPONSE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6192 char dbuf[100]; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6193 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6194 sprintf(dbuf, "Requesting XT %d: %s", |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6195 xt_index_out, key_names[xt_index_out]); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6196 log_tr(dbuf); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6197 # endif |
7 | 6198 sprintf(buf, "\033P+q%02x%02x\033\\", |
6199 key_names[xt_index_out][0], key_names[xt_index_out][1]); | |
6200 out_str_nf((char_u *)buf); | |
6201 ++xt_index_out; | |
6202 } | |
6203 | |
6204 /* Send the codes out right away. */ | |
6205 if (xt_index_out != old_idx) | |
6206 out_flush(); | |
6207 } | |
6208 | |
6209 /* | |
6210 * Decode key code response from xterm: '<Esc>P1+r<name>=<string><Esc>\'. | |
6211 * A "0" instead of the "1" indicates a code that isn't supported. | |
6212 * Both <name> and <string> are encoded in hex. | |
6213 * "code" points to the "0" or "1". | |
6214 */ | |
6215 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6216 got_code_from_term(char_u *code, int len) |
7 | 6217 { |
6218 #define XT_LEN 100 | |
6219 char_u name[3]; | |
6220 char_u str[XT_LEN]; | |
6221 int i; | |
6222 int j = 0; | |
6223 int c; | |
6224 | |
6225 /* A '1' means the code is supported, a '0' means it isn't. | |
6226 * When half the length is > XT_LEN we can't use it. | |
6227 * Our names are currently all 2 characters. */ | |
6228 if (code[0] == '1' && code[7] == '=' && len / 2 < XT_LEN) | |
6229 { | |
6230 /* Get the name from the response and find it in the table. */ | |
6231 name[0] = hexhex2nr(code + 3); | |
6232 name[1] = hexhex2nr(code + 5); | |
6233 name[2] = NUL; | |
6234 for (i = 0; key_names[i] != NULL; ++i) | |
6235 { | |
6236 if (STRCMP(key_names[i], name) == 0) | |
6237 { | |
6238 xt_index_in = i; | |
6239 break; | |
6240 } | |
6241 } | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6242 # ifdef DEBUG_TERMRESPONSE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6243 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6244 char buf[100]; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6245 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6246 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
|
6247 log_tr(buf); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6248 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6249 # endif |
7 | 6250 if (key_names[i] != NULL) |
6251 { | |
6252 for (i = 8; (c = hexhex2nr(code + i)) >= 0; i += 2) | |
6253 str[j++] = c; | |
6254 str[j] = NUL; | |
6255 if (name[0] == 'C' && name[1] == 'o') | |
6256 { | |
6257 /* Color count is not a key code. */ | |
6258 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
|
6259 may_adjust_color_count(i); |
7 | 6260 } |
6261 else | |
6262 { | |
6263 /* First delete any existing entry with the same code. */ | |
6264 i = find_term_bykeys(str); | |
6265 if (i >= 0) | |
6266 del_termcode_idx(i); | |
180 | 6267 add_termcode(name, str, ATC_FROM_TERM); |
7 | 6268 } |
6269 } | |
6270 } | |
6271 | |
6272 /* May request more codes now that we received one. */ | |
6273 ++xt_index_in; | |
6274 req_more_codes_from_term(); | |
6275 } | |
6276 | |
6277 /* | |
6278 * Check if there are any unanswered requests and deal with them. | |
6279 * This is called before starting an external program or getting direct | |
6280 * keyboard input. We don't want responses to be send to that program or | |
6281 * handled as typed text. | |
6282 */ | |
6283 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6284 check_for_codes_from_term(void) |
7 | 6285 { |
6286 int c; | |
6287 | |
6288 /* If no codes requested or all are answered, no need to wait. */ | |
6289 if (xt_index_out == 0 || xt_index_out == xt_index_in) | |
6290 return; | |
6291 | |
6292 /* Vgetc() will check for and handle any response. | |
6293 * Keep calling vpeekc() until we don't get any responses. */ | |
6294 ++no_mapping; | |
6295 ++allow_keys; | |
6296 for (;;) | |
6297 { | |
6298 c = vpeekc(); | |
6299 if (c == NUL) /* nothing available */ | |
6300 break; | |
6301 | |
6302 /* If a response is recognized it's replaced with K_IGNORE, must read | |
6303 * it from the input stream. If there is no K_IGNORE we can't do | |
6304 * anything, break here (there might be some responses further on, but | |
6305 * we don't want to throw away any typed chars). */ | |
6306 if (c != K_SPECIAL && c != K_IGNORE) | |
6307 break; | |
6308 c = vgetc(); | |
6309 if (c != K_IGNORE) | |
6310 { | |
6311 vungetc(c); | |
6312 break; | |
6313 } | |
6314 } | |
6315 --no_mapping; | |
6316 --allow_keys; | |
6317 } | |
6318 #endif | |
6319 | |
6320 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) | |
6321 /* | |
6322 * Translate an internal mapping/abbreviation representation into the | |
6323 * corresponding external one recognized by :map/:abbrev commands; | |
6324 * respects the current B/k/< settings of 'cpoption'. | |
6325 * | |
6326 * This function is called when expanding mappings/abbreviations on the | |
1902 | 6327 * command-line, and for building the "Ambiguous mapping..." error message. |
7 | 6328 * |
6329 * It uses a growarray to build the translation string since the | |
6330 * latter can be wider than the original description. The caller has to | |
6331 * free the string afterwards. | |
6332 * | |
6333 * Returns NULL when there is a problem. | |
6334 */ | |
6335 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6336 translate_mapping( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6337 char_u *str, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6338 int expmap) /* TRUE when expanding mappings on command-line */ |
7 | 6339 { |
6340 garray_T ga; | |
6341 int c; | |
6342 int modifiers; | |
6343 int cpo_bslash; | |
6344 int cpo_special; | |
6345 int cpo_keycode; | |
6346 | |
6347 ga_init(&ga); | |
6348 ga.ga_itemsize = 1; | |
6349 ga.ga_growsize = 40; | |
6350 | |
6351 cpo_bslash = (vim_strchr(p_cpo, CPO_BSLASH) != NULL); | |
6352 cpo_special = (vim_strchr(p_cpo, CPO_SPECI) != NULL); | |
6353 cpo_keycode = (vim_strchr(p_cpo, CPO_KEYCODE) == NULL); | |
6354 | |
6355 for (; *str; ++str) | |
6356 { | |
6357 c = *str; | |
6358 if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL) | |
6359 { | |
6360 modifiers = 0; | |
6361 if (str[1] == KS_MODIFIER) | |
6362 { | |
6363 str++; | |
6364 modifiers = *++str; | |
6365 c = *++str; | |
6366 } | |
6367 if (cpo_special && cpo_keycode && c == K_SPECIAL && !modifiers) | |
6368 { | |
6369 int i; | |
6370 | |
6371 /* try to find special key in termcodes */ | |
6372 for (i = 0; i < tc_len; ++i) | |
6373 if (termcodes[i].name[0] == str[1] | |
6374 && termcodes[i].name[1] == str[2]) | |
6375 break; | |
6376 if (i < tc_len) | |
6377 { | |
6378 ga_concat(&ga, termcodes[i].code); | |
6379 str += 2; | |
6380 continue; /* for (str) */ | |
6381 } | |
6382 } | |
6383 if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL) | |
6384 { | |
6385 if (expmap && cpo_special) | |
6386 { | |
6387 ga_clear(&ga); | |
6388 return NULL; | |
6389 } | |
6390 c = TO_SPECIAL(str[1], str[2]); | |
6391 if (c == K_ZERO) /* display <Nul> as ^@ */ | |
6392 c = NUL; | |
6393 str += 2; | |
6394 } | |
6395 if (IS_SPECIAL(c) || modifiers) /* special key */ | |
6396 { | |
6397 if (expmap && cpo_special) | |
6398 { | |
6399 ga_clear(&ga); | |
6400 return NULL; | |
6401 } | |
6402 ga_concat(&ga, get_special_key_name(c, modifiers)); | |
6403 continue; /* for (str) */ | |
6404 } | |
6405 } | |
6406 if (c == ' ' || c == '\t' || c == Ctrl_J || c == Ctrl_V | |
6407 || (c == '<' && !cpo_special) || (c == '\\' && !cpo_bslash)) | |
6408 ga_append(&ga, cpo_bslash ? Ctrl_V : '\\'); | |
6409 if (c) | |
6410 ga_append(&ga, c); | |
6411 } | |
6412 ga_append(&ga, NUL); | |
6413 return (char_u *)(ga.ga_data); | |
6414 } | |
6415 #endif | |
6416 | |
6417 #if (defined(WIN3264) && !defined(FEAT_GUI)) || defined(PROTO) | |
6418 static char ksme_str[20]; | |
6419 static char ksmr_str[20]; | |
6420 static char ksmd_str[20]; | |
6421 | |
6422 /* | |
6423 * For Win32 console: update termcap codes for existing console attributes. | |
6424 */ | |
6425 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6426 update_tcap(int attr) |
7 | 6427 { |
6428 struct builtin_term *p; | |
6429 | |
6430 p = find_builtin_term(DEFAULT_TERM); | |
6431 sprintf(ksme_str, IF_EB("\033|%dm", ESC_STR "|%dm"), attr); | |
6432 sprintf(ksmd_str, IF_EB("\033|%dm", ESC_STR "|%dm"), | |
6433 attr | 0x08); /* FOREGROUND_INTENSITY */ | |
6434 sprintf(ksmr_str, IF_EB("\033|%dm", ESC_STR "|%dm"), | |
6435 ((attr & 0x0F) << 4) | ((attr & 0xF0) >> 4)); | |
6436 | |
6437 while (p->bt_string != NULL) | |
6438 { | |
6439 if (p->bt_entry == (int)KS_ME) | |
6440 p->bt_string = &ksme_str[0]; | |
6441 else if (p->bt_entry == (int)KS_MR) | |
6442 p->bt_string = &ksmr_str[0]; | |
6443 else if (p->bt_entry == (int)KS_MD) | |
6444 p->bt_string = &ksmd_str[0]; | |
6445 ++p; | |
6446 } | |
6447 } | |
6448 #endif | |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6449 |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
6450 #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
|
6451 static int |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6452 hex_digit(int c) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6453 { |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6454 if (isdigit(c)) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6455 return c - '0'; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6456 c = TOLOWER_ASC(c); |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6457 if (c >= 'a' && c <= 'f') |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6458 return c - 'a' + 10; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6459 return 0x1ffffff; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6460 } |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6461 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6462 guicolor_T |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6463 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
|
6464 { |
10512
675dfe47ab69
commit https://github.com/vim/vim/commit/287266527abc163e191a06dd70518bbbdab4468f
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
6465 /* 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
|
6466 * 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
|
6467 * MS-Windows GDI builds. */ |
675dfe47ab69
commit https://github.com/vim/vim/commit/287266527abc163e191a06dd70518bbbdab4468f
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
6468 # 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
|
6469 # undef RGB |
675dfe47ab69
commit https://github.com/vim/vim/commit/287266527abc163e191a06dd70518bbbdab4468f
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
6470 # endif |
9021
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6471 # ifndef RGB |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6472 # 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
|
6473 # endif |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6474 # define LINE_LEN 100 |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6475 FILE *fd; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6476 char line[LINE_LEN]; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6477 char_u *fname; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6478 int r, g, b, i; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6479 guicolor_T color; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6480 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6481 struct rgbcolor_table_S { |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6482 char_u *color_name; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6483 guicolor_T color; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6484 }; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6485 |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6486 /* 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
|
6487 * 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
|
6488 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
|
6489 {(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
|
6490 {(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
|
6491 {(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
|
6492 {(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
|
6493 {(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
|
6494 {(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
|
6495 {(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
|
6496 {(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
|
6497 {(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
|
6498 {(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
|
6499 {(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
|
6500 {(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
|
6501 {(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
|
6502 {(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
|
6503 {(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
|
6504 {(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
|
6505 {(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
|
6506 {(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
|
6507 {(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
|
6508 {(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
|
6509 {(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
|
6510 {(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
|
6511 {(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
|
6512 {(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
|
6513 {(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
|
6514 {(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
|
6515 {(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
|
6516 {(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
|
6517 {(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
|
6518 {(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
|
6519 }; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6520 |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6521 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
|
6522 static int size = 0; |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6523 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6524 if (name[0] == '#' && STRLEN(name) == 7) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6525 { |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6526 /* Name is in "#rrggbb" format */ |
9021
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6527 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
|
6528 ((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
|
6529 ((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
|
6530 if (color > 0xffffff) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6531 return INVALCOLOR; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6532 return color; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6533 } |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6534 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6535 /* 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
|
6536 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
|
6537 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
|
6538 return rgb_table[i].color; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6539 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6540 /* |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6541 * 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
|
6542 */ |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6543 if (size == 0) |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6544 { |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6545 int counting; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6546 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6547 /* colornames_table not yet initialized */ |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6548 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
|
6549 if (fname == NULL) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6550 return INVALCOLOR; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6551 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6552 fd = fopen((char *)fname, "rt"); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6553 vim_free(fname); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6554 if (fd == NULL) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6555 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6556 if (p_verbose > 1) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6557 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
|
6558 return INVALCOLOR; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6559 } |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6560 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6561 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
|
6562 { |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6563 if (!counting) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6564 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6565 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
|
6566 (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
|
6567 if (colornames_table == NULL) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6568 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6569 fclose(fd); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6570 return INVALCOLOR; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6571 } |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6572 rewind(fd); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6573 } |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6574 size = 0; |
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 while (!feof(fd)) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6577 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6578 size_t len; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6579 int pos; |
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 ignoredp = fgets(line, LINE_LEN, fd); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6582 len = strlen(line); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6583 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6584 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
|
6585 continue; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6586 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6587 line[len - 1] = '\0'; |
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 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
|
6590 if (i != 3) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6591 continue; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6592 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6593 if (!counting) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6594 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6595 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
|
6596 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6597 if (s == NULL) |
9628
fefd0551aa9d
commit https://github.com/vim/vim/commit/2e45d21c819272051f7ef4436f483e4b2ecfb369
Christian Brabandt <cb@256bit.org>
parents:
9601
diff
changeset
|
6598 { |
fefd0551aa9d
commit https://github.com/vim/vim/commit/2e45d21c819272051f7ef4436f483e4b2ecfb369
Christian Brabandt <cb@256bit.org>
parents:
9601
diff
changeset
|
6599 fclose(fd); |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6600 return INVALCOLOR; |
9628
fefd0551aa9d
commit https://github.com/vim/vim/commit/2e45d21c819272051f7ef4436f483e4b2ecfb369
Christian Brabandt <cb@256bit.org>
parents:
9601
diff
changeset
|
6601 } |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6602 colornames_table[size].color_name = s; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6603 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
|
6604 } |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6605 size++; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6606 } |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6607 } |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6608 fclose(fd); |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6609 } |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6610 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6611 for (i = 0; i < size; i++) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6612 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
|
6613 return colornames_table[i].color; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6614 |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6615 return INVALCOLOR; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6616 } |
11745
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11739
diff
changeset
|
6617 |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11739
diff
changeset
|
6618 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
|
6619 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
|
6620 { |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11739
diff
changeset
|
6621 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
|
6622 |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11739
diff
changeset
|
6623 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
|
6624 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
|
6625 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
|
6626 } |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6627 #endif |