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