Mercurial > vim
annotate src/term.c @ 13398:aef75fbfc07d v8.0.1573
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
commit https://github.com/vim/vim/commit/89894aa671ed1db03d95d38cab300702c242239d
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Mar 5 22:43:10 2018 +0100
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Problem: getwinpos(1) may cause response to be handled as command.
Solution: Handle any cursor position report once one was request. (partly by
Hirohito Higashi)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 05 Mar 2018 22:45:06 +0100 |
parents | 6740c499de13 |
children | 4e30f3f4cb78 |
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 gather_termleader(void); |
7 | 80 #ifdef FEAT_TERMRESPONSE |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
81 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
|
82 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
|
83 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
|
84 static void check_for_codes_from_term(void); |
7 | 85 #endif |
86 #if defined(FEAT_GUI) \ | |
1623 | 87 || (defined(FEAT_MOUSE) && (!defined(UNIX) || defined(FEAT_MOUSE_XTERM) \ |
88 || 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
|
89 static int get_bytes_from_buf(char_u *, char_u *, int); |
7 | 90 #endif |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
91 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
|
92 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
|
93 static int term_7to8bit(char_u *p); |
7 | 94 #ifdef FEAT_TERMRESPONSE |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
95 static void switch_to_8bit(void); |
7 | 96 #endif |
97 | |
98 #ifdef HAVE_TGETENT | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
99 static char_u *tgetent_error(char_u *, char_u *); |
7 | 100 |
101 /* | |
102 * Here is our own prototype for tgetstr(), any prototypes from the include | |
103 * files have been disabled by the define at the start of this file. | |
104 */ | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
105 char *tgetstr(char *, char **); |
7 | 106 |
107 # ifdef FEAT_TERMRESPONSE | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
108 /* 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
|
109 # if 0 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
110 # define DEBUG_TERMRESPONSE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
111 static void log_tr(char *msg); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
112 # define LOG_TR(msg) log_tr(msg) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
113 # else |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
114 # define LOG_TR(msg) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
115 # 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
|
116 |
1345621ecdfb
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 # 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
|
118 # 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
|
119 # 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
|
120 |
7 | 121 /* 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
|
122 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
|
123 |
4215 | 124 /* 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
|
125 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
|
126 |
12634
94566ecb55f0
patch 8.0.1195: can't build on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12632
diff
changeset
|
127 # ifdef FEAT_TERMINAL |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
128 /* Request foreground color report: */ |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
129 static int rfg_status = STATUS_GET; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
130 static int fg_r = 0; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
131 static int fg_g = 0; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
132 static int fg_b = 0; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
133 static int bg_r = 255; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
134 static int bg_g = 255; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
135 static int bg_b = 255; |
12634
94566ecb55f0
patch 8.0.1195: can't build on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12632
diff
changeset
|
136 # endif |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
137 |
6874 | 138 /* 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
|
139 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
|
140 |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
141 /* 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
|
142 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
|
143 |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
144 /* 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
|
145 static int rcs_status = STATUS_GET; |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
146 |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
147 /* Request windos position report: */ |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
148 static int winpos_status = STATUS_GET; |
7 | 149 # endif |
150 | |
151 /* | |
152 * Don't declare these variables if termcap.h contains them. | |
153 * Autoconf checks if these variables should be declared extern (not all | |
154 * systems have them). | |
155 * Some versions define ospeed to be speed_t, but that is incompatible with | |
156 * BSD, where ospeed is short and speed_t is long. | |
157 */ | |
158 # ifndef HAVE_OSPEED | |
159 # ifdef OSPEED_EXTERN | |
160 extern short ospeed; | |
161 # else | |
162 short ospeed; | |
163 # endif | |
164 # endif | |
165 # ifndef HAVE_UP_BC_PC | |
166 # ifdef UP_BC_PC_EXTERN | |
167 extern char *UP, *BC, PC; | |
168 # else | |
169 char *UP, *BC, PC; | |
170 # endif | |
171 # endif | |
172 | |
173 # define TGETSTR(s, p) vim_tgetstr((s), (p)) | |
174 # 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
|
175 static char_u *vim_tgetstr(char *s, char_u **pp); |
7 | 176 #endif /* HAVE_TGETENT */ |
177 | |
178 static int detected_8bit = FALSE; /* detected 8-bit terminal */ | |
179 | |
12184
76fbd85c3cea
patch 8.0.0972: compiler warnings for unused variables
Christian Brabandt <cb@256bit.org>
parents:
12174
diff
changeset
|
180 #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
|
181 /* 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
|
182 * 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
|
183 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
|
184 |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
185 /* 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
|
186 * 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
|
187 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
|
188 |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
189 /* 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
|
190 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
|
191 #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
|
192 |
298 | 193 static struct builtin_term builtin_termcaps[] = |
7 | 194 { |
195 | |
196 #if defined(FEAT_GUI) | |
197 /* | |
198 * GUI pseudo term-cap. | |
199 */ | |
200 {(int)KS_NAME, "gui"}, | |
201 {(int)KS_CE, IF_EB("\033|$", ESC_STR "|$")}, | |
202 {(int)KS_AL, IF_EB("\033|i", ESC_STR "|i")}, | |
203 # ifdef TERMINFO | |
204 {(int)KS_CAL, IF_EB("\033|%p1%dI", ESC_STR "|%p1%dI")}, | |
205 # else | |
206 {(int)KS_CAL, IF_EB("\033|%dI", ESC_STR "|%dI")}, | |
207 # endif | |
208 {(int)KS_DL, IF_EB("\033|d", ESC_STR "|d")}, | |
209 # ifdef TERMINFO | |
210 {(int)KS_CDL, IF_EB("\033|%p1%dD", ESC_STR "|%p1%dD")}, | |
211 {(int)KS_CS, IF_EB("\033|%p1%d;%p2%dR", ESC_STR "|%p1%d;%p2%dR")}, | |
212 {(int)KS_CSV, IF_EB("\033|%p1%d;%p2%dV", ESC_STR "|%p1%d;%p2%dV")}, | |
213 # else | |
214 {(int)KS_CDL, IF_EB("\033|%dD", ESC_STR "|%dD")}, | |
215 {(int)KS_CS, IF_EB("\033|%d;%dR", ESC_STR "|%d;%dR")}, | |
216 {(int)KS_CSV, IF_EB("\033|%d;%dV", ESC_STR "|%d;%dV")}, | |
217 # endif | |
218 {(int)KS_CL, IF_EB("\033|C", ESC_STR "|C")}, | |
219 /* attributes switched on with 'h', off with * 'H' */ | |
220 {(int)KS_ME, IF_EB("\033|31H", ESC_STR "|31H")}, /* HL_ALL */ | |
221 {(int)KS_MR, IF_EB("\033|1h", ESC_STR "|1h")}, /* HL_INVERSE */ | |
222 {(int)KS_MD, IF_EB("\033|2h", ESC_STR "|2h")}, /* HL_BOLD */ | |
223 {(int)KS_SE, IF_EB("\033|16H", ESC_STR "|16H")}, /* HL_STANDOUT */ | |
224 {(int)KS_SO, IF_EB("\033|16h", ESC_STR "|16h")}, /* HL_STANDOUT */ | |
225 {(int)KS_UE, IF_EB("\033|8H", ESC_STR "|8H")}, /* HL_UNDERLINE */ | |
226 {(int)KS_US, IF_EB("\033|8h", ESC_STR "|8h")}, /* HL_UNDERLINE */ | |
205 | 227 {(int)KS_UCE, IF_EB("\033|8C", ESC_STR "|8C")}, /* HL_UNDERCURL */ |
228 {(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
|
229 {(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
|
230 {(int)KS_STS, IF_EB("\033|4c", ESC_STR "|4c")}, /* HL_STRIKETHROUGH */ |
7 | 231 {(int)KS_CZR, IF_EB("\033|4H", ESC_STR "|4H")}, /* HL_ITALIC */ |
232 {(int)KS_CZH, IF_EB("\033|4h", ESC_STR "|4h")}, /* HL_ITALIC */ | |
233 {(int)KS_VB, IF_EB("\033|f", ESC_STR "|f")}, | |
234 {(int)KS_MS, "y"}, | |
235 {(int)KS_UT, "y"}, | |
6602 | 236 {(int)KS_XN, "y"}, |
7 | 237 {(int)KS_LE, "\b"}, /* cursor-left = BS */ |
238 {(int)KS_ND, "\014"}, /* cursor-right = CTRL-L */ | |
239 # ifdef TERMINFO | |
240 {(int)KS_CM, IF_EB("\033|%p1%d;%p2%dM", ESC_STR "|%p1%d;%p2%dM")}, | |
241 # else | |
242 {(int)KS_CM, IF_EB("\033|%d;%dM", ESC_STR "|%d;%dM")}, | |
243 # endif | |
244 /* there are no key sequences here, the GUI sequences are recognized | |
205 | 245 * in check_termcode() */ |
7 | 246 #endif |
247 | |
248 #ifndef NO_BUILTIN_TCAPS | |
249 | |
250 # if defined(AMIGA) || defined(ALL_BUILTIN_TCAPS) | |
251 /* | |
252 * Amiga console window, default for Amiga | |
253 */ | |
254 {(int)KS_NAME, "amiga"}, | |
255 {(int)KS_CE, "\033[K"}, | |
256 {(int)KS_CD, "\033[J"}, | |
257 {(int)KS_AL, "\033[L"}, | |
258 # ifdef TERMINFO | |
259 {(int)KS_CAL, "\033[%p1%dL"}, | |
260 # else | |
261 {(int)KS_CAL, "\033[%dL"}, | |
262 # endif | |
263 {(int)KS_DL, "\033[M"}, | |
264 # ifdef TERMINFO | |
265 {(int)KS_CDL, "\033[%p1%dM"}, | |
266 # else | |
267 {(int)KS_CDL, "\033[%dM"}, | |
268 # endif | |
269 {(int)KS_CL, "\014"}, | |
270 {(int)KS_VI, "\033[0 p"}, | |
271 {(int)KS_VE, "\033[1 p"}, | |
272 {(int)KS_ME, "\033[0m"}, | |
273 {(int)KS_MR, "\033[7m"}, | |
274 {(int)KS_MD, "\033[1m"}, | |
275 {(int)KS_SE, "\033[0m"}, | |
276 {(int)KS_SO, "\033[33m"}, | |
277 {(int)KS_US, "\033[4m"}, | |
278 {(int)KS_UE, "\033[0m"}, | |
279 {(int)KS_CZH, "\033[3m"}, | |
280 {(int)KS_CZR, "\033[0m"}, | |
281 #if defined(__MORPHOS__) || defined(__AROS__) | |
282 {(int)KS_CCO, "8"}, /* allow 8 colors */ | |
283 # ifdef TERMINFO | |
284 {(int)KS_CAB, "\033[4%p1%dm"},/* set background color */ | |
285 {(int)KS_CAF, "\033[3%p1%dm"},/* set foreground color */ | |
286 # else | |
287 {(int)KS_CAB, "\033[4%dm"}, /* set background color */ | |
288 {(int)KS_CAF, "\033[3%dm"}, /* set foreground color */ | |
289 # endif | |
290 {(int)KS_OP, "\033[m"}, /* reset colors */ | |
291 #endif | |
292 {(int)KS_MS, "y"}, | |
293 {(int)KS_UT, "y"}, /* guessed */ | |
294 {(int)KS_LE, "\b"}, | |
295 # ifdef TERMINFO | |
296 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
297 # else | |
298 {(int)KS_CM, "\033[%i%d;%dH"}, | |
299 # endif | |
300 #if defined(__MORPHOS__) | |
301 {(int)KS_SR, "\033M"}, | |
302 #endif | |
303 # ifdef TERMINFO | |
304 {(int)KS_CRI, "\033[%p1%dC"}, | |
305 # else | |
306 {(int)KS_CRI, "\033[%dC"}, | |
307 # endif | |
308 {K_UP, "\233A"}, | |
309 {K_DOWN, "\233B"}, | |
310 {K_LEFT, "\233D"}, | |
311 {K_RIGHT, "\233C"}, | |
312 {K_S_UP, "\233T"}, | |
313 {K_S_DOWN, "\233S"}, | |
314 {K_S_LEFT, "\233 A"}, | |
315 {K_S_RIGHT, "\233 @"}, | |
316 {K_S_TAB, "\233Z"}, | |
317 {K_F1, "\233\060~"},/* some compilers don't dig "\2330" */ | |
318 {K_F2, "\233\061~"}, | |
319 {K_F3, "\233\062~"}, | |
320 {K_F4, "\233\063~"}, | |
321 {K_F5, "\233\064~"}, | |
322 {K_F6, "\233\065~"}, | |
323 {K_F7, "\233\066~"}, | |
324 {K_F8, "\233\067~"}, | |
325 {K_F9, "\233\070~"}, | |
326 {K_F10, "\233\071~"}, | |
327 {K_S_F1, "\233\061\060~"}, | |
328 {K_S_F2, "\233\061\061~"}, | |
329 {K_S_F3, "\233\061\062~"}, | |
330 {K_S_F4, "\233\061\063~"}, | |
331 {K_S_F5, "\233\061\064~"}, | |
332 {K_S_F6, "\233\061\065~"}, | |
333 {K_S_F7, "\233\061\066~"}, | |
334 {K_S_F8, "\233\061\067~"}, | |
335 {K_S_F9, "\233\061\070~"}, | |
336 {K_S_F10, "\233\061\071~"}, | |
337 {K_HELP, "\233?~"}, | |
338 {K_INS, "\233\064\060~"}, /* 101 key keyboard */ | |
339 {K_PAGEUP, "\233\064\061~"}, /* 101 key keyboard */ | |
340 {K_PAGEDOWN, "\233\064\062~"}, /* 101 key keyboard */ | |
341 {K_HOME, "\233\064\064~"}, /* 101 key keyboard */ | |
342 {K_END, "\233\064\065~"}, /* 101 key keyboard */ | |
343 | |
344 {BT_EXTRA_KEYS, ""}, | |
345 {TERMCAP2KEY('#', '2'), "\233\065\064~"}, /* shifted home key */ | |
346 {TERMCAP2KEY('#', '3'), "\233\065\060~"}, /* shifted insert key */ | |
347 {TERMCAP2KEY('*', '7'), "\233\065\065~"}, /* shifted end key */ | |
348 # endif | |
349 | |
350 # if defined(__BEOS__) || defined(ALL_BUILTIN_TCAPS) | |
351 /* | |
352 * almost standard ANSI terminal, default for bebox | |
353 */ | |
354 {(int)KS_NAME, "beos-ansi"}, | |
355 {(int)KS_CE, "\033[K"}, | |
356 {(int)KS_CD, "\033[J"}, | |
357 {(int)KS_AL, "\033[L"}, | |
358 # ifdef TERMINFO | |
359 {(int)KS_CAL, "\033[%p1%dL"}, | |
360 # else | |
361 {(int)KS_CAL, "\033[%dL"}, | |
362 # endif | |
363 {(int)KS_DL, "\033[M"}, | |
364 # ifdef TERMINFO | |
365 {(int)KS_CDL, "\033[%p1%dM"}, | |
366 # else | |
367 {(int)KS_CDL, "\033[%dM"}, | |
368 # endif | |
369 #ifdef BEOS_PR_OR_BETTER | |
370 # ifdef TERMINFO | |
371 {(int)KS_CS, "\033[%i%p1%d;%p2%dr"}, | |
372 # else | |
373 {(int)KS_CS, "\033[%i%d;%dr"}, /* scroll region */ | |
374 # endif | |
375 #endif | |
376 {(int)KS_CL, "\033[H\033[2J"}, | |
377 #ifdef notyet | |
378 {(int)KS_VI, "[VI]"}, /* cursor invisible, VT320: CSI ? 25 l */ | |
379 {(int)KS_VE, "[VE]"}, /* cursor visible, VT320: CSI ? 25 h */ | |
380 #endif | |
381 {(int)KS_ME, "\033[m"}, /* normal mode */ | |
382 {(int)KS_MR, "\033[7m"}, /* reverse */ | |
383 {(int)KS_MD, "\033[1m"}, /* bold */ | |
384 {(int)KS_SO, "\033[31m"}, /* standout mode: red */ | |
385 {(int)KS_SE, "\033[m"}, /* standout end */ | |
386 {(int)KS_CZH, "\033[35m"}, /* italic: purple */ | |
387 {(int)KS_CZR, "\033[m"}, /* italic end */ | |
388 {(int)KS_US, "\033[4m"}, /* underscore mode */ | |
389 {(int)KS_UE, "\033[m"}, /* underscore end */ | |
390 {(int)KS_CCO, "8"}, /* allow 8 colors */ | |
391 # ifdef TERMINFO | |
392 {(int)KS_CAB, "\033[4%p1%dm"},/* set background color */ | |
393 {(int)KS_CAF, "\033[3%p1%dm"},/* set foreground color */ | |
394 # else | |
395 {(int)KS_CAB, "\033[4%dm"}, /* set background color */ | |
396 {(int)KS_CAF, "\033[3%dm"}, /* set foreground color */ | |
397 # endif | |
398 {(int)KS_OP, "\033[m"}, /* reset colors */ | |
399 {(int)KS_MS, "y"}, /* safe to move cur in reverse mode */ | |
400 {(int)KS_UT, "y"}, /* guessed */ | |
401 {(int)KS_LE, "\b"}, | |
402 # ifdef TERMINFO | |
403 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
404 # else | |
405 {(int)KS_CM, "\033[%i%d;%dH"}, | |
406 # endif | |
407 {(int)KS_SR, "\033M"}, | |
408 # ifdef TERMINFO | |
409 {(int)KS_CRI, "\033[%p1%dC"}, | |
410 # else | |
411 {(int)KS_CRI, "\033[%dC"}, | |
412 # endif | |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
413 # if defined(BEOS_DR8) |
7 | 414 {(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
|
415 # endif |
7 | 416 |
417 {K_UP, "\033[A"}, | |
418 {K_DOWN, "\033[B"}, | |
419 {K_LEFT, "\033[D"}, | |
420 {K_RIGHT, "\033[C"}, | |
421 # endif | |
422 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
423 # if defined(UNIX) || defined(ALL_BUILTIN_TCAPS) || defined(SOME_BUILTIN_TCAPS) |
7 | 424 /* |
425 * standard ANSI terminal, default for unix | |
426 */ | |
427 {(int)KS_NAME, "ansi"}, | |
428 {(int)KS_CE, IF_EB("\033[K", ESC_STR "[K")}, | |
429 {(int)KS_AL, IF_EB("\033[L", ESC_STR "[L")}, | |
430 # ifdef TERMINFO | |
431 {(int)KS_CAL, IF_EB("\033[%p1%dL", ESC_STR "[%p1%dL")}, | |
432 # else | |
433 {(int)KS_CAL, IF_EB("\033[%dL", ESC_STR "[%dL")}, | |
434 # endif | |
435 {(int)KS_DL, IF_EB("\033[M", ESC_STR "[M")}, | |
436 # ifdef TERMINFO | |
437 {(int)KS_CDL, IF_EB("\033[%p1%dM", ESC_STR "[%p1%dM")}, | |
438 # else | |
439 {(int)KS_CDL, IF_EB("\033[%dM", ESC_STR "[%dM")}, | |
440 # endif | |
441 {(int)KS_CL, IF_EB("\033[H\033[2J", ESC_STR "[H" ESC_STR_nc "[2J")}, | |
442 {(int)KS_ME, IF_EB("\033[0m", ESC_STR "[0m")}, | |
443 {(int)KS_MR, IF_EB("\033[7m", ESC_STR "[7m")}, | |
444 {(int)KS_MS, "y"}, | |
445 {(int)KS_UT, "y"}, /* guessed */ | |
446 {(int)KS_LE, "\b"}, | |
447 # ifdef TERMINFO | |
448 {(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", ESC_STR "[%i%p1%d;%p2%dH")}, | |
449 # else | |
450 {(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")}, | |
451 # endif | |
452 # ifdef TERMINFO | |
453 {(int)KS_CRI, IF_EB("\033[%p1%dC", ESC_STR "[%p1%dC")}, | |
454 # else | |
455 {(int)KS_CRI, IF_EB("\033[%dC", ESC_STR "[%dC")}, | |
456 # endif | |
457 # endif | |
458 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
459 # if defined(ALL_BUILTIN_TCAPS) |
7 | 460 /* |
461 * These codes are valid when nansi.sys or equivalent has been installed. | |
462 * Function keys on a PC are preceded with a NUL. These are converted into | |
463 * K_NUL '\316' in mch_inchar(), because we cannot handle NULs in key codes. | |
464 * CTRL-arrow is used instead of SHIFT-arrow. | |
465 */ | |
466 {(int)KS_NAME, "pcansi"}, | |
467 {(int)KS_DL, "\033[M"}, | |
468 {(int)KS_AL, "\033[L"}, | |
469 {(int)KS_CE, "\033[K"}, | |
470 {(int)KS_CL, "\033[2J"}, | |
471 {(int)KS_ME, "\033[0m"}, | |
472 {(int)KS_MR, "\033[5m"}, /* reverse: black on lightgrey */ | |
473 {(int)KS_MD, "\033[1m"}, /* bold: white text */ | |
474 {(int)KS_SE, "\033[0m"}, /* standout end */ | |
475 {(int)KS_SO, "\033[31m"}, /* standout: white on blue */ | |
476 {(int)KS_CZH, "\033[34;43m"}, /* italic mode: blue text on yellow */ | |
477 {(int)KS_CZR, "\033[0m"}, /* italic mode end */ | |
478 {(int)KS_US, "\033[36;41m"}, /* underscore mode: cyan text on red */ | |
479 {(int)KS_UE, "\033[0m"}, /* underscore mode end */ | |
480 {(int)KS_CCO, "8"}, /* allow 8 colors */ | |
481 # ifdef TERMINFO | |
482 {(int)KS_CAB, "\033[4%p1%dm"},/* set background color */ | |
483 {(int)KS_CAF, "\033[3%p1%dm"},/* set foreground color */ | |
484 # else | |
485 {(int)KS_CAB, "\033[4%dm"}, /* set background color */ | |
486 {(int)KS_CAF, "\033[3%dm"}, /* set foreground color */ | |
487 # endif | |
488 {(int)KS_OP, "\033[0m"}, /* reset colors */ | |
489 {(int)KS_MS, "y"}, | |
490 {(int)KS_UT, "y"}, /* guessed */ | |
491 {(int)KS_LE, "\b"}, | |
492 # ifdef TERMINFO | |
493 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
494 # else | |
495 {(int)KS_CM, "\033[%i%d;%dH"}, | |
496 # endif | |
497 # ifdef TERMINFO | |
498 {(int)KS_CRI, "\033[%p1%dC"}, | |
499 # else | |
500 {(int)KS_CRI, "\033[%dC"}, | |
501 # endif | |
502 {K_UP, "\316H"}, | |
503 {K_DOWN, "\316P"}, | |
504 {K_LEFT, "\316K"}, | |
505 {K_RIGHT, "\316M"}, | |
506 {K_S_LEFT, "\316s"}, | |
507 {K_S_RIGHT, "\316t"}, | |
508 {K_F1, "\316;"}, | |
509 {K_F2, "\316<"}, | |
510 {K_F3, "\316="}, | |
511 {K_F4, "\316>"}, | |
512 {K_F5, "\316?"}, | |
513 {K_F6, "\316@"}, | |
514 {K_F7, "\316A"}, | |
515 {K_F8, "\316B"}, | |
516 {K_F9, "\316C"}, | |
517 {K_F10, "\316D"}, | |
518 {K_F11, "\316\205"}, /* guessed */ | |
519 {K_F12, "\316\206"}, /* guessed */ | |
520 {K_S_F1, "\316T"}, | |
521 {K_S_F2, "\316U"}, | |
522 {K_S_F3, "\316V"}, | |
523 {K_S_F4, "\316W"}, | |
524 {K_S_F5, "\316X"}, | |
525 {K_S_F6, "\316Y"}, | |
526 {K_S_F7, "\316Z"}, | |
527 {K_S_F8, "\316["}, | |
528 {K_S_F9, "\316\\"}, | |
529 {K_S_F10, "\316]"}, | |
530 {K_S_F11, "\316\207"}, /* guessed */ | |
531 {K_S_F12, "\316\210"}, /* guessed */ | |
532 {K_INS, "\316R"}, | |
533 {K_DEL, "\316S"}, | |
534 {K_HOME, "\316G"}, | |
535 {K_END, "\316O"}, | |
536 {K_PAGEDOWN, "\316Q"}, | |
537 {K_PAGEUP, "\316I"}, | |
538 # endif | |
539 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
540 # if defined(WIN3264) || defined(ALL_BUILTIN_TCAPS) |
7 | 541 /* |
542 * These codes are valid for the Win32 Console . The entries that start with | |
543 * ESC | are translated into console calls in os_win32.c. The function keys | |
544 * are also translated in os_win32.c. | |
545 */ | |
546 {(int)KS_NAME, "win32"}, | |
547 {(int)KS_CE, "\033|K"}, /* clear to end of line */ | |
548 {(int)KS_AL, "\033|L"}, /* add new blank line */ | |
549 # ifdef TERMINFO | |
550 {(int)KS_CAL, "\033|%p1%dL"}, /* add number of new blank lines */ | |
551 # else | |
552 {(int)KS_CAL, "\033|%dL"}, /* add number of new blank lines */ | |
553 # endif | |
554 {(int)KS_DL, "\033|M"}, /* delete line */ | |
555 # ifdef TERMINFO | |
556 {(int)KS_CDL, "\033|%p1%dM"}, /* delete number of lines */ | |
557 # else | |
558 {(int)KS_CDL, "\033|%dM"}, /* delete number of lines */ | |
559 # endif | |
560 {(int)KS_CL, "\033|J"}, /* clear screen */ | |
561 {(int)KS_CD, "\033|j"}, /* clear to end of display */ | |
562 {(int)KS_VI, "\033|v"}, /* cursor invisible */ | |
563 {(int)KS_VE, "\033|V"}, /* cursor visible */ | |
564 | |
565 {(int)KS_ME, "\033|0m"}, /* normal */ | |
566 {(int)KS_MR, "\033|112m"}, /* reverse: black on lightgray */ | |
567 {(int)KS_MD, "\033|15m"}, /* bold: white on black */ | |
568 #if 1 | |
569 {(int)KS_SO, "\033|31m"}, /* standout: white on blue */ | |
570 {(int)KS_SE, "\033|0m"}, /* standout end */ | |
571 #else | |
572 {(int)KS_SO, "\033|F"}, /* standout: high intensity */ | |
573 {(int)KS_SE, "\033|f"}, /* standout end */ | |
574 #endif | |
575 {(int)KS_CZH, "\033|225m"}, /* italic: blue text on yellow */ | |
576 {(int)KS_CZR, "\033|0m"}, /* italic end */ | |
577 {(int)KS_US, "\033|67m"}, /* underscore: cyan text on red */ | |
578 {(int)KS_UE, "\033|0m"}, /* underscore end */ | |
579 {(int)KS_CCO, "16"}, /* allow 16 colors */ | |
580 # ifdef TERMINFO | |
581 {(int)KS_CAB, "\033|%p1%db"}, /* set background color */ | |
582 {(int)KS_CAF, "\033|%p1%df"}, /* set foreground color */ | |
583 # else | |
584 {(int)KS_CAB, "\033|%db"}, /* set background color */ | |
585 {(int)KS_CAF, "\033|%df"}, /* set foreground color */ | |
586 # endif | |
587 | |
588 {(int)KS_MS, "y"}, /* save to move cur in reverse mode */ | |
589 {(int)KS_UT, "y"}, | |
6602 | 590 {(int)KS_XN, "y"}, |
7 | 591 {(int)KS_LE, "\b"}, |
592 # ifdef TERMINFO | |
593 {(int)KS_CM, "\033|%i%p1%d;%p2%dH"},/* cursor motion */ | |
594 # else | |
595 {(int)KS_CM, "\033|%i%d;%dH"},/* cursor motion */ | |
596 # endif | |
597 {(int)KS_VB, "\033|B"}, /* visual bell */ | |
598 {(int)KS_TI, "\033|S"}, /* put terminal in termcap mode */ | |
599 {(int)KS_TE, "\033|E"}, /* out of termcap mode */ | |
600 # ifdef TERMINFO | |
601 {(int)KS_CS, "\033|%i%p1%d;%p2%dr"},/* scroll region */ | |
602 # else | |
603 {(int)KS_CS, "\033|%i%d;%dr"},/* scroll region */ | |
604 # endif | |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
605 # ifdef FEAT_TERMGUICOLORS |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
606 {(int)KS_8F, "\033|38;2;%lu;%lu;%lum"}, |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
607 {(int)KS_8B, "\033|48;2;%lu;%lu;%lum"}, |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
608 # endif |
7 | 609 |
610 {K_UP, "\316H"}, | |
611 {K_DOWN, "\316P"}, | |
612 {K_LEFT, "\316K"}, | |
613 {K_RIGHT, "\316M"}, | |
614 {K_S_UP, "\316\304"}, | |
615 {K_S_DOWN, "\316\317"}, | |
616 {K_S_LEFT, "\316\311"}, | |
617 {K_C_LEFT, "\316s"}, | |
618 {K_S_RIGHT, "\316\313"}, | |
619 {K_C_RIGHT, "\316t"}, | |
620 {K_S_TAB, "\316\017"}, | |
621 {K_F1, "\316;"}, | |
622 {K_F2, "\316<"}, | |
623 {K_F3, "\316="}, | |
624 {K_F4, "\316>"}, | |
625 {K_F5, "\316?"}, | |
626 {K_F6, "\316@"}, | |
627 {K_F7, "\316A"}, | |
628 {K_F8, "\316B"}, | |
629 {K_F9, "\316C"}, | |
630 {K_F10, "\316D"}, | |
631 {K_F11, "\316\205"}, | |
632 {K_F12, "\316\206"}, | |
633 {K_S_F1, "\316T"}, | |
634 {K_S_F2, "\316U"}, | |
635 {K_S_F3, "\316V"}, | |
636 {K_S_F4, "\316W"}, | |
637 {K_S_F5, "\316X"}, | |
638 {K_S_F6, "\316Y"}, | |
639 {K_S_F7, "\316Z"}, | |
640 {K_S_F8, "\316["}, | |
641 {K_S_F9, "\316\\"}, | |
642 {K_S_F10, "\316]"}, | |
643 {K_S_F11, "\316\207"}, | |
644 {K_S_F12, "\316\210"}, | |
645 {K_INS, "\316R"}, | |
646 {K_DEL, "\316S"}, | |
647 {K_HOME, "\316G"}, | |
648 {K_S_HOME, "\316\302"}, | |
649 {K_C_HOME, "\316w"}, | |
650 {K_END, "\316O"}, | |
651 {K_S_END, "\316\315"}, | |
652 {K_C_END, "\316u"}, | |
653 {K_PAGEDOWN, "\316Q"}, | |
654 {K_PAGEUP, "\316I"}, | |
655 {K_KPLUS, "\316N"}, | |
656 {K_KMINUS, "\316J"}, | |
657 {K_KMULTIPLY, "\316\067"}, | |
658 {K_K0, "\316\332"}, | |
659 {K_K1, "\316\336"}, | |
660 {K_K2, "\316\342"}, | |
661 {K_K3, "\316\346"}, | |
662 {K_K4, "\316\352"}, | |
663 {K_K5, "\316\356"}, | |
664 {K_K6, "\316\362"}, | |
665 {K_K7, "\316\366"}, | |
666 {K_K8, "\316\372"}, | |
667 {K_K9, "\316\376"}, | |
668 # endif | |
669 | |
670 # if defined(VMS) || defined(ALL_BUILTIN_TCAPS) | |
671 /* | |
672 * VT320 is working as an ANSI terminal compatible DEC terminal. | |
673 * (it covers VT1x0, VT2x0 and VT3x0 up to VT320 on VMS as well) | |
674 * Note: K_F1...K_F5 are for internal use, should not be defined. | |
675 * TODO:- rewrite ESC[ codes to CSI | |
676 * - keyboard languages (CSI ? 26 n) | |
677 */ | |
678 {(int)KS_NAME, "vt320"}, | |
679 {(int)KS_CE, IF_EB("\033[K", ESC_STR "[K")}, | |
680 {(int)KS_AL, IF_EB("\033[L", ESC_STR "[L")}, | |
681 # ifdef TERMINFO | |
682 {(int)KS_CAL, IF_EB("\033[%p1%dL", ESC_STR "[%p1%dL")}, | |
683 # else | |
684 {(int)KS_CAL, IF_EB("\033[%dL", ESC_STR "[%dL")}, | |
685 # endif | |
686 {(int)KS_DL, IF_EB("\033[M", ESC_STR "[M")}, | |
687 # ifdef TERMINFO | |
688 {(int)KS_CDL, IF_EB("\033[%p1%dM", ESC_STR "[%p1%dM")}, | |
689 # else | |
690 {(int)KS_CDL, IF_EB("\033[%dM", ESC_STR "[%dM")}, | |
691 # endif | |
692 {(int)KS_CL, IF_EB("\033[H\033[2J", ESC_STR "[H" ESC_STR_nc "[2J")}, | |
22 | 693 {(int)KS_CD, IF_EB("\033[J", ESC_STR "[J")}, |
694 {(int)KS_CCO, "8"}, /* allow 8 colors */ | |
7 | 695 {(int)KS_ME, IF_EB("\033[0m", ESC_STR "[0m")}, |
696 {(int)KS_MR, IF_EB("\033[7m", ESC_STR "[7m")}, | |
344 | 697 {(int)KS_MD, IF_EB("\033[1m", ESC_STR "[1m")}, /* bold mode */ |
698 {(int)KS_SE, IF_EB("\033[22m", ESC_STR "[22m")},/* normal mode */ | |
699 {(int)KS_UE, IF_EB("\033[24m", ESC_STR "[24m")},/* exit underscore mode */ | |
700 {(int)KS_US, IF_EB("\033[4m", ESC_STR "[4m")}, /* underscore mode */ | |
701 {(int)KS_CZH, IF_EB("\033[34;43m", ESC_STR "[34;43m")}, /* italic mode: blue text on yellow */ | |
702 {(int)KS_CZR, IF_EB("\033[0m", ESC_STR "[0m")}, /* italic mode end */ | |
703 {(int)KS_CAB, IF_EB("\033[4%dm", ESC_STR "[4%dm")}, /* set background color (ANSI) */ | |
704 {(int)KS_CAF, IF_EB("\033[3%dm", ESC_STR "[3%dm")}, /* set foreground color (ANSI) */ | |
705 {(int)KS_CSB, IF_EB("\033[102;%dm", ESC_STR "[102;%dm")}, /* set screen background color */ | |
706 {(int)KS_CSF, IF_EB("\033[101;%dm", ESC_STR "[101;%dm")}, /* set screen foreground color */ | |
7 | 707 {(int)KS_MS, "y"}, |
708 {(int)KS_UT, "y"}, | |
6602 | 709 {(int)KS_XN, "y"}, |
7 | 710 {(int)KS_LE, "\b"}, |
711 # ifdef TERMINFO | |
712 {(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", | |
713 ESC_STR "[%i%p1%d;%p2%dH")}, | |
714 # else | |
715 {(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")}, | |
716 # endif | |
717 # ifdef TERMINFO | |
718 {(int)KS_CRI, IF_EB("\033[%p1%dC", ESC_STR "[%p1%dC")}, | |
719 # else | |
720 {(int)KS_CRI, IF_EB("\033[%dC", ESC_STR "[%dC")}, | |
721 # endif | |
722 {K_UP, IF_EB("\033[A", ESC_STR "[A")}, | |
723 {K_DOWN, IF_EB("\033[B", ESC_STR "[B")}, | |
724 {K_RIGHT, IF_EB("\033[C", ESC_STR "[C")}, | |
725 {K_LEFT, IF_EB("\033[D", ESC_STR "[D")}, | |
344 | 726 {K_F1, IF_EB("\033[11~", ESC_STR "[11~")}, |
727 {K_F2, IF_EB("\033[12~", ESC_STR "[12~")}, | |
728 {K_F3, IF_EB("\033[13~", ESC_STR "[13~")}, | |
729 {K_F4, IF_EB("\033[14~", ESC_STR "[14~")}, | |
730 {K_F5, IF_EB("\033[15~", ESC_STR "[15~")}, | |
7 | 731 {K_F6, IF_EB("\033[17~", ESC_STR "[17~")}, |
732 {K_F7, IF_EB("\033[18~", ESC_STR "[18~")}, | |
733 {K_F8, IF_EB("\033[19~", ESC_STR "[19~")}, | |
734 {K_F9, IF_EB("\033[20~", ESC_STR "[20~")}, | |
735 {K_F10, IF_EB("\033[21~", ESC_STR "[21~")}, | |
344 | 736 {K_F11, IF_EB("\033[23~", ESC_STR "[23~")}, |
7 | 737 {K_F12, IF_EB("\033[24~", ESC_STR "[24~")}, |
738 {K_F13, IF_EB("\033[25~", ESC_STR "[25~")}, | |
739 {K_F14, IF_EB("\033[26~", ESC_STR "[26~")}, | |
740 {K_F15, IF_EB("\033[28~", ESC_STR "[28~")}, /* Help */ | |
741 {K_F16, IF_EB("\033[29~", ESC_STR "[29~")}, /* Select */ | |
742 {K_F17, IF_EB("\033[31~", ESC_STR "[31~")}, | |
743 {K_F18, IF_EB("\033[32~", ESC_STR "[32~")}, | |
744 {K_F19, IF_EB("\033[33~", ESC_STR "[33~")}, | |
745 {K_F20, IF_EB("\033[34~", ESC_STR "[34~")}, | |
746 {K_INS, IF_EB("\033[2~", ESC_STR "[2~")}, | |
747 {K_DEL, IF_EB("\033[3~", ESC_STR "[3~")}, | |
748 {K_HOME, IF_EB("\033[1~", ESC_STR "[1~")}, | |
749 {K_END, IF_EB("\033[4~", ESC_STR "[4~")}, | |
750 {K_PAGEUP, IF_EB("\033[5~", ESC_STR "[5~")}, | |
751 {K_PAGEDOWN, IF_EB("\033[6~", ESC_STR "[6~")}, | |
752 {K_KPLUS, IF_EB("\033Ok", ESC_STR "Ok")}, /* keypad plus */ | |
753 {K_KMINUS, IF_EB("\033Om", ESC_STR "Om")}, /* keypad minus */ | |
754 {K_KDIVIDE, IF_EB("\033Oo", ESC_STR "Oo")}, /* keypad / */ | |
755 {K_KMULTIPLY, IF_EB("\033Oj", ESC_STR "Oj")}, /* keypad * */ | |
756 {K_KENTER, IF_EB("\033OM", ESC_STR "OM")}, /* keypad Enter */ | |
757 {K_BS, "\x7f"}, /* for some reason 0177 doesn't work */ | |
758 # endif | |
759 | |
760 # if defined(ALL_BUILTIN_TCAPS) || defined(__MINT__) | |
761 /* | |
762 * Ordinary vt52 | |
763 */ | |
764 {(int)KS_NAME, "vt52"}, | |
765 {(int)KS_CE, IF_EB("\033K", ESC_STR "K")}, | |
766 {(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
|
767 # ifdef TERMINFO |
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
768 {(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
|
769 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
|
770 # else |
7 | 771 {(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
|
772 # endif |
7 | 773 {(int)KS_LE, "\b"}, |
7264
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
774 {(int)KS_SR, IF_EB("\033I", ESC_STR "I")}, |
7 | 775 {(int)KS_AL, IF_EB("\033L", ESC_STR "L")}, |
776 {(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
|
777 {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
|
778 {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
|
779 {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
|
780 {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
|
781 {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
|
782 {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
|
783 {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
|
784 # ifdef __MINT__ |
7 | 785 {(int)KS_CL, IF_EB("\033E", ESC_STR "E")}, |
786 {(int)KS_VE, IF_EB("\033e", ESC_STR "e")}, | |
787 {(int)KS_VI, IF_EB("\033f", ESC_STR "f")}, | |
788 {(int)KS_SO, IF_EB("\033p", ESC_STR "p")}, | |
789 {(int)KS_SE, IF_EB("\033q", ESC_STR "q")}, | |
790 {K_S_UP, IF_EB("\033a", ESC_STR "a")}, | |
791 {K_S_DOWN, IF_EB("\033b", ESC_STR "b")}, | |
792 {K_S_LEFT, IF_EB("\033d", ESC_STR "d")}, | |
793 {K_S_RIGHT, IF_EB("\033c", ESC_STR "c")}, | |
794 {K_F4, IF_EB("\033S", ESC_STR "S")}, | |
795 {K_F5, IF_EB("\033T", ESC_STR "T")}, | |
796 {K_F6, IF_EB("\033U", ESC_STR "U")}, | |
797 {K_F7, IF_EB("\033V", ESC_STR "V")}, | |
798 {K_F8, IF_EB("\033W", ESC_STR "W")}, | |
799 {K_F9, IF_EB("\033X", ESC_STR "X")}, | |
800 {K_F10, IF_EB("\033Y", ESC_STR "Y")}, | |
801 {K_S_F1, IF_EB("\033p", ESC_STR "p")}, | |
802 {K_S_F2, IF_EB("\033q", ESC_STR "q")}, | |
803 {K_S_F3, IF_EB("\033r", ESC_STR "r")}, | |
804 {K_S_F4, IF_EB("\033s", ESC_STR "s")}, | |
805 {K_S_F5, IF_EB("\033t", ESC_STR "t")}, | |
806 {K_S_F6, IF_EB("\033u", ESC_STR "u")}, | |
807 {K_S_F7, IF_EB("\033v", ESC_STR "v")}, | |
808 {K_S_F8, IF_EB("\033w", ESC_STR "w")}, | |
809 {K_S_F9, IF_EB("\033x", ESC_STR "x")}, | |
810 {K_S_F10, IF_EB("\033y", ESC_STR "y")}, | |
811 {K_INS, IF_EB("\033I", ESC_STR "I")}, | |
812 {K_HOME, IF_EB("\033E", ESC_STR "E")}, | |
813 {K_PAGEDOWN, IF_EB("\033b", ESC_STR "b")}, | |
814 {K_PAGEUP, IF_EB("\033a", ESC_STR "a")}, | |
815 # else | |
816 {(int)KS_CL, IF_EB("\033H\033J", ESC_STR "H" ESC_STR_nc "J")}, | |
817 {(int)KS_MS, "y"}, | |
818 # endif | |
819 # endif | |
820 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
821 # 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
|
822 {(int)KS_NAME, "xterm"}, |
7 | 823 {(int)KS_CE, IF_EB("\033[K", ESC_STR "[K")}, |
824 {(int)KS_AL, IF_EB("\033[L", ESC_STR "[L")}, | |
825 # ifdef TERMINFO | |
826 {(int)KS_CAL, IF_EB("\033[%p1%dL", ESC_STR "[%p1%dL")}, | |
827 # else | |
828 {(int)KS_CAL, IF_EB("\033[%dL", ESC_STR "[%dL")}, | |
829 # endif | |
830 {(int)KS_DL, IF_EB("\033[M", ESC_STR "[M")}, | |
831 # ifdef TERMINFO | |
832 {(int)KS_CDL, IF_EB("\033[%p1%dM", ESC_STR "[%p1%dM")}, | |
833 # else | |
834 {(int)KS_CDL, IF_EB("\033[%dM", ESC_STR "[%dM")}, | |
835 # endif | |
836 # ifdef TERMINFO | |
837 {(int)KS_CS, IF_EB("\033[%i%p1%d;%p2%dr", | |
838 ESC_STR "[%i%p1%d;%p2%dr")}, | |
839 # else | |
840 {(int)KS_CS, IF_EB("\033[%i%d;%dr", ESC_STR "[%i%d;%dr")}, | |
841 # endif | |
842 {(int)KS_CL, IF_EB("\033[H\033[2J", ESC_STR "[H" ESC_STR_nc "[2J")}, | |
843 {(int)KS_CD, IF_EB("\033[J", ESC_STR "[J")}, | |
844 {(int)KS_ME, IF_EB("\033[m", ESC_STR "[m")}, | |
845 {(int)KS_MR, IF_EB("\033[7m", ESC_STR "[7m")}, | |
846 {(int)KS_MD, IF_EB("\033[1m", ESC_STR "[1m")}, | |
847 {(int)KS_UE, IF_EB("\033[m", ESC_STR "[m")}, | |
848 {(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
|
849 {(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
|
850 {(int)KS_STS, IF_EB("\033[9m", ESC_STR "[9m")}, |
7 | 851 {(int)KS_MS, "y"}, |
852 {(int)KS_UT, "y"}, | |
853 {(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
|
854 {(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
|
855 {(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
|
856 {(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
|
857 {(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
|
858 # ifdef TERMINFO |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
859 {(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
|
860 # else |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
861 {(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
|
862 # endif |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
863 {(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
|
864 {(int)KS_CRS, IF_EB("\033P$q q\033\\", ESC_STR "P$q q" ESC_STR "\\")}, |
7 | 865 # ifdef TERMINFO |
866 {(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", | |
867 ESC_STR "[%i%p1%d;%p2%dH")}, | |
868 # else | |
869 {(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")}, | |
870 # endif | |
871 {(int)KS_SR, IF_EB("\033M", ESC_STR "M")}, | |
872 # ifdef TERMINFO | |
873 {(int)KS_CRI, IF_EB("\033[%p1%dC", ESC_STR "[%p1%dC")}, | |
874 # else | |
875 {(int)KS_CRI, IF_EB("\033[%dC", ESC_STR "[%dC")}, | |
876 # endif | |
877 {(int)KS_KS, IF_EB("\033[?1h\033=", ESC_STR "[?1h" ESC_STR_nc "=")}, | |
878 {(int)KS_KE, IF_EB("\033[?1l\033>", ESC_STR "[?1l" ESC_STR_nc ">")}, | |
879 # ifdef FEAT_XTERM_SAVE | |
880 {(int)KS_TI, IF_EB("\0337\033[?47h", ESC_STR "7" ESC_STR_nc "[?47h")}, | |
881 {(int)KS_TE, IF_EB("\033[2J\033[?47l\0338", | |
882 ESC_STR "[2J" ESC_STR_nc "[?47l" ESC_STR_nc "8")}, | |
883 # endif | |
884 {(int)KS_CIS, IF_EB("\033]1;", ESC_STR "]1;")}, | |
885 {(int)KS_CIE, "\007"}, | |
886 {(int)KS_TS, IF_EB("\033]2;", ESC_STR "]2;")}, | |
887 {(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
|
888 {(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
|
889 {(int)KS_CEC, "\007"}, |
7 | 890 # ifdef TERMINFO |
891 {(int)KS_CWS, IF_EB("\033[8;%p1%d;%p2%dt", | |
892 ESC_STR "[8;%p1%d;%p2%dt")}, | |
893 {(int)KS_CWP, IF_EB("\033[3;%p1%d;%p2%dt", | |
894 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
|
895 {(int)KS_CGP, IF_EB("\033[13t", ESC_STR "[13t")}, |
7 | 896 # else |
897 {(int)KS_CWS, IF_EB("\033[8;%d;%dt", ESC_STR "[8;%d;%dt")}, | |
898 {(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
|
899 {(int)KS_CGP, IF_EB("\033[13t", ESC_STR "[13t")}, |
7 | 900 # endif |
901 {(int)KS_CRV, IF_EB("\033[>c", ESC_STR "[>c")}, | |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
902 {(int)KS_RFG, IF_EB("\033]10;?\007", ESC_STR "]10;?\007")}, |
6874 | 903 {(int)KS_RBG, IF_EB("\033]11;?\007", ESC_STR "]11;?\007")}, |
4215 | 904 {(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
|
905 # ifdef FEAT_TERMGUICOLORS |
8985
42eb58c9da92
commit https://github.com/vim/vim/commit/b2fa54a84078e2b8dc3c7c7bfbccf6b75c0788d0
Christian Brabandt <cb@256bit.org>
parents:
8981
diff
changeset
|
906 /* 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
|
907 {(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
|
908 {(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
|
909 # endif |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
910 {(int)KS_CBE, IF_EB("\033[?2004h", ESC_STR "[?2004h")}, |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
911 {(int)KS_CBD, IF_EB("\033[?2004l", ESC_STR "[?2004l")}, |
180 | 912 |
913 {K_UP, IF_EB("\033O*A", ESC_STR "O*A")}, | |
914 {K_DOWN, IF_EB("\033O*B", ESC_STR "O*B")}, | |
915 {K_RIGHT, IF_EB("\033O*C", ESC_STR "O*C")}, | |
916 {K_LEFT, IF_EB("\033O*D", ESC_STR "O*D")}, | |
917 /* An extra set of cursor keys for vt100 mode */ | |
918 {K_XUP, IF_EB("\033[1;*A", ESC_STR "[1;*A")}, | |
919 {K_XDOWN, IF_EB("\033[1;*B", ESC_STR "[1;*B")}, | |
920 {K_XRIGHT, IF_EB("\033[1;*C", ESC_STR "[1;*C")}, | |
921 {K_XLEFT, IF_EB("\033[1;*D", ESC_STR "[1;*D")}, | |
7 | 922 /* An extra set of function keys for vt100 mode */ |
180 | 923 {K_XF1, IF_EB("\033O*P", ESC_STR "O*P")}, |
924 {K_XF2, IF_EB("\033O*Q", ESC_STR "O*Q")}, | |
925 {K_XF3, IF_EB("\033O*R", ESC_STR "O*R")}, | |
926 {K_XF4, IF_EB("\033O*S", ESC_STR "O*S")}, | |
179 | 927 {K_F1, IF_EB("\033[11;*~", ESC_STR "[11;*~")}, |
928 {K_F2, IF_EB("\033[12;*~", ESC_STR "[12;*~")}, | |
929 {K_F3, IF_EB("\033[13;*~", ESC_STR "[13;*~")}, | |
930 {K_F4, IF_EB("\033[14;*~", ESC_STR "[14;*~")}, | |
931 {K_F5, IF_EB("\033[15;*~", ESC_STR "[15;*~")}, | |
932 {K_F6, IF_EB("\033[17;*~", ESC_STR "[17;*~")}, | |
933 {K_F7, IF_EB("\033[18;*~", ESC_STR "[18;*~")}, | |
934 {K_F8, IF_EB("\033[19;*~", ESC_STR "[19;*~")}, | |
935 {K_F9, IF_EB("\033[20;*~", ESC_STR "[20;*~")}, | |
936 {K_F10, IF_EB("\033[21;*~", ESC_STR "[21;*~")}, | |
937 {K_F11, IF_EB("\033[23;*~", ESC_STR "[23;*~")}, | |
938 {K_F12, IF_EB("\033[24;*~", ESC_STR "[24;*~")}, | |
7 | 939 {K_S_TAB, IF_EB("\033[Z", ESC_STR "[Z")}, |
179 | 940 {K_HELP, IF_EB("\033[28;*~", ESC_STR "[28;*~")}, |
941 {K_UNDO, IF_EB("\033[26;*~", ESC_STR "[26;*~")}, | |
942 {K_INS, IF_EB("\033[2;*~", ESC_STR "[2;*~")}, | |
943 {K_HOME, IF_EB("\033[1;*H", ESC_STR "[1;*H")}, | |
180 | 944 /* {K_S_HOME, IF_EB("\033O2H", ESC_STR "O2H")}, */ |
945 /* {K_C_HOME, IF_EB("\033O5H", ESC_STR "O5H")}, */ | |
230 | 946 {K_KHOME, IF_EB("\033[1;*~", ESC_STR "[1;*~")}, |
180 | 947 {K_XHOME, IF_EB("\033O*H", ESC_STR "O*H")}, /* other Home */ |
230 | 948 {K_ZHOME, IF_EB("\033[7;*~", ESC_STR "[7;*~")}, /* other Home */ |
179 | 949 {K_END, IF_EB("\033[1;*F", ESC_STR "[1;*F")}, |
180 | 950 /* {K_S_END, IF_EB("\033O2F", ESC_STR "O2F")}, */ |
951 /* {K_C_END, IF_EB("\033O5F", ESC_STR "O5F")}, */ | |
179 | 952 {K_KEND, IF_EB("\033[4;*~", ESC_STR "[4;*~")}, |
180 | 953 {K_XEND, IF_EB("\033O*F", ESC_STR "O*F")}, /* other End */ |
230 | 954 {K_ZEND, IF_EB("\033[8;*~", ESC_STR "[8;*~")}, |
179 | 955 {K_PAGEUP, IF_EB("\033[5;*~", ESC_STR "[5;*~")}, |
956 {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
|
957 {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
|
958 {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
|
959 {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
|
960 {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
|
961 {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
|
962 {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
|
963 {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
|
964 {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
|
965 {K_PE, IF_EB("\033[201~", ESC_STR "[201~")}, /* paste end */ |
7 | 966 |
967 {BT_EXTRA_KEYS, ""}, | |
179 | 968 {TERMCAP2KEY('k', '0'), IF_EB("\033[10;*~", ESC_STR "[10;*~")}, /* F0 */ |
969 {TERMCAP2KEY('F', '3'), IF_EB("\033[25;*~", ESC_STR "[25;*~")}, /* F13 */ | |
970 /* F14 and F15 are missing, because they send the same codes as the undo | |
971 * and help key, although they don't work on all keyboards. */ | |
972 {TERMCAP2KEY('F', '6'), IF_EB("\033[29;*~", ESC_STR "[29;*~")}, /* F16 */ | |
973 {TERMCAP2KEY('F', '7'), IF_EB("\033[31;*~", ESC_STR "[31;*~")}, /* F17 */ | |
974 {TERMCAP2KEY('F', '8'), IF_EB("\033[32;*~", ESC_STR "[32;*~")}, /* F18 */ | |
975 {TERMCAP2KEY('F', '9'), IF_EB("\033[33;*~", ESC_STR "[33;*~")}, /* F19 */ | |
976 {TERMCAP2KEY('F', 'A'), IF_EB("\033[34;*~", ESC_STR "[34;*~")}, /* F20 */ | |
977 | |
978 {TERMCAP2KEY('F', 'B'), IF_EB("\033[42;*~", ESC_STR "[42;*~")}, /* F21 */ | |
979 {TERMCAP2KEY('F', 'C'), IF_EB("\033[43;*~", ESC_STR "[43;*~")}, /* F22 */ | |
980 {TERMCAP2KEY('F', 'D'), IF_EB("\033[44;*~", ESC_STR "[44;*~")}, /* F23 */ | |
981 {TERMCAP2KEY('F', 'E'), IF_EB("\033[45;*~", ESC_STR "[45;*~")}, /* F24 */ | |
982 {TERMCAP2KEY('F', 'F'), IF_EB("\033[46;*~", ESC_STR "[46;*~")}, /* F25 */ | |
983 {TERMCAP2KEY('F', 'G'), IF_EB("\033[47;*~", ESC_STR "[47;*~")}, /* F26 */ | |
984 {TERMCAP2KEY('F', 'H'), IF_EB("\033[48;*~", ESC_STR "[48;*~")}, /* F27 */ | |
985 {TERMCAP2KEY('F', 'I'), IF_EB("\033[49;*~", ESC_STR "[49;*~")}, /* F28 */ | |
986 {TERMCAP2KEY('F', 'J'), IF_EB("\033[50;*~", ESC_STR "[50;*~")}, /* F29 */ | |
987 {TERMCAP2KEY('F', 'K'), IF_EB("\033[51;*~", ESC_STR "[51;*~")}, /* F30 */ | |
988 | |
989 {TERMCAP2KEY('F', 'L'), IF_EB("\033[52;*~", ESC_STR "[52;*~")}, /* F31 */ | |
990 {TERMCAP2KEY('F', 'M'), IF_EB("\033[53;*~", ESC_STR "[53;*~")}, /* F32 */ | |
991 {TERMCAP2KEY('F', 'N'), IF_EB("\033[54;*~", ESC_STR "[54;*~")}, /* F33 */ | |
992 {TERMCAP2KEY('F', 'O'), IF_EB("\033[55;*~", ESC_STR "[55;*~")}, /* F34 */ | |
993 {TERMCAP2KEY('F', 'P'), IF_EB("\033[56;*~", ESC_STR "[56;*~")}, /* F35 */ | |
994 {TERMCAP2KEY('F', 'Q'), IF_EB("\033[57;*~", ESC_STR "[57;*~")}, /* F36 */ | |
995 {TERMCAP2KEY('F', 'R'), IF_EB("\033[58;*~", ESC_STR "[58;*~")}, /* F37 */ | |
7 | 996 # endif |
997 | |
998 # if defined(UNIX) || defined(ALL_BUILTIN_TCAPS) | |
999 /* | |
1000 * iris-ansi for Silicon Graphics machines. | |
1001 */ | |
1002 {(int)KS_NAME, "iris-ansi"}, | |
1003 {(int)KS_CE, "\033[K"}, | |
1004 {(int)KS_CD, "\033[J"}, | |
1005 {(int)KS_AL, "\033[L"}, | |
1006 # ifdef TERMINFO | |
1007 {(int)KS_CAL, "\033[%p1%dL"}, | |
1008 # else | |
1009 {(int)KS_CAL, "\033[%dL"}, | |
1010 # endif | |
1011 {(int)KS_DL, "\033[M"}, | |
1012 # ifdef TERMINFO | |
1013 {(int)KS_CDL, "\033[%p1%dM"}, | |
1014 # else | |
1015 {(int)KS_CDL, "\033[%dM"}, | |
1016 # endif | |
1017 #if 0 /* The scroll region is not working as Vim expects. */ | |
1018 # ifdef TERMINFO | |
1019 {(int)KS_CS, "\033[%i%p1%d;%p2%dr"}, | |
1020 # else | |
1021 {(int)KS_CS, "\033[%i%d;%dr"}, | |
1022 # endif | |
1023 #endif | |
1024 {(int)KS_CL, "\033[H\033[2J"}, | |
1025 {(int)KS_VE, "\033[9/y\033[12/y"}, /* These aren't documented */ | |
1026 {(int)KS_VS, "\033[10/y\033[=1h\033[=2l"}, /* These aren't documented */ | |
1027 {(int)KS_TI, "\033[=6h"}, | |
1028 {(int)KS_TE, "\033[=6l"}, | |
1029 {(int)KS_SE, "\033[21;27m"}, | |
1030 {(int)KS_SO, "\033[1;7m"}, | |
1031 {(int)KS_ME, "\033[m"}, | |
1032 {(int)KS_MR, "\033[7m"}, | |
1033 {(int)KS_MD, "\033[1m"}, | |
1034 {(int)KS_CCO, "8"}, /* allow 8 colors */ | |
1035 {(int)KS_CZH, "\033[3m"}, /* italic mode on */ | |
1036 {(int)KS_CZR, "\033[23m"}, /* italic mode off */ | |
1037 {(int)KS_US, "\033[4m"}, /* underline on */ | |
1038 {(int)KS_UE, "\033[24m"}, /* underline off */ | |
1039 # ifdef TERMINFO | |
1040 {(int)KS_CAB, "\033[4%p1%dm"}, /* set background color (ANSI) */ | |
1041 {(int)KS_CAF, "\033[3%p1%dm"}, /* set foreground color (ANSI) */ | |
1042 {(int)KS_CSB, "\033[102;%p1%dm"}, /* set screen background color */ | |
1043 {(int)KS_CSF, "\033[101;%p1%dm"}, /* set screen foreground color */ | |
1044 # else | |
1045 {(int)KS_CAB, "\033[4%dm"}, /* set background color (ANSI) */ | |
1046 {(int)KS_CAF, "\033[3%dm"}, /* set foreground color (ANSI) */ | |
1047 {(int)KS_CSB, "\033[102;%dm"}, /* set screen background color */ | |
1048 {(int)KS_CSF, "\033[101;%dm"}, /* set screen foreground color */ | |
1049 # endif | |
1050 {(int)KS_MS, "y"}, /* guessed */ | |
1051 {(int)KS_UT, "y"}, /* guessed */ | |
1052 {(int)KS_LE, "\b"}, | |
1053 # ifdef TERMINFO | |
1054 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
1055 # else | |
1056 {(int)KS_CM, "\033[%i%d;%dH"}, | |
1057 # endif | |
1058 {(int)KS_SR, "\033M"}, | |
1059 # ifdef TERMINFO | |
1060 {(int)KS_CRI, "\033[%p1%dC"}, | |
1061 # else | |
1062 {(int)KS_CRI, "\033[%dC"}, | |
1063 # endif | |
1064 {(int)KS_CIS, "\033P3.y"}, | |
1065 {(int)KS_CIE, "\234"}, /* ST "String Terminator" */ | |
1066 {(int)KS_TS, "\033P1.y"}, | |
1067 {(int)KS_FS, "\234"}, /* ST "String Terminator" */ | |
1068 # ifdef TERMINFO | |
1069 {(int)KS_CWS, "\033[203;%p1%d;%p2%d/y"}, | |
1070 {(int)KS_CWP, "\033[205;%p1%d;%p2%d/y"}, | |
1071 # else | |
1072 {(int)KS_CWS, "\033[203;%d;%d/y"}, | |
1073 {(int)KS_CWP, "\033[205;%d;%d/y"}, | |
1074 # endif | |
1075 {K_UP, "\033[A"}, | |
1076 {K_DOWN, "\033[B"}, | |
1077 {K_LEFT, "\033[D"}, | |
1078 {K_RIGHT, "\033[C"}, | |
1079 {K_S_UP, "\033[161q"}, | |
1080 {K_S_DOWN, "\033[164q"}, | |
1081 {K_S_LEFT, "\033[158q"}, | |
1082 {K_S_RIGHT, "\033[167q"}, | |
1083 {K_F1, "\033[001q"}, | |
1084 {K_F2, "\033[002q"}, | |
1085 {K_F3, "\033[003q"}, | |
1086 {K_F4, "\033[004q"}, | |
1087 {K_F5, "\033[005q"}, | |
1088 {K_F6, "\033[006q"}, | |
1089 {K_F7, "\033[007q"}, | |
1090 {K_F8, "\033[008q"}, | |
1091 {K_F9, "\033[009q"}, | |
1092 {K_F10, "\033[010q"}, | |
1093 {K_F11, "\033[011q"}, | |
1094 {K_F12, "\033[012q"}, | |
1095 {K_S_F1, "\033[013q"}, | |
1096 {K_S_F2, "\033[014q"}, | |
1097 {K_S_F3, "\033[015q"}, | |
1098 {K_S_F4, "\033[016q"}, | |
1099 {K_S_F5, "\033[017q"}, | |
1100 {K_S_F6, "\033[018q"}, | |
1101 {K_S_F7, "\033[019q"}, | |
1102 {K_S_F8, "\033[020q"}, | |
1103 {K_S_F9, "\033[021q"}, | |
1104 {K_S_F10, "\033[022q"}, | |
1105 {K_S_F11, "\033[023q"}, | |
1106 {K_S_F12, "\033[024q"}, | |
1107 {K_INS, "\033[139q"}, | |
1108 {K_HOME, "\033[H"}, | |
1109 {K_END, "\033[146q"}, | |
1110 {K_PAGEUP, "\033[150q"}, | |
1111 {K_PAGEDOWN, "\033[154q"}, | |
1112 # endif | |
1113 | |
1114 # if defined(DEBUG) || defined(ALL_BUILTIN_TCAPS) | |
1115 /* | |
1116 * for debugging | |
1117 */ | |
1118 {(int)KS_NAME, "debug"}, | |
1119 {(int)KS_CE, "[CE]"}, | |
1120 {(int)KS_CD, "[CD]"}, | |
1121 {(int)KS_AL, "[AL]"}, | |
1122 # ifdef TERMINFO | |
1123 {(int)KS_CAL, "[CAL%p1%d]"}, | |
1124 # else | |
1125 {(int)KS_CAL, "[CAL%d]"}, | |
1126 # endif | |
1127 {(int)KS_DL, "[DL]"}, | |
1128 # ifdef TERMINFO | |
1129 {(int)KS_CDL, "[CDL%p1%d]"}, | |
1130 # else | |
1131 {(int)KS_CDL, "[CDL%d]"}, | |
1132 # endif | |
1133 # ifdef TERMINFO | |
1134 {(int)KS_CS, "[%p1%dCS%p2%d]"}, | |
1135 # else | |
1136 {(int)KS_CS, "[%dCS%d]"}, | |
1137 # endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12429
diff
changeset
|
1138 # ifdef TERMINFO |
7 | 1139 {(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
|
1140 # else |
7 | 1141 {(int)KS_CSV, "[%dCSV%d]"}, |
1142 # endif | |
1143 # ifdef TERMINFO | |
1144 {(int)KS_CAB, "[CAB%p1%d]"}, | |
1145 {(int)KS_CAF, "[CAF%p1%d]"}, | |
1146 {(int)KS_CSB, "[CSB%p1%d]"}, | |
1147 {(int)KS_CSF, "[CSF%p1%d]"}, | |
1148 # else | |
1149 {(int)KS_CAB, "[CAB%d]"}, | |
1150 {(int)KS_CAF, "[CAF%d]"}, | |
1151 {(int)KS_CSB, "[CSB%d]"}, | |
1152 {(int)KS_CSF, "[CSF%d]"}, | |
1153 # endif | |
1154 {(int)KS_OP, "[OP]"}, | |
1155 {(int)KS_LE, "[LE]"}, | |
1156 {(int)KS_CL, "[CL]"}, | |
1157 {(int)KS_VI, "[VI]"}, | |
1158 {(int)KS_VE, "[VE]"}, | |
1159 {(int)KS_VS, "[VS]"}, | |
1160 {(int)KS_ME, "[ME]"}, | |
1161 {(int)KS_MR, "[MR]"}, | |
1162 {(int)KS_MB, "[MB]"}, | |
1163 {(int)KS_MD, "[MD]"}, | |
1164 {(int)KS_SE, "[SE]"}, | |
1165 {(int)KS_SO, "[SO]"}, | |
1166 {(int)KS_UE, "[UE]"}, | |
1167 {(int)KS_US, "[US]"}, | |
205 | 1168 {(int)KS_UCE, "[UCE]"}, |
1169 {(int)KS_UCS, "[UCS]"}, | |
12317
2a8890b80923
patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents:
12307
diff
changeset
|
1170 {(int)KS_STE, "[STE]"}, |
2a8890b80923
patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents:
12307
diff
changeset
|
1171 {(int)KS_STS, "[STS]"}, |
7 | 1172 {(int)KS_MS, "[MS]"}, |
1173 {(int)KS_UT, "[UT]"}, | |
6602 | 1174 {(int)KS_XN, "[XN]"}, |
7 | 1175 # ifdef TERMINFO |
1176 {(int)KS_CM, "[%p1%dCM%p2%d]"}, | |
1177 # else | |
1178 {(int)KS_CM, "[%dCM%d]"}, | |
1179 # endif | |
1180 {(int)KS_SR, "[SR]"}, | |
1181 # ifdef TERMINFO | |
1182 {(int)KS_CRI, "[CRI%p1%d]"}, | |
1183 # else | |
1184 {(int)KS_CRI, "[CRI%d]"}, | |
1185 # endif | |
1186 {(int)KS_VB, "[VB]"}, | |
1187 {(int)KS_KS, "[KS]"}, | |
1188 {(int)KS_KE, "[KE]"}, | |
1189 {(int)KS_TI, "[TI]"}, | |
1190 {(int)KS_TE, "[TE]"}, | |
1191 {(int)KS_CIS, "[CIS]"}, | |
1192 {(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
|
1193 {(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
|
1194 {(int)KS_CEC, "[CEC]"}, |
7 | 1195 {(int)KS_TS, "[TS]"}, |
1196 {(int)KS_FS, "[FS]"}, | |
1197 # ifdef TERMINFO | |
1198 {(int)KS_CWS, "[%p1%dCWS%p2%d]"}, | |
1199 {(int)KS_CWP, "[%p1%dCWP%p2%d]"}, | |
1200 # else | |
1201 {(int)KS_CWS, "[%dCWS%d]"}, | |
1202 {(int)KS_CWP, "[%dCWP%d]"}, | |
1203 # endif | |
1204 {(int)KS_CRV, "[CRV]"}, | |
4215 | 1205 {(int)KS_U7, "[U7]"}, |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
1206 {(int)KS_RFG, "[RFG]"}, |
6874 | 1207 {(int)KS_RBG, "[RBG]"}, |
7 | 1208 {K_UP, "[KU]"}, |
1209 {K_DOWN, "[KD]"}, | |
1210 {K_LEFT, "[KL]"}, | |
1211 {K_RIGHT, "[KR]"}, | |
180 | 1212 {K_XUP, "[xKU]"}, |
1213 {K_XDOWN, "[xKD]"}, | |
1214 {K_XLEFT, "[xKL]"}, | |
1215 {K_XRIGHT, "[xKR]"}, | |
7 | 1216 {K_S_UP, "[S-KU]"}, |
1217 {K_S_DOWN, "[S-KD]"}, | |
1218 {K_S_LEFT, "[S-KL]"}, | |
1219 {K_C_LEFT, "[C-KL]"}, | |
1220 {K_S_RIGHT, "[S-KR]"}, | |
1221 {K_C_RIGHT, "[C-KR]"}, | |
1222 {K_F1, "[F1]"}, | |
1223 {K_XF1, "[xF1]"}, | |
1224 {K_F2, "[F2]"}, | |
1225 {K_XF2, "[xF2]"}, | |
1226 {K_F3, "[F3]"}, | |
1227 {K_XF3, "[xF3]"}, | |
1228 {K_F4, "[F4]"}, | |
1229 {K_XF4, "[xF4]"}, | |
1230 {K_F5, "[F5]"}, | |
1231 {K_F6, "[F6]"}, | |
1232 {K_F7, "[F7]"}, | |
1233 {K_F8, "[F8]"}, | |
1234 {K_F9, "[F9]"}, | |
1235 {K_F10, "[F10]"}, | |
1236 {K_F11, "[F11]"}, | |
1237 {K_F12, "[F12]"}, | |
1238 {K_S_F1, "[S-F1]"}, | |
1239 {K_S_XF1, "[S-xF1]"}, | |
1240 {K_S_F2, "[S-F2]"}, | |
1241 {K_S_XF2, "[S-xF2]"}, | |
1242 {K_S_F3, "[S-F3]"}, | |
1243 {K_S_XF3, "[S-xF3]"}, | |
1244 {K_S_F4, "[S-F4]"}, | |
1245 {K_S_XF4, "[S-xF4]"}, | |
1246 {K_S_F5, "[S-F5]"}, | |
1247 {K_S_F6, "[S-F6]"}, | |
1248 {K_S_F7, "[S-F7]"}, | |
1249 {K_S_F8, "[S-F8]"}, | |
1250 {K_S_F9, "[S-F9]"}, | |
1251 {K_S_F10, "[S-F10]"}, | |
1252 {K_S_F11, "[S-F11]"}, | |
1253 {K_S_F12, "[S-F12]"}, | |
1254 {K_HELP, "[HELP]"}, | |
1255 {K_UNDO, "[UNDO]"}, | |
1256 {K_BS, "[BS]"}, | |
1257 {K_INS, "[INS]"}, | |
1258 {K_KINS, "[KINS]"}, | |
1259 {K_DEL, "[DEL]"}, | |
1260 {K_KDEL, "[KDEL]"}, | |
1261 {K_HOME, "[HOME]"}, | |
1262 {K_S_HOME, "[C-HOME]"}, | |
1263 {K_C_HOME, "[C-HOME]"}, | |
1264 {K_KHOME, "[KHOME]"}, | |
1265 {K_XHOME, "[XHOME]"}, | |
230 | 1266 {K_ZHOME, "[ZHOME]"}, |
7 | 1267 {K_END, "[END]"}, |
1268 {K_S_END, "[C-END]"}, | |
1269 {K_C_END, "[C-END]"}, | |
1270 {K_KEND, "[KEND]"}, | |
1271 {K_XEND, "[XEND]"}, | |
230 | 1272 {K_ZEND, "[ZEND]"}, |
7 | 1273 {K_PAGEUP, "[PAGEUP]"}, |
1274 {K_PAGEDOWN, "[PAGEDOWN]"}, | |
1275 {K_KPAGEUP, "[KPAGEUP]"}, | |
1276 {K_KPAGEDOWN, "[KPAGEDOWN]"}, | |
1277 {K_MOUSE, "[MOUSE]"}, | |
1278 {K_KPLUS, "[KPLUS]"}, | |
1279 {K_KMINUS, "[KMINUS]"}, | |
1280 {K_KDIVIDE, "[KDIVIDE]"}, | |
1281 {K_KMULTIPLY, "[KMULTIPLY]"}, | |
1282 {K_KENTER, "[KENTER]"}, | |
1283 {K_KPOINT, "[KPOINT]"}, | |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
1284 {K_PS, "[PASTE-START]"}, |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
1285 {K_PE, "[PASTE-END]"}, |
7 | 1286 {K_K0, "[K0]"}, |
1287 {K_K1, "[K1]"}, | |
1288 {K_K2, "[K2]"}, | |
1289 {K_K3, "[K3]"}, | |
1290 {K_K4, "[K4]"}, | |
1291 {K_K5, "[K5]"}, | |
1292 {K_K6, "[K6]"}, | |
1293 {K_K7, "[K7]"}, | |
1294 {K_K8, "[K8]"}, | |
1295 {K_K9, "[K9]"}, | |
1296 # endif | |
1297 | |
1298 #endif /* NO_BUILTIN_TCAPS */ | |
1299 | |
1300 /* | |
1301 * The most minimal terminal: only clear screen and cursor positioning | |
1302 * Always included. | |
1303 */ | |
1304 {(int)KS_NAME, "dumb"}, | |
1305 {(int)KS_CL, "\014"}, | |
1306 #ifdef TERMINFO | |
1307 {(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", | |
1308 ESC_STR "[%i%p1%d;%p2%dH")}, | |
1309 #else | |
1310 {(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")}, | |
1311 #endif | |
1312 | |
1313 /* | |
1314 * end marker | |
1315 */ | |
1316 {(int)KS_NAME, NULL} | |
1317 | |
1318 }; /* end of builtin_termcaps */ | |
1319 | |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1320 #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
|
1321 guicolor_T |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1322 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
|
1323 { |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
1324 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
|
1325 } |
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 guicolor_T |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1328 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
|
1329 { |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1330 guicolor_T t; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1331 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1332 if (*name == NUL) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1333 return INVALCOLOR; |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1334 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
|
1335 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1336 if (t == INVALCOLOR) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1337 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
|
1338 return t; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1339 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1340 |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
1341 guicolor_T |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1342 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
|
1343 { |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
1344 return color; |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1345 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1346 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1347 |
7 | 1348 /* |
1349 * DEFAULT_TERM is used, when no terminal is specified with -T option or $TERM. | |
1350 */ | |
1351 #ifdef AMIGA | |
1352 # define DEFAULT_TERM (char_u *)"amiga" | |
1353 #endif | |
1354 | |
1355 #ifdef MSWIN | |
1356 # define DEFAULT_TERM (char_u *)"win32" | |
1357 #endif | |
1358 | |
1359 #if defined(UNIX) && !defined(__MINT__) | |
1360 # define DEFAULT_TERM (char_u *)"ansi" | |
1361 #endif | |
1362 | |
1363 #ifdef __MINT__ | |
1364 # define DEFAULT_TERM (char_u *)"vt52" | |
1365 #endif | |
1366 | |
1367 #ifdef VMS | |
1368 # define DEFAULT_TERM (char_u *)"vt320" | |
1369 #endif | |
1370 | |
1371 #ifdef __BEOS__ | |
1372 # undef DEFAULT_TERM | |
1373 # define DEFAULT_TERM (char_u *)"beos-ansi" | |
1374 #endif | |
1375 | |
1376 #ifndef DEFAULT_TERM | |
1377 # define DEFAULT_TERM (char_u *)"dumb" | |
1378 #endif | |
1379 | |
1380 /* | |
1381 * Term_strings contains currently used terminal output strings. | |
1382 * It is initialized with the default values by parse_builtin_tcap(). | |
1383 * The values can be changed by setting the option with the same name. | |
1384 */ | |
1385 char_u *(term_strings[(int)KS_LAST + 1]); | |
1386 | |
1221 | 1387 static int need_gather = FALSE; /* need to fill termleader[] */ |
1388 static char_u termleader[256 + 1]; /* for check_termcode() */ | |
7 | 1389 #ifdef FEAT_TERMRESPONSE |
1221 | 1390 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
|
1391 static int is_not_xterm = FALSE; /* recognized not-really-xterm */ |
7 | 1392 #endif |
1393 | |
1394 static struct builtin_term * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1395 find_builtin_term(char_u *term) |
7 | 1396 { |
1397 struct builtin_term *p; | |
1398 | |
1399 p = builtin_termcaps; | |
1400 while (p->bt_string != NULL) | |
1401 { | |
1402 if (p->bt_entry == (int)KS_NAME) | |
1403 { | |
1404 #ifdef UNIX | |
1405 if (STRCMP(p->bt_string, "iris-ansi") == 0 && vim_is_iris(term)) | |
1406 return p; | |
1407 else if (STRCMP(p->bt_string, "xterm") == 0 && vim_is_xterm(term)) | |
1408 return p; | |
1409 else | |
1410 #endif | |
1411 #ifdef VMS | |
1412 if (STRCMP(p->bt_string, "vt320") == 0 && vim_is_vt300(term)) | |
1413 return p; | |
1414 else | |
1415 #endif | |
1416 if (STRCMP(term, p->bt_string) == 0) | |
1417 return p; | |
1418 } | |
1419 ++p; | |
1420 } | |
1421 return p; | |
1422 } | |
1423 | |
1424 /* | |
1425 * Parsing of the builtin termcap entries. | |
1426 * Caller should check if 'name' is a valid builtin term. | |
1427 * The terminal's name is not set, as this is already done in termcapinit(). | |
1428 */ | |
1429 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1430 parse_builtin_tcap(char_u *term) |
7 | 1431 { |
1432 struct builtin_term *p; | |
1433 char_u name[2]; | |
1434 int term_8bit; | |
1435 | |
1436 p = find_builtin_term(term); | |
1437 term_8bit = term_is_8bit(term); | |
1438 | |
1439 /* Do not parse if builtin term not found */ | |
1440 if (p->bt_string == NULL) | |
1441 return; | |
1442 | |
1443 for (++p; p->bt_entry != (int)KS_NAME && p->bt_entry != BT_EXTRA_KEYS; ++p) | |
1444 { | |
1445 if ((int)p->bt_entry >= 0) /* KS_xx entry */ | |
1446 { | |
1447 /* Only set the value if it wasn't set yet. */ | |
1448 if (term_strings[p->bt_entry] == NULL | |
1449 || term_strings[p->bt_entry] == empty_option) | |
1450 { | |
1451 /* 8bit terminal: use CSI instead of <Esc>[ */ | |
1452 if (term_8bit && term_7to8bit((char_u *)p->bt_string) != 0) | |
1453 { | |
1454 char_u *s, *t; | |
1455 | |
1456 s = vim_strsave((char_u *)p->bt_string); | |
1457 if (s != NULL) | |
1458 { | |
1459 for (t = s; *t; ++t) | |
1460 if (term_7to8bit(t)) | |
1461 { | |
1462 *t = term_7to8bit(t); | |
1463 STRCPY(t + 1, t + 2); | |
1464 } | |
1465 term_strings[p->bt_entry] = s; | |
1466 set_term_option_alloced(&term_strings[p->bt_entry]); | |
1467 } | |
1468 } | |
1469 else | |
1470 term_strings[p->bt_entry] = (char_u *)p->bt_string; | |
1471 } | |
1472 } | |
1473 else | |
1474 { | |
1475 name[0] = KEY2TERMCAP0((int)p->bt_entry); | |
1476 name[1] = KEY2TERMCAP1((int)p->bt_entry); | |
1477 if (find_termcode(name) == NULL) | |
1478 add_termcode(name, (char_u *)p->bt_string, term_8bit); | |
1479 } | |
1480 } | |
1481 } | |
11739
5c69c6d9e2eb
patch 8.0.0752: build fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11731
diff
changeset
|
1482 |
7 | 1483 /* |
1484 * Set number of colors. | |
1485 * Store it as a number in t_colors. | |
1486 * Store it as a string in T_CCO (using nr_colors[]). | |
1487 */ | |
1488 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1489 set_color_count(int nr) |
7 | 1490 { |
1491 char_u nr_colors[20]; /* string for number of colors */ | |
1492 | |
1493 t_colors = nr; | |
1494 if (t_colors > 1) | |
1495 sprintf((char *)nr_colors, "%d", t_colors); | |
1496 else | |
1497 *nr_colors = NUL; | |
694 | 1498 set_string_option_direct((char_u *)"t_Co", -1, nr_colors, OPT_FREE, 0); |
7 | 1499 } |
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
|
1500 |
11739
5c69c6d9e2eb
patch 8.0.0752: build fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11731
diff
changeset
|
1501 #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
|
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 * 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
|
1504 */ |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1505 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
|
1506 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
|
1507 { |
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1508 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
|
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 /* 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
|
1511 * 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
|
1512 * 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
|
1513 * 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
|
1514 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
|
1515 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
|
1516 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
|
1517 # 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
|
1518 { |
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
|
1519 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
|
1520 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
|
1521 |
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
|
1522 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
|
1523 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
|
1524 } |
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
|
1525 # 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
|
1526 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
|
1527 # 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
|
1528 } |
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
|
1529 } |
7 | 1530 #endif |
1531 | |
1532 #ifdef HAVE_TGETENT | |
1533 static char *(key_names[]) = | |
1534 { | |
1535 #ifdef FEAT_TERMRESPONSE | |
1536 /* Do this one first, it may cause a screen redraw. */ | |
1537 "Co", | |
1538 #endif | |
1539 "ku", "kd", "kr", "kl", | |
1540 "#2", "#4", "%i", "*7", | |
1541 "k1", "k2", "k3", "k4", "k5", "k6", | |
1542 "k7", "k8", "k9", "k;", "F1", "F2", | |
1543 "%1", "&8", "kb", "kI", "kD", "kh", | |
1544 "@7", "kP", "kN", "K1", "K3", "K4", "K5", "kB", | |
1545 NULL | |
1546 }; | |
1547 #endif | |
1548 | |
1549 /* | |
1550 * Set terminal options for terminal "term". | |
1551 * Return OK if terminal 'term' was found in a termcap, FAIL otherwise. | |
1552 * | |
1553 * While doing this, until ttest(), some options may be NULL, be careful. | |
1554 */ | |
1555 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1556 set_termname(char_u *term) |
7 | 1557 { |
1558 struct builtin_term *termp; | |
1559 #ifdef HAVE_TGETENT | |
1560 int builtin_first = p_tbi; | |
1561 int try; | |
1562 int termcap_cleared = FALSE; | |
1563 #endif | |
1564 int width = 0, height = 0; | |
1565 char_u *error_msg = NULL; | |
1566 char_u *bs_p, *del_p; | |
1567 | |
168 | 1568 /* In silect mode (ex -s) we don't use the 'term' option. */ |
1569 if (silent_mode) | |
1570 return OK; | |
1571 | |
7 | 1572 detected_8bit = FALSE; /* reset 8-bit detection */ |
1573 | |
1574 if (term_is_builtin(term)) | |
1575 { | |
1576 term += 8; | |
1577 #ifdef HAVE_TGETENT | |
1578 builtin_first = 1; | |
1579 #endif | |
1580 } | |
1581 | |
1582 /* | |
1583 * If HAVE_TGETENT is not defined, only the builtin termcap is used, otherwise: | |
1584 * If builtin_first is TRUE: | |
1585 * 0. try builtin termcap | |
1586 * 1. try external termcap | |
1587 * 2. if both fail default to a builtin terminal | |
1588 * If builtin_first is FALSE: | |
1589 * 1. try external termcap | |
1590 * 2. try builtin termcap, if both fail default to a builtin terminal | |
1591 */ | |
1592 #ifdef HAVE_TGETENT | |
1593 for (try = builtin_first ? 0 : 1; try < 3; ++try) | |
1594 { | |
1595 /* | |
1596 * Use external termcap | |
1597 */ | |
1598 if (try == 1) | |
1599 { | |
1600 char_u *p; | |
1601 static char_u tstrbuf[TBUFSZ]; | |
1602 int i; | |
1603 char_u tbuf[TBUFSZ]; | |
1604 char_u *tp; | |
1605 static struct { | |
1606 enum SpecialKey dest; /* index in term_strings[] */ | |
1607 char *name; /* termcap name for string */ | |
1608 } string_names[] = | |
1609 { {KS_CE, "ce"}, {KS_AL, "al"}, {KS_CAL,"AL"}, | |
1610 {KS_DL, "dl"}, {KS_CDL,"DL"}, {KS_CS, "cs"}, | |
1611 {KS_CL, "cl"}, {KS_CD, "cd"}, | |
1612 {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
|
1613 {KS_ME, "me"}, {KS_MR, "mr"}, |
7 | 1614 {KS_MD, "md"}, {KS_SE, "se"}, {KS_SO, "so"}, |
1615 {KS_CZH,"ZH"}, {KS_CZR,"ZR"}, {KS_UE, "ue"}, | |
205 | 1616 {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
|
1617 {KS_STE,"Te"}, {KS_STS,"Ts"}, |
205 | 1618 {KS_CM, "cm"}, {KS_SR, "sr"}, |
7 | 1619 {KS_CRI,"RI"}, {KS_VB, "vb"}, {KS_KS, "ks"}, |
1620 {KS_KE, "ke"}, {KS_TI, "ti"}, {KS_TE, "te"}, | |
1621 {KS_BC, "bc"}, {KS_CSB,"Sb"}, {KS_CSF,"Sf"}, | |
1622 {KS_CAB,"AB"}, {KS_CAF,"AF"}, {KS_LE, "le"}, | |
1623 {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
|
1624 {KS_VS, "vs"}, {KS_CVS, "VS"}, |
7 | 1625 {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
|
1626 {KS_CSC, "SC"}, {KS_CEC, "EC"}, |
7 | 1627 {KS_TS, "ts"}, {KS_FS, "fs"}, |
1628 {KS_CWP, "WP"}, {KS_CWS, "WS"}, | |
36 | 1629 {KS_CSI, "SI"}, {KS_CEI, "EI"}, |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
1630 {KS_U7, "u7"}, {KS_RFG, "RF"}, {KS_RBG, "RB"}, |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1631 {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
|
1632 {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
|
1633 {KS_CPS, "PS"}, {KS_CPE, "PE"}, |
7 | 1634 {(enum SpecialKey)0, NULL} |
1635 }; | |
1636 | |
1637 /* | |
1638 * If the external termcap does not have a matching entry, try the | |
1639 * builtin ones. | |
1640 */ | |
1641 if ((error_msg = tgetent_error(tbuf, term)) == NULL) | |
1642 { | |
1643 tp = tstrbuf; | |
1644 if (!termcap_cleared) | |
1645 { | |
1646 clear_termoptions(); /* clear old options */ | |
1647 termcap_cleared = TRUE; | |
1648 } | |
1649 | |
1650 /* get output strings */ | |
1651 for (i = 0; string_names[i].name != NULL; ++i) | |
1652 { | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
10676
diff
changeset
|
1653 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
|
1654 || 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
|
1655 TERM_STR(string_names[i].dest) = |
7 | 1656 TGETSTR(string_names[i].name, &tp); |
1657 } | |
1658 | |
1659 /* tgetflag() returns 1 if the flag is present, 0 if not and | |
1660 * possibly -1 if the flag doesn't exist. */ | |
1661 if ((T_MS == NULL || T_MS == empty_option) | |
1662 && tgetflag("ms") > 0) | |
1663 T_MS = (char_u *)"y"; | |
1664 if ((T_XS == NULL || T_XS == empty_option) | |
1665 && tgetflag("xs") > 0) | |
1666 T_XS = (char_u *)"y"; | |
6602 | 1667 if ((T_XN == NULL || T_XN == empty_option) |
1668 && tgetflag("xn") > 0) | |
1669 T_XN = (char_u *)"y"; | |
7 | 1670 if ((T_DB == NULL || T_DB == empty_option) |
1671 && tgetflag("db") > 0) | |
1672 T_DB = (char_u *)"y"; | |
1673 if ((T_DA == NULL || T_DA == empty_option) | |
1674 && tgetflag("da") > 0) | |
1675 T_DA = (char_u *)"y"; | |
1676 if ((T_UT == NULL || T_UT == empty_option) | |
1677 && tgetflag("ut") > 0) | |
1678 T_UT = (char_u *)"y"; | |
1679 | |
1680 | |
1681 /* | |
1682 * get key codes | |
1683 */ | |
1684 for (i = 0; key_names[i] != NULL; ++i) | |
1685 { | |
1686 if (find_termcode((char_u *)key_names[i]) == NULL) | |
1687 { | |
1688 p = TGETSTR(key_names[i], &tp); | |
1689 /* if cursor-left == backspace, ignore it (televideo | |
1690 * 925) */ | |
1691 if (p != NULL | |
1692 && (*p != Ctrl_H | |
1693 || key_names[i][0] != 'k' | |
1694 || key_names[i][1] != 'l')) | |
1695 add_termcode((char_u *)key_names[i], p, FALSE); | |
1696 } | |
1697 } | |
1698 | |
1699 if (height == 0) | |
1700 height = tgetnum("li"); | |
1701 if (width == 0) | |
1702 width = tgetnum("co"); | |
1703 | |
1704 /* | |
1705 * Get number of colors (if not done already). | |
1706 */ | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
10676
diff
changeset
|
1707 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
|
1708 || TERM_STR(KS_CCO) == empty_option) |
7 | 1709 set_color_count(tgetnum("Co")); |
1710 | |
1711 # ifndef hpux | |
1712 BC = (char *)TGETSTR("bc", &tp); | |
1713 UP = (char *)TGETSTR("up", &tp); | |
1714 p = TGETSTR("pc", &tp); | |
1715 if (p) | |
1716 PC = *p; | |
1717 # endif /* hpux */ | |
1718 } | |
1719 } | |
1720 else /* try == 0 || try == 2 */ | |
1721 #endif /* HAVE_TGETENT */ | |
1722 /* | |
1723 * Use builtin termcap | |
1724 */ | |
1725 { | |
1726 #ifdef HAVE_TGETENT | |
1727 /* | |
1728 * If builtin termcap was already used, there is no need to search | |
1729 * for the builtin termcap again, quit now. | |
1730 */ | |
1731 if (try == 2 && builtin_first && termcap_cleared) | |
1732 break; | |
1733 #endif | |
1734 /* | |
1735 * search for 'term' in builtin_termcaps[] | |
1736 */ | |
1737 termp = find_builtin_term(term); | |
1738 if (termp->bt_string == NULL) /* did not find it */ | |
1739 { | |
1740 #ifdef HAVE_TGETENT | |
1741 /* | |
1742 * If try == 0, first try the external termcap. If that is not | |
1743 * found we'll get back here with try == 2. | |
1744 * If termcap_cleared is set we used the external termcap, | |
1745 * don't complain about not finding the term in the builtin | |
1746 * termcap. | |
1747 */ | |
1748 if (try == 0) /* try external one */ | |
1749 continue; | |
1750 if (termcap_cleared) /* found in external termcap */ | |
1751 break; | |
1752 #endif | |
1753 | |
1754 mch_errmsg("\r\n"); | |
1755 if (error_msg != NULL) | |
1756 { | |
1757 mch_errmsg((char *)error_msg); | |
1758 mch_errmsg("\r\n"); | |
1759 } | |
1760 mch_errmsg("'"); | |
1761 mch_errmsg((char *)term); | |
1762 mch_errmsg(_("' not known. Available builtin terminals are:")); | |
1763 mch_errmsg("\r\n"); | |
1764 for (termp = &(builtin_termcaps[0]); termp->bt_string != NULL; | |
1765 ++termp) | |
1766 { | |
1767 if (termp->bt_entry == (int)KS_NAME) | |
1768 { | |
1769 #ifdef HAVE_TGETENT | |
1770 mch_errmsg(" builtin_"); | |
1771 #else | |
1772 mch_errmsg(" "); | |
1773 #endif | |
1774 mch_errmsg(termp->bt_string); | |
1775 mch_errmsg("\r\n"); | |
1776 } | |
1777 } | |
1778 /* when user typed :set term=xxx, quit here */ | |
1779 if (starting != NO_SCREEN) | |
1780 { | |
1781 screen_start(); /* don't know where cursor is now */ | |
1782 wait_return(TRUE); | |
1783 return FAIL; | |
1784 } | |
1785 term = DEFAULT_TERM; | |
1786 mch_errmsg(_("defaulting to '")); | |
1787 mch_errmsg((char *)term); | |
1788 mch_errmsg("'\r\n"); | |
1789 if (emsg_silent == 0) | |
1790 { | |
1791 screen_start(); /* don't know where cursor is now */ | |
1792 out_flush(); | |
11307
6e1c19d3de03
patch 8.0.0539: startup test fails on Mac
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1793 if (!is_not_a_term()) |
6e1c19d3de03
patch 8.0.0539: startup test fails on Mac
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1794 ui_delay(2000L, TRUE); |
7 | 1795 } |
694 | 1796 set_string_option_direct((char_u *)"term", -1, term, |
1797 OPT_FREE, 0); | |
7 | 1798 display_errors(); |
1799 } | |
1800 out_flush(); | |
1801 #ifdef HAVE_TGETENT | |
1802 if (!termcap_cleared) | |
1803 { | |
1804 #endif | |
1805 clear_termoptions(); /* clear old options */ | |
1806 #ifdef HAVE_TGETENT | |
1807 termcap_cleared = TRUE; | |
1808 } | |
1809 #endif | |
1810 parse_builtin_tcap(term); | |
1811 #ifdef FEAT_GUI | |
1812 if (term_is_gui(term)) | |
1813 { | |
1814 out_flush(); | |
1815 gui_init(); | |
1816 /* If starting the GUI failed, don't do any of the other | |
1817 * things for this terminal */ | |
1818 if (!gui.in_use) | |
1819 return FAIL; | |
1820 #ifdef HAVE_TGETENT | |
1821 break; /* don't try using external termcap */ | |
1822 #endif | |
1823 } | |
1824 #endif /* FEAT_GUI */ | |
1825 } | |
1826 #ifdef HAVE_TGETENT | |
1827 } | |
1828 #endif | |
1829 | |
1830 /* | |
1831 * special: There is no info in the termcap about whether the cursor | |
1832 * positioning is relative to the start of the screen or to the start of the | |
1833 * scrolling region. We just guess here. Only msdos pcterm is known to do it | |
1834 * relative. | |
1835 */ | |
1836 if (STRCMP(term, "pcterm") == 0) | |
1837 T_CCS = (char_u *)"yes"; | |
1838 else | |
1839 T_CCS = empty_option; | |
1840 | |
1841 #ifdef UNIX | |
1842 /* | |
1843 * Any "stty" settings override the default for t_kb from the termcap. | |
1844 * This is in os_unix.c, because it depends a lot on the version of unix that | |
1845 * is being used. | |
1846 * Don't do this when the GUI is active, it uses "t_kb" and "t_kD" directly. | |
1847 */ | |
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
|
1848 # ifdef FEAT_GUI |
7 | 1849 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
|
1850 # endif |
7 | 1851 get_stty(); |
1852 #endif | |
1853 | |
1854 /* | |
1855 * If the termcap has no entry for 'bs' and/or 'del' and the ioctl() also | |
1856 * didn't work, use the default CTRL-H | |
1857 * The default for t_kD is DEL, unless t_kb is DEL. | |
1858 * The vim_strsave'd strings are probably lost forever, well it's only two | |
1859 * bytes. Don't do this when the GUI is active, it uses "t_kb" and "t_kD" | |
1860 * directly. | |
1861 */ | |
1862 #ifdef FEAT_GUI | |
1863 if (!gui.in_use) | |
1864 #endif | |
1865 { | |
1866 bs_p = find_termcode((char_u *)"kb"); | |
1867 del_p = find_termcode((char_u *)"kD"); | |
1868 if (bs_p == NULL || *bs_p == NUL) | |
1869 add_termcode((char_u *)"kb", (bs_p = (char_u *)CTRL_H_STR), FALSE); | |
1870 if ((del_p == NULL || *del_p == NUL) && | |
1871 (bs_p == NULL || *bs_p != DEL)) | |
1872 add_termcode((char_u *)"kD", (char_u *)DEL_STR, FALSE); | |
1873 } | |
1874 | |
1875 #if defined(UNIX) || defined(VMS) | |
1876 term_is_xterm = vim_is_xterm(term); | |
1877 #endif | |
1878 | |
1879 #ifdef FEAT_MOUSE | |
1880 # if defined(UNIX) || defined(VMS) | |
1881 # ifdef FEAT_MOUSE_TTY | |
1882 /* | |
1883 * For Unix, set the 'ttymouse' option to the type of mouse to be used. | |
1884 * The termcode for the mouse is added as a side effect in option.c. | |
1885 */ | |
1886 { | |
11563
2547bbe6716e
patch 8.0.0664: mouse does not work in tmux
Christian Brabandt <cb@256bit.org>
parents:
11557
diff
changeset
|
1887 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
|
1888 |
7 | 1889 # ifdef FEAT_MOUSE_XTERM |
1623 | 1890 if (use_xterm_like_mouse(term)) |
7 | 1891 { |
1892 if (use_xterm_mouse()) | |
1893 p = NULL; /* keep existing value, might be "xterm2" */ | |
1894 else | |
1895 p = (char_u *)"xterm"; | |
1896 } | |
1897 # endif | |
1898 if (p != NULL) | |
3980 | 1899 { |
7 | 1900 set_option_value((char_u *)"ttym", 0L, p, 0); |
3980 | 1901 /* Reset the WAS_SET flag, 'ttymouse' can be set to "sgr" or |
1902 * "xterm2" in check_termcode(). */ | |
1903 reset_option_was_set((char_u *)"ttym"); | |
1904 } | |
7 | 1905 if (p == NULL |
1906 # ifdef FEAT_GUI | |
1907 || gui.in_use | |
1908 # endif | |
1909 ) | |
1910 check_mouse_termcode(); /* set mouse termcode anyway */ | |
1911 } | |
1912 # endif | |
1913 # else | |
1914 set_mouse_termcode(KS_MOUSE, (char_u *)"\233M"); | |
1915 # endif | |
1916 #endif /* FEAT_MOUSE */ | |
1917 | |
1918 #ifdef USE_TERM_CONSOLE | |
1919 /* DEFAULT_TERM indicates that it is the machine console. */ | |
1920 if (STRCMP(term, DEFAULT_TERM) != 0) | |
1921 term_console = FALSE; | |
1922 else | |
1923 { | |
1924 term_console = TRUE; | |
1925 # ifdef AMIGA | |
1926 win_resize_on(); /* enable window resizing reports */ | |
1927 # endif | |
1928 } | |
1929 #endif | |
1930 | |
1931 #if defined(UNIX) || defined(VMS) | |
1932 /* | |
1933 * 'ttyfast' is default on for xterm, iris-ansi and a few others. | |
1934 */ | |
1935 if (vim_is_fastterm(term)) | |
1936 p_tf = TRUE; | |
1937 #endif | |
1938 #ifdef USE_TERM_CONSOLE | |
1939 /* | |
1940 * 'ttyfast' is default on consoles | |
1941 */ | |
1942 if (term_console) | |
1943 p_tf = TRUE; | |
1944 #endif | |
1945 | |
1946 ttest(TRUE); /* make sure we have a valid set of terminal codes */ | |
1947 | |
1948 full_screen = TRUE; /* we can use termcap codes from now on */ | |
1949 set_term_defaults(); /* use current values as defaults */ | |
1950 #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
|
1951 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
|
1952 crv_status = STATUS_GET; /* Get terminal version later */ |
7 | 1953 #endif |
1954 | |
1955 /* | |
1956 * Initialize the terminal with the appropriate termcap codes. | |
1957 * Set the mouse and window title if possible. | |
1958 * Don't do this when starting, need to parse the .vimrc first, because it | |
1959 * may redefine t_TI etc. | |
1960 */ | |
1961 if (starting != NO_SCREEN) | |
1962 { | |
1963 starttermcap(); /* may change terminal mode */ | |
1964 #ifdef FEAT_MOUSE | |
1965 setmouse(); /* may start using the mouse */ | |
1966 #endif | |
1967 #ifdef FEAT_TITLE | |
1968 maketitle(); /* may display window title */ | |
1969 #endif | |
1970 } | |
1971 | |
1972 /* display initial screen after ttest() checking. jw. */ | |
1973 if (width <= 0 || height <= 0) | |
1974 { | |
1975 /* termcap failed to report size */ | |
1976 /* set defaults, in case ui_get_shellsize() also fails */ | |
1977 width = 80; | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
1978 #if defined(WIN3264) |
7 | 1979 height = 25; /* console is often 25 lines */ |
1980 #else | |
1981 height = 24; /* most terminals are 24 lines */ | |
1982 #endif | |
1983 } | |
1984 set_shellsize(width, height, FALSE); /* may change Rows */ | |
1985 if (starting != NO_SCREEN) | |
1986 { | |
1987 if (scroll_region) | |
1988 scroll_region_reset(); /* In case Rows changed */ | |
1989 check_map_keycodes(); /* check mappings for terminal codes used */ | |
1990 | |
1991 { | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9125
diff
changeset
|
1992 bufref_T old_curbuf; |
7 | 1993 |
1994 /* | |
1995 * Execute the TermChanged autocommands for each buffer that is | |
1996 * loaded. | |
1997 */ | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9125
diff
changeset
|
1998 set_bufref(&old_curbuf, curbuf); |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9628
diff
changeset
|
1999 FOR_ALL_BUFFERS(curbuf) |
7 | 2000 { |
2001 if (curbuf->b_ml.ml_mfp != NULL) | |
2002 apply_autocmds(EVENT_TERMCHANGED, NULL, NULL, FALSE, | |
2003 curbuf); | |
2004 } | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9125
diff
changeset
|
2005 if (bufref_valid(&old_curbuf)) |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9125
diff
changeset
|
2006 curbuf = old_curbuf.br_buf; |
7 | 2007 } |
2008 } | |
2009 | |
2010 #ifdef FEAT_TERMRESPONSE | |
2011 may_req_termresponse(); | |
2012 #endif | |
2013 | |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2014 #if defined(WIN3264) && !defined(FEAT_GUI) && defined(FEAT_TERMGUICOLORS) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2015 if (STRCMP(term, "win32") == 0) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2016 set_color_count((p_tgc) ? 256 : 16); |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2017 #endif |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2018 |
7 | 2019 return OK; |
2020 } | |
2021 | |
2022 #if defined(FEAT_MOUSE) || defined(PROTO) | |
2023 | |
2024 # ifdef FEAT_MOUSE_TTY | |
2025 # define HMT_NORMAL 1 | |
2026 # define HMT_NETTERM 2 | |
2027 # define HMT_DEC 4 | |
2028 # define HMT_JSBTERM 8 | |
2029 # define HMT_PTERM 16 | |
3176 | 2030 # define HMT_URXVT 32 |
3746 | 2031 # 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
|
2032 # define HMT_SGR_REL 128 |
7 | 2033 static int has_mouse_termcode = 0; |
2034 # endif | |
2035 | |
1623 | 2036 # if (!defined(UNIX) || defined(FEAT_MOUSE_TTY)) || defined(PROTO) |
7 | 2037 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2038 set_mouse_termcode( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2039 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
|
2040 char_u *s) |
7 | 2041 { |
2042 char_u name[2]; | |
2043 | |
2044 name[0] = n; | |
2045 name[1] = KE_FILLER; | |
2046 add_termcode(name, s, FALSE); | |
2047 # ifdef FEAT_MOUSE_TTY | |
2048 # ifdef FEAT_MOUSE_JSB | |
2049 if (n == KS_JSBTERM_MOUSE) | |
2050 has_mouse_termcode |= HMT_JSBTERM; | |
2051 else | |
2052 # endif | |
2053 # ifdef FEAT_MOUSE_NET | |
2054 if (n == KS_NETTERM_MOUSE) | |
2055 has_mouse_termcode |= HMT_NETTERM; | |
2056 else | |
2057 # endif | |
2058 # ifdef FEAT_MOUSE_DEC | |
2059 if (n == KS_DEC_MOUSE) | |
2060 has_mouse_termcode |= HMT_DEC; | |
2061 else | |
2062 # endif | |
2063 # ifdef FEAT_MOUSE_PTERM | |
2064 if (n == KS_PTERM_MOUSE) | |
2065 has_mouse_termcode |= HMT_PTERM; | |
2066 else | |
2067 # endif | |
3176 | 2068 # ifdef FEAT_MOUSE_URXVT |
2069 if (n == KS_URXVT_MOUSE) | |
2070 has_mouse_termcode |= HMT_URXVT; | |
2071 else | |
2072 # endif | |
3746 | 2073 # ifdef FEAT_MOUSE_SGR |
2074 if (n == KS_SGR_MOUSE) | |
2075 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
|
2076 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
|
2077 has_mouse_termcode |= HMT_SGR_REL; |
3746 | 2078 else |
2079 # endif | |
7 | 2080 has_mouse_termcode |= HMT_NORMAL; |
2081 # endif | |
2082 } | |
2083 # endif | |
2084 | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7307
diff
changeset
|
2085 # if ((defined(UNIX) || defined(VMS)) \ |
1623 | 2086 && defined(FEAT_MOUSE_TTY)) || defined(PROTO) |
7 | 2087 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2088 del_mouse_termcode( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2089 int n) /* KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE */ |
7 | 2090 { |
2091 char_u name[2]; | |
2092 | |
2093 name[0] = n; | |
2094 name[1] = KE_FILLER; | |
2095 del_termcode(name); | |
2096 # ifdef FEAT_MOUSE_TTY | |
2097 # ifdef FEAT_MOUSE_JSB | |
2098 if (n == KS_JSBTERM_MOUSE) | |
2099 has_mouse_termcode &= ~HMT_JSBTERM; | |
2100 else | |
2101 # endif | |
2102 # ifdef FEAT_MOUSE_NET | |
2103 if (n == KS_NETTERM_MOUSE) | |
2104 has_mouse_termcode &= ~HMT_NETTERM; | |
2105 else | |
2106 # endif | |
2107 # ifdef FEAT_MOUSE_DEC | |
2108 if (n == KS_DEC_MOUSE) | |
2109 has_mouse_termcode &= ~HMT_DEC; | |
2110 else | |
2111 # endif | |
2112 # ifdef FEAT_MOUSE_PTERM | |
2113 if (n == KS_PTERM_MOUSE) | |
2114 has_mouse_termcode &= ~HMT_PTERM; | |
2115 else | |
2116 # endif | |
3176 | 2117 # ifdef FEAT_MOUSE_URXVT |
2118 if (n == KS_URXVT_MOUSE) | |
2119 has_mouse_termcode &= ~HMT_URXVT; | |
2120 else | |
2121 # endif | |
3746 | 2122 # ifdef FEAT_MOUSE_SGR |
2123 if (n == KS_SGR_MOUSE) | |
2124 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
|
2125 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
|
2126 has_mouse_termcode &= ~HMT_SGR_REL; |
3746 | 2127 else |
2128 # endif | |
7 | 2129 has_mouse_termcode &= ~HMT_NORMAL; |
2130 # endif | |
2131 } | |
2132 # endif | |
2133 #endif | |
2134 | |
2135 #ifdef HAVE_TGETENT | |
2136 /* | |
2137 * Call tgetent() | |
2138 * Return error message if it fails, NULL if it's OK. | |
2139 */ | |
2140 static char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2141 tgetent_error(char_u *tbuf, char_u *term) |
7 | 2142 { |
2143 int i; | |
2144 | |
2145 i = TGETENT(tbuf, term); | |
2146 if (i < 0 /* -1 is always an error */ | |
2147 # ifdef TGETENT_ZERO_ERR | |
2148 || i == 0 /* sometimes zero is also an error */ | |
2149 # endif | |
2150 ) | |
2151 { | |
2152 /* On FreeBSD tputs() gets a SEGV after a tgetent() which fails. Call | |
2153 * tgetent() with the always existing "dumb" entry to avoid a crash or | |
2154 * hang. */ | |
2155 (void)TGETENT(tbuf, "dumb"); | |
2156 | |
2157 if (i < 0) | |
2158 # ifdef TGETENT_ZERO_ERR | |
2159 return (char_u *)_("E557: Cannot open termcap file"); | |
2160 if (i == 0) | |
2161 # endif | |
2162 #ifdef TERMINFO | |
2163 return (char_u *)_("E558: Terminal entry not found in terminfo"); | |
2164 #else | |
2165 return (char_u *)_("E559: Terminal entry not found in termcap"); | |
2166 #endif | |
2167 } | |
2168 return NULL; | |
2169 } | |
2170 | |
2171 /* | |
2172 * Some versions of tgetstr() have been reported to return -1 instead of NULL. | |
2173 * Fix that here. | |
2174 */ | |
2175 static char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2176 vim_tgetstr(char *s, char_u **pp) |
7 | 2177 { |
2178 char *p; | |
2179 | |
2180 p = tgetstr(s, (char **)pp); | |
2181 if (p == (char *)-1) | |
2182 p = NULL; | |
2183 return (char_u *)p; | |
2184 } | |
2185 #endif /* HAVE_TGETENT */ | |
2186 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
2187 #if defined(HAVE_TGETENT) && (defined(UNIX) || defined(VMS) || defined(MACOS_X)) |
7 | 2188 /* |
2189 * Get Columns and Rows from the termcap. Used after a window signal if the | |
2190 * ioctl() fails. It doesn't make sense to call tgetent each time if the "co" | |
2191 * and "li" entries never change. But on some systems this works. | |
2192 * Errors while getting the entries are ignored. | |
2193 */ | |
2194 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2195 getlinecol( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2196 long *cp, /* pointer to columns */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2197 long *rp) /* pointer to rows */ |
7 | 2198 { |
2199 char_u tbuf[TBUFSZ]; | |
2200 | |
2201 if (T_NAME != NULL && *T_NAME != NUL && tgetent_error(tbuf, T_NAME) == NULL) | |
2202 { | |
2203 if (*cp == 0) | |
2204 *cp = tgetnum("co"); | |
2205 if (*rp == 0) | |
2206 *rp = tgetnum("li"); | |
2207 } | |
2208 } | |
2209 #endif /* defined(HAVE_TGETENT) && defined(UNIX) */ | |
2210 | |
2211 /* | |
2212 * Get a string entry from the termcap and add it to the list of termcodes. | |
2213 * Used for <t_xx> special keys. | |
2214 * Give an error message for failure when not sourcing. | |
2215 * If force given, replace an existing entry. | |
2216 * Return FAIL if the entry was not found, OK if the entry was added. | |
2217 */ | |
2218 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2219 add_termcap_entry(char_u *name, int force) |
7 | 2220 { |
2221 char_u *term; | |
2222 int key; | |
2223 struct builtin_term *termp; | |
2224 #ifdef HAVE_TGETENT | |
2225 char_u *string; | |
2226 int i; | |
2227 int builtin_first; | |
2228 char_u tbuf[TBUFSZ]; | |
2229 char_u tstrbuf[TBUFSZ]; | |
2230 char_u *tp = tstrbuf; | |
2231 char_u *error_msg = NULL; | |
2232 #endif | |
2233 | |
2234 /* | |
2235 * If the GUI is running or will start in a moment, we only support the keys | |
2236 * that the GUI can produce. | |
2237 */ | |
2238 #ifdef FEAT_GUI | |
2239 if (gui.in_use || gui.starting) | |
2240 return gui_mch_haskey(name); | |
2241 #endif | |
2242 | |
2243 if (!force && find_termcode(name) != NULL) /* it's already there */ | |
2244 return OK; | |
2245 | |
2246 term = T_NAME; | |
2247 if (term == NULL || *term == NUL) /* 'term' not defined yet */ | |
2248 return FAIL; | |
2249 | |
2250 if (term_is_builtin(term)) /* name starts with "builtin_" */ | |
2251 { | |
2252 term += 8; | |
2253 #ifdef HAVE_TGETENT | |
2254 builtin_first = TRUE; | |
2255 #endif | |
2256 } | |
2257 #ifdef HAVE_TGETENT | |
2258 else | |
2259 builtin_first = p_tbi; | |
2260 #endif | |
2261 | |
2262 #ifdef HAVE_TGETENT | |
2263 /* | |
2264 * We can get the entry from the builtin termcap and from the external one. | |
2265 * If 'ttybuiltin' is on or the terminal name starts with "builtin_", try | |
2266 * builtin termcap first. | |
2267 * If 'ttybuiltin' is off, try external termcap first. | |
2268 */ | |
2269 for (i = 0; i < 2; ++i) | |
2270 { | |
7210
08b50e436093
commit https://github.com/vim/vim/commit/98b30a473a58ae98c280e0383c8b1e08c0ebced5
Christian Brabandt <cb@256bit.org>
parents:
6901
diff
changeset
|
2271 if ((!builtin_first) == i) |
7 | 2272 #endif |
2273 /* | |
2274 * Search in builtin termcap | |
2275 */ | |
2276 { | |
2277 termp = find_builtin_term(term); | |
2278 if (termp->bt_string != NULL) /* found it */ | |
2279 { | |
2280 key = TERMCAP2KEY(name[0], name[1]); | |
2281 while (termp->bt_entry != (int)KS_NAME) | |
2282 { | |
2283 if ((int)termp->bt_entry == key) | |
2284 { | |
2285 add_termcode(name, (char_u *)termp->bt_string, | |
2286 term_is_8bit(term)); | |
2287 return OK; | |
2288 } | |
2289 ++termp; | |
2290 } | |
2291 } | |
2292 } | |
2293 #ifdef HAVE_TGETENT | |
2294 else | |
2295 /* | |
2296 * Search in external termcap | |
2297 */ | |
2298 { | |
2299 error_msg = tgetent_error(tbuf, term); | |
2300 if (error_msg == NULL) | |
2301 { | |
2302 string = TGETSTR((char *)name, &tp); | |
2303 if (string != NULL && *string != NUL) | |
2304 { | |
2305 add_termcode(name, string, FALSE); | |
2306 return OK; | |
2307 } | |
2308 } | |
2309 } | |
2310 } | |
2311 #endif | |
2312 | |
2313 if (sourcing_name == NULL) | |
2314 { | |
2315 #ifdef HAVE_TGETENT | |
2316 if (error_msg != NULL) | |
2317 EMSG(error_msg); | |
2318 else | |
2319 #endif | |
2320 EMSG2(_("E436: No \"%s\" entry in termcap"), name); | |
2321 } | |
2322 return FAIL; | |
2323 } | |
2324 | |
2325 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2326 term_is_builtin(char_u *name) |
7 | 2327 { |
2328 return (STRNCMP(name, "builtin_", (size_t)8) == 0); | |
2329 } | |
2330 | |
2331 /* | |
2332 * Return TRUE if terminal "name" uses CSI instead of <Esc>[. | |
2333 * Assume that the terminal is using 8-bit controls when the name contains | |
2334 * "8bit", like in "xterm-8bit". | |
2335 */ | |
2336 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2337 term_is_8bit(char_u *name) |
7 | 2338 { |
2339 return (detected_8bit || strstr((char *)name, "8bit") != NULL); | |
2340 } | |
2341 | |
2342 /* | |
2343 * 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
|
2344 * <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
|
2345 * <Esc>] -> OSC <M-C-]> |
7 | 2346 * <Esc>O -> <M-C-O> |
2347 */ | |
2348 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2349 term_7to8bit(char_u *p) |
7 | 2350 { |
2351 if (*p == ESC) | |
2352 { | |
2353 if (p[1] == '[') | |
2354 return CSI; | |
2355 if (p[1] == ']') | |
6901 | 2356 return OSC; |
7 | 2357 if (p[1] == 'O') |
2358 return 0x8f; | |
2359 } | |
2360 return 0; | |
2361 } | |
2362 | |
2363 #ifdef FEAT_GUI | |
2364 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2365 term_is_gui(char_u *name) |
7 | 2366 { |
2367 return (STRCMP(name, "builtin_gui") == 0 || STRCMP(name, "gui") == 0); | |
2368 } | |
2369 #endif | |
2370 | |
2371 #if !defined(HAVE_TGETENT) || defined(AMIGA) || defined(PROTO) | |
2372 | |
2373 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2374 tltoa(unsigned long i) |
7 | 2375 { |
2376 static char_u buf[16]; | |
2377 char_u *p; | |
2378 | |
2379 p = buf + 15; | |
2380 *p = '\0'; | |
2381 do | |
2382 { | |
2383 --p; | |
2384 *p = (char_u) (i % 10 + '0'); | |
2385 i /= 10; | |
2386 } | |
2387 while (i > 0 && p > buf); | |
2388 return p; | |
2389 } | |
2390 #endif | |
2391 | |
2392 #ifndef HAVE_TGETENT | |
2393 | |
2394 /* | |
2395 * minimal tgoto() implementation. | |
2396 * no padding and we only parse for %i %d and %+char | |
2397 */ | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
2398 static char *tgoto(char *, int, int); |
298 | 2399 |
2400 static char * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2401 tgoto(char *cm, int x, int y) |
7 | 2402 { |
2403 static char buf[30]; | |
2404 char *p, *s, *e; | |
2405 | |
2406 if (!cm) | |
2407 return "OOPS"; | |
2408 e = buf + 29; | |
2409 for (s = buf; s < e && *cm; cm++) | |
2410 { | |
2411 if (*cm != '%') | |
2412 { | |
2413 *s++ = *cm; | |
2414 continue; | |
2415 } | |
2416 switch (*++cm) | |
2417 { | |
2418 case 'd': | |
2419 p = (char *)tltoa((unsigned long)y); | |
2420 y = x; | |
2421 while (*p) | |
2422 *s++ = *p++; | |
2423 break; | |
2424 case 'i': | |
2425 x++; | |
2426 y++; | |
2427 break; | |
2428 case '+': | |
2429 *s++ = (char)(*++cm + y); | |
2430 y = x; | |
2431 break; | |
2432 case '%': | |
2433 *s++ = *cm; | |
2434 break; | |
2435 default: | |
2436 return "OOPS"; | |
2437 } | |
2438 } | |
2439 *s = '\0'; | |
2440 return buf; | |
2441 } | |
2442 | |
2443 #endif /* HAVE_TGETENT */ | |
2444 | |
2445 /* | |
2446 * Set the terminal name and initialize the terminal options. | |
2447 * If "name" is NULL or empty, get the terminal name from the environment. | |
2448 * If that fails, use the default terminal name. | |
2449 */ | |
2450 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2451 termcapinit(char_u *name) |
7 | 2452 { |
2453 char_u *term; | |
2454 | |
2455 if (name != NULL && *name == NUL) | |
2456 name = NULL; /* empty name is equal to no name */ | |
2457 term = name; | |
2458 | |
2459 #ifdef __BEOS__ | |
2460 /* | |
2461 * TERM environment variable is normally set to 'ansi' on the Bebox; | |
2462 * Since the BeBox doesn't quite support full ANSI yet, we use our | |
2463 * own custom 'ansi-beos' termcap instead, unless the -T option has | |
2464 * been given on the command line. | |
2465 */ | |
2466 if (term == NULL | |
2467 && strcmp((char *)mch_getenv((char_u *)"TERM"), "ansi") == 0) | |
2468 term = DEFAULT_TERM; | |
2469 #endif | |
2470 #ifndef MSWIN | |
2471 if (term == NULL) | |
2472 term = mch_getenv((char_u *)"TERM"); | |
2473 #endif | |
2474 if (term == NULL || *term == NUL) | |
2475 term = DEFAULT_TERM; | |
694 | 2476 set_string_option_direct((char_u *)"term", -1, term, OPT_FREE, 0); |
7 | 2477 |
2478 /* Set the default terminal name. */ | |
2479 set_string_default("term", term); | |
2480 set_string_default("ttytype", term); | |
2481 | |
2482 /* | |
2483 * Avoid using "term" here, because the next mch_getenv() may overwrite it. | |
2484 */ | |
2485 set_termname(T_NAME != NULL ? T_NAME : term); | |
2486 } | |
2487 | |
2488 /* | |
2489 * the number of calls to ui_write is reduced by using the buffer "out_buf" | |
2490 */ | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
2491 #define OUT_SIZE 2047 |
7 | 2492 /* Add one to allow mch_write() in os_win32.c to append a NUL */ |
2493 static char_u out_buf[OUT_SIZE + 1]; | |
2494 static int out_pos = 0; /* number of chars in out_buf */ | |
2495 | |
2496 /* | |
2497 * out_flush(): flush the output buffer | |
2498 */ | |
2499 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2500 out_flush(void) |
7 | 2501 { |
2502 int len; | |
2503 | |
2504 if (out_pos != 0) | |
2505 { | |
2506 /* set out_pos to 0 before ui_write, to avoid recursiveness */ | |
2507 len = out_pos; | |
2508 out_pos = 0; | |
2509 ui_write(out_buf, len); | |
2510 } | |
2511 } | |
2512 | |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2513 /* |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
2514 * out_flush_cursor(): flush the output buffer and redraw the cursor. |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
2515 * Does not flush recursively in the GUI to avoid slow drawing. |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2516 */ |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2517 void |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2518 out_flush_cursor( |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2519 int force UNUSED, /* when TRUE, update cursor even when not moved */ |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2520 int clear_selection UNUSED) /* clear selection under cursor */ |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2521 { |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2522 mch_disable_flush(); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2523 out_flush(); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2524 mch_enable_flush(); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2525 #ifdef FEAT_GUI |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2526 if (gui.in_use) |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2527 { |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2528 gui_update_cursor(force, clear_selection); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2529 gui_may_flush(); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2530 } |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2531 #endif |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2532 } |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2533 |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2534 |
7 | 2535 #if defined(FEAT_MBYTE) || defined(PROTO) |
2536 /* | |
2537 * Sometimes a byte out of a multi-byte character is written with out_char(). | |
2538 * To avoid flushing half of the character, call this function first. | |
2539 */ | |
2540 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2541 out_flush_check(void) |
7 | 2542 { |
2543 if (enc_dbcs != 0 && out_pos >= OUT_SIZE - MB_MAXBYTES) | |
2544 out_flush(); | |
2545 } | |
2546 #endif | |
2547 | |
2548 #ifdef FEAT_GUI | |
2549 /* | |
2550 * out_trash(): Throw away the contents of the output buffer | |
2551 */ | |
2552 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2553 out_trash(void) |
7 | 2554 { |
2555 out_pos = 0; | |
2556 } | |
2557 #endif | |
2558 | |
2559 /* | |
2560 * out_char(c): put a byte into the output buffer. | |
2561 * Flush it if it becomes full. | |
2562 * This should not be used for outputting text on the screen (use functions | |
2563 * like msg_puts() and screen_putchar() for that). | |
2564 */ | |
2565 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2566 out_char(unsigned c) |
7 | 2567 { |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12640
diff
changeset
|
2568 #if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(MACOS_X) |
7 | 2569 if (c == '\n') /* turn LF into CR-LF (CRMOD doesn't seem to do this) */ |
2570 out_char('\r'); | |
2571 #endif | |
2572 | |
2573 out_buf[out_pos++] = c; | |
2574 | |
2575 /* For testing we flush each time. */ | |
2576 if (out_pos >= OUT_SIZE || p_wd) | |
2577 out_flush(); | |
2578 } | |
2579 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
2580 static void out_char_nf(unsigned); |
7 | 2581 |
2582 /* | |
2583 * out_char_nf(c): like out_char(), but don't flush when p_wd is set | |
2584 */ | |
2585 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2586 out_char_nf(unsigned c) |
7 | 2587 { |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12640
diff
changeset
|
2588 #if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(MACOS_X) |
7 | 2589 if (c == '\n') /* turn LF into CR-LF (CRMOD doesn't seem to do this) */ |
2590 out_char_nf('\r'); | |
2591 #endif | |
2592 | |
2593 out_buf[out_pos++] = c; | |
2594 | |
2595 if (out_pos >= OUT_SIZE) | |
2596 out_flush(); | |
2597 } | |
2598 | |
2237
770485470e59
Add a few #ifdefs to exclude functions that are not used. (Domnique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
1941
diff
changeset
|
2599 #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
|
2600 || defined(FEAT_TERMRESPONSE) || defined(PROTO) |
7 | 2601 /* |
2602 * A never-padding out_str. | |
2603 * use this whenever you don't want to run the string through tputs. | |
2604 * tputs above is harmless, but tputs from the termcap library | |
2605 * is likely to strip off leading digits, that it mistakes for padding | |
2606 * information, and "%i", "%d", etc. | |
2607 * This should only be used for writing terminal codes, not for outputting | |
2608 * normal text (use functions like msg_puts() and screen_putchar() for that). | |
2609 */ | |
2610 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2611 out_str_nf(char_u *s) |
7 | 2612 { |
2613 if (out_pos > OUT_SIZE - 20) /* avoid terminal strings being split up */ | |
2614 out_flush(); | |
2615 while (*s) | |
2616 out_char_nf(*s++); | |
2617 | |
2618 /* For testing we write one string at a time. */ | |
2619 if (p_wd) | |
2620 out_flush(); | |
2621 } | |
2237
770485470e59
Add a few #ifdefs to exclude functions that are not used. (Domnique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
1941
diff
changeset
|
2622 #endif |
7 | 2623 |
2624 /* | |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2625 * 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
|
2626 * 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
|
2627 * it at the wrong time. |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2628 * Note: Only for terminal strings. |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2629 */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2630 void |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2631 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
|
2632 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2633 if (s != NULL && *s) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2634 { |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2635 #ifdef HAVE_TGETENT |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2636 char_u *p; |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2637 #endif |
11601
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 #ifdef FEAT_GUI |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2640 /* 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
|
2641 if (gui.in_use) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2642 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2643 out_str_nf(s); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2644 return; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2645 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2646 #endif |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2647 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
|
2648 out_flush(); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2649 #ifdef HAVE_TGETENT |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2650 for (p = s; *s; ++s) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2651 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2652 /* flush just before delay command */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2653 if (*s == '$' && *(s + 1) == '<') |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2654 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2655 char_u save_c = *s; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2656 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
|
2657 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2658 *s = NUL; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2659 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
|
2660 *s = save_c; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2661 out_flush(); |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2662 # ifdef ELAPSED_FUNC |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2663 /* 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
|
2664 * vim_beep(). */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2665 p = vim_strchr(s, '>'); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2666 if (p == NULL || duration <= 0) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2667 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2668 /* 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
|
2669 p = s; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2670 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2671 else |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2672 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2673 ++p; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2674 do_sleep(duration); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2675 } |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2676 # else |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2677 /* 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
|
2678 p = s; |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2679 # endif |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2680 break; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2681 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2682 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2683 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
|
2684 #else |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2685 while (*s) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2686 out_char_nf(*s++); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2687 #endif |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2688 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2689 /* 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
|
2690 if (p_wd) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2691 out_flush(); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2692 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2693 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2694 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2695 /* |
7 | 2696 * out_str(s): Put a character string a byte at a time into the output buffer. |
2697 * If HAVE_TGETENT is defined use the termcap parser. (jw) | |
2698 * This should only be used for writing terminal codes, not for outputting | |
2699 * normal text (use functions like msg_puts() and screen_putchar() for that). | |
2700 */ | |
2701 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2702 out_str(char_u *s) |
7 | 2703 { |
2704 if (s != NULL && *s) | |
2705 { | |
2706 #ifdef FEAT_GUI | |
2707 /* Don't use tputs() when GUI is used, ncurses crashes. */ | |
2708 if (gui.in_use) | |
2709 { | |
2710 out_str_nf(s); | |
2711 return; | |
2712 } | |
2713 #endif | |
2714 /* avoid terminal strings being split up */ | |
2715 if (out_pos > OUT_SIZE - 20) | |
2716 out_flush(); | |
2717 #ifdef HAVE_TGETENT | |
2718 tputs((char *)s, 1, TPUTSFUNCAST out_char_nf); | |
2719 #else | |
2720 while (*s) | |
2721 out_char_nf(*s++); | |
2722 #endif | |
2723 | |
2724 /* For testing we write one string at a time. */ | |
2725 if (p_wd) | |
2726 out_flush(); | |
2727 } | |
2728 } | |
2729 | |
2730 /* | |
2731 * cursor positioning using termcap parser. (jw) | |
2732 */ | |
2733 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2734 term_windgoto(int row, int col) |
7 | 2735 { |
2736 OUT_STR(tgoto((char *)T_CM, col, row)); | |
2737 } | |
2738 | |
2739 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2740 term_cursor_right(int i) |
7 | 2741 { |
2742 OUT_STR(tgoto((char *)T_CRI, 0, i)); | |
2743 } | |
2744 | |
2745 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2746 term_append_lines(int line_count) |
7 | 2747 { |
2748 OUT_STR(tgoto((char *)T_CAL, 0, line_count)); | |
2749 } | |
2750 | |
2751 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2752 term_delete_lines(int line_count) |
7 | 2753 { |
2754 OUT_STR(tgoto((char *)T_CDL, 0, line_count)); | |
2755 } | |
2756 | |
2757 #if defined(HAVE_TGETENT) || defined(PROTO) | |
2758 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2759 term_set_winpos(int x, int y) |
7 | 2760 { |
2761 /* Can't handle a negative value here */ | |
2762 if (x < 0) | |
2763 x = 0; | |
2764 if (y < 0) | |
2765 y = 0; | |
2766 OUT_STR(tgoto((char *)T_CWP, y, x)); | |
2767 } | |
2768 | |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2769 # 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
|
2770 /* |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2771 * 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
|
2772 */ |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2773 static int |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2774 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
|
2775 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2776 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
|
2777 && termcap_active |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2778 # ifdef UNIX |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2779 && (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
|
2780 # endif |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2781 && p_ek; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2782 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2783 |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2784 static int winpos_x = -1; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2785 static int winpos_y = -1; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2786 static int did_request_winpos = 0; |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2787 |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2788 /* |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2789 * 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
|
2790 * 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
|
2791 */ |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2792 int |
13379
0f9dd1b43244
patch 8.0.1563: timeout of getwinposx() can be too short
Christian Brabandt <cb@256bit.org>
parents:
13365
diff
changeset
|
2793 term_get_winpos(int *x, int *y, varnumber_T timeout) |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2794 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2795 int count = 0; |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2796 int prev_winpos_x = winpos_x; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2797 int prev_winpos_y = winpos_y; |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2798 |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2799 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
|
2800 return FAIL; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2801 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
|
2802 winpos_y = -1; |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2803 ++did_request_winpos; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2804 winpos_status = STATUS_SENT; |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2805 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
|
2806 out_flush(); |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2807 |
13379
0f9dd1b43244
patch 8.0.1563: timeout of getwinposx() can be too short
Christian Brabandt <cb@256bit.org>
parents:
13365
diff
changeset
|
2808 /* Try reading the result for "timeout" msec. */ |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2809 while (count++ <= timeout / 10 && !got_int) |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2810 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2811 (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
|
2812 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
|
2813 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2814 *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
|
2815 *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
|
2816 return OK; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2817 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2818 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
|
2819 } |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2820 /* Do not reset "did_request_winpos", if we timed out the response might |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2821 * still come later and we must consume it. */ |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2822 |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2823 winpos_x = prev_winpos_x; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2824 winpos_y = prev_winpos_y; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2825 if (timeout < 10 && prev_winpos_y >= 0 && prev_winpos_y >= 0) |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2826 { |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2827 /* Polling: return previous values if we have them. */ |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2828 *x = winpos_x; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2829 *y = winpos_y; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2830 return OK; |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2831 } |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2832 |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2833 return FALSE; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2834 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2835 # endif |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2836 |
7 | 2837 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
|
2838 term_set_winsize(int height, int width) |
7 | 2839 { |
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
|
2840 OUT_STR(tgoto((char *)T_CWS, width, height)); |
7 | 2841 } |
2842 #endif | |
2843 | |
2844 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2845 term_color(char_u *s, int n) |
7 | 2846 { |
2847 char buf[20]; | |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2848 int i = *s == CSI ? 1 : 2; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2849 /* index in s[] just after <Esc>[ or CSI */ |
7 | 2850 |
2851 /* Special handling of 16 colors, because termcap can't handle it */ | |
2852 /* Also accept "\e[3%dm" for TERMINFO, it is sometimes used */ | |
2853 /* Also accept CSI instead of <Esc>[ */ | |
2854 if (n >= 8 && t_colors >= 16 | |
2855 && ((s[0] == ESC && s[1] == '[') || (s[0] == CSI && (i = 1) == 1)) | |
2856 && s[i] != NUL | |
2857 && (STRCMP(s + i + 1, "%p1%dm") == 0 | |
2858 || STRCMP(s + i + 1, "%dm") == 0) | |
2859 && (s[i] == '3' || s[i] == '4')) | |
2860 { | |
2861 #ifdef TERMINFO | |
9068
0a3bc9fdea20
commit https://github.com/vim/vim/commit/827b165b2aebad2cfe98cc6d5804c6c0fe8afd89
Christian Brabandt <cb@256bit.org>
parents:
9027
diff
changeset
|
2862 char *format = "%s%s%%p1%%dm"; |
7 | 2863 #else |
9068
0a3bc9fdea20
commit https://github.com/vim/vim/commit/827b165b2aebad2cfe98cc6d5804c6c0fe8afd89
Christian Brabandt <cb@256bit.org>
parents:
9027
diff
changeset
|
2864 char *format = "%s%s%%dm"; |
7 | 2865 #endif |
9068
0a3bc9fdea20
commit https://github.com/vim/vim/commit/827b165b2aebad2cfe98cc6d5804c6c0fe8afd89
Christian Brabandt <cb@256bit.org>
parents:
9027
diff
changeset
|
2866 sprintf(buf, format, |
7 | 2867 i == 2 ? IF_EB("\033[", ESC_STR "[") : "\233", |
2868 s[i] == '3' ? (n >= 16 ? "38;5;" : "9") | |
2869 : (n >= 16 ? "48;5;" : "10")); | |
2870 OUT_STR(tgoto(buf, 0, n >= 16 ? n : n - 8)); | |
2871 } | |
2872 else | |
2873 OUT_STR(tgoto((char *)s, 0, n)); | |
2874 } | |
2875 | |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2876 void |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2877 term_fg_color(int n) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2878 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2879 /* Use "AF" termcap entry if present, "Sf" entry otherwise */ |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2880 if (*T_CAF) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2881 term_color(T_CAF, n); |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2882 else if (*T_CSF) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2883 term_color(T_CSF, n); |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2884 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2885 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2886 void |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2887 term_bg_color(int n) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2888 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2889 /* Use "AB" termcap entry if present, "Sb" entry otherwise */ |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2890 if (*T_CAB) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2891 term_color(T_CAB, n); |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2892 else if (*T_CSB) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2893 term_color(T_CSB, n); |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2894 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2895 |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
2896 #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
|
2897 |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2898 #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
|
2899 #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
|
2900 #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
|
2901 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2902 static void |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2903 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
|
2904 { |
8975
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
2905 #define MAX_COLOR_STR_LEN 100 |
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
2906 char buf[MAX_COLOR_STR_LEN]; |
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
2907 |
8981
3b51b0aeb9a3
commit https://github.com/vim/vim/commit/a1c487eef71d1673e57511453009de9cb4c9af51
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
2908 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
|
2909 (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
|
2910 OUT_STR(buf); |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2911 } |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2912 |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2913 void |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2914 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
|
2915 { |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2916 term_rgb_color(T_8F, rgb); |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2917 } |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2918 |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2919 void |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2920 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
|
2921 { |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2922 term_rgb_color(T_8B, rgb); |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2923 } |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2924 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2925 |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7307
diff
changeset
|
2926 #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
|
2927 || defined(MACOS_X))) || defined(PROTO) |
7 | 2928 /* |
2929 * Generic function to set window title, using t_ts and t_fs. | |
2930 */ | |
2931 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2932 term_settitle(char_u *title) |
7 | 2933 { |
2934 /* t_ts takes one argument: column in status line */ | |
2935 OUT_STR(tgoto((char *)T_TS, 0, 0)); /* set title start */ | |
2936 out_str_nf(title); | |
2937 out_str(T_FS); /* set title end */ | |
2938 out_flush(); | |
2939 } | |
2940 #endif | |
2941 | |
2942 /* | |
2943 * Make sure we have a valid set or terminal options. | |
2944 * Replace all entries that are NULL by empty_option | |
2945 */ | |
2946 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2947 ttest(int pairs) |
7 | 2948 { |
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
|
2949 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
|
2950 |
7 | 2951 check_options(); /* make sure no options are NULL */ |
2952 | |
2953 /* | |
2954 * MUST have "cm": cursor motion. | |
2955 */ | |
2956 if (*T_CM == NUL) | |
2957 EMSG(_("E437: terminal capability \"cm\" required")); | |
2958 | |
2959 /* | |
2960 * if "cs" defined, use a scroll region, it's faster. | |
2961 */ | |
2962 if (*T_CS != NUL) | |
2963 scroll_region = TRUE; | |
2964 else | |
2965 scroll_region = FALSE; | |
2966 | |
2967 if (pairs) | |
2968 { | |
2969 /* | |
2970 * optional pairs | |
2971 */ | |
2972 /* TP goes to normal mode for TI (invert) and TB (bold) */ | |
2973 if (*T_ME == NUL) | |
2974 T_ME = T_MR = T_MD = T_MB = empty_option; | |
2975 if (*T_SO == NUL || *T_SE == NUL) | |
2976 T_SO = T_SE = empty_option; | |
2977 if (*T_US == NUL || *T_UE == NUL) | |
2978 T_US = T_UE = empty_option; | |
2979 if (*T_CZH == NUL || *T_CZR == NUL) | |
2980 T_CZH = T_CZR = empty_option; | |
2981 | |
2982 /* T_VE is needed even though T_VI is not defined */ | |
2983 if (*T_VE == NUL) | |
2984 T_VI = empty_option; | |
2985 | |
2986 /* if 'mr' or 'me' is not defined use 'so' and 'se' */ | |
2987 if (*T_ME == NUL) | |
2988 { | |
2989 T_ME = T_SE; | |
2990 T_MR = T_SO; | |
2991 T_MD = T_SO; | |
2992 } | |
2993 | |
2994 /* if 'so' or 'se' is not defined use 'mr' and 'me' */ | |
2995 if (*T_SO == NUL) | |
2996 { | |
2997 T_SE = T_ME; | |
2998 if (*T_MR == NUL) | |
2999 T_SO = T_MD; | |
3000 else | |
3001 T_SO = T_MR; | |
3002 } | |
3003 | |
3004 /* if 'ZH' or 'ZR' is not defined use 'mr' and 'me' */ | |
3005 if (*T_CZH == NUL) | |
3006 { | |
3007 T_CZR = T_ME; | |
3008 if (*T_MR == NUL) | |
3009 T_CZH = T_MD; | |
3010 else | |
3011 T_CZH = T_MR; | |
3012 } | |
3013 | |
3014 /* "Sb" and "Sf" come in pairs */ | |
3015 if (*T_CSB == NUL || *T_CSF == NUL) | |
3016 { | |
3017 T_CSB = empty_option; | |
3018 T_CSF = empty_option; | |
3019 } | |
3020 | |
3021 /* "AB" and "AF" come in pairs */ | |
3022 if (*T_CAB == NUL || *T_CAF == NUL) | |
3023 { | |
3024 T_CAB = empty_option; | |
3025 T_CAF = empty_option; | |
3026 } | |
3027 | |
3028 /* if 'Sb' and 'AB' are not defined, reset "Co" */ | |
3029 if (*T_CSB == NUL && *T_CAB == NUL) | |
1941 | 3030 free_one_termoption(T_CCO); |
7 | 3031 |
3032 /* Set 'weirdinvert' according to value of 't_xs' */ | |
3033 p_wiv = (*T_XS != NUL); | |
3034 } | |
3035 need_gather = TRUE; | |
3036 | |
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
|
3037 /* Set t_colors to the value of $COLORS or t_Co. */ |
7 | 3038 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
|
3039 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
|
3040 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
|
3041 { |
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
|
3042 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
|
3043 |
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
|
3044 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
|
3045 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
|
3046 } |
7 | 3047 } |
3048 | |
3049 #if (defined(FEAT_GUI) && (defined(FEAT_MENU) || !defined(USE_ON_FLY_SCROLL))) \ | |
3050 || defined(PROTO) | |
3051 /* | |
3052 * Represent the given long_u as individual bytes, with the most significant | |
3053 * byte first, and store them in dst. | |
3054 */ | |
3055 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3056 add_long_to_buf(long_u val, char_u *dst) |
7 | 3057 { |
3058 int i; | |
3059 int shift; | |
3060 | |
1883 | 3061 for (i = 1; i <= (int)sizeof(long_u); i++) |
7 | 3062 { |
3063 shift = 8 * (sizeof(long_u) - i); | |
3064 dst[i - 1] = (char_u) ((val >> shift) & 0xff); | |
3065 } | |
3066 } | |
3067 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
3068 static int get_long_from_buf(char_u *buf, long_u *val); |
7 | 3069 |
3070 /* | |
3071 * Interpret the next string of bytes in buf as a long integer, with the most | |
3072 * significant byte first. Note that it is assumed that buf has been through | |
3073 * inchar(), so that NUL and K_SPECIAL will be represented as three bytes each. | |
3074 * Puts result in val, and returns the number of bytes read from buf | |
3075 * (between sizeof(long_u) and 2 * sizeof(long_u)), or -1 if not enough bytes | |
3076 * were present. | |
3077 */ | |
3078 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3079 get_long_from_buf(char_u *buf, long_u *val) |
7 | 3080 { |
3081 int len; | |
3082 char_u bytes[sizeof(long_u)]; | |
3083 int i; | |
3084 int shift; | |
3085 | |
3086 *val = 0; | |
3087 len = get_bytes_from_buf(buf, bytes, (int)sizeof(long_u)); | |
3088 if (len != -1) | |
3089 { | |
1883 | 3090 for (i = 0; i < (int)sizeof(long_u); i++) |
7 | 3091 { |
3092 shift = 8 * (sizeof(long_u) - 1 - i); | |
3093 *val += (long_u)bytes[i] << shift; | |
3094 } | |
3095 } | |
3096 return len; | |
3097 } | |
3098 #endif | |
3099 | |
3100 #if defined(FEAT_GUI) \ | |
1623 | 3101 || (defined(FEAT_MOUSE) && (!defined(UNIX) || defined(FEAT_MOUSE_XTERM) \ |
3102 || defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE))) | |
7 | 3103 /* |
3104 * Read the next num_bytes bytes from buf, and store them in bytes. Assume | |
3105 * that buf has been through inchar(). Returns the actual number of bytes used | |
3106 * from buf (between num_bytes and num_bytes*2), or -1 if not enough bytes were | |
3107 * available. | |
3108 */ | |
3109 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3110 get_bytes_from_buf(char_u *buf, char_u *bytes, int num_bytes) |
7 | 3111 { |
3112 int len = 0; | |
3113 int i; | |
3114 char_u c; | |
3115 | |
3116 for (i = 0; i < num_bytes; i++) | |
3117 { | |
3118 if ((c = buf[len++]) == NUL) | |
3119 return -1; | |
3120 if (c == K_SPECIAL) | |
3121 { | |
3122 if (buf[len] == NUL || buf[len + 1] == NUL) /* cannot happen? */ | |
3123 return -1; | |
3124 if (buf[len++] == (int)KS_ZERO) | |
3125 c = NUL; | |
5076
19ed30f7cef7
updated for version 7.3.1281
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
3126 /* 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
|
3127 * 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
|
3128 if (buf[len++] == (int)KE_CSI) |
19ed30f7cef7
updated for version 7.3.1281
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
3129 c = CSI; |
7 | 3130 } |
1160 | 3131 else if (c == CSI && buf[len] == KS_EXTRA |
3132 && buf[len + 1] == (int)KE_CSI) | |
667 | 3133 /* CSI is stored as CSI KS_SPECIAL KE_CSI to avoid confusion with |
3134 * the start of a special key, see add_to_input_buf_csi(). */ | |
3135 len += 2; | |
7 | 3136 bytes[i] = c; |
3137 } | |
3138 return len; | |
3139 } | |
3140 #endif | |
3141 | |
3142 /* | |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3143 * 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
|
3144 * too big. |
7 | 3145 */ |
3146 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3147 check_shellsize(void) |
7 | 3148 { |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3149 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
|
3150 Rows = min_rows(); |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3151 limit_screen_size(); |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3152 } |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3153 |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3154 /* |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3155 * 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
|
3156 */ |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3157 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3158 limit_screen_size(void) |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3159 { |
7 | 3160 if (Columns < MIN_COLUMNS) |
3161 Columns = MIN_COLUMNS; | |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3162 else if (Columns > 10000) |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3163 Columns = 10000; |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3164 if (Rows > 1000) |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3165 Rows = 1000; |
7 | 3166 } |
3167 | |
41 | 3168 /* |
3169 * Invoked just before the screen structures are going to be (re)allocated. | |
3170 */ | |
7 | 3171 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3172 win_new_shellsize(void) |
7 | 3173 { |
3174 static int old_Rows = 0; | |
3175 static int old_Columns = 0; | |
3176 | |
3177 if (old_Rows != Rows || old_Columns != Columns) | |
3178 ui_new_shellsize(); | |
3179 if (old_Rows != Rows) | |
3180 { | |
164 | 3181 /* if 'window' uses the whole screen, keep it using that */ |
179 | 3182 if (p_window == old_Rows - 1 || old_Rows == 0) |
164 | 3183 p_window = Rows - 1; |
7 | 3184 old_Rows = Rows; |
3185 shell_new_rows(); /* update window sizes */ | |
3186 } | |
3187 if (old_Columns != Columns) | |
3188 { | |
3189 old_Columns = Columns; | |
3190 shell_new_columns(); /* update window sizes */ | |
3191 } | |
3192 } | |
3193 | |
3194 /* | |
3195 * Call this function when the Vim shell has been resized in any way. | |
3196 * Will obtain the current size and redraw (also when size didn't change). | |
3197 */ | |
3198 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3199 shell_resized(void) |
7 | 3200 { |
3201 set_shellsize(0, 0, FALSE); | |
3202 } | |
3203 | |
3204 /* | |
3205 * Check if the shell size changed. Handle a resize. | |
3206 * When the size didn't change, nothing happens. | |
3207 */ | |
3208 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3209 shell_resized_check(void) |
7 | 3210 { |
3211 int old_Rows = Rows; | |
3212 int old_Columns = Columns; | |
3213 | |
3770 | 3214 if (!exiting |
3215 #ifdef FEAT_GUI | |
3216 /* Do not get the size when executing a shell command during | |
3217 * startup. */ | |
3218 && !gui.starting | |
3219 #endif | |
3220 ) | |
2673 | 3221 { |
3222 (void)ui_get_shellsize(); | |
3223 check_shellsize(); | |
3224 if (old_Rows != Rows || old_Columns != Columns) | |
3225 shell_resized(); | |
3226 } | |
7 | 3227 } |
3228 | |
3229 /* | |
3230 * Set size of the Vim shell. | |
3231 * If 'mustset' is TRUE, we must set Rows and Columns, do not get the real | |
3232 * window size (this is used for the :win command). | |
3233 * If 'mustset' is FALSE, we may try to get the real window size and if | |
3234 * it fails use 'width' and 'height'. | |
3235 */ | |
3236 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3237 set_shellsize(int width, int height, int mustset) |
7 | 3238 { |
3239 static int busy = FALSE; | |
3240 | |
3241 /* | |
3242 * Avoid recursiveness, can happen when setting the window size causes | |
3243 * another window-changed signal. | |
3244 */ | |
3245 if (busy) | |
3246 return; | |
3247 | |
3248 if (width < 0 || height < 0) /* just checking... */ | |
3249 return; | |
3250 | |
3068 | 3251 if (State == HITRETURN || State == SETWSIZE) |
7 | 3252 { |
3068 | 3253 /* postpone the resizing */ |
7 | 3254 State = SETWSIZE; |
3255 return; | |
3256 } | |
3257 | |
3068 | 3258 /* curwin->w_buffer can be NULL when we are closing a window and the |
3259 * buffer has already been closed and removing a scrollbar causes a resize | |
3260 * event. Don't resize then, it will happen after entering another buffer. | |
3261 */ | |
3262 if (curwin->w_buffer == NULL) | |
3263 return; | |
3264 | |
7 | 3265 ++busy; |
3266 | |
3267 #ifdef AMIGA | |
3268 out_flush(); /* must do this before mch_get_shellsize() for | |
3269 some obscure reason */ | |
3270 #endif | |
3271 | |
3272 if (mustset || (ui_get_shellsize() == FAIL && height != 0)) | |
3273 { | |
3274 Rows = height; | |
3275 Columns = width; | |
3276 check_shellsize(); | |
3277 ui_set_shellsize(mustset); | |
3278 } | |
3279 else | |
3280 check_shellsize(); | |
3281 | |
3282 /* The window layout used to be adjusted here, but it now happens in | |
3283 * screenalloc() (also invoked from screenclear()). That is because the | |
3284 * "busy" check above may skip this, but not screenalloc(). */ | |
3285 | |
3286 if (State != ASKMORE && State != EXTERNCMD && State != CONFIRM) | |
3287 screenclear(); | |
3288 else | |
3289 screen_start(); /* don't know where cursor is now */ | |
3290 | |
3291 if (starting != NO_SCREEN) | |
3292 { | |
3293 #ifdef FEAT_TITLE | |
3294 maketitle(); | |
3295 #endif | |
3296 changed_line_abv_curs(); | |
3297 invalidate_botline(); | |
3298 | |
3299 /* | |
3300 * We only redraw when it's needed: | |
3301 * - While at the more prompt or executing an external command, don't | |
3302 * redraw, but position the cursor. | |
3303 * - While editing the command line, only redraw that. | |
3304 * - in Ex mode, don't redraw anything. | |
3305 * - Otherwise, redraw right now, and position the cursor. | |
3306 * Always need to call update_screen() or screenalloc(), to make | |
3307 * sure Rows/Columns and the size of ScreenLines[] is correct! | |
3308 */ | |
3309 if (State == ASKMORE || State == EXTERNCMD || State == CONFIRM | |
3310 || exmode_active) | |
3311 { | |
3312 screenalloc(FALSE); | |
3313 repeat_message(); | |
3314 } | |
3315 else | |
3316 { | |
1024 | 3317 if (curwin->w_p_scb) |
3318 do_check_scrollbind(TRUE); | |
3319 if (State & CMDLINE) | |
648 | 3320 { |
1024 | 3321 update_screen(NOT_VALID); |
3322 redrawcmdline(); | |
648 | 3323 } |
3324 else | |
1024 | 3325 { |
3326 update_topline(); | |
3327 #if defined(FEAT_INS_EXPAND) | |
3328 if (pum_visible()) | |
3329 { | |
3330 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
|
3331 ins_compl_show_pum(); |
1024 | 3332 } |
648 | 3333 #endif |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12513
diff
changeset
|
3334 update_screen(NOT_VALID); |
1024 | 3335 if (redrawing()) |
3336 setcursor(); | |
3337 } | |
7 | 3338 } |
3339 cursor_on(); /* redrawing may have switched it off */ | |
3340 } | |
3341 out_flush(); | |
3342 --busy; | |
3343 } | |
3344 | |
3345 /* | |
3346 * Set the terminal to TMODE_RAW (for Normal mode) or TMODE_COOK (for external | |
3347 * commands and Ex mode). | |
3348 */ | |
3349 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3350 settmode(int tmode) |
7 | 3351 { |
3352 #ifdef FEAT_GUI | |
3353 /* don't set the term where gvim was started to any mode */ | |
3354 if (gui.in_use) | |
3355 return; | |
3356 #endif | |
3357 | |
3358 if (full_screen) | |
3359 { | |
3360 /* | |
3361 * When returning after calling a shell we want to really set the | |
3362 * terminal to raw mode, even though we think it already is, because | |
3363 * the shell program may have reset the terminal mode. | |
3364 * When we think the terminal is normal, don't try to set it to | |
3365 * normal again, because that causes problems (logout!) on some | |
3366 * machines. | |
3367 */ | |
3368 if (tmode != TMODE_COOK || cur_tmode != TMODE_COOK) | |
3369 { | |
3370 #ifdef FEAT_TERMRESPONSE | |
1691 | 3371 # ifdef FEAT_GUI |
3372 if (!gui.in_use && !gui.starting) | |
3373 # endif | |
3374 { | |
3375 /* May need to check for T_CRV response and termcodes, it | |
3376 * doesn't work in Cooked mode, an external program may get | |
3377 * 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
|
3378 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
|
3379 || u7_status == STATUS_SENT |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3380 #ifdef FEAT_TERMINAL |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3381 || rfg_status == STATUS_SENT |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3382 #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
|
3383 || 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
|
3384 || rbm_status == STATUS_SENT |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
3385 || rcs_status == STATUS_SENT |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
3386 || winpos_status == STATUS_SENT)) |
1691 | 3387 (void)vpeekc_nomap(); |
3388 check_for_codes_from_term(); | |
3389 } | |
7 | 3390 #endif |
3391 #ifdef FEAT_MOUSE_TTY | |
3392 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
|
3393 mch_setmouse(FALSE); /* switch mouse off */ |
7 | 3394 #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
|
3395 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
|
3396 out_str(T_BD); /* disable bracketed paste mode */ |
7 | 3397 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
|
3398 mch_settmode(tmode); /* machine specific function */ |
7 | 3399 cur_tmode = tmode; |
3400 #ifdef FEAT_MOUSE | |
3401 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
|
3402 setmouse(); /* may switch mouse on */ |
7 | 3403 #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
|
3404 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
|
3405 out_str(T_BE); /* enable bracketed paste mode */ |
7 | 3406 out_flush(); |
3407 } | |
3408 #ifdef FEAT_TERMRESPONSE | |
3409 may_req_termresponse(); | |
3410 #endif | |
3411 } | |
3412 } | |
3413 | |
3414 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3415 starttermcap(void) |
7 | 3416 { |
3417 if (full_screen && !termcap_active) | |
3418 { | |
3419 out_str(T_TI); /* start termcap mode */ | |
3420 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
|
3421 out_str(T_BE); /* enable bracketed paste mode */ |
7 | 3422 out_flush(); |
3423 termcap_active = TRUE; | |
3424 screen_start(); /* don't know where cursor is now */ | |
3425 #ifdef FEAT_TERMRESPONSE | |
1691 | 3426 # ifdef FEAT_GUI |
3427 if (!gui.in_use && !gui.starting) | |
3428 # endif | |
3429 { | |
3430 may_req_termresponse(); | |
3431 /* Immediately check for a response. If t_Co changes, we don't | |
3432 * 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
|
3433 if (crv_status == STATUS_SENT) |
1691 | 3434 check_for_codes_from_term(); |
3435 } | |
7 | 3436 #endif |
3437 } | |
3438 } | |
3439 | |
3440 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3441 stoptermcap(void) |
7 | 3442 { |
3443 screen_stop_highlight(); | |
3444 reset_cterm_colors(); | |
3445 if (termcap_active) | |
3446 { | |
3447 #ifdef FEAT_TERMRESPONSE | |
1691 | 3448 # ifdef FEAT_GUI |
3449 if (!gui.in_use && !gui.starting) | |
3450 # endif | |
3451 { | |
6874 | 3452 /* 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
|
3453 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
|
3454 || u7_status == STATUS_SENT |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3455 # ifdef FEAT_TERMINAL |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3456 || rfg_status == STATUS_SENT |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3457 # 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
|
3458 || 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
|
3459 || rbm_status == STATUS_SENT |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
3460 || rcs_status == STATUS_SENT |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
3461 || winpos_status == STATUS_SENT) |
4391 | 3462 { |
3463 # ifdef UNIX | |
3464 /* Give the terminal a chance to respond. */ | |
3465 mch_delay(100L, FALSE); | |
3466 # endif | |
3467 # ifdef TCIFLUSH | |
3468 /* Discard data received but not read. */ | |
3469 if (exiting) | |
3470 tcflush(fileno(stdin), TCIFLUSH); | |
3471 # endif | |
3472 } | |
1691 | 3473 /* Check for termcodes first, otherwise an external program may |
3474 * get them. */ | |
3475 check_for_codes_from_term(); | |
3476 } | |
7 | 3477 #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
|
3478 out_str(T_BD); /* disable bracketed paste mode */ |
7 | 3479 out_str(T_KE); /* stop "keypad transmit" mode */ |
3480 out_flush(); | |
3481 termcap_active = FALSE; | |
3482 cursor_on(); /* just in case it is still off */ | |
3483 out_str(T_TE); /* stop termcap mode */ | |
3484 screen_start(); /* don't know where cursor is now */ | |
3485 out_flush(); | |
3486 } | |
3487 } | |
3488 | |
5932 | 3489 #if defined(FEAT_TERMRESPONSE) || defined(PROTO) |
7 | 3490 /* |
3491 * Request version string (for xterm) when needed. | |
3492 * Only do this after switching to raw mode, otherwise the result will be | |
3493 * echoed. | |
626 | 3494 * Only do this after startup has finished, to avoid that the response comes |
1221 | 3495 * while executing "-c !cmd" or even after "-c quit". |
7 | 3496 * Only do this after termcap mode has been started, otherwise the codes for |
3497 * the cursor keys may be wrong. | |
620 | 3498 * Only do this when 'esckeys' is on, otherwise the response causes trouble in |
3499 * Insert mode. | |
164 | 3500 * On Unix only do it when both output and input are a tty (avoid writing |
3501 * request to terminal while reading from a file). | |
7 | 3502 * The result is caught in check_termcode(). |
3503 */ | |
626 | 3504 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3505 may_req_termresponse(void) |
7 | 3506 { |
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
|
3507 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
|
3508 && can_get_termresponse() |
626 | 3509 && starting == 0 |
7 | 3510 && *T_CRV != NUL) |
3511 { | |
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
|
3512 LOG_TR("Sending CRV request"); |
7 | 3513 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
|
3514 crv_status = STATUS_SENT; |
7 | 3515 /* check for the characters now, otherwise they might be eaten by |
3516 * get_keystroke() */ | |
3517 out_flush(); | |
3518 (void)vpeekc_nomap(); | |
3519 } | |
3520 } | |
4215 | 3521 |
3522 # if defined(FEAT_MBYTE) || defined(PROTO) | |
3523 /* | |
3524 * 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
|
3525 * First, we move the cursor to (1, 0) and print a test ambiguous character |
4215 | 3526 * \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
|
3527 * 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
|
3528 * or if it is treated as double width, that will be (1, 2). |
4215 | 3529 * This function has the side effect that changes cursor position, so |
3530 * it must be called immediately after entering termcap mode. | |
3531 */ | |
3532 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3533 may_req_ambiguous_char_width(void) |
4215 | 3534 { |
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
|
3535 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
|
3536 && 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
|
3537 && starting == 0 |
4215 | 3538 && *T_U7 != NUL |
3539 && !option_was_set((char_u *)"ambiwidth")) | |
3540 { | |
3541 char_u buf[16]; | |
3542 | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3543 LOG_TR("Sending U7 request"); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3544 /* 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
|
3545 * 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
|
3546 term_windgoto(1, 0); |
4215 | 3547 buf[mb_char2bytes(0x25bd, buf)] = 0; |
3548 out_str(buf); | |
3549 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
|
3550 u7_status = STATUS_SENT; |
5724 | 3551 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
|
3552 |
08e60ce4cbf3
patch 8.0.0611: the screen is not redrawn after sending t_u7
Christian Brabandt <cb@256bit.org>
parents:
11453
diff
changeset
|
3553 /* 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
|
3554 * after this. Clear them out for now. */ |
5724 | 3555 term_windgoto(1, 0); |
4215 | 3556 out_str((char_u *)" "); |
3557 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
|
3558 |
13008
e775011b4c1e
patch 8.0.1380: using "vim -r swapfile" the hit-enter prompt is misplaced.
Christian Brabandt <cb@256bit.org>
parents:
12895
diff
changeset
|
3559 /* Need to reset the known cursor position. */ |
e775011b4c1e
patch 8.0.1380: using "vim -r swapfile" the hit-enter prompt is misplaced.
Christian Brabandt <cb@256bit.org>
parents:
12895
diff
changeset
|
3560 screen_start(); |
e775011b4c1e
patch 8.0.1380: using "vim -r swapfile" the hit-enter prompt is misplaced.
Christian Brabandt <cb@256bit.org>
parents:
12895
diff
changeset
|
3561 |
4215 | 3562 /* check for the characters now, otherwise they might be eaten by |
3563 * get_keystroke() */ | |
3564 out_flush(); | |
3565 (void)vpeekc_nomap(); | |
3566 } | |
3567 } | |
3568 # endif | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3569 |
6874 | 3570 /* |
6885 | 3571 * Similar to requesting the version string: Request the terminal background |
3572 * color when it is the right moment. | |
6874 | 3573 */ |
3574 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3575 may_req_bg_color(void) |
6874 | 3576 { |
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
|
3577 if (can_get_termresponse() && starting == 0) |
6874 | 3578 { |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3579 int didit = FALSE; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3580 |
12640
a715f0b44532
patch 8.0.1198: older compilers don't know uint8_t
Christian Brabandt <cb@256bit.org>
parents:
12634
diff
changeset
|
3581 # ifdef FEAT_TERMINAL |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3582 /* Only request foreground if t_RF is set. */ |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3583 if (rfg_status == STATUS_GET && *T_RFG != NUL) |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3584 { |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3585 LOG_TR("Sending FG request"); |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3586 out_str(T_RFG); |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3587 rfg_status = STATUS_SENT; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3588 didit = TRUE; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3589 } |
12640
a715f0b44532
patch 8.0.1198: older compilers don't know uint8_t
Christian Brabandt <cb@256bit.org>
parents:
12634
diff
changeset
|
3590 # endif |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3591 |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3592 /* Only request background if t_RB is set. */ |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3593 if (rbg_status == STATUS_GET && *T_RBG != NUL) |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3594 { |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3595 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
|
3596 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
|
3597 rbg_status = STATUS_SENT; |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3598 didit = TRUE; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3599 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3600 |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3601 if (didit) |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3602 { |
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
|
3603 /* 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
|
3604 * 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
|
3605 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
|
3606 (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
|
3607 } |
6874 | 3608 } |
3609 } | |
3610 | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3611 # ifdef DEBUG_TERMRESPONSE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3612 static void |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3613 log_tr(char *msg) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3614 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3615 static FILE *fd_tr = NULL; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3616 static proftime_T start; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3617 proftime_T now; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3618 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3619 if (fd_tr == NULL) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3620 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3621 fd_tr = fopen("termresponse.log", "w"); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3622 profile_start(&start); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3623 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3624 now = start; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3625 profile_end(&now); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3626 fprintf(fd_tr, "%s: %s %s\n", |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3627 profile_msg(&now), |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3628 must_redraw == NOT_VALID ? "NV" |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3629 : must_redraw == CLEAR ? "CL" : " ", |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3630 msg); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3631 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3632 # endif |
7 | 3633 #endif |
3634 | |
3635 /* | |
3636 * Return TRUE when saving and restoring the screen. | |
3637 */ | |
3638 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3639 swapping_screen(void) |
7 | 3640 { |
3641 return (full_screen && *T_TI != NUL); | |
3642 } | |
3643 | |
3644 #ifdef FEAT_MOUSE | |
3645 /* | |
3646 * setmouse() - switch mouse on/off depending on current mode and 'mouse' | |
3647 */ | |
3648 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3649 setmouse(void) |
7 | 3650 { |
3651 # ifdef FEAT_MOUSE_TTY | |
3652 int checkfor; | |
3653 # endif | |
3654 | |
3655 # ifdef FEAT_MOUSESHAPE | |
3656 update_mouseshape(-1); | |
3657 # endif | |
3658 | |
3659 # ifdef FEAT_MOUSE_TTY /* Should be outside proc, but may break MOUSESHAPE */ | |
3660 # ifdef FEAT_GUI | |
3661 /* In the GUI the mouse is always enabled. */ | |
3662 if (gui.in_use) | |
3663 return; | |
3664 # endif | |
3665 /* be quick when mouse is off */ | |
3666 if (*p_mouse == NUL || has_mouse_termcode == 0) | |
3667 return; | |
3668 | |
3669 /* don't switch mouse on when not in raw mode (Ex mode) */ | |
3670 if (cur_tmode != TMODE_RAW) | |
3671 { | |
3672 mch_setmouse(FALSE); | |
3673 return; | |
3674 } | |
3675 | |
3676 if (VIsual_active) | |
3677 checkfor = MOUSE_VISUAL; | |
5735 | 3678 else if (State == HITRETURN || State == ASKMORE || State == SETWSIZE) |
7 | 3679 checkfor = MOUSE_RETURN; |
3680 else if (State & INSERT) | |
3681 checkfor = MOUSE_INSERT; | |
3682 else if (State & CMDLINE) | |
3683 checkfor = MOUSE_COMMAND; | |
3684 else if (State == CONFIRM || State == EXTERNCMD) | |
3685 checkfor = ' '; /* don't use mouse for ":confirm" or ":!cmd" */ | |
3686 else | |
3687 checkfor = MOUSE_NORMAL; /* assume normal mode */ | |
3688 | |
3689 if (mouse_has(checkfor)) | |
3690 mch_setmouse(TRUE); | |
3691 else | |
3692 mch_setmouse(FALSE); | |
3693 # endif | |
3694 } | |
3695 | |
3696 /* | |
3697 * Return TRUE if | |
3698 * - "c" is in 'mouse', or | |
3699 * - 'a' is in 'mouse' and "c" is in MOUSE_A, or | |
3700 * - the current buffer is a help file and 'h' is in 'mouse' and we are in a | |
3701 * normal editing mode (not at hit-return message). | |
3702 */ | |
3703 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3704 mouse_has(int c) |
7 | 3705 { |
3706 char_u *p; | |
3707 | |
3708 for (p = p_mouse; *p; ++p) | |
3709 switch (*p) | |
3710 { | |
3711 case 'a': if (vim_strchr((char_u *)MOUSE_A, c) != NULL) | |
3712 return TRUE; | |
3713 break; | |
3714 case MOUSE_HELP: if (c != MOUSE_RETURN && curbuf->b_help) | |
3715 return TRUE; | |
3716 break; | |
3717 default: if (c == *p) return TRUE; break; | |
3718 } | |
3719 return FALSE; | |
3720 } | |
3721 | |
3722 /* | |
3723 * Return TRUE when 'mousemodel' is set to "popup" or "popup_setpos". | |
3724 */ | |
3725 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3726 mouse_model_popup(void) |
7 | 3727 { |
3728 return (p_mousem[0] == 'p'); | |
3729 } | |
3730 #endif | |
3731 | |
3732 /* | |
3733 * By outputting the 'cursor very visible' termcap code, for some windowed | |
3734 * terminals this makes the screen scrolled to the correct position. | |
3735 * Used when starting Vim or returning from a shell. | |
3736 */ | |
3737 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3738 scroll_start(void) |
7 | 3739 { |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3740 if (*T_VS != NUL && *T_CVS != NUL) |
7 | 3741 { |
3742 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
|
3743 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
|
3744 screen_start(); /* don't know where cursor is now */ |
7 | 3745 } |
3746 } | |
3747 | |
3748 static int cursor_is_off = FALSE; | |
3749 | |
3750 /* | |
3751 * Enable the cursor. | |
3752 */ | |
3753 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3754 cursor_on(void) |
7 | 3755 { |
3756 if (cursor_is_off) | |
3757 { | |
3758 out_str(T_VE); | |
3759 cursor_is_off = FALSE; | |
3760 } | |
3761 } | |
3762 | |
3763 /* | |
3764 * Disable the cursor. | |
3765 */ | |
3766 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3767 cursor_off(void) |
7 | 3768 { |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3769 if (full_screen && !cursor_is_off) |
7 | 3770 { |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3771 out_str(T_VI); /* disable cursor */ |
7 | 3772 cursor_is_off = TRUE; |
3773 } | |
3774 } | |
3775 | |
39 | 3776 #if defined(CURSOR_SHAPE) || defined(PROTO) |
7 | 3777 /* |
6727 | 3778 * Set cursor shape to match Insert or Replace mode. |
36 | 3779 */ |
3780 void | |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3781 term_cursor_mode(int forced) |
36 | 3782 { |
12078
d21b8f31b296
patch 8.0.0919: cursor color isn't set on startup
Christian Brabandt <cb@256bit.org>
parents:
12076
diff
changeset
|
3783 static int showing_mode = -1; |
6727 | 3784 char_u *p; |
3785 | |
3786 /* Only do something when redrawing the screen and we can restore the | |
3787 * mode. */ | |
3788 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
|
3789 { |
12184
76fbd85c3cea
patch 8.0.0972: compiler warnings for unused variables
Christian Brabandt <cb@256bit.org>
parents:
12174
diff
changeset
|
3790 # 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
|
3791 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
|
3792 /* 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
|
3793 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
|
3794 # endif |
36 | 3795 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
|
3796 } |
36 | 3797 |
6727 | 3798 if ((State & REPLACE) == REPLACE) |
36 | 3799 { |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3800 if (forced || showing_mode != REPLACE) |
6727 | 3801 { |
3802 if (*T_CSR != NUL) | |
3803 p = T_CSR; /* Replace mode cursor */ | |
3804 else | |
3805 p = T_CSI; /* fall back to Insert mode cursor */ | |
3806 if (*p != NUL) | |
3807 { | |
3808 out_str(p); | |
3809 showing_mode = REPLACE; | |
3810 } | |
3811 } | |
36 | 3812 } |
6727 | 3813 else if (State & INSERT) |
36 | 3814 { |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3815 if ((forced || showing_mode != INSERT) && *T_CSI != NUL) |
6727 | 3816 { |
3817 out_str(T_CSI); /* Insert mode cursor */ | |
3818 showing_mode = INSERT; | |
3819 } | |
3820 } | |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3821 else if (forced || showing_mode != NORMAL) |
6727 | 3822 { |
3823 out_str(T_CEI); /* non-Insert mode cursor */ | |
3824 showing_mode = NORMAL; | |
36 | 3825 } |
3826 } | |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3827 |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3828 # 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
|
3829 void |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3830 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
|
3831 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3832 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
|
3833 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3834 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
|
3835 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
|
3836 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
|
3837 out_flush(); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3838 } |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3839 } |
12172
444793fce117
patch 8.0.0966: build failure without terminal feature
Christian Brabandt <cb@256bit.org>
parents:
12170
diff
changeset
|
3840 # endif |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3841 |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3842 int |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3843 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
|
3844 { |
12261
875d7cc9b127
patch 8.0.1010: build failure without termresponse feature
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3845 #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
|
3846 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
|
3847 && 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
|
3848 #else |
875d7cc9b127
patch 8.0.1010: build failure without termresponse feature
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3849 return FALSE; |
875d7cc9b127
patch 8.0.1010: build failure without termresponse feature
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3850 #endif |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3851 } |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3852 |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3853 /* |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3854 * "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
|
3855 */ |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3856 void |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3857 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
|
3858 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3859 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
|
3860 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3861 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
|
3862 out_flush(); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3863 } |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3864 else |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3865 { |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3866 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
|
3867 |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3868 /* 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
|
3869 * 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
|
3870 * 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
|
3871 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
|
3872 do_blink = !blink; |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3873 |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3874 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
|
3875 { |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3876 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
|
3877 out_flush(); |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3878 } |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3879 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
|
3880 { |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3881 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
|
3882 out_flush(); |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3883 } |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3884 } |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3885 } |
39 | 3886 #endif |
36 | 3887 |
3888 /* | |
7 | 3889 * Set scrolling region for window 'wp'. |
3890 * The region starts 'off' lines from the start of the window. | |
3891 * Also set the vertical scroll region for a vertically split window. Always | |
3892 * the full width of the window, excluding the vertical separator. | |
3893 */ | |
3894 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3895 scroll_region_set(win_T *wp, int off) |
7 | 3896 { |
3897 OUT_STR(tgoto((char *)T_CS, W_WINROW(wp) + wp->w_height - 1, | |
3898 W_WINROW(wp) + off)); | |
3899 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
|
3900 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
|
3901 wp->w_wincol)); |
7 | 3902 screen_start(); /* don't know where cursor is now */ |
3903 } | |
3904 | |
3905 /* | |
3906 * Reset scrolling region to the whole screen. | |
3907 */ | |
3908 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3909 scroll_region_reset(void) |
7 | 3910 { |
3911 OUT_STR(tgoto((char *)T_CS, (int)Rows - 1, 0)); | |
3912 if (*T_CSV != NUL) | |
3913 OUT_STR(tgoto((char *)T_CSV, (int)Columns - 1, 0)); | |
3914 screen_start(); /* don't know where cursor is now */ | |
3915 } | |
3916 | |
3917 | |
3918 /* | |
3919 * List of terminal codes that are currently recognized. | |
3920 */ | |
3921 | |
298 | 3922 static struct termcode |
7 | 3923 { |
3924 char_u name[2]; /* termcap name of entry */ | |
3925 char_u *code; /* terminal code (in allocated memory) */ | |
3926 int len; /* STRLEN(code) */ | |
179 | 3927 int modlen; /* length of part before ";*~". */ |
7 | 3928 } *termcodes = NULL; |
3929 | |
3930 static int tc_max_len = 0; /* number of entries that termcodes[] can hold */ | |
3931 static int tc_len = 0; /* current number of entries in termcodes[] */ | |
3932 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
3933 static int termcode_star(char_u *code, int len); |
180 | 3934 |
7 | 3935 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3936 clear_termcodes(void) |
7 | 3937 { |
3938 while (tc_len > 0) | |
3939 vim_free(termcodes[--tc_len].code); | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
3940 VIM_CLEAR(termcodes); |
7 | 3941 tc_max_len = 0; |
3942 | |
3943 #ifdef HAVE_TGETENT | |
3944 BC = (char *)empty_option; | |
3945 UP = (char *)empty_option; | |
3946 PC = NUL; /* set pad character to NUL */ | |
3947 ospeed = 0; | |
3948 #endif | |
3949 | |
3950 need_gather = TRUE; /* need to fill termleader[] */ | |
3951 } | |
3952 | |
180 | 3953 #define ATC_FROM_TERM 55 |
3954 | |
7 | 3955 /* |
3956 * Add a new entry to the list of terminal codes. | |
3957 * The list is kept alphabetical for ":set termcap" | |
180 | 3958 * "flags" is TRUE when replacing 7-bit by 8-bit controls is desired. |
3959 * "flags" can also be ATC_FROM_TERM for got_code_from_term(). | |
7 | 3960 */ |
3961 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3962 add_termcode(char_u *name, char_u *string, int flags) |
7 | 3963 { |
3964 struct termcode *new_tc; | |
3965 int i, j; | |
3966 char_u *s; | |
179 | 3967 int len; |
7 | 3968 |
3969 if (string == NULL || *string == NUL) | |
3970 { | |
3971 del_termcode(name); | |
3972 return; | |
3973 } | |
3974 | |
6047 | 3975 #if defined(WIN3264) && !defined(FEAT_GUI) |
3976 s = vim_strnsave(string, (int)STRLEN(string) + 1); | |
3977 #else | |
7 | 3978 s = vim_strsave(string); |
6047 | 3979 #endif |
7 | 3980 if (s == NULL) |
3981 return; | |
3982 | |
3983 /* Change leading <Esc>[ to CSI, change <Esc>O to <M-O>. */ | |
180 | 3984 if (flags != 0 && flags != ATC_FROM_TERM && term_7to8bit(string) != 0) |
7 | 3985 { |
1623 | 3986 STRMOVE(s, s + 1); |
7 | 3987 s[0] = term_7to8bit(string); |
3988 } | |
6047 | 3989 |
3990 #if defined(WIN3264) && !defined(FEAT_GUI) | |
3991 if (s[0] == K_NUL) | |
3992 { | |
6102 | 3993 STRMOVE(s + 1, s); |
3994 s[1] = 3; | |
6047 | 3995 } |
3996 #endif | |
3997 | |
179 | 3998 len = (int)STRLEN(s); |
7 | 3999 |
4000 need_gather = TRUE; /* need to fill termleader[] */ | |
4001 | |
4002 /* | |
4003 * need to make space for more entries | |
4004 */ | |
4005 if (tc_len == tc_max_len) | |
4006 { | |
4007 tc_max_len += 20; | |
4008 new_tc = (struct termcode *)alloc( | |
4009 (unsigned)(tc_max_len * sizeof(struct termcode))); | |
4010 if (new_tc == NULL) | |
4011 { | |
4012 tc_max_len -= 20; | |
4013 return; | |
4014 } | |
4015 for (i = 0; i < tc_len; ++i) | |
4016 new_tc[i] = termcodes[i]; | |
4017 vim_free(termcodes); | |
4018 termcodes = new_tc; | |
4019 } | |
4020 | |
4021 /* | |
4022 * Look for existing entry with the same name, it is replaced. | |
4023 * Look for an existing entry that is alphabetical higher, the new entry | |
4024 * is inserted in front of it. | |
4025 */ | |
4026 for (i = 0; i < tc_len; ++i) | |
4027 { | |
4028 if (termcodes[i].name[0] < name[0]) | |
4029 continue; | |
4030 if (termcodes[i].name[0] == name[0]) | |
4031 { | |
4032 if (termcodes[i].name[1] < name[1]) | |
4033 continue; | |
4034 /* | |
180 | 4035 * Exact match: May replace old code. |
7 | 4036 */ |
4037 if (termcodes[i].name[1] == name[1]) | |
4038 { | |
180 | 4039 if (flags == ATC_FROM_TERM && (j = termcode_star( |
4040 termcodes[i].code, termcodes[i].len)) > 0) | |
179 | 4041 { |
180 | 4042 /* Don't replace ESC[123;*X or ESC O*X with another when |
4043 * invoked from got_code_from_term(). */ | |
4044 if (len == termcodes[i].len - j | |
179 | 4045 && STRNCMP(s, termcodes[i].code, len - 1) == 0 |
180 | 4046 && s[len - 1] |
4047 == termcodes[i].code[termcodes[i].len - 1]) | |
179 | 4048 { |
180 | 4049 /* They are equal but for the ";*": don't add it. */ |
179 | 4050 vim_free(s); |
4051 return; | |
4052 } | |
4053 } | |
4054 else | |
4055 { | |
180 | 4056 /* Replace old code. */ |
179 | 4057 vim_free(termcodes[i].code); |
4058 --tc_len; | |
4059 break; | |
4060 } | |
7 | 4061 } |
4062 } | |
4063 /* | |
4064 * Found alphabetical larger entry, move rest to insert new entry | |
4065 */ | |
4066 for (j = tc_len; j > i; --j) | |
4067 termcodes[j] = termcodes[j - 1]; | |
4068 break; | |
4069 } | |
4070 | |
4071 termcodes[i].name[0] = name[0]; | |
4072 termcodes[i].name[1] = name[1]; | |
4073 termcodes[i].code = s; | |
179 | 4074 termcodes[i].len = len; |
180 | 4075 |
4076 /* For xterm we recognize special codes like "ESC[42;*X" and "ESC O*X" that | |
4077 * accept modifiers. */ | |
4078 termcodes[i].modlen = 0; | |
4079 j = termcode_star(s, len); | |
4080 if (j > 0) | |
4081 termcodes[i].modlen = len - 1 - j; | |
7 | 4082 ++tc_len; |
4083 } | |
4084 | |
180 | 4085 /* |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
4086 * Check termcode "code[len]" for ending in ;*X or *X. |
180 | 4087 * 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
|
4088 * Return 0 if not found, 2 for ;*X and 1 for *X. |
180 | 4089 */ |
4090 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4091 termcode_star(char_u *code, int len) |
180 | 4092 { |
4093 /* Shortest is <M-O>*X. With ; shortest is <CSI>1;*X */ | |
4094 if (len >= 3 && code[len - 2] == '*') | |
4095 { | |
4096 if (len >= 5 && code[len - 3] == ';') | |
4097 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
|
4098 else |
180 | 4099 return 1; |
4100 } | |
4101 return 0; | |
4102 } | |
4103 | |
7 | 4104 char_u * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4105 find_termcode(char_u *name) |
7 | 4106 { |
4107 int i; | |
4108 | |
4109 for (i = 0; i < tc_len; ++i) | |
4110 if (termcodes[i].name[0] == name[0] && termcodes[i].name[1] == name[1]) | |
4111 return termcodes[i].code; | |
4112 return NULL; | |
4113 } | |
4114 | |
4115 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) | |
4116 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4117 get_termcode(int i) |
7 | 4118 { |
4119 if (i >= tc_len) | |
4120 return NULL; | |
4121 return &termcodes[i].name[0]; | |
4122 } | |
4123 #endif | |
4124 | |
4125 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4126 del_termcode(char_u *name) |
7 | 4127 { |
4128 int i; | |
4129 | |
4130 if (termcodes == NULL) /* nothing there yet */ | |
4131 return; | |
4132 | |
4133 need_gather = TRUE; /* need to fill termleader[] */ | |
4134 | |
4135 for (i = 0; i < tc_len; ++i) | |
4136 if (termcodes[i].name[0] == name[0] && termcodes[i].name[1] == name[1]) | |
4137 { | |
4138 del_termcode_idx(i); | |
4139 return; | |
4140 } | |
4141 /* not found. Give error message? */ | |
4142 } | |
4143 | |
4144 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4145 del_termcode_idx(int idx) |
7 | 4146 { |
4147 int i; | |
4148 | |
4149 vim_free(termcodes[idx].code); | |
4150 --tc_len; | |
4151 for (i = idx; i < tc_len; ++i) | |
4152 termcodes[i] = termcodes[i + 1]; | |
4153 } | |
4154 | |
4155 #ifdef FEAT_TERMRESPONSE | |
4156 /* | |
4157 * Called when detected that the terminal sends 8-bit codes. | |
4158 * Convert all 7-bit codes to their 8-bit equivalent. | |
4159 */ | |
4160 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4161 switch_to_8bit(void) |
7 | 4162 { |
4163 int i; | |
4164 int c; | |
4165 | |
4166 /* Only need to do something when not already using 8-bit codes. */ | |
4167 if (!term_is_8bit(T_NAME)) | |
4168 { | |
4169 for (i = 0; i < tc_len; ++i) | |
4170 { | |
4171 c = term_7to8bit(termcodes[i].code); | |
4172 if (c != 0) | |
4173 { | |
1623 | 4174 STRMOVE(termcodes[i].code + 1, termcodes[i].code + 2); |
7 | 4175 termcodes[i].code[0] = c; |
4176 } | |
4177 } | |
4178 need_gather = TRUE; /* need to fill termleader[] */ | |
4179 } | |
4180 detected_8bit = TRUE; | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4181 LOG_TR("Switching to 8 bit"); |
7 | 4182 } |
4183 #endif | |
4184 | |
4185 #ifdef CHECK_DOUBLE_CLICK | |
4186 static linenr_T orig_topline = 0; | |
4187 # ifdef FEAT_DIFF | |
4188 static int orig_topfill = 0; | |
4189 # endif | |
4190 #endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12429
diff
changeset
|
4191 #if defined(CHECK_DOUBLE_CLICK) || defined(PROTO) |
7 | 4192 /* |
4193 * Checking for double clicks ourselves. | |
4194 * "orig_topline" is used to avoid detecting a double-click when the window | |
4195 * contents scrolled (e.g., when 'scrolloff' is non-zero). | |
4196 */ | |
4197 /* | |
4198 * Set orig_topline. Used when jumping to another window, so that a double | |
4199 * click still works. | |
4200 */ | |
4201 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4202 set_mouse_topline(win_T *wp) |
7 | 4203 { |
4204 orig_topline = wp->w_topline; | |
4205 # ifdef FEAT_DIFF | |
4206 orig_topfill = wp->w_topfill; | |
4207 # endif | |
4208 } | |
4209 #endif | |
4210 | |
4211 /* | |
4212 * Check if typebuf.tb_buf[] contains a terminal key code. | |
4213 * Check from typebuf.tb_buf[typebuf.tb_off] to typebuf.tb_buf[typebuf.tb_off | |
4214 * + max_offset]. | |
4215 * Return 0 for no match, -1 for partial match, > 0 for full match. | |
2672 | 4216 * Return KEYLEN_REMOVED when a key code was deleted. |
7 | 4217 * With a match, the match is removed, the replacement code is inserted in |
4218 * typebuf.tb_buf[] and the number of characters in typebuf.tb_buf[] is | |
4219 * returned. | |
3328 | 4220 * When "buf" is not NULL, buf[bufsize] is used instead of typebuf.tb_buf[]. |
4221 * "buflen" is then the length of the string in buf[] and is updated for | |
4222 * inserts and deletes. | |
7 | 4223 */ |
4224 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4225 check_termcode( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4226 int max_offset, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4227 char_u *buf, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4228 int bufsize, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4229 int *buflen) |
7 | 4230 { |
4231 char_u *tp; | |
4232 char_u *p; | |
4233 int slen = 0; /* init for GCC */ | |
180 | 4234 int modslen; |
7 | 4235 int len; |
2672 | 4236 int retval = 0; |
7 | 4237 int offset; |
4238 char_u key_name[2]; | |
180 | 4239 int modifiers; |
11565
91519a14ec1f
patch 8.0.0665: warning for uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
11563
diff
changeset
|
4240 char_u *modifiers_start = NULL; |
180 | 4241 int key; |
7 | 4242 int new_slen; |
4243 int extra; | |
4244 char_u string[MAX_KEY_CODE_LEN + 1]; | |
4245 int i, j; | |
4246 int idx = 0; | |
4247 #ifdef FEAT_MOUSE | |
1623 | 4248 # if !defined(UNIX) || defined(FEAT_MOUSE_XTERM) || defined(FEAT_GUI) \ |
4249 || defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE) | |
7 | 4250 char_u bytes[6]; |
4251 int num_bytes; | |
4252 # endif | |
4253 int mouse_code = 0; /* init for GCC */ | |
4254 int is_click, is_drag; | |
4255 int wheel_code = 0; | |
4256 int current_button; | |
4257 static int held_button = MOUSE_RELEASE; | |
4258 static int orig_num_clicks = 1; | |
4259 static int orig_mouse_code = 0x0; | |
4260 # ifdef CHECK_DOUBLE_CLICK | |
4261 static int orig_mouse_col = 0; | |
4262 static int orig_mouse_row = 0; | |
4263 static struct timeval orig_mouse_time = {0, 0}; | |
4264 /* time of previous mouse click */ | |
4265 struct timeval mouse_time; /* time of current mouse click */ | |
4266 long timediff; /* elapsed time in msec */ | |
4267 # endif | |
4268 #endif | |
4269 int cpo_koffset; | |
4270 #ifdef FEAT_MOUSE_GPM | |
4271 extern int gpm_flag; /* gpm library variable */ | |
4272 #endif | |
4273 | |
4274 cpo_koffset = (vim_strchr(p_cpo, CPO_KOFFSET) != NULL); | |
4275 | |
4276 /* | |
4277 * Speed up the checks for terminal codes by gathering all first bytes | |
4278 * used in termleader[]. Often this is just a single <Esc>. | |
4279 */ | |
4280 if (need_gather) | |
4281 gather_termleader(); | |
4282 | |
4283 /* | |
4284 * Check at several positions in typebuf.tb_buf[], to catch something like | |
4285 * "x<Up>" that can be mapped. Stop at max_offset, because characters | |
4286 * after that cannot be used for mapping, and with @r commands | |
4223 | 4287 * typebuf.tb_buf[] can become very long. |
7 | 4288 * This is used often, KEEP IT FAST! |
4289 */ | |
4290 for (offset = 0; offset < max_offset; ++offset) | |
4291 { | |
4292 if (buf == NULL) | |
4293 { | |
4294 if (offset >= typebuf.tb_len) | |
4295 break; | |
4296 tp = typebuf.tb_buf + typebuf.tb_off + offset; | |
4297 len = typebuf.tb_len - offset; /* length of the input */ | |
4298 } | |
4299 else | |
4300 { | |
3328 | 4301 if (offset >= *buflen) |
7 | 4302 break; |
4303 tp = buf + offset; | |
3328 | 4304 len = *buflen - offset; |
7 | 4305 } |
4306 | |
4307 /* | |
4308 * Don't check characters after K_SPECIAL, those are already | |
4309 * translated terminal chars (avoid translating ~@^Hx). | |
4310 */ | |
4311 if (*tp == K_SPECIAL) | |
4312 { | |
4313 offset += 2; /* there are always 2 extra characters */ | |
4314 continue; | |
4315 } | |
4316 | |
4317 /* | |
4318 * Skip this position if the character does not appear as the first | |
4319 * character in term_strings. This speeds up a lot, since most | |
4320 * termcodes start with the same character (ESC or CSI). | |
4321 */ | |
4322 i = *tp; | |
4323 for (p = termleader; *p && *p != i; ++p) | |
4324 ; | |
4325 if (*p == NUL) | |
4326 continue; | |
4327 | |
4328 /* | |
4329 * Skip this position if p_ek is not set and tp[0] is an ESC and we | |
4330 * are in Insert mode. | |
4331 */ | |
4332 if (*tp == ESC && !p_ek && (State & INSERT)) | |
4333 continue; | |
4334 | |
4335 key_name[0] = NUL; /* no key name found yet */ | |
699 | 4336 key_name[1] = NUL; /* no key name found yet */ |
180 | 4337 modifiers = 0; /* no modifiers yet */ |
7 | 4338 |
4339 #ifdef FEAT_GUI | |
4340 if (gui.in_use) | |
4341 { | |
4342 /* | |
4343 * GUI special key codes are all of the form [CSI xx]. | |
4344 */ | |
4345 if (*tp == CSI) /* Special key from GUI */ | |
4346 { | |
4347 if (len < 3) | |
4348 return -1; /* Shouldn't happen */ | |
4349 slen = 3; | |
4350 key_name[0] = tp[1]; | |
4351 key_name[1] = tp[2]; | |
4352 } | |
4353 } | |
4354 else | |
4355 #endif /* FEAT_GUI */ | |
4356 { | |
4357 for (idx = 0; idx < tc_len; ++idx) | |
4358 { | |
4359 /* | |
4360 * Ignore the entry if we are not at the start of | |
4361 * typebuf.tb_buf[] | |
4362 * and there are not enough characters to make a match. | |
4363 * But only when the 'K' flag is in 'cpoptions'. | |
4364 */ | |
4365 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
|
4366 modifiers_start = NULL; |
7 | 4367 if (cpo_koffset && offset && len < slen) |
4368 continue; | |
4369 if (STRNCMP(termcodes[idx].code, tp, | |
4370 (size_t)(slen > len ? len : slen)) == 0) | |
4371 { | |
4372 if (len < slen) /* got a partial sequence */ | |
4373 return -1; /* need to get more chars */ | |
4374 | |
4375 /* | |
4376 * When found a keypad key, check if there is another key | |
4377 * that matches and use that one. This makes <Home> to be | |
4378 * found instead of <kHome> when they produce the same | |
4379 * key code. | |
4380 */ | |
4381 if (termcodes[idx].name[0] == 'K' | |
4382 && VIM_ISDIGIT(termcodes[idx].name[1])) | |
4383 { | |
4384 for (j = idx + 1; j < tc_len; ++j) | |
4385 if (termcodes[j].len == slen && | |
4386 STRNCMP(termcodes[idx].code, | |
4387 termcodes[j].code, slen) == 0) | |
4388 { | |
4389 idx = j; | |
4390 break; | |
4391 } | |
4392 } | |
4393 | |
4394 key_name[0] = termcodes[idx].name[0]; | |
4395 key_name[1] = termcodes[idx].name[1]; | |
4396 break; | |
4397 } | |
179 | 4398 |
4399 /* | |
4400 * Check for code with modifier, like xterm uses: | |
180 | 4401 * <Esc>[123;*X (modslen == slen - 3) |
4402 * Also <Esc>O*X and <M-O>*X (modslen == slen - 2). | |
4403 * When there is a modifier the * matches a number. | |
4404 * When there is no modifier the ;* or * is omitted. | |
179 | 4405 */ |
4406 if (termcodes[idx].modlen > 0) | |
4407 { | |
180 | 4408 modslen = termcodes[idx].modlen; |
4409 if (cpo_koffset && offset && len < modslen) | |
179 | 4410 continue; |
4411 if (STRNCMP(termcodes[idx].code, tp, | |
180 | 4412 (size_t)(modslen > len ? len : modslen)) == 0) |
179 | 4413 { |
4414 int n; | |
180 | 4415 |
4416 if (len <= modslen) /* got a partial sequence */ | |
179 | 4417 return -1; /* need to get more chars */ |
4418 | |
180 | 4419 if (tp[modslen] == termcodes[idx].code[slen - 1]) |
4420 slen = modslen + 1; /* no modifiers */ | |
4421 else if (tp[modslen] != ';' && modslen == slen - 3) | |
179 | 4422 continue; /* no match */ |
4423 else | |
4424 { | |
4425 /* Skip over the digits, the final char must | |
4426 * 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
|
4427 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
|
4428 || tp[j] == ';'); ++j) |
179 | 4429 ; |
4430 ++j; | |
4431 if (len < j) /* got a partial sequence */ | |
4432 return -1; /* need to get more chars */ | |
180 | 4433 if (tp[j - 1] != termcodes[idx].code[slen - 1]) |
4434 continue; /* no match */ | |
179 | 4435 |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
4436 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
|
4437 |
179 | 4438 /* 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
|
4439 n = atoi((char *)modifiers_start) - 1; |
179 | 4440 if (n & 1) |
180 | 4441 modifiers |= MOD_MASK_SHIFT; |
179 | 4442 if (n & 2) |
180 | 4443 modifiers |= MOD_MASK_ALT; |
179 | 4444 if (n & 4) |
180 | 4445 modifiers |= MOD_MASK_CTRL; |
179 | 4446 if (n & 8) |
180 | 4447 modifiers |= MOD_MASK_META; |
179 | 4448 |
4449 slen = j; | |
4450 } | |
4451 key_name[0] = termcodes[idx].name[0]; | |
4452 key_name[1] = termcodes[idx].name[1]; | |
4453 break; | |
4454 } | |
4455 } | |
7 | 4456 } |
4457 } | |
4458 | |
4459 #ifdef FEAT_TERMRESPONSE | |
3166 | 4460 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
|
4461 /* Mouse codes of DEC and pterm start with <ESC>[. When |
6102 | 4462 * detecting the start of these mouse codes they might as well be |
4463 * another key code or terminal response. */ | |
4464 # ifdef FEAT_MOUSE_DEC | |
4465 || key_name[0] == KS_DEC_MOUSE | |
4466 # endif | |
4467 # ifdef FEAT_MOUSE_PTERM | |
4468 || key_name[0] == KS_PTERM_MOUSE | |
4223 | 4469 # endif |
6102 | 4470 ) |
7 | 4471 { |
6102 | 4472 /* Check for some responses from the terminal starting with |
4473 * "<Esc>[" or CSI: | |
4215 | 4474 * |
6102 | 4475 * - 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
|
4476 * Libvterm returns {x} == 0, {vers} == 100, {y} == 0. |
4215 | 4477 * Also eat other possible responses to t_RV, rxvt returns |
4478 * "<Esc>[?1;2c". Also accept CSI instead of <Esc>[. | |
4479 * mrxvt has been reported to have "+" in the version. Assume | |
4480 * the escape sequence ends with a letter or one of "{|}~". | |
4481 * | |
6102 | 4482 * - Cursor position report: <Esc>[{row};{col}R |
4483 * The final byte must be 'R'. It is used for checking the | |
4215 | 4484 * 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
|
4485 * |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4486 * - window position reply: <Esc>[3;{x};{y}t |
4215 | 4487 */ |
6901 | 4488 char_u *argp = tp[0] == ESC ? tp + 2 : tp + 1; |
4489 | |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
4490 if ((*T_CRV != NUL || *T_U7 != NUL || did_request_winpos) |
6901 | 4491 && ((tp[0] == ESC && len >= 3 && tp[1] == '[') |
4395 | 4492 || (tp[0] == CSI && len >= 2)) |
6874 | 4493 && (VIM_ISDIGIT(*argp) || *argp == '>' || *argp == '?')) |
7 | 4494 { |
11784
80fa4b0eb0b0
patch 8.0.0774: build failure without the multi-byte feature
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
4495 int col = 0; |
80fa4b0eb0b0
patch 8.0.0774: build failure without the multi-byte feature
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
4496 int semicols = 0; |
5724 | 4497 #ifdef FEAT_MBYTE |
5743 | 4498 int row_char = NUL; |
5724 | 4499 #endif |
11784
80fa4b0eb0b0
patch 8.0.0774: build failure without the multi-byte feature
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
4500 |
7 | 4501 extra = 0; |
1552 | 4502 for (i = 2 + (tp[0] != CSI); i < len |
4503 && !(tp[i] >= '{' && tp[i] <= '~') | |
4504 && !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
|
4505 if (tp[i] == ';' && ++semicols == 1) |
5724 | 4506 { |
4395 | 4507 extra = i + 1; |
5724 | 4508 #ifdef FEAT_MBYTE |
4509 row_char = tp[i - 1]; | |
4510 #endif | |
4511 } | |
7 | 4512 if (i == len) |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4513 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4514 LOG_TR("Not enough characters for CRV"); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4515 return -1; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4516 } |
5724 | 4517 if (extra > 0) |
4518 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
|
4519 |
80fa4b0eb0b0
patch 8.0.0774: build failure without the multi-byte feature
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
4520 #ifdef FEAT_MBYTE |
5724 | 4521 /* Eat it when it has 2 arguments and ends in 'R'. Also when |
4522 * u7_status is not "sent", it may be from a previous Vim that | |
4523 * just exited. But not for <S-F3>, it sends something | |
4524 * 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
|
4525 if (semicols == 1 && tp[i] == 'R') |
4215 | 4526 { |
6102 | 4527 if (row_char == '2' && col >= 2) |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4528 { |
6102 | 4529 char *aw = NULL; |
4530 | |
4531 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
|
4532 u7_status = STATUS_GOT; |
6102 | 4533 did_cursorhold = TRUE; |
4534 if (col == 2) | |
4535 aw = "single"; | |
4536 else if (col == 3) | |
4537 aw = "double"; | |
4538 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
|
4539 { |
6102 | 4540 /* Setting the option causes a screen redraw. Do |
4541 * that right away if possible, keeping any | |
4542 * messages. */ | |
4543 set_option_value((char_u *)"ambw", 0L, | |
4544 (char_u *)aw, 0); | |
4545 # ifdef DEBUG_TERMRESPONSE | |
4546 { | |
4547 char buf[100]; | |
4548 int r = redraw_asap(CLEAR); | |
4549 | |
4550 sprintf(buf, | |
4551 "set 'ambiwidth', redraw_asap(): %d", | |
4552 r); | |
4553 log_tr(buf); | |
4554 } | |
4555 # else | |
4556 redraw_asap(CLEAR); | |
4557 # endif | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4558 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4559 } |
4215 | 4560 key_name[0] = (int)KS_EXTRA; |
4561 key_name[1] = (int)KE_IGNORE; | |
4562 slen = i + 1; | |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4563 # ifdef FEAT_EVAL |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4564 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
|
4565 # endif |
4215 | 4566 } |
4567 else | |
4568 #endif | |
7 | 4569 /* eat it when at least one digit and ending in 'c' */ |
4215 | 4570 if (*T_CRV != NUL && i > 2 + (tp[0] != CSI) && tp[i] == 'c') |
7 | 4571 { |
12307
50b0b3aaa545
patch 8.0.1033: detecting background color does not work in screen
Christian Brabandt <cb@256bit.org>
parents:
12295
diff
changeset
|
4572 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
|
4573 |
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
|
4574 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
|
4575 crv_status = STATUS_GOT; |
4262 | 4576 did_cursorhold = TRUE; |
7 | 4577 |
4578 /* If this code starts with CSI, you can bet that the | |
4579 * terminal uses 8-bit codes. */ | |
4580 if (tp[0] == CSI) | |
4581 switch_to_8bit(); | |
4582 | |
4583 /* 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
|
4584 * Screen sends 40500. |
7 | 4585 * Ignore it for when the user has set 'term' to xterm, |
4586 * 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
|
4587 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
|
4588 version = 0; |
7 | 4589 |
11784
80fa4b0eb0b0
patch 8.0.0774: build failure without the multi-byte feature
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
4590 if (tp[1 + (tp[0] != CSI)] == '>' && semicols == 2) |
7 | 4591 { |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4592 int need_flush = FALSE; |
12853
b2a8d6ef578b
patch 8.0.1303: 'ttymouse' is not set to "sgr" for Terminal.app and Iterm2
Christian Brabandt <cb@256bit.org>
parents:
12790
diff
changeset
|
4593 # ifdef FEAT_MOUSE_SGR |
b2a8d6ef578b
patch 8.0.1303: 'ttymouse' is not set to "sgr" for Terminal.app and Iterm2
Christian Brabandt <cb@256bit.org>
parents:
12790
diff
changeset
|
4594 int is_iterm2 = FALSE; |
b2a8d6ef578b
patch 8.0.1303: 'ttymouse' is not set to "sgr" for Terminal.app and Iterm2
Christian Brabandt <cb@256bit.org>
parents:
12790
diff
changeset
|
4595 # endif |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4596 |
7 | 4597 /* 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
|
4598 if (version >= 141) |
7 | 4599 { |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4600 LOG_TR("Enable checking for XT codes"); |
7 | 4601 check_for_codes = TRUE; |
4602 need_gather = TRUE; | |
4603 req_codes_from_term(); | |
4604 } | |
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
|
4605 |
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
|
4606 /* 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
|
4607 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
|
4608 && 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
|
4609 { |
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
|
4610 /* 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
|
4611 * 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
|
4612 * 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
|
4613 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
|
4614 may_adjust_color_count(256); |
12761
2c502179c75d
patch 8.0.1258: 'ttymouse' is set to "sgr" even though it's not supported
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
4615 # ifdef FEAT_MOUSE_SGR |
2c502179c75d
patch 8.0.1258: 'ttymouse' is set to "sgr" even though it's not supported
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
4616 /* Libvterm can handle SGR mouse reporting. */ |
2c502179c75d
patch 8.0.1258: 'ttymouse' is set to "sgr" even though it's not supported
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
4617 if (!option_was_set((char_u *)"ttym")) |
2c502179c75d
patch 8.0.1258: 'ttymouse' is set to "sgr" even though it's not supported
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
4618 set_option_value((char_u *)"ttym", 0L, |
2c502179c75d
patch 8.0.1258: 'ttymouse' is set to "sgr" even though it's not supported
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
4619 (char_u *)"sgr", 0); |
2c502179c75d
patch 8.0.1258: 'ttymouse' is set to "sgr" even though it's not supported
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
4620 # endif |
2c502179c75d
patch 8.0.1258: 'ttymouse' is set to "sgr" even though it's not supported
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
4621 } |
2c502179c75d
patch 8.0.1258: 'ttymouse' is set to "sgr" even though it's not supported
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
4622 |
12853
b2a8d6ef578b
patch 8.0.1303: 'ttymouse' is not set to "sgr" for Terminal.app and Iterm2
Christian Brabandt <cb@256bit.org>
parents:
12790
diff
changeset
|
4623 if (version == 95) |
b2a8d6ef578b
patch 8.0.1303: 'ttymouse' is not set to "sgr" for Terminal.app and Iterm2
Christian Brabandt <cb@256bit.org>
parents:
12790
diff
changeset
|
4624 { |
b2a8d6ef578b
patch 8.0.1303: 'ttymouse' is not set to "sgr" for Terminal.app and Iterm2
Christian Brabandt <cb@256bit.org>
parents:
12790
diff
changeset
|
4625 /* Mac Terminal.app sends 1;95;0 */ |
b2a8d6ef578b
patch 8.0.1303: 'ttymouse' is not set to "sgr" for Terminal.app and Iterm2
Christian Brabandt <cb@256bit.org>
parents:
12790
diff
changeset
|
4626 if (STRNCMP(tp + extra - 2, "1;95;0c", 7) == 0) |
b2a8d6ef578b
patch 8.0.1303: 'ttymouse' is not set to "sgr" for Terminal.app and Iterm2
Christian Brabandt <cb@256bit.org>
parents:
12790
diff
changeset
|
4627 { |
b2a8d6ef578b
patch 8.0.1303: 'ttymouse' is not set to "sgr" for Terminal.app and Iterm2
Christian Brabandt <cb@256bit.org>
parents:
12790
diff
changeset
|
4628 is_not_xterm = TRUE; |
b2a8d6ef578b
patch 8.0.1303: 'ttymouse' is not set to "sgr" for Terminal.app and Iterm2
Christian Brabandt <cb@256bit.org>
parents:
12790
diff
changeset
|
4629 is_mac_terminal = TRUE; |
b2a8d6ef578b
patch 8.0.1303: 'ttymouse' is not set to "sgr" for Terminal.app and Iterm2
Christian Brabandt <cb@256bit.org>
parents:
12790
diff
changeset
|
4630 } |
b2a8d6ef578b
patch 8.0.1303: 'ttymouse' is not set to "sgr" for Terminal.app and Iterm2
Christian Brabandt <cb@256bit.org>
parents:
12790
diff
changeset
|
4631 # ifdef FEAT_MOUSE_SGR |
13008
e775011b4c1e
patch 8.0.1380: using "vim -r swapfile" the hit-enter prompt is misplaced.
Christian Brabandt <cb@256bit.org>
parents:
12895
diff
changeset
|
4632 /* iTerm2 sends 0;95;0 */ |
12853
b2a8d6ef578b
patch 8.0.1303: 'ttymouse' is not set to "sgr" for Terminal.app and Iterm2
Christian Brabandt <cb@256bit.org>
parents:
12790
diff
changeset
|
4633 if (STRNCMP(tp + extra - 2, "0;95;0c", 7) == 0) |
b2a8d6ef578b
patch 8.0.1303: 'ttymouse' is not set to "sgr" for Terminal.app and Iterm2
Christian Brabandt <cb@256bit.org>
parents:
12790
diff
changeset
|
4634 is_iterm2 = TRUE; |
b2a8d6ef578b
patch 8.0.1303: 'ttymouse' is not set to "sgr" for Terminal.app and Iterm2
Christian Brabandt <cb@256bit.org>
parents:
12790
diff
changeset
|
4635 # endif |
b2a8d6ef578b
patch 8.0.1303: 'ttymouse' is not set to "sgr" for Terminal.app and Iterm2
Christian Brabandt <cb@256bit.org>
parents:
12790
diff
changeset
|
4636 } |
b2a8d6ef578b
patch 8.0.1303: 'ttymouse' is not set to "sgr" for Terminal.app and Iterm2
Christian Brabandt <cb@256bit.org>
parents:
12790
diff
changeset
|
4637 |
12761
2c502179c75d
patch 8.0.1258: 'ttymouse' is set to "sgr" even though it's not supported
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
4638 /* Only set 'ttymouse' automatically if it was not set |
2c502179c75d
patch 8.0.1258: 'ttymouse' is set to "sgr" even though it's not supported
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
4639 * by the user already. */ |
2c502179c75d
patch 8.0.1258: 'ttymouse' is set to "sgr" even though it's not supported
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
4640 if (!option_was_set((char_u *)"ttym")) |
2c502179c75d
patch 8.0.1258: 'ttymouse' is set to "sgr" even though it's not supported
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
4641 { |
2c502179c75d
patch 8.0.1258: 'ttymouse' is set to "sgr" even though it's not supported
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
4642 # ifdef FEAT_MOUSE_SGR |
12853
b2a8d6ef578b
patch 8.0.1303: 'ttymouse' is not set to "sgr" for Terminal.app and Iterm2
Christian Brabandt <cb@256bit.org>
parents:
12790
diff
changeset
|
4643 /* Xterm version 277 supports SGR. Also support |
13008
e775011b4c1e
patch 8.0.1380: using "vim -r swapfile" the hit-enter prompt is misplaced.
Christian Brabandt <cb@256bit.org>
parents:
12895
diff
changeset
|
4644 * Terminal.app and iTerm2. */ |
12853
b2a8d6ef578b
patch 8.0.1303: 'ttymouse' is not set to "sgr" for Terminal.app and Iterm2
Christian Brabandt <cb@256bit.org>
parents:
12790
diff
changeset
|
4645 if (version >= 277 || is_iterm2 || is_mac_terminal) |
12761
2c502179c75d
patch 8.0.1258: 'ttymouse' is set to "sgr" even though it's not supported
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
4646 set_option_value((char_u *)"ttym", 0L, |
2c502179c75d
patch 8.0.1258: 'ttymouse' is set to "sgr" even though it's not supported
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
4647 (char_u *)"sgr", 0); |
2c502179c75d
patch 8.0.1258: 'ttymouse' is set to "sgr" even though it's not supported
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
4648 else |
2c502179c75d
patch 8.0.1258: 'ttymouse' is set to "sgr" even though it's not supported
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
4649 # endif |
2c502179c75d
patch 8.0.1258: 'ttymouse' is set to "sgr" even though it's not supported
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
4650 /* if xterm version >= 95 use mouse dragging */ |
2c502179c75d
patch 8.0.1258: 'ttymouse' is set to "sgr" even though it's not supported
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
4651 if (version >= 95) |
2c502179c75d
patch 8.0.1258: 'ttymouse' is set to "sgr" even though it's not supported
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
4652 set_option_value((char_u *)"ttym", 0L, |
2c502179c75d
patch 8.0.1258: 'ttymouse' is set to "sgr" even though it's not supported
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
4653 (char_u *)"xterm2", 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
|
4654 } |
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
|
4655 |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4656 /* 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
|
4657 * "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
|
4658 * 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
|
4659 |
12359
c83669fb7601
patch 8.0.1059: older Gnome terminal returns smaller version number
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
4660 /* 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
|
4661 * 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
|
4662 * 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
|
4663 * 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
|
4664 * 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
|
4665 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
|
4666 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
|
4667 |
12373
71524e1a717b
patch 8.0.1066: some terminals can't handle requesting cursor mode
Christian Brabandt <cb@256bit.org>
parents:
12359
diff
changeset
|
4668 /* 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
|
4669 * 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
|
4670 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
|
4671 && 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
|
4672 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
|
4673 |
270256b6d0b8
patch 8.0.1027: more terminals can't handle requesting cursor mode
Christian Brabandt <cb@256bit.org>
parents:
12283
diff
changeset
|
4674 /* 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
|
4675 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
|
4676 && 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
|
4677 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
|
4678 |
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
|
4679 /* 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
|
4680 * 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
|
4681 * 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
|
4682 * 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
|
4683 * 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
|
4684 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
|
4685 && version >= 279 |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4686 && !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
|
4687 && *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
|
4688 && *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
|
4689 { |
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
|
4690 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
|
4691 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
|
4692 rcs_status = STATUS_SENT; |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4693 need_flush = TRUE; |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4694 } |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4695 |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4696 /* 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
|
4697 * 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
|
4698 * 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
|
4699 if (rbm_status == STATUS_GET |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4700 && !is_not_xterm |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4701 && *T_CRC != NUL) |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4702 { |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4703 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
|
4704 out_str(T_CRC); |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4705 rbm_status = STATUS_SENT; |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4706 need_flush = TRUE; |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4707 } |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4708 |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4709 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
|
4710 out_flush(); |
7 | 4711 } |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4712 slen = i + 1; |
7 | 4713 # ifdef FEAT_EVAL |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4714 set_vim_var_string(VV_TERMRESPONSE, tp, slen); |
7 | 4715 # endif |
4716 apply_autocmds(EVENT_TERMRESPONSE, | |
4717 NULL, NULL, FALSE, curbuf); | |
4718 key_name[0] = (int)KS_EXTRA; | |
4719 key_name[1] = (int)KE_IGNORE; | |
4720 } | |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4721 |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4722 /* 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
|
4723 * {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
|
4724 * {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
|
4725 * |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4726 * {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
|
4727 */ |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4728 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
|
4729 && 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
|
4730 && i == j + 6 |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4731 && 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
|
4732 && 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
|
4733 && tp[j + 3] == ';' |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4734 && tp[i - 1] == '$' |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4735 && tp[i] == 'y') |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4736 { |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4737 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
|
4738 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
|
4739 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
|
4740 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
|
4741 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
|
4742 slen = i + 1; |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4743 # ifdef FEAT_EVAL |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4744 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
|
4745 # endif |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4746 } |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4747 |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4748 /* |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4749 * 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
|
4750 * {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
|
4751 */ |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
4752 else if (did_request_winpos |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4753 && ((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
|
4754 || (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
|
4755 && 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
|
4756 && 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
|
4757 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4758 j += 2; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4759 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
|
4760 ; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4761 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
|
4762 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4763 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
|
4764 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
|
4765 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
|
4766 ; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4767 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
|
4768 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4769 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
|
4770 /* 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
|
4771 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
|
4772 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
|
4773 slen = i + 1; |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
4774 |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
4775 if (--did_request_winpos <= 0) |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
4776 winpos_status = STATUS_GOT; |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4777 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4778 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4779 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
|
4780 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4781 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
|
4782 return -1; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4783 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4784 } |
6901 | 4785 } |
4786 | |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4787 /* Check for fore/background color response from the terminal: |
6901 | 4788 * |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4789 * {lead}{code};rgb:{rrrr}/{gggg}/{bbbb}{tail} |
6901 | 4790 * |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4791 * {code} is 10 for foreground, 11 for background |
6901 | 4792 * {lead} can be <Esc>] or OSC |
4793 * {tail} can be '\007', <Esc>\ or STERM. | |
4794 * | |
4795 * Consume any code that starts with "{lead}11;", it's also | |
4796 * possible that "rgba" is following. | |
4797 */ | |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4798 else if ((*T_RBG != NUL || *T_RFG != NUL) |
6901 | 4799 && ((tp[0] == ESC && len >= 2 && tp[1] == ']') |
4800 || tp[0] == OSC)) | |
4801 { | |
4802 j = 1 + (tp[0] == ESC); | |
4803 if (len >= j + 3 && (argp[0] != '1' | |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4804 || (argp[1] != '1' && argp[1] != '0') |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4805 || argp[2] != ';')) |
6901 | 4806 i = 0; /* no match */ |
4807 else | |
4808 for (i = j; i < len; ++i) | |
4809 if (tp[i] == '\007' || (tp[0] == OSC ? tp[i] == STERM | |
4810 : (tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\'))) | |
4811 { | |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4812 int is_bg = argp[1] == '1'; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4813 |
6901 | 4814 if (i - j >= 21 && STRNCMP(tp + j + 3, "rgb:", 4) == 0 |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4815 && tp[j + 11] == '/' && tp[j + 16] == '/') |
11453
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4816 { |
12790
305693246ff6
patch 8.0.1272: warnings for unused variables in tiny build
Christian Brabandt <cb@256bit.org>
parents:
12761
diff
changeset
|
4817 #ifdef FEAT_TERMINAL |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4818 int rval = hexhex2nr(tp + j + 7); |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4819 int gval = hexhex2nr(tp + j + 12); |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4820 int bval = hexhex2nr(tp + j + 17); |
12790
305693246ff6
patch 8.0.1272: warnings for unused variables in tiny build
Christian Brabandt <cb@256bit.org>
parents:
12761
diff
changeset
|
4821 #endif |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4822 if (is_bg) |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4823 { |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4824 char *newval = (3 * '6' < tp[j+7] + tp[j+12] |
11453
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4825 + 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
|
4826 |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4827 LOG_TR("Received RBG response"); |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4828 rbg_status = STATUS_GOT; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4829 #ifdef FEAT_TERMINAL |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4830 bg_r = rval; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4831 bg_g = gval; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4832 bg_b = bval; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4833 #endif |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4834 if (!option_was_set((char_u *)"bg") |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4835 && STRCMP(p_bg, newval) != 0) |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4836 { |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4837 /* value differs, apply it */ |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4838 set_option_value((char_u *)"bg", 0L, |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4839 (char_u *)newval, 0); |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4840 reset_option_was_set((char_u *)"bg"); |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4841 redraw_asap(CLEAR); |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4842 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4843 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4844 #ifdef FEAT_TERMINAL |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4845 else |
11453
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4846 { |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4847 LOG_TR("Received RFG response"); |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4848 rfg_status = STATUS_GOT; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4849 fg_r = rval; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4850 fg_g = gval; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4851 fg_b = bval; |
11453
ec47e673a021
patch 8.0.0610: the screen is redrawn when default 'background' is detected
Christian Brabandt <cb@256bit.org>
parents:
11368
diff
changeset
|
4852 } |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4853 #endif |
6901 | 4854 } |
4855 | |
4856 /* got finished code: consume it */ | |
4857 key_name[0] = (int)KS_EXTRA; | |
4858 key_name[1] = (int)KE_IGNORE; | |
4859 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
|
4860 # ifdef FEAT_EVAL |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4861 set_vim_var_string(is_bg ? VV_TERMRBGRESP |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4862 : VV_TERMRFGRESP, tp, slen); |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4863 # endif |
6901 | 4864 break; |
4865 } | |
4866 if (i == len) | |
6874 | 4867 { |
6901 | 4868 LOG_TR("not enough characters for RB"); |
4869 return -1; | |
6874 | 4870 } |
7 | 4871 } |
4872 | |
6901 | 4873 /* Check for key code response from xterm: |
4874 * {lead}{flag}+r<hex bytes><{tail} | |
4875 * | |
4876 * {lead} can be <Esc>P or DCS | |
4877 * {flag} can be '0' or '1' | |
4878 * {tail} can be Esc>\ or STERM | |
4879 * | |
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
|
4880 * Check for cursor shape response from xterm: |
13365
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4881 * {lead}1$r<digit> q{tail} |
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
|
4882 * |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4883 * {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
|
4884 * {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
|
4885 * |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4886 * Consume any code that starts with "{lead}.+r" or "{lead}.$r". |
6901 | 4887 */ |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4888 else if ((check_for_codes || rcs_status == STATUS_SENT) |
6901 | 4889 && ((tp[0] == ESC && len >= 2 && tp[1] == 'P') |
7 | 4890 || tp[0] == DCS)) |
4891 { | |
6901 | 4892 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
|
4893 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
|
4894 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
|
4895 else if ((argp[1] != '+' && argp[1] != '$') || argp[2] != 'r') |
6901 | 4896 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
|
4897 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
|
4898 /* key code response */ |
6901 | 4899 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
|
4900 { |
6901 | 4901 if ((tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\') |
7 | 4902 || tp[i] == STERM) |
4903 { | |
6901 | 4904 if (i - j >= 3) |
7 | 4905 got_code_from_term(tp + j, i); |
4906 key_name[0] = (int)KS_EXTRA; | |
4907 key_name[1] = (int)KE_IGNORE; | |
4908 slen = i + 1 + (tp[i] == ESC); | |
4909 break; | |
4910 } | |
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
|
4911 } |
13365
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4912 else |
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
|
4913 { |
13365
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4914 /* Probably the cursor shape response. Make sure that "i" |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4915 * is equal to "len" when there are not sufficient |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4916 * characters. */ |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4917 for (i = j + 3; 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
|
4918 { |
13365
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4919 if (i - j == 3 && !isdigit(tp[i])) |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4920 break; |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4921 if (i - j == 4 && tp[i] != ' ') |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4922 break; |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4923 if (i - j == 5 && tp[i] != 'q') |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4924 break; |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4925 if (i - j == 6 && tp[i] != ESC && tp[i] != STERM) |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4926 break; |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4927 if ((i - j == 6 && tp[i] == STERM) |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4928 || (i - j == 7 && tp[i] == '\\')) |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4929 { |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4930 int number = argp[3] - '0'; |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4931 |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4932 /* 0, 1 = block blink, 2 = block |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4933 * 3 = underline blink, 4 = underline |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4934 * 5 = vertical bar blink, 6 = vertical bar */ |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4935 number = number == 0 ? 1 : number; |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4936 initial_cursor_shape = (number + 1) / 2; |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4937 /* The blink flag is actually inverted, compared to |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4938 * the value set with T_SH. */ |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4939 initial_cursor_shape_blink = |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4940 (number & 1) ? FALSE : TRUE; |
13365
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4941 rcs_status = STATUS_GOT; |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4942 LOG_TR("Received cursor shape response"); |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4943 |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4944 key_name[0] = (int)KS_EXTRA; |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4945 key_name[1] = (int)KE_IGNORE; |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4946 slen = i + 1; |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4947 # ifdef FEAT_EVAL |
13365
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4948 set_vim_var_string(VV_TERMSTYLERESP, tp, slen); |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4949 # endif |
13365
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4950 break; |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
4951 } |
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
|
4952 } |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4953 } |
7 | 4954 |
4955 if (i == len) | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4956 { |
6901 | 4957 /* These codes arrive many together, each code can be |
4958 * truncated at any point. */ | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4959 LOG_TR("not enough characters for XT"); |
6901 | 4960 return -1; |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4961 } |
7 | 4962 } |
4963 } | |
4964 #endif | |
4965 | |
4966 if (key_name[0] == NUL) | |
4967 continue; /* No match at this position, try next one */ | |
4968 | |
4969 /* We only get here when we have a complete termcode match */ | |
4970 | |
4971 #ifdef FEAT_MOUSE | |
4972 # ifdef FEAT_GUI | |
4973 /* | |
4974 * Only in the GUI: Fetch the pointer coordinates of the scroll event | |
4975 * so that we know which window to scroll later. | |
4976 */ | |
4977 if (gui.in_use | |
4978 && key_name[0] == (int)KS_EXTRA | |
4979 && (key_name[1] == (int)KE_X1MOUSE | |
4980 || 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
|
4981 || key_name[1] == (int)KE_MOUSELEFT |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2347
diff
changeset
|
4982 || key_name[1] == (int)KE_MOUSERIGHT |
7 | 4983 || key_name[1] == (int)KE_MOUSEDOWN |
4984 || key_name[1] == (int)KE_MOUSEUP)) | |
4985 { | |
4986 num_bytes = get_bytes_from_buf(tp + slen, bytes, 4); | |
4987 if (num_bytes == -1) /* not enough coordinates */ | |
4988 return -1; | |
4989 mouse_col = 128 * (bytes[0] - ' ' - 1) + bytes[1] - ' ' - 1; | |
4990 mouse_row = 128 * (bytes[2] - ' ' - 1) + bytes[3] - ' ' - 1; | |
4991 slen += num_bytes; | |
4992 } | |
4993 else | |
4994 # endif | |
4995 /* | |
4996 * If it is a mouse click, get the coordinates. | |
4997 */ | |
3746 | 4998 if (key_name[0] == KS_MOUSE |
7 | 4999 # ifdef FEAT_MOUSE_JSB |
3746 | 5000 || key_name[0] == KS_JSBTERM_MOUSE |
7 | 5001 # endif |
5002 # ifdef FEAT_MOUSE_NET | |
3746 | 5003 || key_name[0] == KS_NETTERM_MOUSE |
7 | 5004 # endif |
5005 # ifdef FEAT_MOUSE_DEC | |
3746 | 5006 || key_name[0] == KS_DEC_MOUSE |
7 | 5007 # endif |
5008 # ifdef FEAT_MOUSE_PTERM | |
3746 | 5009 || key_name[0] == KS_PTERM_MOUSE |
7 | 5010 # endif |
3166 | 5011 # ifdef FEAT_MOUSE_URXVT |
3746 | 5012 || key_name[0] == KS_URXVT_MOUSE |
5013 # endif | |
5014 # ifdef FEAT_MOUSE_SGR | |
5015 || 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
|
5016 || key_name[0] == KS_SGR_MOUSE_RELEASE |
3166 | 5017 # endif |
7 | 5018 ) |
5019 { | |
5020 is_click = is_drag = FALSE; | |
5021 | |
1623 | 5022 # if !defined(UNIX) || defined(FEAT_MOUSE_XTERM) || defined(FEAT_GUI) \ |
5023 || defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE) | |
7 | 5024 if (key_name[0] == (int)KS_MOUSE) |
5025 { | |
5026 /* | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
5027 * For xterm we get "<t_mouse>scr", where |
7 | 5028 * s == encoded button state: |
5029 * 0x20 = left button down | |
5030 * 0x21 = middle button down | |
5031 * 0x22 = right button down | |
5032 * 0x23 = any button release | |
5033 * 0x60 = button 4 down (scroll wheel down) | |
5034 * 0x61 = button 5 down (scroll wheel up) | |
5035 * add 0x04 for SHIFT | |
5036 * add 0x08 for ALT | |
5037 * add 0x10 for CTRL | |
5038 * add 0x20 for mouse drag (0x40 is drag with left button) | |
12895
d872005ecfcd
patch 8.0.1324: some xterm sends different mouse move codes
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
5039 * add 0x40 for mouse move (0x80 is move, 0x81 too) |
d872005ecfcd
patch 8.0.1324: some xterm sends different mouse move codes
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
5040 * 0x43 (drag + release) is also move |
7 | 5041 * c == column + ' ' + 1 == column + 33 |
5042 * r == row + ' ' + 1 == row + 33 | |
5043 * | |
5044 * The coordinates are passed on through global variables. | |
5045 * Ugly, but this avoids trouble with mouse clicks at an | |
5046 * unexpected moment and allows for mapping them. | |
5047 */ | |
5048 for (;;) | |
5049 { | |
5050 #ifdef FEAT_GUI | |
5051 if (gui.in_use) | |
5052 { | |
5053 /* GUI uses more bits for columns > 223 */ | |
5054 num_bytes = get_bytes_from_buf(tp + slen, bytes, 5); | |
5055 if (num_bytes == -1) /* not enough coordinates */ | |
5056 return -1; | |
5057 mouse_code = bytes[0]; | |
5058 mouse_col = 128 * (bytes[1] - ' ' - 1) | |
5059 + bytes[2] - ' ' - 1; | |
5060 mouse_row = 128 * (bytes[3] - ' ' - 1) | |
5061 + bytes[4] - ' ' - 1; | |
5062 } | |
5063 else | |
5064 #endif | |
5065 { | |
5066 num_bytes = get_bytes_from_buf(tp + slen, bytes, 3); | |
5067 if (num_bytes == -1) /* not enough coordinates */ | |
5068 return -1; | |
5069 mouse_code = bytes[0]; | |
5070 mouse_col = bytes[1] - ' ' - 1; | |
5071 mouse_row = bytes[2] - ' ' - 1; | |
5072 } | |
5073 slen += num_bytes; | |
5074 | |
5075 /* If the following bytes is also a mouse code and it has | |
5076 * the same code, dump this one and get the next. This | |
5077 * makes dragging a whole lot faster. */ | |
5078 #ifdef FEAT_GUI | |
5079 if (gui.in_use) | |
5080 j = 3; | |
5081 else | |
5082 #endif | |
5083 j = termcodes[idx].len; | |
5084 if (STRNCMP(tp, tp + slen, (size_t)j) == 0 | |
5085 && tp[slen + j] == mouse_code | |
5086 && tp[slen + j + 1] != NUL | |
5087 && tp[slen + j + 2] != NUL | |
5088 #ifdef FEAT_GUI | |
5089 && (!gui.in_use | |
5090 || (tp[slen + j + 3] != NUL | |
5091 && tp[slen + j + 4] != NUL)) | |
5092 #endif | |
5093 ) | |
5094 slen += j; | |
5095 else | |
5096 break; | |
5097 } | |
3166 | 5098 } |
5099 | |
3746 | 5100 # if defined(FEAT_MOUSE_URXVT) || defined(FEAT_MOUSE_SGR) |
5101 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
|
5102 || 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
|
5103 || key_name[0] == KS_SGR_MOUSE_RELEASE) |
3166 | 5104 { |
11567
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5105 /* URXVT 1015 mouse reporting mode: |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5106 * 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
|
5107 * are decimal instead of bytes. |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5108 * |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5109 * \033[%d;%d;%dM |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5110 * ^-- row |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5111 * ^----- column |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5112 * ^-------- code |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5113 * |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5114 * SGR 1006 mouse reporting mode: |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5115 * 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
|
5116 * are decimal instead of bytes. |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5117 * |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5118 * \033[<%d;%d;%dM |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5119 * ^-- row |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5120 * ^----- column |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5121 * ^-------- code |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5122 * |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5123 * \033[<%d;%d;%dm : mouse release event |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5124 * ^-- row |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5125 * ^----- column |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5126 * ^-------- code |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5127 */ |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5128 p = modifiers_start; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5129 if (p == NULL) |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5130 return -1; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5131 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5132 mouse_code = getdigits(&p); |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5133 if (*p++ != ';') |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5134 return -1; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5135 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5136 /* 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
|
5137 if (key_name[0] == KS_SGR_MOUSE |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5138 || key_name[0] == KS_SGR_MOUSE_RELEASE) |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5139 mouse_code += 32; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5140 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5141 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
|
5142 mouse_code |= MOUSE_RELEASE; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5143 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5144 mouse_col = getdigits(&p) - 1; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5145 if (*p++ != ';') |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5146 return -1; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5147 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5148 mouse_row = getdigits(&p) - 1; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5149 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5150 /* 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
|
5151 * modifier keys (alt/shift/ctrl/meta) state. */ |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5152 modifiers = 0; |
3166 | 5153 } |
5154 # endif | |
5155 | |
5156 if (key_name[0] == (int)KS_MOUSE | |
5157 #ifdef FEAT_MOUSE_URXVT | |
5158 || key_name[0] == (int)KS_URXVT_MOUSE | |
5159 #endif | |
3746 | 5160 #ifdef FEAT_MOUSE_SGR |
5161 || 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
|
5162 || key_name[0] == KS_SGR_MOUSE_RELEASE |
3746 | 5163 #endif |
3166 | 5164 ) |
5165 { | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
5166 # if !defined(MSWIN) |
7 | 5167 /* |
5168 * Handle mouse events. | |
5169 * Recognize the xterm mouse wheel, but not in the GUI, the | |
5170 * Linux console with GPM and the MS-DOS or Win32 console | |
5171 * (multi-clicks use >= 0x60). | |
5172 */ | |
5173 if (mouse_code >= MOUSEWHEEL_LOW | |
5174 # ifdef FEAT_GUI | |
5175 && !gui.in_use | |
5176 # endif | |
5177 # ifdef FEAT_MOUSE_GPM | |
5178 && gpm_flag == 0 | |
5179 # endif | |
5180 ) | |
5181 { | |
12895
d872005ecfcd
patch 8.0.1324: some xterm sends different mouse move codes
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
5182 # if defined(UNIX) && defined(FEAT_MOUSE_TTY) |
d872005ecfcd
patch 8.0.1324: some xterm sends different mouse move codes
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
5183 if (use_xterm_mouse() > 1 && mouse_code >= 0x80) |
d872005ecfcd
patch 8.0.1324: some xterm sends different mouse move codes
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
5184 /* mouse-move event, using MOUSE_DRAG works */ |
d872005ecfcd
patch 8.0.1324: some xterm sends different mouse move codes
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
5185 mouse_code = MOUSE_DRAG; |
d872005ecfcd
patch 8.0.1324: some xterm sends different mouse move codes
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
5186 else |
d872005ecfcd
patch 8.0.1324: some xterm sends different mouse move codes
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
5187 # endif |
d872005ecfcd
patch 8.0.1324: some xterm sends different mouse move codes
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
5188 /* Keep the mouse_code before it's changed, so that we |
d872005ecfcd
patch 8.0.1324: some xterm sends different mouse move codes
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
5189 * remember that it was a mouse wheel click. */ |
d872005ecfcd
patch 8.0.1324: some xterm sends different mouse move codes
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
5190 wheel_code = mouse_code; |
7 | 5191 } |
5192 # ifdef FEAT_MOUSE_XTERM | |
5193 else if (held_button == MOUSE_RELEASE | |
5194 # ifdef FEAT_GUI | |
5195 && !gui.in_use | |
5196 # endif | |
5197 && (mouse_code == 0x23 || mouse_code == 0x24)) | |
5198 { | |
5199 /* Apparently used by rxvt scroll wheel. */ | |
5200 wheel_code = mouse_code - 0x23 + MOUSEWHEEL_LOW; | |
5201 } | |
5202 # endif | |
5203 | |
5204 # if defined(UNIX) && defined(FEAT_MOUSE_TTY) | |
5205 else if (use_xterm_mouse() > 1) | |
5206 { | |
5207 if (mouse_code & MOUSE_DRAG_XTERM) | |
5208 mouse_code |= MOUSE_DRAG; | |
5209 } | |
5210 # endif | |
5211 # ifdef FEAT_XCLIPBOARD | |
5212 else if (!(mouse_code & MOUSE_DRAG & ~MOUSE_CLICK_MASK)) | |
5213 { | |
5214 if ((mouse_code & MOUSE_RELEASE) == MOUSE_RELEASE) | |
5215 stop_xterm_trace(); | |
5216 else | |
5217 start_xterm_trace(mouse_code); | |
5218 } | |
5219 # endif | |
5220 # endif | |
5221 } | |
5222 # endif /* !UNIX || FEAT_MOUSE_XTERM */ | |
5223 # ifdef FEAT_MOUSE_NET | |
5224 if (key_name[0] == (int)KS_NETTERM_MOUSE) | |
5225 { | |
5226 int mc, mr; | |
5227 | |
5228 /* expect a rather limited sequence like: balancing { | |
5229 * \033}6,45\r | |
5230 * '6' is the row, 45 is the column | |
5231 */ | |
5232 p = tp + slen; | |
5233 mr = getdigits(&p); | |
5234 if (*p++ != ',') | |
5235 return -1; | |
5236 mc = getdigits(&p); | |
5237 if (*p++ != '\r') | |
5238 return -1; | |
5239 | |
5240 mouse_col = mc - 1; | |
5241 mouse_row = mr - 1; | |
5242 mouse_code = MOUSE_LEFT; | |
5243 slen += (int)(p - (tp + slen)); | |
5244 } | |
5245 # endif /* FEAT_MOUSE_NET */ | |
5246 # ifdef FEAT_MOUSE_JSB | |
5247 if (key_name[0] == (int)KS_JSBTERM_MOUSE) | |
5248 { | |
5249 int mult, val, iter, button, status; | |
5250 | |
5251 /* JSBTERM Input Model | |
5252 * \033[0~zw uniq escape sequence | |
5253 * (L-x) Left button pressed - not pressed x not reporting | |
5254 * (M-x) Middle button pressed - not pressed x not reporting | |
5255 * (R-x) Right button pressed - not pressed x not reporting | |
5256 * (SDmdu) Single , Double click, m mouse move d button down | |
5257 * u button up | |
5258 * ### X cursor position padded to 3 digits | |
5259 * ### Y cursor position padded to 3 digits | |
5260 * (s-x) SHIFT key pressed - not pressed x not reporting | |
5261 * (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
|
5262 * \033\\ terminating sequence |
7 | 5263 */ |
5264 | |
5265 p = tp + slen; | |
5266 button = mouse_code = 0; | |
5267 switch (*p++) | |
5268 { | |
5269 case 'L': button = 1; break; | |
5270 case '-': break; | |
5271 case 'x': break; /* ignore sequence */ | |
5272 default: return -1; /* Unknown Result */ | |
5273 } | |
5274 switch (*p++) | |
5275 { | |
5276 case 'M': button |= 2; break; | |
5277 case '-': break; | |
5278 case 'x': break; /* ignore sequence */ | |
5279 default: return -1; /* Unknown Result */ | |
5280 } | |
5281 switch (*p++) | |
5282 { | |
5283 case 'R': button |= 4; break; | |
5284 case '-': break; | |
5285 case 'x': break; /* ignore sequence */ | |
5286 default: return -1; /* Unknown Result */ | |
5287 } | |
5288 status = *p++; | |
5289 for (val = 0, mult = 100, iter = 0; iter < 3; iter++, | |
5290 mult /= 10, p++) | |
5291 if (*p >= '0' && *p <= '9') | |
5292 val += (*p - '0') * mult; | |
5293 else | |
5294 return -1; | |
5295 mouse_col = val; | |
5296 for (val = 0, mult = 100, iter = 0; iter < 3; iter++, | |
5297 mult /= 10, p++) | |
5298 if (*p >= '0' && *p <= '9') | |
5299 val += (*p - '0') * mult; | |
5300 else | |
5301 return -1; | |
5302 mouse_row = val; | |
5303 switch (*p++) | |
5304 { | |
5305 case 's': button |= 8; break; /* SHIFT key Pressed */ | |
5306 case '-': break; /* Not Pressed */ | |
5307 case 'x': break; /* Not Reporting */ | |
5308 default: return -1; /* Unknown Result */ | |
5309 } | |
5310 switch (*p++) | |
5311 { | |
5312 case 'c': button |= 16; break; /* CTRL key Pressed */ | |
5313 case '-': break; /* Not Pressed */ | |
5314 case 'x': break; /* Not Reporting */ | |
5315 default: return -1; /* Unknown Result */ | |
5316 } | |
5317 if (*p++ != '\033') | |
5318 return -1; | |
5319 if (*p++ != '\\') | |
5320 return -1; | |
5321 switch (status) | |
5322 { | |
5323 case 'D': /* Double Click */ | |
5324 case 'S': /* Single Click */ | |
5325 if (button & 1) mouse_code |= MOUSE_LEFT; | |
5326 if (button & 2) mouse_code |= MOUSE_MIDDLE; | |
5327 if (button & 4) mouse_code |= MOUSE_RIGHT; | |
5328 if (button & 8) mouse_code |= MOUSE_SHIFT; | |
5329 if (button & 16) mouse_code |= MOUSE_CTRL; | |
5330 break; | |
5331 case 'm': /* Mouse move */ | |
5332 if (button & 1) mouse_code |= MOUSE_LEFT; | |
5333 if (button & 2) mouse_code |= MOUSE_MIDDLE; | |
5334 if (button & 4) mouse_code |= MOUSE_RIGHT; | |
5335 if (button & 8) mouse_code |= MOUSE_SHIFT; | |
5336 if (button & 16) mouse_code |= MOUSE_CTRL; | |
5337 if ((button & 7) != 0) | |
5338 { | |
5339 held_button = mouse_code; | |
5340 mouse_code |= MOUSE_DRAG; | |
5341 } | |
5342 is_drag = TRUE; | |
5343 showmode(); | |
5344 break; | |
5345 case 'd': /* Button Down */ | |
5346 if (button & 1) mouse_code |= MOUSE_LEFT; | |
5347 if (button & 2) mouse_code |= MOUSE_MIDDLE; | |
5348 if (button & 4) mouse_code |= MOUSE_RIGHT; | |
5349 if (button & 8) mouse_code |= MOUSE_SHIFT; | |
5350 if (button & 16) mouse_code |= MOUSE_CTRL; | |
5351 break; | |
5352 case 'u': /* Button Up */ | |
5353 if (button & 1) | |
5354 mouse_code |= MOUSE_LEFT | MOUSE_RELEASE; | |
5355 if (button & 2) | |
5356 mouse_code |= MOUSE_MIDDLE | MOUSE_RELEASE; | |
5357 if (button & 4) | |
5358 mouse_code |= MOUSE_RIGHT | MOUSE_RELEASE; | |
5359 if (button & 8) | |
5360 mouse_code |= MOUSE_SHIFT; | |
5361 if (button & 16) | |
5362 mouse_code |= MOUSE_CTRL; | |
5363 break; | |
5364 default: return -1; /* Unknown Result */ | |
5365 } | |
5366 | |
5367 slen += (p - (tp + slen)); | |
5368 } | |
5369 # endif /* FEAT_MOUSE_JSB */ | |
5370 # ifdef FEAT_MOUSE_DEC | |
5371 if (key_name[0] == (int)KS_DEC_MOUSE) | |
5372 { | |
5373 /* The DEC Locator Input Model | |
5374 * Netterm delivers the code sequence: | |
5375 * \033[2;4;24;80&w (left button down) | |
5376 * \033[3;0;24;80&w (left button up) | |
5377 * \033[6;1;24;80&w (right button down) | |
5378 * \033[7;0;24;80&w (right button up) | |
5379 * CSI Pe ; Pb ; Pr ; Pc ; Pp & w | |
5380 * Pe is the event code | |
5381 * Pb is the button code | |
5382 * Pr is the row coordinate | |
5383 * Pc is the column coordinate | |
5384 * Pp is the third coordinate (page number) | |
5385 * Pe, the event code indicates what event caused this report | |
5386 * The following event codes are defined: | |
5387 * 0 - request, the terminal received an explicit request | |
5388 * for a locator report, but the locator is unavailable | |
5389 * 1 - request, the terminal received an explicit request | |
5390 * for a locator report | |
5391 * 2 - left button down | |
5392 * 3 - left button up | |
5393 * 4 - middle button down | |
5394 * 5 - middle button up | |
5395 * 6 - right button down | |
5396 * 7 - right button up | |
5397 * 8 - fourth button down | |
5398 * 9 - fourth button up | |
5399 * 10 - locator outside filter rectangle | |
5400 * Pb, the button code, ASCII decimal 0-15 indicating which | |
5401 * buttons are down if any. The state of the four buttons | |
5402 * on the locator correspond to the low four bits of the | |
5403 * decimal value, | |
5404 * "1" means button depressed | |
5405 * 0 - no buttons down, | |
5406 * 1 - right, | |
5407 * 2 - middle, | |
5408 * 4 - left, | |
5409 * 8 - fourth | |
5410 * Pr is the row coordinate of the locator position in the page, | |
5411 * encoded as an ASCII decimal value. | |
5412 * If Pr is omitted, the locator position is undefined | |
5413 * (outside the terminal window for example). | |
5414 * Pc is the column coordinate of the locator position in the | |
5415 * page, encoded as an ASCII decimal value. | |
5416 * If Pc is omitted, the locator position is undefined | |
5417 * (outside the terminal window for example). | |
5418 * Pp is the page coordinate of the locator position | |
5419 * encoded as an ASCII decimal value. | |
5420 * The page coordinate may be omitted if the locator is on | |
5421 * page one (the default). We ignore it anyway. | |
5422 */ | |
5423 int Pe, Pb, Pr, Pc; | |
5424 | |
5425 p = tp + slen; | |
5426 | |
5427 /* get event status */ | |
5428 Pe = getdigits(&p); | |
5429 if (*p++ != ';') | |
5430 return -1; | |
5431 | |
5432 /* get button status */ | |
5433 Pb = getdigits(&p); | |
5434 if (*p++ != ';') | |
5435 return -1; | |
5436 | |
5437 /* get row status */ | |
5438 Pr = getdigits(&p); | |
5439 if (*p++ != ';') | |
5440 return -1; | |
5441 | |
5442 /* get column status */ | |
5443 Pc = getdigits(&p); | |
5444 | |
5445 /* the page parameter is optional */ | |
5446 if (*p == ';') | |
5447 { | |
5448 p++; | |
5449 (void)getdigits(&p); | |
5450 } | |
5451 if (*p++ != '&') | |
5452 return -1; | |
5453 if (*p++ != 'w') | |
5454 return -1; | |
5455 | |
5456 mouse_code = 0; | |
5457 switch (Pe) | |
5458 { | |
5459 case 0: return -1; /* position request while unavailable */ | |
5460 case 1: /* a response to a locator position request includes | |
5461 the status of all buttons */ | |
5462 Pb &= 7; /* mask off and ignore fourth button */ | |
5463 if (Pb & 4) | |
5464 mouse_code = MOUSE_LEFT; | |
5465 if (Pb & 2) | |
5466 mouse_code = MOUSE_MIDDLE; | |
5467 if (Pb & 1) | |
5468 mouse_code = MOUSE_RIGHT; | |
5469 if (Pb) | |
5470 { | |
5471 held_button = mouse_code; | |
5472 mouse_code |= MOUSE_DRAG; | |
227 | 5473 WantQueryMouse = TRUE; |
7 | 5474 } |
5475 is_drag = TRUE; | |
5476 showmode(); | |
5477 break; | |
5478 case 2: mouse_code = MOUSE_LEFT; | |
227 | 5479 WantQueryMouse = TRUE; |
7 | 5480 break; |
5481 case 3: mouse_code = MOUSE_RELEASE | MOUSE_LEFT; | |
5482 break; | |
5483 case 4: mouse_code = MOUSE_MIDDLE; | |
227 | 5484 WantQueryMouse = TRUE; |
7 | 5485 break; |
5486 case 5: mouse_code = MOUSE_RELEASE | MOUSE_MIDDLE; | |
5487 break; | |
5488 case 6: mouse_code = MOUSE_RIGHT; | |
227 | 5489 WantQueryMouse = TRUE; |
7 | 5490 break; |
5491 case 7: mouse_code = MOUSE_RELEASE | MOUSE_RIGHT; | |
5492 break; | |
5493 case 8: return -1; /* fourth button down */ | |
5494 case 9: return -1; /* fourth button up */ | |
5495 case 10: return -1; /* mouse outside of filter rectangle */ | |
5496 default: return -1; /* should never occur */ | |
5497 } | |
5498 | |
5499 mouse_col = Pc - 1; | |
5500 mouse_row = Pr - 1; | |
5501 | |
5502 slen += (int)(p - (tp + slen)); | |
5503 } | |
5504 # endif /* FEAT_MOUSE_DEC */ | |
5505 # ifdef FEAT_MOUSE_PTERM | |
5506 if (key_name[0] == (int)KS_PTERM_MOUSE) | |
5507 { | |
2237
770485470e59
Add a few #ifdefs to exclude functions that are not used. (Domnique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
1941
diff
changeset
|
5508 int button, num_clicks, action; |
7 | 5509 |
5510 p = tp + slen; | |
5511 | |
5512 action = getdigits(&p); | |
5513 if (*p++ != ';') | |
5514 return -1; | |
5515 | |
5516 mouse_row = getdigits(&p); | |
5517 if (*p++ != ';') | |
5518 return -1; | |
5519 mouse_col = getdigits(&p); | |
5520 if (*p++ != ';') | |
5521 return -1; | |
5522 | |
5523 button = getdigits(&p); | |
5524 mouse_code = 0; | |
5525 | |
9929
579abc260d85
commit https://github.com/vim/vim/commit/de7762a2c1498e2dc43586feb5f982d661799f85
Christian Brabandt <cb@256bit.org>
parents:
9869
diff
changeset
|
5526 switch (button) |
7 | 5527 { |
5528 case 4: mouse_code = MOUSE_LEFT; break; | |
5529 case 1: mouse_code = MOUSE_RIGHT; break; | |
5530 case 2: mouse_code = MOUSE_MIDDLE; break; | |
5531 default: return -1; | |
5532 } | |
5533 | |
9929
579abc260d85
commit https://github.com/vim/vim/commit/de7762a2c1498e2dc43586feb5f982d661799f85
Christian Brabandt <cb@256bit.org>
parents:
9869
diff
changeset
|
5534 switch (action) |
7 | 5535 { |
5536 case 31: /* Initial press */ | |
5537 if (*p++ != ';') | |
5538 return -1; | |
5539 | |
5540 num_clicks = getdigits(&p); /* Not used */ | |
5541 break; | |
5542 | |
5543 case 32: /* Release */ | |
5544 mouse_code |= MOUSE_RELEASE; | |
5545 break; | |
5546 | |
5547 case 33: /* Drag */ | |
5548 held_button = mouse_code; | |
5549 mouse_code |= MOUSE_DRAG; | |
5550 break; | |
5551 | |
5552 default: | |
5553 return -1; | |
5554 } | |
5555 | |
5556 if (*p++ != 't') | |
5557 return -1; | |
5558 | |
5559 slen += (p - (tp + slen)); | |
5560 } | |
5561 # endif /* FEAT_MOUSE_PTERM */ | |
5562 | |
5563 /* Interpret the mouse code */ | |
5564 current_button = (mouse_code & MOUSE_CLICK_MASK); | |
5565 if (current_button == MOUSE_RELEASE | |
5566 # ifdef FEAT_MOUSE_XTERM | |
5567 && wheel_code == 0 | |
5568 # endif | |
5569 ) | |
5570 { | |
5571 /* | |
5572 * If we get a mouse drag or release event when | |
5573 * there is no mouse button held down (held_button == | |
5574 * MOUSE_RELEASE), produce a K_IGNORE below. | |
5575 * (can happen when you hold down two buttons | |
5576 * and then let them go, or click in the menu bar, but not | |
5577 * on a menu, and drag into the text). | |
5578 */ | |
5579 if ((mouse_code & MOUSE_DRAG) == MOUSE_DRAG) | |
5580 is_drag = TRUE; | |
5581 current_button = held_button; | |
5582 } | |
5583 else if (wheel_code == 0) | |
5584 { | |
5585 # ifdef CHECK_DOUBLE_CLICK | |
5586 # ifdef FEAT_MOUSE_GPM | |
5587 # ifdef FEAT_GUI | |
5588 /* | |
5589 * Only for Unix, when GUI or gpm is not active, we handle | |
5590 * multi-clicks here. | |
5591 */ | |
5592 if (gpm_flag == 0 && !gui.in_use) | |
5593 # else | |
5594 if (gpm_flag == 0) | |
5595 # endif | |
5596 # else | |
5597 # ifdef FEAT_GUI | |
5598 if (!gui.in_use) | |
5599 # endif | |
5600 # endif | |
5601 { | |
5602 /* | |
5603 * Compute the time elapsed since the previous mouse click. | |
5604 */ | |
5605 gettimeofday(&mouse_time, NULL); | |
9125
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5606 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
|
5607 { |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5608 /* |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5609 * 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
|
5610 * 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
|
5611 * 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
|
5612 * multiplication overflow. |
9125
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5613 */ |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5614 timediff = p_mouset; |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5615 } |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5616 else |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5617 { |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5618 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
|
5619 - 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
|
5620 if (timediff < 0) |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5621 --orig_mouse_time.tv_sec; |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5622 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
|
5623 - 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
|
5624 } |
7 | 5625 orig_mouse_time = mouse_time; |
5626 if (mouse_code == orig_mouse_code | |
5627 && timediff < p_mouset | |
5628 && orig_num_clicks != 4 | |
5629 && orig_mouse_col == mouse_col | |
5630 && orig_mouse_row == mouse_row | |
683 | 5631 && ((orig_topline == curwin->w_topline |
7 | 5632 #ifdef FEAT_DIFF |
683 | 5633 && orig_topfill == curwin->w_topfill |
7 | 5634 #endif |
683 | 5635 ) |
5636 /* Double click in tab pages line also works | |
5637 * 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
|
5638 || (mouse_row == 0 && firstwin->w_winrow > 0)) |
683 | 5639 ) |
7 | 5640 ++orig_num_clicks; |
5641 else | |
5642 orig_num_clicks = 1; | |
5643 orig_mouse_col = mouse_col; | |
5644 orig_mouse_row = mouse_row; | |
5645 orig_topline = curwin->w_topline; | |
5646 #ifdef FEAT_DIFF | |
5647 orig_topfill = curwin->w_topfill; | |
5648 #endif | |
5649 } | |
5650 # if defined(FEAT_GUI) || defined(FEAT_MOUSE_GPM) | |
5651 else | |
5652 orig_num_clicks = NUM_MOUSE_CLICKS(mouse_code); | |
5653 # endif | |
5654 # else | |
5655 orig_num_clicks = NUM_MOUSE_CLICKS(mouse_code); | |
5656 # endif | |
5657 is_click = TRUE; | |
5658 orig_mouse_code = mouse_code; | |
5659 } | |
5660 if (!is_drag) | |
5661 held_button = mouse_code & MOUSE_CLICK_MASK; | |
5662 | |
5663 /* | |
5664 * Translate the actual mouse event into a pseudo mouse event. | |
5665 * First work out what modifiers are to be used. | |
5666 */ | |
5667 if (orig_mouse_code & MOUSE_SHIFT) | |
5668 modifiers |= MOD_MASK_SHIFT; | |
5669 if (orig_mouse_code & MOUSE_CTRL) | |
5670 modifiers |= MOD_MASK_CTRL; | |
5671 if (orig_mouse_code & MOUSE_ALT) | |
5672 modifiers |= MOD_MASK_ALT; | |
5673 if (orig_num_clicks == 2) | |
5674 modifiers |= MOD_MASK_2CLICK; | |
5675 else if (orig_num_clicks == 3) | |
5676 modifiers |= MOD_MASK_3CLICK; | |
5677 else if (orig_num_clicks == 4) | |
5678 modifiers |= MOD_MASK_4CLICK; | |
5679 | |
9929
579abc260d85
commit https://github.com/vim/vim/commit/de7762a2c1498e2dc43586feb5f982d661799f85
Christian Brabandt <cb@256bit.org>
parents:
9869
diff
changeset
|
5680 /* 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
|
5681 * added, then it's not mouse up/down. */ |
7 | 5682 key_name[0] = (int)KS_EXTRA; |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
5683 if (wheel_code != 0 |
9929
579abc260d85
commit https://github.com/vim/vim/commit/de7762a2c1498e2dc43586feb5f982d661799f85
Christian Brabandt <cb@256bit.org>
parents:
9869
diff
changeset
|
5684 && (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
|
5685 { |
1a4a66f0c871
Make CTRL modifier work for mouse wheel. (Benjamin Haskell)
Bram Moolenaar <bram@vim.org>
parents:
2279
diff
changeset
|
5686 if (wheel_code & MOUSE_CTRL) |
1a4a66f0c871
Make CTRL modifier work for mouse wheel. (Benjamin Haskell)
Bram Moolenaar <bram@vim.org>
parents:
2279
diff
changeset
|
5687 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
|
5688 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
|
5689 modifiers |= MOD_MASK_ALT; |
7 | 5690 key_name[1] = (wheel_code & 1) |
5691 ? (int)KE_MOUSEUP : (int)KE_MOUSEDOWN; | |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12853
diff
changeset
|
5692 held_button = MOUSE_RELEASE; |
2336
1a4a66f0c871
Make CTRL modifier work for mouse wheel. (Benjamin Haskell)
Bram Moolenaar <bram@vim.org>
parents:
2279
diff
changeset
|
5693 } |
7 | 5694 else |
5695 key_name[1] = get_pseudo_mouse_code(current_button, | |
5696 is_click, is_drag); | |
7256
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5697 |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5698 /* 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
|
5699 * return weird values. */ |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5700 if (mouse_col >= Columns) |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5701 mouse_col = Columns - 1; |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5702 if (mouse_row >= Rows) |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5703 mouse_row = Rows - 1; |
7 | 5704 } |
5705 #endif /* FEAT_MOUSE */ | |
5706 | |
5707 #ifdef FEAT_GUI | |
5708 /* | |
5709 * If using the GUI, then we get menu and scrollbar events. | |
5710 * | |
5711 * A menu event is encoded as K_SPECIAL, KS_MENU, KE_FILLER followed by | |
5712 * four bytes which are to be taken as a pointer to the vimmenu_T | |
5713 * structure. | |
5714 * | |
1221 | 5715 * A tab line event is encoded as K_SPECIAL KS_TABLINE nr, where "nr" |
685 | 5716 * is one byte with the tab index. |
5717 * | |
7 | 5718 * A scrollbar event is K_SPECIAL, KS_VER_SCROLLBAR, KE_FILLER followed |
5719 * by one byte representing the scrollbar number, and then four bytes | |
5720 * representing a long_u which is the new value of the scrollbar. | |
5721 * | |
5722 * A horizontal scrollbar event is K_SPECIAL, KS_HOR_SCROLLBAR, | |
5723 * KE_FILLER followed by four bytes representing a long_u which is the | |
5724 * new value of the scrollbar. | |
5725 */ | |
5726 # ifdef FEAT_MENU | |
5727 else if (key_name[0] == (int)KS_MENU) | |
5728 { | |
5729 long_u val; | |
5730 | |
5731 num_bytes = get_long_from_buf(tp + slen, &val); | |
5732 if (num_bytes == -1) | |
5733 return -1; | |
5734 current_menu = (vimmenu_T *)val; | |
5735 slen += num_bytes; | |
936 | 5736 |
5737 /* The menu may have been deleted right after it was used, check | |
5738 * for that. */ | |
5739 if (check_menu_pointer(root_menu, current_menu) == FAIL) | |
5740 { | |
5741 key_name[0] = KS_EXTRA; | |
5742 key_name[1] = (int)KE_IGNORE; | |
5743 } | |
7 | 5744 } |
5745 # endif | |
685 | 5746 # ifdef FEAT_GUI_TABLINE |
5747 else if (key_name[0] == (int)KS_TABLINE) | |
5748 { | |
688 | 5749 /* Selecting tabline tab or using its menu. */ |
685 | 5750 num_bytes = get_bytes_from_buf(tp + slen, bytes, 1); |
5751 if (num_bytes == -1) | |
5752 return -1; | |
5753 current_tab = (int)bytes[0]; | |
1394 | 5754 if (current_tab == 255) /* -1 in a byte gives 255 */ |
5755 current_tab = -1; | |
685 | 5756 slen += num_bytes; |
5757 } | |
688 | 5758 else if (key_name[0] == (int)KS_TABMENU) |
5759 { | |
5760 /* Selecting tabline tab or using its menu. */ | |
5761 num_bytes = get_bytes_from_buf(tp + slen, bytes, 2); | |
5762 if (num_bytes == -1) | |
5763 return -1; | |
5764 current_tab = (int)bytes[0]; | |
5765 current_tabmenu = (int)bytes[1]; | |
5766 slen += num_bytes; | |
5767 } | |
685 | 5768 # endif |
7 | 5769 # ifndef USE_ON_FLY_SCROLL |
5770 else if (key_name[0] == (int)KS_VER_SCROLLBAR) | |
5771 { | |
5772 long_u val; | |
5773 | |
5774 /* Get the last scrollbar event in the queue of the same type */ | |
5775 j = 0; | |
5776 for (i = 0; tp[j] == CSI && tp[j + 1] == KS_VER_SCROLLBAR | |
5777 && tp[j + 2] != NUL; ++i) | |
5778 { | |
5779 j += 3; | |
5780 num_bytes = get_bytes_from_buf(tp + j, bytes, 1); | |
5781 if (num_bytes == -1) | |
5782 break; | |
5783 if (i == 0) | |
5784 current_scrollbar = (int)bytes[0]; | |
5785 else if (current_scrollbar != (int)bytes[0]) | |
5786 break; | |
5787 j += num_bytes; | |
5788 num_bytes = get_long_from_buf(tp + j, &val); | |
5789 if (num_bytes == -1) | |
5790 break; | |
5791 scrollbar_value = val; | |
5792 j += num_bytes; | |
5793 slen = j; | |
5794 } | |
5795 if (i == 0) /* not enough characters to make one */ | |
5796 return -1; | |
5797 } | |
5798 else if (key_name[0] == (int)KS_HOR_SCROLLBAR) | |
5799 { | |
5800 long_u val; | |
5801 | |
5802 /* Get the last horiz. scrollbar event in the queue */ | |
5803 j = 0; | |
5804 for (i = 0; tp[j] == CSI && tp[j + 1] == KS_HOR_SCROLLBAR | |
5805 && tp[j + 2] != NUL; ++i) | |
5806 { | |
5807 j += 3; | |
5808 num_bytes = get_long_from_buf(tp + j, &val); | |
5809 if (num_bytes == -1) | |
5810 break; | |
5811 scrollbar_value = val; | |
5812 j += num_bytes; | |
5813 slen = j; | |
5814 } | |
5815 if (i == 0) /* not enough characters to make one */ | |
5816 return -1; | |
5817 } | |
5818 # endif /* !USE_ON_FLY_SCROLL */ | |
5819 #endif /* FEAT_GUI */ | |
5820 | |
180 | 5821 /* |
5822 * Change <xHome> to <Home>, <xUp> to <Up>, etc. | |
5823 */ | |
5824 key = handle_x_keys(TERMCAP2KEY(key_name[0], key_name[1])); | |
5825 | |
5826 /* | |
5827 * Add any modifier codes to our string. | |
5828 */ | |
5829 new_slen = 0; /* Length of what will replace the termcode */ | |
5830 if (modifiers != 0) | |
5831 { | |
5832 /* Some keys have the modifier included. Need to handle that here | |
5833 * to make mappings work. */ | |
5834 key = simplify_key(key, &modifiers); | |
5835 if (modifiers != 0) | |
5836 { | |
5837 string[new_slen++] = K_SPECIAL; | |
5838 string[new_slen++] = (int)KS_MODIFIER; | |
5839 string[new_slen++] = modifiers; | |
5840 } | |
5841 } | |
5842 | |
7 | 5843 /* Finally, add the special key code to our string */ |
180 | 5844 key_name[0] = KEY2TERMCAP0(key); |
5845 key_name[1] = KEY2TERMCAP1(key); | |
7 | 5846 if (key_name[0] == KS_KEY) |
1787 | 5847 { |
5848 /* from ":set <M-b>=xx" */ | |
5849 #ifdef FEAT_MBYTE | |
5850 if (has_mbyte) | |
5851 new_slen += (*mb_char2bytes)(key_name[1], string + new_slen); | |
5852 else | |
5853 #endif | |
5854 string[new_slen++] = key_name[1]; | |
5855 } | |
2672 | 5856 else if (new_slen == 0 && key_name[0] == KS_EXTRA |
5857 && key_name[1] == KE_IGNORE) | |
5858 { | |
5859 /* Do not put K_IGNORE into the buffer, do return KEYLEN_REMOVED | |
5860 * to indicate what happened. */ | |
5861 retval = KEYLEN_REMOVED; | |
5862 } | |
7 | 5863 else |
5864 { | |
5865 string[new_slen++] = K_SPECIAL; | |
5866 string[new_slen++] = key_name[0]; | |
5867 string[new_slen++] = key_name[1]; | |
5868 } | |
5869 string[new_slen] = NUL; | |
5870 extra = new_slen - slen; | |
5871 if (buf == NULL) | |
5872 { | |
5873 if (extra < 0) | |
5874 /* remove matched chars, taking care of noremap */ | |
5875 del_typebuf(-extra, offset); | |
5876 else if (extra > 0) | |
5877 /* insert the extra space we need */ | |
5878 ins_typebuf(string + slen, REMAP_YES, offset, FALSE, FALSE); | |
5879 | |
5880 /* | |
5881 * Careful: del_typebuf() and ins_typebuf() may have reallocated | |
5882 * typebuf.tb_buf[]! | |
5883 */ | |
5884 mch_memmove(typebuf.tb_buf + typebuf.tb_off + offset, string, | |
5885 (size_t)new_slen); | |
5886 } | |
5887 else | |
5888 { | |
5889 if (extra < 0) | |
5890 /* remove matched characters */ | |
5891 mch_memmove(buf + offset, buf + offset - extra, | |
3328 | 5892 (size_t)(*buflen + offset + extra)); |
7 | 5893 else if (extra > 0) |
3328 | 5894 { |
5895 /* Insert the extra space we need. If there is insufficient | |
5896 * space return -1. */ | |
5897 if (*buflen + extra + new_slen >= bufsize) | |
5898 return -1; | |
7 | 5899 mch_memmove(buf + offset + extra, buf + offset, |
3328 | 5900 (size_t)(*buflen - offset)); |
5901 } | |
7 | 5902 mch_memmove(buf + offset, string, (size_t)new_slen); |
3328 | 5903 *buflen = *buflen + extra + new_slen; |
7 | 5904 } |
2672 | 5905 return retval == 0 ? (len + extra + offset) : retval; |
7 | 5906 } |
5907 | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5908 #ifdef FEAT_TERMRESPONSE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5909 LOG_TR("normal character"); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5910 #endif |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5911 |
7 | 5912 return 0; /* no match found */ |
5913 } | |
5914 | |
12634
94566ecb55f0
patch 8.0.1195: can't build on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12632
diff
changeset
|
5915 #if (defined(FEAT_TERMINAL) && defined(FEAT_TERMRESPONSE)) || defined(PROTO) |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5916 /* |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5917 * Get the text foreground color, if known. |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5918 */ |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5919 void |
12640
a715f0b44532
patch 8.0.1198: older compilers don't know uint8_t
Christian Brabandt <cb@256bit.org>
parents:
12634
diff
changeset
|
5920 term_get_fg_color(char_u *r, char_u *g, char_u *b) |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5921 { |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5922 if (rfg_status == STATUS_GOT) |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5923 { |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5924 *r = fg_r; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5925 *g = fg_g; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5926 *b = fg_b; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5927 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5928 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5929 |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5930 /* |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5931 * Get the text background color, if known. |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5932 */ |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5933 void |
12640
a715f0b44532
patch 8.0.1198: older compilers don't know uint8_t
Christian Brabandt <cb@256bit.org>
parents:
12634
diff
changeset
|
5934 term_get_bg_color(char_u *r, char_u *g, char_u *b) |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5935 { |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5936 if (rbg_status == STATUS_GOT) |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5937 { |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5938 *r = bg_r; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5939 *g = bg_g; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5940 *b = bg_b; |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5941 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5942 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5943 #endif |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
5944 |
7 | 5945 /* |
5946 * Replace any terminal code strings in from[] with the equivalent internal | |
5947 * vim representation. This is used for the "from" and "to" part of a | |
5948 * mapping, and the "to" part of a menu command. | |
5949 * Any strings like "<C-UP>" are also replaced, unless 'cpoptions' contains | |
5950 * '<'. | |
5951 * K_SPECIAL by itself is replaced by K_SPECIAL KS_SPECIAL KE_FILLER. | |
5952 * | |
5953 * The replacement is done in result[] and finally copied into allocated | |
5954 * memory. If this all works well *bufp is set to the allocated memory and a | |
5955 * pointer to it is returned. If something fails *bufp is set to NULL and from | |
5956 * is returned. | |
5957 * | |
5958 * CTRL-V characters are removed. When "from_part" is TRUE, a trailing CTRL-V | |
5959 * is included, otherwise it is removed (for ":map xx ^V", maps xx to | |
5960 * nothing). When 'cpoptions' does not contain 'B', a backslash can be used | |
5961 * instead of a CTRL-V. | |
5962 */ | |
859 | 5963 char_u * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5964 replace_termcodes( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5965 char_u *from, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5966 char_u **bufp, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5967 int from_part, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5968 int do_lt, /* also translate <lt> */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5969 int special) /* always accept <key> notation */ |
7 | 5970 { |
5971 int i; | |
5972 int slen; | |
5973 int key; | |
5974 int dlen = 0; | |
5975 char_u *src; | |
5976 int do_backslash; /* backslash is a special character */ | |
5977 int do_special; /* recognize <> key codes */ | |
5978 int do_key_code; /* recognize raw key codes */ | |
5979 char_u *result; /* buffer for resulting string */ | |
5980 | |
5981 do_backslash = (vim_strchr(p_cpo, CPO_BSLASH) == NULL); | |
859 | 5982 do_special = (vim_strchr(p_cpo, CPO_SPECI) == NULL) || special; |
7 | 5983 do_key_code = (vim_strchr(p_cpo, CPO_KEYCODE) == NULL); |
5984 | |
5985 /* | |
5986 * Allocate space for the translation. Worst case a single character is | |
5987 * replaced by 6 bytes (shifted special key), plus a NUL at the end. | |
5988 */ | |
5989 result = alloc((unsigned)STRLEN(from) * 6 + 1); | |
5990 if (result == NULL) /* out of memory */ | |
5991 { | |
5992 *bufp = NULL; | |
5993 return from; | |
5994 } | |
5995 | |
5996 src = from; | |
5997 | |
5998 /* | |
5999 * Check for #n at start only: function key n | |
6000 */ | |
6001 if (from_part && src[0] == '#' && VIM_ISDIGIT(src[1])) /* function key */ | |
6002 { | |
6003 result[dlen++] = K_SPECIAL; | |
6004 result[dlen++] = 'k'; | |
6005 if (src[1] == '0') | |
6006 result[dlen++] = ';'; /* #0 is F10 is "k;" */ | |
6007 else | |
6008 result[dlen++] = src[1]; /* #3 is F3 is "k3" */ | |
6009 src += 2; | |
6010 } | |
6011 | |
6012 /* | |
6013 * Copy each byte from *from to result[dlen] | |
6014 */ | |
6015 while (*src != NUL) | |
6016 { | |
6017 /* | |
6018 * 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
|
6019 * like "<C-S-LeftMouse>" |
7 | 6020 */ |
6021 if (do_special && (do_lt || STRNCMP(src, "<lt>", 4) != 0)) | |
6022 { | |
6023 #ifdef FEAT_EVAL | |
6024 /* | |
6025 * Replace <SID> by K_SNR <script-nr> _. | |
6026 * (room: 5 * 6 = 30 bytes; needed: 3 + <nr> + 1 <= 14) | |
6027 */ | |
6028 if (STRNICMP(src, "<SID>", 5) == 0) | |
6029 { | |
6030 if (current_SID <= 0) | |
6031 EMSG(_(e_usingsid)); | |
6032 else | |
6033 { | |
6034 src += 5; | |
6035 result[dlen++] = K_SPECIAL; | |
6036 result[dlen++] = (int)KS_EXTRA; | |
6037 result[dlen++] = (int)KE_SNR; | |
6038 sprintf((char *)result + dlen, "%ld", (long)current_SID); | |
6039 dlen += (int)STRLEN(result + dlen); | |
6040 result[dlen++] = '_'; | |
6041 continue; | |
6042 } | |
6043 } | |
6044 #endif | |
6045 | |
9869
989d44d35a66
commit https://github.com/vim/vim/commit/35a4cfa200917dd171b1fff3cd5b6cee9add673d
Christian Brabandt <cb@256bit.org>
parents:
9814
diff
changeset
|
6046 slen = trans_special(&src, result + dlen, TRUE, FALSE); |
7 | 6047 if (slen) |
6048 { | |
6049 dlen += slen; | |
6050 continue; | |
6051 } | |
6052 } | |
6053 | |
6054 /* | |
6055 * If 'cpoptions' does not contain 'k', see if it's an actual key-code. | |
6056 * Note that this is also checked after replacing the <> form. | |
6057 * Single character codes are NOT replaced (e.g. ^H or DEL), because | |
6058 * it could be a character in the file. | |
6059 */ | |
6060 if (do_key_code) | |
6061 { | |
6062 i = find_term_bykeys(src); | |
6063 if (i >= 0) | |
6064 { | |
6065 result[dlen++] = K_SPECIAL; | |
6066 result[dlen++] = termcodes[i].name[0]; | |
6067 result[dlen++] = termcodes[i].name[1]; | |
6068 src += termcodes[i].len; | |
6069 /* If terminal code matched, continue after it. */ | |
6070 continue; | |
6071 } | |
6072 } | |
6073 | |
6074 #ifdef FEAT_EVAL | |
6075 if (do_special) | |
6076 { | |
6077 char_u *p, *s, len; | |
6078 | |
6079 /* | |
6080 * Replace <Leader> by the value of "mapleader". | |
6081 * Replace <LocalLeader> by the value of "maplocalleader". | |
6082 * If "mapleader" or "maplocalleader" isn't set use a backslash. | |
6083 */ | |
6084 if (STRNICMP(src, "<Leader>", 8) == 0) | |
6085 { | |
6086 len = 8; | |
6087 p = get_var_value((char_u *)"g:mapleader"); | |
6088 } | |
6089 else if (STRNICMP(src, "<LocalLeader>", 13) == 0) | |
6090 { | |
6091 len = 13; | |
6092 p = get_var_value((char_u *)"g:maplocalleader"); | |
6093 } | |
6094 else | |
6095 { | |
6096 len = 0; | |
6097 p = NULL; | |
6098 } | |
6099 if (len != 0) | |
6100 { | |
6101 /* Allow up to 8 * 6 characters for "mapleader". */ | |
6102 if (p == NULL || *p == NUL || STRLEN(p) > 8 * 6) | |
6103 s = (char_u *)"\\"; | |
6104 else | |
6105 s = p; | |
6106 while (*s != NUL) | |
6107 result[dlen++] = *s++; | |
6108 src += len; | |
6109 continue; | |
6110 } | |
6111 } | |
6112 #endif | |
6113 | |
6114 /* | |
6115 * Remove CTRL-V and ignore the next character. | |
6116 * For "from" side the CTRL-V at the end is included, for the "to" | |
6117 * part it is removed. | |
6118 * If 'cpoptions' does not contain 'B', also accept a backslash. | |
6119 */ | |
6120 key = *src; | |
6121 if (key == Ctrl_V || (do_backslash && key == '\\')) | |
6122 { | |
6123 ++src; /* skip CTRL-V or backslash */ | |
6124 if (*src == NUL) | |
6125 { | |
6126 if (from_part) | |
6127 result[dlen++] = key; | |
6128 break; | |
6129 } | |
6130 } | |
6131 | |
6132 #ifdef FEAT_MBYTE | |
6133 /* skip multibyte char correctly */ | |
474 | 6134 for (i = (*mb_ptr2len)(src); i > 0; --i) |
7 | 6135 #endif |
6136 { | |
6137 /* | |
6138 * If the character is K_SPECIAL, replace it with K_SPECIAL | |
6139 * KS_SPECIAL KE_FILLER. | |
6140 * If compiled with the GUI replace CSI with K_CSI. | |
6141 */ | |
6142 if (*src == K_SPECIAL) | |
6143 { | |
6144 result[dlen++] = K_SPECIAL; | |
6145 result[dlen++] = KS_SPECIAL; | |
6146 result[dlen++] = KE_FILLER; | |
6147 } | |
6148 # ifdef FEAT_GUI | |
6149 else if (*src == CSI) | |
6150 { | |
6151 result[dlen++] = K_SPECIAL; | |
6152 result[dlen++] = KS_EXTRA; | |
6153 result[dlen++] = (int)KE_CSI; | |
6154 } | |
6155 # endif | |
6156 else | |
6157 result[dlen++] = *src; | |
6158 ++src; | |
6159 } | |
6160 } | |
6161 result[dlen] = NUL; | |
6162 | |
6163 /* | |
6164 * Copy the new string to allocated memory. | |
6165 * If this fails, just return from. | |
6166 */ | |
6167 if ((*bufp = vim_strsave(result)) != NULL) | |
6168 from = *bufp; | |
6169 vim_free(result); | |
6170 return from; | |
6171 } | |
6172 | |
6173 /* | |
6174 * Find a termcode with keys 'src' (must be NUL terminated). | |
6175 * Return the index in termcodes[], or -1 if not found. | |
6176 */ | |
6177 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6178 find_term_bykeys(char_u *src) |
7 | 6179 { |
6180 int i; | |
3290 | 6181 int slen = (int)STRLEN(src); |
7 | 6182 |
6183 for (i = 0; i < tc_len; ++i) | |
6184 { | |
3273 | 6185 if (slen == termcodes[i].len |
6186 && STRNCMP(termcodes[i].code, src, (size_t)slen) == 0) | |
7 | 6187 return i; |
6188 } | |
6189 return -1; | |
6190 } | |
6191 | |
6192 /* | |
6193 * Gather the first characters in the terminal key codes into a string. | |
6194 * Used to speed up check_termcode(). | |
6195 */ | |
6196 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6197 gather_termleader(void) |
7 | 6198 { |
6199 int i; | |
6200 int len = 0; | |
6201 | |
6202 #ifdef FEAT_GUI | |
6203 if (gui.in_use) | |
6204 termleader[len++] = CSI; /* the GUI codes are not in termcodes[] */ | |
6205 #endif | |
6206 #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
|
6207 if (check_for_codes || *T_CRS != NUL) |
7 | 6208 termleader[len++] = DCS; /* the termcode response starts with DCS |
6209 in 8-bit mode */ | |
6210 #endif | |
6211 termleader[len] = NUL; | |
6212 | |
6213 for (i = 0; i < tc_len; ++i) | |
6214 if (vim_strchr(termleader, termcodes[i].code[0]) == NULL) | |
6215 { | |
6216 termleader[len++] = termcodes[i].code[0]; | |
6217 termleader[len] = NUL; | |
6218 } | |
6219 | |
6220 need_gather = FALSE; | |
6221 } | |
6222 | |
6223 /* | |
6224 * Show all termcodes (for ":set termcap") | |
6225 * This code looks a lot like showoptions(), but is different. | |
6226 */ | |
6227 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6228 show_termcodes(void) |
7 | 6229 { |
6230 int col; | |
6231 int *items; | |
6232 int item_count; | |
6233 int run; | |
6234 int row, rows; | |
6235 int cols; | |
6236 int i; | |
6237 int len; | |
6238 | |
180 | 6239 #define INC3 27 /* try to make three columns */ |
6240 #define INC2 40 /* try to make two columns */ | |
7 | 6241 #define GAP 2 /* spaces between columns */ |
6242 | |
6243 if (tc_len == 0) /* no terminal codes (must be GUI) */ | |
6244 return; | |
6245 items = (int *)alloc((unsigned)(sizeof(int) * tc_len)); | |
6246 if (items == NULL) | |
6247 return; | |
6248 | |
6249 /* Highlight title */ | |
6250 MSG_PUTS_TITLE(_("\n--- Terminal keys ---")); | |
6251 | |
6252 /* | |
6253 * do the loop two times: | |
6254 * 1. display the short items (non-strings and short strings) | |
180 | 6255 * 2. display the medium items (medium length strings) |
6256 * 3. display the long items (remaining strings) | |
7 | 6257 */ |
180 | 6258 for (run = 1; run <= 3 && !got_int; ++run) |
7 | 6259 { |
6260 /* | |
6261 * collect the items in items[] | |
6262 */ | |
6263 item_count = 0; | |
6264 for (i = 0; i < tc_len; i++) | |
6265 { | |
6266 len = show_one_termcode(termcodes[i].name, | |
6267 termcodes[i].code, FALSE); | |
180 | 6268 if (len <= INC3 - GAP ? run == 1 |
6269 : len <= INC2 - GAP ? run == 2 | |
6270 : run == 3) | |
7 | 6271 items[item_count++] = i; |
6272 } | |
6273 | |
6274 /* | |
6275 * display the items | |
6276 */ | |
180 | 6277 if (run <= 2) |
7 | 6278 { |
180 | 6279 cols = (Columns + GAP) / (run == 1 ? INC3 : INC2); |
7 | 6280 if (cols == 0) |
6281 cols = 1; | |
6282 rows = (item_count + cols - 1) / cols; | |
6283 } | |
180 | 6284 else /* run == 3 */ |
7 | 6285 rows = item_count; |
6286 for (row = 0; row < rows && !got_int; ++row) | |
6287 { | |
6288 msg_putchar('\n'); /* go to next line */ | |
6289 if (got_int) /* 'q' typed in more */ | |
6290 break; | |
6291 col = 0; | |
6292 for (i = row; i < item_count; i += rows) | |
6293 { | |
6294 msg_col = col; /* make columns */ | |
6295 show_one_termcode(termcodes[items[i]].name, | |
6296 termcodes[items[i]].code, TRUE); | |
180 | 6297 if (run == 2) |
6298 col += INC2; | |
6299 else | |
6300 col += INC3; | |
7 | 6301 } |
6302 out_flush(); | |
6303 ui_breakcheck(); | |
6304 } | |
6305 } | |
6306 vim_free(items); | |
6307 } | |
6308 | |
6309 /* | |
6310 * Show one termcode entry. | |
6311 * Output goes into IObuff[] | |
6312 */ | |
6313 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6314 show_one_termcode(char_u *name, char_u *code, int printit) |
7 | 6315 { |
6316 char_u *p; | |
6317 int len; | |
6318 | |
6319 if (name[0] > '~') | |
6320 { | |
6321 IObuff[0] = ' '; | |
6322 IObuff[1] = ' '; | |
6323 IObuff[2] = ' '; | |
6324 IObuff[3] = ' '; | |
6325 } | |
6326 else | |
6327 { | |
6328 IObuff[0] = 't'; | |
6329 IObuff[1] = '_'; | |
6330 IObuff[2] = name[0]; | |
6331 IObuff[3] = name[1]; | |
6332 } | |
6333 IObuff[4] = ' '; | |
6334 | |
6335 p = get_special_key_name(TERMCAP2KEY(name[0], name[1]), 0); | |
6336 if (p[1] != 't') | |
6337 STRCPY(IObuff + 5, p); | |
6338 else | |
6339 IObuff[5] = NUL; | |
6340 len = (int)STRLEN(IObuff); | |
6341 do | |
6342 IObuff[len++] = ' '; | |
6343 while (len < 17); | |
6344 IObuff[len] = NUL; | |
6345 if (code == NULL) | |
6346 len += 4; | |
6347 else | |
6348 len += vim_strsize(code); | |
6349 | |
6350 if (printit) | |
6351 { | |
6352 msg_puts(IObuff); | |
6353 if (code == NULL) | |
6354 msg_puts((char_u *)"NULL"); | |
6355 else | |
6356 msg_outtrans(code); | |
6357 } | |
6358 return len; | |
6359 } | |
6360 | |
6361 #if defined(FEAT_TERMRESPONSE) || defined(PROTO) | |
6362 /* | |
6363 * For Xterm >= 140 compiled with OPT_TCAP_QUERY: Obtain the actually used | |
6364 * termcap codes from the terminal itself. | |
6365 * We get them one by one to avoid a very long response string. | |
6366 */ | |
6102 | 6367 static int xt_index_in = 0; |
6368 static int xt_index_out = 0; | |
6369 | |
7 | 6370 static void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6371 req_codes_from_term(void) |
7 | 6372 { |
6373 xt_index_out = 0; | |
6374 xt_index_in = 0; | |
6375 req_more_codes_from_term(); | |
6376 } | |
6377 | |
6378 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6379 req_more_codes_from_term(void) |
7 | 6380 { |
6381 char buf[11]; | |
6382 int old_idx = xt_index_out; | |
6383 | |
6384 /* Don't do anything when going to exit. */ | |
6385 if (exiting) | |
6386 return; | |
6387 | |
6388 /* Send up to 10 more requests out than we received. Avoid sending too | |
6389 * many, there can be a buffer overflow somewhere. */ | |
6390 while (xt_index_out < xt_index_in + 10 && key_names[xt_index_out] != NULL) | |
6391 { | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6392 # ifdef DEBUG_TERMRESPONSE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6393 char dbuf[100]; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6394 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6395 sprintf(dbuf, "Requesting XT %d: %s", |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6396 xt_index_out, key_names[xt_index_out]); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6397 log_tr(dbuf); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6398 # endif |
7 | 6399 sprintf(buf, "\033P+q%02x%02x\033\\", |
6400 key_names[xt_index_out][0], key_names[xt_index_out][1]); | |
6401 out_str_nf((char_u *)buf); | |
6402 ++xt_index_out; | |
6403 } | |
6404 | |
6405 /* Send the codes out right away. */ | |
6406 if (xt_index_out != old_idx) | |
6407 out_flush(); | |
6408 } | |
6409 | |
6410 /* | |
6411 * Decode key code response from xterm: '<Esc>P1+r<name>=<string><Esc>\'. | |
6412 * A "0" instead of the "1" indicates a code that isn't supported. | |
6413 * Both <name> and <string> are encoded in hex. | |
6414 * "code" points to the "0" or "1". | |
6415 */ | |
6416 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6417 got_code_from_term(char_u *code, int len) |
7 | 6418 { |
6419 #define XT_LEN 100 | |
6420 char_u name[3]; | |
6421 char_u str[XT_LEN]; | |
6422 int i; | |
6423 int j = 0; | |
6424 int c; | |
6425 | |
6426 /* A '1' means the code is supported, a '0' means it isn't. | |
6427 * When half the length is > XT_LEN we can't use it. | |
6428 * Our names are currently all 2 characters. */ | |
6429 if (code[0] == '1' && code[7] == '=' && len / 2 < XT_LEN) | |
6430 { | |
6431 /* Get the name from the response and find it in the table. */ | |
6432 name[0] = hexhex2nr(code + 3); | |
6433 name[1] = hexhex2nr(code + 5); | |
6434 name[2] = NUL; | |
6435 for (i = 0; key_names[i] != NULL; ++i) | |
6436 { | |
6437 if (STRCMP(key_names[i], name) == 0) | |
6438 { | |
6439 xt_index_in = i; | |
6440 break; | |
6441 } | |
6442 } | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6443 # ifdef DEBUG_TERMRESPONSE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6444 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6445 char buf[100]; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6446 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6447 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
|
6448 log_tr(buf); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6449 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6450 # endif |
7 | 6451 if (key_names[i] != NULL) |
6452 { | |
6453 for (i = 8; (c = hexhex2nr(code + i)) >= 0; i += 2) | |
6454 str[j++] = c; | |
6455 str[j] = NUL; | |
6456 if (name[0] == 'C' && name[1] == 'o') | |
6457 { | |
6458 /* Color count is not a key code. */ | |
6459 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
|
6460 may_adjust_color_count(i); |
7 | 6461 } |
6462 else | |
6463 { | |
6464 /* First delete any existing entry with the same code. */ | |
6465 i = find_term_bykeys(str); | |
6466 if (i >= 0) | |
6467 del_termcode_idx(i); | |
180 | 6468 add_termcode(name, str, ATC_FROM_TERM); |
7 | 6469 } |
6470 } | |
6471 } | |
6472 | |
6473 /* May request more codes now that we received one. */ | |
6474 ++xt_index_in; | |
6475 req_more_codes_from_term(); | |
6476 } | |
6477 | |
6478 /* | |
6479 * Check if there are any unanswered requests and deal with them. | |
6480 * This is called before starting an external program or getting direct | |
6481 * keyboard input. We don't want responses to be send to that program or | |
6482 * handled as typed text. | |
6483 */ | |
6484 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6485 check_for_codes_from_term(void) |
7 | 6486 { |
6487 int c; | |
6488 | |
6489 /* If no codes requested or all are answered, no need to wait. */ | |
6490 if (xt_index_out == 0 || xt_index_out == xt_index_in) | |
6491 return; | |
6492 | |
6493 /* Vgetc() will check for and handle any response. | |
6494 * Keep calling vpeekc() until we don't get any responses. */ | |
6495 ++no_mapping; | |
6496 ++allow_keys; | |
6497 for (;;) | |
6498 { | |
6499 c = vpeekc(); | |
6500 if (c == NUL) /* nothing available */ | |
6501 break; | |
6502 | |
6503 /* If a response is recognized it's replaced with K_IGNORE, must read | |
6504 * it from the input stream. If there is no K_IGNORE we can't do | |
6505 * anything, break here (there might be some responses further on, but | |
6506 * we don't want to throw away any typed chars). */ | |
6507 if (c != K_SPECIAL && c != K_IGNORE) | |
6508 break; | |
6509 c = vgetc(); | |
6510 if (c != K_IGNORE) | |
6511 { | |
6512 vungetc(c); | |
6513 break; | |
6514 } | |
6515 } | |
6516 --no_mapping; | |
6517 --allow_keys; | |
6518 } | |
6519 #endif | |
6520 | |
6521 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) | |
6522 /* | |
6523 * Translate an internal mapping/abbreviation representation into the | |
6524 * corresponding external one recognized by :map/:abbrev commands; | |
6525 * respects the current B/k/< settings of 'cpoption'. | |
6526 * | |
6527 * This function is called when expanding mappings/abbreviations on the | |
1902 | 6528 * command-line, and for building the "Ambiguous mapping..." error message. |
7 | 6529 * |
6530 * It uses a growarray to build the translation string since the | |
6531 * latter can be wider than the original description. The caller has to | |
6532 * free the string afterwards. | |
6533 * | |
6534 * Returns NULL when there is a problem. | |
6535 */ | |
6536 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6537 translate_mapping( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6538 char_u *str, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6539 int expmap) /* TRUE when expanding mappings on command-line */ |
7 | 6540 { |
6541 garray_T ga; | |
6542 int c; | |
6543 int modifiers; | |
6544 int cpo_bslash; | |
6545 int cpo_special; | |
6546 int cpo_keycode; | |
6547 | |
6548 ga_init(&ga); | |
6549 ga.ga_itemsize = 1; | |
6550 ga.ga_growsize = 40; | |
6551 | |
6552 cpo_bslash = (vim_strchr(p_cpo, CPO_BSLASH) != NULL); | |
6553 cpo_special = (vim_strchr(p_cpo, CPO_SPECI) != NULL); | |
6554 cpo_keycode = (vim_strchr(p_cpo, CPO_KEYCODE) == NULL); | |
6555 | |
6556 for (; *str; ++str) | |
6557 { | |
6558 c = *str; | |
6559 if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL) | |
6560 { | |
6561 modifiers = 0; | |
6562 if (str[1] == KS_MODIFIER) | |
6563 { | |
6564 str++; | |
6565 modifiers = *++str; | |
6566 c = *++str; | |
6567 } | |
6568 if (cpo_special && cpo_keycode && c == K_SPECIAL && !modifiers) | |
6569 { | |
6570 int i; | |
6571 | |
6572 /* try to find special key in termcodes */ | |
6573 for (i = 0; i < tc_len; ++i) | |
6574 if (termcodes[i].name[0] == str[1] | |
6575 && termcodes[i].name[1] == str[2]) | |
6576 break; | |
6577 if (i < tc_len) | |
6578 { | |
6579 ga_concat(&ga, termcodes[i].code); | |
6580 str += 2; | |
6581 continue; /* for (str) */ | |
6582 } | |
6583 } | |
6584 if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL) | |
6585 { | |
6586 if (expmap && cpo_special) | |
6587 { | |
6588 ga_clear(&ga); | |
6589 return NULL; | |
6590 } | |
6591 c = TO_SPECIAL(str[1], str[2]); | |
6592 if (c == K_ZERO) /* display <Nul> as ^@ */ | |
6593 c = NUL; | |
6594 str += 2; | |
6595 } | |
6596 if (IS_SPECIAL(c) || modifiers) /* special key */ | |
6597 { | |
6598 if (expmap && cpo_special) | |
6599 { | |
6600 ga_clear(&ga); | |
6601 return NULL; | |
6602 } | |
6603 ga_concat(&ga, get_special_key_name(c, modifiers)); | |
6604 continue; /* for (str) */ | |
6605 } | |
6606 } | |
6607 if (c == ' ' || c == '\t' || c == Ctrl_J || c == Ctrl_V | |
6608 || (c == '<' && !cpo_special) || (c == '\\' && !cpo_bslash)) | |
6609 ga_append(&ga, cpo_bslash ? Ctrl_V : '\\'); | |
6610 if (c) | |
6611 ga_append(&ga, c); | |
6612 } | |
6613 ga_append(&ga, NUL); | |
6614 return (char_u *)(ga.ga_data); | |
6615 } | |
6616 #endif | |
6617 | |
6618 #if (defined(WIN3264) && !defined(FEAT_GUI)) || defined(PROTO) | |
6619 static char ksme_str[20]; | |
6620 static char ksmr_str[20]; | |
6621 static char ksmd_str[20]; | |
6622 | |
6623 /* | |
6624 * For Win32 console: update termcap codes for existing console attributes. | |
6625 */ | |
6626 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6627 update_tcap(int attr) |
7 | 6628 { |
6629 struct builtin_term *p; | |
6630 | |
6631 p = find_builtin_term(DEFAULT_TERM); | |
6632 sprintf(ksme_str, IF_EB("\033|%dm", ESC_STR "|%dm"), attr); | |
6633 sprintf(ksmd_str, IF_EB("\033|%dm", ESC_STR "|%dm"), | |
6634 attr | 0x08); /* FOREGROUND_INTENSITY */ | |
6635 sprintf(ksmr_str, IF_EB("\033|%dm", ESC_STR "|%dm"), | |
6636 ((attr & 0x0F) << 4) | ((attr & 0xF0) >> 4)); | |
6637 | |
6638 while (p->bt_string != NULL) | |
6639 { | |
6640 if (p->bt_entry == (int)KS_ME) | |
6641 p->bt_string = &ksme_str[0]; | |
6642 else if (p->bt_entry == (int)KS_MR) | |
6643 p->bt_string = &ksmr_str[0]; | |
6644 else if (p->bt_entry == (int)KS_MD) | |
6645 p->bt_string = &ksmd_str[0]; | |
6646 ++p; | |
6647 } | |
6648 } | |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6649 |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6650 # ifdef FEAT_TERMGUICOLORS |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6651 struct ks_tbl_s |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6652 { |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6653 int code; /* value of KS_ */ |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6654 char *vtp; /* code in vtp mode */ |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6655 char *buf; /* buffer in non-vtp mode */ |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6656 char *vbuf; /* buffer in vtp mode */ |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6657 }; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6658 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6659 static struct ks_tbl_s ks_tbl[] = |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6660 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6661 {(int)KS_ME, "\033|0m" }, /* normal */ |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6662 {(int)KS_MR, "\033|7m" }, /* reverse */ |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6663 {(int)KS_MD, "\033|1m" }, /* bold */ |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6664 {(int)KS_SO, "\033|91m"}, /* standout: bright red text */ |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6665 {(int)KS_SE, "\033|39m"}, /* standout end: default color */ |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6666 {(int)KS_CZH, "\033|95m"}, /* italic: bright magenta text */ |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6667 {(int)KS_CZR, "\033|0m",}, /* italic end */ |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6668 {(int)KS_US, "\033|4m",}, /* underscore */ |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6669 {(int)KS_UE, "\033|24m"}, /* underscore end */ |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6670 {(int)KS_NAME, NULL} |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6671 }; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6672 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6673 static struct builtin_term * |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6674 find_first_tcap( |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6675 char_u *name, |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6676 int code) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6677 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6678 struct builtin_term *p; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6679 |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6680 for (p = find_builtin_term(name); p->bt_string != NULL; ++p) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6681 if (p->bt_entry == code) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6682 return p; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6683 return NULL; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6684 } |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6685 # endif |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6686 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6687 /* |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6688 * For Win32 console: replace the sequence immediately after termguicolors. |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6689 */ |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6690 void |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6691 swap_tcap(void) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6692 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6693 # ifdef FEAT_TERMGUICOLORS |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6694 static int init_done = FALSE; |
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6695 static int last_tgc; |
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6696 struct ks_tbl_s *ks; |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6697 struct builtin_term *bt; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6698 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6699 /* buffer initialization */ |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6700 if (!init_done) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6701 { |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6702 for (ks = ks_tbl; ks->vtp != NULL; ks++) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6703 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6704 bt = find_first_tcap(DEFAULT_TERM, ks->code); |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6705 if (bt != NULL) |
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6706 { |
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6707 ks->buf = bt->bt_string; |
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6708 ks->vbuf = ks->vtp; |
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6709 } |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6710 } |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6711 init_done = TRUE; |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6712 last_tgc = p_tgc; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6713 return; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6714 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6715 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6716 if (last_tgc != p_tgc) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6717 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6718 if (p_tgc) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6719 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6720 /* switch to special character sequence */ |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6721 for (ks = ks_tbl; ks->vtp != NULL; ks++) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6722 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6723 bt = find_first_tcap(DEFAULT_TERM, ks->code); |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6724 if (bt != NULL) |
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6725 { |
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6726 ks->buf = bt->bt_string; |
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6727 bt->bt_string = ks->vbuf; |
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6728 } |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6729 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6730 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6731 else |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6732 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6733 /* switch to index color */ |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6734 for (ks = ks_tbl; ks->vtp != NULL; ks++) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6735 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6736 bt = find_first_tcap(DEFAULT_TERM, ks->code); |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6737 if (bt != NULL) |
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6738 { |
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6739 ks->vbuf = bt->bt_string; |
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6740 bt->bt_string = ks->buf; |
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6741 } |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6742 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6743 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6744 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6745 last_tgc = p_tgc; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6746 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6747 # endif |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6748 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6749 |
7 | 6750 #endif |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6751 |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
6752 #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
|
6753 static int |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6754 hex_digit(int c) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6755 { |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6756 if (isdigit(c)) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6757 return c - '0'; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6758 c = TOLOWER_ASC(c); |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6759 if (c >= 'a' && c <= 'f') |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6760 return c - 'a' + 10; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6761 return 0x1ffffff; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6762 } |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6763 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6764 guicolor_T |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6765 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
|
6766 { |
10512
675dfe47ab69
commit https://github.com/vim/vim/commit/287266527abc163e191a06dd70518bbbdab4468f
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
6767 /* 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
|
6768 * 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
|
6769 * MS-Windows GDI builds. */ |
675dfe47ab69
commit https://github.com/vim/vim/commit/287266527abc163e191a06dd70518bbbdab4468f
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
6770 # 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
|
6771 # undef RGB |
675dfe47ab69
commit https://github.com/vim/vim/commit/287266527abc163e191a06dd70518bbbdab4468f
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
6772 # endif |
9021
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6773 # ifndef RGB |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6774 # 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
|
6775 # endif |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6776 # define LINE_LEN 100 |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6777 FILE *fd; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6778 char line[LINE_LEN]; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6779 char_u *fname; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6780 int r, g, b, i; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6781 guicolor_T color; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6782 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6783 struct rgbcolor_table_S { |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6784 char_u *color_name; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6785 guicolor_T color; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6786 }; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6787 |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6788 /* 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
|
6789 * 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
|
6790 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
|
6791 {(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
|
6792 {(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
|
6793 {(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
|
6794 {(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
|
6795 {(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
|
6796 {(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
|
6797 {(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
|
6798 {(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
|
6799 {(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
|
6800 {(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
|
6801 {(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
|
6802 {(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
|
6803 {(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
|
6804 {(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
|
6805 {(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
|
6806 {(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
|
6807 {(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
|
6808 {(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
|
6809 {(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
|
6810 {(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
|
6811 {(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
|
6812 {(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
|
6813 {(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
|
6814 {(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
|
6815 {(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
|
6816 {(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
|
6817 {(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
|
6818 {(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
|
6819 {(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
|
6820 {(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
|
6821 }; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6822 |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6823 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
|
6824 static int size = 0; |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6825 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6826 if (name[0] == '#' && STRLEN(name) == 7) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6827 { |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6828 /* Name is in "#rrggbb" format */ |
9021
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6829 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
|
6830 ((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
|
6831 ((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
|
6832 if (color > 0xffffff) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6833 return INVALCOLOR; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6834 return color; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6835 } |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6836 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6837 /* 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
|
6838 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
|
6839 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
|
6840 return rgb_table[i].color; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6841 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6842 /* |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6843 * 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
|
6844 */ |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6845 if (size == 0) |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6846 { |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6847 int counting; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6848 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6849 /* colornames_table not yet initialized */ |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6850 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
|
6851 if (fname == NULL) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6852 return INVALCOLOR; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6853 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6854 fd = fopen((char *)fname, "rt"); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6855 vim_free(fname); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6856 if (fd == NULL) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6857 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6858 if (p_verbose > 1) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6859 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
|
6860 return INVALCOLOR; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6861 } |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6862 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6863 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
|
6864 { |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6865 if (!counting) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6866 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6867 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
|
6868 (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
|
6869 if (colornames_table == NULL) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6870 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6871 fclose(fd); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6872 return INVALCOLOR; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6873 } |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6874 rewind(fd); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6875 } |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6876 size = 0; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6877 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6878 while (!feof(fd)) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6879 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6880 size_t len; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6881 int pos; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6882 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6883 ignoredp = fgets(line, LINE_LEN, fd); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6884 len = strlen(line); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6885 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6886 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
|
6887 continue; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6888 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6889 line[len - 1] = '\0'; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6890 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6891 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
|
6892 if (i != 3) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6893 continue; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6894 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6895 if (!counting) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6896 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6897 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
|
6898 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6899 if (s == NULL) |
9628
fefd0551aa9d
commit https://github.com/vim/vim/commit/2e45d21c819272051f7ef4436f483e4b2ecfb369
Christian Brabandt <cb@256bit.org>
parents:
9601
diff
changeset
|
6900 { |
fefd0551aa9d
commit https://github.com/vim/vim/commit/2e45d21c819272051f7ef4436f483e4b2ecfb369
Christian Brabandt <cb@256bit.org>
parents:
9601
diff
changeset
|
6901 fclose(fd); |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6902 return INVALCOLOR; |
9628
fefd0551aa9d
commit https://github.com/vim/vim/commit/2e45d21c819272051f7ef4436f483e4b2ecfb369
Christian Brabandt <cb@256bit.org>
parents:
9601
diff
changeset
|
6903 } |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6904 colornames_table[size].color_name = s; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6905 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
|
6906 } |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6907 size++; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6908 } |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6909 } |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6910 fclose(fd); |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6911 } |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6912 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6913 for (i = 0; i < size; i++) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6914 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
|
6915 return colornames_table[i].color; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6916 |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6917 return INVALCOLOR; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6918 } |
11745
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11739
diff
changeset
|
6919 |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11739
diff
changeset
|
6920 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
|
6921 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
|
6922 { |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11739
diff
changeset
|
6923 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
|
6924 |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11739
diff
changeset
|
6925 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
|
6926 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
|
6927 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
|
6928 } |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6929 #endif |