Mercurial > vim
annotate src/term.c @ 16058:012f03e583e2 v8.1.1034
patch 8.1.1034: too many #ifdefs
commit https://github.com/vim/vim/commit/2ace1bd652211506b60faddb8243e48400c89492
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Mar 22 12:03:30 2019 +0100
patch 8.1.1034: too many #ifdefs
Problem: Too many #ifdefs.
Solution: Merge FEAT_MOUSE_SGR into FEAT_MOUSE_XTERM / FEAT_MOUSE_TTY.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 22 Mar 2019 12:15:04 +0100 |
parents | 7fad90423bd2 |
children | bed0d7200635 |
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 void parse_builtin_tcap(char_u *s); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
78 static void gather_termleader(void); |
7 | 79 #ifdef FEAT_TERMRESPONSE |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
80 static void req_codes_from_term(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
81 static void req_more_codes_from_term(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
82 static void got_code_from_term(char_u *code, int len); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
83 static void check_for_codes_from_term(void); |
7 | 84 #endif |
85 #if defined(FEAT_GUI) \ | |
1623 | 86 || (defined(FEAT_MOUSE) && (!defined(UNIX) || defined(FEAT_MOUSE_XTERM) \ |
87 || 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
|
88 static int get_bytes_from_buf(char_u *, char_u *, int); |
7 | 89 #endif |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
90 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
|
91 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
|
92 static int term_7to8bit(char_u *p); |
7 | 93 |
94 #ifdef HAVE_TGETENT | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
95 static char *tgetent_error(char_u *, char_u *); |
7 | 96 |
97 /* | |
98 * Here is our own prototype for tgetstr(), any prototypes from the include | |
99 * files have been disabled by the define at the start of this file. | |
100 */ | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
101 char *tgetstr(char *, char **); |
7 | 102 |
103 # ifdef FEAT_TERMRESPONSE | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
104 /* 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
|
105 # if 0 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
106 # define DEBUG_TERMRESPONSE |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
107 static void log_tr(const char *fmt, ...); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
108 # define LOG_TR(msg) log_tr msg |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
109 # else |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
110 # define LOG_TR(msg) do { /**/ } while (0) |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
111 # 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
|
112 |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
113 # 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
|
114 # 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
|
115 # 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
|
116 |
7 | 117 /* 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
|
118 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
|
119 |
4215 | 120 /* 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
|
121 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
|
122 |
12634
94566ecb55f0
patch 8.0.1195: can't build on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12632
diff
changeset
|
123 # 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
|
124 /* 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
|
125 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
|
126 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
|
127 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
|
128 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
|
129 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
|
130 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
|
131 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
|
132 # 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
|
133 |
6874 | 134 /* 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
|
135 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
|
136 |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
137 /* 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
|
138 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
|
139 |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
140 /* 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
|
141 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
|
142 |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
143 /* 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
|
144 static int winpos_status = STATUS_GET; |
7 | 145 # endif |
146 | |
147 /* | |
148 * Don't declare these variables if termcap.h contains them. | |
149 * Autoconf checks if these variables should be declared extern (not all | |
150 * systems have them). | |
151 * Some versions define ospeed to be speed_t, but that is incompatible with | |
152 * BSD, where ospeed is short and speed_t is long. | |
153 */ | |
154 # ifndef HAVE_OSPEED | |
155 # ifdef OSPEED_EXTERN | |
156 extern short ospeed; | |
157 # else | |
158 short ospeed; | |
159 # endif | |
160 # endif | |
161 # ifndef HAVE_UP_BC_PC | |
162 # ifdef UP_BC_PC_EXTERN | |
163 extern char *UP, *BC, PC; | |
164 # else | |
165 char *UP, *BC, PC; | |
166 # endif | |
167 # endif | |
168 | |
169 # define TGETSTR(s, p) vim_tgetstr((s), (p)) | |
170 # 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
|
171 static char_u *vim_tgetstr(char *s, char_u **pp); |
7 | 172 #endif /* HAVE_TGETENT */ |
173 | |
174 static int detected_8bit = FALSE; /* detected 8-bit terminal */ | |
175 | |
12184
76fbd85c3cea
patch 8.0.0972: compiler warnings for unused variables
Christian Brabandt <cb@256bit.org>
parents:
12174
diff
changeset
|
176 #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
|
177 /* 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
|
178 * 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
|
179 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
|
180 |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
181 /* 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
|
182 * 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
|
183 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
|
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 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
|
186 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
|
187 #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
|
188 |
298 | 189 static struct builtin_term builtin_termcaps[] = |
7 | 190 { |
191 | |
192 #if defined(FEAT_GUI) | |
193 /* | |
194 * GUI pseudo term-cap. | |
195 */ | |
196 {(int)KS_NAME, "gui"}, | |
197 {(int)KS_CE, IF_EB("\033|$", ESC_STR "|$")}, | |
198 {(int)KS_AL, IF_EB("\033|i", ESC_STR "|i")}, | |
199 # ifdef TERMINFO | |
200 {(int)KS_CAL, IF_EB("\033|%p1%dI", ESC_STR "|%p1%dI")}, | |
201 # else | |
202 {(int)KS_CAL, IF_EB("\033|%dI", ESC_STR "|%dI")}, | |
203 # endif | |
204 {(int)KS_DL, IF_EB("\033|d", ESC_STR "|d")}, | |
205 # ifdef TERMINFO | |
206 {(int)KS_CDL, IF_EB("\033|%p1%dD", ESC_STR "|%p1%dD")}, | |
207 {(int)KS_CS, IF_EB("\033|%p1%d;%p2%dR", ESC_STR "|%p1%d;%p2%dR")}, | |
208 {(int)KS_CSV, IF_EB("\033|%p1%d;%p2%dV", ESC_STR "|%p1%d;%p2%dV")}, | |
209 # else | |
210 {(int)KS_CDL, IF_EB("\033|%dD", ESC_STR "|%dD")}, | |
211 {(int)KS_CS, IF_EB("\033|%d;%dR", ESC_STR "|%d;%dR")}, | |
212 {(int)KS_CSV, IF_EB("\033|%d;%dV", ESC_STR "|%d;%dV")}, | |
213 # endif | |
214 {(int)KS_CL, IF_EB("\033|C", ESC_STR "|C")}, | |
215 /* attributes switched on with 'h', off with * 'H' */ | |
216 {(int)KS_ME, IF_EB("\033|31H", ESC_STR "|31H")}, /* HL_ALL */ | |
217 {(int)KS_MR, IF_EB("\033|1h", ESC_STR "|1h")}, /* HL_INVERSE */ | |
218 {(int)KS_MD, IF_EB("\033|2h", ESC_STR "|2h")}, /* HL_BOLD */ | |
219 {(int)KS_SE, IF_EB("\033|16H", ESC_STR "|16H")}, /* HL_STANDOUT */ | |
220 {(int)KS_SO, IF_EB("\033|16h", ESC_STR "|16h")}, /* HL_STANDOUT */ | |
221 {(int)KS_UE, IF_EB("\033|8H", ESC_STR "|8H")}, /* HL_UNDERLINE */ | |
222 {(int)KS_US, IF_EB("\033|8h", ESC_STR "|8h")}, /* HL_UNDERLINE */ | |
205 | 223 {(int)KS_UCE, IF_EB("\033|8C", ESC_STR "|8C")}, /* HL_UNDERCURL */ |
224 {(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
|
225 {(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
|
226 {(int)KS_STS, IF_EB("\033|4c", ESC_STR "|4c")}, /* HL_STRIKETHROUGH */ |
7 | 227 {(int)KS_CZR, IF_EB("\033|4H", ESC_STR "|4H")}, /* HL_ITALIC */ |
228 {(int)KS_CZH, IF_EB("\033|4h", ESC_STR "|4h")}, /* HL_ITALIC */ | |
229 {(int)KS_VB, IF_EB("\033|f", ESC_STR "|f")}, | |
230 {(int)KS_MS, "y"}, | |
231 {(int)KS_UT, "y"}, | |
6602 | 232 {(int)KS_XN, "y"}, |
7 | 233 {(int)KS_LE, "\b"}, /* cursor-left = BS */ |
234 {(int)KS_ND, "\014"}, /* cursor-right = CTRL-L */ | |
235 # ifdef TERMINFO | |
236 {(int)KS_CM, IF_EB("\033|%p1%d;%p2%dM", ESC_STR "|%p1%d;%p2%dM")}, | |
237 # else | |
238 {(int)KS_CM, IF_EB("\033|%d;%dM", ESC_STR "|%d;%dM")}, | |
239 # endif | |
240 /* there are no key sequences here, the GUI sequences are recognized | |
205 | 241 * in check_termcode() */ |
7 | 242 #endif |
243 | |
244 #ifndef NO_BUILTIN_TCAPS | |
245 | |
246 # if defined(AMIGA) || defined(ALL_BUILTIN_TCAPS) | |
247 /* | |
248 * Amiga console window, default for Amiga | |
249 */ | |
250 {(int)KS_NAME, "amiga"}, | |
251 {(int)KS_CE, "\033[K"}, | |
252 {(int)KS_CD, "\033[J"}, | |
253 {(int)KS_AL, "\033[L"}, | |
254 # ifdef TERMINFO | |
255 {(int)KS_CAL, "\033[%p1%dL"}, | |
256 # else | |
257 {(int)KS_CAL, "\033[%dL"}, | |
258 # endif | |
259 {(int)KS_DL, "\033[M"}, | |
260 # ifdef TERMINFO | |
261 {(int)KS_CDL, "\033[%p1%dM"}, | |
262 # else | |
263 {(int)KS_CDL, "\033[%dM"}, | |
264 # endif | |
265 {(int)KS_CL, "\014"}, | |
266 {(int)KS_VI, "\033[0 p"}, | |
267 {(int)KS_VE, "\033[1 p"}, | |
268 {(int)KS_ME, "\033[0m"}, | |
269 {(int)KS_MR, "\033[7m"}, | |
270 {(int)KS_MD, "\033[1m"}, | |
271 {(int)KS_SE, "\033[0m"}, | |
272 {(int)KS_SO, "\033[33m"}, | |
273 {(int)KS_US, "\033[4m"}, | |
274 {(int)KS_UE, "\033[0m"}, | |
275 {(int)KS_CZH, "\033[3m"}, | |
276 {(int)KS_CZR, "\033[0m"}, | |
277 #if defined(__MORPHOS__) || defined(__AROS__) | |
278 {(int)KS_CCO, "8"}, /* allow 8 colors */ | |
279 # ifdef TERMINFO | |
280 {(int)KS_CAB, "\033[4%p1%dm"},/* set background color */ | |
281 {(int)KS_CAF, "\033[3%p1%dm"},/* set foreground color */ | |
282 # else | |
283 {(int)KS_CAB, "\033[4%dm"}, /* set background color */ | |
284 {(int)KS_CAF, "\033[3%dm"}, /* set foreground color */ | |
285 # endif | |
286 {(int)KS_OP, "\033[m"}, /* reset colors */ | |
287 #endif | |
288 {(int)KS_MS, "y"}, | |
289 {(int)KS_UT, "y"}, /* guessed */ | |
290 {(int)KS_LE, "\b"}, | |
291 # ifdef TERMINFO | |
292 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
293 # else | |
294 {(int)KS_CM, "\033[%i%d;%dH"}, | |
295 # endif | |
296 #if defined(__MORPHOS__) | |
297 {(int)KS_SR, "\033M"}, | |
298 #endif | |
299 # ifdef TERMINFO | |
300 {(int)KS_CRI, "\033[%p1%dC"}, | |
301 # else | |
302 {(int)KS_CRI, "\033[%dC"}, | |
303 # endif | |
304 {K_UP, "\233A"}, | |
305 {K_DOWN, "\233B"}, | |
306 {K_LEFT, "\233D"}, | |
307 {K_RIGHT, "\233C"}, | |
308 {K_S_UP, "\233T"}, | |
309 {K_S_DOWN, "\233S"}, | |
310 {K_S_LEFT, "\233 A"}, | |
311 {K_S_RIGHT, "\233 @"}, | |
312 {K_S_TAB, "\233Z"}, | |
313 {K_F1, "\233\060~"},/* some compilers don't dig "\2330" */ | |
314 {K_F2, "\233\061~"}, | |
315 {K_F3, "\233\062~"}, | |
316 {K_F4, "\233\063~"}, | |
317 {K_F5, "\233\064~"}, | |
318 {K_F6, "\233\065~"}, | |
319 {K_F7, "\233\066~"}, | |
320 {K_F8, "\233\067~"}, | |
321 {K_F9, "\233\070~"}, | |
322 {K_F10, "\233\071~"}, | |
323 {K_S_F1, "\233\061\060~"}, | |
324 {K_S_F2, "\233\061\061~"}, | |
325 {K_S_F3, "\233\061\062~"}, | |
326 {K_S_F4, "\233\061\063~"}, | |
327 {K_S_F5, "\233\061\064~"}, | |
328 {K_S_F6, "\233\061\065~"}, | |
329 {K_S_F7, "\233\061\066~"}, | |
330 {K_S_F8, "\233\061\067~"}, | |
331 {K_S_F9, "\233\061\070~"}, | |
332 {K_S_F10, "\233\061\071~"}, | |
333 {K_HELP, "\233?~"}, | |
334 {K_INS, "\233\064\060~"}, /* 101 key keyboard */ | |
335 {K_PAGEUP, "\233\064\061~"}, /* 101 key keyboard */ | |
336 {K_PAGEDOWN, "\233\064\062~"}, /* 101 key keyboard */ | |
337 {K_HOME, "\233\064\064~"}, /* 101 key keyboard */ | |
338 {K_END, "\233\064\065~"}, /* 101 key keyboard */ | |
339 | |
340 {BT_EXTRA_KEYS, ""}, | |
341 {TERMCAP2KEY('#', '2'), "\233\065\064~"}, /* shifted home key */ | |
342 {TERMCAP2KEY('#', '3'), "\233\065\060~"}, /* shifted insert key */ | |
343 {TERMCAP2KEY('*', '7'), "\233\065\065~"}, /* shifted end key */ | |
344 # endif | |
345 | |
346 # if defined(__BEOS__) || defined(ALL_BUILTIN_TCAPS) | |
347 /* | |
348 * almost standard ANSI terminal, default for bebox | |
349 */ | |
350 {(int)KS_NAME, "beos-ansi"}, | |
351 {(int)KS_CE, "\033[K"}, | |
352 {(int)KS_CD, "\033[J"}, | |
353 {(int)KS_AL, "\033[L"}, | |
354 # ifdef TERMINFO | |
355 {(int)KS_CAL, "\033[%p1%dL"}, | |
356 # else | |
357 {(int)KS_CAL, "\033[%dL"}, | |
358 # endif | |
359 {(int)KS_DL, "\033[M"}, | |
360 # ifdef TERMINFO | |
361 {(int)KS_CDL, "\033[%p1%dM"}, | |
362 # else | |
363 {(int)KS_CDL, "\033[%dM"}, | |
364 # endif | |
365 #ifdef BEOS_PR_OR_BETTER | |
366 # ifdef TERMINFO | |
367 {(int)KS_CS, "\033[%i%p1%d;%p2%dr"}, | |
368 # else | |
369 {(int)KS_CS, "\033[%i%d;%dr"}, /* scroll region */ | |
370 # endif | |
371 #endif | |
372 {(int)KS_CL, "\033[H\033[2J"}, | |
373 #ifdef notyet | |
374 {(int)KS_VI, "[VI]"}, /* cursor invisible, VT320: CSI ? 25 l */ | |
375 {(int)KS_VE, "[VE]"}, /* cursor visible, VT320: CSI ? 25 h */ | |
376 #endif | |
377 {(int)KS_ME, "\033[m"}, /* normal mode */ | |
378 {(int)KS_MR, "\033[7m"}, /* reverse */ | |
379 {(int)KS_MD, "\033[1m"}, /* bold */ | |
380 {(int)KS_SO, "\033[31m"}, /* standout mode: red */ | |
381 {(int)KS_SE, "\033[m"}, /* standout end */ | |
382 {(int)KS_CZH, "\033[35m"}, /* italic: purple */ | |
383 {(int)KS_CZR, "\033[m"}, /* italic end */ | |
384 {(int)KS_US, "\033[4m"}, /* underscore mode */ | |
385 {(int)KS_UE, "\033[m"}, /* underscore end */ | |
386 {(int)KS_CCO, "8"}, /* allow 8 colors */ | |
387 # ifdef TERMINFO | |
388 {(int)KS_CAB, "\033[4%p1%dm"},/* set background color */ | |
389 {(int)KS_CAF, "\033[3%p1%dm"},/* set foreground color */ | |
390 # else | |
391 {(int)KS_CAB, "\033[4%dm"}, /* set background color */ | |
392 {(int)KS_CAF, "\033[3%dm"}, /* set foreground color */ | |
393 # endif | |
394 {(int)KS_OP, "\033[m"}, /* reset colors */ | |
395 {(int)KS_MS, "y"}, /* safe to move cur in reverse mode */ | |
396 {(int)KS_UT, "y"}, /* guessed */ | |
397 {(int)KS_LE, "\b"}, | |
398 # ifdef TERMINFO | |
399 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
400 # else | |
401 {(int)KS_CM, "\033[%i%d;%dH"}, | |
402 # endif | |
403 {(int)KS_SR, "\033M"}, | |
404 # ifdef TERMINFO | |
405 {(int)KS_CRI, "\033[%p1%dC"}, | |
406 # else | |
407 {(int)KS_CRI, "\033[%dC"}, | |
408 # endif | |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
409 # if defined(BEOS_DR8) |
7 | 410 {(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
|
411 # endif |
7 | 412 |
413 {K_UP, "\033[A"}, | |
414 {K_DOWN, "\033[B"}, | |
415 {K_LEFT, "\033[D"}, | |
416 {K_RIGHT, "\033[C"}, | |
417 # endif | |
418 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
419 # if defined(UNIX) || defined(ALL_BUILTIN_TCAPS) || defined(SOME_BUILTIN_TCAPS) |
7 | 420 /* |
421 * standard ANSI terminal, default for unix | |
422 */ | |
423 {(int)KS_NAME, "ansi"}, | |
424 {(int)KS_CE, IF_EB("\033[K", ESC_STR "[K")}, | |
425 {(int)KS_AL, IF_EB("\033[L", ESC_STR "[L")}, | |
426 # ifdef TERMINFO | |
427 {(int)KS_CAL, IF_EB("\033[%p1%dL", ESC_STR "[%p1%dL")}, | |
428 # else | |
429 {(int)KS_CAL, IF_EB("\033[%dL", ESC_STR "[%dL")}, | |
430 # endif | |
431 {(int)KS_DL, IF_EB("\033[M", ESC_STR "[M")}, | |
432 # ifdef TERMINFO | |
433 {(int)KS_CDL, IF_EB("\033[%p1%dM", ESC_STR "[%p1%dM")}, | |
434 # else | |
435 {(int)KS_CDL, IF_EB("\033[%dM", ESC_STR "[%dM")}, | |
436 # endif | |
437 {(int)KS_CL, IF_EB("\033[H\033[2J", ESC_STR "[H" ESC_STR_nc "[2J")}, | |
438 {(int)KS_ME, IF_EB("\033[0m", ESC_STR "[0m")}, | |
439 {(int)KS_MR, IF_EB("\033[7m", ESC_STR "[7m")}, | |
440 {(int)KS_MS, "y"}, | |
441 {(int)KS_UT, "y"}, /* guessed */ | |
442 {(int)KS_LE, "\b"}, | |
443 # ifdef TERMINFO | |
444 {(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", ESC_STR "[%i%p1%d;%p2%dH")}, | |
445 # else | |
446 {(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")}, | |
447 # endif | |
448 # ifdef TERMINFO | |
449 {(int)KS_CRI, IF_EB("\033[%p1%dC", ESC_STR "[%p1%dC")}, | |
450 # else | |
451 {(int)KS_CRI, IF_EB("\033[%dC", ESC_STR "[%dC")}, | |
452 # endif | |
453 # endif | |
454 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
455 # if defined(ALL_BUILTIN_TCAPS) |
7 | 456 /* |
457 * These codes are valid when nansi.sys or equivalent has been installed. | |
458 * Function keys on a PC are preceded with a NUL. These are converted into | |
459 * K_NUL '\316' in mch_inchar(), because we cannot handle NULs in key codes. | |
460 * CTRL-arrow is used instead of SHIFT-arrow. | |
461 */ | |
462 {(int)KS_NAME, "pcansi"}, | |
463 {(int)KS_DL, "\033[M"}, | |
464 {(int)KS_AL, "\033[L"}, | |
465 {(int)KS_CE, "\033[K"}, | |
466 {(int)KS_CL, "\033[2J"}, | |
467 {(int)KS_ME, "\033[0m"}, | |
468 {(int)KS_MR, "\033[5m"}, /* reverse: black on lightgrey */ | |
469 {(int)KS_MD, "\033[1m"}, /* bold: white text */ | |
470 {(int)KS_SE, "\033[0m"}, /* standout end */ | |
471 {(int)KS_SO, "\033[31m"}, /* standout: white on blue */ | |
472 {(int)KS_CZH, "\033[34;43m"}, /* italic mode: blue text on yellow */ | |
473 {(int)KS_CZR, "\033[0m"}, /* italic mode end */ | |
474 {(int)KS_US, "\033[36;41m"}, /* underscore mode: cyan text on red */ | |
475 {(int)KS_UE, "\033[0m"}, /* underscore mode end */ | |
476 {(int)KS_CCO, "8"}, /* allow 8 colors */ | |
477 # ifdef TERMINFO | |
478 {(int)KS_CAB, "\033[4%p1%dm"},/* set background color */ | |
479 {(int)KS_CAF, "\033[3%p1%dm"},/* set foreground color */ | |
480 # else | |
481 {(int)KS_CAB, "\033[4%dm"}, /* set background color */ | |
482 {(int)KS_CAF, "\033[3%dm"}, /* set foreground color */ | |
483 # endif | |
484 {(int)KS_OP, "\033[0m"}, /* reset colors */ | |
485 {(int)KS_MS, "y"}, | |
486 {(int)KS_UT, "y"}, /* guessed */ | |
487 {(int)KS_LE, "\b"}, | |
488 # ifdef TERMINFO | |
489 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
490 # else | |
491 {(int)KS_CM, "\033[%i%d;%dH"}, | |
492 # endif | |
493 # ifdef TERMINFO | |
494 {(int)KS_CRI, "\033[%p1%dC"}, | |
495 # else | |
496 {(int)KS_CRI, "\033[%dC"}, | |
497 # endif | |
498 {K_UP, "\316H"}, | |
499 {K_DOWN, "\316P"}, | |
500 {K_LEFT, "\316K"}, | |
501 {K_RIGHT, "\316M"}, | |
502 {K_S_LEFT, "\316s"}, | |
503 {K_S_RIGHT, "\316t"}, | |
504 {K_F1, "\316;"}, | |
505 {K_F2, "\316<"}, | |
506 {K_F3, "\316="}, | |
507 {K_F4, "\316>"}, | |
508 {K_F5, "\316?"}, | |
509 {K_F6, "\316@"}, | |
510 {K_F7, "\316A"}, | |
511 {K_F8, "\316B"}, | |
512 {K_F9, "\316C"}, | |
513 {K_F10, "\316D"}, | |
514 {K_F11, "\316\205"}, /* guessed */ | |
515 {K_F12, "\316\206"}, /* guessed */ | |
516 {K_S_F1, "\316T"}, | |
517 {K_S_F2, "\316U"}, | |
518 {K_S_F3, "\316V"}, | |
519 {K_S_F4, "\316W"}, | |
520 {K_S_F5, "\316X"}, | |
521 {K_S_F6, "\316Y"}, | |
522 {K_S_F7, "\316Z"}, | |
523 {K_S_F8, "\316["}, | |
524 {K_S_F9, "\316\\"}, | |
525 {K_S_F10, "\316]"}, | |
526 {K_S_F11, "\316\207"}, /* guessed */ | |
527 {K_S_F12, "\316\210"}, /* guessed */ | |
528 {K_INS, "\316R"}, | |
529 {K_DEL, "\316S"}, | |
530 {K_HOME, "\316G"}, | |
531 {K_END, "\316O"}, | |
532 {K_PAGEDOWN, "\316Q"}, | |
533 {K_PAGEUP, "\316I"}, | |
534 # endif | |
535 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15852
diff
changeset
|
536 # if defined(MSWIN) || defined(ALL_BUILTIN_TCAPS) |
7 | 537 /* |
538 * These codes are valid for the Win32 Console . The entries that start with | |
539 * ESC | are translated into console calls in os_win32.c. The function keys | |
540 * are also translated in os_win32.c. | |
541 */ | |
542 {(int)KS_NAME, "win32"}, | |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
543 {(int)KS_CE, "\033|K"}, // clear to end of line |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
544 {(int)KS_AL, "\033|L"}, // add new blank line |
7 | 545 # ifdef TERMINFO |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
546 {(int)KS_CAL, "\033|%p1%dL"}, // add number of new blank lines |
7 | 547 # else |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
548 {(int)KS_CAL, "\033|%dL"}, // add number of new blank lines |
7 | 549 # endif |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
550 {(int)KS_DL, "\033|M"}, // delete line |
7 | 551 # ifdef TERMINFO |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
552 {(int)KS_CDL, "\033|%p1%dM"}, // delete number of lines |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
553 {(int)KS_CSV, "\033|%p1%d;%p2%dV"}, |
7 | 554 # else |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
555 {(int)KS_CDL, "\033|%dM"}, // delete number of lines |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
556 {(int)KS_CSV, "\033|%d;%dV"}, |
7 | 557 # endif |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
558 {(int)KS_CL, "\033|J"}, // clear screen |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
559 {(int)KS_CD, "\033|j"}, // clear to end of display |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
560 {(int)KS_VI, "\033|v"}, // cursor invisible |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
561 {(int)KS_VE, "\033|V"}, // cursor visible |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
562 |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
563 {(int)KS_ME, "\033|0m"}, // normal |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
564 {(int)KS_MR, "\033|112m"}, // reverse: black on lightgray |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
565 {(int)KS_MD, "\033|15m"}, // bold: white on black |
7 | 566 #if 1 |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
567 {(int)KS_SO, "\033|31m"}, // standout: white on blue |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
568 {(int)KS_SE, "\033|0m"}, // standout end |
7 | 569 #else |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
570 {(int)KS_SO, "\033|F"}, // standout: high intensity |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
571 {(int)KS_SE, "\033|f"}, // standout end |
7 | 572 #endif |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
573 {(int)KS_CZH, "\033|225m"}, // italic: blue text on yellow |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
574 {(int)KS_CZR, "\033|0m"}, // italic end |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
575 {(int)KS_US, "\033|67m"}, // underscore: cyan text on red |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
576 {(int)KS_UE, "\033|0m"}, // underscore end |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
577 {(int)KS_CCO, "16"}, // allow 16 colors |
7 | 578 # ifdef TERMINFO |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
579 {(int)KS_CAB, "\033|%p1%db"}, // set background color |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
580 {(int)KS_CAF, "\033|%p1%df"}, // set foreground color |
7 | 581 # else |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
582 {(int)KS_CAB, "\033|%db"}, // set background color |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
583 {(int)KS_CAF, "\033|%df"}, // set foreground color |
7 | 584 # endif |
585 | |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
586 {(int)KS_MS, "y"}, // save to move cur in reverse mode |
7 | 587 {(int)KS_UT, "y"}, |
6602 | 588 {(int)KS_XN, "y"}, |
7 | 589 {(int)KS_LE, "\b"}, |
590 # ifdef TERMINFO | |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
591 {(int)KS_CM, "\033|%i%p1%d;%p2%dH"}, // cursor motion |
7 | 592 # else |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
593 {(int)KS_CM, "\033|%i%d;%dH"}, // cursor motion |
7 | 594 # endif |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
595 {(int)KS_VB, "\033|B"}, // visual bell |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
596 {(int)KS_TI, "\033|S"}, // put terminal in termcap mode |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
597 {(int)KS_TE, "\033|E"}, // out of termcap mode |
7 | 598 # ifdef TERMINFO |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
599 {(int)KS_CS, "\033|%i%p1%d;%p2%dr"}, // scroll region |
7 | 600 # else |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
601 {(int)KS_CS, "\033|%i%d;%dr"}, // scroll region |
7 | 602 # 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
|
603 # 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
|
604 {(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
|
605 {(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
|
606 # endif |
7 | 607 |
608 {K_UP, "\316H"}, | |
609 {K_DOWN, "\316P"}, | |
610 {K_LEFT, "\316K"}, | |
611 {K_RIGHT, "\316M"}, | |
612 {K_S_UP, "\316\304"}, | |
613 {K_S_DOWN, "\316\317"}, | |
614 {K_S_LEFT, "\316\311"}, | |
615 {K_C_LEFT, "\316s"}, | |
616 {K_S_RIGHT, "\316\313"}, | |
617 {K_C_RIGHT, "\316t"}, | |
618 {K_S_TAB, "\316\017"}, | |
619 {K_F1, "\316;"}, | |
620 {K_F2, "\316<"}, | |
621 {K_F3, "\316="}, | |
622 {K_F4, "\316>"}, | |
623 {K_F5, "\316?"}, | |
624 {K_F6, "\316@"}, | |
625 {K_F7, "\316A"}, | |
626 {K_F8, "\316B"}, | |
627 {K_F9, "\316C"}, | |
628 {K_F10, "\316D"}, | |
629 {K_F11, "\316\205"}, | |
630 {K_F12, "\316\206"}, | |
631 {K_S_F1, "\316T"}, | |
632 {K_S_F2, "\316U"}, | |
633 {K_S_F3, "\316V"}, | |
634 {K_S_F4, "\316W"}, | |
635 {K_S_F5, "\316X"}, | |
636 {K_S_F6, "\316Y"}, | |
637 {K_S_F7, "\316Z"}, | |
638 {K_S_F8, "\316["}, | |
639 {K_S_F9, "\316\\"}, | |
640 {K_S_F10, "\316]"}, | |
641 {K_S_F11, "\316\207"}, | |
642 {K_S_F12, "\316\210"}, | |
643 {K_INS, "\316R"}, | |
644 {K_DEL, "\316S"}, | |
645 {K_HOME, "\316G"}, | |
646 {K_S_HOME, "\316\302"}, | |
647 {K_C_HOME, "\316w"}, | |
648 {K_END, "\316O"}, | |
649 {K_S_END, "\316\315"}, | |
650 {K_C_END, "\316u"}, | |
651 {K_PAGEDOWN, "\316Q"}, | |
652 {K_PAGEUP, "\316I"}, | |
653 {K_KPLUS, "\316N"}, | |
654 {K_KMINUS, "\316J"}, | |
655 {K_KMULTIPLY, "\316\067"}, | |
656 {K_K0, "\316\332"}, | |
657 {K_K1, "\316\336"}, | |
658 {K_K2, "\316\342"}, | |
659 {K_K3, "\316\346"}, | |
660 {K_K4, "\316\352"}, | |
661 {K_K5, "\316\356"}, | |
662 {K_K6, "\316\362"}, | |
663 {K_K7, "\316\366"}, | |
664 {K_K8, "\316\372"}, | |
665 {K_K9, "\316\376"}, | |
666 # endif | |
667 | |
668 # if defined(VMS) || defined(ALL_BUILTIN_TCAPS) | |
669 /* | |
670 * VT320 is working as an ANSI terminal compatible DEC terminal. | |
671 * (it covers VT1x0, VT2x0 and VT3x0 up to VT320 on VMS as well) | |
672 * TODO:- rewrite ESC[ codes to CSI | |
673 * - keyboard languages (CSI ? 26 n) | |
674 */ | |
675 {(int)KS_NAME, "vt320"}, | |
676 {(int)KS_CE, IF_EB("\033[K", ESC_STR "[K")}, | |
677 {(int)KS_AL, IF_EB("\033[L", ESC_STR "[L")}, | |
678 # ifdef TERMINFO | |
679 {(int)KS_CAL, IF_EB("\033[%p1%dL", ESC_STR "[%p1%dL")}, | |
680 # else | |
681 {(int)KS_CAL, IF_EB("\033[%dL", ESC_STR "[%dL")}, | |
682 # endif | |
683 {(int)KS_DL, IF_EB("\033[M", ESC_STR "[M")}, | |
684 # ifdef TERMINFO | |
685 {(int)KS_CDL, IF_EB("\033[%p1%dM", ESC_STR "[%p1%dM")}, | |
686 # else | |
687 {(int)KS_CDL, IF_EB("\033[%dM", ESC_STR "[%dM")}, | |
688 # endif | |
689 {(int)KS_CL, IF_EB("\033[H\033[2J", ESC_STR "[H" ESC_STR_nc "[2J")}, | |
22 | 690 {(int)KS_CD, IF_EB("\033[J", ESC_STR "[J")}, |
691 {(int)KS_CCO, "8"}, /* allow 8 colors */ | |
7 | 692 {(int)KS_ME, IF_EB("\033[0m", ESC_STR "[0m")}, |
693 {(int)KS_MR, IF_EB("\033[7m", ESC_STR "[7m")}, | |
344 | 694 {(int)KS_MD, IF_EB("\033[1m", ESC_STR "[1m")}, /* bold mode */ |
695 {(int)KS_SE, IF_EB("\033[22m", ESC_STR "[22m")},/* normal mode */ | |
696 {(int)KS_UE, IF_EB("\033[24m", ESC_STR "[24m")},/* exit underscore mode */ | |
697 {(int)KS_US, IF_EB("\033[4m", ESC_STR "[4m")}, /* underscore mode */ | |
698 {(int)KS_CZH, IF_EB("\033[34;43m", ESC_STR "[34;43m")}, /* italic mode: blue text on yellow */ | |
699 {(int)KS_CZR, IF_EB("\033[0m", ESC_STR "[0m")}, /* italic mode end */ | |
700 {(int)KS_CAB, IF_EB("\033[4%dm", ESC_STR "[4%dm")}, /* set background color (ANSI) */ | |
701 {(int)KS_CAF, IF_EB("\033[3%dm", ESC_STR "[3%dm")}, /* set foreground color (ANSI) */ | |
702 {(int)KS_CSB, IF_EB("\033[102;%dm", ESC_STR "[102;%dm")}, /* set screen background color */ | |
703 {(int)KS_CSF, IF_EB("\033[101;%dm", ESC_STR "[101;%dm")}, /* set screen foreground color */ | |
7 | 704 {(int)KS_MS, "y"}, |
705 {(int)KS_UT, "y"}, | |
6602 | 706 {(int)KS_XN, "y"}, |
7 | 707 {(int)KS_LE, "\b"}, |
708 # ifdef TERMINFO | |
709 {(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", | |
710 ESC_STR "[%i%p1%d;%p2%dH")}, | |
711 # else | |
712 {(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")}, | |
713 # endif | |
714 # ifdef TERMINFO | |
715 {(int)KS_CRI, IF_EB("\033[%p1%dC", ESC_STR "[%p1%dC")}, | |
716 # else | |
717 {(int)KS_CRI, IF_EB("\033[%dC", ESC_STR "[%dC")}, | |
718 # endif | |
719 {K_UP, IF_EB("\033[A", ESC_STR "[A")}, | |
720 {K_DOWN, IF_EB("\033[B", ESC_STR "[B")}, | |
721 {K_RIGHT, IF_EB("\033[C", ESC_STR "[C")}, | |
722 {K_LEFT, IF_EB("\033[D", ESC_STR "[D")}, | |
14252
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
723 // Note: cursor key sequences for application cursor mode are omitted, |
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
724 // because they interfere with typed commands: <Esc>OA. |
344 | 725 {K_F1, IF_EB("\033[11~", ESC_STR "[11~")}, |
726 {K_F2, IF_EB("\033[12~", ESC_STR "[12~")}, | |
727 {K_F3, IF_EB("\033[13~", ESC_STR "[13~")}, | |
728 {K_F4, IF_EB("\033[14~", ESC_STR "[14~")}, | |
729 {K_F5, IF_EB("\033[15~", ESC_STR "[15~")}, | |
7 | 730 {K_F6, IF_EB("\033[17~", ESC_STR "[17~")}, |
731 {K_F7, IF_EB("\033[18~", ESC_STR "[18~")}, | |
732 {K_F8, IF_EB("\033[19~", ESC_STR "[19~")}, | |
733 {K_F9, IF_EB("\033[20~", ESC_STR "[20~")}, | |
734 {K_F10, IF_EB("\033[21~", ESC_STR "[21~")}, | |
344 | 735 {K_F11, IF_EB("\033[23~", ESC_STR "[23~")}, |
7 | 736 {K_F12, IF_EB("\033[24~", ESC_STR "[24~")}, |
737 {K_F13, IF_EB("\033[25~", ESC_STR "[25~")}, | |
738 {K_F14, IF_EB("\033[26~", ESC_STR "[26~")}, | |
739 {K_F15, IF_EB("\033[28~", ESC_STR "[28~")}, /* Help */ | |
740 {K_F16, IF_EB("\033[29~", ESC_STR "[29~")}, /* Select */ | |
741 {K_F17, IF_EB("\033[31~", ESC_STR "[31~")}, | |
742 {K_F18, IF_EB("\033[32~", ESC_STR "[32~")}, | |
743 {K_F19, IF_EB("\033[33~", ESC_STR "[33~")}, | |
744 {K_F20, IF_EB("\033[34~", ESC_STR "[34~")}, | |
745 {K_INS, IF_EB("\033[2~", ESC_STR "[2~")}, | |
746 {K_DEL, IF_EB("\033[3~", ESC_STR "[3~")}, | |
747 {K_HOME, IF_EB("\033[1~", ESC_STR "[1~")}, | |
748 {K_END, IF_EB("\033[4~", ESC_STR "[4~")}, | |
749 {K_PAGEUP, IF_EB("\033[5~", ESC_STR "[5~")}, | |
750 {K_PAGEDOWN, IF_EB("\033[6~", ESC_STR "[6~")}, | |
14252
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
751 // These sequences starting with <Esc> O may interfere with what the user |
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
752 // is typing. Remove these if that bothers you. |
7 | 753 {K_KPLUS, IF_EB("\033Ok", ESC_STR "Ok")}, /* keypad plus */ |
754 {K_KMINUS, IF_EB("\033Om", ESC_STR "Om")}, /* keypad minus */ | |
755 {K_KDIVIDE, IF_EB("\033Oo", ESC_STR "Oo")}, /* keypad / */ | |
756 {K_KMULTIPLY, IF_EB("\033Oj", ESC_STR "Oj")}, /* keypad * */ | |
757 {K_KENTER, IF_EB("\033OM", ESC_STR "OM")}, /* keypad Enter */ | |
14252
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
758 {K_K0, IF_EB("\033Op", ESC_STR "Op")}, /* keypad 0 */ |
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
759 {K_K1, IF_EB("\033Oq", ESC_STR "Oq")}, /* keypad 1 */ |
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
760 {K_K2, IF_EB("\033Or", ESC_STR "Or")}, /* keypad 2 */ |
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
761 {K_K3, IF_EB("\033Os", ESC_STR "Os")}, /* keypad 3 */ |
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
762 {K_K4, IF_EB("\033Ot", ESC_STR "Ot")}, /* keypad 4 */ |
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
763 {K_K5, IF_EB("\033Ou", ESC_STR "Ou")}, /* keypad 5 */ |
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
764 {K_K6, IF_EB("\033Ov", ESC_STR "Ov")}, /* keypad 6 */ |
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
765 {K_K7, IF_EB("\033Ow", ESC_STR "Ow")}, /* keypad 7 */ |
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
766 {K_K8, IF_EB("\033Ox", ESC_STR "Ox")}, /* keypad 8 */ |
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
767 {K_K9, IF_EB("\033Oy", ESC_STR "Oy")}, /* keypad 9 */ |
7 | 768 {K_BS, "\x7f"}, /* for some reason 0177 doesn't work */ |
769 # endif | |
770 | |
771 # if defined(ALL_BUILTIN_TCAPS) || defined(__MINT__) | |
772 /* | |
773 * Ordinary vt52 | |
774 */ | |
775 {(int)KS_NAME, "vt52"}, | |
776 {(int)KS_CE, IF_EB("\033K", ESC_STR "K")}, | |
777 {(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
|
778 # ifdef TERMINFO |
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
779 {(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
|
780 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
|
781 # else |
7 | 782 {(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
|
783 # endif |
7 | 784 {(int)KS_LE, "\b"}, |
7264
b1b86aa171cd
commit https://github.com/vim/vim/commit/2a1b474fd82aff922f18570593972b12feaa2073
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
785 {(int)KS_SR, IF_EB("\033I", ESC_STR "I")}, |
7 | 786 {(int)KS_AL, IF_EB("\033L", ESC_STR "L")}, |
787 {(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
|
788 {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
|
789 {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
|
790 {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
|
791 {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
|
792 {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
|
793 {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
|
794 {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
|
795 # ifdef __MINT__ |
7 | 796 {(int)KS_CL, IF_EB("\033E", ESC_STR "E")}, |
797 {(int)KS_VE, IF_EB("\033e", ESC_STR "e")}, | |
798 {(int)KS_VI, IF_EB("\033f", ESC_STR "f")}, | |
799 {(int)KS_SO, IF_EB("\033p", ESC_STR "p")}, | |
800 {(int)KS_SE, IF_EB("\033q", ESC_STR "q")}, | |
801 {K_S_UP, IF_EB("\033a", ESC_STR "a")}, | |
802 {K_S_DOWN, IF_EB("\033b", ESC_STR "b")}, | |
803 {K_S_LEFT, IF_EB("\033d", ESC_STR "d")}, | |
804 {K_S_RIGHT, IF_EB("\033c", ESC_STR "c")}, | |
805 {K_F4, IF_EB("\033S", ESC_STR "S")}, | |
806 {K_F5, IF_EB("\033T", ESC_STR "T")}, | |
807 {K_F6, IF_EB("\033U", ESC_STR "U")}, | |
808 {K_F7, IF_EB("\033V", ESC_STR "V")}, | |
809 {K_F8, IF_EB("\033W", ESC_STR "W")}, | |
810 {K_F9, IF_EB("\033X", ESC_STR "X")}, | |
811 {K_F10, IF_EB("\033Y", ESC_STR "Y")}, | |
812 {K_S_F1, IF_EB("\033p", ESC_STR "p")}, | |
813 {K_S_F2, IF_EB("\033q", ESC_STR "q")}, | |
814 {K_S_F3, IF_EB("\033r", ESC_STR "r")}, | |
815 {K_S_F4, IF_EB("\033s", ESC_STR "s")}, | |
816 {K_S_F5, IF_EB("\033t", ESC_STR "t")}, | |
817 {K_S_F6, IF_EB("\033u", ESC_STR "u")}, | |
818 {K_S_F7, IF_EB("\033v", ESC_STR "v")}, | |
819 {K_S_F8, IF_EB("\033w", ESC_STR "w")}, | |
820 {K_S_F9, IF_EB("\033x", ESC_STR "x")}, | |
821 {K_S_F10, IF_EB("\033y", ESC_STR "y")}, | |
822 {K_INS, IF_EB("\033I", ESC_STR "I")}, | |
823 {K_HOME, IF_EB("\033E", ESC_STR "E")}, | |
824 {K_PAGEDOWN, IF_EB("\033b", ESC_STR "b")}, | |
825 {K_PAGEUP, IF_EB("\033a", ESC_STR "a")}, | |
826 # else | |
827 {(int)KS_CL, IF_EB("\033H\033J", ESC_STR "H" ESC_STR_nc "J")}, | |
828 {(int)KS_MS, "y"}, | |
829 # endif | |
830 # endif | |
831 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
832 # 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
|
833 {(int)KS_NAME, "xterm"}, |
7 | 834 {(int)KS_CE, IF_EB("\033[K", ESC_STR "[K")}, |
835 {(int)KS_AL, IF_EB("\033[L", ESC_STR "[L")}, | |
836 # ifdef TERMINFO | |
837 {(int)KS_CAL, IF_EB("\033[%p1%dL", ESC_STR "[%p1%dL")}, | |
838 # else | |
839 {(int)KS_CAL, IF_EB("\033[%dL", ESC_STR "[%dL")}, | |
840 # endif | |
841 {(int)KS_DL, IF_EB("\033[M", ESC_STR "[M")}, | |
842 # ifdef TERMINFO | |
843 {(int)KS_CDL, IF_EB("\033[%p1%dM", ESC_STR "[%p1%dM")}, | |
844 # else | |
845 {(int)KS_CDL, IF_EB("\033[%dM", ESC_STR "[%dM")}, | |
846 # endif | |
847 # ifdef TERMINFO | |
848 {(int)KS_CS, IF_EB("\033[%i%p1%d;%p2%dr", | |
849 ESC_STR "[%i%p1%d;%p2%dr")}, | |
850 # else | |
851 {(int)KS_CS, IF_EB("\033[%i%d;%dr", ESC_STR "[%i%d;%dr")}, | |
852 # endif | |
853 {(int)KS_CL, IF_EB("\033[H\033[2J", ESC_STR "[H" ESC_STR_nc "[2J")}, | |
854 {(int)KS_CD, IF_EB("\033[J", ESC_STR "[J")}, | |
855 {(int)KS_ME, IF_EB("\033[m", ESC_STR "[m")}, | |
856 {(int)KS_MR, IF_EB("\033[7m", ESC_STR "[7m")}, | |
857 {(int)KS_MD, IF_EB("\033[1m", ESC_STR "[1m")}, | |
858 {(int)KS_UE, IF_EB("\033[m", ESC_STR "[m")}, | |
859 {(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
|
860 {(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
|
861 {(int)KS_STS, IF_EB("\033[9m", ESC_STR "[9m")}, |
7 | 862 {(int)KS_MS, "y"}, |
863 {(int)KS_UT, "y"}, | |
864 {(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
|
865 {(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
|
866 {(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
|
867 {(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
|
868 {(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
|
869 # ifdef TERMINFO |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
870 {(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
|
871 # else |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
872 {(int)KS_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
|
873 # endif |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
874 {(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
|
875 {(int)KS_CRS, IF_EB("\033P$q q\033\\", ESC_STR "P$q q" ESC_STR "\\")}, |
7 | 876 # ifdef TERMINFO |
877 {(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", | |
878 ESC_STR "[%i%p1%d;%p2%dH")}, | |
879 # else | |
880 {(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")}, | |
881 # endif | |
882 {(int)KS_SR, IF_EB("\033M", ESC_STR "M")}, | |
883 # ifdef TERMINFO | |
884 {(int)KS_CRI, IF_EB("\033[%p1%dC", ESC_STR "[%p1%dC")}, | |
885 # else | |
886 {(int)KS_CRI, IF_EB("\033[%dC", ESC_STR "[%dC")}, | |
887 # endif | |
888 {(int)KS_KS, IF_EB("\033[?1h\033=", ESC_STR "[?1h" ESC_STR_nc "=")}, | |
889 {(int)KS_KE, IF_EB("\033[?1l\033>", ESC_STR "[?1l" ESC_STR_nc ">")}, | |
890 # ifdef FEAT_XTERM_SAVE | |
891 {(int)KS_TI, IF_EB("\0337\033[?47h", ESC_STR "7" ESC_STR_nc "[?47h")}, | |
892 {(int)KS_TE, IF_EB("\033[2J\033[?47l\0338", | |
893 ESC_STR "[2J" ESC_STR_nc "[?47l" ESC_STR_nc "8")}, | |
894 # endif | |
895 {(int)KS_CIS, IF_EB("\033]1;", ESC_STR "]1;")}, | |
896 {(int)KS_CIE, "\007"}, | |
897 {(int)KS_TS, IF_EB("\033]2;", ESC_STR "]2;")}, | |
898 {(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
|
899 {(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
|
900 {(int)KS_CEC, "\007"}, |
7 | 901 # ifdef TERMINFO |
902 {(int)KS_CWS, IF_EB("\033[8;%p1%d;%p2%dt", | |
903 ESC_STR "[8;%p1%d;%p2%dt")}, | |
904 {(int)KS_CWP, IF_EB("\033[3;%p1%d;%p2%dt", | |
905 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
|
906 {(int)KS_CGP, IF_EB("\033[13t", ESC_STR "[13t")}, |
7 | 907 # else |
908 {(int)KS_CWS, IF_EB("\033[8;%d;%dt", ESC_STR "[8;%d;%dt")}, | |
909 {(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
|
910 {(int)KS_CGP, IF_EB("\033[13t", ESC_STR "[13t")}, |
7 | 911 # endif |
912 {(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
|
913 {(int)KS_RFG, IF_EB("\033]10;?\007", ESC_STR "]10;?\007")}, |
6874 | 914 {(int)KS_RBG, IF_EB("\033]11;?\007", ESC_STR "]11;?\007")}, |
4215 | 915 {(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
|
916 # ifdef FEAT_TERMGUICOLORS |
8985
42eb58c9da92
commit https://github.com/vim/vim/commit/b2fa54a84078e2b8dc3c7c7bfbccf6b75c0788d0
Christian Brabandt <cb@256bit.org>
parents:
8981
diff
changeset
|
917 /* 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
|
918 {(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
|
919 {(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
|
920 # endif |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
921 {(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
|
922 {(int)KS_CBD, IF_EB("\033[?2004l", ESC_STR "[?2004l")}, |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
923 {(int)KS_CST, IF_EB("\033[22;2t", ESC_STR "[22;2t")}, |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
924 {(int)KS_CRT, IF_EB("\033[23;2t", ESC_STR "[23;2t")}, |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
925 {(int)KS_SSI, IF_EB("\033[22;1t", ESC_STR "[22;1t")}, |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
926 {(int)KS_SRI, IF_EB("\033[23;1t", ESC_STR "[23;1t")}, |
180 | 927 |
928 {K_UP, IF_EB("\033O*A", ESC_STR "O*A")}, | |
929 {K_DOWN, IF_EB("\033O*B", ESC_STR "O*B")}, | |
930 {K_RIGHT, IF_EB("\033O*C", ESC_STR "O*C")}, | |
931 {K_LEFT, IF_EB("\033O*D", ESC_STR "O*D")}, | |
932 /* An extra set of cursor keys for vt100 mode */ | |
933 {K_XUP, IF_EB("\033[1;*A", ESC_STR "[1;*A")}, | |
934 {K_XDOWN, IF_EB("\033[1;*B", ESC_STR "[1;*B")}, | |
935 {K_XRIGHT, IF_EB("\033[1;*C", ESC_STR "[1;*C")}, | |
936 {K_XLEFT, IF_EB("\033[1;*D", ESC_STR "[1;*D")}, | |
7 | 937 /* An extra set of function keys for vt100 mode */ |
180 | 938 {K_XF1, IF_EB("\033O*P", ESC_STR "O*P")}, |
939 {K_XF2, IF_EB("\033O*Q", ESC_STR "O*Q")}, | |
940 {K_XF3, IF_EB("\033O*R", ESC_STR "O*R")}, | |
941 {K_XF4, IF_EB("\033O*S", ESC_STR "O*S")}, | |
179 | 942 {K_F1, IF_EB("\033[11;*~", ESC_STR "[11;*~")}, |
943 {K_F2, IF_EB("\033[12;*~", ESC_STR "[12;*~")}, | |
944 {K_F3, IF_EB("\033[13;*~", ESC_STR "[13;*~")}, | |
945 {K_F4, IF_EB("\033[14;*~", ESC_STR "[14;*~")}, | |
946 {K_F5, IF_EB("\033[15;*~", ESC_STR "[15;*~")}, | |
947 {K_F6, IF_EB("\033[17;*~", ESC_STR "[17;*~")}, | |
948 {K_F7, IF_EB("\033[18;*~", ESC_STR "[18;*~")}, | |
949 {K_F8, IF_EB("\033[19;*~", ESC_STR "[19;*~")}, | |
950 {K_F9, IF_EB("\033[20;*~", ESC_STR "[20;*~")}, | |
951 {K_F10, IF_EB("\033[21;*~", ESC_STR "[21;*~")}, | |
952 {K_F11, IF_EB("\033[23;*~", ESC_STR "[23;*~")}, | |
953 {K_F12, IF_EB("\033[24;*~", ESC_STR "[24;*~")}, | |
7 | 954 {K_S_TAB, IF_EB("\033[Z", ESC_STR "[Z")}, |
179 | 955 {K_HELP, IF_EB("\033[28;*~", ESC_STR "[28;*~")}, |
956 {K_UNDO, IF_EB("\033[26;*~", ESC_STR "[26;*~")}, | |
957 {K_INS, IF_EB("\033[2;*~", ESC_STR "[2;*~")}, | |
958 {K_HOME, IF_EB("\033[1;*H", ESC_STR "[1;*H")}, | |
180 | 959 /* {K_S_HOME, IF_EB("\033O2H", ESC_STR "O2H")}, */ |
960 /* {K_C_HOME, IF_EB("\033O5H", ESC_STR "O5H")}, */ | |
230 | 961 {K_KHOME, IF_EB("\033[1;*~", ESC_STR "[1;*~")}, |
180 | 962 {K_XHOME, IF_EB("\033O*H", ESC_STR "O*H")}, /* other Home */ |
230 | 963 {K_ZHOME, IF_EB("\033[7;*~", ESC_STR "[7;*~")}, /* other Home */ |
179 | 964 {K_END, IF_EB("\033[1;*F", ESC_STR "[1;*F")}, |
180 | 965 /* {K_S_END, IF_EB("\033O2F", ESC_STR "O2F")}, */ |
966 /* {K_C_END, IF_EB("\033O5F", ESC_STR "O5F")}, */ | |
179 | 967 {K_KEND, IF_EB("\033[4;*~", ESC_STR "[4;*~")}, |
180 | 968 {K_XEND, IF_EB("\033O*F", ESC_STR "O*F")}, /* other End */ |
230 | 969 {K_ZEND, IF_EB("\033[8;*~", ESC_STR "[8;*~")}, |
179 | 970 {K_PAGEUP, IF_EB("\033[5;*~", ESC_STR "[5;*~")}, |
971 {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
|
972 {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
|
973 {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
|
974 {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
|
975 {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
|
976 {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
|
977 {K_KPOINT, IF_EB("\033O*n", ESC_STR "O*n")}, /* keypad . */ |
14252
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
978 {K_K0, IF_EB("\033O*p", ESC_STR "O*p")}, /* keypad 0 */ |
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
979 {K_K1, IF_EB("\033O*q", ESC_STR "O*q")}, /* keypad 1 */ |
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
980 {K_K2, IF_EB("\033O*r", ESC_STR "O*r")}, /* keypad 2 */ |
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
981 {K_K3, IF_EB("\033O*s", ESC_STR "O*s")}, /* keypad 3 */ |
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
982 {K_K4, IF_EB("\033O*t", ESC_STR "O*t")}, /* keypad 4 */ |
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
983 {K_K5, IF_EB("\033O*u", ESC_STR "O*u")}, /* keypad 5 */ |
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
984 {K_K6, IF_EB("\033O*v", ESC_STR "O*v")}, /* keypad 6 */ |
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
985 {K_K7, IF_EB("\033O*w", ESC_STR "O*w")}, /* keypad 7 */ |
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
986 {K_K8, IF_EB("\033O*x", ESC_STR "O*x")}, /* keypad 8 */ |
b557af8dedab
patch 8.1.0142: xterm and vt320 builtin termcap missing keypad keys
Christian Brabandt <cb@256bit.org>
parents:
14224
diff
changeset
|
987 {K_K9, IF_EB("\033O*y", ESC_STR "O*y")}, /* keypad 9 */ |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
988 {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
|
989 {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
|
990 {K_PE, IF_EB("\033[201~", ESC_STR "[201~")}, /* paste end */ |
7 | 991 |
992 {BT_EXTRA_KEYS, ""}, | |
179 | 993 {TERMCAP2KEY('k', '0'), IF_EB("\033[10;*~", ESC_STR "[10;*~")}, /* F0 */ |
994 {TERMCAP2KEY('F', '3'), IF_EB("\033[25;*~", ESC_STR "[25;*~")}, /* F13 */ | |
995 /* F14 and F15 are missing, because they send the same codes as the undo | |
996 * and help key, although they don't work on all keyboards. */ | |
997 {TERMCAP2KEY('F', '6'), IF_EB("\033[29;*~", ESC_STR "[29;*~")}, /* F16 */ | |
998 {TERMCAP2KEY('F', '7'), IF_EB("\033[31;*~", ESC_STR "[31;*~")}, /* F17 */ | |
999 {TERMCAP2KEY('F', '8'), IF_EB("\033[32;*~", ESC_STR "[32;*~")}, /* F18 */ | |
1000 {TERMCAP2KEY('F', '9'), IF_EB("\033[33;*~", ESC_STR "[33;*~")}, /* F19 */ | |
1001 {TERMCAP2KEY('F', 'A'), IF_EB("\033[34;*~", ESC_STR "[34;*~")}, /* F20 */ | |
1002 | |
1003 {TERMCAP2KEY('F', 'B'), IF_EB("\033[42;*~", ESC_STR "[42;*~")}, /* F21 */ | |
1004 {TERMCAP2KEY('F', 'C'), IF_EB("\033[43;*~", ESC_STR "[43;*~")}, /* F22 */ | |
1005 {TERMCAP2KEY('F', 'D'), IF_EB("\033[44;*~", ESC_STR "[44;*~")}, /* F23 */ | |
1006 {TERMCAP2KEY('F', 'E'), IF_EB("\033[45;*~", ESC_STR "[45;*~")}, /* F24 */ | |
1007 {TERMCAP2KEY('F', 'F'), IF_EB("\033[46;*~", ESC_STR "[46;*~")}, /* F25 */ | |
1008 {TERMCAP2KEY('F', 'G'), IF_EB("\033[47;*~", ESC_STR "[47;*~")}, /* F26 */ | |
1009 {TERMCAP2KEY('F', 'H'), IF_EB("\033[48;*~", ESC_STR "[48;*~")}, /* F27 */ | |
1010 {TERMCAP2KEY('F', 'I'), IF_EB("\033[49;*~", ESC_STR "[49;*~")}, /* F28 */ | |
1011 {TERMCAP2KEY('F', 'J'), IF_EB("\033[50;*~", ESC_STR "[50;*~")}, /* F29 */ | |
1012 {TERMCAP2KEY('F', 'K'), IF_EB("\033[51;*~", ESC_STR "[51;*~")}, /* F30 */ | |
1013 | |
1014 {TERMCAP2KEY('F', 'L'), IF_EB("\033[52;*~", ESC_STR "[52;*~")}, /* F31 */ | |
1015 {TERMCAP2KEY('F', 'M'), IF_EB("\033[53;*~", ESC_STR "[53;*~")}, /* F32 */ | |
1016 {TERMCAP2KEY('F', 'N'), IF_EB("\033[54;*~", ESC_STR "[54;*~")}, /* F33 */ | |
1017 {TERMCAP2KEY('F', 'O'), IF_EB("\033[55;*~", ESC_STR "[55;*~")}, /* F34 */ | |
1018 {TERMCAP2KEY('F', 'P'), IF_EB("\033[56;*~", ESC_STR "[56;*~")}, /* F35 */ | |
1019 {TERMCAP2KEY('F', 'Q'), IF_EB("\033[57;*~", ESC_STR "[57;*~")}, /* F36 */ | |
1020 {TERMCAP2KEY('F', 'R'), IF_EB("\033[58;*~", ESC_STR "[58;*~")}, /* F37 */ | |
7 | 1021 # endif |
1022 | |
1023 # if defined(UNIX) || defined(ALL_BUILTIN_TCAPS) | |
1024 /* | |
1025 * iris-ansi for Silicon Graphics machines. | |
1026 */ | |
1027 {(int)KS_NAME, "iris-ansi"}, | |
1028 {(int)KS_CE, "\033[K"}, | |
1029 {(int)KS_CD, "\033[J"}, | |
1030 {(int)KS_AL, "\033[L"}, | |
1031 # ifdef TERMINFO | |
1032 {(int)KS_CAL, "\033[%p1%dL"}, | |
1033 # else | |
1034 {(int)KS_CAL, "\033[%dL"}, | |
1035 # endif | |
1036 {(int)KS_DL, "\033[M"}, | |
1037 # ifdef TERMINFO | |
1038 {(int)KS_CDL, "\033[%p1%dM"}, | |
1039 # else | |
1040 {(int)KS_CDL, "\033[%dM"}, | |
1041 # endif | |
1042 #if 0 /* The scroll region is not working as Vim expects. */ | |
1043 # ifdef TERMINFO | |
1044 {(int)KS_CS, "\033[%i%p1%d;%p2%dr"}, | |
1045 # else | |
1046 {(int)KS_CS, "\033[%i%d;%dr"}, | |
1047 # endif | |
1048 #endif | |
1049 {(int)KS_CL, "\033[H\033[2J"}, | |
1050 {(int)KS_VE, "\033[9/y\033[12/y"}, /* These aren't documented */ | |
1051 {(int)KS_VS, "\033[10/y\033[=1h\033[=2l"}, /* These aren't documented */ | |
1052 {(int)KS_TI, "\033[=6h"}, | |
1053 {(int)KS_TE, "\033[=6l"}, | |
1054 {(int)KS_SE, "\033[21;27m"}, | |
1055 {(int)KS_SO, "\033[1;7m"}, | |
1056 {(int)KS_ME, "\033[m"}, | |
1057 {(int)KS_MR, "\033[7m"}, | |
1058 {(int)KS_MD, "\033[1m"}, | |
1059 {(int)KS_CCO, "8"}, /* allow 8 colors */ | |
1060 {(int)KS_CZH, "\033[3m"}, /* italic mode on */ | |
1061 {(int)KS_CZR, "\033[23m"}, /* italic mode off */ | |
1062 {(int)KS_US, "\033[4m"}, /* underline on */ | |
1063 {(int)KS_UE, "\033[24m"}, /* underline off */ | |
1064 # ifdef TERMINFO | |
1065 {(int)KS_CAB, "\033[4%p1%dm"}, /* set background color (ANSI) */ | |
1066 {(int)KS_CAF, "\033[3%p1%dm"}, /* set foreground color (ANSI) */ | |
1067 {(int)KS_CSB, "\033[102;%p1%dm"}, /* set screen background color */ | |
1068 {(int)KS_CSF, "\033[101;%p1%dm"}, /* set screen foreground color */ | |
1069 # else | |
1070 {(int)KS_CAB, "\033[4%dm"}, /* set background color (ANSI) */ | |
1071 {(int)KS_CAF, "\033[3%dm"}, /* set foreground color (ANSI) */ | |
1072 {(int)KS_CSB, "\033[102;%dm"}, /* set screen background color */ | |
1073 {(int)KS_CSF, "\033[101;%dm"}, /* set screen foreground color */ | |
1074 # endif | |
1075 {(int)KS_MS, "y"}, /* guessed */ | |
1076 {(int)KS_UT, "y"}, /* guessed */ | |
1077 {(int)KS_LE, "\b"}, | |
1078 # ifdef TERMINFO | |
1079 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, | |
1080 # else | |
1081 {(int)KS_CM, "\033[%i%d;%dH"}, | |
1082 # endif | |
1083 {(int)KS_SR, "\033M"}, | |
1084 # ifdef TERMINFO | |
1085 {(int)KS_CRI, "\033[%p1%dC"}, | |
1086 # else | |
1087 {(int)KS_CRI, "\033[%dC"}, | |
1088 # endif | |
1089 {(int)KS_CIS, "\033P3.y"}, | |
1090 {(int)KS_CIE, "\234"}, /* ST "String Terminator" */ | |
1091 {(int)KS_TS, "\033P1.y"}, | |
1092 {(int)KS_FS, "\234"}, /* ST "String Terminator" */ | |
1093 # ifdef TERMINFO | |
1094 {(int)KS_CWS, "\033[203;%p1%d;%p2%d/y"}, | |
1095 {(int)KS_CWP, "\033[205;%p1%d;%p2%d/y"}, | |
1096 # else | |
1097 {(int)KS_CWS, "\033[203;%d;%d/y"}, | |
1098 {(int)KS_CWP, "\033[205;%d;%d/y"}, | |
1099 # endif | |
1100 {K_UP, "\033[A"}, | |
1101 {K_DOWN, "\033[B"}, | |
1102 {K_LEFT, "\033[D"}, | |
1103 {K_RIGHT, "\033[C"}, | |
1104 {K_S_UP, "\033[161q"}, | |
1105 {K_S_DOWN, "\033[164q"}, | |
1106 {K_S_LEFT, "\033[158q"}, | |
1107 {K_S_RIGHT, "\033[167q"}, | |
1108 {K_F1, "\033[001q"}, | |
1109 {K_F2, "\033[002q"}, | |
1110 {K_F3, "\033[003q"}, | |
1111 {K_F4, "\033[004q"}, | |
1112 {K_F5, "\033[005q"}, | |
1113 {K_F6, "\033[006q"}, | |
1114 {K_F7, "\033[007q"}, | |
1115 {K_F8, "\033[008q"}, | |
1116 {K_F9, "\033[009q"}, | |
1117 {K_F10, "\033[010q"}, | |
1118 {K_F11, "\033[011q"}, | |
1119 {K_F12, "\033[012q"}, | |
1120 {K_S_F1, "\033[013q"}, | |
1121 {K_S_F2, "\033[014q"}, | |
1122 {K_S_F3, "\033[015q"}, | |
1123 {K_S_F4, "\033[016q"}, | |
1124 {K_S_F5, "\033[017q"}, | |
1125 {K_S_F6, "\033[018q"}, | |
1126 {K_S_F7, "\033[019q"}, | |
1127 {K_S_F8, "\033[020q"}, | |
1128 {K_S_F9, "\033[021q"}, | |
1129 {K_S_F10, "\033[022q"}, | |
1130 {K_S_F11, "\033[023q"}, | |
1131 {K_S_F12, "\033[024q"}, | |
1132 {K_INS, "\033[139q"}, | |
1133 {K_HOME, "\033[H"}, | |
1134 {K_END, "\033[146q"}, | |
1135 {K_PAGEUP, "\033[150q"}, | |
1136 {K_PAGEDOWN, "\033[154q"}, | |
1137 # endif | |
1138 | |
1139 # if defined(DEBUG) || defined(ALL_BUILTIN_TCAPS) | |
1140 /* | |
1141 * for debugging | |
1142 */ | |
1143 {(int)KS_NAME, "debug"}, | |
1144 {(int)KS_CE, "[CE]"}, | |
1145 {(int)KS_CD, "[CD]"}, | |
1146 {(int)KS_AL, "[AL]"}, | |
1147 # ifdef TERMINFO | |
1148 {(int)KS_CAL, "[CAL%p1%d]"}, | |
1149 # else | |
1150 {(int)KS_CAL, "[CAL%d]"}, | |
1151 # endif | |
1152 {(int)KS_DL, "[DL]"}, | |
1153 # ifdef TERMINFO | |
1154 {(int)KS_CDL, "[CDL%p1%d]"}, | |
1155 # else | |
1156 {(int)KS_CDL, "[CDL%d]"}, | |
1157 # endif | |
1158 # ifdef TERMINFO | |
1159 {(int)KS_CS, "[%p1%dCS%p2%d]"}, | |
1160 # else | |
1161 {(int)KS_CS, "[%dCS%d]"}, | |
1162 # endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12429
diff
changeset
|
1163 # ifdef TERMINFO |
7 | 1164 {(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
|
1165 # else |
7 | 1166 {(int)KS_CSV, "[%dCSV%d]"}, |
1167 # endif | |
1168 # ifdef TERMINFO | |
1169 {(int)KS_CAB, "[CAB%p1%d]"}, | |
1170 {(int)KS_CAF, "[CAF%p1%d]"}, | |
1171 {(int)KS_CSB, "[CSB%p1%d]"}, | |
1172 {(int)KS_CSF, "[CSF%p1%d]"}, | |
1173 # else | |
1174 {(int)KS_CAB, "[CAB%d]"}, | |
1175 {(int)KS_CAF, "[CAF%d]"}, | |
1176 {(int)KS_CSB, "[CSB%d]"}, | |
1177 {(int)KS_CSF, "[CSF%d]"}, | |
1178 # endif | |
1179 {(int)KS_OP, "[OP]"}, | |
1180 {(int)KS_LE, "[LE]"}, | |
1181 {(int)KS_CL, "[CL]"}, | |
1182 {(int)KS_VI, "[VI]"}, | |
1183 {(int)KS_VE, "[VE]"}, | |
1184 {(int)KS_VS, "[VS]"}, | |
1185 {(int)KS_ME, "[ME]"}, | |
1186 {(int)KS_MR, "[MR]"}, | |
1187 {(int)KS_MB, "[MB]"}, | |
1188 {(int)KS_MD, "[MD]"}, | |
1189 {(int)KS_SE, "[SE]"}, | |
1190 {(int)KS_SO, "[SO]"}, | |
1191 {(int)KS_UE, "[UE]"}, | |
1192 {(int)KS_US, "[US]"}, | |
205 | 1193 {(int)KS_UCE, "[UCE]"}, |
1194 {(int)KS_UCS, "[UCS]"}, | |
12317
2a8890b80923
patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents:
12307
diff
changeset
|
1195 {(int)KS_STE, "[STE]"}, |
2a8890b80923
patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents:
12307
diff
changeset
|
1196 {(int)KS_STS, "[STS]"}, |
7 | 1197 {(int)KS_MS, "[MS]"}, |
1198 {(int)KS_UT, "[UT]"}, | |
6602 | 1199 {(int)KS_XN, "[XN]"}, |
7 | 1200 # ifdef TERMINFO |
1201 {(int)KS_CM, "[%p1%dCM%p2%d]"}, | |
1202 # else | |
1203 {(int)KS_CM, "[%dCM%d]"}, | |
1204 # endif | |
1205 {(int)KS_SR, "[SR]"}, | |
1206 # ifdef TERMINFO | |
1207 {(int)KS_CRI, "[CRI%p1%d]"}, | |
1208 # else | |
1209 {(int)KS_CRI, "[CRI%d]"}, | |
1210 # endif | |
1211 {(int)KS_VB, "[VB]"}, | |
1212 {(int)KS_KS, "[KS]"}, | |
1213 {(int)KS_KE, "[KE]"}, | |
1214 {(int)KS_TI, "[TI]"}, | |
1215 {(int)KS_TE, "[TE]"}, | |
1216 {(int)KS_CIS, "[CIS]"}, | |
1217 {(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
|
1218 {(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
|
1219 {(int)KS_CEC, "[CEC]"}, |
7 | 1220 {(int)KS_TS, "[TS]"}, |
1221 {(int)KS_FS, "[FS]"}, | |
1222 # ifdef TERMINFO | |
1223 {(int)KS_CWS, "[%p1%dCWS%p2%d]"}, | |
1224 {(int)KS_CWP, "[%p1%dCWP%p2%d]"}, | |
1225 # else | |
1226 {(int)KS_CWS, "[%dCWS%d]"}, | |
1227 {(int)KS_CWP, "[%dCWP%d]"}, | |
1228 # endif | |
1229 {(int)KS_CRV, "[CRV]"}, | |
4215 | 1230 {(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
|
1231 {(int)KS_RFG, "[RFG]"}, |
6874 | 1232 {(int)KS_RBG, "[RBG]"}, |
7 | 1233 {K_UP, "[KU]"}, |
1234 {K_DOWN, "[KD]"}, | |
1235 {K_LEFT, "[KL]"}, | |
1236 {K_RIGHT, "[KR]"}, | |
180 | 1237 {K_XUP, "[xKU]"}, |
1238 {K_XDOWN, "[xKD]"}, | |
1239 {K_XLEFT, "[xKL]"}, | |
1240 {K_XRIGHT, "[xKR]"}, | |
7 | 1241 {K_S_UP, "[S-KU]"}, |
1242 {K_S_DOWN, "[S-KD]"}, | |
1243 {K_S_LEFT, "[S-KL]"}, | |
1244 {K_C_LEFT, "[C-KL]"}, | |
1245 {K_S_RIGHT, "[S-KR]"}, | |
1246 {K_C_RIGHT, "[C-KR]"}, | |
1247 {K_F1, "[F1]"}, | |
1248 {K_XF1, "[xF1]"}, | |
1249 {K_F2, "[F2]"}, | |
1250 {K_XF2, "[xF2]"}, | |
1251 {K_F3, "[F3]"}, | |
1252 {K_XF3, "[xF3]"}, | |
1253 {K_F4, "[F4]"}, | |
1254 {K_XF4, "[xF4]"}, | |
1255 {K_F5, "[F5]"}, | |
1256 {K_F6, "[F6]"}, | |
1257 {K_F7, "[F7]"}, | |
1258 {K_F8, "[F8]"}, | |
1259 {K_F9, "[F9]"}, | |
1260 {K_F10, "[F10]"}, | |
1261 {K_F11, "[F11]"}, | |
1262 {K_F12, "[F12]"}, | |
1263 {K_S_F1, "[S-F1]"}, | |
1264 {K_S_XF1, "[S-xF1]"}, | |
1265 {K_S_F2, "[S-F2]"}, | |
1266 {K_S_XF2, "[S-xF2]"}, | |
1267 {K_S_F3, "[S-F3]"}, | |
1268 {K_S_XF3, "[S-xF3]"}, | |
1269 {K_S_F4, "[S-F4]"}, | |
1270 {K_S_XF4, "[S-xF4]"}, | |
1271 {K_S_F5, "[S-F5]"}, | |
1272 {K_S_F6, "[S-F6]"}, | |
1273 {K_S_F7, "[S-F7]"}, | |
1274 {K_S_F8, "[S-F8]"}, | |
1275 {K_S_F9, "[S-F9]"}, | |
1276 {K_S_F10, "[S-F10]"}, | |
1277 {K_S_F11, "[S-F11]"}, | |
1278 {K_S_F12, "[S-F12]"}, | |
1279 {K_HELP, "[HELP]"}, | |
1280 {K_UNDO, "[UNDO]"}, | |
1281 {K_BS, "[BS]"}, | |
1282 {K_INS, "[INS]"}, | |
1283 {K_KINS, "[KINS]"}, | |
1284 {K_DEL, "[DEL]"}, | |
1285 {K_KDEL, "[KDEL]"}, | |
1286 {K_HOME, "[HOME]"}, | |
1287 {K_S_HOME, "[C-HOME]"}, | |
1288 {K_C_HOME, "[C-HOME]"}, | |
1289 {K_KHOME, "[KHOME]"}, | |
1290 {K_XHOME, "[XHOME]"}, | |
230 | 1291 {K_ZHOME, "[ZHOME]"}, |
7 | 1292 {K_END, "[END]"}, |
1293 {K_S_END, "[C-END]"}, | |
1294 {K_C_END, "[C-END]"}, | |
1295 {K_KEND, "[KEND]"}, | |
1296 {K_XEND, "[XEND]"}, | |
230 | 1297 {K_ZEND, "[ZEND]"}, |
7 | 1298 {K_PAGEUP, "[PAGEUP]"}, |
1299 {K_PAGEDOWN, "[PAGEDOWN]"}, | |
1300 {K_KPAGEUP, "[KPAGEUP]"}, | |
1301 {K_KPAGEDOWN, "[KPAGEDOWN]"}, | |
1302 {K_MOUSE, "[MOUSE]"}, | |
1303 {K_KPLUS, "[KPLUS]"}, | |
1304 {K_KMINUS, "[KMINUS]"}, | |
1305 {K_KDIVIDE, "[KDIVIDE]"}, | |
1306 {K_KMULTIPLY, "[KMULTIPLY]"}, | |
1307 {K_KENTER, "[KENTER]"}, | |
1308 {K_KPOINT, "[KPOINT]"}, | |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
1309 {K_PS, "[PASTE-START]"}, |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10512
diff
changeset
|
1310 {K_PE, "[PASTE-END]"}, |
7 | 1311 {K_K0, "[K0]"}, |
1312 {K_K1, "[K1]"}, | |
1313 {K_K2, "[K2]"}, | |
1314 {K_K3, "[K3]"}, | |
1315 {K_K4, "[K4]"}, | |
1316 {K_K5, "[K5]"}, | |
1317 {K_K6, "[K6]"}, | |
1318 {K_K7, "[K7]"}, | |
1319 {K_K8, "[K8]"}, | |
1320 {K_K9, "[K9]"}, | |
1321 # endif | |
1322 | |
1323 #endif /* NO_BUILTIN_TCAPS */ | |
1324 | |
1325 /* | |
1326 * The most minimal terminal: only clear screen and cursor positioning | |
1327 * Always included. | |
1328 */ | |
1329 {(int)KS_NAME, "dumb"}, | |
1330 {(int)KS_CL, "\014"}, | |
1331 #ifdef TERMINFO | |
1332 {(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", | |
1333 ESC_STR "[%i%p1%d;%p2%dH")}, | |
1334 #else | |
1335 {(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")}, | |
1336 #endif | |
1337 | |
1338 /* | |
1339 * end marker | |
1340 */ | |
1341 {(int)KS_NAME, NULL} | |
1342 | |
1343 }; /* end of builtin_termcaps */ | |
1344 | |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1345 #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
|
1346 guicolor_T |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1347 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
|
1348 { |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
1349 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
|
1350 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1351 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1352 guicolor_T |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1353 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
|
1354 { |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1355 guicolor_T t; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1356 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1357 if (*name == NUL) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1358 return INVALCOLOR; |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1359 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
|
1360 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1361 if (t == INVALCOLOR) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
1362 semsg(_("E254: Cannot allocate color %s"), name); |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1363 return t; |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1364 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1365 |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
1366 guicolor_T |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
1367 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
|
1368 { |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
1369 return color; |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1370 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1371 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1372 |
7 | 1373 /* |
1374 * DEFAULT_TERM is used, when no terminal is specified with -T option or $TERM. | |
1375 */ | |
1376 #ifdef AMIGA | |
1377 # define DEFAULT_TERM (char_u *)"amiga" | |
1378 #endif | |
1379 | |
1380 #ifdef MSWIN | |
1381 # define DEFAULT_TERM (char_u *)"win32" | |
1382 #endif | |
1383 | |
1384 #if defined(UNIX) && !defined(__MINT__) | |
1385 # define DEFAULT_TERM (char_u *)"ansi" | |
1386 #endif | |
1387 | |
1388 #ifdef __MINT__ | |
1389 # define DEFAULT_TERM (char_u *)"vt52" | |
1390 #endif | |
1391 | |
1392 #ifdef VMS | |
1393 # define DEFAULT_TERM (char_u *)"vt320" | |
1394 #endif | |
1395 | |
1396 #ifdef __BEOS__ | |
1397 # undef DEFAULT_TERM | |
1398 # define DEFAULT_TERM (char_u *)"beos-ansi" | |
1399 #endif | |
1400 | |
1401 #ifndef DEFAULT_TERM | |
1402 # define DEFAULT_TERM (char_u *)"dumb" | |
1403 #endif | |
1404 | |
1405 /* | |
1406 * Term_strings contains currently used terminal output strings. | |
1407 * It is initialized with the default values by parse_builtin_tcap(). | |
1408 * The values can be changed by setting the option with the same name. | |
1409 */ | |
1410 char_u *(term_strings[(int)KS_LAST + 1]); | |
1411 | |
1221 | 1412 static int need_gather = FALSE; /* need to fill termleader[] */ |
1413 static char_u termleader[256 + 1]; /* for check_termcode() */ | |
7 | 1414 #ifdef FEAT_TERMRESPONSE |
1221 | 1415 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
|
1416 static int is_not_xterm = FALSE; /* recognized not-really-xterm */ |
7 | 1417 #endif |
1418 | |
1419 static struct builtin_term * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1420 find_builtin_term(char_u *term) |
7 | 1421 { |
1422 struct builtin_term *p; | |
1423 | |
1424 p = builtin_termcaps; | |
1425 while (p->bt_string != NULL) | |
1426 { | |
1427 if (p->bt_entry == (int)KS_NAME) | |
1428 { | |
1429 #ifdef UNIX | |
1430 if (STRCMP(p->bt_string, "iris-ansi") == 0 && vim_is_iris(term)) | |
1431 return p; | |
1432 else if (STRCMP(p->bt_string, "xterm") == 0 && vim_is_xterm(term)) | |
1433 return p; | |
1434 else | |
1435 #endif | |
1436 #ifdef VMS | |
1437 if (STRCMP(p->bt_string, "vt320") == 0 && vim_is_vt300(term)) | |
1438 return p; | |
1439 else | |
1440 #endif | |
1441 if (STRCMP(term, p->bt_string) == 0) | |
1442 return p; | |
1443 } | |
1444 ++p; | |
1445 } | |
1446 return p; | |
1447 } | |
1448 | |
1449 /* | |
1450 * Parsing of the builtin termcap entries. | |
1451 * Caller should check if 'name' is a valid builtin term. | |
1452 * The terminal's name is not set, as this is already done in termcapinit(). | |
1453 */ | |
1454 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1455 parse_builtin_tcap(char_u *term) |
7 | 1456 { |
1457 struct builtin_term *p; | |
1458 char_u name[2]; | |
1459 int term_8bit; | |
1460 | |
1461 p = find_builtin_term(term); | |
1462 term_8bit = term_is_8bit(term); | |
1463 | |
1464 /* Do not parse if builtin term not found */ | |
1465 if (p->bt_string == NULL) | |
1466 return; | |
1467 | |
1468 for (++p; p->bt_entry != (int)KS_NAME && p->bt_entry != BT_EXTRA_KEYS; ++p) | |
1469 { | |
1470 if ((int)p->bt_entry >= 0) /* KS_xx entry */ | |
1471 { | |
1472 /* Only set the value if it wasn't set yet. */ | |
1473 if (term_strings[p->bt_entry] == NULL | |
1474 || term_strings[p->bt_entry] == empty_option) | |
1475 { | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1476 #ifdef FEAT_EVAL |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1477 int opt_idx = -1; |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1478 #endif |
7 | 1479 /* 8bit terminal: use CSI instead of <Esc>[ */ |
1480 if (term_8bit && term_7to8bit((char_u *)p->bt_string) != 0) | |
1481 { | |
1482 char_u *s, *t; | |
1483 | |
1484 s = vim_strsave((char_u *)p->bt_string); | |
1485 if (s != NULL) | |
1486 { | |
1487 for (t = s; *t; ++t) | |
1488 if (term_7to8bit(t)) | |
1489 { | |
1490 *t = term_7to8bit(t); | |
14321
6bcac243b9de
patch 8.1.0176: overlapping string argument for strcpy()
Christian Brabandt <cb@256bit.org>
parents:
14282
diff
changeset
|
1491 STRMOVE(t + 1, t + 2); |
7 | 1492 } |
1493 term_strings[p->bt_entry] = s; | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1494 #ifdef FEAT_EVAL |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1495 opt_idx = |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1496 #endif |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1497 set_term_option_alloced( |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1498 &term_strings[p->bt_entry]); |
7 | 1499 } |
1500 } | |
1501 else | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1502 { |
7 | 1503 term_strings[p->bt_entry] = (char_u *)p->bt_string; |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1504 #ifdef FEAT_EVAL |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1505 opt_idx = get_term_opt_idx(&term_strings[p->bt_entry]); |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1506 #endif |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1507 } |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1508 #ifdef FEAT_EVAL |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1509 set_term_option_sctx_idx(NULL, opt_idx); |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1510 #endif |
7 | 1511 } |
1512 } | |
1513 else | |
1514 { | |
1515 name[0] = KEY2TERMCAP0((int)p->bt_entry); | |
1516 name[1] = KEY2TERMCAP1((int)p->bt_entry); | |
1517 if (find_termcode(name) == NULL) | |
1518 add_termcode(name, (char_u *)p->bt_string, term_8bit); | |
1519 } | |
1520 } | |
1521 } | |
11739
5c69c6d9e2eb
patch 8.0.0752: build fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11731
diff
changeset
|
1522 |
7 | 1523 /* |
1524 * Set number of colors. | |
1525 * Store it as a number in t_colors. | |
1526 * Store it as a string in T_CCO (using nr_colors[]). | |
1527 */ | |
1528 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1529 set_color_count(int nr) |
7 | 1530 { |
1531 char_u nr_colors[20]; /* string for number of colors */ | |
1532 | |
1533 t_colors = nr; | |
1534 if (t_colors > 1) | |
1535 sprintf((char *)nr_colors, "%d", t_colors); | |
1536 else | |
1537 *nr_colors = NUL; | |
694 | 1538 set_string_option_direct((char_u *)"t_Co", -1, nr_colors, OPT_FREE, 0); |
7 | 1539 } |
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
|
1540 |
11739
5c69c6d9e2eb
patch 8.0.0752: build fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11731
diff
changeset
|
1541 #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
|
1542 /* |
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
|
1543 * 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
|
1544 */ |
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
|
1545 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
|
1546 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
|
1547 { |
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
|
1548 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
|
1549 { |
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
|
1550 /* 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
|
1551 * 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
|
1552 * 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
|
1553 * 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
|
1554 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
|
1555 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
|
1556 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
|
1557 # 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
|
1558 { |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
1559 int r = redraw_asap(CLEAR); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
1560 |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
1561 log_tr("Received t_Co, redraw_asap(): %d", r); |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1562 } |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
1563 #else |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1564 redraw_asap(CLEAR); |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
1565 #endif |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
1566 } |
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
|
1567 } |
7 | 1568 #endif |
1569 | |
1570 #ifdef HAVE_TGETENT | |
1571 static char *(key_names[]) = | |
1572 { | |
1573 #ifdef FEAT_TERMRESPONSE | |
1574 /* Do this one first, it may cause a screen redraw. */ | |
1575 "Co", | |
1576 #endif | |
1577 "ku", "kd", "kr", "kl", | |
1578 "#2", "#4", "%i", "*7", | |
1579 "k1", "k2", "k3", "k4", "k5", "k6", | |
1580 "k7", "k8", "k9", "k;", "F1", "F2", | |
1581 "%1", "&8", "kb", "kI", "kD", "kh", | |
1582 "@7", "kP", "kN", "K1", "K3", "K4", "K5", "kB", | |
1583 NULL | |
1584 }; | |
1585 #endif | |
1586 | |
13874
fc2f175e8169
patch 8.0.1808: can't build without TGETENT
Christian Brabandt <cb@256bit.org>
parents:
13872
diff
changeset
|
1587 #ifdef HAVE_TGETENT |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1588 static void |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1589 get_term_entries(int *height, int *width) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1590 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1591 static struct { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1592 enum SpecialKey dest; /* index in term_strings[] */ |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1593 char *name; /* termcap name for string */ |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1594 } string_names[] = |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1595 { {KS_CE, "ce"}, {KS_AL, "al"}, {KS_CAL,"AL"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1596 {KS_DL, "dl"}, {KS_CDL,"DL"}, {KS_CS, "cs"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1597 {KS_CL, "cl"}, {KS_CD, "cd"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1598 {KS_VI, "vi"}, {KS_VE, "ve"}, {KS_MB, "mb"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1599 {KS_ME, "me"}, {KS_MR, "mr"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1600 {KS_MD, "md"}, {KS_SE, "se"}, {KS_SO, "so"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1601 {KS_CZH,"ZH"}, {KS_CZR,"ZR"}, {KS_UE, "ue"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1602 {KS_US, "us"}, {KS_UCE, "Ce"}, {KS_UCS, "Cs"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1603 {KS_STE,"Te"}, {KS_STS,"Ts"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1604 {KS_CM, "cm"}, {KS_SR, "sr"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1605 {KS_CRI,"RI"}, {KS_VB, "vb"}, {KS_KS, "ks"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1606 {KS_KE, "ke"}, {KS_TI, "ti"}, {KS_TE, "te"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1607 {KS_BC, "bc"}, {KS_CSB,"Sb"}, {KS_CSF,"Sf"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1608 {KS_CAB,"AB"}, {KS_CAF,"AF"}, {KS_LE, "le"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1609 {KS_ND, "nd"}, {KS_OP, "op"}, {KS_CRV, "RV"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1610 {KS_VS, "vs"}, {KS_CVS, "VS"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1611 {KS_CIS, "IS"}, {KS_CIE, "IE"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1612 {KS_CSC, "SC"}, {KS_CEC, "EC"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1613 {KS_TS, "ts"}, {KS_FS, "fs"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1614 {KS_CWP, "WP"}, {KS_CWS, "WS"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1615 {KS_CSI, "SI"}, {KS_CEI, "EI"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1616 {KS_U7, "u7"}, {KS_RFG, "RF"}, {KS_RBG, "RB"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1617 {KS_8F, "8f"}, {KS_8B, "8b"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1618 {KS_CBE, "BE"}, {KS_CBD, "BD"}, |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1619 {KS_CPS, "PS"}, {KS_CPE, "PE"}, |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
1620 {KS_CST, "ST"}, {KS_CRT, "RT"}, |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
1621 {KS_SSI, "Si"}, {KS_SRI, "Ri"}, |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1622 {(enum SpecialKey)0, NULL} |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1623 }; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1624 int i; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1625 char_u *p; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1626 static char_u tstrbuf[TBUFSZ]; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1627 char_u *tp = tstrbuf; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1628 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1629 /* |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1630 * get output strings |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1631 */ |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1632 for (i = 0; string_names[i].name != NULL; ++i) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1633 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1634 if (TERM_STR(string_names[i].dest) == NULL |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1635 || TERM_STR(string_names[i].dest) == empty_option) |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1636 { |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1637 TERM_STR(string_names[i].dest) = TGETSTR(string_names[i].name, &tp); |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1638 #ifdef FEAT_EVAL |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1639 set_term_option_sctx_idx(string_names[i].name, -1); |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1640 #endif |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1641 } |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1642 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1643 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1644 /* tgetflag() returns 1 if the flag is present, 0 if not and |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1645 * possibly -1 if the flag doesn't exist. */ |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1646 if ((T_MS == NULL || T_MS == empty_option) && tgetflag("ms") > 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1647 T_MS = (char_u *)"y"; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1648 if ((T_XS == NULL || T_XS == empty_option) && tgetflag("xs") > 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1649 T_XS = (char_u *)"y"; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1650 if ((T_XN == NULL || T_XN == empty_option) && tgetflag("xn") > 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1651 T_XN = (char_u *)"y"; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1652 if ((T_DB == NULL || T_DB == empty_option) && tgetflag("db") > 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1653 T_DB = (char_u *)"y"; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1654 if ((T_DA == NULL || T_DA == empty_option) && tgetflag("da") > 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1655 T_DA = (char_u *)"y"; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1656 if ((T_UT == NULL || T_UT == empty_option) && tgetflag("ut") > 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1657 T_UT = (char_u *)"y"; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1658 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1659 /* |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1660 * get key codes |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1661 */ |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1662 for (i = 0; key_names[i] != NULL; ++i) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1663 if (find_termcode((char_u *)key_names[i]) == NULL) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1664 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1665 p = TGETSTR(key_names[i], &tp); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1666 /* if cursor-left == backspace, ignore it (televideo 925) */ |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1667 if (p != NULL |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1668 && (*p != Ctrl_H |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1669 || key_names[i][0] != 'k' |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1670 || key_names[i][1] != 'l')) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1671 add_termcode((char_u *)key_names[i], p, FALSE); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1672 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1673 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1674 if (*height == 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1675 *height = tgetnum("li"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1676 if (*width == 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1677 *width = tgetnum("co"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1678 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1679 /* |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1680 * Get number of colors (if not done already). |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1681 */ |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1682 if (TERM_STR(KS_CCO) == NULL || TERM_STR(KS_CCO) == empty_option) |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1683 { |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1684 set_color_count(tgetnum("Co")); |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1685 #ifdef FEAT_EVAL |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1686 set_term_option_sctx_idx("Co", -1); |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1687 #endif |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
1688 } |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1689 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1690 # ifndef hpux |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1691 BC = (char *)TGETSTR("bc", &tp); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1692 UP = (char *)TGETSTR("up", &tp); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1693 p = TGETSTR("pc", &tp); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1694 if (p) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1695 PC = *p; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1696 # endif |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1697 } |
13874
fc2f175e8169
patch 8.0.1808: can't build without TGETENT
Christian Brabandt <cb@256bit.org>
parents:
13872
diff
changeset
|
1698 #endif |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1699 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1700 static void |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
1701 report_term_error(char *error_msg, char_u *term) |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1702 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1703 struct builtin_term *termp; |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1704 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1705 mch_errmsg("\r\n"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1706 if (error_msg != NULL) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1707 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
1708 mch_errmsg(error_msg); |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1709 mch_errmsg("\r\n"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1710 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1711 mch_errmsg("'"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1712 mch_errmsg((char *)term); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1713 mch_errmsg(_("' not known. Available builtin terminals are:")); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1714 mch_errmsg("\r\n"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1715 for (termp = &(builtin_termcaps[0]); termp->bt_string != NULL; ++termp) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1716 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1717 if (termp->bt_entry == (int)KS_NAME) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1718 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1719 #ifdef HAVE_TGETENT |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1720 mch_errmsg(" builtin_"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1721 #else |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1722 mch_errmsg(" "); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1723 #endif |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1724 mch_errmsg(termp->bt_string); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1725 mch_errmsg("\r\n"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1726 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1727 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1728 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1729 |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1730 static void |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1731 report_default_term(char_u *term) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1732 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1733 mch_errmsg(_("defaulting to '")); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1734 mch_errmsg((char *)term); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1735 mch_errmsg("'\r\n"); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1736 if (emsg_silent == 0) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1737 { |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1738 screen_start(); /* don't know where cursor is now */ |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1739 out_flush(); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1740 if (!is_not_a_term()) |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1741 ui_delay(2000L, TRUE); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1742 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1743 } |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1744 |
7 | 1745 /* |
1746 * Set terminal options for terminal "term". | |
1747 * Return OK if terminal 'term' was found in a termcap, FAIL otherwise. | |
1748 * | |
1749 * While doing this, until ttest(), some options may be NULL, be careful. | |
1750 */ | |
1751 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1752 set_termname(char_u *term) |
7 | 1753 { |
1754 struct builtin_term *termp; | |
1755 #ifdef HAVE_TGETENT | |
1756 int builtin_first = p_tbi; | |
1757 int try; | |
1758 int termcap_cleared = FALSE; | |
1759 #endif | |
1760 int width = 0, height = 0; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
1761 char *error_msg = NULL; |
7 | 1762 char_u *bs_p, *del_p; |
1763 | |
168 | 1764 /* In silect mode (ex -s) we don't use the 'term' option. */ |
1765 if (silent_mode) | |
1766 return OK; | |
1767 | |
7 | 1768 detected_8bit = FALSE; /* reset 8-bit detection */ |
1769 | |
1770 if (term_is_builtin(term)) | |
1771 { | |
1772 term += 8; | |
1773 #ifdef HAVE_TGETENT | |
1774 builtin_first = 1; | |
1775 #endif | |
1776 } | |
1777 | |
1778 /* | |
1779 * If HAVE_TGETENT is not defined, only the builtin termcap is used, otherwise: | |
1780 * If builtin_first is TRUE: | |
1781 * 0. try builtin termcap | |
1782 * 1. try external termcap | |
1783 * 2. if both fail default to a builtin terminal | |
1784 * If builtin_first is FALSE: | |
1785 * 1. try external termcap | |
1786 * 2. try builtin termcap, if both fail default to a builtin terminal | |
1787 */ | |
1788 #ifdef HAVE_TGETENT | |
1789 for (try = builtin_first ? 0 : 1; try < 3; ++try) | |
1790 { | |
1791 /* | |
1792 * Use external termcap | |
1793 */ | |
1794 if (try == 1) | |
1795 { | |
1796 char_u tbuf[TBUFSZ]; | |
1797 | |
1798 /* | |
1799 * If the external termcap does not have a matching entry, try the | |
1800 * builtin ones. | |
1801 */ | |
1802 if ((error_msg = tgetent_error(tbuf, term)) == NULL) | |
1803 { | |
1804 if (!termcap_cleared) | |
1805 { | |
1806 clear_termoptions(); /* clear old options */ | |
1807 termcap_cleared = TRUE; | |
1808 } | |
1809 | |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1810 get_term_entries(&height, &width); |
7 | 1811 } |
1812 } | |
1813 else /* try == 0 || try == 2 */ | |
1814 #endif /* HAVE_TGETENT */ | |
1815 /* | |
1816 * Use builtin termcap | |
1817 */ | |
1818 { | |
1819 #ifdef HAVE_TGETENT | |
1820 /* | |
1821 * If builtin termcap was already used, there is no need to search | |
1822 * for the builtin termcap again, quit now. | |
1823 */ | |
1824 if (try == 2 && builtin_first && termcap_cleared) | |
1825 break; | |
1826 #endif | |
1827 /* | |
1828 * search for 'term' in builtin_termcaps[] | |
1829 */ | |
1830 termp = find_builtin_term(term); | |
1831 if (termp->bt_string == NULL) /* did not find it */ | |
1832 { | |
1833 #ifdef HAVE_TGETENT | |
1834 /* | |
1835 * If try == 0, first try the external termcap. If that is not | |
1836 * found we'll get back here with try == 2. | |
1837 * If termcap_cleared is set we used the external termcap, | |
1838 * don't complain about not finding the term in the builtin | |
1839 * termcap. | |
1840 */ | |
1841 if (try == 0) /* try external one */ | |
1842 continue; | |
1843 if (termcap_cleared) /* found in external termcap */ | |
1844 break; | |
1845 #endif | |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1846 report_term_error(error_msg, term); |
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1847 |
7 | 1848 /* when user typed :set term=xxx, quit here */ |
1849 if (starting != NO_SCREEN) | |
1850 { | |
1851 screen_start(); /* don't know where cursor is now */ | |
1852 wait_return(TRUE); | |
1853 return FAIL; | |
1854 } | |
1855 term = DEFAULT_TERM; | |
13872
9d3ddfa88a56
patch 8.0.1807: function to set terminal name is too long
Christian Brabandt <cb@256bit.org>
parents:
13839
diff
changeset
|
1856 report_default_term(term); |
694 | 1857 set_string_option_direct((char_u *)"term", -1, term, |
1858 OPT_FREE, 0); | |
7 | 1859 display_errors(); |
1860 } | |
1861 out_flush(); | |
1862 #ifdef HAVE_TGETENT | |
1863 if (!termcap_cleared) | |
1864 { | |
1865 #endif | |
1866 clear_termoptions(); /* clear old options */ | |
1867 #ifdef HAVE_TGETENT | |
1868 termcap_cleared = TRUE; | |
1869 } | |
1870 #endif | |
1871 parse_builtin_tcap(term); | |
1872 #ifdef FEAT_GUI | |
1873 if (term_is_gui(term)) | |
1874 { | |
1875 out_flush(); | |
1876 gui_init(); | |
1877 /* If starting the GUI failed, don't do any of the other | |
1878 * things for this terminal */ | |
1879 if (!gui.in_use) | |
1880 return FAIL; | |
1881 #ifdef HAVE_TGETENT | |
1882 break; /* don't try using external termcap */ | |
1883 #endif | |
1884 } | |
1885 #endif /* FEAT_GUI */ | |
1886 } | |
1887 #ifdef HAVE_TGETENT | |
1888 } | |
1889 #endif | |
1890 | |
1891 /* | |
1892 * special: There is no info in the termcap about whether the cursor | |
1893 * positioning is relative to the start of the screen or to the start of the | |
1894 * scrolling region. We just guess here. Only msdos pcterm is known to do it | |
1895 * relative. | |
1896 */ | |
1897 if (STRCMP(term, "pcterm") == 0) | |
1898 T_CCS = (char_u *)"yes"; | |
1899 else | |
1900 T_CCS = empty_option; | |
1901 | |
1902 #ifdef UNIX | |
1903 /* | |
1904 * Any "stty" settings override the default for t_kb from the termcap. | |
1905 * This is in os_unix.c, because it depends a lot on the version of unix that | |
1906 * is being used. | |
1907 * Don't do this when the GUI is active, it uses "t_kb" and "t_kD" directly. | |
1908 */ | |
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
|
1909 # ifdef FEAT_GUI |
7 | 1910 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
|
1911 # endif |
7 | 1912 get_stty(); |
1913 #endif | |
1914 | |
1915 /* | |
1916 * If the termcap has no entry for 'bs' and/or 'del' and the ioctl() also | |
1917 * didn't work, use the default CTRL-H | |
1918 * The default for t_kD is DEL, unless t_kb is DEL. | |
1919 * The vim_strsave'd strings are probably lost forever, well it's only two | |
1920 * bytes. Don't do this when the GUI is active, it uses "t_kb" and "t_kD" | |
1921 * directly. | |
1922 */ | |
1923 #ifdef FEAT_GUI | |
1924 if (!gui.in_use) | |
1925 #endif | |
1926 { | |
1927 bs_p = find_termcode((char_u *)"kb"); | |
1928 del_p = find_termcode((char_u *)"kD"); | |
1929 if (bs_p == NULL || *bs_p == NUL) | |
1930 add_termcode((char_u *)"kb", (bs_p = (char_u *)CTRL_H_STR), FALSE); | |
1931 if ((del_p == NULL || *del_p == NUL) && | |
1932 (bs_p == NULL || *bs_p != DEL)) | |
1933 add_termcode((char_u *)"kD", (char_u *)DEL_STR, FALSE); | |
1934 } | |
1935 | |
1936 #if defined(UNIX) || defined(VMS) | |
1937 term_is_xterm = vim_is_xterm(term); | |
1938 #endif | |
1939 | |
1940 #ifdef FEAT_MOUSE | |
1941 # if defined(UNIX) || defined(VMS) | |
1942 # ifdef FEAT_MOUSE_TTY | |
1943 /* | |
1944 * For Unix, set the 'ttymouse' option to the type of mouse to be used. | |
1945 * The termcode for the mouse is added as a side effect in option.c. | |
1946 */ | |
1947 { | |
11563
2547bbe6716e
patch 8.0.0664: mouse does not work in tmux
Christian Brabandt <cb@256bit.org>
parents:
11557
diff
changeset
|
1948 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
|
1949 |
7 | 1950 # ifdef FEAT_MOUSE_XTERM |
1623 | 1951 if (use_xterm_like_mouse(term)) |
7 | 1952 { |
1953 if (use_xterm_mouse()) | |
1954 p = NULL; /* keep existing value, might be "xterm2" */ | |
1955 else | |
1956 p = (char_u *)"xterm"; | |
1957 } | |
1958 # endif | |
1959 if (p != NULL) | |
3980 | 1960 { |
7 | 1961 set_option_value((char_u *)"ttym", 0L, p, 0); |
3980 | 1962 /* Reset the WAS_SET flag, 'ttymouse' can be set to "sgr" or |
1963 * "xterm2" in check_termcode(). */ | |
1964 reset_option_was_set((char_u *)"ttym"); | |
1965 } | |
7 | 1966 if (p == NULL |
1967 # ifdef FEAT_GUI | |
1968 || gui.in_use | |
1969 # endif | |
1970 ) | |
1971 check_mouse_termcode(); /* set mouse termcode anyway */ | |
1972 } | |
1973 # endif | |
1974 # else | |
1975 set_mouse_termcode(KS_MOUSE, (char_u *)"\233M"); | |
1976 # endif | |
1977 #endif /* FEAT_MOUSE */ | |
1978 | |
1979 #ifdef USE_TERM_CONSOLE | |
1980 /* DEFAULT_TERM indicates that it is the machine console. */ | |
1981 if (STRCMP(term, DEFAULT_TERM) != 0) | |
1982 term_console = FALSE; | |
1983 else | |
1984 { | |
1985 term_console = TRUE; | |
1986 # ifdef AMIGA | |
1987 win_resize_on(); /* enable window resizing reports */ | |
1988 # endif | |
1989 } | |
1990 #endif | |
1991 | |
1992 #if defined(UNIX) || defined(VMS) | |
1993 /* | |
1994 * 'ttyfast' is default on for xterm, iris-ansi and a few others. | |
1995 */ | |
1996 if (vim_is_fastterm(term)) | |
1997 p_tf = TRUE; | |
1998 #endif | |
1999 #ifdef USE_TERM_CONSOLE | |
2000 /* | |
2001 * 'ttyfast' is default on consoles | |
2002 */ | |
2003 if (term_console) | |
2004 p_tf = TRUE; | |
2005 #endif | |
2006 | |
2007 ttest(TRUE); /* make sure we have a valid set of terminal codes */ | |
2008 | |
2009 full_screen = TRUE; /* we can use termcap codes from now on */ | |
2010 set_term_defaults(); /* use current values as defaults */ | |
2011 #ifdef FEAT_TERMRESPONSE | |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
2012 LOG_TR(("setting crv_status to STATUS_GET")); |
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
|
2013 crv_status = STATUS_GET; /* Get terminal version later */ |
7 | 2014 #endif |
2015 | |
2016 /* | |
2017 * Initialize the terminal with the appropriate termcap codes. | |
2018 * Set the mouse and window title if possible. | |
2019 * Don't do this when starting, need to parse the .vimrc first, because it | |
2020 * may redefine t_TI etc. | |
2021 */ | |
2022 if (starting != NO_SCREEN) | |
2023 { | |
2024 starttermcap(); /* may change terminal mode */ | |
2025 #ifdef FEAT_MOUSE | |
2026 setmouse(); /* may start using the mouse */ | |
2027 #endif | |
2028 #ifdef FEAT_TITLE | |
2029 maketitle(); /* may display window title */ | |
2030 #endif | |
2031 } | |
2032 | |
2033 /* display initial screen after ttest() checking. jw. */ | |
2034 if (width <= 0 || height <= 0) | |
2035 { | |
2036 /* termcap failed to report size */ | |
2037 /* set defaults, in case ui_get_shellsize() also fails */ | |
2038 width = 80; | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15852
diff
changeset
|
2039 #if defined(MSWIN) |
7 | 2040 height = 25; /* console is often 25 lines */ |
2041 #else | |
2042 height = 24; /* most terminals are 24 lines */ | |
2043 #endif | |
2044 } | |
2045 set_shellsize(width, height, FALSE); /* may change Rows */ | |
2046 if (starting != NO_SCREEN) | |
2047 { | |
2048 if (scroll_region) | |
2049 scroll_region_reset(); /* In case Rows changed */ | |
2050 check_map_keycodes(); /* check mappings for terminal codes used */ | |
2051 | |
2052 { | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9125
diff
changeset
|
2053 bufref_T old_curbuf; |
7 | 2054 |
2055 /* | |
2056 * Execute the TermChanged autocommands for each buffer that is | |
2057 * loaded. | |
2058 */ | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9125
diff
changeset
|
2059 set_bufref(&old_curbuf, curbuf); |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9628
diff
changeset
|
2060 FOR_ALL_BUFFERS(curbuf) |
7 | 2061 { |
2062 if (curbuf->b_ml.ml_mfp != NULL) | |
2063 apply_autocmds(EVENT_TERMCHANGED, NULL, NULL, FALSE, | |
2064 curbuf); | |
2065 } | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9125
diff
changeset
|
2066 if (bufref_valid(&old_curbuf)) |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9125
diff
changeset
|
2067 curbuf = old_curbuf.br_buf; |
7 | 2068 } |
2069 } | |
2070 | |
2071 #ifdef FEAT_TERMRESPONSE | |
2072 may_req_termresponse(); | |
2073 #endif | |
2074 | |
2075 return OK; | |
2076 } | |
2077 | |
2078 #if defined(FEAT_MOUSE) || defined(PROTO) | |
2079 | |
2080 # ifdef FEAT_MOUSE_TTY | |
2081 # define HMT_NORMAL 1 | |
2082 # define HMT_NETTERM 2 | |
2083 # define HMT_DEC 4 | |
2084 # define HMT_JSBTERM 8 | |
2085 # define HMT_PTERM 16 | |
3176 | 2086 # define HMT_URXVT 32 |
3746 | 2087 # 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
|
2088 # define HMT_SGR_REL 128 |
7 | 2089 static int has_mouse_termcode = 0; |
2090 # endif | |
2091 | |
1623 | 2092 # if (!defined(UNIX) || defined(FEAT_MOUSE_TTY)) || defined(PROTO) |
7 | 2093 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2094 set_mouse_termcode( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2095 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
|
2096 char_u *s) |
7 | 2097 { |
2098 char_u name[2]; | |
2099 | |
2100 name[0] = n; | |
2101 name[1] = KE_FILLER; | |
2102 add_termcode(name, s, FALSE); | |
2103 # ifdef FEAT_MOUSE_TTY | |
2104 # ifdef FEAT_MOUSE_JSB | |
2105 if (n == KS_JSBTERM_MOUSE) | |
2106 has_mouse_termcode |= HMT_JSBTERM; | |
2107 else | |
2108 # endif | |
2109 # ifdef FEAT_MOUSE_NET | |
2110 if (n == KS_NETTERM_MOUSE) | |
2111 has_mouse_termcode |= HMT_NETTERM; | |
2112 else | |
2113 # endif | |
2114 # ifdef FEAT_MOUSE_DEC | |
2115 if (n == KS_DEC_MOUSE) | |
2116 has_mouse_termcode |= HMT_DEC; | |
2117 else | |
2118 # endif | |
2119 # ifdef FEAT_MOUSE_PTERM | |
2120 if (n == KS_PTERM_MOUSE) | |
2121 has_mouse_termcode |= HMT_PTERM; | |
2122 else | |
2123 # endif | |
3176 | 2124 # ifdef FEAT_MOUSE_URXVT |
2125 if (n == KS_URXVT_MOUSE) | |
2126 has_mouse_termcode |= HMT_URXVT; | |
2127 else | |
2128 # endif | |
3746 | 2129 if (n == KS_SGR_MOUSE) |
2130 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
|
2131 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
|
2132 has_mouse_termcode |= HMT_SGR_REL; |
3746 | 2133 else |
7 | 2134 has_mouse_termcode |= HMT_NORMAL; |
2135 # endif | |
2136 } | |
2137 # endif | |
2138 | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7307
diff
changeset
|
2139 # if ((defined(UNIX) || defined(VMS)) \ |
1623 | 2140 && defined(FEAT_MOUSE_TTY)) || defined(PROTO) |
7 | 2141 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2142 del_mouse_termcode( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2143 int n) /* KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE */ |
7 | 2144 { |
2145 char_u name[2]; | |
2146 | |
2147 name[0] = n; | |
2148 name[1] = KE_FILLER; | |
2149 del_termcode(name); | |
2150 # ifdef FEAT_MOUSE_TTY | |
2151 # ifdef FEAT_MOUSE_JSB | |
2152 if (n == KS_JSBTERM_MOUSE) | |
2153 has_mouse_termcode &= ~HMT_JSBTERM; | |
2154 else | |
2155 # endif | |
2156 # ifdef FEAT_MOUSE_NET | |
2157 if (n == KS_NETTERM_MOUSE) | |
2158 has_mouse_termcode &= ~HMT_NETTERM; | |
2159 else | |
2160 # endif | |
2161 # ifdef FEAT_MOUSE_DEC | |
2162 if (n == KS_DEC_MOUSE) | |
2163 has_mouse_termcode &= ~HMT_DEC; | |
2164 else | |
2165 # endif | |
2166 # ifdef FEAT_MOUSE_PTERM | |
2167 if (n == KS_PTERM_MOUSE) | |
2168 has_mouse_termcode &= ~HMT_PTERM; | |
2169 else | |
2170 # endif | |
3176 | 2171 # ifdef FEAT_MOUSE_URXVT |
2172 if (n == KS_URXVT_MOUSE) | |
2173 has_mouse_termcode &= ~HMT_URXVT; | |
2174 else | |
2175 # endif | |
3746 | 2176 if (n == KS_SGR_MOUSE) |
2177 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
|
2178 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
|
2179 has_mouse_termcode &= ~HMT_SGR_REL; |
3746 | 2180 else |
7 | 2181 has_mouse_termcode &= ~HMT_NORMAL; |
2182 # endif | |
2183 } | |
2184 # endif | |
2185 #endif | |
2186 | |
2187 #ifdef HAVE_TGETENT | |
2188 /* | |
2189 * Call tgetent() | |
2190 * Return error message if it fails, NULL if it's OK. | |
2191 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
2192 static char * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2193 tgetent_error(char_u *tbuf, char_u *term) |
7 | 2194 { |
2195 int i; | |
2196 | |
2197 i = TGETENT(tbuf, term); | |
2198 if (i < 0 /* -1 is always an error */ | |
2199 # ifdef TGETENT_ZERO_ERR | |
2200 || i == 0 /* sometimes zero is also an error */ | |
2201 # endif | |
2202 ) | |
2203 { | |
2204 /* On FreeBSD tputs() gets a SEGV after a tgetent() which fails. Call | |
2205 * tgetent() with the always existing "dumb" entry to avoid a crash or | |
2206 * hang. */ | |
2207 (void)TGETENT(tbuf, "dumb"); | |
2208 | |
2209 if (i < 0) | |
2210 # ifdef TGETENT_ZERO_ERR | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
2211 return _("E557: Cannot open termcap file"); |
7 | 2212 if (i == 0) |
2213 # endif | |
2214 #ifdef TERMINFO | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
2215 return _("E558: Terminal entry not found in terminfo"); |
7 | 2216 #else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
2217 return _("E559: Terminal entry not found in termcap"); |
7 | 2218 #endif |
2219 } | |
2220 return NULL; | |
2221 } | |
2222 | |
2223 /* | |
2224 * Some versions of tgetstr() have been reported to return -1 instead of NULL. | |
2225 * Fix that here. | |
2226 */ | |
2227 static char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2228 vim_tgetstr(char *s, char_u **pp) |
7 | 2229 { |
2230 char *p; | |
2231 | |
2232 p = tgetstr(s, (char **)pp); | |
2233 if (p == (char *)-1) | |
2234 p = NULL; | |
2235 return (char_u *)p; | |
2236 } | |
2237 #endif /* HAVE_TGETENT */ | |
2238 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
2239 #if defined(HAVE_TGETENT) && (defined(UNIX) || defined(VMS) || defined(MACOS_X)) |
7 | 2240 /* |
2241 * Get Columns and Rows from the termcap. Used after a window signal if the | |
2242 * ioctl() fails. It doesn't make sense to call tgetent each time if the "co" | |
2243 * and "li" entries never change. But on some systems this works. | |
2244 * Errors while getting the entries are ignored. | |
2245 */ | |
2246 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2247 getlinecol( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2248 long *cp, /* pointer to columns */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2249 long *rp) /* pointer to rows */ |
7 | 2250 { |
2251 char_u tbuf[TBUFSZ]; | |
2252 | |
2253 if (T_NAME != NULL && *T_NAME != NUL && tgetent_error(tbuf, T_NAME) == NULL) | |
2254 { | |
2255 if (*cp == 0) | |
2256 *cp = tgetnum("co"); | |
2257 if (*rp == 0) | |
2258 *rp = tgetnum("li"); | |
2259 } | |
2260 } | |
2261 #endif /* defined(HAVE_TGETENT) && defined(UNIX) */ | |
2262 | |
2263 /* | |
2264 * Get a string entry from the termcap and add it to the list of termcodes. | |
2265 * Used for <t_xx> special keys. | |
2266 * Give an error message for failure when not sourcing. | |
2267 * If force given, replace an existing entry. | |
2268 * Return FAIL if the entry was not found, OK if the entry was added. | |
2269 */ | |
2270 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2271 add_termcap_entry(char_u *name, int force) |
7 | 2272 { |
2273 char_u *term; | |
2274 int key; | |
2275 struct builtin_term *termp; | |
2276 #ifdef HAVE_TGETENT | |
2277 char_u *string; | |
2278 int i; | |
2279 int builtin_first; | |
2280 char_u tbuf[TBUFSZ]; | |
2281 char_u tstrbuf[TBUFSZ]; | |
2282 char_u *tp = tstrbuf; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
2283 char *error_msg = NULL; |
7 | 2284 #endif |
2285 | |
2286 /* | |
2287 * If the GUI is running or will start in a moment, we only support the keys | |
2288 * that the GUI can produce. | |
2289 */ | |
2290 #ifdef FEAT_GUI | |
2291 if (gui.in_use || gui.starting) | |
2292 return gui_mch_haskey(name); | |
2293 #endif | |
2294 | |
2295 if (!force && find_termcode(name) != NULL) /* it's already there */ | |
2296 return OK; | |
2297 | |
2298 term = T_NAME; | |
2299 if (term == NULL || *term == NUL) /* 'term' not defined yet */ | |
2300 return FAIL; | |
2301 | |
2302 if (term_is_builtin(term)) /* name starts with "builtin_" */ | |
2303 { | |
2304 term += 8; | |
2305 #ifdef HAVE_TGETENT | |
2306 builtin_first = TRUE; | |
2307 #endif | |
2308 } | |
2309 #ifdef HAVE_TGETENT | |
2310 else | |
2311 builtin_first = p_tbi; | |
2312 #endif | |
2313 | |
2314 #ifdef HAVE_TGETENT | |
2315 /* | |
2316 * We can get the entry from the builtin termcap and from the external one. | |
2317 * If 'ttybuiltin' is on or the terminal name starts with "builtin_", try | |
2318 * builtin termcap first. | |
2319 * If 'ttybuiltin' is off, try external termcap first. | |
2320 */ | |
2321 for (i = 0; i < 2; ++i) | |
2322 { | |
7210
08b50e436093
commit https://github.com/vim/vim/commit/98b30a473a58ae98c280e0383c8b1e08c0ebced5
Christian Brabandt <cb@256bit.org>
parents:
6901
diff
changeset
|
2323 if ((!builtin_first) == i) |
7 | 2324 #endif |
2325 /* | |
2326 * Search in builtin termcap | |
2327 */ | |
2328 { | |
2329 termp = find_builtin_term(term); | |
2330 if (termp->bt_string != NULL) /* found it */ | |
2331 { | |
2332 key = TERMCAP2KEY(name[0], name[1]); | |
13406
4e30f3f4cb78
patch 8.0.1577: virtual replace test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13398
diff
changeset
|
2333 ++termp; |
7 | 2334 while (termp->bt_entry != (int)KS_NAME) |
2335 { | |
2336 if ((int)termp->bt_entry == key) | |
2337 { | |
2338 add_termcode(name, (char_u *)termp->bt_string, | |
2339 term_is_8bit(term)); | |
2340 return OK; | |
2341 } | |
2342 ++termp; | |
2343 } | |
2344 } | |
2345 } | |
2346 #ifdef HAVE_TGETENT | |
2347 else | |
2348 /* | |
2349 * Search in external termcap | |
2350 */ | |
2351 { | |
2352 error_msg = tgetent_error(tbuf, term); | |
2353 if (error_msg == NULL) | |
2354 { | |
2355 string = TGETSTR((char *)name, &tp); | |
2356 if (string != NULL && *string != NUL) | |
2357 { | |
2358 add_termcode(name, string, FALSE); | |
2359 return OK; | |
2360 } | |
2361 } | |
2362 } | |
2363 } | |
2364 #endif | |
2365 | |
2366 if (sourcing_name == NULL) | |
2367 { | |
2368 #ifdef HAVE_TGETENT | |
2369 if (error_msg != NULL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
2370 emsg(error_msg); |
7 | 2371 else |
2372 #endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
2373 semsg(_("E436: No \"%s\" entry in termcap"), name); |
7 | 2374 } |
2375 return FAIL; | |
2376 } | |
2377 | |
2378 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2379 term_is_builtin(char_u *name) |
7 | 2380 { |
2381 return (STRNCMP(name, "builtin_", (size_t)8) == 0); | |
2382 } | |
2383 | |
2384 /* | |
2385 * Return TRUE if terminal "name" uses CSI instead of <Esc>[. | |
2386 * Assume that the terminal is using 8-bit controls when the name contains | |
2387 * "8bit", like in "xterm-8bit". | |
2388 */ | |
2389 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2390 term_is_8bit(char_u *name) |
7 | 2391 { |
2392 return (detected_8bit || strstr((char *)name, "8bit") != NULL); | |
2393 } | |
2394 | |
2395 /* | |
2396 * 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
|
2397 * <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
|
2398 * <Esc>] -> OSC <M-C-]> |
7 | 2399 * <Esc>O -> <M-C-O> |
2400 */ | |
2401 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2402 term_7to8bit(char_u *p) |
7 | 2403 { |
2404 if (*p == ESC) | |
2405 { | |
2406 if (p[1] == '[') | |
2407 return CSI; | |
2408 if (p[1] == ']') | |
6901 | 2409 return OSC; |
7 | 2410 if (p[1] == 'O') |
2411 return 0x8f; | |
2412 } | |
2413 return 0; | |
2414 } | |
2415 | |
13762
9de2b25932eb
patch 8.0.1753: various warnings from a static analyser
Christian Brabandt <cb@256bit.org>
parents:
13573
diff
changeset
|
2416 #if defined(FEAT_GUI) || defined(PROTO) |
7 | 2417 int |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2418 term_is_gui(char_u *name) |
7 | 2419 { |
2420 return (STRCMP(name, "builtin_gui") == 0 || STRCMP(name, "gui") == 0); | |
2421 } | |
2422 #endif | |
2423 | |
2424 #if !defined(HAVE_TGETENT) || defined(AMIGA) || defined(PROTO) | |
2425 | |
2426 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2427 tltoa(unsigned long i) |
7 | 2428 { |
2429 static char_u buf[16]; | |
2430 char_u *p; | |
2431 | |
2432 p = buf + 15; | |
2433 *p = '\0'; | |
2434 do | |
2435 { | |
2436 --p; | |
2437 *p = (char_u) (i % 10 + '0'); | |
2438 i /= 10; | |
2439 } | |
2440 while (i > 0 && p > buf); | |
2441 return p; | |
2442 } | |
2443 #endif | |
2444 | |
2445 #ifndef HAVE_TGETENT | |
2446 | |
2447 /* | |
2448 * minimal tgoto() implementation. | |
2449 * no padding and we only parse for %i %d and %+char | |
2450 */ | |
298 | 2451 static char * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2452 tgoto(char *cm, int x, int y) |
7 | 2453 { |
2454 static char buf[30]; | |
2455 char *p, *s, *e; | |
2456 | |
2457 if (!cm) | |
2458 return "OOPS"; | |
2459 e = buf + 29; | |
2460 for (s = buf; s < e && *cm; cm++) | |
2461 { | |
2462 if (*cm != '%') | |
2463 { | |
2464 *s++ = *cm; | |
2465 continue; | |
2466 } | |
2467 switch (*++cm) | |
2468 { | |
2469 case 'd': | |
2470 p = (char *)tltoa((unsigned long)y); | |
2471 y = x; | |
2472 while (*p) | |
2473 *s++ = *p++; | |
2474 break; | |
2475 case 'i': | |
2476 x++; | |
2477 y++; | |
2478 break; | |
2479 case '+': | |
2480 *s++ = (char)(*++cm + y); | |
2481 y = x; | |
2482 break; | |
2483 case '%': | |
2484 *s++ = *cm; | |
2485 break; | |
2486 default: | |
2487 return "OOPS"; | |
2488 } | |
2489 } | |
2490 *s = '\0'; | |
2491 return buf; | |
2492 } | |
2493 | |
2494 #endif /* HAVE_TGETENT */ | |
2495 | |
2496 /* | |
2497 * Set the terminal name and initialize the terminal options. | |
2498 * If "name" is NULL or empty, get the terminal name from the environment. | |
2499 * If that fails, use the default terminal name. | |
2500 */ | |
2501 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2502 termcapinit(char_u *name) |
7 | 2503 { |
2504 char_u *term; | |
2505 | |
2506 if (name != NULL && *name == NUL) | |
2507 name = NULL; /* empty name is equal to no name */ | |
2508 term = name; | |
2509 | |
2510 #ifdef __BEOS__ | |
2511 /* | |
2512 * TERM environment variable is normally set to 'ansi' on the Bebox; | |
2513 * Since the BeBox doesn't quite support full ANSI yet, we use our | |
2514 * own custom 'ansi-beos' termcap instead, unless the -T option has | |
2515 * been given on the command line. | |
2516 */ | |
2517 if (term == NULL | |
2518 && strcmp((char *)mch_getenv((char_u *)"TERM"), "ansi") == 0) | |
2519 term = DEFAULT_TERM; | |
2520 #endif | |
2521 #ifndef MSWIN | |
2522 if (term == NULL) | |
2523 term = mch_getenv((char_u *)"TERM"); | |
2524 #endif | |
2525 if (term == NULL || *term == NUL) | |
2526 term = DEFAULT_TERM; | |
694 | 2527 set_string_option_direct((char_u *)"term", -1, term, OPT_FREE, 0); |
7 | 2528 |
2529 /* Set the default terminal name. */ | |
2530 set_string_default("term", term); | |
2531 set_string_default("ttytype", term); | |
2532 | |
2533 /* | |
2534 * Avoid using "term" here, because the next mch_getenv() may overwrite it. | |
2535 */ | |
2536 set_termname(T_NAME != NULL ? T_NAME : term); | |
2537 } | |
2538 | |
2539 /* | |
2540 * the number of calls to ui_write is reduced by using the buffer "out_buf" | |
2541 */ | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
2542 #define OUT_SIZE 2047 |
7 | 2543 /* Add one to allow mch_write() in os_win32.c to append a NUL */ |
2544 static char_u out_buf[OUT_SIZE + 1]; | |
2545 static int out_pos = 0; /* number of chars in out_buf */ | |
2546 | |
2547 /* | |
2548 * out_flush(): flush the output buffer | |
2549 */ | |
2550 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2551 out_flush(void) |
7 | 2552 { |
2553 int len; | |
2554 | |
2555 if (out_pos != 0) | |
2556 { | |
2557 /* set out_pos to 0 before ui_write, to avoid recursiveness */ | |
2558 len = out_pos; | |
2559 out_pos = 0; | |
2560 ui_write(out_buf, len); | |
2561 } | |
2562 } | |
2563 | |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2564 /* |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
2565 * out_flush_cursor(): flush the output buffer and redraw the cursor. |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
2566 * Does not flush recursively in the GUI to avoid slow drawing. |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2567 */ |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2568 void |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2569 out_flush_cursor( |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2570 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
|
2571 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
|
2572 { |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2573 mch_disable_flush(); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2574 out_flush(); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2575 mch_enable_flush(); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2576 #ifdef FEAT_GUI |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2577 if (gui.in_use) |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2578 { |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2579 gui_update_cursor(force, clear_selection); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2580 gui_may_flush(); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2581 } |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2582 #endif |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2583 } |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2584 |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13008
diff
changeset
|
2585 |
7 | 2586 /* |
2587 * Sometimes a byte out of a multi-byte character is written with out_char(). | |
2588 * To avoid flushing half of the character, call this function first. | |
2589 */ | |
2590 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2591 out_flush_check(void) |
7 | 2592 { |
2593 if (enc_dbcs != 0 && out_pos >= OUT_SIZE - MB_MAXBYTES) | |
2594 out_flush(); | |
2595 } | |
2596 | |
2597 #ifdef FEAT_GUI | |
2598 /* | |
2599 * out_trash(): Throw away the contents of the output buffer | |
2600 */ | |
2601 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2602 out_trash(void) |
7 | 2603 { |
2604 out_pos = 0; | |
2605 } | |
2606 #endif | |
2607 | |
2608 /* | |
2609 * out_char(c): put a byte into the output buffer. | |
2610 * Flush it if it becomes full. | |
2611 * This should not be used for outputting text on the screen (use functions | |
2612 * like msg_puts() and screen_putchar() for that). | |
2613 */ | |
2614 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2615 out_char(unsigned c) |
7 | 2616 { |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12640
diff
changeset
|
2617 #if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(MACOS_X) |
7 | 2618 if (c == '\n') /* turn LF into CR-LF (CRMOD doesn't seem to do this) */ |
2619 out_char('\r'); | |
2620 #endif | |
2621 | |
2622 out_buf[out_pos++] = c; | |
2623 | |
2624 /* For testing we flush each time. */ | |
2625 if (out_pos >= OUT_SIZE || p_wd) | |
2626 out_flush(); | |
2627 } | |
2628 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
2629 static void out_char_nf(unsigned); |
7 | 2630 |
2631 /* | |
2632 * out_char_nf(c): like out_char(), but don't flush when p_wd is set | |
2633 */ | |
2634 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2635 out_char_nf(unsigned c) |
7 | 2636 { |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12640
diff
changeset
|
2637 #if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(MACOS_X) |
7 | 2638 if (c == '\n') /* turn LF into CR-LF (CRMOD doesn't seem to do this) */ |
2639 out_char_nf('\r'); | |
2640 #endif | |
2641 | |
2642 out_buf[out_pos++] = c; | |
2643 | |
2644 if (out_pos >= OUT_SIZE) | |
2645 out_flush(); | |
2646 } | |
2647 | |
2237
770485470e59
Add a few #ifdefs to exclude functions that are not used. (Domnique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
1941
diff
changeset
|
2648 #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
|
2649 || defined(FEAT_TERMRESPONSE) || defined(PROTO) |
7 | 2650 /* |
2651 * A never-padding out_str. | |
2652 * use this whenever you don't want to run the string through tputs. | |
2653 * tputs above is harmless, but tputs from the termcap library | |
2654 * is likely to strip off leading digits, that it mistakes for padding | |
2655 * information, and "%i", "%d", etc. | |
2656 * This should only be used for writing terminal codes, not for outputting | |
2657 * normal text (use functions like msg_puts() and screen_putchar() for that). | |
2658 */ | |
2659 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2660 out_str_nf(char_u *s) |
7 | 2661 { |
2662 if (out_pos > OUT_SIZE - 20) /* avoid terminal strings being split up */ | |
2663 out_flush(); | |
2664 while (*s) | |
2665 out_char_nf(*s++); | |
2666 | |
2667 /* For testing we write one string at a time. */ | |
2668 if (p_wd) | |
2669 out_flush(); | |
2670 } | |
2237
770485470e59
Add a few #ifdefs to exclude functions that are not used. (Domnique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
1941
diff
changeset
|
2671 #endif |
7 | 2672 |
2673 /* | |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2674 * 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
|
2675 * 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
|
2676 * it at the wrong time. |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2677 * Note: Only for terminal strings. |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2678 */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2679 void |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2680 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
|
2681 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2682 if (s != NULL && *s) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2683 { |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2684 #ifdef HAVE_TGETENT |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2685 char_u *p; |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2686 #endif |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2687 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2688 #ifdef FEAT_GUI |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2689 /* 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
|
2690 if (gui.in_use) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2691 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2692 out_str_nf(s); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2693 return; |
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 #endif |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2696 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
|
2697 out_flush(); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2698 #ifdef HAVE_TGETENT |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2699 for (p = s; *s; ++s) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2700 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2701 /* flush just before delay command */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2702 if (*s == '$' && *(s + 1) == '<') |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2703 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2704 char_u save_c = *s; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2705 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
|
2706 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2707 *s = NUL; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2708 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
|
2709 *s = save_c; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2710 out_flush(); |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2711 # ifdef ELAPSED_FUNC |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2712 /* 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
|
2713 * vim_beep(). */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2714 p = vim_strchr(s, '>'); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2715 if (p == NULL || duration <= 0) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2716 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2717 /* 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
|
2718 p = s; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2719 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2720 else |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2721 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2722 ++p; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2723 do_sleep(duration); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2724 } |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2725 # else |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2726 /* 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
|
2727 p = s; |
11615
568ea579d20e
patch 8.0.0690: compiler warning on non-Unix system
Christian Brabandt <cb@256bit.org>
parents:
11601
diff
changeset
|
2728 # endif |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2729 break; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2730 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2731 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2732 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
|
2733 #else |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2734 while (*s) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2735 out_char_nf(*s++); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2736 #endif |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2737 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2738 /* 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
|
2739 if (p_wd) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2740 out_flush(); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2741 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2742 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2743 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11567
diff
changeset
|
2744 /* |
7 | 2745 * out_str(s): Put a character string a byte at a time into the output buffer. |
2746 * If HAVE_TGETENT is defined use the termcap parser. (jw) | |
2747 * This should only be used for writing terminal codes, not for outputting | |
2748 * normal text (use functions like msg_puts() and screen_putchar() for that). | |
2749 */ | |
2750 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2751 out_str(char_u *s) |
7 | 2752 { |
2753 if (s != NULL && *s) | |
2754 { | |
2755 #ifdef FEAT_GUI | |
2756 /* Don't use tputs() when GUI is used, ncurses crashes. */ | |
2757 if (gui.in_use) | |
2758 { | |
2759 out_str_nf(s); | |
2760 return; | |
2761 } | |
2762 #endif | |
2763 /* avoid terminal strings being split up */ | |
2764 if (out_pos > OUT_SIZE - 20) | |
2765 out_flush(); | |
2766 #ifdef HAVE_TGETENT | |
2767 tputs((char *)s, 1, TPUTSFUNCAST out_char_nf); | |
2768 #else | |
2769 while (*s) | |
2770 out_char_nf(*s++); | |
2771 #endif | |
2772 | |
2773 /* For testing we write one string at a time. */ | |
2774 if (p_wd) | |
2775 out_flush(); | |
2776 } | |
2777 } | |
2778 | |
2779 /* | |
2780 * cursor positioning using termcap parser. (jw) | |
2781 */ | |
2782 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2783 term_windgoto(int row, int col) |
7 | 2784 { |
2785 OUT_STR(tgoto((char *)T_CM, col, row)); | |
2786 } | |
2787 | |
2788 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2789 term_cursor_right(int i) |
7 | 2790 { |
2791 OUT_STR(tgoto((char *)T_CRI, 0, i)); | |
2792 } | |
2793 | |
2794 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2795 term_append_lines(int line_count) |
7 | 2796 { |
2797 OUT_STR(tgoto((char *)T_CAL, 0, line_count)); | |
2798 } | |
2799 | |
2800 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2801 term_delete_lines(int line_count) |
7 | 2802 { |
2803 OUT_STR(tgoto((char *)T_CDL, 0, line_count)); | |
2804 } | |
2805 | |
2806 #if defined(HAVE_TGETENT) || defined(PROTO) | |
2807 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2808 term_set_winpos(int x, int y) |
7 | 2809 { |
2810 /* Can't handle a negative value here */ | |
2811 if (x < 0) | |
2812 x = 0; | |
2813 if (y < 0) | |
2814 y = 0; | |
2815 OUT_STR(tgoto((char *)T_CWP, y, x)); | |
2816 } | |
2817 | |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2818 # 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
|
2819 /* |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2820 * 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
|
2821 */ |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2822 static int |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2823 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
|
2824 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2825 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
|
2826 && termcap_active |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2827 # ifdef UNIX |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2828 && (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
|
2829 # endif |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2830 && p_ek; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2831 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2832 |
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
|
2833 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
|
2834 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
|
2835 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
|
2836 |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2837 # if (defined(FEAT_EVAL) && defined(HAVE_TGETENT)) || defined(PROTO) |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2838 /* |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2839 * 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
|
2840 * 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
|
2841 */ |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2842 int |
13379
0f9dd1b43244
patch 8.0.1563: timeout of getwinposx() can be too short
Christian Brabandt <cb@256bit.org>
parents:
13365
diff
changeset
|
2843 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
|
2844 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2845 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
|
2846 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
|
2847 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
|
2848 |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2849 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
|
2850 return FAIL; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2851 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
|
2852 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
|
2853 ++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
|
2854 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
|
2855 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
|
2856 out_flush(); |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2857 |
13379
0f9dd1b43244
patch 8.0.1563: timeout of getwinposx() can be too short
Christian Brabandt <cb@256bit.org>
parents:
13365
diff
changeset
|
2858 /* 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
|
2859 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
|
2860 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2861 (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
|
2862 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
|
2863 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2864 *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
|
2865 *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
|
2866 return OK; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2867 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2868 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
|
2869 } |
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
|
2870 /* 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
|
2871 * 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
|
2872 |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2873 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
|
2874 winpos_y = prev_winpos_y; |
13762
9de2b25932eb
patch 8.0.1753: various warnings from a static analyser
Christian Brabandt <cb@256bit.org>
parents:
13573
diff
changeset
|
2875 if (timeout < 10 && prev_winpos_y >= 0 && prev_winpos_x >= 0) |
13398
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2876 { |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2877 /* 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
|
2878 *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
|
2879 *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
|
2880 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
|
2881 } |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2882 |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2883 return FALSE; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2884 } |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2885 # endif |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2886 # endif |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
2887 |
7 | 2888 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
|
2889 term_set_winsize(int height, int width) |
7 | 2890 { |
11731
d06f3576823a
patch 8.0.0748: running Vim in terminal window doesn't use the right colors
Christian Brabandt <cb@256bit.org>
parents:
11615
diff
changeset
|
2891 OUT_STR(tgoto((char *)T_CWS, width, height)); |
7 | 2892 } |
2893 #endif | |
2894 | |
2895 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2896 term_color(char_u *s, int n) |
7 | 2897 { |
2898 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
|
2899 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
|
2900 /* index in s[] just after <Esc>[ or CSI */ |
7 | 2901 |
2902 /* Special handling of 16 colors, because termcap can't handle it */ | |
2903 /* Also accept "\e[3%dm" for TERMINFO, it is sometimes used */ | |
2904 /* Also accept CSI instead of <Esc>[ */ | |
2905 if (n >= 8 && t_colors >= 16 | |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
2906 && ((s[0] == ESC && s[1] == '[') |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
2907 #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
2908 || (s[0] == ESC && s[1] == '|') |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
2909 #endif |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
2910 || (s[0] == CSI && (i = 1) == 1)) |
7 | 2911 && s[i] != NUL |
2912 && (STRCMP(s + i + 1, "%p1%dm") == 0 | |
2913 || STRCMP(s + i + 1, "%dm") == 0) | |
2914 && (s[i] == '3' || s[i] == '4')) | |
2915 { | |
2916 #ifdef TERMINFO | |
9068
0a3bc9fdea20
commit https://github.com/vim/vim/commit/827b165b2aebad2cfe98cc6d5804c6c0fe8afd89
Christian Brabandt <cb@256bit.org>
parents:
9027
diff
changeset
|
2917 char *format = "%s%s%%p1%%dm"; |
7 | 2918 #else |
9068
0a3bc9fdea20
commit https://github.com/vim/vim/commit/827b165b2aebad2cfe98cc6d5804c6c0fe8afd89
Christian Brabandt <cb@256bit.org>
parents:
9027
diff
changeset
|
2919 char *format = "%s%s%%dm"; |
7 | 2920 #endif |
14007
5d6e8dedfc73
patch 8.1.0021: clang warns for undefined behavior
Christian Brabandt <cb@256bit.org>
parents:
13874
diff
changeset
|
2921 char *lead = i == 2 ? ( |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
2922 #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS) |
14007
5d6e8dedfc73
patch 8.1.0021: clang warns for undefined behavior
Christian Brabandt <cb@256bit.org>
parents:
13874
diff
changeset
|
2923 s[1] == '|' ? IF_EB("\033|", ESC_STR "|") : |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
2924 #endif |
14007
5d6e8dedfc73
patch 8.1.0021: clang warns for undefined behavior
Christian Brabandt <cb@256bit.org>
parents:
13874
diff
changeset
|
2925 IF_EB("\033[", ESC_STR "[")) : "\233"; |
5d6e8dedfc73
patch 8.1.0021: clang warns for undefined behavior
Christian Brabandt <cb@256bit.org>
parents:
13874
diff
changeset
|
2926 char *tail = s[i] == '3' ? (n >= 16 ? "38;5;" : "9") |
5d6e8dedfc73
patch 8.1.0021: clang warns for undefined behavior
Christian Brabandt <cb@256bit.org>
parents:
13874
diff
changeset
|
2927 : (n >= 16 ? "48;5;" : "10"); |
5d6e8dedfc73
patch 8.1.0021: clang warns for undefined behavior
Christian Brabandt <cb@256bit.org>
parents:
13874
diff
changeset
|
2928 |
5d6e8dedfc73
patch 8.1.0021: clang warns for undefined behavior
Christian Brabandt <cb@256bit.org>
parents:
13874
diff
changeset
|
2929 sprintf(buf, format, lead, tail); |
7 | 2930 OUT_STR(tgoto(buf, 0, n >= 16 ? n : n - 8)); |
2931 } | |
2932 else | |
2933 OUT_STR(tgoto((char *)s, 0, n)); | |
2934 } | |
2935 | |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2936 void |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2937 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
|
2938 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2939 /* 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
|
2940 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
|
2941 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
|
2942 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
|
2943 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
|
2944 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2945 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2946 void |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2947 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
|
2948 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2949 /* 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
|
2950 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
|
2951 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
|
2952 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
|
2953 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
|
2954 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
2955 |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
2956 #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
|
2957 |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2958 #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
|
2959 #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
|
2960 #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
|
2961 |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2962 static void |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2963 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
|
2964 { |
8975
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
2965 #define MAX_COLOR_STR_LEN 100 |
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
2966 char buf[MAX_COLOR_STR_LEN]; |
9c097bfad637
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
2967 |
8981
3b51b0aeb9a3
commit https://github.com/vim/vim/commit/a1c487eef71d1673e57511453009de9cb4c9af51
Christian Brabandt <cb@256bit.org>
parents:
8977
diff
changeset
|
2968 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
|
2969 (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
|
2970 OUT_STR(buf); |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2971 } |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2972 |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2973 void |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2974 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
|
2975 { |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2976 term_rgb_color(T_8F, rgb); |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2977 } |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2978 |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2979 void |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2980 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
|
2981 { |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2982 term_rgb_color(T_8B, rgb); |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9929
diff
changeset
|
2983 } |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2984 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2985 |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7307
diff
changeset
|
2986 #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
|
2987 || defined(MACOS_X))) || defined(PROTO) |
7 | 2988 /* |
2989 * Generic function to set window title, using t_ts and t_fs. | |
2990 */ | |
2991 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2992 term_settitle(char_u *title) |
7 | 2993 { |
2994 /* t_ts takes one argument: column in status line */ | |
2995 OUT_STR(tgoto((char *)T_TS, 0, 0)); /* set title start */ | |
2996 out_str_nf(title); | |
2997 out_str(T_FS); /* set title end */ | |
2998 out_flush(); | |
2999 } | |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3000 |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3001 /* |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3002 * Tell the terminal to push (save) the title and/or icon, so that it can be |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3003 * popped (restored) later. |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3004 */ |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3005 void |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3006 term_push_title(int which) |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3007 { |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3008 if ((which & SAVE_RESTORE_TITLE) && *T_CST != NUL) |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3009 { |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3010 OUT_STR(T_CST); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3011 out_flush(); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3012 } |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3013 |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3014 if ((which & SAVE_RESTORE_ICON) && *T_SSI != NUL) |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3015 { |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3016 OUT_STR(T_SSI); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3017 out_flush(); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3018 } |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3019 } |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3020 |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3021 /* |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3022 * Tell the terminal to pop the title and/or icon. |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3023 */ |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3024 void |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3025 term_pop_title(int which) |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3026 { |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3027 if ((which & SAVE_RESTORE_TITLE) && *T_CRT != NUL) |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3028 { |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3029 OUT_STR(T_CRT); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3030 out_flush(); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3031 } |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3032 |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3033 if ((which & SAVE_RESTORE_ICON) && *T_SRI != NUL) |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3034 { |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3035 OUT_STR(T_SRI); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3036 out_flush(); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3037 } |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14461
diff
changeset
|
3038 } |
7 | 3039 #endif |
3040 | |
3041 /* | |
3042 * Make sure we have a valid set or terminal options. | |
3043 * Replace all entries that are NULL by empty_option | |
3044 */ | |
3045 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3046 ttest(int pairs) |
7 | 3047 { |
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
|
3048 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
|
3049 |
7 | 3050 check_options(); /* make sure no options are NULL */ |
3051 | |
3052 /* | |
3053 * MUST have "cm": cursor motion. | |
3054 */ | |
3055 if (*T_CM == NUL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
3056 emsg(_("E437: terminal capability \"cm\" required")); |
7 | 3057 |
3058 /* | |
3059 * if "cs" defined, use a scroll region, it's faster. | |
3060 */ | |
3061 if (*T_CS != NUL) | |
3062 scroll_region = TRUE; | |
3063 else | |
3064 scroll_region = FALSE; | |
3065 | |
3066 if (pairs) | |
3067 { | |
3068 /* | |
3069 * optional pairs | |
3070 */ | |
3071 /* TP goes to normal mode for TI (invert) and TB (bold) */ | |
3072 if (*T_ME == NUL) | |
3073 T_ME = T_MR = T_MD = T_MB = empty_option; | |
3074 if (*T_SO == NUL || *T_SE == NUL) | |
3075 T_SO = T_SE = empty_option; | |
3076 if (*T_US == NUL || *T_UE == NUL) | |
3077 T_US = T_UE = empty_option; | |
3078 if (*T_CZH == NUL || *T_CZR == NUL) | |
3079 T_CZH = T_CZR = empty_option; | |
3080 | |
3081 /* T_VE is needed even though T_VI is not defined */ | |
3082 if (*T_VE == NUL) | |
3083 T_VI = empty_option; | |
3084 | |
3085 /* if 'mr' or 'me' is not defined use 'so' and 'se' */ | |
3086 if (*T_ME == NUL) | |
3087 { | |
3088 T_ME = T_SE; | |
3089 T_MR = T_SO; | |
3090 T_MD = T_SO; | |
3091 } | |
3092 | |
3093 /* if 'so' or 'se' is not defined use 'mr' and 'me' */ | |
3094 if (*T_SO == NUL) | |
3095 { | |
3096 T_SE = T_ME; | |
3097 if (*T_MR == NUL) | |
3098 T_SO = T_MD; | |
3099 else | |
3100 T_SO = T_MR; | |
3101 } | |
3102 | |
3103 /* if 'ZH' or 'ZR' is not defined use 'mr' and 'me' */ | |
3104 if (*T_CZH == NUL) | |
3105 { | |
3106 T_CZR = T_ME; | |
3107 if (*T_MR == NUL) | |
3108 T_CZH = T_MD; | |
3109 else | |
3110 T_CZH = T_MR; | |
3111 } | |
3112 | |
3113 /* "Sb" and "Sf" come in pairs */ | |
3114 if (*T_CSB == NUL || *T_CSF == NUL) | |
3115 { | |
3116 T_CSB = empty_option; | |
3117 T_CSF = empty_option; | |
3118 } | |
3119 | |
3120 /* "AB" and "AF" come in pairs */ | |
3121 if (*T_CAB == NUL || *T_CAF == NUL) | |
3122 { | |
3123 T_CAB = empty_option; | |
3124 T_CAF = empty_option; | |
3125 } | |
3126 | |
3127 /* if 'Sb' and 'AB' are not defined, reset "Co" */ | |
3128 if (*T_CSB == NUL && *T_CAB == NUL) | |
1941 | 3129 free_one_termoption(T_CCO); |
7 | 3130 |
3131 /* Set 'weirdinvert' according to value of 't_xs' */ | |
3132 p_wiv = (*T_XS != NUL); | |
3133 } | |
3134 need_gather = TRUE; | |
3135 | |
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
|
3136 /* Set t_colors to the value of $COLORS or t_Co. */ |
7 | 3137 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
|
3138 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
|
3139 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
|
3140 { |
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
|
3141 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
|
3142 |
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
|
3143 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
|
3144 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
|
3145 } |
7 | 3146 } |
3147 | |
3148 #if (defined(FEAT_GUI) && (defined(FEAT_MENU) || !defined(USE_ON_FLY_SCROLL))) \ | |
3149 || defined(PROTO) | |
3150 /* | |
3151 * Represent the given long_u as individual bytes, with the most significant | |
3152 * byte first, and store them in dst. | |
3153 */ | |
3154 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3155 add_long_to_buf(long_u val, char_u *dst) |
7 | 3156 { |
3157 int i; | |
3158 int shift; | |
3159 | |
1883 | 3160 for (i = 1; i <= (int)sizeof(long_u); i++) |
7 | 3161 { |
3162 shift = 8 * (sizeof(long_u) - i); | |
3163 dst[i - 1] = (char_u) ((val >> shift) & 0xff); | |
3164 } | |
3165 } | |
3166 | |
3167 /* | |
3168 * Interpret the next string of bytes in buf as a long integer, with the most | |
3169 * significant byte first. Note that it is assumed that buf has been through | |
3170 * inchar(), so that NUL and K_SPECIAL will be represented as three bytes each. | |
3171 * Puts result in val, and returns the number of bytes read from buf | |
3172 * (between sizeof(long_u) and 2 * sizeof(long_u)), or -1 if not enough bytes | |
3173 * were present. | |
3174 */ | |
3175 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3176 get_long_from_buf(char_u *buf, long_u *val) |
7 | 3177 { |
3178 int len; | |
3179 char_u bytes[sizeof(long_u)]; | |
3180 int i; | |
3181 int shift; | |
3182 | |
3183 *val = 0; | |
3184 len = get_bytes_from_buf(buf, bytes, (int)sizeof(long_u)); | |
3185 if (len != -1) | |
3186 { | |
1883 | 3187 for (i = 0; i < (int)sizeof(long_u); i++) |
7 | 3188 { |
3189 shift = 8 * (sizeof(long_u) - 1 - i); | |
3190 *val += (long_u)bytes[i] << shift; | |
3191 } | |
3192 } | |
3193 return len; | |
3194 } | |
3195 #endif | |
3196 | |
3197 #if defined(FEAT_GUI) \ | |
1623 | 3198 || (defined(FEAT_MOUSE) && (!defined(UNIX) || defined(FEAT_MOUSE_XTERM) \ |
3199 || defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE))) | |
7 | 3200 /* |
3201 * Read the next num_bytes bytes from buf, and store them in bytes. Assume | |
3202 * that buf has been through inchar(). Returns the actual number of bytes used | |
3203 * from buf (between num_bytes and num_bytes*2), or -1 if not enough bytes were | |
3204 * available. | |
3205 */ | |
3206 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3207 get_bytes_from_buf(char_u *buf, char_u *bytes, int num_bytes) |
7 | 3208 { |
3209 int len = 0; | |
3210 int i; | |
3211 char_u c; | |
3212 | |
3213 for (i = 0; i < num_bytes; i++) | |
3214 { | |
3215 if ((c = buf[len++]) == NUL) | |
3216 return -1; | |
3217 if (c == K_SPECIAL) | |
3218 { | |
3219 if (buf[len] == NUL || buf[len + 1] == NUL) /* cannot happen? */ | |
3220 return -1; | |
3221 if (buf[len++] == (int)KS_ZERO) | |
3222 c = NUL; | |
5076
19ed30f7cef7
updated for version 7.3.1281
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
3223 /* 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
|
3224 * 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
|
3225 if (buf[len++] == (int)KE_CSI) |
19ed30f7cef7
updated for version 7.3.1281
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
3226 c = CSI; |
7 | 3227 } |
1160 | 3228 else if (c == CSI && buf[len] == KS_EXTRA |
3229 && buf[len + 1] == (int)KE_CSI) | |
667 | 3230 /* CSI is stored as CSI KS_SPECIAL KE_CSI to avoid confusion with |
3231 * the start of a special key, see add_to_input_buf_csi(). */ | |
3232 len += 2; | |
7 | 3233 bytes[i] = c; |
3234 } | |
3235 return len; | |
3236 } | |
3237 #endif | |
3238 | |
3239 /* | |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3240 * 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
|
3241 * too big. |
7 | 3242 */ |
3243 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3244 check_shellsize(void) |
7 | 3245 { |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3246 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
|
3247 Rows = min_rows(); |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3248 limit_screen_size(); |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3249 } |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3250 |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3251 /* |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3252 * 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
|
3253 */ |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3254 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3255 limit_screen_size(void) |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3256 { |
7 | 3257 if (Columns < MIN_COLUMNS) |
3258 Columns = MIN_COLUMNS; | |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3259 else if (Columns > 10000) |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3260 Columns = 10000; |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3261 if (Rows > 1000) |
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
4395
diff
changeset
|
3262 Rows = 1000; |
7 | 3263 } |
3264 | |
41 | 3265 /* |
3266 * Invoked just before the screen structures are going to be (re)allocated. | |
3267 */ | |
7 | 3268 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3269 win_new_shellsize(void) |
7 | 3270 { |
3271 static int old_Rows = 0; | |
3272 static int old_Columns = 0; | |
3273 | |
3274 if (old_Rows != Rows || old_Columns != Columns) | |
3275 ui_new_shellsize(); | |
3276 if (old_Rows != Rows) | |
3277 { | |
164 | 3278 /* if 'window' uses the whole screen, keep it using that */ |
179 | 3279 if (p_window == old_Rows - 1 || old_Rows == 0) |
164 | 3280 p_window = Rows - 1; |
7 | 3281 old_Rows = Rows; |
3282 shell_new_rows(); /* update window sizes */ | |
3283 } | |
3284 if (old_Columns != Columns) | |
3285 { | |
3286 old_Columns = Columns; | |
3287 shell_new_columns(); /* update window sizes */ | |
3288 } | |
3289 } | |
3290 | |
3291 /* | |
3292 * Call this function when the Vim shell has been resized in any way. | |
3293 * Will obtain the current size and redraw (also when size didn't change). | |
3294 */ | |
3295 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3296 shell_resized(void) |
7 | 3297 { |
3298 set_shellsize(0, 0, FALSE); | |
3299 } | |
3300 | |
3301 /* | |
3302 * Check if the shell size changed. Handle a resize. | |
3303 * When the size didn't change, nothing happens. | |
3304 */ | |
3305 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3306 shell_resized_check(void) |
7 | 3307 { |
3308 int old_Rows = Rows; | |
3309 int old_Columns = Columns; | |
3310 | |
3770 | 3311 if (!exiting |
3312 #ifdef FEAT_GUI | |
3313 /* Do not get the size when executing a shell command during | |
3314 * startup. */ | |
3315 && !gui.starting | |
3316 #endif | |
3317 ) | |
2673 | 3318 { |
3319 (void)ui_get_shellsize(); | |
3320 check_shellsize(); | |
3321 if (old_Rows != Rows || old_Columns != Columns) | |
3322 shell_resized(); | |
3323 } | |
7 | 3324 } |
3325 | |
3326 /* | |
3327 * Set size of the Vim shell. | |
3328 * If 'mustset' is TRUE, we must set Rows and Columns, do not get the real | |
3329 * window size (this is used for the :win command). | |
3330 * If 'mustset' is FALSE, we may try to get the real window size and if | |
3331 * it fails use 'width' and 'height'. | |
3332 */ | |
3333 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3334 set_shellsize(int width, int height, int mustset) |
7 | 3335 { |
3336 static int busy = FALSE; | |
3337 | |
3338 /* | |
3339 * Avoid recursiveness, can happen when setting the window size causes | |
3340 * another window-changed signal. | |
3341 */ | |
3342 if (busy) | |
3343 return; | |
3344 | |
3345 if (width < 0 || height < 0) /* just checking... */ | |
3346 return; | |
3347 | |
3068 | 3348 if (State == HITRETURN || State == SETWSIZE) |
7 | 3349 { |
3068 | 3350 /* postpone the resizing */ |
7 | 3351 State = SETWSIZE; |
3352 return; | |
3353 } | |
3354 | |
3068 | 3355 /* curwin->w_buffer can be NULL when we are closing a window and the |
3356 * buffer has already been closed and removing a scrollbar causes a resize | |
3357 * event. Don't resize then, it will happen after entering another buffer. | |
3358 */ | |
3359 if (curwin->w_buffer == NULL) | |
3360 return; | |
3361 | |
7 | 3362 ++busy; |
3363 | |
3364 #ifdef AMIGA | |
3365 out_flush(); /* must do this before mch_get_shellsize() for | |
3366 some obscure reason */ | |
3367 #endif | |
3368 | |
3369 if (mustset || (ui_get_shellsize() == FAIL && height != 0)) | |
3370 { | |
3371 Rows = height; | |
3372 Columns = width; | |
3373 check_shellsize(); | |
3374 ui_set_shellsize(mustset); | |
3375 } | |
3376 else | |
3377 check_shellsize(); | |
3378 | |
3379 /* The window layout used to be adjusted here, but it now happens in | |
3380 * screenalloc() (also invoked from screenclear()). That is because the | |
3381 * "busy" check above may skip this, but not screenalloc(). */ | |
3382 | |
3383 if (State != ASKMORE && State != EXTERNCMD && State != CONFIRM) | |
3384 screenclear(); | |
3385 else | |
3386 screen_start(); /* don't know where cursor is now */ | |
3387 | |
3388 if (starting != NO_SCREEN) | |
3389 { | |
3390 #ifdef FEAT_TITLE | |
3391 maketitle(); | |
3392 #endif | |
3393 changed_line_abv_curs(); | |
3394 invalidate_botline(); | |
3395 | |
3396 /* | |
3397 * We only redraw when it's needed: | |
3398 * - While at the more prompt or executing an external command, don't | |
3399 * redraw, but position the cursor. | |
3400 * - While editing the command line, only redraw that. | |
3401 * - in Ex mode, don't redraw anything. | |
3402 * - Otherwise, redraw right now, and position the cursor. | |
3403 * Always need to call update_screen() or screenalloc(), to make | |
3404 * sure Rows/Columns and the size of ScreenLines[] is correct! | |
3405 */ | |
3406 if (State == ASKMORE || State == EXTERNCMD || State == CONFIRM | |
3407 || exmode_active) | |
3408 { | |
3409 screenalloc(FALSE); | |
3410 repeat_message(); | |
3411 } | |
3412 else | |
3413 { | |
1024 | 3414 if (curwin->w_p_scb) |
3415 do_check_scrollbind(TRUE); | |
3416 if (State & CMDLINE) | |
648 | 3417 { |
1024 | 3418 update_screen(NOT_VALID); |
3419 redrawcmdline(); | |
648 | 3420 } |
3421 else | |
1024 | 3422 { |
3423 update_topline(); | |
3424 #if defined(FEAT_INS_EXPAND) | |
3425 if (pum_visible()) | |
3426 { | |
3427 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
|
3428 ins_compl_show_pum(); |
1024 | 3429 } |
648 | 3430 #endif |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12513
diff
changeset
|
3431 update_screen(NOT_VALID); |
1024 | 3432 if (redrawing()) |
3433 setcursor(); | |
3434 } | |
7 | 3435 } |
3436 cursor_on(); /* redrawing may have switched it off */ | |
3437 } | |
3438 out_flush(); | |
3439 --busy; | |
3440 } | |
3441 | |
3442 /* | |
3443 * Set the terminal to TMODE_RAW (for Normal mode) or TMODE_COOK (for external | |
3444 * commands and Ex mode). | |
3445 */ | |
3446 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3447 settmode(int tmode) |
7 | 3448 { |
3449 #ifdef FEAT_GUI | |
3450 /* don't set the term where gvim was started to any mode */ | |
3451 if (gui.in_use) | |
3452 return; | |
3453 #endif | |
3454 | |
3455 if (full_screen) | |
3456 { | |
3457 /* | |
3458 * When returning after calling a shell we want to really set the | |
3459 * terminal to raw mode, even though we think it already is, because | |
3460 * the shell program may have reset the terminal mode. | |
3461 * When we think the terminal is normal, don't try to set it to | |
3462 * normal again, because that causes problems (logout!) on some | |
3463 * machines. | |
3464 */ | |
3465 if (tmode != TMODE_COOK || cur_tmode != TMODE_COOK) | |
3466 { | |
3467 #ifdef FEAT_TERMRESPONSE | |
1691 | 3468 # ifdef FEAT_GUI |
3469 if (!gui.in_use && !gui.starting) | |
3470 # endif | |
3471 { | |
3472 /* May need to check for T_CRV response and termcodes, it | |
3473 * doesn't work in Cooked mode, an external program may get | |
3474 * 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
|
3475 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
|
3476 || 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
|
3477 #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
|
3478 || 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
|
3479 #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
|
3480 || 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
|
3481 || 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
|
3482 || 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
|
3483 || winpos_status == STATUS_SENT)) |
1691 | 3484 (void)vpeekc_nomap(); |
3485 check_for_codes_from_term(); | |
3486 } | |
7 | 3487 #endif |
3488 #ifdef FEAT_MOUSE_TTY | |
3489 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
|
3490 mch_setmouse(FALSE); /* switch mouse off */ |
7 | 3491 #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
|
3492 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
|
3493 out_str(T_BD); /* disable bracketed paste mode */ |
7 | 3494 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
|
3495 mch_settmode(tmode); /* machine specific function */ |
7 | 3496 cur_tmode = tmode; |
3497 #ifdef FEAT_MOUSE | |
3498 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
|
3499 setmouse(); /* may switch mouse on */ |
7 | 3500 #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
|
3501 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
|
3502 out_str(T_BE); /* enable bracketed paste mode */ |
7 | 3503 out_flush(); |
3504 } | |
3505 #ifdef FEAT_TERMRESPONSE | |
3506 may_req_termresponse(); | |
3507 #endif | |
3508 } | |
3509 } | |
3510 | |
3511 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3512 starttermcap(void) |
7 | 3513 { |
3514 if (full_screen && !termcap_active) | |
3515 { | |
3516 out_str(T_TI); /* start termcap mode */ | |
3517 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
|
3518 out_str(T_BE); /* enable bracketed paste mode */ |
7 | 3519 out_flush(); |
3520 termcap_active = TRUE; | |
3521 screen_start(); /* don't know where cursor is now */ | |
3522 #ifdef FEAT_TERMRESPONSE | |
1691 | 3523 # ifdef FEAT_GUI |
3524 if (!gui.in_use && !gui.starting) | |
3525 # endif | |
3526 { | |
3527 may_req_termresponse(); | |
3528 /* Immediately check for a response. If t_Co changes, we don't | |
3529 * 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
|
3530 if (crv_status == STATUS_SENT) |
1691 | 3531 check_for_codes_from_term(); |
3532 } | |
7 | 3533 #endif |
3534 } | |
3535 } | |
3536 | |
3537 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3538 stoptermcap(void) |
7 | 3539 { |
3540 screen_stop_highlight(); | |
3541 reset_cterm_colors(); | |
3542 if (termcap_active) | |
3543 { | |
3544 #ifdef FEAT_TERMRESPONSE | |
1691 | 3545 # ifdef FEAT_GUI |
3546 if (!gui.in_use && !gui.starting) | |
3547 # endif | |
3548 { | |
6874 | 3549 /* 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
|
3550 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
|
3551 || 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
|
3552 # 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
|
3553 || 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
|
3554 # 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
|
3555 || 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
|
3556 || 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
|
3557 || 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
|
3558 || winpos_status == STATUS_SENT) |
4391 | 3559 { |
3560 # ifdef UNIX | |
3561 /* Give the terminal a chance to respond. */ | |
3562 mch_delay(100L, FALSE); | |
3563 # endif | |
3564 # ifdef TCIFLUSH | |
3565 /* Discard data received but not read. */ | |
3566 if (exiting) | |
3567 tcflush(fileno(stdin), TCIFLUSH); | |
3568 # endif | |
3569 } | |
1691 | 3570 /* Check for termcodes first, otherwise an external program may |
3571 * get them. */ | |
3572 check_for_codes_from_term(); | |
3573 } | |
7 | 3574 #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
|
3575 out_str(T_BD); /* disable bracketed paste mode */ |
7 | 3576 out_str(T_KE); /* stop "keypad transmit" mode */ |
3577 out_flush(); | |
3578 termcap_active = FALSE; | |
3579 cursor_on(); /* just in case it is still off */ | |
3580 out_str(T_TE); /* stop termcap mode */ | |
3581 screen_start(); /* don't know where cursor is now */ | |
3582 out_flush(); | |
3583 } | |
3584 } | |
3585 | |
5932 | 3586 #if defined(FEAT_TERMRESPONSE) || defined(PROTO) |
7 | 3587 /* |
3588 * Request version string (for xterm) when needed. | |
3589 * Only do this after switching to raw mode, otherwise the result will be | |
3590 * echoed. | |
626 | 3591 * Only do this after startup has finished, to avoid that the response comes |
1221 | 3592 * while executing "-c !cmd" or even after "-c quit". |
7 | 3593 * Only do this after termcap mode has been started, otherwise the codes for |
3594 * the cursor keys may be wrong. | |
620 | 3595 * Only do this when 'esckeys' is on, otherwise the response causes trouble in |
3596 * Insert mode. | |
164 | 3597 * On Unix only do it when both output and input are a tty (avoid writing |
3598 * request to terminal while reading from a file). | |
7 | 3599 * The result is caught in check_termcode(). |
3600 */ | |
626 | 3601 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3602 may_req_termresponse(void) |
7 | 3603 { |
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
|
3604 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
|
3605 && can_get_termresponse() |
626 | 3606 && starting == 0 |
7 | 3607 && *T_CRV != NUL) |
3608 { | |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3609 LOG_TR(("Sending CRV request")); |
7 | 3610 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
|
3611 crv_status = STATUS_SENT; |
7 | 3612 /* check for the characters now, otherwise they might be eaten by |
3613 * get_keystroke() */ | |
3614 out_flush(); | |
3615 (void)vpeekc_nomap(); | |
3616 } | |
3617 } | |
4215 | 3618 |
3619 /* | |
3620 * 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
|
3621 * First, we move the cursor to (1, 0) and print a test ambiguous character |
4215 | 3622 * \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
|
3623 * 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
|
3624 * or if it is treated as double width, that will be (1, 2). |
4215 | 3625 * This function has the side effect that changes cursor position, so |
3626 * it must be called immediately after entering termcap mode. | |
3627 */ | |
3628 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3629 may_req_ambiguous_char_width(void) |
4215 | 3630 { |
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
|
3631 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
|
3632 && 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
|
3633 && starting == 0 |
4215 | 3634 && *T_U7 != NUL |
3635 && !option_was_set((char_u *)"ambiwidth")) | |
3636 { | |
3637 char_u buf[16]; | |
3638 | |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3639 LOG_TR(("Sending U7 request")); |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3640 /* 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
|
3641 * 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
|
3642 term_windgoto(1, 0); |
4215 | 3643 buf[mb_char2bytes(0x25bd, buf)] = 0; |
3644 out_str(buf); | |
3645 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
|
3646 u7_status = STATUS_SENT; |
5724 | 3647 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
|
3648 |
08e60ce4cbf3
patch 8.0.0611: the screen is not redrawn after sending t_u7
Christian Brabandt <cb@256bit.org>
parents:
11453
diff
changeset
|
3649 /* 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
|
3650 * after this. Clear them out for now. */ |
5724 | 3651 term_windgoto(1, 0); |
4215 | 3652 out_str((char_u *)" "); |
3653 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
|
3654 |
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
|
3655 /* 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
|
3656 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
|
3657 |
4215 | 3658 /* check for the characters now, otherwise they might be eaten by |
3659 * get_keystroke() */ | |
3660 out_flush(); | |
3661 (void)vpeekc_nomap(); | |
3662 } | |
3663 } | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3664 |
6874 | 3665 /* |
6885 | 3666 * Similar to requesting the version string: Request the terminal background |
3667 * color when it is the right moment. | |
6874 | 3668 */ |
3669 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3670 may_req_bg_color(void) |
6874 | 3671 { |
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
|
3672 if (can_get_termresponse() && starting == 0) |
6874 | 3673 { |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3674 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
|
3675 |
12640
a715f0b44532
patch 8.0.1198: older compilers don't know uint8_t
Christian Brabandt <cb@256bit.org>
parents:
12634
diff
changeset
|
3676 # 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
|
3677 /* 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
|
3678 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
|
3679 { |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3680 LOG_TR(("Sending FG request")); |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3681 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
|
3682 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
|
3683 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
|
3684 } |
12640
a715f0b44532
patch 8.0.1198: older compilers don't know uint8_t
Christian Brabandt <cb@256bit.org>
parents:
12634
diff
changeset
|
3685 # 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
|
3686 |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3687 /* 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
|
3688 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
|
3689 { |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3690 LOG_TR(("Sending BG request")); |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
3691 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
|
3692 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
|
3693 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
|
3694 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3695 |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
3696 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
|
3697 { |
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
|
3698 /* 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
|
3699 * 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
|
3700 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
|
3701 (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
|
3702 } |
6874 | 3703 } |
3704 } | |
3705 | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3706 # ifdef DEBUG_TERMRESPONSE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3707 static void |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3708 log_tr(const char *fmt, ...) |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3709 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3710 static FILE *fd_tr = NULL; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3711 static proftime_T start; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3712 proftime_T now; |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3713 va_list ap; |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3714 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3715 if (fd_tr == NULL) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3716 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3717 fd_tr = fopen("termresponse.log", "w"); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3718 profile_start(&start); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3719 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3720 now = start; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3721 profile_end(&now); |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3722 fprintf(fd_tr, "%s: %s ", profile_msg(&now), |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3723 must_redraw == NOT_VALID ? "NV" |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3724 : must_redraw == CLEAR ? "CL" : " "); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3725 va_start(ap, fmt); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3726 vfprintf(fd_tr, fmt, ap); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3727 va_end(ap); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3728 fputc('\n', fd_tr); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3729 fflush(fd_tr); |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3730 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
3731 # endif |
7 | 3732 #endif |
3733 | |
3734 /* | |
3735 * Return TRUE when saving and restoring the screen. | |
3736 */ | |
3737 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3738 swapping_screen(void) |
7 | 3739 { |
3740 return (full_screen && *T_TI != NUL); | |
3741 } | |
3742 | |
13489
24e8f9044bed
patch 8.0.1618: color Grey50 is missing in the compiled-in table
Christian Brabandt <cb@256bit.org>
parents:
13406
diff
changeset
|
3743 #if defined(FEAT_MOUSE) || defined(PROTO) |
7 | 3744 /* |
3745 * setmouse() - switch mouse on/off depending on current mode and 'mouse' | |
3746 */ | |
3747 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3748 setmouse(void) |
7 | 3749 { |
3750 # ifdef FEAT_MOUSE_TTY | |
3751 int checkfor; | |
3752 # endif | |
3753 | |
3754 # ifdef FEAT_MOUSESHAPE | |
3755 update_mouseshape(-1); | |
3756 # endif | |
3757 | |
3758 # ifdef FEAT_MOUSE_TTY /* Should be outside proc, but may break MOUSESHAPE */ | |
3759 # ifdef FEAT_GUI | |
3760 /* In the GUI the mouse is always enabled. */ | |
3761 if (gui.in_use) | |
3762 return; | |
3763 # endif | |
3764 /* be quick when mouse is off */ | |
3765 if (*p_mouse == NUL || has_mouse_termcode == 0) | |
3766 return; | |
3767 | |
3768 /* don't switch mouse on when not in raw mode (Ex mode) */ | |
3769 if (cur_tmode != TMODE_RAW) | |
3770 { | |
3771 mch_setmouse(FALSE); | |
3772 return; | |
3773 } | |
3774 | |
3775 if (VIsual_active) | |
3776 checkfor = MOUSE_VISUAL; | |
5735 | 3777 else if (State == HITRETURN || State == ASKMORE || State == SETWSIZE) |
7 | 3778 checkfor = MOUSE_RETURN; |
3779 else if (State & INSERT) | |
3780 checkfor = MOUSE_INSERT; | |
3781 else if (State & CMDLINE) | |
3782 checkfor = MOUSE_COMMAND; | |
3783 else if (State == CONFIRM || State == EXTERNCMD) | |
3784 checkfor = ' '; /* don't use mouse for ":confirm" or ":!cmd" */ | |
3785 else | |
3786 checkfor = MOUSE_NORMAL; /* assume normal mode */ | |
3787 | |
3788 if (mouse_has(checkfor)) | |
3789 mch_setmouse(TRUE); | |
3790 else | |
3791 mch_setmouse(FALSE); | |
3792 # endif | |
3793 } | |
3794 | |
3795 /* | |
3796 * Return TRUE if | |
3797 * - "c" is in 'mouse', or | |
3798 * - 'a' is in 'mouse' and "c" is in MOUSE_A, or | |
3799 * - the current buffer is a help file and 'h' is in 'mouse' and we are in a | |
3800 * normal editing mode (not at hit-return message). | |
3801 */ | |
3802 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3803 mouse_has(int c) |
7 | 3804 { |
3805 char_u *p; | |
3806 | |
3807 for (p = p_mouse; *p; ++p) | |
3808 switch (*p) | |
3809 { | |
3810 case 'a': if (vim_strchr((char_u *)MOUSE_A, c) != NULL) | |
3811 return TRUE; | |
3812 break; | |
3813 case MOUSE_HELP: if (c != MOUSE_RETURN && curbuf->b_help) | |
3814 return TRUE; | |
3815 break; | |
3816 default: if (c == *p) return TRUE; break; | |
3817 } | |
3818 return FALSE; | |
3819 } | |
3820 | |
3821 /* | |
3822 * Return TRUE when 'mousemodel' is set to "popup" or "popup_setpos". | |
3823 */ | |
3824 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3825 mouse_model_popup(void) |
7 | 3826 { |
3827 return (p_mousem[0] == 'p'); | |
3828 } | |
3829 #endif | |
3830 | |
3831 /* | |
3832 * By outputting the 'cursor very visible' termcap code, for some windowed | |
3833 * terminals this makes the screen scrolled to the correct position. | |
3834 * Used when starting Vim or returning from a shell. | |
3835 */ | |
3836 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3837 scroll_start(void) |
7 | 3838 { |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3839 if (*T_VS != NUL && *T_CVS != NUL) |
7 | 3840 { |
3841 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
|
3842 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
|
3843 screen_start(); /* don't know where cursor is now */ |
7 | 3844 } |
3845 } | |
3846 | |
3847 static int cursor_is_off = FALSE; | |
3848 | |
3849 /* | |
14581
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3850 * Enable the cursor without checking if it's already enabled. |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3851 */ |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3852 void |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3853 cursor_on_force(void) |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3854 { |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3855 out_str(T_VE); |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3856 cursor_is_off = FALSE; |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3857 } |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3858 |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3859 /* |
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3860 * Enable the cursor if it's currently off. |
7 | 3861 */ |
3862 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3863 cursor_on(void) |
7 | 3864 { |
3865 if (cursor_is_off) | |
14581
bb02e9e33026
patch 8.1.0304: no redraw when using a STOP signal on Vim and then CONT
Christian Brabandt <cb@256bit.org>
parents:
14577
diff
changeset
|
3866 cursor_on_force(); |
7 | 3867 } |
3868 | |
3869 /* | |
3870 * Disable the cursor. | |
3871 */ | |
3872 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3873 cursor_off(void) |
7 | 3874 { |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3875 if (full_screen && !cursor_is_off) |
7 | 3876 { |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3877 out_str(T_VI); /* disable cursor */ |
7 | 3878 cursor_is_off = TRUE; |
3879 } | |
3880 } | |
3881 | |
39 | 3882 #if defined(CURSOR_SHAPE) || defined(PROTO) |
7 | 3883 /* |
6727 | 3884 * Set cursor shape to match Insert or Replace mode. |
36 | 3885 */ |
3886 void | |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3887 term_cursor_mode(int forced) |
36 | 3888 { |
12078
d21b8f31b296
patch 8.0.0919: cursor color isn't set on startup
Christian Brabandt <cb@256bit.org>
parents:
12076
diff
changeset
|
3889 static int showing_mode = -1; |
6727 | 3890 char_u *p; |
3891 | |
3892 /* Only do something when redrawing the screen and we can restore the | |
3893 * mode. */ | |
3894 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
|
3895 { |
12184
76fbd85c3cea
patch 8.0.0972: compiler warnings for unused variables
Christian Brabandt <cb@256bit.org>
parents:
12174
diff
changeset
|
3896 # 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
|
3897 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
|
3898 /* 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
|
3899 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
|
3900 # endif |
36 | 3901 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
|
3902 } |
36 | 3903 |
6727 | 3904 if ((State & REPLACE) == REPLACE) |
36 | 3905 { |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3906 if (forced || showing_mode != REPLACE) |
6727 | 3907 { |
3908 if (*T_CSR != NUL) | |
3909 p = T_CSR; /* Replace mode cursor */ | |
3910 else | |
3911 p = T_CSI; /* fall back to Insert mode cursor */ | |
3912 if (*p != NUL) | |
3913 { | |
3914 out_str(p); | |
3915 showing_mode = REPLACE; | |
3916 } | |
3917 } | |
36 | 3918 } |
6727 | 3919 else if (State & INSERT) |
36 | 3920 { |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3921 if ((forced || showing_mode != INSERT) && *T_CSI != NUL) |
6727 | 3922 { |
3923 out_str(T_CSI); /* Insert mode cursor */ | |
3924 showing_mode = INSERT; | |
3925 } | |
3926 } | |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3927 else if (forced || showing_mode != NORMAL) |
6727 | 3928 { |
3929 out_str(T_CEI); /* non-Insert mode cursor */ | |
3930 showing_mode = NORMAL; | |
36 | 3931 } |
3932 } | |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3933 |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3934 # 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
|
3935 void |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3936 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
|
3937 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3938 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
|
3939 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3940 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
|
3941 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
|
3942 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
|
3943 out_flush(); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3944 } |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3945 } |
12172
444793fce117
patch 8.0.0966: build failure without terminal feature
Christian Brabandt <cb@256bit.org>
parents:
12170
diff
changeset
|
3946 # endif |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3947 |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3948 int |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3949 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
|
3950 { |
12261
875d7cc9b127
patch 8.0.1010: build failure without termresponse feature
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3951 #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
|
3952 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
|
3953 && 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
|
3954 #else |
875d7cc9b127
patch 8.0.1010: build failure without termresponse feature
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3955 return FALSE; |
875d7cc9b127
patch 8.0.1010: build failure without termresponse feature
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3956 #endif |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3957 } |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3958 |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3959 /* |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3960 * "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
|
3961 */ |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3962 void |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3963 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
|
3964 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3965 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
|
3966 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3967 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
|
3968 out_flush(); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3969 } |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3970 else |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3971 { |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3972 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
|
3973 |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3974 /* 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
|
3975 * 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
|
3976 * 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
|
3977 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
|
3978 do_blink = !blink; |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3979 |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3980 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
|
3981 { |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3982 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
|
3983 out_flush(); |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3984 } |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3985 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
|
3986 { |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3987 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
|
3988 out_flush(); |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
3989 } |
12186
36456f237c59
patch 8.0.0973: initial info about blinking cursor is wrong
Christian Brabandt <cb@256bit.org>
parents:
12184
diff
changeset
|
3990 } |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
11784
diff
changeset
|
3991 } |
39 | 3992 #endif |
36 | 3993 |
3994 /* | |
7 | 3995 * Set scrolling region for window 'wp'. |
3996 * The region starts 'off' lines from the start of the window. | |
3997 * Also set the vertical scroll region for a vertically split window. Always | |
3998 * the full width of the window, excluding the vertical separator. | |
3999 */ | |
4000 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4001 scroll_region_set(win_T *wp, int off) |
7 | 4002 { |
4003 OUT_STR(tgoto((char *)T_CS, W_WINROW(wp) + wp->w_height - 1, | |
4004 W_WINROW(wp) + off)); | |
4005 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
|
4006 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
|
4007 wp->w_wincol)); |
7 | 4008 screen_start(); /* don't know where cursor is now */ |
4009 } | |
4010 | |
4011 /* | |
4012 * Reset scrolling region to the whole screen. | |
4013 */ | |
4014 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4015 scroll_region_reset(void) |
7 | 4016 { |
4017 OUT_STR(tgoto((char *)T_CS, (int)Rows - 1, 0)); | |
4018 if (*T_CSV != NUL) | |
4019 OUT_STR(tgoto((char *)T_CSV, (int)Columns - 1, 0)); | |
4020 screen_start(); /* don't know where cursor is now */ | |
4021 } | |
4022 | |
4023 | |
4024 /* | |
4025 * List of terminal codes that are currently recognized. | |
4026 */ | |
4027 | |
298 | 4028 static struct termcode |
7 | 4029 { |
4030 char_u name[2]; /* termcap name of entry */ | |
4031 char_u *code; /* terminal code (in allocated memory) */ | |
4032 int len; /* STRLEN(code) */ | |
179 | 4033 int modlen; /* length of part before ";*~". */ |
7 | 4034 } *termcodes = NULL; |
4035 | |
4036 static int tc_max_len = 0; /* number of entries that termcodes[] can hold */ | |
4037 static int tc_len = 0; /* current number of entries in termcodes[] */ | |
4038 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
4039 static int termcode_star(char_u *code, int len); |
180 | 4040 |
7 | 4041 void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4042 clear_termcodes(void) |
7 | 4043 { |
4044 while (tc_len > 0) | |
4045 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
|
4046 VIM_CLEAR(termcodes); |
7 | 4047 tc_max_len = 0; |
4048 | |
4049 #ifdef HAVE_TGETENT | |
4050 BC = (char *)empty_option; | |
4051 UP = (char *)empty_option; | |
4052 PC = NUL; /* set pad character to NUL */ | |
4053 ospeed = 0; | |
4054 #endif | |
4055 | |
4056 need_gather = TRUE; /* need to fill termleader[] */ | |
4057 } | |
4058 | |
180 | 4059 #define ATC_FROM_TERM 55 |
4060 | |
7 | 4061 /* |
4062 * Add a new entry to the list of terminal codes. | |
4063 * The list is kept alphabetical for ":set termcap" | |
180 | 4064 * "flags" is TRUE when replacing 7-bit by 8-bit controls is desired. |
4065 * "flags" can also be ATC_FROM_TERM for got_code_from_term(). | |
7 | 4066 */ |
4067 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4068 add_termcode(char_u *name, char_u *string, int flags) |
7 | 4069 { |
4070 struct termcode *new_tc; | |
4071 int i, j; | |
4072 char_u *s; | |
179 | 4073 int len; |
7 | 4074 |
4075 if (string == NULL || *string == NUL) | |
4076 { | |
4077 del_termcode(name); | |
4078 return; | |
4079 } | |
4080 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15852
diff
changeset
|
4081 #if defined(MSWIN) && !defined(FEAT_GUI) |
6047 | 4082 s = vim_strnsave(string, (int)STRLEN(string) + 1); |
4083 #else | |
7 | 4084 s = vim_strsave(string); |
6047 | 4085 #endif |
7 | 4086 if (s == NULL) |
4087 return; | |
4088 | |
4089 /* Change leading <Esc>[ to CSI, change <Esc>O to <M-O>. */ | |
180 | 4090 if (flags != 0 && flags != ATC_FROM_TERM && term_7to8bit(string) != 0) |
7 | 4091 { |
1623 | 4092 STRMOVE(s, s + 1); |
7 | 4093 s[0] = term_7to8bit(string); |
4094 } | |
6047 | 4095 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15852
diff
changeset
|
4096 #if defined(MSWIN) && !defined(FEAT_GUI) |
6047 | 4097 if (s[0] == K_NUL) |
4098 { | |
6102 | 4099 STRMOVE(s + 1, s); |
4100 s[1] = 3; | |
6047 | 4101 } |
4102 #endif | |
4103 | |
179 | 4104 len = (int)STRLEN(s); |
7 | 4105 |
4106 need_gather = TRUE; /* need to fill termleader[] */ | |
4107 | |
4108 /* | |
4109 * need to make space for more entries | |
4110 */ | |
4111 if (tc_len == tc_max_len) | |
4112 { | |
4113 tc_max_len += 20; | |
4114 new_tc = (struct termcode *)alloc( | |
4115 (unsigned)(tc_max_len * sizeof(struct termcode))); | |
4116 if (new_tc == NULL) | |
4117 { | |
4118 tc_max_len -= 20; | |
4119 return; | |
4120 } | |
4121 for (i = 0; i < tc_len; ++i) | |
4122 new_tc[i] = termcodes[i]; | |
4123 vim_free(termcodes); | |
4124 termcodes = new_tc; | |
4125 } | |
4126 | |
4127 /* | |
4128 * Look for existing entry with the same name, it is replaced. | |
4129 * Look for an existing entry that is alphabetical higher, the new entry | |
4130 * is inserted in front of it. | |
4131 */ | |
4132 for (i = 0; i < tc_len; ++i) | |
4133 { | |
4134 if (termcodes[i].name[0] < name[0]) | |
4135 continue; | |
4136 if (termcodes[i].name[0] == name[0]) | |
4137 { | |
4138 if (termcodes[i].name[1] < name[1]) | |
4139 continue; | |
4140 /* | |
180 | 4141 * Exact match: May replace old code. |
7 | 4142 */ |
4143 if (termcodes[i].name[1] == name[1]) | |
4144 { | |
180 | 4145 if (flags == ATC_FROM_TERM && (j = termcode_star( |
4146 termcodes[i].code, termcodes[i].len)) > 0) | |
179 | 4147 { |
180 | 4148 /* Don't replace ESC[123;*X or ESC O*X with another when |
4149 * invoked from got_code_from_term(). */ | |
4150 if (len == termcodes[i].len - j | |
179 | 4151 && STRNCMP(s, termcodes[i].code, len - 1) == 0 |
180 | 4152 && s[len - 1] |
4153 == termcodes[i].code[termcodes[i].len - 1]) | |
179 | 4154 { |
180 | 4155 /* They are equal but for the ";*": don't add it. */ |
179 | 4156 vim_free(s); |
4157 return; | |
4158 } | |
4159 } | |
4160 else | |
4161 { | |
180 | 4162 /* Replace old code. */ |
179 | 4163 vim_free(termcodes[i].code); |
4164 --tc_len; | |
4165 break; | |
4166 } | |
7 | 4167 } |
4168 } | |
4169 /* | |
4170 * Found alphabetical larger entry, move rest to insert new entry | |
4171 */ | |
4172 for (j = tc_len; j > i; --j) | |
4173 termcodes[j] = termcodes[j - 1]; | |
4174 break; | |
4175 } | |
4176 | |
4177 termcodes[i].name[0] = name[0]; | |
4178 termcodes[i].name[1] = name[1]; | |
4179 termcodes[i].code = s; | |
179 | 4180 termcodes[i].len = len; |
180 | 4181 |
4182 /* For xterm we recognize special codes like "ESC[42;*X" and "ESC O*X" that | |
4183 * accept modifiers. */ | |
4184 termcodes[i].modlen = 0; | |
4185 j = termcode_star(s, len); | |
4186 if (j > 0) | |
4187 termcodes[i].modlen = len - 1 - j; | |
7 | 4188 ++tc_len; |
4189 } | |
4190 | |
180 | 4191 /* |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
4192 * Check termcode "code[len]" for ending in ;*X or *X. |
180 | 4193 * 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
|
4194 * Return 0 if not found, 2 for ;*X and 1 for *X. |
180 | 4195 */ |
4196 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4197 termcode_star(char_u *code, int len) |
180 | 4198 { |
4199 /* Shortest is <M-O>*X. With ; shortest is <CSI>1;*X */ | |
4200 if (len >= 3 && code[len - 2] == '*') | |
4201 { | |
4202 if (len >= 5 && code[len - 3] == ';') | |
4203 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
|
4204 else |
180 | 4205 return 1; |
4206 } | |
4207 return 0; | |
4208 } | |
4209 | |
7 | 4210 char_u * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4211 find_termcode(char_u *name) |
7 | 4212 { |
4213 int i; | |
4214 | |
4215 for (i = 0; i < tc_len; ++i) | |
4216 if (termcodes[i].name[0] == name[0] && termcodes[i].name[1] == name[1]) | |
4217 return termcodes[i].code; | |
4218 return NULL; | |
4219 } | |
4220 | |
4221 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) | |
4222 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4223 get_termcode(int i) |
7 | 4224 { |
4225 if (i >= tc_len) | |
4226 return NULL; | |
4227 return &termcodes[i].name[0]; | |
4228 } | |
4229 #endif | |
4230 | |
4231 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4232 del_termcode(char_u *name) |
7 | 4233 { |
4234 int i; | |
4235 | |
4236 if (termcodes == NULL) /* nothing there yet */ | |
4237 return; | |
4238 | |
4239 need_gather = TRUE; /* need to fill termleader[] */ | |
4240 | |
4241 for (i = 0; i < tc_len; ++i) | |
4242 if (termcodes[i].name[0] == name[0] && termcodes[i].name[1] == name[1]) | |
4243 { | |
4244 del_termcode_idx(i); | |
4245 return; | |
4246 } | |
4247 /* not found. Give error message? */ | |
4248 } | |
4249 | |
4250 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4251 del_termcode_idx(int idx) |
7 | 4252 { |
4253 int i; | |
4254 | |
4255 vim_free(termcodes[idx].code); | |
4256 --tc_len; | |
4257 for (i = idx; i < tc_len; ++i) | |
4258 termcodes[i] = termcodes[i + 1]; | |
4259 } | |
4260 | |
4261 #ifdef FEAT_TERMRESPONSE | |
4262 /* | |
4263 * Called when detected that the terminal sends 8-bit codes. | |
4264 * Convert all 7-bit codes to their 8-bit equivalent. | |
4265 */ | |
4266 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4267 switch_to_8bit(void) |
7 | 4268 { |
4269 int i; | |
4270 int c; | |
4271 | |
4272 /* Only need to do something when not already using 8-bit codes. */ | |
4273 if (!term_is_8bit(T_NAME)) | |
4274 { | |
4275 for (i = 0; i < tc_len; ++i) | |
4276 { | |
4277 c = term_7to8bit(termcodes[i].code); | |
4278 if (c != 0) | |
4279 { | |
1623 | 4280 STRMOVE(termcodes[i].code + 1, termcodes[i].code + 2); |
7 | 4281 termcodes[i].code[0] = c; |
4282 } | |
4283 } | |
4284 need_gather = TRUE; /* need to fill termleader[] */ | |
4285 } | |
4286 detected_8bit = TRUE; | |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
4287 LOG_TR(("Switching to 8 bit")); |
7 | 4288 } |
4289 #endif | |
4290 | |
4291 #ifdef CHECK_DOUBLE_CLICK | |
4292 static linenr_T orig_topline = 0; | |
4293 # ifdef FEAT_DIFF | |
4294 static int orig_topfill = 0; | |
4295 # endif | |
4296 #endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12429
diff
changeset
|
4297 #if defined(CHECK_DOUBLE_CLICK) || defined(PROTO) |
7 | 4298 /* |
4299 * Checking for double clicks ourselves. | |
4300 * "orig_topline" is used to avoid detecting a double-click when the window | |
4301 * contents scrolled (e.g., when 'scrolloff' is non-zero). | |
4302 */ | |
4303 /* | |
4304 * Set orig_topline. Used when jumping to another window, so that a double | |
4305 * click still works. | |
4306 */ | |
4307 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4308 set_mouse_topline(win_T *wp) |
7 | 4309 { |
4310 orig_topline = wp->w_topline; | |
4311 # ifdef FEAT_DIFF | |
4312 orig_topfill = wp->w_topfill; | |
4313 # endif | |
4314 } | |
4315 #endif | |
4316 | |
4317 /* | |
4318 * Check if typebuf.tb_buf[] contains a terminal key code. | |
4319 * Check from typebuf.tb_buf[typebuf.tb_off] to typebuf.tb_buf[typebuf.tb_off | |
4320 * + max_offset]. | |
4321 * Return 0 for no match, -1 for partial match, > 0 for full match. | |
2672 | 4322 * Return KEYLEN_REMOVED when a key code was deleted. |
7 | 4323 * With a match, the match is removed, the replacement code is inserted in |
4324 * typebuf.tb_buf[] and the number of characters in typebuf.tb_buf[] is | |
4325 * returned. | |
3328 | 4326 * When "buf" is not NULL, buf[bufsize] is used instead of typebuf.tb_buf[]. |
4327 * "buflen" is then the length of the string in buf[] and is updated for | |
4328 * inserts and deletes. | |
7 | 4329 */ |
4330 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4331 check_termcode( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4332 int max_offset, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4333 char_u *buf, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4334 int bufsize, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4335 int *buflen) |
7 | 4336 { |
4337 char_u *tp; | |
4338 char_u *p; | |
4339 int slen = 0; /* init for GCC */ | |
180 | 4340 int modslen; |
7 | 4341 int len; |
2672 | 4342 int retval = 0; |
7 | 4343 int offset; |
4344 char_u key_name[2]; | |
180 | 4345 int modifiers; |
11565
91519a14ec1f
patch 8.0.0665: warning for uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
11563
diff
changeset
|
4346 char_u *modifiers_start = NULL; |
180 | 4347 int key; |
7 | 4348 int new_slen; |
4349 int extra; | |
4350 char_u string[MAX_KEY_CODE_LEN + 1]; | |
4351 int i, j; | |
4352 int idx = 0; | |
4353 #ifdef FEAT_MOUSE | |
1623 | 4354 # if !defined(UNIX) || defined(FEAT_MOUSE_XTERM) || defined(FEAT_GUI) \ |
4355 || defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE) | |
7 | 4356 char_u bytes[6]; |
4357 int num_bytes; | |
4358 # endif | |
4359 int mouse_code = 0; /* init for GCC */ | |
4360 int is_click, is_drag; | |
4361 int wheel_code = 0; | |
4362 int current_button; | |
4363 static int held_button = MOUSE_RELEASE; | |
4364 static int orig_num_clicks = 1; | |
4365 static int orig_mouse_code = 0x0; | |
4366 # ifdef CHECK_DOUBLE_CLICK | |
4367 static int orig_mouse_col = 0; | |
4368 static int orig_mouse_row = 0; | |
4369 static struct timeval orig_mouse_time = {0, 0}; | |
4370 /* time of previous mouse click */ | |
4371 struct timeval mouse_time; /* time of current mouse click */ | |
4372 long timediff; /* elapsed time in msec */ | |
4373 # endif | |
4374 #endif | |
4375 int cpo_koffset; | |
4376 #ifdef FEAT_MOUSE_GPM | |
4377 extern int gpm_flag; /* gpm library variable */ | |
4378 #endif | |
4379 | |
4380 cpo_koffset = (vim_strchr(p_cpo, CPO_KOFFSET) != NULL); | |
4381 | |
4382 /* | |
4383 * Speed up the checks for terminal codes by gathering all first bytes | |
4384 * used in termleader[]. Often this is just a single <Esc>. | |
4385 */ | |
4386 if (need_gather) | |
4387 gather_termleader(); | |
4388 | |
4389 /* | |
4390 * Check at several positions in typebuf.tb_buf[], to catch something like | |
4391 * "x<Up>" that can be mapped. Stop at max_offset, because characters | |
4392 * after that cannot be used for mapping, and with @r commands | |
4223 | 4393 * typebuf.tb_buf[] can become very long. |
7 | 4394 * This is used often, KEEP IT FAST! |
4395 */ | |
4396 for (offset = 0; offset < max_offset; ++offset) | |
4397 { | |
4398 if (buf == NULL) | |
4399 { | |
4400 if (offset >= typebuf.tb_len) | |
4401 break; | |
4402 tp = typebuf.tb_buf + typebuf.tb_off + offset; | |
4403 len = typebuf.tb_len - offset; /* length of the input */ | |
4404 } | |
4405 else | |
4406 { | |
3328 | 4407 if (offset >= *buflen) |
7 | 4408 break; |
4409 tp = buf + offset; | |
3328 | 4410 len = *buflen - offset; |
7 | 4411 } |
4412 | |
4413 /* | |
4414 * Don't check characters after K_SPECIAL, those are already | |
4415 * translated terminal chars (avoid translating ~@^Hx). | |
4416 */ | |
4417 if (*tp == K_SPECIAL) | |
4418 { | |
4419 offset += 2; /* there are always 2 extra characters */ | |
4420 continue; | |
4421 } | |
4422 | |
4423 /* | |
4424 * Skip this position if the character does not appear as the first | |
4425 * character in term_strings. This speeds up a lot, since most | |
4426 * termcodes start with the same character (ESC or CSI). | |
4427 */ | |
4428 i = *tp; | |
4429 for (p = termleader; *p && *p != i; ++p) | |
4430 ; | |
4431 if (*p == NUL) | |
4432 continue; | |
4433 | |
4434 /* | |
4435 * Skip this position if p_ek is not set and tp[0] is an ESC and we | |
4436 * are in Insert mode. | |
4437 */ | |
4438 if (*tp == ESC && !p_ek && (State & INSERT)) | |
4439 continue; | |
4440 | |
4441 key_name[0] = NUL; /* no key name found yet */ | |
699 | 4442 key_name[1] = NUL; /* no key name found yet */ |
180 | 4443 modifiers = 0; /* no modifiers yet */ |
7 | 4444 |
4445 #ifdef FEAT_GUI | |
4446 if (gui.in_use) | |
4447 { | |
4448 /* | |
4449 * GUI special key codes are all of the form [CSI xx]. | |
4450 */ | |
4451 if (*tp == CSI) /* Special key from GUI */ | |
4452 { | |
4453 if (len < 3) | |
4454 return -1; /* Shouldn't happen */ | |
4455 slen = 3; | |
4456 key_name[0] = tp[1]; | |
4457 key_name[1] = tp[2]; | |
4458 } | |
4459 } | |
4460 else | |
4461 #endif /* FEAT_GUI */ | |
4462 { | |
4463 for (idx = 0; idx < tc_len; ++idx) | |
4464 { | |
4465 /* | |
4466 * Ignore the entry if we are not at the start of | |
4467 * typebuf.tb_buf[] | |
4468 * and there are not enough characters to make a match. | |
4469 * But only when the 'K' flag is in 'cpoptions'. | |
4470 */ | |
4471 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
|
4472 modifiers_start = NULL; |
7 | 4473 if (cpo_koffset && offset && len < slen) |
4474 continue; | |
4475 if (STRNCMP(termcodes[idx].code, tp, | |
4476 (size_t)(slen > len ? len : slen)) == 0) | |
4477 { | |
4478 if (len < slen) /* got a partial sequence */ | |
4479 return -1; /* need to get more chars */ | |
4480 | |
4481 /* | |
4482 * When found a keypad key, check if there is another key | |
4483 * that matches and use that one. This makes <Home> to be | |
4484 * found instead of <kHome> when they produce the same | |
4485 * key code. | |
4486 */ | |
4487 if (termcodes[idx].name[0] == 'K' | |
4488 && VIM_ISDIGIT(termcodes[idx].name[1])) | |
4489 { | |
4490 for (j = idx + 1; j < tc_len; ++j) | |
4491 if (termcodes[j].len == slen && | |
4492 STRNCMP(termcodes[idx].code, | |
4493 termcodes[j].code, slen) == 0) | |
4494 { | |
4495 idx = j; | |
4496 break; | |
4497 } | |
4498 } | |
4499 | |
4500 key_name[0] = termcodes[idx].name[0]; | |
4501 key_name[1] = termcodes[idx].name[1]; | |
4502 break; | |
4503 } | |
179 | 4504 |
4505 /* | |
4506 * Check for code with modifier, like xterm uses: | |
180 | 4507 * <Esc>[123;*X (modslen == slen - 3) |
4508 * Also <Esc>O*X and <M-O>*X (modslen == slen - 2). | |
4509 * When there is a modifier the * matches a number. | |
4510 * When there is no modifier the ;* or * is omitted. | |
179 | 4511 */ |
4512 if (termcodes[idx].modlen > 0) | |
4513 { | |
180 | 4514 modslen = termcodes[idx].modlen; |
4515 if (cpo_koffset && offset && len < modslen) | |
179 | 4516 continue; |
4517 if (STRNCMP(termcodes[idx].code, tp, | |
180 | 4518 (size_t)(modslen > len ? len : modslen)) == 0) |
179 | 4519 { |
4520 int n; | |
180 | 4521 |
4522 if (len <= modslen) /* got a partial sequence */ | |
179 | 4523 return -1; /* need to get more chars */ |
4524 | |
180 | 4525 if (tp[modslen] == termcodes[idx].code[slen - 1]) |
4526 slen = modslen + 1; /* no modifiers */ | |
4527 else if (tp[modslen] != ';' && modslen == slen - 3) | |
179 | 4528 continue; /* no match */ |
4529 else | |
4530 { | |
4531 /* Skip over the digits, the final char must | |
4532 * 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
|
4533 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
|
4534 || tp[j] == ';'); ++j) |
179 | 4535 ; |
4536 ++j; | |
4537 if (len < j) /* got a partial sequence */ | |
4538 return -1; /* need to get more chars */ | |
180 | 4539 if (tp[j - 1] != termcodes[idx].code[slen - 1]) |
4540 continue; /* no match */ | |
179 | 4541 |
11557
7e5e76d8d451
patch 8.0.0661: recognizing urxvt mouse codes does not work well
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
4542 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
|
4543 |
179 | 4544 /* 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
|
4545 n = atoi((char *)modifiers_start) - 1; |
179 | 4546 if (n & 1) |
180 | 4547 modifiers |= MOD_MASK_SHIFT; |
179 | 4548 if (n & 2) |
180 | 4549 modifiers |= MOD_MASK_ALT; |
179 | 4550 if (n & 4) |
180 | 4551 modifiers |= MOD_MASK_CTRL; |
179 | 4552 if (n & 8) |
180 | 4553 modifiers |= MOD_MASK_META; |
179 | 4554 |
4555 slen = j; | |
4556 } | |
4557 key_name[0] = termcodes[idx].name[0]; | |
4558 key_name[1] = termcodes[idx].name[1]; | |
4559 break; | |
4560 } | |
4561 } | |
7 | 4562 } |
4563 } | |
4564 | |
4565 #ifdef FEAT_TERMRESPONSE | |
3166 | 4566 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
|
4567 /* Mouse codes of DEC and pterm start with <ESC>[. When |
6102 | 4568 * detecting the start of these mouse codes they might as well be |
4569 * another key code or terminal response. */ | |
4570 # ifdef FEAT_MOUSE_DEC | |
4571 || key_name[0] == KS_DEC_MOUSE | |
4572 # endif | |
4573 # ifdef FEAT_MOUSE_PTERM | |
4574 || key_name[0] == KS_PTERM_MOUSE | |
4223 | 4575 # endif |
6102 | 4576 ) |
7 | 4577 { |
6102 | 4578 /* Check for some responses from the terminal starting with |
4579 * "<Esc>[" or CSI: | |
4215 | 4580 * |
6102 | 4581 * - 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
|
4582 * Libvterm returns {x} == 0, {vers} == 100, {y} == 0. |
4215 | 4583 * Also eat other possible responses to t_RV, rxvt returns |
4584 * "<Esc>[?1;2c". Also accept CSI instead of <Esc>[. | |
4585 * mrxvt has been reported to have "+" in the version. Assume | |
4586 * the escape sequence ends with a letter or one of "{|}~". | |
4587 * | |
6102 | 4588 * - Cursor position report: <Esc>[{row};{col}R |
4589 * The final byte must be 'R'. It is used for checking the | |
4215 | 4590 * 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
|
4591 * |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4592 * - window position reply: <Esc>[3;{x};{y}t |
4215 | 4593 */ |
6901 | 4594 char_u *argp = tp[0] == ESC ? tp + 2 : tp + 1; |
4595 | |
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
|
4596 if ((*T_CRV != NUL || *T_U7 != NUL || did_request_winpos) |
6901 | 4597 && ((tp[0] == ESC && len >= 3 && tp[1] == '[') |
4395 | 4598 || (tp[0] == CSI && len >= 2)) |
6874 | 4599 && (VIM_ISDIGIT(*argp) || *argp == '>' || *argp == '?')) |
7 | 4600 { |
11784
80fa4b0eb0b0
patch 8.0.0774: build failure without the multi-byte feature
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
4601 int col = 0; |
80fa4b0eb0b0
patch 8.0.0774: build failure without the multi-byte feature
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
4602 int semicols = 0; |
5743 | 4603 int row_char = NUL; |
11784
80fa4b0eb0b0
patch 8.0.0774: build failure without the multi-byte feature
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
4604 |
7 | 4605 extra = 0; |
1552 | 4606 for (i = 2 + (tp[0] != CSI); i < len |
4607 && !(tp[i] >= '{' && tp[i] <= '~') | |
4608 && !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
|
4609 if (tp[i] == ';' && ++semicols == 1) |
5724 | 4610 { |
4395 | 4611 extra = i + 1; |
5724 | 4612 row_char = tp[i - 1]; |
4613 } | |
7 | 4614 if (i == len) |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4615 { |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
4616 LOG_TR(("Not enough characters for CRV")); |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4617 return -1; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4618 } |
5724 | 4619 if (extra > 0) |
4620 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
|
4621 |
5724 | 4622 /* Eat it when it has 2 arguments and ends in 'R'. Also when |
4623 * u7_status is not "sent", it may be from a previous Vim that | |
4624 * just exited. But not for <S-F3>, it sends something | |
4625 * 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
|
4626 if (semicols == 1 && tp[i] == 'R') |
4215 | 4627 { |
6102 | 4628 if (row_char == '2' && col >= 2) |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4629 { |
6102 | 4630 char *aw = NULL; |
4631 | |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
4632 LOG_TR(("Received U7 status: %s", tp)); |
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
|
4633 u7_status = STATUS_GOT; |
6102 | 4634 did_cursorhold = TRUE; |
4635 if (col == 2) | |
4636 aw = "single"; | |
4637 else if (col == 3) | |
4638 aw = "double"; | |
4639 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
|
4640 { |
6102 | 4641 /* Setting the option causes a screen redraw. Do |
4642 * that right away if possible, keeping any | |
4643 * messages. */ | |
4644 set_option_value((char_u *)"ambw", 0L, | |
4645 (char_u *)aw, 0); | |
4646 # ifdef DEBUG_TERMRESPONSE | |
4647 { | |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
4648 int r = redraw_asap(CLEAR); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
4649 |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
4650 log_tr("set 'ambiwidth', redraw_asap(): %d", r); |
6102 | 4651 } |
4652 # else | |
4653 redraw_asap(CLEAR); | |
4654 # endif | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4655 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
4656 } |
4215 | 4657 key_name[0] = (int)KS_EXTRA; |
4658 key_name[1] = (int)KE_IGNORE; | |
4659 slen = i + 1; | |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4660 # ifdef FEAT_EVAL |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4661 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
|
4662 # endif |
4215 | 4663 } |
7 | 4664 /* eat it when at least one digit and ending in 'c' */ |
15605
62b3805506b3
patch 8.1.0810: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
4665 else if (*T_CRV != NUL && i > 2 + (tp[0] != CSI) |
62b3805506b3
patch 8.1.0810: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
4666 && tp[i] == 'c') |
7 | 4667 { |
12307
50b0b3aaa545
patch 8.0.1033: detecting background color does not work in screen
Christian Brabandt <cb@256bit.org>
parents:
12295
diff
changeset
|
4668 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
|
4669 |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
4670 LOG_TR(("Received CRV response: %s", tp)); |
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
|
4671 crv_status = STATUS_GOT; |
4262 | 4672 did_cursorhold = TRUE; |
7 | 4673 |
4674 /* If this code starts with CSI, you can bet that the | |
4675 * terminal uses 8-bit codes. */ | |
4676 if (tp[0] == CSI) | |
4677 switch_to_8bit(); | |
4678 | |
4679 /* 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
|
4680 * Screen sends 40500. |
7 | 4681 * Ignore it for when the user has set 'term' to xterm, |
4682 * 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
|
4683 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
|
4684 version = 0; |
7 | 4685 |
11784
80fa4b0eb0b0
patch 8.0.0774: build failure without the multi-byte feature
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
4686 if (tp[1 + (tp[0] != CSI)] == '>' && semicols == 2) |
7 | 4687 { |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4688 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
|
4689 int is_iterm2 = FALSE; |
15111
6fcfff2b4ba5
patch 8.1.0566: SGR not enabled for mintty because $TERM is "xterm"
Bram Moolenaar <Bram@vim.org>
parents:
14867
diff
changeset
|
4690 int is_mintty = FALSE; |
6fcfff2b4ba5
patch 8.1.0566: SGR not enabled for mintty because $TERM is "xterm"
Bram Moolenaar <Bram@vim.org>
parents:
14867
diff
changeset
|
4691 |
6fcfff2b4ba5
patch 8.1.0566: SGR not enabled for mintty because $TERM is "xterm"
Bram Moolenaar <Bram@vim.org>
parents:
14867
diff
changeset
|
4692 // mintty 2.9.5 sends 77;20905;0c. |
6fcfff2b4ba5
patch 8.1.0566: SGR not enabled for mintty because $TERM is "xterm"
Bram Moolenaar <Bram@vim.org>
parents:
14867
diff
changeset
|
4693 // (77 is ASCII 'M' for mintty.) |
6fcfff2b4ba5
patch 8.1.0566: SGR not enabled for mintty because $TERM is "xterm"
Bram Moolenaar <Bram@vim.org>
parents:
14867
diff
changeset
|
4694 if (STRNCMP(tp + extra - 3, "77;", 3) == 0) |
6fcfff2b4ba5
patch 8.1.0566: SGR not enabled for mintty because $TERM is "xterm"
Bram Moolenaar <Bram@vim.org>
parents:
14867
diff
changeset
|
4695 is_mintty = TRUE; |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4696 |
7 | 4697 /* 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
|
4698 if (version >= 141) |
7 | 4699 { |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
4700 LOG_TR(("Enable checking for XT codes")); |
7 | 4701 check_for_codes = TRUE; |
4702 need_gather = TRUE; | |
4703 req_codes_from_term(); | |
4704 } | |
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
|
4705 |
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
|
4706 /* 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
|
4707 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
|
4708 && 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
|
4709 { |
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
|
4710 /* 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
|
4711 * 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
|
4712 * 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
|
4713 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
|
4714 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
|
4715 /* 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
|
4716 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
|
4717 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
|
4718 (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
|
4719 } |
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
|
4720 |
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
|
4721 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
|
4722 { |
14282
89dcceaa5c22
patch 8.1.0157: old iTerm2 is not recognized, resulting in stray output
Christian Brabandt <cb@256bit.org>
parents:
14252
diff
changeset
|
4723 // Mac Terminal.app sends 1;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
|
4724 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
|
4725 { |
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
|
4726 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
|
4727 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
|
4728 } |
14282
89dcceaa5c22
patch 8.1.0157: old iTerm2 is not recognized, resulting in stray output
Christian Brabandt <cb@256bit.org>
parents:
14252
diff
changeset
|
4729 // 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
|
4730 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
|
4731 is_iterm2 = TRUE; |
14282
89dcceaa5c22
patch 8.1.0157: old iTerm2 is not recognized, resulting in stray output
Christian Brabandt <cb@256bit.org>
parents:
14252
diff
changeset
|
4732 // old iTerm2 sends 0;95; |
16058
012f03e583e2
patch 8.1.1034: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
4733 else if (STRNCMP(tp + extra - 2, "0;95;c", 6) == 0) |
14282
89dcceaa5c22
patch 8.1.0157: old iTerm2 is not recognized, resulting in stray output
Christian Brabandt <cb@256bit.org>
parents:
14252
diff
changeset
|
4734 is_not_xterm = TRUE; |
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
|
4735 } |
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
|
4736 |
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
|
4737 /* 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
|
4738 * 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
|
4739 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
|
4740 { |
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
|
4741 /* Xterm version 277 supports SGR. Also support |
15111
6fcfff2b4ba5
patch 8.1.0566: SGR not enabled for mintty because $TERM is "xterm"
Bram Moolenaar <Bram@vim.org>
parents:
14867
diff
changeset
|
4742 * Terminal.app, iTerm2 and mintty. */ |
6fcfff2b4ba5
patch 8.1.0566: SGR not enabled for mintty because $TERM is "xterm"
Bram Moolenaar <Bram@vim.org>
parents:
14867
diff
changeset
|
4743 if (version >= 277 || is_iterm2 || is_mac_terminal |
6fcfff2b4ba5
patch 8.1.0566: SGR not enabled for mintty because $TERM is "xterm"
Bram Moolenaar <Bram@vim.org>
parents:
14867
diff
changeset
|
4744 || is_mintty) |
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
|
4745 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
|
4746 (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
|
4747 /* if xterm version >= 95 use mouse dragging */ |
16058
012f03e583e2
patch 8.1.1034: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
4748 else if (version >= 95) |
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
|
4749 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
|
4750 (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
|
4751 } |
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
|
4752 |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4753 /* 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
|
4754 * "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
|
4755 * 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
|
4756 |
12359
c83669fb7601
patch 8.0.1059: older Gnome terminal returns smaller version number
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
4757 /* 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
|
4758 * 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
|
4759 * 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
|
4760 * 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
|
4761 * 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
|
4762 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
|
4763 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
|
4764 |
12373
71524e1a717b
patch 8.0.1066: some terminals can't handle requesting cursor mode
Christian Brabandt <cb@256bit.org>
parents:
12359
diff
changeset
|
4765 /* 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
|
4766 * 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
|
4767 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
|
4768 && 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
|
4769 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
|
4770 |
270256b6d0b8
patch 8.0.1027: more terminals can't handle requesting cursor mode
Christian Brabandt <cb@256bit.org>
parents:
12283
diff
changeset
|
4771 /* 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
|
4772 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
|
4773 && 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
|
4774 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
|
4775 |
14224
85e0442b7a04
patch 8.1.0129: still some xterm-like terminals get a stray "p"
Christian Brabandt <cb@256bit.org>
parents:
14007
diff
changeset
|
4776 // Xterm first responded to this request at patch level |
85e0442b7a04
patch 8.1.0129: still some xterm-like terminals get a stray "p"
Christian Brabandt <cb@256bit.org>
parents:
14007
diff
changeset
|
4777 // 95, so assume anything below 95 is not xterm. |
85e0442b7a04
patch 8.1.0129: still some xterm-like terminals get a stray "p"
Christian Brabandt <cb@256bit.org>
parents:
14007
diff
changeset
|
4778 if (version < 95) |
85e0442b7a04
patch 8.1.0129: still some xterm-like terminals get a stray "p"
Christian Brabandt <cb@256bit.org>
parents:
14007
diff
changeset
|
4779 is_not_xterm = TRUE; |
85e0442b7a04
patch 8.1.0129: still some xterm-like terminals get a stray "p"
Christian Brabandt <cb@256bit.org>
parents:
14007
diff
changeset
|
4780 |
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
|
4781 /* 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
|
4782 * 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
|
4783 * 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
|
4784 * 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
|
4785 * 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
|
4786 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
|
4787 && version >= 279 |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4788 && !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
|
4789 && *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
|
4790 && *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
|
4791 { |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
4792 LOG_TR(("Sending cursor style request")); |
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
|
4793 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
|
4794 rcs_status = STATUS_SENT; |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4795 need_flush = TRUE; |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4796 } |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4797 |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4798 /* 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
|
4799 * 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
|
4800 * 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
|
4801 if (rbm_status == STATUS_GET |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4802 && !is_not_xterm |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4803 && *T_CRC != NUL) |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4804 { |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
4805 LOG_TR(("Sending cursor blink mode request")); |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4806 out_str(T_CRC); |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4807 rbm_status = STATUS_SENT; |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4808 need_flush = TRUE; |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4809 } |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4810 |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4811 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
|
4812 out_flush(); |
7 | 4813 } |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4814 slen = i + 1; |
7 | 4815 # ifdef FEAT_EVAL |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4816 set_vim_var_string(VV_TERMRESPONSE, tp, slen); |
7 | 4817 # endif |
4818 apply_autocmds(EVENT_TERMRESPONSE, | |
4819 NULL, NULL, FALSE, curbuf); | |
4820 key_name[0] = (int)KS_EXTRA; | |
4821 key_name[1] = (int)KE_IGNORE; | |
4822 } | |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4823 |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4824 /* 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
|
4825 * {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
|
4826 * {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
|
4827 * |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4828 * {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
|
4829 */ |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4830 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
|
4831 && 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
|
4832 && i == j + 6 |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4833 && 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
|
4834 && 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
|
4835 && tp[j + 3] == ';' |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4836 && tp[i - 1] == '$' |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4837 && tp[i] == 'y') |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4838 { |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4839 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
|
4840 rbm_status = STATUS_GOT; |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
4841 LOG_TR(("Received cursor blinking mode response: %s", tp)); |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4842 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
|
4843 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
|
4844 slen = i + 1; |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4845 # ifdef FEAT_EVAL |
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4846 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
|
4847 # endif |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4848 } |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4849 |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4850 /* |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4851 * 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
|
4852 * {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
|
4853 */ |
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
|
4854 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
|
4855 && ((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
|
4856 || (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
|
4857 && 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
|
4858 && 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
|
4859 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4860 j += 2; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4861 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
|
4862 ; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4863 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
|
4864 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4865 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
|
4866 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
|
4867 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
|
4868 ; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4869 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
|
4870 { |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4871 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
|
4872 /* 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
|
4873 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
|
4874 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
|
4875 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
|
4876 |
aef75fbfc07d
patch 8.0.1573: getwinpos(1) may cause response to be handled as command
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
4877 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
|
4878 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
|
4879 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4880 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4881 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
|
4882 { |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
4883 LOG_TR(("not enough characters for winpos")); |
11315
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4884 return -1; |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4885 } |
0c091a7c588c
patch 8.0.0543: test_edit causes older xfce4-terminal to close
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
4886 } |
6901 | 4887 } |
4888 | |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4889 /* Check for fore/background color response from the terminal: |
6901 | 4890 * |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4891 * {lead}{code};rgb:{rrrr}/{gggg}/{bbbb}{tail} |
6901 | 4892 * |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4893 * {code} is 10 for foreground, 11 for background |
6901 | 4894 * {lead} can be <Esc>] or OSC |
4895 * {tail} can be '\007', <Esc>\ or STERM. | |
4896 * | |
4897 * Consume any code that starts with "{lead}11;", it's also | |
4898 * possible that "rgba" is following. | |
4899 */ | |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4900 else if ((*T_RBG != NUL || *T_RFG != NUL) |
6901 | 4901 && ((tp[0] == ESC && len >= 2 && tp[1] == ']') |
4902 || tp[0] == OSC)) | |
4903 { | |
4904 j = 1 + (tp[0] == ESC); | |
4905 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
|
4906 || (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
|
4907 || argp[2] != ';')) |
6901 | 4908 i = 0; /* no match */ |
4909 else | |
4910 for (i = j; i < len; ++i) | |
4911 if (tp[i] == '\007' || (tp[0] == OSC ? tp[i] == STERM | |
4912 : (tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\'))) | |
4913 { | |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4914 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
|
4915 |
6901 | 4916 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
|
4917 && 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
|
4918 { |
12790
305693246ff6
patch 8.0.1272: warnings for unused variables in tiny build
Christian Brabandt <cb@256bit.org>
parents:
12761
diff
changeset
|
4919 #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
|
4920 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
|
4921 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
|
4922 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
|
4923 #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
|
4924 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
|
4925 { |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4926 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
|
4927 + 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
|
4928 |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
4929 LOG_TR(("Received RBG response: %s", tp)); |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4930 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
|
4931 #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
|
4932 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
|
4933 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
|
4934 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
|
4935 #endif |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4936 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
|
4937 && 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
|
4938 { |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4939 /* 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
|
4940 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
|
4941 (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
|
4942 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
|
4943 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
|
4944 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4945 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4946 #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
|
4947 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
|
4948 { |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
4949 LOG_TR(("Received RFG response: %s", tp)); |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4950 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
|
4951 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
|
4952 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
|
4953 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
|
4954 } |
12632
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
4955 #endif |
6901 | 4956 } |
4957 | |
4958 /* got finished code: consume it */ | |
4959 key_name[0] = (int)KS_EXTRA; | |
4960 key_name[1] = (int)KE_IGNORE; | |
4961 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
|
4962 # 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
|
4963 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
|
4964 : VV_TERMRFGRESP, tp, slen); |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
4965 # endif |
6901 | 4966 break; |
4967 } | |
4968 if (i == len) | |
6874 | 4969 { |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
4970 LOG_TR(("not enough characters for RB")); |
6901 | 4971 return -1; |
6874 | 4972 } |
7 | 4973 } |
4974 | |
6901 | 4975 /* Check for key code response from xterm: |
4976 * {lead}{flag}+r<hex bytes><{tail} | |
4977 * | |
4978 * {lead} can be <Esc>P or DCS | |
4979 * {flag} can be '0' or '1' | |
4980 * {tail} can be Esc>\ or STERM | |
4981 * | |
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
|
4982 * 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
|
4983 * {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
|
4984 * |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4985 * {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
|
4986 * {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
|
4987 * |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
4988 * Consume any code that starts with "{lead}.+r" or "{lead}.$r". |
6901 | 4989 */ |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12234
diff
changeset
|
4990 else if ((check_for_codes || rcs_status == STATUS_SENT) |
6901 | 4991 && ((tp[0] == ESC && len >= 2 && tp[1] == 'P') |
7 | 4992 || tp[0] == DCS)) |
4993 { | |
6901 | 4994 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
|
4995 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
|
4996 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
|
4997 else if ((argp[1] != '+' && argp[1] != '$') || argp[2] != 'r') |
6901 | 4998 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
|
4999 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
|
5000 /* key code response */ |
6901 | 5001 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
|
5002 { |
6901 | 5003 if ((tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\') |
7 | 5004 || tp[i] == STERM) |
5005 { | |
6901 | 5006 if (i - j >= 3) |
7 | 5007 got_code_from_term(tp + j, i); |
5008 key_name[0] = (int)KS_EXTRA; | |
5009 key_name[1] = (int)KE_IGNORE; | |
5010 slen = i + 1 + (tp[i] == ESC); | |
5011 break; | |
5012 } | |
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
|
5013 } |
13365
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
5014 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
|
5015 { |
13365
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
5016 /* 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
|
5017 * 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
|
5018 * characters. */ |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
5019 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
|
5020 { |
13365
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
5021 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
|
5022 break; |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
5023 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
|
5024 break; |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
5025 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
|
5026 break; |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
5027 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
|
5028 break; |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
5029 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
|
5030 || (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
|
5031 { |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
5032 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
|
5033 |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
5034 /* 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
|
5035 * 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
|
5036 * 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
|
5037 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
|
5038 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
|
5039 /* 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
|
5040 * 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
|
5041 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
|
5042 (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
|
5043 rcs_status = STATUS_GOT; |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
5044 LOG_TR(("Received cursor shape response: %s", tp)); |
13365
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
5045 |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
5046 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
|
5047 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
|
5048 slen = i + 1; |
12273
c952a6af25e0
patch 8.0.1016: gnome terminal echoes t_RC
Christian Brabandt <cb@256bit.org>
parents:
12261
diff
changeset
|
5049 # 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
|
5050 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
|
5051 # endif |
13365
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
5052 break; |
c6bafddbfa33
patch 8.0.1556: may not parse the t_RS response correctly
Christian Brabandt <cb@256bit.org>
parents:
13316
diff
changeset
|
5053 } |
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
|
5054 } |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12078
diff
changeset
|
5055 } |
7 | 5056 |
5057 if (i == len) | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5058 { |
6901 | 5059 /* These codes arrive many together, each code can be |
5060 * truncated at any point. */ | |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
5061 LOG_TR(("not enough characters for XT")); |
6901 | 5062 return -1; |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
5063 } |
7 | 5064 } |
5065 } | |
5066 #endif | |
5067 | |
5068 if (key_name[0] == NUL) | |
5069 continue; /* No match at this position, try next one */ | |
5070 | |
5071 /* We only get here when we have a complete termcode match */ | |
5072 | |
5073 #ifdef FEAT_MOUSE | |
5074 # ifdef FEAT_GUI | |
5075 /* | |
5076 * Only in the GUI: Fetch the pointer coordinates of the scroll event | |
5077 * so that we know which window to scroll later. | |
5078 */ | |
5079 if (gui.in_use | |
5080 && key_name[0] == (int)KS_EXTRA | |
5081 && (key_name[1] == (int)KE_X1MOUSE | |
5082 || 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
|
5083 || key_name[1] == (int)KE_MOUSELEFT |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2347
diff
changeset
|
5084 || key_name[1] == (int)KE_MOUSERIGHT |
7 | 5085 || key_name[1] == (int)KE_MOUSEDOWN |
5086 || key_name[1] == (int)KE_MOUSEUP)) | |
5087 { | |
5088 num_bytes = get_bytes_from_buf(tp + slen, bytes, 4); | |
5089 if (num_bytes == -1) /* not enough coordinates */ | |
5090 return -1; | |
5091 mouse_col = 128 * (bytes[0] - ' ' - 1) + bytes[1] - ' ' - 1; | |
5092 mouse_row = 128 * (bytes[2] - ' ' - 1) + bytes[3] - ' ' - 1; | |
5093 slen += num_bytes; | |
5094 } | |
5095 else | |
5096 # endif | |
5097 /* | |
5098 * If it is a mouse click, get the coordinates. | |
5099 */ | |
3746 | 5100 if (key_name[0] == KS_MOUSE |
7 | 5101 # ifdef FEAT_MOUSE_JSB |
3746 | 5102 || key_name[0] == KS_JSBTERM_MOUSE |
7 | 5103 # endif |
5104 # ifdef FEAT_MOUSE_NET | |
3746 | 5105 || key_name[0] == KS_NETTERM_MOUSE |
7 | 5106 # endif |
5107 # ifdef FEAT_MOUSE_DEC | |
3746 | 5108 || key_name[0] == KS_DEC_MOUSE |
7 | 5109 # endif |
5110 # ifdef FEAT_MOUSE_PTERM | |
3746 | 5111 || key_name[0] == KS_PTERM_MOUSE |
7 | 5112 # endif |
3166 | 5113 # ifdef FEAT_MOUSE_URXVT |
3746 | 5114 || key_name[0] == KS_URXVT_MOUSE |
5115 # endif | |
5116 || key_name[0] == KS_SGR_MOUSE | |
16058
012f03e583e2
patch 8.1.1034: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
5117 || key_name[0] == KS_SGR_MOUSE_RELEASE) |
7 | 5118 { |
5119 is_click = is_drag = FALSE; | |
5120 | |
1623 | 5121 # if !defined(UNIX) || defined(FEAT_MOUSE_XTERM) || defined(FEAT_GUI) \ |
5122 || defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE) | |
7 | 5123 if (key_name[0] == (int)KS_MOUSE) |
5124 { | |
5125 /* | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
5126 * For xterm we get "<t_mouse>scr", where |
7 | 5127 * s == encoded button state: |
5128 * 0x20 = left button down | |
5129 * 0x21 = middle button down | |
5130 * 0x22 = right button down | |
5131 * 0x23 = any button release | |
5132 * 0x60 = button 4 down (scroll wheel down) | |
5133 * 0x61 = button 5 down (scroll wheel up) | |
5134 * add 0x04 for SHIFT | |
5135 * add 0x08 for ALT | |
5136 * add 0x10 for CTRL | |
5137 * 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
|
5138 * 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
|
5139 * 0x43 (drag + release) is also move |
7 | 5140 * c == column + ' ' + 1 == column + 33 |
5141 * r == row + ' ' + 1 == row + 33 | |
5142 * | |
5143 * The coordinates are passed on through global variables. | |
5144 * Ugly, but this avoids trouble with mouse clicks at an | |
5145 * unexpected moment and allows for mapping them. | |
5146 */ | |
5147 for (;;) | |
5148 { | |
16058
012f03e583e2
patch 8.1.1034: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
5149 # ifdef FEAT_GUI |
7 | 5150 if (gui.in_use) |
5151 { | |
5152 /* GUI uses more bits for columns > 223 */ | |
5153 num_bytes = get_bytes_from_buf(tp + slen, bytes, 5); | |
5154 if (num_bytes == -1) /* not enough coordinates */ | |
5155 return -1; | |
5156 mouse_code = bytes[0]; | |
5157 mouse_col = 128 * (bytes[1] - ' ' - 1) | |
5158 + bytes[2] - ' ' - 1; | |
5159 mouse_row = 128 * (bytes[3] - ' ' - 1) | |
5160 + bytes[4] - ' ' - 1; | |
5161 } | |
5162 else | |
16058
012f03e583e2
patch 8.1.1034: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
5163 # endif |
7 | 5164 { |
5165 num_bytes = get_bytes_from_buf(tp + slen, bytes, 3); | |
5166 if (num_bytes == -1) /* not enough coordinates */ | |
5167 return -1; | |
5168 mouse_code = bytes[0]; | |
5169 mouse_col = bytes[1] - ' ' - 1; | |
5170 mouse_row = bytes[2] - ' ' - 1; | |
5171 } | |
5172 slen += num_bytes; | |
5173 | |
5174 /* If the following bytes is also a mouse code and it has | |
5175 * the same code, dump this one and get the next. This | |
5176 * makes dragging a whole lot faster. */ | |
16058
012f03e583e2
patch 8.1.1034: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
5177 # ifdef FEAT_GUI |
7 | 5178 if (gui.in_use) |
5179 j = 3; | |
5180 else | |
16058
012f03e583e2
patch 8.1.1034: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
5181 # endif |
7 | 5182 j = termcodes[idx].len; |
5183 if (STRNCMP(tp, tp + slen, (size_t)j) == 0 | |
5184 && tp[slen + j] == mouse_code | |
5185 && tp[slen + j + 1] != NUL | |
5186 && tp[slen + j + 2] != NUL | |
16058
012f03e583e2
patch 8.1.1034: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
5187 # ifdef FEAT_GUI |
7 | 5188 && (!gui.in_use |
5189 || (tp[slen + j + 3] != NUL | |
5190 && tp[slen + j + 4] != NUL)) | |
16058
012f03e583e2
patch 8.1.1034: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
5191 # endif |
7 | 5192 ) |
5193 slen += j; | |
5194 else | |
5195 break; | |
5196 } | |
3166 | 5197 } |
5198 | |
3746 | 5199 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
|
5200 || 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
|
5201 || key_name[0] == KS_SGR_MOUSE_RELEASE) |
3166 | 5202 { |
11567
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5203 /* URXVT 1015 mouse reporting mode: |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5204 * 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
|
5205 * are decimal instead of bytes. |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5206 * |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5207 * \033[%d;%d;%dM |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5208 * ^-- row |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5209 * ^----- column |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5210 * ^-------- code |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5211 * |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5212 * SGR 1006 mouse reporting mode: |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5213 * 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
|
5214 * are decimal instead of bytes. |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5215 * |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5216 * \033[<%d;%d;%dM |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5217 * ^-- row |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5218 * ^----- column |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5219 * ^-------- code |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5220 * |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5221 * \033[<%d;%d;%dm : mouse release event |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5222 * ^-- row |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5223 * ^----- column |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5224 * ^-------- code |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5225 */ |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5226 p = modifiers_start; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5227 if (p == NULL) |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5228 return -1; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5229 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5230 mouse_code = getdigits(&p); |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5231 if (*p++ != ';') |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5232 return -1; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5233 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5234 /* 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
|
5235 if (key_name[0] == KS_SGR_MOUSE |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5236 || key_name[0] == KS_SGR_MOUSE_RELEASE) |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5237 mouse_code += 32; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5238 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5239 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
|
5240 mouse_code |= MOUSE_RELEASE; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5241 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5242 mouse_col = getdigits(&p) - 1; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5243 if (*p++ != ';') |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5244 return -1; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5245 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5246 mouse_row = getdigits(&p) - 1; |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5247 |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5248 /* 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
|
5249 * modifier keys (alt/shift/ctrl/meta) state. */ |
632daabce5d8
patch 8.0.0666: dead for loop
Christian Brabandt <cb@256bit.org>
parents:
11565
diff
changeset
|
5250 modifiers = 0; |
3166 | 5251 } |
5252 | |
5253 if (key_name[0] == (int)KS_MOUSE | |
16058
012f03e583e2
patch 8.1.1034: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
5254 # ifdef FEAT_MOUSE_URXVT |
3166 | 5255 || key_name[0] == (int)KS_URXVT_MOUSE |
16058
012f03e583e2
patch 8.1.1034: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
5256 # endif |
3746 | 5257 || key_name[0] == KS_SGR_MOUSE |
16058
012f03e583e2
patch 8.1.1034: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
5258 || key_name[0] == KS_SGR_MOUSE_RELEASE) |
3166 | 5259 { |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
5260 # if !defined(MSWIN) |
7 | 5261 /* |
5262 * Handle mouse events. | |
5263 * Recognize the xterm mouse wheel, but not in the GUI, the | |
5264 * Linux console with GPM and the MS-DOS or Win32 console | |
5265 * (multi-clicks use >= 0x60). | |
5266 */ | |
5267 if (mouse_code >= MOUSEWHEEL_LOW | |
5268 # ifdef FEAT_GUI | |
5269 && !gui.in_use | |
5270 # endif | |
5271 # ifdef FEAT_MOUSE_GPM | |
5272 && gpm_flag == 0 | |
5273 # endif | |
5274 ) | |
5275 { | |
12895
d872005ecfcd
patch 8.0.1324: some xterm sends different mouse move codes
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
5276 # 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
|
5277 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
|
5278 /* 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
|
5279 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
|
5280 else |
d872005ecfcd
patch 8.0.1324: some xterm sends different mouse move codes
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
5281 # endif |
d872005ecfcd
patch 8.0.1324: some xterm sends different mouse move codes
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
5282 /* 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
|
5283 * 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
|
5284 wheel_code = mouse_code; |
7 | 5285 } |
5286 # ifdef FEAT_MOUSE_XTERM | |
5287 else if (held_button == MOUSE_RELEASE | |
5288 # ifdef FEAT_GUI | |
5289 && !gui.in_use | |
5290 # endif | |
13573
23e5f12f43d7
patch 8.0.1659: scroll events not recognized for some xterm emulators
Christian Brabandt <cb@256bit.org>
parents:
13489
diff
changeset
|
5291 && (mouse_code == 0x23 || mouse_code == 0x24 |
23e5f12f43d7
patch 8.0.1659: scroll events not recognized for some xterm emulators
Christian Brabandt <cb@256bit.org>
parents:
13489
diff
changeset
|
5292 || mouse_code == 0x40 || mouse_code == 0x41)) |
7 | 5293 { |
13573
23e5f12f43d7
patch 8.0.1659: scroll events not recognized for some xterm emulators
Christian Brabandt <cb@256bit.org>
parents:
13489
diff
changeset
|
5294 /* Apparently 0x23 and 0x24 are used by rxvt scroll wheel. |
23e5f12f43d7
patch 8.0.1659: scroll events not recognized for some xterm emulators
Christian Brabandt <cb@256bit.org>
parents:
13489
diff
changeset
|
5295 * And 0x40 and 0x41 are used by some xterm emulator. */ |
23e5f12f43d7
patch 8.0.1659: scroll events not recognized for some xterm emulators
Christian Brabandt <cb@256bit.org>
parents:
13489
diff
changeset
|
5296 wheel_code = mouse_code - (mouse_code >= 0x40 ? 0x40 : 0x23) |
23e5f12f43d7
patch 8.0.1659: scroll events not recognized for some xterm emulators
Christian Brabandt <cb@256bit.org>
parents:
13489
diff
changeset
|
5297 + MOUSEWHEEL_LOW; |
7 | 5298 } |
5299 # endif | |
5300 | |
5301 # if defined(UNIX) && defined(FEAT_MOUSE_TTY) | |
5302 else if (use_xterm_mouse() > 1) | |
5303 { | |
5304 if (mouse_code & MOUSE_DRAG_XTERM) | |
5305 mouse_code |= MOUSE_DRAG; | |
5306 } | |
5307 # endif | |
5308 # ifdef FEAT_XCLIPBOARD | |
5309 else if (!(mouse_code & MOUSE_DRAG & ~MOUSE_CLICK_MASK)) | |
5310 { | |
5311 if ((mouse_code & MOUSE_RELEASE) == MOUSE_RELEASE) | |
5312 stop_xterm_trace(); | |
5313 else | |
5314 start_xterm_trace(mouse_code); | |
5315 } | |
5316 # endif | |
5317 # endif | |
5318 } | |
5319 # endif /* !UNIX || FEAT_MOUSE_XTERM */ | |
5320 # ifdef FEAT_MOUSE_NET | |
5321 if (key_name[0] == (int)KS_NETTERM_MOUSE) | |
5322 { | |
5323 int mc, mr; | |
5324 | |
5325 /* expect a rather limited sequence like: balancing { | |
5326 * \033}6,45\r | |
5327 * '6' is the row, 45 is the column | |
5328 */ | |
5329 p = tp + slen; | |
5330 mr = getdigits(&p); | |
5331 if (*p++ != ',') | |
5332 return -1; | |
5333 mc = getdigits(&p); | |
5334 if (*p++ != '\r') | |
5335 return -1; | |
5336 | |
5337 mouse_col = mc - 1; | |
5338 mouse_row = mr - 1; | |
5339 mouse_code = MOUSE_LEFT; | |
5340 slen += (int)(p - (tp + slen)); | |
5341 } | |
5342 # endif /* FEAT_MOUSE_NET */ | |
5343 # ifdef FEAT_MOUSE_JSB | |
5344 if (key_name[0] == (int)KS_JSBTERM_MOUSE) | |
5345 { | |
5346 int mult, val, iter, button, status; | |
5347 | |
5348 /* JSBTERM Input Model | |
5349 * \033[0~zw uniq escape sequence | |
5350 * (L-x) Left button pressed - not pressed x not reporting | |
5351 * (M-x) Middle button pressed - not pressed x not reporting | |
5352 * (R-x) Right button pressed - not pressed x not reporting | |
5353 * (SDmdu) Single , Double click, m mouse move d button down | |
5354 * u button up | |
5355 * ### X cursor position padded to 3 digits | |
5356 * ### Y cursor position padded to 3 digits | |
5357 * (s-x) SHIFT key pressed - not pressed x not reporting | |
5358 * (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
|
5359 * \033\\ terminating sequence |
7 | 5360 */ |
5361 | |
5362 p = tp + slen; | |
5363 button = mouse_code = 0; | |
5364 switch (*p++) | |
5365 { | |
5366 case 'L': button = 1; break; | |
5367 case '-': break; | |
5368 case 'x': break; /* ignore sequence */ | |
5369 default: return -1; /* Unknown Result */ | |
5370 } | |
5371 switch (*p++) | |
5372 { | |
5373 case 'M': button |= 2; break; | |
5374 case '-': break; | |
5375 case 'x': break; /* ignore sequence */ | |
5376 default: return -1; /* Unknown Result */ | |
5377 } | |
5378 switch (*p++) | |
5379 { | |
5380 case 'R': button |= 4; break; | |
5381 case '-': break; | |
5382 case 'x': break; /* ignore sequence */ | |
5383 default: return -1; /* Unknown Result */ | |
5384 } | |
5385 status = *p++; | |
5386 for (val = 0, mult = 100, iter = 0; iter < 3; iter++, | |
5387 mult /= 10, p++) | |
5388 if (*p >= '0' && *p <= '9') | |
5389 val += (*p - '0') * mult; | |
5390 else | |
5391 return -1; | |
5392 mouse_col = val; | |
5393 for (val = 0, mult = 100, iter = 0; iter < 3; iter++, | |
5394 mult /= 10, p++) | |
5395 if (*p >= '0' && *p <= '9') | |
5396 val += (*p - '0') * mult; | |
5397 else | |
5398 return -1; | |
5399 mouse_row = val; | |
5400 switch (*p++) | |
5401 { | |
5402 case 's': button |= 8; break; /* SHIFT key Pressed */ | |
5403 case '-': break; /* Not Pressed */ | |
5404 case 'x': break; /* Not Reporting */ | |
5405 default: return -1; /* Unknown Result */ | |
5406 } | |
5407 switch (*p++) | |
5408 { | |
5409 case 'c': button |= 16; break; /* CTRL key Pressed */ | |
5410 case '-': break; /* Not Pressed */ | |
5411 case 'x': break; /* Not Reporting */ | |
5412 default: return -1; /* Unknown Result */ | |
5413 } | |
5414 if (*p++ != '\033') | |
5415 return -1; | |
5416 if (*p++ != '\\') | |
5417 return -1; | |
5418 switch (status) | |
5419 { | |
5420 case 'D': /* Double Click */ | |
5421 case 'S': /* Single Click */ | |
5422 if (button & 1) mouse_code |= MOUSE_LEFT; | |
5423 if (button & 2) mouse_code |= MOUSE_MIDDLE; | |
5424 if (button & 4) mouse_code |= MOUSE_RIGHT; | |
5425 if (button & 8) mouse_code |= MOUSE_SHIFT; | |
5426 if (button & 16) mouse_code |= MOUSE_CTRL; | |
5427 break; | |
5428 case 'm': /* Mouse move */ | |
5429 if (button & 1) mouse_code |= MOUSE_LEFT; | |
5430 if (button & 2) mouse_code |= MOUSE_MIDDLE; | |
5431 if (button & 4) mouse_code |= MOUSE_RIGHT; | |
5432 if (button & 8) mouse_code |= MOUSE_SHIFT; | |
5433 if (button & 16) mouse_code |= MOUSE_CTRL; | |
5434 if ((button & 7) != 0) | |
5435 { | |
5436 held_button = mouse_code; | |
5437 mouse_code |= MOUSE_DRAG; | |
5438 } | |
5439 is_drag = TRUE; | |
5440 showmode(); | |
5441 break; | |
5442 case 'd': /* Button Down */ | |
5443 if (button & 1) mouse_code |= MOUSE_LEFT; | |
5444 if (button & 2) mouse_code |= MOUSE_MIDDLE; | |
5445 if (button & 4) mouse_code |= MOUSE_RIGHT; | |
5446 if (button & 8) mouse_code |= MOUSE_SHIFT; | |
5447 if (button & 16) mouse_code |= MOUSE_CTRL; | |
5448 break; | |
5449 case 'u': /* Button Up */ | |
5450 if (button & 1) | |
5451 mouse_code |= MOUSE_LEFT | MOUSE_RELEASE; | |
5452 if (button & 2) | |
5453 mouse_code |= MOUSE_MIDDLE | MOUSE_RELEASE; | |
5454 if (button & 4) | |
5455 mouse_code |= MOUSE_RIGHT | MOUSE_RELEASE; | |
5456 if (button & 8) | |
5457 mouse_code |= MOUSE_SHIFT; | |
5458 if (button & 16) | |
5459 mouse_code |= MOUSE_CTRL; | |
5460 break; | |
5461 default: return -1; /* Unknown Result */ | |
5462 } | |
5463 | |
5464 slen += (p - (tp + slen)); | |
5465 } | |
5466 # endif /* FEAT_MOUSE_JSB */ | |
5467 # ifdef FEAT_MOUSE_DEC | |
5468 if (key_name[0] == (int)KS_DEC_MOUSE) | |
5469 { | |
5470 /* The DEC Locator Input Model | |
5471 * Netterm delivers the code sequence: | |
5472 * \033[2;4;24;80&w (left button down) | |
5473 * \033[3;0;24;80&w (left button up) | |
5474 * \033[6;1;24;80&w (right button down) | |
5475 * \033[7;0;24;80&w (right button up) | |
5476 * CSI Pe ; Pb ; Pr ; Pc ; Pp & w | |
5477 * Pe is the event code | |
5478 * Pb is the button code | |
5479 * Pr is the row coordinate | |
5480 * Pc is the column coordinate | |
5481 * Pp is the third coordinate (page number) | |
5482 * Pe, the event code indicates what event caused this report | |
5483 * The following event codes are defined: | |
5484 * 0 - request, the terminal received an explicit request | |
5485 * for a locator report, but the locator is unavailable | |
5486 * 1 - request, the terminal received an explicit request | |
5487 * for a locator report | |
5488 * 2 - left button down | |
5489 * 3 - left button up | |
5490 * 4 - middle button down | |
5491 * 5 - middle button up | |
5492 * 6 - right button down | |
5493 * 7 - right button up | |
5494 * 8 - fourth button down | |
5495 * 9 - fourth button up | |
5496 * 10 - locator outside filter rectangle | |
5497 * Pb, the button code, ASCII decimal 0-15 indicating which | |
5498 * buttons are down if any. The state of the four buttons | |
5499 * on the locator correspond to the low four bits of the | |
5500 * decimal value, | |
5501 * "1" means button depressed | |
5502 * 0 - no buttons down, | |
5503 * 1 - right, | |
5504 * 2 - middle, | |
5505 * 4 - left, | |
5506 * 8 - fourth | |
5507 * Pr is the row coordinate of the locator position in the page, | |
5508 * encoded as an ASCII decimal value. | |
5509 * If Pr is omitted, the locator position is undefined | |
5510 * (outside the terminal window for example). | |
5511 * Pc is the column coordinate of the locator position in the | |
5512 * page, encoded as an ASCII decimal value. | |
5513 * If Pc is omitted, the locator position is undefined | |
5514 * (outside the terminal window for example). | |
5515 * Pp is the page coordinate of the locator position | |
5516 * encoded as an ASCII decimal value. | |
5517 * The page coordinate may be omitted if the locator is on | |
5518 * page one (the default). We ignore it anyway. | |
5519 */ | |
5520 int Pe, Pb, Pr, Pc; | |
5521 | |
5522 p = tp + slen; | |
5523 | |
5524 /* get event status */ | |
5525 Pe = getdigits(&p); | |
5526 if (*p++ != ';') | |
5527 return -1; | |
5528 | |
5529 /* get button status */ | |
5530 Pb = getdigits(&p); | |
5531 if (*p++ != ';') | |
5532 return -1; | |
5533 | |
5534 /* get row status */ | |
5535 Pr = getdigits(&p); | |
5536 if (*p++ != ';') | |
5537 return -1; | |
5538 | |
5539 /* get column status */ | |
5540 Pc = getdigits(&p); | |
5541 | |
5542 /* the page parameter is optional */ | |
5543 if (*p == ';') | |
5544 { | |
5545 p++; | |
5546 (void)getdigits(&p); | |
5547 } | |
5548 if (*p++ != '&') | |
5549 return -1; | |
5550 if (*p++ != 'w') | |
5551 return -1; | |
5552 | |
5553 mouse_code = 0; | |
5554 switch (Pe) | |
5555 { | |
5556 case 0: return -1; /* position request while unavailable */ | |
5557 case 1: /* a response to a locator position request includes | |
5558 the status of all buttons */ | |
5559 Pb &= 7; /* mask off and ignore fourth button */ | |
5560 if (Pb & 4) | |
5561 mouse_code = MOUSE_LEFT; | |
5562 if (Pb & 2) | |
5563 mouse_code = MOUSE_MIDDLE; | |
5564 if (Pb & 1) | |
5565 mouse_code = MOUSE_RIGHT; | |
5566 if (Pb) | |
5567 { | |
5568 held_button = mouse_code; | |
5569 mouse_code |= MOUSE_DRAG; | |
227 | 5570 WantQueryMouse = TRUE; |
7 | 5571 } |
5572 is_drag = TRUE; | |
5573 showmode(); | |
5574 break; | |
5575 case 2: mouse_code = MOUSE_LEFT; | |
227 | 5576 WantQueryMouse = TRUE; |
7 | 5577 break; |
5578 case 3: mouse_code = MOUSE_RELEASE | MOUSE_LEFT; | |
5579 break; | |
5580 case 4: mouse_code = MOUSE_MIDDLE; | |
227 | 5581 WantQueryMouse = TRUE; |
7 | 5582 break; |
5583 case 5: mouse_code = MOUSE_RELEASE | MOUSE_MIDDLE; | |
5584 break; | |
5585 case 6: mouse_code = MOUSE_RIGHT; | |
227 | 5586 WantQueryMouse = TRUE; |
7 | 5587 break; |
5588 case 7: mouse_code = MOUSE_RELEASE | MOUSE_RIGHT; | |
5589 break; | |
5590 case 8: return -1; /* fourth button down */ | |
5591 case 9: return -1; /* fourth button up */ | |
5592 case 10: return -1; /* mouse outside of filter rectangle */ | |
5593 default: return -1; /* should never occur */ | |
5594 } | |
5595 | |
5596 mouse_col = Pc - 1; | |
5597 mouse_row = Pr - 1; | |
5598 | |
5599 slen += (int)(p - (tp + slen)); | |
5600 } | |
5601 # endif /* FEAT_MOUSE_DEC */ | |
5602 # ifdef FEAT_MOUSE_PTERM | |
5603 if (key_name[0] == (int)KS_PTERM_MOUSE) | |
5604 { | |
2237
770485470e59
Add a few #ifdefs to exclude functions that are not used. (Domnique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
1941
diff
changeset
|
5605 int button, num_clicks, action; |
7 | 5606 |
5607 p = tp + slen; | |
5608 | |
5609 action = getdigits(&p); | |
5610 if (*p++ != ';') | |
5611 return -1; | |
5612 | |
5613 mouse_row = getdigits(&p); | |
5614 if (*p++ != ';') | |
5615 return -1; | |
5616 mouse_col = getdigits(&p); | |
5617 if (*p++ != ';') | |
5618 return -1; | |
5619 | |
5620 button = getdigits(&p); | |
5621 mouse_code = 0; | |
5622 | |
9929
579abc260d85
commit https://github.com/vim/vim/commit/de7762a2c1498e2dc43586feb5f982d661799f85
Christian Brabandt <cb@256bit.org>
parents:
9869
diff
changeset
|
5623 switch (button) |
7 | 5624 { |
5625 case 4: mouse_code = MOUSE_LEFT; break; | |
5626 case 1: mouse_code = MOUSE_RIGHT; break; | |
5627 case 2: mouse_code = MOUSE_MIDDLE; break; | |
5628 default: return -1; | |
5629 } | |
5630 | |
9929
579abc260d85
commit https://github.com/vim/vim/commit/de7762a2c1498e2dc43586feb5f982d661799f85
Christian Brabandt <cb@256bit.org>
parents:
9869
diff
changeset
|
5631 switch (action) |
7 | 5632 { |
5633 case 31: /* Initial press */ | |
5634 if (*p++ != ';') | |
5635 return -1; | |
5636 | |
5637 num_clicks = getdigits(&p); /* Not used */ | |
5638 break; | |
5639 | |
5640 case 32: /* Release */ | |
5641 mouse_code |= MOUSE_RELEASE; | |
5642 break; | |
5643 | |
5644 case 33: /* Drag */ | |
5645 held_button = mouse_code; | |
5646 mouse_code |= MOUSE_DRAG; | |
5647 break; | |
5648 | |
5649 default: | |
5650 return -1; | |
5651 } | |
5652 | |
5653 if (*p++ != 't') | |
5654 return -1; | |
5655 | |
5656 slen += (p - (tp + slen)); | |
5657 } | |
5658 # endif /* FEAT_MOUSE_PTERM */ | |
5659 | |
5660 /* Interpret the mouse code */ | |
5661 current_button = (mouse_code & MOUSE_CLICK_MASK); | |
5662 if (current_button == MOUSE_RELEASE | |
5663 # ifdef FEAT_MOUSE_XTERM | |
5664 && wheel_code == 0 | |
5665 # endif | |
5666 ) | |
5667 { | |
5668 /* | |
5669 * If we get a mouse drag or release event when | |
5670 * there is no mouse button held down (held_button == | |
5671 * MOUSE_RELEASE), produce a K_IGNORE below. | |
5672 * (can happen when you hold down two buttons | |
5673 * and then let them go, or click in the menu bar, but not | |
5674 * on a menu, and drag into the text). | |
5675 */ | |
5676 if ((mouse_code & MOUSE_DRAG) == MOUSE_DRAG) | |
5677 is_drag = TRUE; | |
5678 current_button = held_button; | |
5679 } | |
5680 else if (wheel_code == 0) | |
5681 { | |
5682 # ifdef CHECK_DOUBLE_CLICK | |
5683 # ifdef FEAT_MOUSE_GPM | |
5684 # ifdef FEAT_GUI | |
5685 /* | |
5686 * Only for Unix, when GUI or gpm is not active, we handle | |
5687 * multi-clicks here. | |
5688 */ | |
5689 if (gpm_flag == 0 && !gui.in_use) | |
5690 # else | |
5691 if (gpm_flag == 0) | |
5692 # endif | |
5693 # else | |
5694 # ifdef FEAT_GUI | |
5695 if (!gui.in_use) | |
5696 # endif | |
5697 # endif | |
5698 { | |
5699 /* | |
5700 * Compute the time elapsed since the previous mouse click. | |
5701 */ | |
5702 gettimeofday(&mouse_time, NULL); | |
9125
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5703 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
|
5704 { |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5705 /* |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5706 * 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
|
5707 * 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
|
5708 * 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
|
5709 * multiplication overflow. |
9125
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5710 */ |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5711 timediff = p_mouset; |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5712 } |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5713 else |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5714 { |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5715 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
|
5716 - 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
|
5717 if (timediff < 0) |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5718 --orig_mouse_time.tv_sec; |
bcc132f80109
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
5719 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
|
5720 - 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
|
5721 } |
7 | 5722 orig_mouse_time = mouse_time; |
5723 if (mouse_code == orig_mouse_code | |
5724 && timediff < p_mouset | |
5725 && orig_num_clicks != 4 | |
5726 && orig_mouse_col == mouse_col | |
5727 && orig_mouse_row == mouse_row | |
683 | 5728 && ((orig_topline == curwin->w_topline |
7 | 5729 #ifdef FEAT_DIFF |
683 | 5730 && orig_topfill == curwin->w_topfill |
7 | 5731 #endif |
683 | 5732 ) |
5733 /* Double click in tab pages line also works | |
5734 * 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
|
5735 || (mouse_row == 0 && firstwin->w_winrow > 0)) |
683 | 5736 ) |
7 | 5737 ++orig_num_clicks; |
5738 else | |
5739 orig_num_clicks = 1; | |
5740 orig_mouse_col = mouse_col; | |
5741 orig_mouse_row = mouse_row; | |
5742 orig_topline = curwin->w_topline; | |
5743 #ifdef FEAT_DIFF | |
5744 orig_topfill = curwin->w_topfill; | |
5745 #endif | |
5746 } | |
5747 # if defined(FEAT_GUI) || defined(FEAT_MOUSE_GPM) | |
5748 else | |
5749 orig_num_clicks = NUM_MOUSE_CLICKS(mouse_code); | |
5750 # endif | |
5751 # else | |
5752 orig_num_clicks = NUM_MOUSE_CLICKS(mouse_code); | |
5753 # endif | |
5754 is_click = TRUE; | |
5755 orig_mouse_code = mouse_code; | |
5756 } | |
5757 if (!is_drag) | |
5758 held_button = mouse_code & MOUSE_CLICK_MASK; | |
5759 | |
5760 /* | |
5761 * Translate the actual mouse event into a pseudo mouse event. | |
5762 * First work out what modifiers are to be used. | |
5763 */ | |
5764 if (orig_mouse_code & MOUSE_SHIFT) | |
5765 modifiers |= MOD_MASK_SHIFT; | |
5766 if (orig_mouse_code & MOUSE_CTRL) | |
5767 modifiers |= MOD_MASK_CTRL; | |
5768 if (orig_mouse_code & MOUSE_ALT) | |
5769 modifiers |= MOD_MASK_ALT; | |
5770 if (orig_num_clicks == 2) | |
5771 modifiers |= MOD_MASK_2CLICK; | |
5772 else if (orig_num_clicks == 3) | |
5773 modifiers |= MOD_MASK_3CLICK; | |
5774 else if (orig_num_clicks == 4) | |
5775 modifiers |= MOD_MASK_4CLICK; | |
5776 | |
9929
579abc260d85
commit https://github.com/vim/vim/commit/de7762a2c1498e2dc43586feb5f982d661799f85
Christian Brabandt <cb@256bit.org>
parents:
9869
diff
changeset
|
5777 /* 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
|
5778 * added, then it's not mouse up/down. */ |
7 | 5779 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
|
5780 if (wheel_code != 0 |
9929
579abc260d85
commit https://github.com/vim/vim/commit/de7762a2c1498e2dc43586feb5f982d661799f85
Christian Brabandt <cb@256bit.org>
parents:
9869
diff
changeset
|
5781 && (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
|
5782 { |
1a4a66f0c871
Make CTRL modifier work for mouse wheel. (Benjamin Haskell)
Bram Moolenaar <bram@vim.org>
parents:
2279
diff
changeset
|
5783 if (wheel_code & MOUSE_CTRL) |
1a4a66f0c871
Make CTRL modifier work for mouse wheel. (Benjamin Haskell)
Bram Moolenaar <bram@vim.org>
parents:
2279
diff
changeset
|
5784 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
|
5785 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
|
5786 modifiers |= MOD_MASK_ALT; |
7 | 5787 key_name[1] = (wheel_code & 1) |
5788 ? (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
|
5789 held_button = MOUSE_RELEASE; |
2336
1a4a66f0c871
Make CTRL modifier work for mouse wheel. (Benjamin Haskell)
Bram Moolenaar <bram@vim.org>
parents:
2279
diff
changeset
|
5790 } |
7 | 5791 else |
5792 key_name[1] = get_pseudo_mouse_code(current_button, | |
5793 is_click, is_drag); | |
7256
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5794 |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5795 /* 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
|
5796 * return weird values. */ |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5797 if (mouse_col >= Columns) |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5798 mouse_col = Columns - 1; |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5799 if (mouse_row >= Rows) |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7210
diff
changeset
|
5800 mouse_row = Rows - 1; |
7 | 5801 } |
5802 #endif /* FEAT_MOUSE */ | |
5803 | |
5804 #ifdef FEAT_GUI | |
5805 /* | |
5806 * If using the GUI, then we get menu and scrollbar events. | |
5807 * | |
5808 * A menu event is encoded as K_SPECIAL, KS_MENU, KE_FILLER followed by | |
5809 * four bytes which are to be taken as a pointer to the vimmenu_T | |
5810 * structure. | |
5811 * | |
1221 | 5812 * A tab line event is encoded as K_SPECIAL KS_TABLINE nr, where "nr" |
685 | 5813 * is one byte with the tab index. |
5814 * | |
7 | 5815 * A scrollbar event is K_SPECIAL, KS_VER_SCROLLBAR, KE_FILLER followed |
5816 * by one byte representing the scrollbar number, and then four bytes | |
5817 * representing a long_u which is the new value of the scrollbar. | |
5818 * | |
5819 * A horizontal scrollbar event is K_SPECIAL, KS_HOR_SCROLLBAR, | |
5820 * KE_FILLER followed by four bytes representing a long_u which is the | |
5821 * new value of the scrollbar. | |
5822 */ | |
5823 # ifdef FEAT_MENU | |
5824 else if (key_name[0] == (int)KS_MENU) | |
5825 { | |
5826 long_u val; | |
5827 | |
5828 num_bytes = get_long_from_buf(tp + slen, &val); | |
5829 if (num_bytes == -1) | |
5830 return -1; | |
5831 current_menu = (vimmenu_T *)val; | |
5832 slen += num_bytes; | |
936 | 5833 |
5834 /* The menu may have been deleted right after it was used, check | |
5835 * for that. */ | |
5836 if (check_menu_pointer(root_menu, current_menu) == FAIL) | |
5837 { | |
5838 key_name[0] = KS_EXTRA; | |
5839 key_name[1] = (int)KE_IGNORE; | |
5840 } | |
7 | 5841 } |
5842 # endif | |
685 | 5843 # ifdef FEAT_GUI_TABLINE |
5844 else if (key_name[0] == (int)KS_TABLINE) | |
5845 { | |
688 | 5846 /* Selecting tabline tab or using its menu. */ |
685 | 5847 num_bytes = get_bytes_from_buf(tp + slen, bytes, 1); |
5848 if (num_bytes == -1) | |
5849 return -1; | |
5850 current_tab = (int)bytes[0]; | |
1394 | 5851 if (current_tab == 255) /* -1 in a byte gives 255 */ |
5852 current_tab = -1; | |
685 | 5853 slen += num_bytes; |
5854 } | |
688 | 5855 else if (key_name[0] == (int)KS_TABMENU) |
5856 { | |
5857 /* Selecting tabline tab or using its menu. */ | |
5858 num_bytes = get_bytes_from_buf(tp + slen, bytes, 2); | |
5859 if (num_bytes == -1) | |
5860 return -1; | |
5861 current_tab = (int)bytes[0]; | |
5862 current_tabmenu = (int)bytes[1]; | |
5863 slen += num_bytes; | |
5864 } | |
685 | 5865 # endif |
7 | 5866 # ifndef USE_ON_FLY_SCROLL |
5867 else if (key_name[0] == (int)KS_VER_SCROLLBAR) | |
5868 { | |
5869 long_u val; | |
5870 | |
5871 /* Get the last scrollbar event in the queue of the same type */ | |
5872 j = 0; | |
5873 for (i = 0; tp[j] == CSI && tp[j + 1] == KS_VER_SCROLLBAR | |
5874 && tp[j + 2] != NUL; ++i) | |
5875 { | |
5876 j += 3; | |
5877 num_bytes = get_bytes_from_buf(tp + j, bytes, 1); | |
5878 if (num_bytes == -1) | |
5879 break; | |
5880 if (i == 0) | |
5881 current_scrollbar = (int)bytes[0]; | |
5882 else if (current_scrollbar != (int)bytes[0]) | |
5883 break; | |
5884 j += num_bytes; | |
5885 num_bytes = get_long_from_buf(tp + j, &val); | |
5886 if (num_bytes == -1) | |
5887 break; | |
5888 scrollbar_value = val; | |
5889 j += num_bytes; | |
5890 slen = j; | |
5891 } | |
5892 if (i == 0) /* not enough characters to make one */ | |
5893 return -1; | |
5894 } | |
5895 else if (key_name[0] == (int)KS_HOR_SCROLLBAR) | |
5896 { | |
5897 long_u val; | |
5898 | |
5899 /* Get the last horiz. scrollbar event in the queue */ | |
5900 j = 0; | |
5901 for (i = 0; tp[j] == CSI && tp[j + 1] == KS_HOR_SCROLLBAR | |
5902 && tp[j + 2] != NUL; ++i) | |
5903 { | |
5904 j += 3; | |
5905 num_bytes = get_long_from_buf(tp + j, &val); | |
5906 if (num_bytes == -1) | |
5907 break; | |
5908 scrollbar_value = val; | |
5909 j += num_bytes; | |
5910 slen = j; | |
5911 } | |
5912 if (i == 0) /* not enough characters to make one */ | |
5913 return -1; | |
5914 } | |
5915 # endif /* !USE_ON_FLY_SCROLL */ | |
5916 #endif /* FEAT_GUI */ | |
5917 | |
180 | 5918 /* |
5919 * Change <xHome> to <Home>, <xUp> to <Up>, etc. | |
5920 */ | |
5921 key = handle_x_keys(TERMCAP2KEY(key_name[0], key_name[1])); | |
5922 | |
5923 /* | |
5924 * Add any modifier codes to our string. | |
5925 */ | |
5926 new_slen = 0; /* Length of what will replace the termcode */ | |
5927 if (modifiers != 0) | |
5928 { | |
5929 /* Some keys have the modifier included. Need to handle that here | |
5930 * to make mappings work. */ | |
5931 key = simplify_key(key, &modifiers); | |
5932 if (modifiers != 0) | |
5933 { | |
5934 string[new_slen++] = K_SPECIAL; | |
5935 string[new_slen++] = (int)KS_MODIFIER; | |
5936 string[new_slen++] = modifiers; | |
5937 } | |
5938 } | |
5939 | |
7 | 5940 /* Finally, add the special key code to our string */ |
180 | 5941 key_name[0] = KEY2TERMCAP0(key); |
5942 key_name[1] = KEY2TERMCAP1(key); | |
7 | 5943 if (key_name[0] == KS_KEY) |
1787 | 5944 { |
5945 /* from ":set <M-b>=xx" */ | |
5946 if (has_mbyte) | |
5947 new_slen += (*mb_char2bytes)(key_name[1], string + new_slen); | |
5948 else | |
5949 string[new_slen++] = key_name[1]; | |
5950 } | |
2672 | 5951 else if (new_slen == 0 && key_name[0] == KS_EXTRA |
5952 && key_name[1] == KE_IGNORE) | |
5953 { | |
5954 /* Do not put K_IGNORE into the buffer, do return KEYLEN_REMOVED | |
5955 * to indicate what happened. */ | |
5956 retval = KEYLEN_REMOVED; | |
5957 } | |
7 | 5958 else |
5959 { | |
5960 string[new_slen++] = K_SPECIAL; | |
5961 string[new_slen++] = key_name[0]; | |
5962 string[new_slen++] = key_name[1]; | |
5963 } | |
5964 string[new_slen] = NUL; | |
5965 extra = new_slen - slen; | |
5966 if (buf == NULL) | |
5967 { | |
5968 if (extra < 0) | |
5969 /* remove matched chars, taking care of noremap */ | |
5970 del_typebuf(-extra, offset); | |
5971 else if (extra > 0) | |
5972 /* insert the extra space we need */ | |
5973 ins_typebuf(string + slen, REMAP_YES, offset, FALSE, FALSE); | |
5974 | |
5975 /* | |
5976 * Careful: del_typebuf() and ins_typebuf() may have reallocated | |
5977 * typebuf.tb_buf[]! | |
5978 */ | |
5979 mch_memmove(typebuf.tb_buf + typebuf.tb_off + offset, string, | |
5980 (size_t)new_slen); | |
5981 } | |
5982 else | |
5983 { | |
5984 if (extra < 0) | |
5985 /* remove matched characters */ | |
5986 mch_memmove(buf + offset, buf + offset - extra, | |
3328 | 5987 (size_t)(*buflen + offset + extra)); |
7 | 5988 else if (extra > 0) |
3328 | 5989 { |
5990 /* Insert the extra space we need. If there is insufficient | |
5991 * space return -1. */ | |
5992 if (*buflen + extra + new_slen >= bufsize) | |
5993 return -1; | |
7 | 5994 mch_memmove(buf + offset + extra, buf + offset, |
3328 | 5995 (size_t)(*buflen - offset)); |
5996 } | |
7 | 5997 mch_memmove(buf + offset, string, (size_t)new_slen); |
3328 | 5998 *buflen = *buflen + extra + new_slen; |
7 | 5999 } |
2672 | 6000 return retval == 0 ? (len + extra + offset) : retval; |
7 | 6001 } |
6002 | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6003 #ifdef FEAT_TERMRESPONSE |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6004 LOG_TR(("normal character")); |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6005 #endif |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5076
diff
changeset
|
6006 |
7 | 6007 return 0; /* no match found */ |
6008 } | |
6009 | |
12634
94566ecb55f0
patch 8.0.1195: can't build on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12632
diff
changeset
|
6010 #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
|
6011 /* |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
6012 * 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
|
6013 */ |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
6014 void |
12640
a715f0b44532
patch 8.0.1198: older compilers don't know uint8_t
Christian Brabandt <cb@256bit.org>
parents:
12634
diff
changeset
|
6015 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
|
6016 { |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
6017 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
|
6018 { |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
6019 *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
|
6020 *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
|
6021 *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
|
6022 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
6023 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
6024 |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
6025 /* |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
6026 * 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
|
6027 */ |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
6028 void |
12640
a715f0b44532
patch 8.0.1198: older compilers don't know uint8_t
Christian Brabandt <cb@256bit.org>
parents:
12634
diff
changeset
|
6029 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
|
6030 { |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
6031 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
|
6032 { |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
6033 *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
|
6034 *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
|
6035 *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
|
6036 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
6037 } |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
6038 #endif |
b1a7e3968a31
patch 8.0.1194: actual fg and bg colors of terminal are unknown
Christian Brabandt <cb@256bit.org>
parents:
12592
diff
changeset
|
6039 |
7 | 6040 /* |
6041 * Replace any terminal code strings in from[] with the equivalent internal | |
6042 * vim representation. This is used for the "from" and "to" part of a | |
6043 * mapping, and the "to" part of a menu command. | |
6044 * Any strings like "<C-UP>" are also replaced, unless 'cpoptions' contains | |
6045 * '<'. | |
6046 * K_SPECIAL by itself is replaced by K_SPECIAL KS_SPECIAL KE_FILLER. | |
6047 * | |
6048 * The replacement is done in result[] and finally copied into allocated | |
6049 * memory. If this all works well *bufp is set to the allocated memory and a | |
6050 * pointer to it is returned. If something fails *bufp is set to NULL and from | |
6051 * is returned. | |
6052 * | |
6053 * CTRL-V characters are removed. When "from_part" is TRUE, a trailing CTRL-V | |
6054 * is included, otherwise it is removed (for ":map xx ^V", maps xx to | |
6055 * nothing). When 'cpoptions' does not contain 'B', a backslash can be used | |
6056 * instead of a CTRL-V. | |
6057 */ | |
859 | 6058 char_u * |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6059 replace_termcodes( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6060 char_u *from, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6061 char_u **bufp, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6062 int from_part, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6063 int do_lt, /* also translate <lt> */ |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6064 int special) /* always accept <key> notation */ |
7 | 6065 { |
6066 int i; | |
6067 int slen; | |
6068 int key; | |
6069 int dlen = 0; | |
6070 char_u *src; | |
6071 int do_backslash; /* backslash is a special character */ | |
6072 int do_special; /* recognize <> key codes */ | |
6073 int do_key_code; /* recognize raw key codes */ | |
6074 char_u *result; /* buffer for resulting string */ | |
6075 | |
6076 do_backslash = (vim_strchr(p_cpo, CPO_BSLASH) == NULL); | |
859 | 6077 do_special = (vim_strchr(p_cpo, CPO_SPECI) == NULL) || special; |
7 | 6078 do_key_code = (vim_strchr(p_cpo, CPO_KEYCODE) == NULL); |
6079 | |
6080 /* | |
6081 * Allocate space for the translation. Worst case a single character is | |
6082 * replaced by 6 bytes (shifted special key), plus a NUL at the end. | |
6083 */ | |
6084 result = alloc((unsigned)STRLEN(from) * 6 + 1); | |
6085 if (result == NULL) /* out of memory */ | |
6086 { | |
6087 *bufp = NULL; | |
6088 return from; | |
6089 } | |
6090 | |
6091 src = from; | |
6092 | |
6093 /* | |
6094 * Check for #n at start only: function key n | |
6095 */ | |
6096 if (from_part && src[0] == '#' && VIM_ISDIGIT(src[1])) /* function key */ | |
6097 { | |
6098 result[dlen++] = K_SPECIAL; | |
6099 result[dlen++] = 'k'; | |
6100 if (src[1] == '0') | |
6101 result[dlen++] = ';'; /* #0 is F10 is "k;" */ | |
6102 else | |
6103 result[dlen++] = src[1]; /* #3 is F3 is "k3" */ | |
6104 src += 2; | |
6105 } | |
6106 | |
6107 /* | |
6108 * Copy each byte from *from to result[dlen] | |
6109 */ | |
6110 while (*src != NUL) | |
6111 { | |
6112 /* | |
6113 * 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
|
6114 * like "<C-S-LeftMouse>" |
7 | 6115 */ |
6116 if (do_special && (do_lt || STRNCMP(src, "<lt>", 4) != 0)) | |
6117 { | |
6118 #ifdef FEAT_EVAL | |
6119 /* | |
6120 * Replace <SID> by K_SNR <script-nr> _. | |
6121 * (room: 5 * 6 = 30 bytes; needed: 3 + <nr> + 1 <= 14) | |
6122 */ | |
6123 if (STRNICMP(src, "<SID>", 5) == 0) | |
6124 { | |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14581
diff
changeset
|
6125 if (current_sctx.sc_sid <= 0) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15111
diff
changeset
|
6126 emsg(_(e_usingsid)); |
7 | 6127 else |
6128 { | |
6129 src += 5; | |
6130 result[dlen++] = K_SPECIAL; | |
6131 result[dlen++] = (int)KS_EXTRA; | |
6132 result[dlen++] = (int)KE_SNR; | |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14581
diff
changeset
|
6133 sprintf((char *)result + dlen, "%ld", |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14581
diff
changeset
|
6134 (long)current_sctx.sc_sid); |
7 | 6135 dlen += (int)STRLEN(result + dlen); |
6136 result[dlen++] = '_'; | |
6137 continue; | |
6138 } | |
6139 } | |
6140 #endif | |
6141 | |
9869
989d44d35a66
commit https://github.com/vim/vim/commit/35a4cfa200917dd171b1fff3cd5b6cee9add673d
Christian Brabandt <cb@256bit.org>
parents:
9814
diff
changeset
|
6142 slen = trans_special(&src, result + dlen, TRUE, FALSE); |
7 | 6143 if (slen) |
6144 { | |
6145 dlen += slen; | |
6146 continue; | |
6147 } | |
6148 } | |
6149 | |
6150 /* | |
6151 * If 'cpoptions' does not contain 'k', see if it's an actual key-code. | |
6152 * Note that this is also checked after replacing the <> form. | |
6153 * Single character codes are NOT replaced (e.g. ^H or DEL), because | |
6154 * it could be a character in the file. | |
6155 */ | |
6156 if (do_key_code) | |
6157 { | |
6158 i = find_term_bykeys(src); | |
6159 if (i >= 0) | |
6160 { | |
6161 result[dlen++] = K_SPECIAL; | |
6162 result[dlen++] = termcodes[i].name[0]; | |
6163 result[dlen++] = termcodes[i].name[1]; | |
6164 src += termcodes[i].len; | |
6165 /* If terminal code matched, continue after it. */ | |
6166 continue; | |
6167 } | |
6168 } | |
6169 | |
6170 #ifdef FEAT_EVAL | |
6171 if (do_special) | |
6172 { | |
6173 char_u *p, *s, len; | |
6174 | |
6175 /* | |
6176 * Replace <Leader> by the value of "mapleader". | |
6177 * Replace <LocalLeader> by the value of "maplocalleader". | |
6178 * If "mapleader" or "maplocalleader" isn't set use a backslash. | |
6179 */ | |
6180 if (STRNICMP(src, "<Leader>", 8) == 0) | |
6181 { | |
6182 len = 8; | |
6183 p = get_var_value((char_u *)"g:mapleader"); | |
6184 } | |
6185 else if (STRNICMP(src, "<LocalLeader>", 13) == 0) | |
6186 { | |
6187 len = 13; | |
6188 p = get_var_value((char_u *)"g:maplocalleader"); | |
6189 } | |
6190 else | |
6191 { | |
6192 len = 0; | |
6193 p = NULL; | |
6194 } | |
6195 if (len != 0) | |
6196 { | |
6197 /* Allow up to 8 * 6 characters for "mapleader". */ | |
6198 if (p == NULL || *p == NUL || STRLEN(p) > 8 * 6) | |
6199 s = (char_u *)"\\"; | |
6200 else | |
6201 s = p; | |
6202 while (*s != NUL) | |
6203 result[dlen++] = *s++; | |
6204 src += len; | |
6205 continue; | |
6206 } | |
6207 } | |
6208 #endif | |
6209 | |
6210 /* | |
6211 * Remove CTRL-V and ignore the next character. | |
6212 * For "from" side the CTRL-V at the end is included, for the "to" | |
6213 * part it is removed. | |
6214 * If 'cpoptions' does not contain 'B', also accept a backslash. | |
6215 */ | |
6216 key = *src; | |
6217 if (key == Ctrl_V || (do_backslash && key == '\\')) | |
6218 { | |
6219 ++src; /* skip CTRL-V or backslash */ | |
6220 if (*src == NUL) | |
6221 { | |
6222 if (from_part) | |
6223 result[dlen++] = key; | |
6224 break; | |
6225 } | |
6226 } | |
6227 | |
6228 /* skip multibyte char correctly */ | |
474 | 6229 for (i = (*mb_ptr2len)(src); i > 0; --i) |
7 | 6230 { |
6231 /* | |
6232 * If the character is K_SPECIAL, replace it with K_SPECIAL | |
6233 * KS_SPECIAL KE_FILLER. | |
6234 * If compiled with the GUI replace CSI with K_CSI. | |
6235 */ | |
6236 if (*src == K_SPECIAL) | |
6237 { | |
6238 result[dlen++] = K_SPECIAL; | |
6239 result[dlen++] = KS_SPECIAL; | |
6240 result[dlen++] = KE_FILLER; | |
6241 } | |
6242 # ifdef FEAT_GUI | |
6243 else if (*src == CSI) | |
6244 { | |
6245 result[dlen++] = K_SPECIAL; | |
6246 result[dlen++] = KS_EXTRA; | |
6247 result[dlen++] = (int)KE_CSI; | |
6248 } | |
6249 # endif | |
6250 else | |
6251 result[dlen++] = *src; | |
6252 ++src; | |
6253 } | |
6254 } | |
6255 result[dlen] = NUL; | |
6256 | |
6257 /* | |
6258 * Copy the new string to allocated memory. | |
6259 * If this fails, just return from. | |
6260 */ | |
6261 if ((*bufp = vim_strsave(result)) != NULL) | |
6262 from = *bufp; | |
6263 vim_free(result); | |
6264 return from; | |
6265 } | |
6266 | |
6267 /* | |
6268 * Find a termcode with keys 'src' (must be NUL terminated). | |
6269 * Return the index in termcodes[], or -1 if not found. | |
6270 */ | |
6271 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6272 find_term_bykeys(char_u *src) |
7 | 6273 { |
6274 int i; | |
3290 | 6275 int slen = (int)STRLEN(src); |
7 | 6276 |
6277 for (i = 0; i < tc_len; ++i) | |
6278 { | |
3273 | 6279 if (slen == termcodes[i].len |
6280 && STRNCMP(termcodes[i].code, src, (size_t)slen) == 0) | |
7 | 6281 return i; |
6282 } | |
6283 return -1; | |
6284 } | |
6285 | |
6286 /* | |
6287 * Gather the first characters in the terminal key codes into a string. | |
6288 * Used to speed up check_termcode(). | |
6289 */ | |
6290 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6291 gather_termleader(void) |
7 | 6292 { |
6293 int i; | |
6294 int len = 0; | |
6295 | |
6296 #ifdef FEAT_GUI | |
6297 if (gui.in_use) | |
6298 termleader[len++] = CSI; /* the GUI codes are not in termcodes[] */ | |
6299 #endif | |
6300 #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
|
6301 if (check_for_codes || *T_CRS != NUL) |
7 | 6302 termleader[len++] = DCS; /* the termcode response starts with DCS |
6303 in 8-bit mode */ | |
6304 #endif | |
6305 termleader[len] = NUL; | |
6306 | |
6307 for (i = 0; i < tc_len; ++i) | |
6308 if (vim_strchr(termleader, termcodes[i].code[0]) == NULL) | |
6309 { | |
6310 termleader[len++] = termcodes[i].code[0]; | |
6311 termleader[len] = NUL; | |
6312 } | |
6313 | |
6314 need_gather = FALSE; | |
6315 } | |
6316 | |
6317 /* | |
6318 * Show all termcodes (for ":set termcap") | |
6319 * This code looks a lot like showoptions(), but is different. | |
6320 */ | |
6321 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6322 show_termcodes(void) |
7 | 6323 { |
6324 int col; | |
6325 int *items; | |
6326 int item_count; | |
6327 int run; | |
6328 int row, rows; | |
6329 int cols; | |
6330 int i; | |
6331 int len; | |
6332 | |
180 | 6333 #define INC3 27 /* try to make three columns */ |
6334 #define INC2 40 /* try to make two columns */ | |
7 | 6335 #define GAP 2 /* spaces between columns */ |
6336 | |
6337 if (tc_len == 0) /* no terminal codes (must be GUI) */ | |
6338 return; | |
6339 items = (int *)alloc((unsigned)(sizeof(int) * tc_len)); | |
6340 if (items == NULL) | |
6341 return; | |
6342 | |
6343 /* Highlight title */ | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6344 msg_puts_title(_("\n--- Terminal keys ---")); |
7 | 6345 |
6346 /* | |
6347 * do the loop two times: | |
6348 * 1. display the short items (non-strings and short strings) | |
180 | 6349 * 2. display the medium items (medium length strings) |
6350 * 3. display the long items (remaining strings) | |
7 | 6351 */ |
180 | 6352 for (run = 1; run <= 3 && !got_int; ++run) |
7 | 6353 { |
6354 /* | |
6355 * collect the items in items[] | |
6356 */ | |
6357 item_count = 0; | |
6358 for (i = 0; i < tc_len; i++) | |
6359 { | |
6360 len = show_one_termcode(termcodes[i].name, | |
6361 termcodes[i].code, FALSE); | |
180 | 6362 if (len <= INC3 - GAP ? run == 1 |
6363 : len <= INC2 - GAP ? run == 2 | |
6364 : run == 3) | |
7 | 6365 items[item_count++] = i; |
6366 } | |
6367 | |
6368 /* | |
6369 * display the items | |
6370 */ | |
180 | 6371 if (run <= 2) |
7 | 6372 { |
180 | 6373 cols = (Columns + GAP) / (run == 1 ? INC3 : INC2); |
7 | 6374 if (cols == 0) |
6375 cols = 1; | |
6376 rows = (item_count + cols - 1) / cols; | |
6377 } | |
180 | 6378 else /* run == 3 */ |
7 | 6379 rows = item_count; |
6380 for (row = 0; row < rows && !got_int; ++row) | |
6381 { | |
6382 msg_putchar('\n'); /* go to next line */ | |
6383 if (got_int) /* 'q' typed in more */ | |
6384 break; | |
6385 col = 0; | |
6386 for (i = row; i < item_count; i += rows) | |
6387 { | |
6388 msg_col = col; /* make columns */ | |
6389 show_one_termcode(termcodes[items[i]].name, | |
6390 termcodes[items[i]].code, TRUE); | |
180 | 6391 if (run == 2) |
6392 col += INC2; | |
6393 else | |
6394 col += INC3; | |
7 | 6395 } |
6396 out_flush(); | |
6397 ui_breakcheck(); | |
6398 } | |
6399 } | |
6400 vim_free(items); | |
6401 } | |
6402 | |
6403 /* | |
6404 * Show one termcode entry. | |
6405 * Output goes into IObuff[] | |
6406 */ | |
6407 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6408 show_one_termcode(char_u *name, char_u *code, int printit) |
7 | 6409 { |
6410 char_u *p; | |
6411 int len; | |
6412 | |
6413 if (name[0] > '~') | |
6414 { | |
6415 IObuff[0] = ' '; | |
6416 IObuff[1] = ' '; | |
6417 IObuff[2] = ' '; | |
6418 IObuff[3] = ' '; | |
6419 } | |
6420 else | |
6421 { | |
6422 IObuff[0] = 't'; | |
6423 IObuff[1] = '_'; | |
6424 IObuff[2] = name[0]; | |
6425 IObuff[3] = name[1]; | |
6426 } | |
6427 IObuff[4] = ' '; | |
6428 | |
6429 p = get_special_key_name(TERMCAP2KEY(name[0], name[1]), 0); | |
6430 if (p[1] != 't') | |
6431 STRCPY(IObuff + 5, p); | |
6432 else | |
6433 IObuff[5] = NUL; | |
6434 len = (int)STRLEN(IObuff); | |
6435 do | |
6436 IObuff[len++] = ' '; | |
6437 while (len < 17); | |
6438 IObuff[len] = NUL; | |
6439 if (code == NULL) | |
6440 len += 4; | |
6441 else | |
6442 len += vim_strsize(code); | |
6443 | |
6444 if (printit) | |
6445 { | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6446 msg_puts((char *)IObuff); |
7 | 6447 if (code == NULL) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6448 msg_puts("NULL"); |
7 | 6449 else |
6450 msg_outtrans(code); | |
6451 } | |
6452 return len; | |
6453 } | |
6454 | |
6455 #if defined(FEAT_TERMRESPONSE) || defined(PROTO) | |
6456 /* | |
6457 * For Xterm >= 140 compiled with OPT_TCAP_QUERY: Obtain the actually used | |
6458 * termcap codes from the terminal itself. | |
6459 * We get them one by one to avoid a very long response string. | |
6460 */ | |
6102 | 6461 static int xt_index_in = 0; |
6462 static int xt_index_out = 0; | |
6463 | |
7 | 6464 static void |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6465 req_codes_from_term(void) |
7 | 6466 { |
6467 xt_index_out = 0; | |
6468 xt_index_in = 0; | |
6469 req_more_codes_from_term(); | |
6470 } | |
6471 | |
6472 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6473 req_more_codes_from_term(void) |
7 | 6474 { |
6475 char buf[11]; | |
6476 int old_idx = xt_index_out; | |
6477 | |
6478 /* Don't do anything when going to exit. */ | |
6479 if (exiting) | |
6480 return; | |
6481 | |
6482 /* Send up to 10 more requests out than we received. Avoid sending too | |
6483 * many, there can be a buffer overflow somewhere. */ | |
6484 while (xt_index_out < xt_index_in + 10 && key_names[xt_index_out] != NULL) | |
6485 { | |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6486 char *key_name = key_names[xt_index_out]; |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6487 |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6488 LOG_TR(("Requesting XT %d: %s", xt_index_out, key_name)); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6489 sprintf(buf, "\033P+q%02x%02x\033\\", key_name[0], key_name[1]); |
7 | 6490 out_str_nf((char_u *)buf); |
6491 ++xt_index_out; | |
6492 } | |
6493 | |
6494 /* Send the codes out right away. */ | |
6495 if (xt_index_out != old_idx) | |
6496 out_flush(); | |
6497 } | |
6498 | |
6499 /* | |
6500 * Decode key code response from xterm: '<Esc>P1+r<name>=<string><Esc>\'. | |
6501 * A "0" instead of the "1" indicates a code that isn't supported. | |
6502 * Both <name> and <string> are encoded in hex. | |
6503 * "code" points to the "0" or "1". | |
6504 */ | |
6505 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6506 got_code_from_term(char_u *code, int len) |
7 | 6507 { |
6508 #define XT_LEN 100 | |
6509 char_u name[3]; | |
6510 char_u str[XT_LEN]; | |
6511 int i; | |
6512 int j = 0; | |
6513 int c; | |
6514 | |
6515 /* A '1' means the code is supported, a '0' means it isn't. | |
6516 * When half the length is > XT_LEN we can't use it. | |
6517 * Our names are currently all 2 characters. */ | |
6518 if (code[0] == '1' && code[7] == '=' && len / 2 < XT_LEN) | |
6519 { | |
6520 /* Get the name from the response and find it in the table. */ | |
6521 name[0] = hexhex2nr(code + 3); | |
6522 name[1] = hexhex2nr(code + 5); | |
6523 name[2] = NUL; | |
6524 for (i = 0; key_names[i] != NULL; ++i) | |
6525 { | |
6526 if (STRCMP(key_names[i], name) == 0) | |
6527 { | |
6528 xt_index_in = i; | |
6529 break; | |
6530 } | |
6531 } | |
13780
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6532 |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6533 LOG_TR(("Received XT %d: %s", xt_index_in, (char *)name)); |
5cf4a504bcc0
patch 8.0.1762: terminal debug logging is a bit complicated
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
6534 |
7 | 6535 if (key_names[i] != NULL) |
6536 { | |
6537 for (i = 8; (c = hexhex2nr(code + i)) >= 0; i += 2) | |
6538 str[j++] = c; | |
6539 str[j] = NUL; | |
6540 if (name[0] == 'C' && name[1] == 'o') | |
6541 { | |
6542 /* Color count is not a key code. */ | |
6543 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
|
6544 may_adjust_color_count(i); |
7 | 6545 } |
6546 else | |
6547 { | |
6548 /* First delete any existing entry with the same code. */ | |
6549 i = find_term_bykeys(str); | |
6550 if (i >= 0) | |
6551 del_termcode_idx(i); | |
180 | 6552 add_termcode(name, str, ATC_FROM_TERM); |
7 | 6553 } |
6554 } | |
6555 } | |
6556 | |
6557 /* May request more codes now that we received one. */ | |
6558 ++xt_index_in; | |
6559 req_more_codes_from_term(); | |
6560 } | |
6561 | |
6562 /* | |
6563 * Check if there are any unanswered requests and deal with them. | |
6564 * This is called before starting an external program or getting direct | |
6565 * keyboard input. We don't want responses to be send to that program or | |
6566 * handled as typed text. | |
6567 */ | |
6568 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6569 check_for_codes_from_term(void) |
7 | 6570 { |
6571 int c; | |
6572 | |
6573 /* If no codes requested or all are answered, no need to wait. */ | |
6574 if (xt_index_out == 0 || xt_index_out == xt_index_in) | |
6575 return; | |
6576 | |
6577 /* Vgetc() will check for and handle any response. | |
6578 * Keep calling vpeekc() until we don't get any responses. */ | |
6579 ++no_mapping; | |
6580 ++allow_keys; | |
6581 for (;;) | |
6582 { | |
6583 c = vpeekc(); | |
6584 if (c == NUL) /* nothing available */ | |
6585 break; | |
6586 | |
6587 /* If a response is recognized it's replaced with K_IGNORE, must read | |
6588 * it from the input stream. If there is no K_IGNORE we can't do | |
6589 * anything, break here (there might be some responses further on, but | |
6590 * we don't want to throw away any typed chars). */ | |
6591 if (c != K_SPECIAL && c != K_IGNORE) | |
6592 break; | |
6593 c = vgetc(); | |
6594 if (c != K_IGNORE) | |
6595 { | |
6596 vungetc(c); | |
6597 break; | |
6598 } | |
6599 } | |
6600 --no_mapping; | |
6601 --allow_keys; | |
6602 } | |
6603 #endif | |
6604 | |
6605 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) | |
6606 /* | |
6607 * Translate an internal mapping/abbreviation representation into the | |
6608 * corresponding external one recognized by :map/:abbrev commands; | |
6609 * respects the current B/k/< settings of 'cpoption'. | |
6610 * | |
6611 * This function is called when expanding mappings/abbreviations on the | |
1902 | 6612 * command-line, and for building the "Ambiguous mapping..." error message. |
7 | 6613 * |
6614 * It uses a growarray to build the translation string since the | |
6615 * latter can be wider than the original description. The caller has to | |
6616 * free the string afterwards. | |
6617 * | |
6618 * Returns NULL when there is a problem. | |
6619 */ | |
6620 char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6621 translate_mapping( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6622 char_u *str, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6623 int expmap) /* TRUE when expanding mappings on command-line */ |
7 | 6624 { |
6625 garray_T ga; | |
6626 int c; | |
6627 int modifiers; | |
6628 int cpo_bslash; | |
6629 int cpo_special; | |
6630 int cpo_keycode; | |
6631 | |
6632 ga_init(&ga); | |
6633 ga.ga_itemsize = 1; | |
6634 ga.ga_growsize = 40; | |
6635 | |
6636 cpo_bslash = (vim_strchr(p_cpo, CPO_BSLASH) != NULL); | |
6637 cpo_special = (vim_strchr(p_cpo, CPO_SPECI) != NULL); | |
6638 cpo_keycode = (vim_strchr(p_cpo, CPO_KEYCODE) == NULL); | |
6639 | |
6640 for (; *str; ++str) | |
6641 { | |
6642 c = *str; | |
6643 if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL) | |
6644 { | |
6645 modifiers = 0; | |
6646 if (str[1] == KS_MODIFIER) | |
6647 { | |
6648 str++; | |
6649 modifiers = *++str; | |
6650 c = *++str; | |
6651 } | |
6652 if (cpo_special && cpo_keycode && c == K_SPECIAL && !modifiers) | |
6653 { | |
6654 int i; | |
6655 | |
6656 /* try to find special key in termcodes */ | |
6657 for (i = 0; i < tc_len; ++i) | |
6658 if (termcodes[i].name[0] == str[1] | |
6659 && termcodes[i].name[1] == str[2]) | |
6660 break; | |
6661 if (i < tc_len) | |
6662 { | |
6663 ga_concat(&ga, termcodes[i].code); | |
6664 str += 2; | |
6665 continue; /* for (str) */ | |
6666 } | |
6667 } | |
6668 if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL) | |
6669 { | |
6670 if (expmap && cpo_special) | |
6671 { | |
6672 ga_clear(&ga); | |
6673 return NULL; | |
6674 } | |
6675 c = TO_SPECIAL(str[1], str[2]); | |
6676 if (c == K_ZERO) /* display <Nul> as ^@ */ | |
6677 c = NUL; | |
6678 str += 2; | |
6679 } | |
6680 if (IS_SPECIAL(c) || modifiers) /* special key */ | |
6681 { | |
6682 if (expmap && cpo_special) | |
6683 { | |
6684 ga_clear(&ga); | |
6685 return NULL; | |
6686 } | |
6687 ga_concat(&ga, get_special_key_name(c, modifiers)); | |
6688 continue; /* for (str) */ | |
6689 } | |
6690 } | |
6691 if (c == ' ' || c == '\t' || c == Ctrl_J || c == Ctrl_V | |
6692 || (c == '<' && !cpo_special) || (c == '\\' && !cpo_bslash)) | |
6693 ga_append(&ga, cpo_bslash ? Ctrl_V : '\\'); | |
6694 if (c) | |
6695 ga_append(&ga, c); | |
6696 } | |
6697 ga_append(&ga, NUL); | |
6698 return (char_u *)(ga.ga_data); | |
6699 } | |
6700 #endif | |
6701 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15852
diff
changeset
|
6702 #if (defined(MSWIN) && !defined(FEAT_GUI)) || defined(PROTO) |
7 | 6703 static char ksme_str[20]; |
6704 static char ksmr_str[20]; | |
6705 static char ksmd_str[20]; | |
6706 | |
6707 /* | |
6708 * For Win32 console: update termcap codes for existing console attributes. | |
6709 */ | |
6710 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6711 update_tcap(int attr) |
7 | 6712 { |
6713 struct builtin_term *p; | |
6714 | |
6715 p = find_builtin_term(DEFAULT_TERM); | |
6716 sprintf(ksme_str, IF_EB("\033|%dm", ESC_STR "|%dm"), attr); | |
6717 sprintf(ksmd_str, IF_EB("\033|%dm", ESC_STR "|%dm"), | |
6718 attr | 0x08); /* FOREGROUND_INTENSITY */ | |
6719 sprintf(ksmr_str, IF_EB("\033|%dm", ESC_STR "|%dm"), | |
6720 ((attr & 0x0F) << 4) | ((attr & 0xF0) >> 4)); | |
6721 | |
6722 while (p->bt_string != NULL) | |
6723 { | |
6724 if (p->bt_entry == (int)KS_ME) | |
6725 p->bt_string = &ksme_str[0]; | |
6726 else if (p->bt_entry == (int)KS_MR) | |
6727 p->bt_string = &ksmr_str[0]; | |
6728 else if (p->bt_entry == (int)KS_MD) | |
6729 p->bt_string = &ksmd_str[0]; | |
6730 ++p; | |
6731 } | |
6732 } | |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6733 |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6734 # ifdef FEAT_TERMGUICOLORS |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6735 # define KSSIZE 20 |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6736 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
|
6737 { |
14806
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6738 int code; // value of KS_ |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6739 char *vtp; // code in vtp mode |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6740 char *vtp2; // code in vtp2 mode |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6741 char buf[KSSIZE]; // save buffer in non-vtp mode |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6742 char vbuf[KSSIZE]; // save buffer in vtp mode |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6743 char v2buf[KSSIZE]; // save buffer in vtp2 mode |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6744 char arr[KSSIZE]; // real buffer |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6745 }; |
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 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
|
6748 { |
14806
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6749 {(int)KS_ME, "\033|0m", "\033|0m"}, // normal |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6750 {(int)KS_MR, "\033|7m", "\033|7m"}, // reverse |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6751 {(int)KS_MD, "\033|1m", "\033|1m"}, // bold |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6752 {(int)KS_SO, "\033|91m", "\033|91m"}, // standout: bright red text |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6753 {(int)KS_SE, "\033|39m", "\033|39m"}, // standout end: default color |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6754 {(int)KS_CZH, "\033|95m", "\033|95m"}, // italic: bright magenta text |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6755 {(int)KS_CZR, "\033|0m", "\033|0m"}, // italic end |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6756 {(int)KS_US, "\033|4m", "\033|4m"}, // underscore |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6757 {(int)KS_UE, "\033|24m", "\033|24m"}, // underscore end |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6758 # ifdef TERMINFO |
14806
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6759 {(int)KS_CAB, "\033|%p1%db", "\033|%p14%dm"}, // set background color |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6760 {(int)KS_CAF, "\033|%p1%df", "\033|%p13%dm"}, // set foreground color |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
6761 {(int)KS_CS, "\033|%p1%d;%p2%dR", "\033|%p1%d;%p2%dR"}, |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
6762 {(int)KS_CSV, "\033|%p1%d;%p2%dV", "\033|%p1%d;%p2%dV"}, |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6763 # else |
14806
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6764 {(int)KS_CAB, "\033|%db", "\033|4%dm"}, // set background color |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6765 {(int)KS_CAF, "\033|%df", "\033|3%dm"}, // set foreground color |
15852
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
6766 {(int)KS_CS, "\033|%d;%dR", "\033|%d;%dR"}, |
acd4fc05422b
patch 8.1.0933: When using VTP scroll region isn't used properly
Bram Moolenaar <Bram@vim.org>
parents:
15782
diff
changeset
|
6767 {(int)KS_CSV, "\033|%d;%dV", "\033|%d;%dV"}, |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6768 # endif |
14806
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6769 {(int)KS_CCO, "256", "256"}, // colors |
7cc2d28778ac
patch 8.1.0415: not actually using 16 colors with vtp
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
6770 {(int)KS_NAME} // terminator |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6771 }; |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6772 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6773 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
|
6774 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
|
6775 char_u *name, |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6776 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
|
6777 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6778 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
|
6779 |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6780 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
|
6781 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
|
6782 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
|
6783 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
|
6784 } |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6785 # 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
|
6786 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6787 /* |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6788 * 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
|
6789 */ |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6790 void |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6791 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
|
6792 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6793 # ifdef FEAT_TERMGUICOLORS |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6794 static int init_done = FALSE; |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6795 static int curr_mode; |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6796 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
|
6797 struct builtin_term *bt; |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6798 int mode; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6799 enum |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6800 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6801 CMODEINDEX, |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6802 CMODE24, |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6803 CMODE256 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6804 }; |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6805 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6806 /* buffer initialization */ |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6807 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
|
6808 { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6809 for (ks = ks_tbl; ks->code != (int)KS_NAME; ks++) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6810 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6811 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
|
6812 if (bt != NULL) |
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6813 { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6814 STRNCPY(ks->buf, bt->bt_string, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6815 STRNCPY(ks->vbuf, ks->vtp, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6816 STRNCPY(ks->v2buf, ks->vtp2, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6817 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6818 STRNCPY(ks->arr, bt->bt_string, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6819 bt->bt_string = &ks->arr[0]; |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6820 } |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6821 } |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6822 init_done = TRUE; |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6823 curr_mode = CMODEINDEX; |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6824 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6825 |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6826 if (p_tgc) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6827 mode = CMODE24; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6828 else if (t_colors >= 256) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6829 mode = CMODE256; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6830 else |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6831 mode = CMODEINDEX; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6832 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6833 for (ks = ks_tbl; ks->code != (int)KS_NAME; ks++) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6834 { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6835 bt = find_first_tcap(DEFAULT_TERM, ks->code); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6836 if (bt != NULL) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6837 { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6838 switch (curr_mode) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6839 { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6840 case CMODEINDEX: |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6841 STRNCPY(&ks->buf[0], bt->bt_string, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6842 break; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6843 case CMODE24: |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6844 STRNCPY(&ks->vbuf[0], bt->bt_string, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6845 break; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6846 default: |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6847 STRNCPY(&ks->v2buf[0], bt->bt_string, KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6848 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6849 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6850 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6851 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6852 if (mode != curr_mode) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6853 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6854 for (ks = ks_tbl; ks->code != (int)KS_NAME; ks++) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6855 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6856 bt = find_first_tcap(DEFAULT_TERM, ks->code); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6857 if (bt != NULL) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6858 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6859 switch (mode) |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6860 { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6861 case CMODEINDEX: |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6862 STRNCPY(bt->bt_string, &ks->buf[0], KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6863 break; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6864 case CMODE24: |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6865 STRNCPY(bt->bt_string, &ks->vbuf[0], KSSIZE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6866 break; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6867 default: |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6868 STRNCPY(bt->bt_string, &ks->v2buf[0], KSSIZE); |
13316
de19318319a6
patch 8.0.1532: compiler warnings without termguicolors feature
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
6869 } |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6870 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6871 } |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6872 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
6873 curr_mode = mode; |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6874 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6875 # endif |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6876 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
6877 |
7 | 6878 #endif |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6879 |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
9025
diff
changeset
|
6880 #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
|
6881 static int |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6882 hex_digit(int c) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6883 { |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6884 if (isdigit(c)) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6885 return c - '0'; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6886 c = TOLOWER_ASC(c); |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6887 if (c >= 'a' && c <= 'f') |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6888 return c - 'a' + 10; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6889 return 0x1ffffff; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6890 } |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6891 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6892 guicolor_T |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6893 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
|
6894 { |
10512
675dfe47ab69
commit https://github.com/vim/vim/commit/287266527abc163e191a06dd70518bbbdab4468f
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
6895 /* 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
|
6896 * 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
|
6897 * MS-Windows GDI builds. */ |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15852
diff
changeset
|
6898 # if defined(RGB) && defined(MSWIN) && !defined(FEAT_GUI) |
10512
675dfe47ab69
commit https://github.com/vim/vim/commit/287266527abc163e191a06dd70518bbbdab4468f
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
6899 # undef RGB |
675dfe47ab69
commit https://github.com/vim/vim/commit/287266527abc163e191a06dd70518bbbdab4468f
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
6900 # endif |
9021
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6901 # ifndef RGB |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6902 # 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
|
6903 # endif |
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6904 # define LINE_LEN 100 |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6905 FILE *fd; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6906 char line[LINE_LEN]; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6907 char_u *fname; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6908 int r, g, b, i; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6909 guicolor_T color; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6910 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6911 struct rgbcolor_table_S { |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6912 char_u *color_name; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6913 guicolor_T color; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6914 }; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6915 |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6916 /* 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
|
6917 * 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
|
6918 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
|
6919 {(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
|
6920 {(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
|
6921 {(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
|
6922 {(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
|
6923 {(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
|
6924 {(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
|
6925 {(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
|
6926 {(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
|
6927 {(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
|
6928 {(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
|
6929 {(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
|
6930 {(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
|
6931 {(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
|
6932 {(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
|
6933 {(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
|
6934 {(char_u *)"grey40", RGB(0x66, 0x66, 0x66)}, |
13489
24e8f9044bed
patch 8.0.1618: color Grey50 is missing in the compiled-in table
Christian Brabandt <cb@256bit.org>
parents:
13406
diff
changeset
|
6935 {(char_u *)"grey50", RGB(0x7F, 0x7F, 0x7F)}, |
9601
9cc49b86f613
commit https://github.com/vim/vim/commit/ca8942c6e331a69ddd533dd78931f399f7dcaa79
Christian Brabandt <cb@256bit.org>
parents:
9591
diff
changeset
|
6936 {(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
|
6937 {(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
|
6938 {(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
|
6939 {(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
|
6940 {(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
|
6941 {(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
|
6942 {(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
|
6943 {(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
|
6944 {(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
|
6945 {(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
|
6946 {(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
|
6947 {(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
|
6948 {(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
|
6949 {(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
|
6950 }; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6951 |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6952 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
|
6953 static int size = 0; |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6954 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6955 if (name[0] == '#' && STRLEN(name) == 7) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6956 { |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6957 /* Name is in "#rrggbb" format */ |
9021
bb6ca6366085
commit https://github.com/vim/vim/commit/283ee8b3a07b9da18f6c73f35cf465b83f96406a
Christian Brabandt <cb@256bit.org>
parents:
9019
diff
changeset
|
6958 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
|
6959 ((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
|
6960 ((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
|
6961 if (color > 0xffffff) |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6962 return INVALCOLOR; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6963 return color; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6964 } |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6965 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6966 /* 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
|
6967 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
|
6968 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
|
6969 return rgb_table[i].color; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6970 |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6971 /* |
15782
5de143c7cd76
patch 8.1.0898: a messed up rgb.txt can crash Vim
Bram Moolenaar <Bram@vim.org>
parents:
15605
diff
changeset
|
6972 * Last attempt. Look in the file "$VIMRUNTIME/rgb.txt". |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6973 */ |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6974 if (size == 0) |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
6975 { |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6976 int counting; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6977 |
15782
5de143c7cd76
patch 8.1.0898: a messed up rgb.txt can crash Vim
Bram Moolenaar <Bram@vim.org>
parents:
15605
diff
changeset
|
6978 // colornames_table not yet initialized |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6979 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
|
6980 if (fname == NULL) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6981 return INVALCOLOR; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6982 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6983 fd = fopen((char *)fname, "rt"); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6984 vim_free(fname); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6985 if (fd == NULL) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6986 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6987 if (p_verbose > 1) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6988 verb_msg(_("Cannot open $VIMRUNTIME/rgb.txt")); |
15782
5de143c7cd76
patch 8.1.0898: a messed up rgb.txt can crash Vim
Bram Moolenaar <Bram@vim.org>
parents:
15605
diff
changeset
|
6989 size = -1; // don't try again |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6990 return INVALCOLOR; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6991 } |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6992 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6993 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
|
6994 { |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6995 if (!counting) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6996 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6997 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
|
6998 (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
|
6999 if (colornames_table == NULL) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7000 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7001 fclose(fd); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7002 return INVALCOLOR; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7003 } |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7004 rewind(fd); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7005 } |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7006 size = 0; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7007 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7008 while (!feof(fd)) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7009 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7010 size_t len; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7011 int pos; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7012 |
14730
193471015e1a
patch 8.1.0377: xdiff doesn't use the Vim memory allocation functions
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
7013 vim_ignoredp = fgets(line, LINE_LEN, fd); |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7014 len = strlen(line); |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7015 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7016 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
|
7017 continue; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7018 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7019 line[len - 1] = '\0'; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7020 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7021 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
|
7022 if (i != 3) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7023 continue; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7024 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7025 if (!counting) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7026 { |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7027 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
|
7028 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7029 if (s == NULL) |
9628
fefd0551aa9d
commit https://github.com/vim/vim/commit/2e45d21c819272051f7ef4436f483e4b2ecfb369
Christian Brabandt <cb@256bit.org>
parents:
9601
diff
changeset
|
7030 { |
fefd0551aa9d
commit https://github.com/vim/vim/commit/2e45d21c819272051f7ef4436f483e4b2ecfb369
Christian Brabandt <cb@256bit.org>
parents:
9601
diff
changeset
|
7031 fclose(fd); |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7032 return INVALCOLOR; |
9628
fefd0551aa9d
commit https://github.com/vim/vim/commit/2e45d21c819272051f7ef4436f483e4b2ecfb369
Christian Brabandt <cb@256bit.org>
parents:
9601
diff
changeset
|
7033 } |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7034 colornames_table[size].color_name = s; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7035 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
|
7036 } |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7037 size++; |
15782
5de143c7cd76
patch 8.1.0898: a messed up rgb.txt can crash Vim
Bram Moolenaar <Bram@vim.org>
parents:
15605
diff
changeset
|
7038 |
5de143c7cd76
patch 8.1.0898: a messed up rgb.txt can crash Vim
Bram Moolenaar <Bram@vim.org>
parents:
15605
diff
changeset
|
7039 // The distributed rgb.txt has less than 1000 entries. Limit to |
5de143c7cd76
patch 8.1.0898: a messed up rgb.txt can crash Vim
Bram Moolenaar <Bram@vim.org>
parents:
15605
diff
changeset
|
7040 // 10000, just in case the file was messed up. |
5de143c7cd76
patch 8.1.0898: a messed up rgb.txt can crash Vim
Bram Moolenaar <Bram@vim.org>
parents:
15605
diff
changeset
|
7041 if (size == 10000) |
5de143c7cd76
patch 8.1.0898: a messed up rgb.txt can crash Vim
Bram Moolenaar <Bram@vim.org>
parents:
15605
diff
changeset
|
7042 break; |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7043 } |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
7044 } |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7045 fclose(fd); |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
7046 } |
9591
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7047 |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7048 for (i = 0; i < size; i++) |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7049 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
|
7050 return colornames_table[i].color; |
201773c00b96
commit https://github.com/vim/vim/commit/68015bbd846181d49842d6ef60246c4195d20b89
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7051 |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
7052 return INVALCOLOR; |
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
7053 } |
11745
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11739
diff
changeset
|
7054 |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11739
diff
changeset
|
7055 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
|
7056 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
|
7057 { |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11739
diff
changeset
|
7058 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
|
7059 |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11739
diff
changeset
|
7060 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
|
7061 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
|
7062 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
|
7063 } |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
9001
diff
changeset
|
7064 #endif |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7065 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15852
diff
changeset
|
7066 #if (defined(MSWIN) && !defined(FEAT_GUI_MSWIN)) || defined(FEAT_TERMINAL) \ |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7067 || defined(PROTO) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7068 static int cube_value[] = { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7069 0x00, 0x5F, 0x87, 0xAF, 0xD7, 0xFF |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7070 }; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7071 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7072 static int grey_ramp[] = { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7073 0x08, 0x12, 0x1C, 0x26, 0x30, 0x3A, 0x44, 0x4E, 0x58, 0x62, 0x6C, 0x76, |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7074 0x80, 0x8A, 0x94, 0x9E, 0xA8, 0xB2, 0xBC, 0xC6, 0xD0, 0xDA, 0xE4, 0xEE |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7075 }; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7076 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7077 # ifdef FEAT_TERMINAL |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7078 # include "libvterm/include/vterm.h" // for VTERM_ANSI_INDEX_NONE |
13827
27e09f1a8e5c
patch 8.0.1785: missing symbol in Win32 small build
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
7079 # else |
27e09f1a8e5c
patch 8.0.1785: missing symbol in Win32 small build
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
7080 # define VTERM_ANSI_INDEX_NONE 0 |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7081 # endif |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7082 |
13839
ca8953d36264
patch 8.0.1791: using uint8_t does not work everywhere
Christian Brabandt <cb@256bit.org>
parents:
13827
diff
changeset
|
7083 static char_u ansi_table[16][4] = { |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7084 // R G B idx |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7085 { 0, 0, 0, 1}, // black |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7086 {224, 0, 0, 2}, // dark red |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7087 { 0, 224, 0, 3}, // dark green |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7088 {224, 224, 0, 4}, // dark yellow / brown |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7089 { 0, 0, 224, 5}, // dark blue |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7090 {224, 0, 224, 6}, // dark magenta |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7091 { 0, 224, 224, 7}, // dark cyan |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7092 {224, 224, 224, 8}, // light grey |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7093 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7094 {128, 128, 128, 9}, // dark grey |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7095 {255, 64, 64, 10}, // light red |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7096 { 64, 255, 64, 11}, // light green |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7097 {255, 255, 64, 12}, // yellow |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7098 { 64, 64, 255, 13}, // light blue |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7099 {255, 64, 255, 14}, // light magenta |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7100 { 64, 255, 255, 15}, // light cyan |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7101 {255, 255, 255, 16}, // white |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7102 }; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7103 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7104 void |
13839
ca8953d36264
patch 8.0.1791: using uint8_t does not work everywhere
Christian Brabandt <cb@256bit.org>
parents:
13827
diff
changeset
|
7105 cterm_color2rgb(int nr, char_u *r, char_u *g, char_u *b, char_u *ansi_idx) |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7106 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7107 int idx; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7108 |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7109 if (nr < 16) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7110 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7111 *r = ansi_table[nr][0]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7112 *g = ansi_table[nr][1]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7113 *b = ansi_table[nr][2]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7114 *ansi_idx = ansi_table[nr][3]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7115 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7116 else if (nr < 232) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7117 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7118 /* 216 color cube */ |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7119 idx = nr - 16; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7120 *r = cube_value[idx / 36 % 6]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7121 *g = cube_value[idx / 6 % 6]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7122 *b = cube_value[idx % 6]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7123 *ansi_idx = VTERM_ANSI_INDEX_NONE; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7124 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7125 else if (nr < 256) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7126 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7127 /* 24 grey scale ramp */ |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7128 idx = nr - 232; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7129 *r = grey_ramp[idx]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7130 *g = grey_ramp[idx]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7131 *b = grey_ramp[idx]; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7132 *ansi_idx = VTERM_ANSI_INDEX_NONE; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7133 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7134 else |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7135 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7136 *r = 0; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7137 *g = 0; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7138 *b = 0; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7139 *ansi_idx = 0; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7140 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7141 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13780
diff
changeset
|
7142 #endif |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15852
diff
changeset
|
7143 |