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