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